Permission Denied while sending <protected-broadcast> from an app in /System/app

1.1k Views Asked by At

I am getting:

java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.TIME_SET from pid=xxxxx, uid=xxxxx

for:

Intent timeChanged = new Intent(Intent.ACTION_TIME_CHANGED);
sendBroadcast(timeChanged);

even when I have put my app in /system/app folder. Please help me out to know why this is happening?

2

There are 2 best solutions below

0
Vitaliy On

Try putting the app in the priv-app folder in the system partition, and adding the app to the privapp-permissions.xml file on the same partition, with the TIME_SET permission.

0
Edw590 On

Please come here: Permission Denial of android.intent.action.REBOOT for APP in /system/priv-app. To get the most recent version of the code, just replace "android-5.1.1_r20" with "master").

It seems the app must be a persistent app, which can be done by setting the persistent flag to true on the Application tag of the Manifest. Either that, or have a UserId whitelisted, which is also on the code (though, sharedUserId is deprecated as of API 29, so might not be a good idea to use that way).