From 425504c2de2730eb94b7f750ebcedd3d34e67c19 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Tue, 9 Jun 2020 12:17:58 -0400 Subject: [PATCH] Fix blocked notifications screen Don't filter out apps have don't have any usage events - the package's notifications are still blocked Test: atest, and verify that the packages match the 'blocked count' subtext on the previous screen on an affected device Fixes: 158343184 Change-Id: Iac01708849e3ae0b82f97db679ce512fc9675a17 --- .../settings/applications/AppStateNotificationBridge.java | 3 +++ .../applications/AppStateNotificationBridgeTest.java | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/applications/AppStateNotificationBridge.java b/src/com/android/settings/applications/AppStateNotificationBridge.java index d179642a63d..c8bb5f9a667 100644 --- a/src/com/android/settings/applications/AppStateNotificationBridge.java +++ b/src/com/android/settings/applications/AppStateNotificationBridge.java @@ -84,6 +84,9 @@ public class AppStateNotificationBridge extends AppStateBaseBridge { for (AppEntry entry : apps) { NotificationsSentState stats = map.get(getKey(UserHandle.getUserId(entry.info.uid), entry.info.packageName)); + if (stats == null) { + stats = new NotificationsSentState(); + } calculateAvgSentCounts(stats); addBlockStatus(entry, stats); entry.extraInfo = stats; diff --git a/tests/robotests/src/com/android/settings/applications/AppStateNotificationBridgeTest.java b/tests/robotests/src/com/android/settings/applications/AppStateNotificationBridgeTest.java index 24cb10dcc86..e59361e0981 100644 --- a/tests/robotests/src/com/android/settings/applications/AppStateNotificationBridgeTest.java +++ b/tests/robotests/src/com/android/settings/applications/AppStateNotificationBridgeTest.java @@ -211,7 +211,12 @@ public class AppStateNotificationBridgeTest { when(mSession.getAllApps()).thenReturn(apps); mBridge.loadAllExtraInfo(); - assertThat(apps.get(0).extraInfo).isNull(); + // extra info should exist and blocked status should be populated + assertThat(apps.get(0).extraInfo).isNotNull(); + verify(mBackend).getNotificationsBanned(PKG1, 0); + // but the recent/frequent counts should be 0 so they don't appear on those screens + assertThat(((NotificationsSentState) apps.get(0).extraInfo).avgSentDaily).isEqualTo(0); + assertThat(((NotificationsSentState) apps.get(0).extraInfo).lastSent).isEqualTo(0); } @Test