[Ed: This is a repost from LQ. Didn't know if this topic was 'Advanced' or 'Dev', so please move if necessary.]

Hi!

In order to automatically switch to Wifi Keyboard as my current input method when plugging my phone (Atrix, Android 2.2.2) into my computer, I am looking to circumvent the security restrictions normally preventing that. Normally, applications are not given the permission to change input methods due to them being in control of the system, possibly with malicious intent.

Now, my phone is rooted, and root shall be your god, so this must be possible. To further complicate matters, I am trying to acieve this through Tasker (which does not know about root), as it already provides the several other tasks I want to achieve and can trigger them in any context imaginable. It is, however, able to run scripts - so if there is a way to sudo or similar, I'm set.

Google gave me this page: http://developer.android.com/referen...odManager.html

It says, among other things, the following:

The input method manager as expressed by this class is the central point of the system that manages interaction between all other parts. It is expressed as the client-side API here which exists in each application context and communicates with a global system service that manages the interaction across all processes.

An input method (IME) implements a particular interaction model allowing the user to generate text. The system binds to the current input method that is use, causing it to be created and run, and tells it when to hide and show its UI. Only one IME is running at a time.

Multiple client applications arbitrate with the input method manager for input focus and control over the state of the IME. Only one such client is ever active (working with the IME) at a time.
Only the system is allowed to directly access an IME's InputMethod interface, via the BIND_INPUT_METHOD permission. This is enforced in the system by not binding to an input method service that does not require this permission, so the system can guarantee no other untrusted clients are accessing the current input method outside of its control.
A client application can ask that the system let the user pick a new IME, but can not programmatically switch to one itself. This avoids malicious applications from switching the user to their own IME, which remains running when the user navigates away to another application. An IME, on the other hand, is allowed to programmatically switch the system to another IME, since it already has full control of user input.
The identification of the current IME is represented by this:

IBinder imeToken Supplies the identifying token given to an input method when it was started, which allows it to perform this operation on itself.
I take from this that I either have to
a) gimme that BIND_INPUT_METHOD permission,
b) remove that whole restriction at least temporarily,
c) impersonate being the currently active IME by taking the imeToken away or
d) tell the IME that it should switch to another one.

Unfortunately, my programming experience is limited to C (on microcontrollers...), Python and PHP, and never have I worked in such a large-scale project, only in small ones for personal or limited use. So, well, I have no idea how to achieve any of these goals.

Could any Android-proficient programmer tell me if what I want to do is even possible, and if so, how? I don't need the full code, if there is much to it, but rather some directions, altough I certainly would not mind it

Thanks a bunch for any advice in advance!
V