View Single Post
      10-18-2019, 03:36 AM   #712
Firefly1337
Second Lieutenant
Firefly1337's Avatar
Germany
846
Rep
280
Posts

Drives: F20 M135i LCI
Join Date: Aug 2019
Location: Germany

iTrader: (0)

Since we are discussing development, I could use some input (quite literally )

I wrote a small App that just starts as a foreground service and listens to incoming broadcasts. It checks which broadcast and content (the Integer) was received and translates it to proper KeyEvent values.
E.g. KEYCODE_ENTER = 66.

I am currently trying to figure out how to communicate that to the system, i.e. make the actual input.
If you interact with your own view (say you make your own launcher) then it's fine. But if you want to interfere with other apps, it gets complicated.

In general you need to be rooted.
This is the simplest method:
Code:
shell# input keyevent <code>
This works just fine but is very slow. It has a ~1 second delay between inputs, i.e. it is not really usable for normal iDrive controller usage. Imagine scrolling through 15 apps, you'd need 15 seconds for that.

A better function is hidden in the Android Hardware API.
The class is 'InputManager' and the method 'injectInputEvent'.
However, this requires the permission 'android.permission.INJECT_EVENTS' which is only granted to system apps.
As far as I know, to make a system app it needs to be signed with the same signature/key as the OS (which we don't have). Is there any way around that?

I tried to call the method using Xposed, but official development apparently stopped and now there is EdXposed, which has zero guides on how to develop. I couldn't get it to work yesterday, I will try again over the weekend.
Bear in mind, I still don't have my unit and am developing on my phone at home.

Any other methods I might have missed?
Appreciate 0