Loading services/core/java/com/android/server/notification/PreferencesHelper.java +2 −4 Original line number Diff line number Diff line Loading @@ -1015,11 +1015,9 @@ public class PreferencesHelper implements RankingConfig { private boolean channelIsLive(PackagePreferences pkgPref, NotificationChannel channel) { // Channel is in a group that's blocked if (!TextUtils.isEmpty(channel.getGroup())) { if (pkgPref.groups.get(channel.getGroup()).isBlocked()) { if (isGroupBlocked(pkgPref.pkg, pkgPref.uid, channel.getGroup())) { return false; } } // Channel is deleted or is blocked if (channel.isDeleted() || channel.getImportance() == IMPORTANCE_NONE) { Loading services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -1089,6 +1089,24 @@ public class PreferencesHelperTest extends UiServiceTestCase { assertEquals(0, mHelper.getBlockedChannelCount("pkg2", UID_O)); } @Test public void testUpdateChannelsBypassingDnd_onUserSwitch_onUserUnlocked() throws Exception { int user = USER.getIdentifier(); NotificationChannelGroup ncg = new NotificationChannelGroup("group1", "name1"); NotificationChannel channel1 = new NotificationChannel("id1", "name1", NotificationManager.IMPORTANCE_MAX); channel1.setBypassDnd(true); channel1.setGroup(ncg.getId()); // channel is associated with a group, then group is deleted mHelper.createNotificationChannelGroup(PKG_N_MR1, user, ncg, /* fromTargetApp */ true); mHelper.createNotificationChannel(PKG_N_MR1, user, channel1, true, /*has DND access*/ true); mHelper.deleteNotificationChannelGroup(PKG_N_MR1, user, ncg.getId()); mHelper.onUserSwitched(user); mHelper.onUserUnlocked(user); } @Test public void testGetChannelsBypassingDndCount_noChannelsBypassing() throws Exception { assertEquals(0, mHelper.getNotificationChannelsBypassingDnd(PKG_N_MR1, Loading Loading
services/core/java/com/android/server/notification/PreferencesHelper.java +2 −4 Original line number Diff line number Diff line Loading @@ -1015,11 +1015,9 @@ public class PreferencesHelper implements RankingConfig { private boolean channelIsLive(PackagePreferences pkgPref, NotificationChannel channel) { // Channel is in a group that's blocked if (!TextUtils.isEmpty(channel.getGroup())) { if (pkgPref.groups.get(channel.getGroup()).isBlocked()) { if (isGroupBlocked(pkgPref.pkg, pkgPref.uid, channel.getGroup())) { return false; } } // Channel is deleted or is blocked if (channel.isDeleted() || channel.getImportance() == IMPORTANCE_NONE) { Loading
services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -1089,6 +1089,24 @@ public class PreferencesHelperTest extends UiServiceTestCase { assertEquals(0, mHelper.getBlockedChannelCount("pkg2", UID_O)); } @Test public void testUpdateChannelsBypassingDnd_onUserSwitch_onUserUnlocked() throws Exception { int user = USER.getIdentifier(); NotificationChannelGroup ncg = new NotificationChannelGroup("group1", "name1"); NotificationChannel channel1 = new NotificationChannel("id1", "name1", NotificationManager.IMPORTANCE_MAX); channel1.setBypassDnd(true); channel1.setGroup(ncg.getId()); // channel is associated with a group, then group is deleted mHelper.createNotificationChannelGroup(PKG_N_MR1, user, ncg, /* fromTargetApp */ true); mHelper.createNotificationChannel(PKG_N_MR1, user, channel1, true, /*has DND access*/ true); mHelper.deleteNotificationChannelGroup(PKG_N_MR1, user, ncg.getId()); mHelper.onUserSwitched(user); mHelper.onUserUnlocked(user); } @Test public void testGetChannelsBypassingDndCount_noChannelsBypassing() throws Exception { assertEquals(0, mHelper.getNotificationChannelsBypassingDnd(PKG_N_MR1, Loading