Rohit
Rohit

Reputation: 516

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

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?

Upvotes: 2

Views: 1486

Answers (2)

Edw590
Edw590

Reputation: 515

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).

Upvotes: 0

Vitaliy
Vitaliy

Reputation: 411

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.

Upvotes: 0

Related Questions