Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attempt to change component state security exception in android

hi i am working in framework side implementing one test app to disable another app but when i run my test app it is showing

Java.lang.SecurityException: Permission Denial: attempt to change component state from pid=xxx,uid=xxxx,package uid=xxx
at xxxxxxxx

my java code

PackageManager pm = getApplicationContext().getPackagemanager();
pm.setComponentEnabledSetting(new ComponentName("com.example","MainActivity"),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,PackageManager.DONT_KILL_APP);

AndroidManifest.xml

<uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE>

i have tried above permission with both (Permission is only granted to system apps) and also tried tag but no lucky

how to use system apps granted permission,

Could you please guys help me to resolve this issue

Thanks in advance

like image 323
Aswan Avatar asked Mar 09 '14 03:03

Aswan


2 Answers

If you application is not a part of the system partition, then you will not be granted the permission. Get the app into the system partition and confirm that the PackageManager upon parsing your app during the dexopt grants you your desired permission.

like image 196
JoxTraex Avatar answered Sep 30 '22 19:09

JoxTraex


You can not Enable/disable app unless your app is system app

like image 40
Pampapathi Avatar answered Sep 30 '22 19:09

Pampapathi