From 8e0eb372c9c5c941609daca554c92a44ee61c063 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Tue, 21 Mar 2017 15:04:50 -0400 Subject: [PATCH] Null check! Now with a test Test: runtest systemui-notification Change-Id: I0b98b3dd6aeaa7e300bba98b7d7f7f5afae16596 Fixes: 36245468 --- .../com/android/server/notification/RankingHelper.java | 8 ++++---- .../android/server/notification/RankingHelperTest.java | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/notification/RankingHelper.java b/services/core/java/com/android/server/notification/RankingHelper.java index ce79465d72603..643ef7d14c142 100644 --- a/services/core/java/com/android/server/notification/RankingHelper.java +++ b/services/core/java/com/android/server/notification/RankingHelper.java @@ -683,11 +683,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 5a94018c6eb13..761d9b33e80d5 100644 --- a/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java +++ b/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java @@ -724,6 +724,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 =