Loading services/core/java/com/android/server/notification/NotificationManagerService.java +25 −2 Original line number Diff line number Diff line Loading @@ -16,8 +16,10 @@ package com.android.server.notification; import static android.app.NotificationManager.IMPORTANCE_LOW; import static android.app.NotificationManager.IMPORTANCE_MIN; import static android.app.NotificationManager.IMPORTANCE_NONE; import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED; import static android.content.pm.PackageManager.FEATURE_LEANBACK; import static android.content.pm.PackageManager.FEATURE_TELEVISION; import static android.content.pm.PackageManager.PERMISSION_GRANTED; Loading Loading @@ -1142,6 +1144,12 @@ public class NotificationManagerService extends SystemService { mEnqueuedNotifications.add(r); } @VisibleForTesting NotificationRecord getNotificationRecord(String key) { return mNotificationsByKey.get(key); } @VisibleForTesting void setSystemReady(boolean systemReady) { mSystemReady = systemReady; Loading Loading @@ -1217,7 +1225,7 @@ public class NotificationManagerService extends SystemService { mUsageStats = usageStats; mRankingHandler = new RankingHandlerWorker(mRankingThread.getLooper()); mRankingHelper = new RankingHelper(getContext(), getContext().getPackageManager(), mPackageManagerClient, mRankingHandler, mUsageStats, extractorNames); Loading Loading @@ -1477,7 +1485,7 @@ public class NotificationManagerService extends SystemService { } } } mRankingHelper.updateNotificationChannel(pkg, uid, channel); mRankingHelper.updateNotificationChannel(pkg, uid, channel, true); if (!fromListener) { final NotificationChannel modifiedChannel = Loading Loading @@ -3485,6 +3493,21 @@ public class NotificationManagerService extends SystemService { user, null, System.currentTimeMillis()); final NotificationRecord r = new NotificationRecord(getContext(), n, channel); if ((notification.flags & Notification.FLAG_FOREGROUND_SERVICE) != 0 && (channel.getUserLockedFields() & NotificationChannel.USER_LOCKED_IMPORTANCE) == 0 && (r.getImportance() == IMPORTANCE_MIN || r.getImportance() == IMPORTANCE_NONE)) { // Increase the importance of foreground service notifications unless the user had an // opinion otherwise if (TextUtils.isEmpty(channelId) || NotificationChannel.DEFAULT_CHANNEL_ID.equals(channelId)) { r.setImportance(IMPORTANCE_LOW, "Bumped for foreground service"); } else { channel.setImportance(IMPORTANCE_LOW); mRankingHelper.updateNotificationChannel(pkg, notificationUid, channel, false); r.updateNotificationChannel(channel); } } if (!checkDisqualifyingFeatures(userId, notificationUid, id, tag, r, r.sbn.getOverrideGroupKey() != null)) { return; Loading services/core/java/com/android/server/notification/RankingConfig.java +1 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ public interface RankingConfig { int uid, boolean includeDeleted); void createNotificationChannel(String pkg, int uid, NotificationChannel channel, boolean fromTargetApp); void updateNotificationChannel(String pkg, int uid, NotificationChannel channel); void updateNotificationChannel(String pkg, int uid, NotificationChannel channel, boolean fromUser); NotificationChannel getNotificationChannel(String pkg, int uid, String channelId, boolean includeDeleted); void deleteNotificationChannel(String pkg, int uid, String channelId); void permanentlyDeleteNotificationChannel(String pkg, int uid, String channelId); Loading services/core/java/com/android/server/notification/RankingHelper.java +7 −4 Original line number Diff line number Diff line Loading @@ -589,7 +589,8 @@ public class RankingHelper implements RankingConfig { } @Override public void updateNotificationChannel(String pkg, int uid, NotificationChannel updatedChannel) { public void updateNotificationChannel(String pkg, int uid, NotificationChannel updatedChannel, boolean fromUser) { Preconditions.checkNotNull(updatedChannel); Preconditions.checkNotNull(updatedChannel.getId()); Record r = getOrCreateRecord(pkg, uid); Loading @@ -603,7 +604,11 @@ public class RankingHelper implements RankingConfig { if (updatedChannel.getLockscreenVisibility() == Notification.VISIBILITY_PUBLIC) { updatedChannel.setLockscreenVisibility(Ranking.VISIBILITY_NO_OVERRIDE); } updatedChannel.unlockFields(updatedChannel.getUserLockedFields()); updatedChannel.lockFields(channel.getUserLockedFields()); if (fromUser) { lockFieldsForUpdate(channel, updatedChannel); } r.channels.put(updatedChannel.getId(), updatedChannel); if (NotificationChannel.DEFAULT_CHANNEL_ID.equals(updatedChannel.getId())) { Loading Loading @@ -828,8 +833,6 @@ public class RankingHelper implements RankingConfig { @VisibleForTesting void lockFieldsForUpdate(NotificationChannel original, NotificationChannel update) { update.unlockFields(update.getUserLockedFields()); update.lockFields(original.getUserLockedFields()); if (original.canBypassDnd() != update.canBypassDnd()) { update.lockFields(NotificationChannel.USER_LOCKED_PRIORITY); } Loading services/tests/notification/src/com/android/server/notification/NotificationManagerServiceTest.java +148 −16 Original line number Diff line number Diff line Loading @@ -16,12 +16,15 @@ package com.android.server.notification; import static android.app.NotificationManager.IMPORTANCE_HIGH; import static android.app.NotificationManager.IMPORTANCE_LOW; import static android.app.NotificationManager.IMPORTANCE_NONE; import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED; import static android.content.pm.PackageManager.PERMISSION_DENIED; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertNull; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; Loading Loading @@ -56,6 +59,7 @@ import android.content.pm.ParceledListSlice; import android.graphics.Color; import android.media.AudioManager; import android.os.Binder; import android.os.Build; import android.os.Process; import android.os.UserHandle; import android.provider.Settings.Secure; Loading Loading @@ -241,6 +245,7 @@ public class NotificationManagerServiceTest extends NotificationTestCase { nb.build(), new UserHandle(mUid), null, 0); return new NotificationRecord(mContext, sbn, channel); } private NotificationRecord generateNotificationRecord(NotificationChannel channel) { return generateNotificationRecord(channel, null); } Loading Loading @@ -342,7 +347,7 @@ public class NotificationManagerServiceTest extends NotificationTestCase { // Recreating the channel doesn't throw, but ignores importance. final NotificationChannel dupeChannel = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_HIGH); new NotificationChannel("id", "name", IMPORTANCE_HIGH); mBinderService.createNotificationChannels(PKG, new ParceledListSlice(Arrays.asList(dupeChannel))); final NotificationChannel createdChannel = Loading Loading @@ -378,7 +383,7 @@ public class NotificationManagerServiceTest extends NotificationTestCase { // The user modifies importance directly, can no longer be changed by the app. final NotificationChannel updatedChannel = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_HIGH); new NotificationChannel("id", "name", IMPORTANCE_HIGH); mBinderService.updateNotificationChannelForPackage(PKG, mUid, updatedChannel); // Recreating with a lower importance leaves channel unchanged. Loading @@ -388,7 +393,7 @@ public class NotificationManagerServiceTest extends NotificationTestCase { new ParceledListSlice(Arrays.asList(dupeChannel))); final NotificationChannel createdChannel = mBinderService.getNotificationChannel(PKG, "id"); assertEquals(NotificationManager.IMPORTANCE_HIGH, createdChannel.getImportance()); assertEquals(IMPORTANCE_HIGH, createdChannel.getImportance()); } @Test Loading @@ -397,7 +402,7 @@ public class NotificationManagerServiceTest extends NotificationTestCase { final NotificationChannel channel1 = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_DEFAULT); final NotificationChannel channel2 = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_HIGH); new NotificationChannel("id", "name", IMPORTANCE_HIGH); mBinderService.createNotificationChannels(PKG, new ParceledListSlice(Arrays.asList(channel1, channel2))); final NotificationChannel createdChannel = Loading @@ -410,7 +415,7 @@ public class NotificationManagerServiceTest extends NotificationTestCase { when(mPackageManager.isPackageSuspendedForUser(anyString(), anyInt())).thenReturn(true); NotificationChannel channel = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_HIGH); IMPORTANCE_HIGH); NotificationRecord r = generateNotificationRecord(channel); assertTrue(mNotificationManagerService.isBlocked(r, mUsageStats)); verify(mUsageStats, times(1)).registerSuspendedByAdmin(eq(r)); Loading @@ -421,11 +426,68 @@ public class NotificationManagerServiceTest extends NotificationTestCase { when(mPackageManager.isPackageSuspendedForUser(anyString(), anyInt())).thenReturn(false); NotificationChannel channel = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_HIGH); channel.setImportance(IMPORTANCE_NONE); NotificationManager.IMPORTANCE_NONE); NotificationRecord r = generateNotificationRecord(channel); assertTrue(mNotificationManagerService.isBlocked(r, mUsageStats)); verify(mUsageStats, times(1)).registerBlocked(eq(r)); mBinderService.createNotificationChannels( PKG, new ParceledListSlice(Arrays.asList(channel))); final StatusBarNotification sbn = generateNotificationRecord(channel).sbn; mBinderService.enqueueNotificationWithTag(PKG, "opPkg", "tag", sbn.getId(), sbn.getNotification(), sbn.getUserId()); waitForIdle(); assertEquals(0, mBinderService.getActiveNotifications(sbn.getPackageName()).length); } @Test public void testEnqueuedBlockedNotifications_appBlockedChannelForegroundService() throws Exception { when(mPackageManager.isPackageSuspendedForUser(anyString(), anyInt())).thenReturn(false); NotificationChannel channel = new NotificationChannel("blocked", "name", NotificationManager.IMPORTANCE_NONE); mBinderService.createNotificationChannels( PKG, new ParceledListSlice(Arrays.asList(channel))); final StatusBarNotification sbn = generateNotificationRecord(channel).sbn; sbn.getNotification().flags |= Notification.FLAG_FOREGROUND_SERVICE; mBinderService.enqueueNotificationWithTag(PKG, "opPkg", "tag", sbn.getId(), sbn.getNotification(), sbn.getUserId()); waitForIdle(); assertEquals(1, mBinderService.getActiveNotifications(sbn.getPackageName()).length); assertEquals(IMPORTANCE_LOW, mNotificationManagerService.getNotificationRecord(sbn.getKey()).getImportance()); assertEquals(IMPORTANCE_LOW, mBinderService.getNotificationChannel(PKG, channel.getId()).getImportance()); } @Test public void testEnqueuedBlockedNotifications_userBlockedChannelForegroundService() throws Exception { when(mPackageManager.isPackageSuspendedForUser(anyString(), anyInt())).thenReturn(false); NotificationChannel channel = new NotificationChannel("blockedbyuser", "name", IMPORTANCE_HIGH); mBinderService.createNotificationChannels( PKG, new ParceledListSlice(Arrays.asList(channel))); NotificationChannel update = new NotificationChannel("blockedbyuser", "name", IMPORTANCE_NONE); mBinderService.updateNotificationChannelForPackage(PKG, mUid, update); waitForIdle(); assertEquals(IMPORTANCE_NONE, mBinderService.getNotificationChannel(PKG, channel.getId()).getImportance()); final StatusBarNotification sbn = generateNotificationRecord(channel).sbn; sbn.getNotification().flags |= Notification.FLAG_FOREGROUND_SERVICE; mBinderService.enqueueNotificationWithTag(PKG, "opPkg", "tag", sbn.getId(), sbn.getNotification(), sbn.getUserId()); waitForIdle(); assertEquals(0, mBinderService.getActiveNotifications(sbn.getPackageName()).length); assertNull(mNotificationManagerService.getNotificationRecord(sbn.getKey())); assertEquals(IMPORTANCE_NONE, mBinderService.getNotificationChannel(PKG, channel.getId()).getImportance()); } @Test Loading @@ -441,6 +503,21 @@ public class NotificationManagerServiceTest extends NotificationTestCase { assertEquals(0, mBinderService.getActiveNotifications(sbn.getPackageName()).length); } @Test public void testEnqueuedBlockedNotifications_blockedAppForegroundService() throws Exception { when(mPackageManager.isPackageSuspendedForUser(anyString(), anyInt())).thenReturn(false); mBinderService.setNotificationsEnabledForPackage(PKG, mUid, false); final StatusBarNotification sbn = generateNotificationRecord(null).sbn; sbn.getNotification().flags |= Notification.FLAG_FOREGROUND_SERVICE; mBinderService.enqueueNotificationWithTag(PKG, "opPkg", "tag", sbn.getId(), sbn.getNotification(), sbn.getUserId()); waitForIdle(); assertEquals(0, mBinderService.getActiveNotifications(sbn.getPackageName()).length); assertNull(mNotificationManagerService.getNotificationRecord(sbn.getKey())); } @Test public void testEnqueueNotificationWithTag_PopulatesGetActiveNotifications() throws Exception { mBinderService.enqueueNotificationWithTag(PKG, "opPkg", "tag", 0, Loading Loading @@ -798,7 +875,7 @@ public class NotificationManagerServiceTest extends NotificationTestCase { mNotificationManagerService.setRankingHelper(mRankingHelper); when(mRankingHelper.getNotificationChannel( anyString(), anyInt(), eq("foo"), anyBoolean())).thenReturn( new NotificationChannel("foo", "foo", NotificationManager.IMPORTANCE_HIGH)); new NotificationChannel("foo", "foo", IMPORTANCE_HIGH)); Notification.TvExtender tv = new Notification.TvExtender().setChannelId("foo"); mBinderService.enqueueNotificationWithTag(PKG, "opPkg", "tag", 0, Loading Loading @@ -927,7 +1004,8 @@ public class NotificationManagerServiceTest extends NotificationTestCase { mBinderService.updateNotificationChannelFromPrivilegedListener( null, PKG, Process.myUserHandle(), mTestNotificationChannel); verify(mRankingHelper, times(1)).updateNotificationChannel(anyString(), anyInt(), any()); verify(mRankingHelper, times(1)).updateNotificationChannel( anyString(), anyInt(), any(), anyBoolean()); verify(mListeners, never()).notifyNotificationChannelChanged(eq(PKG), eq(Process.myUserHandle()), eq(mTestNotificationChannel), Loading @@ -948,7 +1026,8 @@ public class NotificationManagerServiceTest extends NotificationTestCase { // pass } verify(mRankingHelper, never()).updateNotificationChannel(anyString(), anyInt(), any()); verify(mRankingHelper, never()).updateNotificationChannel( anyString(), anyInt(), any(), anyBoolean()); verify(mListeners, never()).notifyNotificationChannelChanged(eq(PKG), eq(Process.myUserHandle()), eq(mTestNotificationChannel), Loading @@ -974,7 +1053,8 @@ public class NotificationManagerServiceTest extends NotificationTestCase { // pass } verify(mRankingHelper, never()).updateNotificationChannel(anyString(), anyInt(), any()); verify(mRankingHelper, never()).updateNotificationChannel( anyString(), anyInt(), any(), anyBoolean()); verify(mListeners, never()).notifyNotificationChannelChanged(eq(PKG), eq(Process.myUserHandle()), eq(mTestNotificationChannel), Loading Loading @@ -1345,7 +1425,8 @@ public class NotificationManagerServiceTest extends NotificationTestCase { @Test public void testOnlyAutogroupIfGroupChanged_groupChanged_autogroups() throws Exception { NotificationRecord r = generateNotificationRecord(mTestNotificationChannel, 0, "group", false); NotificationRecord r = generateNotificationRecord(mTestNotificationChannel, 0, "group", false); mNotificationManagerService.addNotification(r); r = generateNotificationRecord(mTestNotificationChannel, 0, null, false); Loading Loading @@ -1425,12 +1506,16 @@ public class NotificationManagerServiceTest extends NotificationTestCase { // Same notifications are enqueued as posted, everything counts b/c id and tag don't match int userId = new UserHandle(mUid).getIdentifier(); assertEquals(40, mNotificationManagerService.getNotificationCountLocked(PKG, userId, 0, null)); assertEquals(40, mNotificationManagerService.getNotificationCountLocked(PKG, userId, 0, "tag2")); assertEquals(2, mNotificationManagerService.getNotificationCountLocked("a", userId, 0, "banana")); assertEquals(40, mNotificationManagerService.getNotificationCountLocked(PKG, userId, 0, null)); assertEquals(40, mNotificationManagerService.getNotificationCountLocked(PKG, userId, 0, "tag2")); assertEquals(2, mNotificationManagerService.getNotificationCountLocked("a", userId, 0, "banana")); // exclude a known notification - it's excluded from only the posted list, not enqueued assertEquals(39, mNotificationManagerService.getNotificationCountLocked(PKG, userId, 0, "tag")); assertEquals(39, mNotificationManagerService.getNotificationCountLocked(PKG, userId, 0, "tag")); } @Test Loading Loading @@ -1560,4 +1645,51 @@ public class NotificationManagerServiceTest extends NotificationTestCase { verify(mZenModeHelper, times(1)).updateDefaultZenRules(); } @Test public void testBumpFGImportance_noChannelChangePreOApp() throws Exception { String preOPkg = "preO"; int preOUid = 145; final ApplicationInfo legacy = new ApplicationInfo(); legacy.targetSdkVersion = Build.VERSION_CODES.N_MR1; when(mPackageManagerClient.getApplicationInfoAsUser(eq(preOPkg), anyInt(), anyInt())) .thenReturn(legacy); when(mPackageManagerClient.getPackageUidAsUser(eq(preOPkg), anyInt())).thenReturn(preOUid); getContext().setMockPackageManager(mPackageManagerClient); Notification.Builder nb = new Notification.Builder(mContext, NotificationChannel.DEFAULT_CHANNEL_ID) .setContentTitle("foo") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setFlag(Notification.FLAG_FOREGROUND_SERVICE, true) .setPriority(Notification.PRIORITY_MIN); StatusBarNotification sbn = new StatusBarNotification(preOPkg, preOPkg, 9, "tag", preOUid, 0, nb.build(), new UserHandle(preOUid), null, 0); mBinderService.enqueueNotificationWithTag(preOPkg, preOPkg, "tag", sbn.getId(), sbn.getNotification(), sbn.getUserId()); waitForIdle(); assertEquals(IMPORTANCE_LOW, mNotificationManagerService.getNotificationRecord(sbn.getKey()).getImportance()); nb = new Notification.Builder(mContext) .setContentTitle("foo") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setFlag(Notification.FLAG_FOREGROUND_SERVICE, true) .setPriority(Notification.PRIORITY_MIN); sbn = new StatusBarNotification(preOPkg, preOPkg, 9, "tag", preOUid, 0, nb.build(), new UserHandle(preOUid), null, 0); mBinderService.enqueueNotificationWithTag(preOPkg, preOPkg, "tag", sbn.getId(), sbn.getNotification(), sbn.getUserId()); waitForIdle(); assertEquals(IMPORTANCE_LOW, mNotificationManagerService.getNotificationRecord(sbn.getKey()).getImportance()); NotificationChannel defaultChannel = mBinderService.getNotificationChannel( preOPkg, NotificationChannel.DEFAULT_CHANNEL_ID); assertEquals(IMPORTANCE_UNSPECIFIED, defaultChannel.getImportance()); } } services/tests/notification/src/com/android/server/notification/RankingHelperTest.java +14 −14 Original line number Diff line number Diff line Loading @@ -484,7 +484,7 @@ public class RankingHelperTest extends NotificationTestCase { final NotificationChannel defaultChannel = mHelper.getNotificationChannel(PKG, UID, NotificationChannel.DEFAULT_CHANNEL_ID, false); defaultChannel.setImportance(NotificationManager.IMPORTANCE_LOW); mHelper.updateNotificationChannel(PKG, UID, defaultChannel); mHelper.updateNotificationChannel(PKG, UID, defaultChannel, true); ByteArrayOutputStream baos = writeXmlAndPurge(PKG, UID, false, NotificationChannel.DEFAULT_CHANNEL_ID); Loading Loading @@ -633,7 +633,7 @@ public class RankingHelperTest extends NotificationTestCase { channel2.setBypassDnd(false); channel2.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); mHelper.updateNotificationChannel(PKG, UID, channel2); mHelper.updateNotificationChannel(PKG, UID, channel2, true); // all fields should be changed assertEquals(channel2, mHelper.getNotificationChannel(PKG, UID, channel.getId(), false)); Loading @@ -657,7 +657,7 @@ public class RankingHelperTest extends NotificationTestCase { defaultChannel.setBypassDnd(true); defaultChannel.setLockscreenVisibility(Notification.VISIBILITY_SECRET); mHelper.updateNotificationChannel(PKG, UID, defaultChannel); mHelper.updateNotificationChannel(PKG, UID, defaultChannel, true); // ensure app level fields are changed assertFalse(mHelper.canShowBadge(PKG, UID)); Loading @@ -681,7 +681,7 @@ public class RankingHelperTest extends NotificationTestCase { channel.setBypassDnd(true); channel.setLockscreenVisibility(Notification.VISIBILITY_SECRET); mHelper.updateNotificationChannel(PKG, UID, channel); mHelper.updateNotificationChannel(PKG, UID, channel, true); // ensure app level fields are not changed assertTrue(mHelper.canShowBadge(PKG, UID)); Loading Loading @@ -772,14 +772,14 @@ public class RankingHelperTest extends NotificationTestCase { update1.setSound(new Uri.Builder().scheme("test").build(), new AudioAttributes.Builder().build()); update1.lockFields(NotificationChannel.USER_LOCKED_PRIORITY); // should be ignored mHelper.updateNotificationChannel(PKG, UID, update1); mHelper.updateNotificationChannel(PKG, UID, update1, true); assertEquals(NotificationChannel.USER_LOCKED_SOUND, mHelper.getNotificationChannel(PKG, UID, update1.getId(), false) .getUserLockedFields()); NotificationChannel update2 = getChannel(); update2.enableVibration(true); mHelper.updateNotificationChannel(PKG, UID, update2); mHelper.updateNotificationChannel(PKG, UID, update2, true); assertEquals(NotificationChannel.USER_LOCKED_SOUND | NotificationChannel.USER_LOCKED_VIBRATION, mHelper.getNotificationChannel(PKG, UID, update2.getId(), false) Loading @@ -792,14 +792,14 @@ public class RankingHelperTest extends NotificationTestCase { final NotificationChannel update1 = getChannel(); update1.setVibrationPattern(new long[]{7945, 46 ,246}); mHelper.updateNotificationChannel(PKG, UID, update1); mHelper.updateNotificationChannel(PKG, UID, update1, true); assertEquals(NotificationChannel.USER_LOCKED_VIBRATION, mHelper.getNotificationChannel(PKG, UID, update1.getId(), false) .getUserLockedFields()); final NotificationChannel update2 = getChannel(); update2.enableLights(true); mHelper.updateNotificationChannel(PKG, UID, update2); mHelper.updateNotificationChannel(PKG, UID, update2, true); assertEquals(NotificationChannel.USER_LOCKED_VIBRATION | NotificationChannel.USER_LOCKED_LIGHTS, mHelper.getNotificationChannel(PKG, UID, update2.getId(), false) Loading @@ -812,14 +812,14 @@ public class RankingHelperTest extends NotificationTestCase { final NotificationChannel update1 = getChannel(); update1.setLightColor(Color.GREEN); mHelper.updateNotificationChannel(PKG, UID, update1); mHelper.updateNotificationChannel(PKG, UID, update1, true); assertEquals(NotificationChannel.USER_LOCKED_LIGHTS, mHelper.getNotificationChannel(PKG, UID, update1.getId(), false) .getUserLockedFields()); final NotificationChannel update2 = getChannel(); update2.setImportance(IMPORTANCE_DEFAULT); mHelper.updateNotificationChannel(PKG, UID, update2); mHelper.updateNotificationChannel(PKG, UID, update2, true); assertEquals(NotificationChannel.USER_LOCKED_LIGHTS | NotificationChannel.USER_LOCKED_IMPORTANCE, mHelper.getNotificationChannel(PKG, UID, update2.getId(), false) Loading @@ -835,14 +835,14 @@ public class RankingHelperTest extends NotificationTestCase { final NotificationChannel update1 = getChannel(); update1.setBypassDnd(true); mHelper.updateNotificationChannel(PKG, UID, update1); mHelper.updateNotificationChannel(PKG, UID, update1, true); assertEquals(NotificationChannel.USER_LOCKED_PRIORITY, mHelper.getNotificationChannel(PKG, UID, update1.getId(), false) .getUserLockedFields()); final NotificationChannel update2 = getChannel(); update2.setLockscreenVisibility(Notification.VISIBILITY_SECRET); mHelper.updateNotificationChannel(PKG, UID, update2); mHelper.updateNotificationChannel(PKG, UID, update2, true); assertEquals(NotificationChannel.USER_LOCKED_PRIORITY | NotificationChannel.USER_LOCKED_VISIBILITY, mHelper.getNotificationChannel(PKG, UID, update2.getId(), false) Loading @@ -850,7 +850,7 @@ public class RankingHelperTest extends NotificationTestCase { final NotificationChannel update3 = getChannel(); update3.setShowBadge(false); mHelper.updateNotificationChannel(PKG, UID, update3); mHelper.updateNotificationChannel(PKG, UID, update3, true); assertEquals(NotificationChannel.USER_LOCKED_PRIORITY | NotificationChannel.USER_LOCKED_VISIBILITY | NotificationChannel.USER_LOCKED_SHOW_BADGE, Loading Loading @@ -1263,7 +1263,7 @@ public class RankingHelperTest extends NotificationTestCase { mHelper.getNotificationChannelGroups(PKG, UID, true).getList(); channel1.setImportance(IMPORTANCE_LOW); mHelper.updateNotificationChannel(PKG, UID, channel1); mHelper.updateNotificationChannel(PKG, UID, channel1, true); List<NotificationChannelGroup> actual = mHelper.getNotificationChannelGroups(PKG, UID, true).getList(); Loading Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +25 −2 Original line number Diff line number Diff line Loading @@ -16,8 +16,10 @@ package com.android.server.notification; import static android.app.NotificationManager.IMPORTANCE_LOW; import static android.app.NotificationManager.IMPORTANCE_MIN; import static android.app.NotificationManager.IMPORTANCE_NONE; import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED; import static android.content.pm.PackageManager.FEATURE_LEANBACK; import static android.content.pm.PackageManager.FEATURE_TELEVISION; import static android.content.pm.PackageManager.PERMISSION_GRANTED; Loading Loading @@ -1142,6 +1144,12 @@ public class NotificationManagerService extends SystemService { mEnqueuedNotifications.add(r); } @VisibleForTesting NotificationRecord getNotificationRecord(String key) { return mNotificationsByKey.get(key); } @VisibleForTesting void setSystemReady(boolean systemReady) { mSystemReady = systemReady; Loading Loading @@ -1217,7 +1225,7 @@ public class NotificationManagerService extends SystemService { mUsageStats = usageStats; mRankingHandler = new RankingHandlerWorker(mRankingThread.getLooper()); mRankingHelper = new RankingHelper(getContext(), getContext().getPackageManager(), mPackageManagerClient, mRankingHandler, mUsageStats, extractorNames); Loading Loading @@ -1477,7 +1485,7 @@ public class NotificationManagerService extends SystemService { } } } mRankingHelper.updateNotificationChannel(pkg, uid, channel); mRankingHelper.updateNotificationChannel(pkg, uid, channel, true); if (!fromListener) { final NotificationChannel modifiedChannel = Loading Loading @@ -3485,6 +3493,21 @@ public class NotificationManagerService extends SystemService { user, null, System.currentTimeMillis()); final NotificationRecord r = new NotificationRecord(getContext(), n, channel); if ((notification.flags & Notification.FLAG_FOREGROUND_SERVICE) != 0 && (channel.getUserLockedFields() & NotificationChannel.USER_LOCKED_IMPORTANCE) == 0 && (r.getImportance() == IMPORTANCE_MIN || r.getImportance() == IMPORTANCE_NONE)) { // Increase the importance of foreground service notifications unless the user had an // opinion otherwise if (TextUtils.isEmpty(channelId) || NotificationChannel.DEFAULT_CHANNEL_ID.equals(channelId)) { r.setImportance(IMPORTANCE_LOW, "Bumped for foreground service"); } else { channel.setImportance(IMPORTANCE_LOW); mRankingHelper.updateNotificationChannel(pkg, notificationUid, channel, false); r.updateNotificationChannel(channel); } } if (!checkDisqualifyingFeatures(userId, notificationUid, id, tag, r, r.sbn.getOverrideGroupKey() != null)) { return; Loading
services/core/java/com/android/server/notification/RankingConfig.java +1 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ public interface RankingConfig { int uid, boolean includeDeleted); void createNotificationChannel(String pkg, int uid, NotificationChannel channel, boolean fromTargetApp); void updateNotificationChannel(String pkg, int uid, NotificationChannel channel); void updateNotificationChannel(String pkg, int uid, NotificationChannel channel, boolean fromUser); NotificationChannel getNotificationChannel(String pkg, int uid, String channelId, boolean includeDeleted); void deleteNotificationChannel(String pkg, int uid, String channelId); void permanentlyDeleteNotificationChannel(String pkg, int uid, String channelId); Loading
services/core/java/com/android/server/notification/RankingHelper.java +7 −4 Original line number Diff line number Diff line Loading @@ -589,7 +589,8 @@ public class RankingHelper implements RankingConfig { } @Override public void updateNotificationChannel(String pkg, int uid, NotificationChannel updatedChannel) { public void updateNotificationChannel(String pkg, int uid, NotificationChannel updatedChannel, boolean fromUser) { Preconditions.checkNotNull(updatedChannel); Preconditions.checkNotNull(updatedChannel.getId()); Record r = getOrCreateRecord(pkg, uid); Loading @@ -603,7 +604,11 @@ public class RankingHelper implements RankingConfig { if (updatedChannel.getLockscreenVisibility() == Notification.VISIBILITY_PUBLIC) { updatedChannel.setLockscreenVisibility(Ranking.VISIBILITY_NO_OVERRIDE); } updatedChannel.unlockFields(updatedChannel.getUserLockedFields()); updatedChannel.lockFields(channel.getUserLockedFields()); if (fromUser) { lockFieldsForUpdate(channel, updatedChannel); } r.channels.put(updatedChannel.getId(), updatedChannel); if (NotificationChannel.DEFAULT_CHANNEL_ID.equals(updatedChannel.getId())) { Loading Loading @@ -828,8 +833,6 @@ public class RankingHelper implements RankingConfig { @VisibleForTesting void lockFieldsForUpdate(NotificationChannel original, NotificationChannel update) { update.unlockFields(update.getUserLockedFields()); update.lockFields(original.getUserLockedFields()); if (original.canBypassDnd() != update.canBypassDnd()) { update.lockFields(NotificationChannel.USER_LOCKED_PRIORITY); } Loading
services/tests/notification/src/com/android/server/notification/NotificationManagerServiceTest.java +148 −16 Original line number Diff line number Diff line Loading @@ -16,12 +16,15 @@ package com.android.server.notification; import static android.app.NotificationManager.IMPORTANCE_HIGH; import static android.app.NotificationManager.IMPORTANCE_LOW; import static android.app.NotificationManager.IMPORTANCE_NONE; import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED; import static android.content.pm.PackageManager.PERMISSION_DENIED; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertNull; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.fail; Loading Loading @@ -56,6 +59,7 @@ import android.content.pm.ParceledListSlice; import android.graphics.Color; import android.media.AudioManager; import android.os.Binder; import android.os.Build; import android.os.Process; import android.os.UserHandle; import android.provider.Settings.Secure; Loading Loading @@ -241,6 +245,7 @@ public class NotificationManagerServiceTest extends NotificationTestCase { nb.build(), new UserHandle(mUid), null, 0); return new NotificationRecord(mContext, sbn, channel); } private NotificationRecord generateNotificationRecord(NotificationChannel channel) { return generateNotificationRecord(channel, null); } Loading Loading @@ -342,7 +347,7 @@ public class NotificationManagerServiceTest extends NotificationTestCase { // Recreating the channel doesn't throw, but ignores importance. final NotificationChannel dupeChannel = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_HIGH); new NotificationChannel("id", "name", IMPORTANCE_HIGH); mBinderService.createNotificationChannels(PKG, new ParceledListSlice(Arrays.asList(dupeChannel))); final NotificationChannel createdChannel = Loading Loading @@ -378,7 +383,7 @@ public class NotificationManagerServiceTest extends NotificationTestCase { // The user modifies importance directly, can no longer be changed by the app. final NotificationChannel updatedChannel = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_HIGH); new NotificationChannel("id", "name", IMPORTANCE_HIGH); mBinderService.updateNotificationChannelForPackage(PKG, mUid, updatedChannel); // Recreating with a lower importance leaves channel unchanged. Loading @@ -388,7 +393,7 @@ public class NotificationManagerServiceTest extends NotificationTestCase { new ParceledListSlice(Arrays.asList(dupeChannel))); final NotificationChannel createdChannel = mBinderService.getNotificationChannel(PKG, "id"); assertEquals(NotificationManager.IMPORTANCE_HIGH, createdChannel.getImportance()); assertEquals(IMPORTANCE_HIGH, createdChannel.getImportance()); } @Test Loading @@ -397,7 +402,7 @@ public class NotificationManagerServiceTest extends NotificationTestCase { final NotificationChannel channel1 = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_DEFAULT); final NotificationChannel channel2 = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_HIGH); new NotificationChannel("id", "name", IMPORTANCE_HIGH); mBinderService.createNotificationChannels(PKG, new ParceledListSlice(Arrays.asList(channel1, channel2))); final NotificationChannel createdChannel = Loading @@ -410,7 +415,7 @@ public class NotificationManagerServiceTest extends NotificationTestCase { when(mPackageManager.isPackageSuspendedForUser(anyString(), anyInt())).thenReturn(true); NotificationChannel channel = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_HIGH); IMPORTANCE_HIGH); NotificationRecord r = generateNotificationRecord(channel); assertTrue(mNotificationManagerService.isBlocked(r, mUsageStats)); verify(mUsageStats, times(1)).registerSuspendedByAdmin(eq(r)); Loading @@ -421,11 +426,68 @@ public class NotificationManagerServiceTest extends NotificationTestCase { when(mPackageManager.isPackageSuspendedForUser(anyString(), anyInt())).thenReturn(false); NotificationChannel channel = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_HIGH); channel.setImportance(IMPORTANCE_NONE); NotificationManager.IMPORTANCE_NONE); NotificationRecord r = generateNotificationRecord(channel); assertTrue(mNotificationManagerService.isBlocked(r, mUsageStats)); verify(mUsageStats, times(1)).registerBlocked(eq(r)); mBinderService.createNotificationChannels( PKG, new ParceledListSlice(Arrays.asList(channel))); final StatusBarNotification sbn = generateNotificationRecord(channel).sbn; mBinderService.enqueueNotificationWithTag(PKG, "opPkg", "tag", sbn.getId(), sbn.getNotification(), sbn.getUserId()); waitForIdle(); assertEquals(0, mBinderService.getActiveNotifications(sbn.getPackageName()).length); } @Test public void testEnqueuedBlockedNotifications_appBlockedChannelForegroundService() throws Exception { when(mPackageManager.isPackageSuspendedForUser(anyString(), anyInt())).thenReturn(false); NotificationChannel channel = new NotificationChannel("blocked", "name", NotificationManager.IMPORTANCE_NONE); mBinderService.createNotificationChannels( PKG, new ParceledListSlice(Arrays.asList(channel))); final StatusBarNotification sbn = generateNotificationRecord(channel).sbn; sbn.getNotification().flags |= Notification.FLAG_FOREGROUND_SERVICE; mBinderService.enqueueNotificationWithTag(PKG, "opPkg", "tag", sbn.getId(), sbn.getNotification(), sbn.getUserId()); waitForIdle(); assertEquals(1, mBinderService.getActiveNotifications(sbn.getPackageName()).length); assertEquals(IMPORTANCE_LOW, mNotificationManagerService.getNotificationRecord(sbn.getKey()).getImportance()); assertEquals(IMPORTANCE_LOW, mBinderService.getNotificationChannel(PKG, channel.getId()).getImportance()); } @Test public void testEnqueuedBlockedNotifications_userBlockedChannelForegroundService() throws Exception { when(mPackageManager.isPackageSuspendedForUser(anyString(), anyInt())).thenReturn(false); NotificationChannel channel = new NotificationChannel("blockedbyuser", "name", IMPORTANCE_HIGH); mBinderService.createNotificationChannels( PKG, new ParceledListSlice(Arrays.asList(channel))); NotificationChannel update = new NotificationChannel("blockedbyuser", "name", IMPORTANCE_NONE); mBinderService.updateNotificationChannelForPackage(PKG, mUid, update); waitForIdle(); assertEquals(IMPORTANCE_NONE, mBinderService.getNotificationChannel(PKG, channel.getId()).getImportance()); final StatusBarNotification sbn = generateNotificationRecord(channel).sbn; sbn.getNotification().flags |= Notification.FLAG_FOREGROUND_SERVICE; mBinderService.enqueueNotificationWithTag(PKG, "opPkg", "tag", sbn.getId(), sbn.getNotification(), sbn.getUserId()); waitForIdle(); assertEquals(0, mBinderService.getActiveNotifications(sbn.getPackageName()).length); assertNull(mNotificationManagerService.getNotificationRecord(sbn.getKey())); assertEquals(IMPORTANCE_NONE, mBinderService.getNotificationChannel(PKG, channel.getId()).getImportance()); } @Test Loading @@ -441,6 +503,21 @@ public class NotificationManagerServiceTest extends NotificationTestCase { assertEquals(0, mBinderService.getActiveNotifications(sbn.getPackageName()).length); } @Test public void testEnqueuedBlockedNotifications_blockedAppForegroundService() throws Exception { when(mPackageManager.isPackageSuspendedForUser(anyString(), anyInt())).thenReturn(false); mBinderService.setNotificationsEnabledForPackage(PKG, mUid, false); final StatusBarNotification sbn = generateNotificationRecord(null).sbn; sbn.getNotification().flags |= Notification.FLAG_FOREGROUND_SERVICE; mBinderService.enqueueNotificationWithTag(PKG, "opPkg", "tag", sbn.getId(), sbn.getNotification(), sbn.getUserId()); waitForIdle(); assertEquals(0, mBinderService.getActiveNotifications(sbn.getPackageName()).length); assertNull(mNotificationManagerService.getNotificationRecord(sbn.getKey())); } @Test public void testEnqueueNotificationWithTag_PopulatesGetActiveNotifications() throws Exception { mBinderService.enqueueNotificationWithTag(PKG, "opPkg", "tag", 0, Loading Loading @@ -798,7 +875,7 @@ public class NotificationManagerServiceTest extends NotificationTestCase { mNotificationManagerService.setRankingHelper(mRankingHelper); when(mRankingHelper.getNotificationChannel( anyString(), anyInt(), eq("foo"), anyBoolean())).thenReturn( new NotificationChannel("foo", "foo", NotificationManager.IMPORTANCE_HIGH)); new NotificationChannel("foo", "foo", IMPORTANCE_HIGH)); Notification.TvExtender tv = new Notification.TvExtender().setChannelId("foo"); mBinderService.enqueueNotificationWithTag(PKG, "opPkg", "tag", 0, Loading Loading @@ -927,7 +1004,8 @@ public class NotificationManagerServiceTest extends NotificationTestCase { mBinderService.updateNotificationChannelFromPrivilegedListener( null, PKG, Process.myUserHandle(), mTestNotificationChannel); verify(mRankingHelper, times(1)).updateNotificationChannel(anyString(), anyInt(), any()); verify(mRankingHelper, times(1)).updateNotificationChannel( anyString(), anyInt(), any(), anyBoolean()); verify(mListeners, never()).notifyNotificationChannelChanged(eq(PKG), eq(Process.myUserHandle()), eq(mTestNotificationChannel), Loading @@ -948,7 +1026,8 @@ public class NotificationManagerServiceTest extends NotificationTestCase { // pass } verify(mRankingHelper, never()).updateNotificationChannel(anyString(), anyInt(), any()); verify(mRankingHelper, never()).updateNotificationChannel( anyString(), anyInt(), any(), anyBoolean()); verify(mListeners, never()).notifyNotificationChannelChanged(eq(PKG), eq(Process.myUserHandle()), eq(mTestNotificationChannel), Loading @@ -974,7 +1053,8 @@ public class NotificationManagerServiceTest extends NotificationTestCase { // pass } verify(mRankingHelper, never()).updateNotificationChannel(anyString(), anyInt(), any()); verify(mRankingHelper, never()).updateNotificationChannel( anyString(), anyInt(), any(), anyBoolean()); verify(mListeners, never()).notifyNotificationChannelChanged(eq(PKG), eq(Process.myUserHandle()), eq(mTestNotificationChannel), Loading Loading @@ -1345,7 +1425,8 @@ public class NotificationManagerServiceTest extends NotificationTestCase { @Test public void testOnlyAutogroupIfGroupChanged_groupChanged_autogroups() throws Exception { NotificationRecord r = generateNotificationRecord(mTestNotificationChannel, 0, "group", false); NotificationRecord r = generateNotificationRecord(mTestNotificationChannel, 0, "group", false); mNotificationManagerService.addNotification(r); r = generateNotificationRecord(mTestNotificationChannel, 0, null, false); Loading Loading @@ -1425,12 +1506,16 @@ public class NotificationManagerServiceTest extends NotificationTestCase { // Same notifications are enqueued as posted, everything counts b/c id and tag don't match int userId = new UserHandle(mUid).getIdentifier(); assertEquals(40, mNotificationManagerService.getNotificationCountLocked(PKG, userId, 0, null)); assertEquals(40, mNotificationManagerService.getNotificationCountLocked(PKG, userId, 0, "tag2")); assertEquals(2, mNotificationManagerService.getNotificationCountLocked("a", userId, 0, "banana")); assertEquals(40, mNotificationManagerService.getNotificationCountLocked(PKG, userId, 0, null)); assertEquals(40, mNotificationManagerService.getNotificationCountLocked(PKG, userId, 0, "tag2")); assertEquals(2, mNotificationManagerService.getNotificationCountLocked("a", userId, 0, "banana")); // exclude a known notification - it's excluded from only the posted list, not enqueued assertEquals(39, mNotificationManagerService.getNotificationCountLocked(PKG, userId, 0, "tag")); assertEquals(39, mNotificationManagerService.getNotificationCountLocked(PKG, userId, 0, "tag")); } @Test Loading Loading @@ -1560,4 +1645,51 @@ public class NotificationManagerServiceTest extends NotificationTestCase { verify(mZenModeHelper, times(1)).updateDefaultZenRules(); } @Test public void testBumpFGImportance_noChannelChangePreOApp() throws Exception { String preOPkg = "preO"; int preOUid = 145; final ApplicationInfo legacy = new ApplicationInfo(); legacy.targetSdkVersion = Build.VERSION_CODES.N_MR1; when(mPackageManagerClient.getApplicationInfoAsUser(eq(preOPkg), anyInt(), anyInt())) .thenReturn(legacy); when(mPackageManagerClient.getPackageUidAsUser(eq(preOPkg), anyInt())).thenReturn(preOUid); getContext().setMockPackageManager(mPackageManagerClient); Notification.Builder nb = new Notification.Builder(mContext, NotificationChannel.DEFAULT_CHANNEL_ID) .setContentTitle("foo") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setFlag(Notification.FLAG_FOREGROUND_SERVICE, true) .setPriority(Notification.PRIORITY_MIN); StatusBarNotification sbn = new StatusBarNotification(preOPkg, preOPkg, 9, "tag", preOUid, 0, nb.build(), new UserHandle(preOUid), null, 0); mBinderService.enqueueNotificationWithTag(preOPkg, preOPkg, "tag", sbn.getId(), sbn.getNotification(), sbn.getUserId()); waitForIdle(); assertEquals(IMPORTANCE_LOW, mNotificationManagerService.getNotificationRecord(sbn.getKey()).getImportance()); nb = new Notification.Builder(mContext) .setContentTitle("foo") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setFlag(Notification.FLAG_FOREGROUND_SERVICE, true) .setPriority(Notification.PRIORITY_MIN); sbn = new StatusBarNotification(preOPkg, preOPkg, 9, "tag", preOUid, 0, nb.build(), new UserHandle(preOUid), null, 0); mBinderService.enqueueNotificationWithTag(preOPkg, preOPkg, "tag", sbn.getId(), sbn.getNotification(), sbn.getUserId()); waitForIdle(); assertEquals(IMPORTANCE_LOW, mNotificationManagerService.getNotificationRecord(sbn.getKey()).getImportance()); NotificationChannel defaultChannel = mBinderService.getNotificationChannel( preOPkg, NotificationChannel.DEFAULT_CHANNEL_ID); assertEquals(IMPORTANCE_UNSPECIFIED, defaultChannel.getImportance()); } }
services/tests/notification/src/com/android/server/notification/RankingHelperTest.java +14 −14 Original line number Diff line number Diff line Loading @@ -484,7 +484,7 @@ public class RankingHelperTest extends NotificationTestCase { final NotificationChannel defaultChannel = mHelper.getNotificationChannel(PKG, UID, NotificationChannel.DEFAULT_CHANNEL_ID, false); defaultChannel.setImportance(NotificationManager.IMPORTANCE_LOW); mHelper.updateNotificationChannel(PKG, UID, defaultChannel); mHelper.updateNotificationChannel(PKG, UID, defaultChannel, true); ByteArrayOutputStream baos = writeXmlAndPurge(PKG, UID, false, NotificationChannel.DEFAULT_CHANNEL_ID); Loading Loading @@ -633,7 +633,7 @@ public class RankingHelperTest extends NotificationTestCase { channel2.setBypassDnd(false); channel2.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); mHelper.updateNotificationChannel(PKG, UID, channel2); mHelper.updateNotificationChannel(PKG, UID, channel2, true); // all fields should be changed assertEquals(channel2, mHelper.getNotificationChannel(PKG, UID, channel.getId(), false)); Loading @@ -657,7 +657,7 @@ public class RankingHelperTest extends NotificationTestCase { defaultChannel.setBypassDnd(true); defaultChannel.setLockscreenVisibility(Notification.VISIBILITY_SECRET); mHelper.updateNotificationChannel(PKG, UID, defaultChannel); mHelper.updateNotificationChannel(PKG, UID, defaultChannel, true); // ensure app level fields are changed assertFalse(mHelper.canShowBadge(PKG, UID)); Loading @@ -681,7 +681,7 @@ public class RankingHelperTest extends NotificationTestCase { channel.setBypassDnd(true); channel.setLockscreenVisibility(Notification.VISIBILITY_SECRET); mHelper.updateNotificationChannel(PKG, UID, channel); mHelper.updateNotificationChannel(PKG, UID, channel, true); // ensure app level fields are not changed assertTrue(mHelper.canShowBadge(PKG, UID)); Loading Loading @@ -772,14 +772,14 @@ public class RankingHelperTest extends NotificationTestCase { update1.setSound(new Uri.Builder().scheme("test").build(), new AudioAttributes.Builder().build()); update1.lockFields(NotificationChannel.USER_LOCKED_PRIORITY); // should be ignored mHelper.updateNotificationChannel(PKG, UID, update1); mHelper.updateNotificationChannel(PKG, UID, update1, true); assertEquals(NotificationChannel.USER_LOCKED_SOUND, mHelper.getNotificationChannel(PKG, UID, update1.getId(), false) .getUserLockedFields()); NotificationChannel update2 = getChannel(); update2.enableVibration(true); mHelper.updateNotificationChannel(PKG, UID, update2); mHelper.updateNotificationChannel(PKG, UID, update2, true); assertEquals(NotificationChannel.USER_LOCKED_SOUND | NotificationChannel.USER_LOCKED_VIBRATION, mHelper.getNotificationChannel(PKG, UID, update2.getId(), false) Loading @@ -792,14 +792,14 @@ public class RankingHelperTest extends NotificationTestCase { final NotificationChannel update1 = getChannel(); update1.setVibrationPattern(new long[]{7945, 46 ,246}); mHelper.updateNotificationChannel(PKG, UID, update1); mHelper.updateNotificationChannel(PKG, UID, update1, true); assertEquals(NotificationChannel.USER_LOCKED_VIBRATION, mHelper.getNotificationChannel(PKG, UID, update1.getId(), false) .getUserLockedFields()); final NotificationChannel update2 = getChannel(); update2.enableLights(true); mHelper.updateNotificationChannel(PKG, UID, update2); mHelper.updateNotificationChannel(PKG, UID, update2, true); assertEquals(NotificationChannel.USER_LOCKED_VIBRATION | NotificationChannel.USER_LOCKED_LIGHTS, mHelper.getNotificationChannel(PKG, UID, update2.getId(), false) Loading @@ -812,14 +812,14 @@ public class RankingHelperTest extends NotificationTestCase { final NotificationChannel update1 = getChannel(); update1.setLightColor(Color.GREEN); mHelper.updateNotificationChannel(PKG, UID, update1); mHelper.updateNotificationChannel(PKG, UID, update1, true); assertEquals(NotificationChannel.USER_LOCKED_LIGHTS, mHelper.getNotificationChannel(PKG, UID, update1.getId(), false) .getUserLockedFields()); final NotificationChannel update2 = getChannel(); update2.setImportance(IMPORTANCE_DEFAULT); mHelper.updateNotificationChannel(PKG, UID, update2); mHelper.updateNotificationChannel(PKG, UID, update2, true); assertEquals(NotificationChannel.USER_LOCKED_LIGHTS | NotificationChannel.USER_LOCKED_IMPORTANCE, mHelper.getNotificationChannel(PKG, UID, update2.getId(), false) Loading @@ -835,14 +835,14 @@ public class RankingHelperTest extends NotificationTestCase { final NotificationChannel update1 = getChannel(); update1.setBypassDnd(true); mHelper.updateNotificationChannel(PKG, UID, update1); mHelper.updateNotificationChannel(PKG, UID, update1, true); assertEquals(NotificationChannel.USER_LOCKED_PRIORITY, mHelper.getNotificationChannel(PKG, UID, update1.getId(), false) .getUserLockedFields()); final NotificationChannel update2 = getChannel(); update2.setLockscreenVisibility(Notification.VISIBILITY_SECRET); mHelper.updateNotificationChannel(PKG, UID, update2); mHelper.updateNotificationChannel(PKG, UID, update2, true); assertEquals(NotificationChannel.USER_LOCKED_PRIORITY | NotificationChannel.USER_LOCKED_VISIBILITY, mHelper.getNotificationChannel(PKG, UID, update2.getId(), false) Loading @@ -850,7 +850,7 @@ public class RankingHelperTest extends NotificationTestCase { final NotificationChannel update3 = getChannel(); update3.setShowBadge(false); mHelper.updateNotificationChannel(PKG, UID, update3); mHelper.updateNotificationChannel(PKG, UID, update3, true); assertEquals(NotificationChannel.USER_LOCKED_PRIORITY | NotificationChannel.USER_LOCKED_VISIBILITY | NotificationChannel.USER_LOCKED_SHOW_BADGE, Loading Loading @@ -1263,7 +1263,7 @@ public class RankingHelperTest extends NotificationTestCase { mHelper.getNotificationChannelGroups(PKG, UID, true).getList(); channel1.setImportance(IMPORTANCE_LOW); mHelper.updateNotificationChannel(PKG, UID, channel1); mHelper.updateNotificationChannel(PKG, UID, channel1, true); List<NotificationChannelGroup> actual = mHelper.getNotificationChannelGroups(PKG, UID, true).getList(); Loading