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

Commit a2b2e377 authored by Julia Reynolds's avatar Julia Reynolds Committed by Christopher Dombroski
Browse files

[RESTRICT AUTOMERGE]: Add cross user permission check - areNotificationsEnabledForPackage

Test: atest
Fixes: 128599467
Change-Id: I13a0ca7590f8c4b44379730e0ee2088aba400c2a
(cherry picked from commit 657d1641)
parent b5e7bbe5
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1413,6 +1413,12 @@ public class NotificationManagerService extends SystemService {
        @Override
        public boolean areNotificationsEnabledForPackage(String pkg, int uid) {
            checkCallerIsSystemOrSameApp(pkg);
            if (UserHandle.getCallingUserId() != UserHandle.getUserId(uid)) {
                getContext().enforceCallingPermission(
                        android.Manifest.permission.INTERACT_ACROSS_USERS,
                        "canNotifyAsPackage for uid " + uid);
            }

            return (mAppOps.checkOpNoThrow(AppOpsManager.OP_POST_NOTIFICATION, uid, pkg)
                    == AppOpsManager.MODE_ALLOWED) && !isPackageSuspendedForUser(pkg, uid);
        }