diff --git a/services/core/java/com/android/server/notification/RankingHelper.java b/services/core/java/com/android/server/notification/RankingHelper.java index a42a70efc5411..73afaa089dd49 100644 --- a/services/core/java/com/android/server/notification/RankingHelper.java +++ b/services/core/java/com/android/server/notification/RankingHelper.java @@ -684,11 +684,11 @@ public class RankingHelper implements RankingConfig { NotificationChannel channel = r.channels.get(channelId); if (channel != null) { channel.setDeleted(true); + LogMaker lm = getChannelLog(channel, pkg); + lm.setType(MetricsProto.MetricsEvent.TYPE_CLOSE); + MetricsLogger.action(lm); + updateConfig(); } - LogMaker lm = getChannelLog(channel, pkg); - lm.setType(MetricsProto.MetricsEvent.TYPE_CLOSE); - MetricsLogger.action(lm); - updateConfig(); } @Override 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 af44264a6bccb..40af2f89c93ad 100644 --- a/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java +++ b/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java @@ -726,6 +726,11 @@ public class RankingHelperTest { assertEquals(channel.canShowBadge(), savedChannel.canShowBadge()); } + @Test + public void testDeleteNonExistentChannel() throws Exception { + mHelper.deleteNotificationChannelGroup(PKG, UID, "does not exist"); + } + @Test public void testGetDeletedChannel() throws Exception { NotificationChannel channel =