Loading core/java/android/app/INotificationManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,7 @@ interface INotificationManager void setBubblesAllowed(String pkg, int uid, boolean allowed); boolean areBubblesAllowed(String pkg); boolean areBubblesAllowedForPackage(String pkg, int uid); boolean hasUserApprovedBubblesForPackage(String pkg, int uid); void createNotificationChannelGroups(String pkg, in ParceledListSlice channelGroupList); void createNotificationChannels(String pkg, in ParceledListSlice channelsList); Loading services/core/java/com/android/server/notification/NotificationManagerService.java +9 −3 Original line number Diff line number Diff line Loading @@ -2340,17 +2340,23 @@ public class NotificationManagerService extends SystemService { public boolean areBubblesAllowedForPackage(String pkg, int uid) { enforceSystemOrSystemUIOrSamePackage(pkg, "Caller not system or systemui or same package"); return mPreferencesHelper.areBubblessAllowed(pkg, uid); return mPreferencesHelper.areBubblesAllowed(pkg, uid); } @Override public void setBubblesAllowed(String pkg, int uid, boolean allowed) { checkCallerIsSystem(); enforceSystemOrSystemUI("Caller not system or systemui"); mPreferencesHelper.setBubblesAllowed(pkg, uid, allowed); handleSavePolicyFile(); } @Override public boolean hasUserApprovedBubblesForPackage(String pkg, int uid) { enforceSystemOrSystemUI("Caller not system or systemui"); int lockedFields = mPreferencesHelper.getAppLockedFields(pkg, uid); return (lockedFields & PreferencesHelper.LockableAppFields.USER_LOCKED_BUBBLE) != 0; } @Override public int getPackageImportance(String pkg) { checkCallerIsSystemOrSameApp(pkg); Loading services/core/java/com/android/server/notification/PreferencesHelper.java +1 −2 Original line number Diff line number Diff line Loading @@ -473,7 +473,7 @@ public class PreferencesHelper implements RankingConfig { * @param uid the uid to check if bubbles are allowed for. * @return whether bubbles are allowed. */ public boolean areBubblessAllowed(String pkg, int uid) { public boolean areBubblesAllowed(String pkg, int uid) { return getOrCreatePackagePreferences(pkg, uid).allowBubble; } Loading @@ -489,7 +489,6 @@ public class PreferencesHelper implements RankingConfig { return getOrCreatePackagePreferences(packageName, uid).importance; } /** * Returns whether the importance of the corresponding notification is user-locked and shouldn't * be adjusted by an assistant (via means of a blocking helper, for example). For the channel Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -3594,6 +3594,22 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { assertFalse(mBinderService.areBubblesAllowedForPackage(PKG, mUid)); } @Test public void testUserApprovedBubblesForPackage() throws Exception { assertFalse(mBinderService.hasUserApprovedBubblesForPackage(PKG, mUid)); mBinderService.setBubblesAllowed(PKG, mUid, true); assertTrue(mBinderService.hasUserApprovedBubblesForPackage(PKG, mUid)); assertTrue(mBinderService.areBubblesAllowedForPackage(PKG, mUid)); } @Test public void testUserRejectsBubblesForPackage() throws Exception { assertFalse(mBinderService.hasUserApprovedBubblesForPackage(PKG, mUid)); mBinderService.setBubblesAllowed(PKG, mUid, false); assertTrue(mBinderService.hasUserApprovedBubblesForPackage(PKG, mUid)); assertFalse(mBinderService.areBubblesAllowedForPackage(PKG, mUid)); } @Test public void testIsCallerInstantApp_primaryUser() throws Exception { ApplicationInfo info = new ApplicationInfo(); Loading services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java +4 −4 Original line number Diff line number Diff line Loading @@ -2162,20 +2162,20 @@ public class PreferencesHelperTest extends UiServiceTestCase { @Test public void testAllowBubbles_defaults() throws Exception { assertTrue(mHelper.areBubblessAllowed(PKG_O, UID_O)); assertTrue(mHelper.areBubblesAllowed(PKG_O, UID_O)); ByteArrayOutputStream baos = writeXmlAndPurge(PKG_O, UID_O, false); mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper); loadStreamXml(baos, false); assertTrue(mHelper.areBubblessAllowed(PKG_O, UID_O)); assertTrue(mHelper.areBubblesAllowed(PKG_O, UID_O)); assertEquals(0, mHelper.getAppLockedFields(PKG_O, UID_O)); } @Test public void testAllowBubbles_xml() throws Exception { mHelper.setBubblesAllowed(PKG_O, UID_O, false); assertFalse(mHelper.areBubblessAllowed(PKG_O, UID_O)); assertFalse(mHelper.areBubblesAllowed(PKG_O, UID_O)); assertEquals(PreferencesHelper.LockableAppFields.USER_LOCKED_BUBBLE, mHelper.getAppLockedFields(PKG_O, UID_O)); Loading @@ -2183,7 +2183,7 @@ public class PreferencesHelperTest extends UiServiceTestCase { mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper); loadStreamXml(baos, false); assertFalse(mHelper.areBubblessAllowed(PKG_O, UID_O)); assertFalse(mHelper.areBubblesAllowed(PKG_O, UID_O)); assertEquals(PreferencesHelper.LockableAppFields.USER_LOCKED_BUBBLE, mHelper.getAppLockedFields(PKG_O, UID_O)); } Loading Loading
core/java/android/app/INotificationManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,7 @@ interface INotificationManager void setBubblesAllowed(String pkg, int uid, boolean allowed); boolean areBubblesAllowed(String pkg); boolean areBubblesAllowedForPackage(String pkg, int uid); boolean hasUserApprovedBubblesForPackage(String pkg, int uid); void createNotificationChannelGroups(String pkg, in ParceledListSlice channelGroupList); void createNotificationChannels(String pkg, in ParceledListSlice channelsList); Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +9 −3 Original line number Diff line number Diff line Loading @@ -2340,17 +2340,23 @@ public class NotificationManagerService extends SystemService { public boolean areBubblesAllowedForPackage(String pkg, int uid) { enforceSystemOrSystemUIOrSamePackage(pkg, "Caller not system or systemui or same package"); return mPreferencesHelper.areBubblessAllowed(pkg, uid); return mPreferencesHelper.areBubblesAllowed(pkg, uid); } @Override public void setBubblesAllowed(String pkg, int uid, boolean allowed) { checkCallerIsSystem(); enforceSystemOrSystemUI("Caller not system or systemui"); mPreferencesHelper.setBubblesAllowed(pkg, uid, allowed); handleSavePolicyFile(); } @Override public boolean hasUserApprovedBubblesForPackage(String pkg, int uid) { enforceSystemOrSystemUI("Caller not system or systemui"); int lockedFields = mPreferencesHelper.getAppLockedFields(pkg, uid); return (lockedFields & PreferencesHelper.LockableAppFields.USER_LOCKED_BUBBLE) != 0; } @Override public int getPackageImportance(String pkg) { checkCallerIsSystemOrSameApp(pkg); Loading
services/core/java/com/android/server/notification/PreferencesHelper.java +1 −2 Original line number Diff line number Diff line Loading @@ -473,7 +473,7 @@ public class PreferencesHelper implements RankingConfig { * @param uid the uid to check if bubbles are allowed for. * @return whether bubbles are allowed. */ public boolean areBubblessAllowed(String pkg, int uid) { public boolean areBubblesAllowed(String pkg, int uid) { return getOrCreatePackagePreferences(pkg, uid).allowBubble; } Loading @@ -489,7 +489,6 @@ public class PreferencesHelper implements RankingConfig { return getOrCreatePackagePreferences(packageName, uid).importance; } /** * Returns whether the importance of the corresponding notification is user-locked and shouldn't * be adjusted by an assistant (via means of a blocking helper, for example). For the channel Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -3594,6 +3594,22 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { assertFalse(mBinderService.areBubblesAllowedForPackage(PKG, mUid)); } @Test public void testUserApprovedBubblesForPackage() throws Exception { assertFalse(mBinderService.hasUserApprovedBubblesForPackage(PKG, mUid)); mBinderService.setBubblesAllowed(PKG, mUid, true); assertTrue(mBinderService.hasUserApprovedBubblesForPackage(PKG, mUid)); assertTrue(mBinderService.areBubblesAllowedForPackage(PKG, mUid)); } @Test public void testUserRejectsBubblesForPackage() throws Exception { assertFalse(mBinderService.hasUserApprovedBubblesForPackage(PKG, mUid)); mBinderService.setBubblesAllowed(PKG, mUid, false); assertTrue(mBinderService.hasUserApprovedBubblesForPackage(PKG, mUid)); assertFalse(mBinderService.areBubblesAllowedForPackage(PKG, mUid)); } @Test public void testIsCallerInstantApp_primaryUser() throws Exception { ApplicationInfo info = new ApplicationInfo(); Loading
services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java +4 −4 Original line number Diff line number Diff line Loading @@ -2162,20 +2162,20 @@ public class PreferencesHelperTest extends UiServiceTestCase { @Test public void testAllowBubbles_defaults() throws Exception { assertTrue(mHelper.areBubblessAllowed(PKG_O, UID_O)); assertTrue(mHelper.areBubblesAllowed(PKG_O, UID_O)); ByteArrayOutputStream baos = writeXmlAndPurge(PKG_O, UID_O, false); mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper); loadStreamXml(baos, false); assertTrue(mHelper.areBubblessAllowed(PKG_O, UID_O)); assertTrue(mHelper.areBubblesAllowed(PKG_O, UID_O)); assertEquals(0, mHelper.getAppLockedFields(PKG_O, UID_O)); } @Test public void testAllowBubbles_xml() throws Exception { mHelper.setBubblesAllowed(PKG_O, UID_O, false); assertFalse(mHelper.areBubblessAllowed(PKG_O, UID_O)); assertFalse(mHelper.areBubblesAllowed(PKG_O, UID_O)); assertEquals(PreferencesHelper.LockableAppFields.USER_LOCKED_BUBBLE, mHelper.getAppLockedFields(PKG_O, UID_O)); Loading @@ -2183,7 +2183,7 @@ public class PreferencesHelperTest extends UiServiceTestCase { mHelper = new PreferencesHelper(getContext(), mPm, mHandler, mMockZenModeHelper); loadStreamXml(baos, false); assertFalse(mHelper.areBubblessAllowed(PKG_O, UID_O)); assertFalse(mHelper.areBubblesAllowed(PKG_O, UID_O)); assertEquals(PreferencesHelper.LockableAppFields.USER_LOCKED_BUBBLE, mHelper.getAppLockedFields(PKG_O, UID_O)); } Loading