Loading services/core/java/com/android/server/notification/NotificationManagerService.java +9 −10 Original line number Diff line number Diff line Loading @@ -11449,21 +11449,20 @@ public class NotificationManagerService extends SystemService { } } } } // clean up anything in the disallowed pkgs list // Clean up removed package from the disallowed packages list for (int i = 0; i < pkgList.length; i++) { String pkg = pkgList[i]; for (int j = mRequestedNotificationListeners.size() - 1; j >= 0; j--) { NotificationListenerFilter nlf = mRequestedNotificationListeners.valueAt(j); VersionedPackage ai = new VersionedPackage(pkg, uidList[i]); nlf.removePackage(ai); } } } } } @Override protected String getRequiredPermission() { Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationListenersTest.java +20 −1 Original line number Diff line number Diff line Loading @@ -426,7 +426,7 @@ public class NotificationListenersTest extends UiServiceTestCase { } @Test public void testOnPackageChanged_removingDisallowedPackage() { public void testOnPackageChanged_removingPackage_removeFromDisallowed() { NotificationListenerFilter nlf = new NotificationListenerFilter(7, new ArraySet<>()); VersionedPackage a1 = new VersionedPackage("pkg1", 243); NotificationListenerFilter nlf2 = Loading @@ -440,6 +440,25 @@ public class NotificationListenersTest extends UiServiceTestCase { assertThat(mListeners.getNotificationListenerFilter(Pair.create(mCn1, 0)) .getDisallowedPackages()).isEmpty(); assertThat(mListeners.getNotificationListenerFilter(Pair.create(mCn2, 0)) .getDisallowedPackages()).isEmpty(); } @Test public void testOnPackageChanged_notRemovingPackage_staysInDisallowed() { NotificationListenerFilter nlf = new NotificationListenerFilter(7, new ArraySet<>()); VersionedPackage a1 = new VersionedPackage("pkg1", 243); NotificationListenerFilter nlf2 = new NotificationListenerFilter(4, new ArraySet<>(new VersionedPackage[] {a1})); mListeners.setNotificationListenerFilter(Pair.create(mCn1, 0), nlf); mListeners.setNotificationListenerFilter(Pair.create(mCn2, 0), nlf2); String[] pkgs = new String[] {"pkg1"}; int[] uids = new int[] {243}; mListeners.onPackagesChanged(false, pkgs, uids); assertThat(mListeners.getNotificationListenerFilter(Pair.create(mCn2, 0)) .getDisallowedPackages()).contains(a1); } @Test Loading Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +9 −10 Original line number Diff line number Diff line Loading @@ -11449,21 +11449,20 @@ public class NotificationManagerService extends SystemService { } } } } // clean up anything in the disallowed pkgs list // Clean up removed package from the disallowed packages list for (int i = 0; i < pkgList.length; i++) { String pkg = pkgList[i]; for (int j = mRequestedNotificationListeners.size() - 1; j >= 0; j--) { NotificationListenerFilter nlf = mRequestedNotificationListeners.valueAt(j); VersionedPackage ai = new VersionedPackage(pkg, uidList[i]); nlf.removePackage(ai); } } } } } @Override protected String getRequiredPermission() { Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationListenersTest.java +20 −1 Original line number Diff line number Diff line Loading @@ -426,7 +426,7 @@ public class NotificationListenersTest extends UiServiceTestCase { } @Test public void testOnPackageChanged_removingDisallowedPackage() { public void testOnPackageChanged_removingPackage_removeFromDisallowed() { NotificationListenerFilter nlf = new NotificationListenerFilter(7, new ArraySet<>()); VersionedPackage a1 = new VersionedPackage("pkg1", 243); NotificationListenerFilter nlf2 = Loading @@ -440,6 +440,25 @@ public class NotificationListenersTest extends UiServiceTestCase { assertThat(mListeners.getNotificationListenerFilter(Pair.create(mCn1, 0)) .getDisallowedPackages()).isEmpty(); assertThat(mListeners.getNotificationListenerFilter(Pair.create(mCn2, 0)) .getDisallowedPackages()).isEmpty(); } @Test public void testOnPackageChanged_notRemovingPackage_staysInDisallowed() { NotificationListenerFilter nlf = new NotificationListenerFilter(7, new ArraySet<>()); VersionedPackage a1 = new VersionedPackage("pkg1", 243); NotificationListenerFilter nlf2 = new NotificationListenerFilter(4, new ArraySet<>(new VersionedPackage[] {a1})); mListeners.setNotificationListenerFilter(Pair.create(mCn1, 0), nlf); mListeners.setNotificationListenerFilter(Pair.create(mCn2, 0), nlf2); String[] pkgs = new String[] {"pkg1"}; int[] uids = new int[] {243}; mListeners.onPackagesChanged(false, pkgs, uids); assertThat(mListeners.getNotificationListenerFilter(Pair.create(mCn2, 0)) .getDisallowedPackages()).contains(a1); } @Test Loading