1

In Android SDK, I know I can use adb shell to grant my app location access permission by command:

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

Now, my app also needs VPN permission like this one: enter image description here

How can I grant my app VPN connection permission the same way as how I did for location permission with adb command?

3
  • are you talking about android.permission.BIND_VPN_SERVICE permission ? Commented Aug 29, 2016 at 14:51
  • @NishantPardamwar, maybe, I am not sure about the permission string for the dialog I am showing in my question, that's why I ask here
    – Leem.fin
    Commented Aug 29, 2016 at 14:56
  • I dont think this will work, but have you tried adb shell pm grant com.xyz.myapp android.permission.BIND_VPN_SERVICE ?
    – Shark
    Commented Jan 5, 2023 at 15:46

1 Answer 1

3

The permission you require is android.permission.BIND_VPN_SERVICE, and this permission has signature protection level. 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 intent = VpnService.prepare(v.getContext());
if (intent != null) {
    startActivityForResult(intent, 0);
} else {
    onActivityResult(RESULT_OK, 0, null);
}

More information, see the documentation here.

Not the answer you're looking for? Browse other questions tagged or ask your own question.