Loading src/com/android/permissioncontroller/permission/ui/AutoGrantPermissionsNotifier.java +19 −2 Original line number Diff line number Diff line Loading @@ -141,6 +141,16 @@ public class AutoGrantPermissionsNotifier { Intent manageAppPermission = getSettingsPermissionIntent(sessionId); Bitmap pkgIconBmp = getPackageIcon(pm.getApplicationIcon(mPackageInfo.applicationInfo)); // Use the hash code of the package name string as a unique request code for // PendingIntent.getActivity. // To prevent multiple notifications related to different apps all leading to the same // "Manage app permissions" screen for one single app, the pending intent for each // notification has to be distinguished from other pending intents. // This is done by specifying a different request code. However, a random request code // cannot be used as we'd like the pending intent to be updated if multiple // notifications are shown for the same app. // The package name hash code serves as a stable request code value. int packageBasedRequestCode = mPackageInfo.packageName.hashCode(); String title = mContext.getString( R.string.auto_granted_location_permission_notification_title); Loading @@ -155,8 +165,8 @@ public class AutoGrantPermissionsNotifier { .setSmallIcon(R.drawable.ic_pin_drop) .setLargeIcon(pkgIconBmp) .setColor(mContext.getColor(android.R.color.system_notification_accent_color)) .setContentIntent(getActivity(mContext, 0, manageAppPermission, FLAG_UPDATE_CURRENT)); .setContentIntent(getActivity(mContext, packageBasedRequestCode, manageAppPermission, FLAG_UPDATE_CURRENT)); // Add the Settings app name since we masquerade it. CharSequence appName = getSettingsAppName(); Loading @@ -168,6 +178,13 @@ public class AutoGrantPermissionsNotifier { NotificationManager notificationManager = getSystemServiceSafe(mContext, NotificationManager.class); // Cancel previous notifications for the same package to avoid redundant notifications. // This code currently only deals with location-related notifications, which would all lead // to the same Settings activity for managing location permissions. // If ever extended to cover multiple types of notifications, then only multiple // notifications of the same group should be canceled. notificationManager.cancel( mPackageInfo.packageName, PERMISSION_GRANTED_BY_ADMIN_NOTIFICATION_ID); notificationManager.notify(mPackageInfo.packageName, PERMISSION_GRANTED_BY_ADMIN_NOTIFICATION_ID, b.build()); Loading Loading
src/com/android/permissioncontroller/permission/ui/AutoGrantPermissionsNotifier.java +19 −2 Original line number Diff line number Diff line Loading @@ -141,6 +141,16 @@ public class AutoGrantPermissionsNotifier { Intent manageAppPermission = getSettingsPermissionIntent(sessionId); Bitmap pkgIconBmp = getPackageIcon(pm.getApplicationIcon(mPackageInfo.applicationInfo)); // Use the hash code of the package name string as a unique request code for // PendingIntent.getActivity. // To prevent multiple notifications related to different apps all leading to the same // "Manage app permissions" screen for one single app, the pending intent for each // notification has to be distinguished from other pending intents. // This is done by specifying a different request code. However, a random request code // cannot be used as we'd like the pending intent to be updated if multiple // notifications are shown for the same app. // The package name hash code serves as a stable request code value. int packageBasedRequestCode = mPackageInfo.packageName.hashCode(); String title = mContext.getString( R.string.auto_granted_location_permission_notification_title); Loading @@ -155,8 +165,8 @@ public class AutoGrantPermissionsNotifier { .setSmallIcon(R.drawable.ic_pin_drop) .setLargeIcon(pkgIconBmp) .setColor(mContext.getColor(android.R.color.system_notification_accent_color)) .setContentIntent(getActivity(mContext, 0, manageAppPermission, FLAG_UPDATE_CURRENT)); .setContentIntent(getActivity(mContext, packageBasedRequestCode, manageAppPermission, FLAG_UPDATE_CURRENT)); // Add the Settings app name since we masquerade it. CharSequence appName = getSettingsAppName(); Loading @@ -168,6 +178,13 @@ public class AutoGrantPermissionsNotifier { NotificationManager notificationManager = getSystemServiceSafe(mContext, NotificationManager.class); // Cancel previous notifications for the same package to avoid redundant notifications. // This code currently only deals with location-related notifications, which would all lead // to the same Settings activity for managing location permissions. // If ever extended to cover multiple types of notifications, then only multiple // notifications of the same group should be canceled. notificationManager.cancel( mPackageInfo.packageName, PERMISSION_GRANTED_BY_ADMIN_NOTIFICATION_ID); notificationManager.notify(mPackageInfo.packageName, PERMISSION_GRANTED_BY_ADMIN_NOTIFICATION_ID, b.build()); Loading