Loading services/core/java/com/android/server/notification/NotificationManagerService.java +5 −5 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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 " Loading Loading @@ -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; } Loading Loading @@ -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); } } services/tests/uiservicestests/src/com/android/server/UiServiceTestCase.java +1 −8 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +102 −148 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +5 −5 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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 " Loading Loading @@ -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; } Loading Loading @@ -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); } }
services/tests/uiservicestests/src/com/android/server/UiServiceTestCase.java +1 −8 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +102 −148 File changed.Preview size limit exceeded, changes collapsed. Show changes