Reputation: 71
I am testing a mobile device management app and would like to grant permission using adb. I have seen several posts where the following is suggested:
adb shell pm grant [package_name] android.permission.WRITE_SECURE_SETTINGS
or
adb shell pm grant [package_name] android.permission.READ_PROFILE
Neither of these have worked for me. For 'READ_PROFILE' I got a return of "Operation not allowed:java.lang.SecurityException: Package #{App_Name} has not requested permission android.permission.READ_PROFILE"
While for 'WRITE_SECURE_SETTINGS', no message got returned. I tried both on M and L.
Upvotes: 1
Views: 2078
Reputation: 753
You can't grant permission if it is not requested in AndroidManifest.xml First you need to add the permission in AndroidManifest.xml as
<uses-permission android:name="android.permission.READ_PROFILE"
Then you can grant the permission from adb because due to security reasons you can't simply grant the permissions from adb without adding the permission in the AndroidManifest.xml
Upvotes: 1