Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fc95f47e authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6321673 from aa9e5198 to rvc-release

Change-Id: If8e015b581b3410a9d0def718358c3fbf107eb8b
parents 4a085649 aa9e5198
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -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);
@@ -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();
@@ -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());