如何使用adb授权或adb撤销? [英] How do I use adb grant or adb revoke?

查看:621
本文介绍了如何使用adb授权或adb撤销?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android文档包含对adb grant和adb revoke命令的以下描述。

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

grant <PACKAGE_PERMISSION>

授予应用程序权限。

revoke <PACKAGE_PERMISSION>

撤消对应用程序的权限。

Revoke permissions to applications. Only optional permissions the application has declared can be revoked.

有人可以举一个使用它们的正确语法的例子吗?

我认为这将是 android.permission.WRITE_EXTERNAL_STORAGE 之类的权限,或者可能只是 WRITE_EXTERNAL_STORAGE 。好吧,我尝试了这些,还有其他几个尝试,但我无法使其正常工作。

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)

推荐答案

要添加:

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

要删除:

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

此更改在Android M发行版中有所更改,因此在Lollipop中(最初在撰写本文时(答案为写作时间),您需要先执行 adb shell

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






完整的权限列表可以找到此处。如果您有 Android构建工具设置后,您可以查看该应用程序正在使用的权限。第一次使用


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

然后获取权限:

aapt d permissions path/to/app/on/computer.apk

这篇关于如何使用adb授权或adb撤销?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆