How to use adb grant or adb revoke?

The Android documentation contains the following description of the adb grant and adb revoke commands.

grant <PACKAGE_PERMISSION> 

Grant application permissions. Only additional permissions stated by expression may be granted.

 revoke <PACKAGE_PERMISSION> 

Revoke permissions for applications. Only optional permissions declared by an expression can be revoked.

Can someone provide an example of the correct syntax for using them?

I assume this will be a permission like android.permission.WRITE_EXTERNAL_STORAGE or maybe just WRITE_EXTERNAL_STORAGE . Well, I tried this, and several others, and I can't get it to work.

I also tried (to no avail) several combinations of the package and resolution, which makes more sense to me (this sounds like a command that will change the resolution to one package, not all)

+41
android android permissions adb
source share
3 answers

Add:

 adb shell pm grant com.name.app android.permission.READ_PROFILE 

Delete:

 adb shell pm revoke com.name.app android.permission.READ_PROFILE 

This has changed in the release of Android M, so in Lollipop (at the initial time of writing the answer) you first had to make an adb shell .

 adb shell pm grant com.name.app android.permission.READ_PROFILE 

A complete list of permissions can be found here . If you have Android build tools configured, you can see what permissions the application uses. First use

 adb shell pm list packages -f 

Then copy the package to your computer:

 adb pull /path/to/package/from/previous/step.apk 

Then get permissions:

 aapt d permissions path/to/app/on/computer.apk 
+61
source share

If you don’t know the name of the permission or want to remove all permissions, you can use

 adb shell pm reset-permissions your.package.name 
+5
source share

So, a little command line (mac / linux) to give your application all the permissions it needs from the command line.

 aapt d permissions ./path/to/your.apk \ | sed -n \ -e "s/'//g" \ -e "/^uses-permission: name=android.permission\./s/^[^=]*=//p" \ | xargs -n 1 adb shell pm grant com.your.package 
+3
source share

All Articles