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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Leem.fin
  • 40,781
  • 83
  • 202
  • 354
  • are you talking about **android.permission.BIND_VPN_SERVICE** permission ? – Nishant Pardamwar Aug 29 '16 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 Aug 29 '16 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 Jan 05 '23 at 15:46

1 Answers1

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.

alijandro
  • 11,627
  • 2
  • 58
  • 74