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

Commit e028ef9b authored by Thiébaud Weksteen's avatar Thiébaud Weksteen Committed by Android (Google) Code Review
Browse files

Merge "Accept MODE_DEFAULT for ACCESS_NOTIFICATIONS" into main

parents 1937cc98 617181cb
Loading
Loading
Loading
Loading
+14 −13
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static android.Manifest.permission.STATUS_BAR_SERVICE;
import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
import static android.app.ActivityManagerInternal.ServiceNotificationPolicy.NOT_FOREGROUND_SERVICE;
import static android.app.AppOpsManager.MODE_ALLOWED;
import static android.app.AppOpsManager.MODE_DEFAULT;
import static android.app.Flags.FLAG_LIFETIME_EXTENSION_REFACTOR;
import static android.app.Flags.lifetimeExtensionRefactor;
import static android.app.Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION;
@@ -3598,8 +3599,8 @@ public class NotificationManagerService extends SystemService {
            }
        }
        @android.annotation.EnforcePermission(android.Manifest.permission.MANAGE_TOAST_RATE_LIMITING)
        @Override
        @EnforcePermission(android.Manifest.permission.MANAGE_TOAST_RATE_LIMITING)
        public void setToastRateLimitingEnabled(boolean enable) {
            super.setToastRateLimitingEnabled_enforcePermission();
@@ -4524,7 +4525,6 @@ public class NotificationManagerService extends SystemService {
            return getActiveNotificationsWithAttribution(callingPkg, null);
        }
        @android.annotation.EnforcePermission(android.Manifest.permission.ACCESS_NOTIFICATIONS)
        /**
         * System-only API for getting a list of current (i.e. not cleared) notifications.
         *
@@ -4532,6 +4532,7 @@ public class NotificationManagerService extends SystemService {
         * @returns A list of all the notifications, in natural order.
         */
        @Override
        @EnforcePermission(android.Manifest.permission.ACCESS_NOTIFICATIONS)
        public StatusBarNotification[] getActiveNotificationsWithAttribution(String callingPkg,
                String callingAttributionTag) {
            // enforce() will ensure the calling uid has the correct permission
@@ -4549,9 +4550,9 @@ public class NotificationManagerService extends SystemService {
            });
            // noteOp will check to make sure the callingPkg matches the uid
            if (mAppOps.noteOpNoThrow(AppOpsManager.OP_ACCESS_NOTIFICATIONS, uid, callingPkg,
                    callingAttributionTag, null)
                    == MODE_ALLOWED) {
            int mode = mAppOps.noteOpNoThrow(AppOpsManager.OP_ACCESS_NOTIFICATIONS, uid, callingPkg,
                        callingAttributionTag, null);
            if (mode == MODE_ALLOWED || mode == MODE_DEFAULT) {
                synchronized (mNotificationLock) {
                    final int N = mNotificationList.size();
                    for (int i = 0; i < N; i++) {
@@ -4651,12 +4652,12 @@ public class NotificationManagerService extends SystemService {
                    includeSnoozed);
        }
        @android.annotation.EnforcePermission(android.Manifest.permission.ACCESS_NOTIFICATIONS)
        /**
         * System-only API for getting a list of recent (cleared, no longer shown) notifications.
         */
        @Override
        @RequiresPermission(android.Manifest.permission.ACCESS_NOTIFICATIONS)
        @EnforcePermission(android.Manifest.permission.ACCESS_NOTIFICATIONS)
        public StatusBarNotification[] getHistoricalNotificationsWithAttribution(String callingPkg,
                String callingAttributionTag, int count, boolean includeSnoozed) {
            // enforce() will ensure the calling uid has the correct permission
@@ -4666,9 +4667,9 @@ public class NotificationManagerService extends SystemService {
            int uid = Binder.getCallingUid();
            // noteOp will check to make sure the callingPkg matches the uid
            if (mAppOps.noteOpNoThrow(AppOpsManager.OP_ACCESS_NOTIFICATIONS, uid, callingPkg,
                    callingAttributionTag, null)
                    == MODE_ALLOWED) {
            int mode = mAppOps.noteOpNoThrow(AppOpsManager.OP_ACCESS_NOTIFICATIONS, uid, callingPkg,
                        callingAttributionTag, null);
            if (mode == MODE_ALLOWED || mode == MODE_DEFAULT) {
                synchronized (mArchive) {
                    tmp = mArchive.getArray(mUm, count, includeSnoozed);
                }
@@ -4676,7 +4677,6 @@ public class NotificationManagerService extends SystemService {
            return tmp;
        }
        @android.annotation.EnforcePermission(android.Manifest.permission.ACCESS_NOTIFICATIONS)
        /**
         * System-only API for getting a list of historical notifications. May contain multiple days
         * of notifications.
@@ -4684,6 +4684,7 @@ public class NotificationManagerService extends SystemService {
        @Override
        @WorkerThread
        @RequiresPermission(android.Manifest.permission.ACCESS_NOTIFICATIONS)
        @EnforcePermission(android.Manifest.permission.ACCESS_NOTIFICATIONS)
        public NotificationHistory getNotificationHistory(String callingPkg,
                String callingAttributionTag) {
            // enforce() will ensure the calling uid has the correct permission
@@ -4691,9 +4692,9 @@ public class NotificationManagerService extends SystemService {
            int uid = Binder.getCallingUid();
            // noteOp will check to make sure the callingPkg matches the uid
            if (mAppOps.noteOpNoThrow(AppOpsManager.OP_ACCESS_NOTIFICATIONS, uid, callingPkg,
                    callingAttributionTag, null)
                    == MODE_ALLOWED) {
            int mode = mAppOps.noteOpNoThrow(AppOpsManager.OP_ACCESS_NOTIFICATIONS, uid, callingPkg,
                        callingAttributionTag, null);
            if (mode == MODE_ALLOWED || mode == MODE_DEFAULT) {
                IntArray currentUserIds = mUserProfiles.getCurrentProfileIds();
                Trace.traceBegin(Trace.TRACE_TAG_SYSTEM_SERVER, "notifHistoryReadHistory");
                try {