How do I use adb grant or adb revoke?

≡放荡痞女 提交于 2019-11-29 20:36:38

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 happen to not know the name of permission or want to clear all permissions you can use

adb shell pm reset-permissions your.package.name 

So here's a little command line (mac/linux) to grant your app all of the permissions it requires 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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!