The Android documentation contains the following description of the adb grant and adb revoke commands.
grant <PACKAGE_PERMISSION>
Grant permissions to applications. Only optional permissions the application has declared can be granted.
revoke <PACKAGE_PERMISSION>
Revoke permissions to applications. Only optional permissions the application has declared can be revoked.
Can anybody please give an example of the correct syntax to use them?
I assume that would be a permission like android.permission.WRITE_EXTERNAL_STORAGE
, or perhaps just WRITE_EXTERNAL_STORAGE
. Well I tried those, and several others and I cannot get it to work.
I also tried (to no avail) several combinations of package and permission, which makes more sense to me (this sounds like a command that would modify a permission on one package, not all)
To revoke permissions(s) we can use the adb shell pm revoke <package> <permission> command. Note: When we install an application with the adb install <apk> command, we can add the -g parameter, and all permissions for the application will be granted.
To Add:
adb shell pm grant com.name.app android.permission.READ_PROFILE
To Remove:
adb shell pm revoke com.name.app android.permission.READ_PROFILE
This changed at the release of Android M, so in Lollipop (at original time of writing answer) you needed to do adb shell
first.
adb shell pm grant com.name.app android.permission.READ_PROFILE
A full list of permissions can be found here. If you have android build tools set up you can see what permissions the app is using. First use
adb shell pm list packages -f
Then copy the package to you computer:
adb pull /path/to/package/from/previous/step.apk
Then get permissions:
aapt d permissions path/to/app/on/computer.apk
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With