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

Commit c725888b authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Revert "Only check uid when comparing apps"

This reverts commit d79fe1e2.

Reason for revert: b/418640774, b/422332061

Change-Id: Icaba4bf8f4d96ff5e058a0cb01b4e9a8ffa429de
parent 7294163e
Loading
Loading
Loading
Loading
+5 −5
Original line number Original line Diff line number Diff line
@@ -5161,8 +5161,8 @@ public class NotificationManagerService extends SystemService {
        public NotificationChannel getConversationNotificationChannel(String callingPkg, int userId,
        public NotificationChannel getConversationNotificationChannel(String callingPkg, int userId,
                String targetPkg, String channelId, boolean returnParentIfNoConversationChannel,
                String targetPkg, String channelId, boolean returnParentIfNoConversationChannel,
                String conversationId) {
                String conversationId) {
            if (isCallerSystemOrSystemUiOrShell()
            if (canNotifyAsPackage(callingPkg, targetPkg, userId)
                    || canNotifyAsPackage(callingPkg, targetPkg, userId)) {
                    || isCallerSystemOrSystemUiOrShell()) {
                int targetUid = -1;
                int targetUid = -1;
                try {
                try {
                    targetUid = mPackageManagerClient.getPackageUidAsUser(targetPkg, userId);
                    targetUid = mPackageManagerClient.getPackageUidAsUser(targetPkg, userId);
@@ -6566,7 +6566,7 @@ public class NotificationManagerService extends SystemService {
                String wellbeingPackage = getContext().getResources().getString(
                String wellbeingPackage = getContext().getResources().getString(
                        com.android.internal.R.string.config_systemWellbeing);
                        com.android.internal.R.string.config_systemWellbeing);
                boolean isCallerWellbeing = !TextUtils.isEmpty(wellbeingPackage)
                boolean isCallerWellbeing = !TextUtils.isEmpty(wellbeingPackage)
                        && isCallerSameApp(wellbeingPackage, uid, userId);
                        && mPackageManagerInternal.isSameApp(wellbeingPackage, uid, userId);
                if (!isCallerWellbeing) {
                if (!isCallerWellbeing) {
                    throw new IllegalArgumentException(
                    throw new IllegalArgumentException(
                            "Only the 'Wellbeing' package can use AutomaticZenRules with "
                            "Only the 'Wellbeing' package can use AutomaticZenRules with "
@@ -6849,7 +6849,7 @@ public class NotificationManagerService extends SystemService {
                    ? mEffectsSuppressors.get(0)
                    ? mEffectsSuppressors.get(0)
                    : null;
                    : null;
            if (isCallerSystemOrSystemUiOrShell() || suppressor == null
            if (isCallerSystemOrSystemUiOrShell() || suppressor == null
                    || isCallerSameApp(suppressor.getPackageName(),
                    || mPackageManagerInternal.isSameApp(suppressor.getPackageName(),
                    Binder.getCallingUid(), UserHandle.getUserId(Binder.getCallingUid()))) {
                    Binder.getCallingUid(), UserHandle.getUserId(Binder.getCallingUid()))) {
                return suppressor;
                return suppressor;
            }
            }
@@ -12175,7 +12175,7 @@ public class NotificationManagerService extends SystemService {
        if (uid == Process.ROOT_UID && ROOT_PKG.equals(pkg)) {
        if (uid == Process.ROOT_UID && ROOT_PKG.equals(pkg)) {
            return;
            return;
        }
        }
        if (!UserHandle.isSameApp(uid, mPackageManagerInternal.getPackageUid(pkg, 0L, userId))) {
        if (!mPackageManagerInternal.isSameApp(pkg, uid, userId)) {
            throw new SecurityException("Package " + pkg + " is not owned by uid " + uid);
            throw new SecurityException("Package " + pkg + " is not owned by uid " + uid);
        }
        }
    }
    }
+1 −8
Original line number Original line Diff line number Diff line
@@ -15,9 +15,7 @@ package com.android.server;


import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.when;


@@ -95,12 +93,7 @@ public class UiServiceTestCase {
                            return Build.VERSION_CODES.CUR_DEVELOPMENT;
                            return Build.VERSION_CODES.CUR_DEVELOPMENT;
                    }
                    }
                });
                });
        when(mPmi.getPackageUid(eq(PKG_N_MR1), anyLong(), anyInt())).thenReturn(UID_N_MR1);

        when(mPmi.getPackageUid(eq(PKG_O), anyLong(), anyInt())).thenReturn(UID_O);
        when(mPmi.getPackageUid(eq(PKG_P), anyLong(), anyInt())).thenReturn(UID_P);
        when(mPmi.getPackageUid(eq(PKG_R), anyLong(), anyInt())).thenReturn(UID_R);
        when(mPmi.getPackageUid(eq(mContext.getPackageName()), anyLong(), eq(mUserId)))
                .thenReturn(mUid);
        LocalServices.removeServiceForTest(UserManagerInternal.class);
        LocalServices.removeServiceForTest(UserManagerInternal.class);
        LocalServices.addService(UserManagerInternal.class, mUmi);
        LocalServices.addService(UserManagerInternal.class, mUmi);
        LocalServices.removeServiceForTest(UriGrantsManagerInternal.class);
        LocalServices.removeServiceForTest(UriGrantsManagerInternal.class);
+102 −148

File changed.

Preview size limit exceeded, changes collapsed.