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

Commit bdda37ca authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Revert "Only check uid when comparing apps"" into main

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

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

@@ -95,12 +93,7 @@ public class UiServiceTestCase {
                            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.addService(UserManagerInternal.class, mUmi);
        LocalServices.removeServiceForTest(UriGrantsManagerInternal.class);
+102 −148

File changed.

Preview size limit exceeded, changes collapsed.