Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -440,6 +440,10 @@ public class NotificationEntryManager implements mLogger.logLifetimeExtended(key, extender.getClass().getName(), "pending"); mLogger.logLifetimeExtended(key, extender.getClass().getName(), "pending"); } } } } if (!lifetimeExtended) { // At this point, we are guaranteed the notification will be removed mAllNotifications.remove(pendingEntry); } } } } } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java +24 −0 Original line number Original line Diff line number Diff line Loading @@ -26,6 +26,7 @@ import static junit.framework.Assert.assertNull; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.assertTrue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyInt; Loading Loading @@ -93,6 +94,7 @@ import org.mockito.MockitoAnnotations; import java.util.ArrayList; import java.util.ArrayList; import java.util.Arrays; import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.List; import java.util.Set; import java.util.Set; Loading Loading @@ -260,6 +262,19 @@ public class NotificationEntryManagerTest extends SysuiTestCase { assertNull(mEntryManager.getActiveNotificationUnfiltered(mSbn.getKey())); assertNull(mEntryManager.getActiveNotificationUnfiltered(mSbn.getKey())); } } @Test public void testRemoveUninflatedNotification_removesNotificationFromAllNotifsList() { // GIVEN an uninflated entry is added mEntryManager.addNotification(mSbn, mRankingMap); assertTrue(entriesContainKey(mEntryManager.getAllNotifs(), mSbn.getKey())); // WHEN the uninflated entry is removed mEntryManager.performRemoveNotification(mSbn, UNDEFINED_DISMISS_REASON); // THEN the entry is still removed from the allNotifications list assertFalse(entriesContainKey(mEntryManager.getAllNotifs(), mSbn.getKey())); } @Test @Test public void testRemoveNotification_onEntryRemoveNotFiredIfEntryDoesntExist() { public void testRemoveNotification_onEntryRemoveNotFiredIfEntryDoesntExist() { Loading Loading @@ -545,6 +560,15 @@ public class NotificationEntryManagerTest extends SysuiTestCase { /* End annex */ /* End annex */ private boolean entriesContainKey(Collection<NotificationEntry> entries, String key) { for (NotificationEntry entry : entries) { if (entry.getSbn().getKey().equals(key)) { return true; } } return false; } private Notification.Action createAction() { private Notification.Action createAction() { return new Notification.Action.Builder( return new Notification.Action.Builder( Icon.createWithResource(getContext(), android.R.drawable.sym_def_app_icon), Icon.createWithResource(getContext(), android.R.drawable.sym_def_app_icon), Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -440,6 +440,10 @@ public class NotificationEntryManager implements mLogger.logLifetimeExtended(key, extender.getClass().getName(), "pending"); mLogger.logLifetimeExtended(key, extender.getClass().getName(), "pending"); } } } } if (!lifetimeExtended) { // At this point, we are guaranteed the notification will be removed mAllNotifications.remove(pendingEntry); } } } } } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java +24 −0 Original line number Original line Diff line number Diff line Loading @@ -26,6 +26,7 @@ import static junit.framework.Assert.assertNull; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.assertTrue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyInt; Loading Loading @@ -93,6 +94,7 @@ import org.mockito.MockitoAnnotations; import java.util.ArrayList; import java.util.ArrayList; import java.util.Arrays; import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.List; import java.util.Set; import java.util.Set; Loading Loading @@ -260,6 +262,19 @@ public class NotificationEntryManagerTest extends SysuiTestCase { assertNull(mEntryManager.getActiveNotificationUnfiltered(mSbn.getKey())); assertNull(mEntryManager.getActiveNotificationUnfiltered(mSbn.getKey())); } } @Test public void testRemoveUninflatedNotification_removesNotificationFromAllNotifsList() { // GIVEN an uninflated entry is added mEntryManager.addNotification(mSbn, mRankingMap); assertTrue(entriesContainKey(mEntryManager.getAllNotifs(), mSbn.getKey())); // WHEN the uninflated entry is removed mEntryManager.performRemoveNotification(mSbn, UNDEFINED_DISMISS_REASON); // THEN the entry is still removed from the allNotifications list assertFalse(entriesContainKey(mEntryManager.getAllNotifs(), mSbn.getKey())); } @Test @Test public void testRemoveNotification_onEntryRemoveNotFiredIfEntryDoesntExist() { public void testRemoveNotification_onEntryRemoveNotFiredIfEntryDoesntExist() { Loading Loading @@ -545,6 +560,15 @@ public class NotificationEntryManagerTest extends SysuiTestCase { /* End annex */ /* End annex */ private boolean entriesContainKey(Collection<NotificationEntry> entries, String key) { for (NotificationEntry entry : entries) { if (entry.getSbn().getKey().equals(key)) { return true; } } return false; } private Notification.Action createAction() { private Notification.Action createAction() { return new Notification.Action.Builder( return new Notification.Action.Builder( Icon.createWithResource(getContext(), android.R.drawable.sym_def_app_icon), Icon.createWithResource(getContext(), android.R.drawable.sym_def_app_icon), Loading