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

Commit 8510feb3 authored by Evan Chen's avatar Evan Chen Committed by Automerger Merge Worker
Browse files

Merge "Do not allow setting notification access across users." into udc-dev...

Merge "Do not allow setting notification access across users." into udc-dev am: 0e1af057 am: 941e5251

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/25096530



Change-Id: I77f1287902ae1acb1d8534d1796b83068b7044d5
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 68f40451 941e5251
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -705,8 +705,7 @@ public class CompanionDeviceManagerService extends SystemService {
        public PendingIntent requestNotificationAccess(ComponentName component, int userId)
                throws RemoteException {
            String callingPackage = component.getPackageName();
            checkCanCallNotificationApi(callingPackage);
            // TODO: check userId.
            checkCanCallNotificationApi(callingPackage, userId);
            if (component.flattenToString().length() > MAX_CN_LENGTH) {
                throw new IllegalArgumentException("Component name is too long.");
            }
@@ -732,7 +731,7 @@ public class CompanionDeviceManagerService extends SystemService {
        @Deprecated
        @Override
        public boolean hasNotificationAccess(ComponentName component) throws RemoteException {
            checkCanCallNotificationApi(component.getPackageName());
            checkCanCallNotificationApi(component.getPackageName(), getCallingUserId());
            NotificationManager nm = getContext().getSystemService(NotificationManager.class);
            return nm.isNotificationListenerAccessGranted(component);
        }
@@ -946,8 +945,7 @@ public class CompanionDeviceManagerService extends SystemService {
            createNewAssociation(userId, packageName, macAddressObj, null, null, false);
        }

        private void checkCanCallNotificationApi(String callingPackage) {
            final int userId = getCallingUserId();
        private void checkCanCallNotificationApi(String callingPackage, int userId) {
            enforceCallerIsSystemOr(userId, callingPackage);

            if (getCallingUid() == SYSTEM_UID) return;