I'm trying to investigate what an app at the office needs to change about its permissions, in order to support Android 6 nicely.
I've found which permission needs confirmation and which isn't, except for one :
<uses-permission android:name=".permission.C2D_MESSAGE"/>
It seems that this permission isn't mentioned anywhere that I look for, as one that's not granted automatically and yet I can't find where the user can enable it as a confirmation.
In order to find which permissions are granted by default and which aren't , I just called this code:
private void checkPermissionsOfApp(String packageName) {
PackageManager pm = getPackageManager();
try {
final ApplicationInfo applicationInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
Log.d("AppLog", "Listing all permissions of app with PackageName: " + applicationInfo.packageName);
PackageInfo packageInfo = pm.getPackageInfo(applicationInfo.packageName, PackageManager.GET_PERMISSIONS);
//Get Permissions
String[] requestedPermissions = packageInfo.requestedPermissions;
if (requestedPermissions != null) {
for (String permission : requestedPermissions) {
boolean permissionGranted = pm.checkPermission(permission, packageName) == PackageManager.PERMISSION_GRANTED;
Log.d("AppLog", "permission:" + permission + " permissionGranted:" + permissionGranted);
}
}
} catch (NameNotFoundException e) {
e.printStackTrace();
}
}
And the call:
checkPermissionsOfApp(getPackageName());
Using the above code, it crashes for the problematic permission, but when using ContextCompat.checkSelfPermission it says it's not granted.
How could it be? How can I grant the app this permission? Is it mentioned anywhere?
The documentation, which was updated in October of 2015, still indicates that you need the signature permission.
See also Not receiving push notifications from GCM (Android)
As @CommonsWare mentioned, this does not appear to be part of the new runtime permission checking, or at least is not considered a "dangerous" permission, and so should be automatically granted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With