android - BroadcastReceiver permission for adb shell -


consider simple tool using broadcastreceiver achieve simple goal. because should not used other applications, defines permission protectionlevel of signature or signatureorsystem:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="any.test">      <permission         android:name="any.test.permission"         android:protectionlevel="signatureorsystem" />      <application android:label="anytest">         <receiver             android:name=".receiver"             android:exported="true"             android:permission="any.test.permission" />     </application> </manifest> 

now i'd test sending broadcasts via

adb shell broadcast -n any.test/.receiver 

from computer. while works fine on emulator, doesn't work @ on real device when permission set. if permission not set, works intended.

so how can define or grant permission can test on real device adb?

i want make exported receiver little more secure in debug mode, if there's special permission adb usage or run-time test allow calls adb can implement in receiver.onreceive(context, intent), too. receiver doesn't have work adb , other apps @ same time.

a root shell can send broadcast protected permissions.
normal shell has been granted lots of permissions, check file in aosp souce code: frameworks\base\packages\shell\androidmanifest.xml.

replace any.test.permission 1 permission in file protectionlevel signatureorsystem, android.permission.real_get_tasks. after that, can send broadcast receiver in shell, other 3rd app can not.


Comments