Permission: INJECT_EVENTS for Instrumenation to other apps
Asked Answered
O

1

6

I know that this is not the first Thread about this permission, however the other ones aren't finished or don't help me.

What I need is to inflate KeyEvents using Instrumentation. That works great and is insanely faster than the shell ("input keyevent ") method. But if I want to inject to other apps I catch a SecurityException. That didn't surprise me to much so I added <uses-permission android:name="android.permission.INJECT_EVENTS" /> to my manifest. Eclipse stops to debug this telling me that only system apps can use this permission. So I compiled using the signed apk tool and pushed that apk to /system/app. Rebooted, and guess what

W/PackageManager( 3499): Not granting permission android.permission.INJECT_EVENTS to package com.<....> (protectionLevel=2 flags=0x8be45) 

The app is targeted for only one special device. So I know all the specs and it is rooted. But su injection-commands take to long and SuperUser is required. I would love to do that with Instrumentation or maybe there is something else I should try?

The firmware is not written by me, so I don't have the platform key.

Thanks for your help!

EDIT: Got the platform keys (The dev used the normal Google ones), signed and aligned, then pushed the apk to /system/app. Also added android:sharedUserId="android.uid.system" to my manifest. On Boot there is no longer the logcat message. However when I want to send the keysync I still catche the SecurityException. Any ideas?

EDIT2: Here is an excerpt from ps. Seems like the package ist not listed as system

u0_a108   5241  2399  492044 48968 ffffffff 40113ab0 S com.mypackage
Osmo answered 19/1, 2013 at 3:47 Comment(0)
O
3

Update

Use the signtool located here, then go ahead and read on in my blog.

Ok, I got the right platform-keys and it works like a charm now! I signed using http://forum.xda-developers.com/showthread.php?t=1125626 and replaced (renamed the sign.... to testkey....) the testkeys inside signare folder with

signapk-key.platform.x509.pem
signapk-key.platform.pk8

(Google for them)

Also make sure to zipalign and then to copy to /system/app. Installing the .apk the normal way is NOT possible as it is flagged as System app.

Osmo answered 20/1, 2013 at 3:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.