-1

This isn't the same as the ones an app has been currently granted - that might be a subset of the ones it would like in total.

This shows how to get the currently granted set. Before Android M, that's the full set because it wouldn't have been installed unless the user had granted all of the ones it wanted. Under Android M however, the user can choose which to grant, and change at any time after installation. I'd like the full set an app would like as listed in it's manifest.

Community
  • 1
  • 1
Carl Whalley
  • 3,011
  • 8
  • 33
  • 48
  • 3
    Your question is unclear, could you clarify what you are looking for? – SaschaM78 Jan 15 '16 at 11:26
  • You can get the full set. But the user can always alt-tab and revoke some of the permissions he granted you earlier, and toggle them as he likes. – Shark Jan 15 '16 at 11:34
  • 1
    "This shows how to get the currently granted set" -- I would expect `GET_PERMISSIONS` to return all that are in the manifest, regardless of whether the user granted them or not. [The `requestedPermissions` field](http://developer.android.com/reference/android/content/pm/PackageInfo.html#requestedPermissions) is documented as "This list includes all permissions requested, even those that were not granted or known by the system at install time." A separate `requestedPermissionsFlags` has the grant status. Do you have evidence to the contrary? – CommonsWare Jan 15 '16 at 12:19
  • I've no evidence either way, just trying various tests on M and pre-M devices. What you say sounds about right, thanks. – Carl Whalley Jan 15 '16 at 16:12

2 Answers2

1

As @CommonsWare commented, PackageInfo.requestedPermissions contains an "Array of all <uses-permission> tags included under <manifest>, or null if there were none."

I've tested this on a device running Android M, and the output I got included the permissions from all <uses-permission> tags regardless of whether those permissions had been granted or not, just as expected.

A minimal example for testing this:

try {
    PackageInfo pi = getPackageManager().getPackageInfo("com.example.foo", PackageManager.GET_PERMISSIONS);
    for (String perm : pi.requestedPermissions) {
        Log.e("Foo", perm);
    }
} catch (Exception e) {
}
Michael
  • 57,169
  • 9
  • 80
  • 125
0

adb shell dumpsys package packagename will give you the permissions info requested by the app with packagename

ashkhn
  • 1,642
  • 1
  • 13
  • 18