Android INJECT_EVENTS permission
Actually, this is pretty simple on a rooted device. I think any app that is running off /system will get access to whatever permissions it requires. So simply manually install your App to /system (as described here http://androidforums.com/droid-all-things-root/64603-installing-apk-system-app-directory.html ):
Execute the following commands in the terminal emulator to remount the /system directory as read/write and to install the application into the /system/app directory from the SDCARD:
su
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
cp /sdcard/APP.apk /system/app
If you prefer to use adb from your computer, execute these commands:
adb remount
adb shell cp /sdcard/APP.apk /system/app
Several users have utilized root explorer from the Google marketplace to simplify this process.
Alternatively, check this out: How to compile Android Application with system permissions
Is it possible to grant INJECT_EVENTS permission to an app for dev/testing purposes
The adb shell is not a SU user. use the RunTime to inject shell commands as SU. Use any tool to grant you SU privileges, then execute your command
Process suProcess = Runtime.getRuntime().exec("su pm grant 'app package' android.permission.INJECT_EVENTS");
suProcess.waitFor();
INJECT_EVENTS permission not granted to privileged app
At least in current versions of Android, INJECT_EVENTS
is a signature
-level permission:
<permission android:name="android.permission.INJECT_EVENTS"
android:protectionLevel="signature" />
(from the current master
branch of the framework manifest)
Your app would need to be signed by the signing key that signed the firmware. Mostly, this is for device manufacturers or custom ROM developers.
Android “Injecting to another application requires INJECT_EVENTS permission”
Is there any solution to fix this without root permission
No, you cannot hold this permission on non-rooted device as this permission is signature based.
android.permission.INJECT_EVENTS
Allows an application to inject user events (keys, touch, trackball)
into the event stream and deliver them to ANY window. Without this
permission, you can only deliver events to windows in your own
process.Not for use by third-party applications
https://github.com/aosp-mirror/platform_frameworks_base/blob/master/core/res/AndroidManifest.xml#L2515
But it still error application requires INJECT_EVENTS permission
This permission is granted to system apps. 3rd party cannot have it. Unless you sign your app with system certificate, you will not be granted INJECT_EVENTS
permission.
Docs here read:
Allows an application to inject user events (keys, touch, trackball)
into the event stream and deliver them to ANY window. Without this
permission, you can only deliver events to windows in your own
process.Not for use by third-party applications.
Injecting to another application requires INJECT_EVENTS permission Android
I found a solution. Try using mediarecorder using this video: https://www.youtube.com/watch?v=69J2ycNCtpE
Permission: INJECT_EVENTS for Instrumenation to other apps
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.
Related Topics
Error:Execution Failed for Task ':Android:Transformclassesandresourceswithproguardforrelease'
Play Audio File from the Assets Directory
How to Determine Device Screen Size Category (Small, Normal, Large, Xlarge) Using Code
How to Resize a Custom View Programmatically
Unsupportedoperationexception: Can't Convert to Dimension: Type=0X1
Appcompat V7 R21 Returning Error in Values.Xml
Turn Off Autosuggest for Edittext
How to Change the Android Actionbar Title and Icon
How to Find the Data Usage on a Per-Application Basis on Android
How to Zip and Unzip a String Using Gzipoutputstream That Is Compatible with .Net
Get the Current Language in Device
Capture Screen Shot of Googlemap Android API V2
Border for an Image View in Android
How Does One Use Glide to Download an Image into a Bitmap
Strange Behavior with Android Orientation Sensor
How to Prevent an Android Device from Going to Sleep Programmatically
Converting JSONarray to Arraylist
Android Locationclient Class Is Deprecated But Used in Documentation