简体   繁体   English

通过 adb shell 命令授予我的应用权限

[英]grant my app permission through adb shell command

In Android SDK, I know I can use adb shell to grant my app location access permission by command:在 Android SDK 中,我知道我可以使用adb shell通过命令授予我的应用位置访问权限:

adb shell pm grant com.xyz.myapp android.permission.ACCESS_FINE_LOCATION

Now, my app also needs VPN permission like this one:现在,我的应用程序还需要像这样的 VPN 权限: 在此处输入图像描述

How can I grant my app VPN connection permission the same way as how I did for location permission with adb command?如何授予我的应用程序 VPN 连接权限,就像我使用adb命令授予位置权限一样?

The permission you require is android.permission.BIND_VPN_SERVICE , and this permission has signature protection level.你需要的权限是android.permission.BIND_VPN_SERVICE ,这个权限有signature保护级别。 It can only be acquired by system application.只能通过系统应用获取。

The dialog popup in you picture is not an usual permission grant dialog.您图片中的弹出对话框不是通常的权限授予对话框。

It's created by the following code, a Intent to system activity.它是由以下代码创建的,一个Intent to system activity。

Intent intent = VpnService.prepare(v.getContext());
if (intent != null) {
    startActivityForResult(intent, 0);
} else {
    onActivityResult(RESULT_OK, 0, null);
}

More information, see the documentation here .更多信息,请参阅此处的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM