diff options
| author | 2017-09-22 15:26:41 +0000 | |
|---|---|---|
| committer | 2017-09-22 15:26:41 +0000 | |
| commit | 77dad3919e12abf3cc8c25a7bb4080dadf2f768d (patch) | |
| tree | 0cb3ce6c81c9be3608e898f1393a027004fc3301 | |
| parent | bdb42e66a29b9ca663f1f1cb3bc002fdbae54719 (diff) | |
| parent | dcaae9dbd07bee1fb66245b9f7d78a70a29662f6 (diff) | |
Bump the importance of foreground service notis am: 8617e4ec9e
am: dcaae9dbd0
Change-Id: I05d29d9d230f75c579f163c61c44d05c700a446a
5 files changed, 195 insertions, 37 deletions
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index fe39fccbc781..dd2acdfee760 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -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; @@ -1142,6 +1144,12 @@ public class NotificationManagerService extends SystemService { } @VisibleForTesting + NotificationRecord getNotificationRecord(String key) { + return mNotificationsByKey.get(key); + } + + + @VisibleForTesting void setSystemReady(boolean systemReady) { mSystemReady = systemReady; } @@ -1216,7 +1224,7 @@ public class NotificationManagerService extends SystemService { mUsageStats = usageStats; mRankingHandler = new RankingHandlerWorker(mRankingThread.getLooper()); mRankingHelper = new RankingHelper(getContext(), - getContext().getPackageManager(), + mPackageManagerClient, mRankingHandler, mUsageStats, extractorNames); @@ -1476,7 +1484,7 @@ public class NotificationManagerService extends SystemService { } } } - mRankingHelper.updateNotificationChannel(pkg, uid, channel); + mRankingHelper.updateNotificationChannel(pkg, uid, channel, true); if (!fromListener) { final NotificationChannel modifiedChannel = @@ -3519,6 +3527,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; diff --git a/services/core/java/com/android/server/notification/RankingConfig.java b/services/core/java/com/android/server/notification/RankingConfig.java index b5ef1c60f607..b9c0d90741f3 100644 --- a/services/core/java/com/android/server/notification/RankingConfig.java +++ b/services/core/java/com/android/server/notification/RankingConfig.java @@ -39,7 +39,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); diff --git a/services/core/java/com/android/server/notification/RankingHelper.java b/services/core/java/com/android/server/notification/RankingHelper.java index fc24581f148f..fea2464ba5b8 100644 --- a/services/core/java/com/android/server/notification/RankingHelper.java +++ b/services/core/java/com/android/server/notification/RankingHelper.java @@ -613,7 +613,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); @@ -627,7 +628,11 @@ public class RankingHelper implements RankingConfig { if (updatedChannel.getLockscreenVisibility() == Notification.VISIBILITY_PUBLIC) { updatedChannel.setLockscreenVisibility(Ranking.VISIBILITY_NO_OVERRIDE); } - lockFieldsForUpdate(channel, updatedChannel); + 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())) { @@ -874,8 +879,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); } diff --git a/services/tests/notification/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/notification/src/com/android/server/notification/NotificationManagerServiceTest.java index ddd21df78e85..71a024c5be07 100644 --- a/services/tests/notification/src/com/android/server/notification/NotificationManagerServiceTest.java +++ b/services/tests/notification/src/com/android/server/notification/NotificationManagerServiceTest.java @@ -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; @@ -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; @@ -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); } @@ -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 = @@ -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. @@ -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 @@ -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 = @@ -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)); @@ -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 @@ -456,6 +518,21 @@ public class NotificationManagerServiceTest extends NotificationTestCase { } @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, generateNotificationRecord(null).getNotification(), 0); @@ -812,7 +889,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, @@ -941,7 +1018,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), @@ -962,7 +1040,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), @@ -988,7 +1067,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), @@ -1359,7 +1439,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); @@ -1439,12 +1520,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 @@ -1574,4 +1659,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()); + } } diff --git a/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java b/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java index 306dd98acaad..2249ff0ce448 100644 --- a/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java +++ b/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java @@ -497,7 +497,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); @@ -646,7 +646,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)); @@ -670,7 +670,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)); @@ -694,7 +694,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)); @@ -785,14 +785,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) @@ -805,14 +805,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) @@ -825,14 +825,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) @@ -848,14 +848,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) @@ -863,7 +863,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, @@ -1276,7 +1276,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(); |