Loading services/core/java/com/android/server/notification/NotificationManagerService.java +5 −3 Original line number Diff line number Diff line Loading @@ -4289,7 +4289,8 @@ public class NotificationManagerService extends SystemService { } // posted from app A on behalf of app A if (isCallerSameApp(targetPkg, callingUid, userId) && TextUtils.equals(callingPkg, targetPkg)) { && (TextUtils.equals(callingPkg, targetPkg) || isCallerSameApp(callingPkg, callingUid, userId))) { return callingUid; } Loading @@ -4306,7 +4307,8 @@ public class NotificationManagerService extends SystemService { return targetUid; } throw new SecurityException("Caller " + callingUid + " cannot post for pkg " + targetPkg); throw new SecurityException("Caller " + callingPkg + ":" + callingUid + " cannot post for pkg " + targetPkg + " in user " + userId); } /** Loading @@ -4326,7 +4328,7 @@ public class NotificationManagerService extends SystemService { if (!isSystemNotification && !isNotificationFromListener) { synchronized (mNotificationLock) { if (mNotificationsByKey.get(r.sbn.getKey()) == null && isCallerInstantApp(pkg, callingUid, r.getUserId())) { && isCallerInstantApp(pkg, Binder.getCallingUid(), userId)) { // Ephemeral apps have some special constraints for notifications. // They are not allowed to create new notifications however they are allowed to // update notifications created by the system (e.g. a foreground service Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +5 −8 Original line number Diff line number Diff line Loading @@ -3448,17 +3448,14 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { } @Test public void testResolveNotificationUid_sameAppWrongPkg() throws Exception { public void testResolveNotificationUid_sameAppDiffPackage() throws Exception { ApplicationInfo info = new ApplicationInfo(); info.uid = Binder.getCallingUid(); when(mPackageManager.getApplicationInfo(anyString(), anyInt(), anyInt())).thenReturn(info); when(mPackageManager.getApplicationInfo(anyString(), anyInt(), eq(0))).thenReturn(info); try { mService.resolveNotificationUid("caller", "other", info.uid, 0); fail("Incorrect pkg didn't throw security exception"); } catch (SecurityException e) { // yay } int actualUid = mService.resolveNotificationUid("caller", "callerAlso", info.uid, 0); assertEquals(info.uid, actualUid); } @Test Loading Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +5 −3 Original line number Diff line number Diff line Loading @@ -4289,7 +4289,8 @@ public class NotificationManagerService extends SystemService { } // posted from app A on behalf of app A if (isCallerSameApp(targetPkg, callingUid, userId) && TextUtils.equals(callingPkg, targetPkg)) { && (TextUtils.equals(callingPkg, targetPkg) || isCallerSameApp(callingPkg, callingUid, userId))) { return callingUid; } Loading @@ -4306,7 +4307,8 @@ public class NotificationManagerService extends SystemService { return targetUid; } throw new SecurityException("Caller " + callingUid + " cannot post for pkg " + targetPkg); throw new SecurityException("Caller " + callingPkg + ":" + callingUid + " cannot post for pkg " + targetPkg + " in user " + userId); } /** Loading @@ -4326,7 +4328,7 @@ public class NotificationManagerService extends SystemService { if (!isSystemNotification && !isNotificationFromListener) { synchronized (mNotificationLock) { if (mNotificationsByKey.get(r.sbn.getKey()) == null && isCallerInstantApp(pkg, callingUid, r.getUserId())) { && isCallerInstantApp(pkg, Binder.getCallingUid(), userId)) { // Ephemeral apps have some special constraints for notifications. // They are not allowed to create new notifications however they are allowed to // update notifications created by the system (e.g. a foreground service Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +5 −8 Original line number Diff line number Diff line Loading @@ -3448,17 +3448,14 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { } @Test public void testResolveNotificationUid_sameAppWrongPkg() throws Exception { public void testResolveNotificationUid_sameAppDiffPackage() throws Exception { ApplicationInfo info = new ApplicationInfo(); info.uid = Binder.getCallingUid(); when(mPackageManager.getApplicationInfo(anyString(), anyInt(), anyInt())).thenReturn(info); when(mPackageManager.getApplicationInfo(anyString(), anyInt(), eq(0))).thenReturn(info); try { mService.resolveNotificationUid("caller", "other", info.uid, 0); fail("Incorrect pkg didn't throw security exception"); } catch (SecurityException e) { // yay } int actualUid = mService.resolveNotificationUid("caller", "callerAlso", info.uid, 0); assertEquals(info.uid, actualUid); } @Test Loading