Loading packages/SystemUI/src/com/android/systemui/statusbar/AlertingNotificationManager.java +4 −0 Original line number Diff line number Diff line Loading @@ -257,6 +257,10 @@ public abstract class AlertingNotificationManager implements NotificationLifetim public void setShouldManageLifetime(NotificationEntry entry, boolean shouldExtend) { if (shouldExtend) { mExtendedLifetimeAlertEntries.add(entry); // We need to make sure that entries are stopping to alert eventually, let's remove // this as soon as possible. AlertEntry alertEntry = mAlertEntries.get(entry.key); alertEntry.removeAsSoonAsPossible(); } else { mExtendedLifetimeAlertEntries.remove(entry); } Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java +8 −0 Original line number Diff line number Diff line Loading @@ -358,6 +358,14 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, region.op(bounds, Op.UNION); } @Override public boolean shouldExtendLifetime(NotificationEntry entry) { // We should not defer the removal if reordering isn't allowed since otherwise // these won't disappear until reordering is allowed again, which happens only once // the notification panel is collapsed again. return mVisualStabilityManager.isReorderingAllowed() && super.shouldExtendLifetime(entry); } @Override public void onConfigChanged(Configuration newConfig) { Resources resources = mContext.getResources(); Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/AlertingNotificationManagerTest.java +21 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import android.app.ActivityManager; import android.app.Notification; Loading Loading @@ -75,6 +77,8 @@ public class AlertingNotificationManagerTest extends SysuiTestCase { @Mock protected ExpandableNotificationRow mRow; private final class TestableAlertingNotificationManager extends AlertingNotificationManager { private AlertEntry mLastCreatedEntry; private TestableAlertingNotificationManager() { mMinimumDisplayTime = TEST_MINIMUM_DISPLAY_TIME; mAutoDismissNotificationDecay = TEST_AUTO_DISMISS_TIME; Loading @@ -87,6 +91,12 @@ public class AlertingNotificationManagerTest extends SysuiTestCase { @Override protected void onAlertEntryRemoved(AlertEntry alertEntry) {} @Override protected AlertEntry createAlertEntry() { mLastCreatedEntry = spy(super.createAlertEntry()); return mLastCreatedEntry; } @Override public int getContentFlag() { return FLAG_CONTENT_VIEW_CONTRACTED; Loading Loading @@ -205,6 +215,17 @@ public class AlertingNotificationManagerTest extends SysuiTestCase { assertTrue(mAlertingNotificationManager.mExtendedLifetimeAlertEntries.contains(mEntry)); } @Test public void testSetShouldManageLifetime_setShouldManageCallsRemoval() { mAlertingNotificationManager.showNotification(mEntry); mAlertingNotificationManager.setShouldManageLifetime(mEntry, true /* shouldManage */); if (mAlertingNotificationManager instanceof TestableAlertingNotificationManager) { TestableAlertingNotificationManager testableManager = (TestableAlertingNotificationManager) mAlertingNotificationManager; verify(testableManager.mLastCreatedEntry).removeAsSoonAsPossible(); } } @Test public void testSetShouldManageLifetime_setShouldNotManage() { mAlertingNotificationManager.mExtendedLifetimeAlertEntries.add(mEntry); Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/AlertingNotificationManager.java +4 −0 Original line number Diff line number Diff line Loading @@ -257,6 +257,10 @@ public abstract class AlertingNotificationManager implements NotificationLifetim public void setShouldManageLifetime(NotificationEntry entry, boolean shouldExtend) { if (shouldExtend) { mExtendedLifetimeAlertEntries.add(entry); // We need to make sure that entries are stopping to alert eventually, let's remove // this as soon as possible. AlertEntry alertEntry = mAlertEntries.get(entry.key); alertEntry.removeAsSoonAsPossible(); } else { mExtendedLifetimeAlertEntries.remove(entry); } Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java +8 −0 Original line number Diff line number Diff line Loading @@ -358,6 +358,14 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, region.op(bounds, Op.UNION); } @Override public boolean shouldExtendLifetime(NotificationEntry entry) { // We should not defer the removal if reordering isn't allowed since otherwise // these won't disappear until reordering is allowed again, which happens only once // the notification panel is collapsed again. return mVisualStabilityManager.isReorderingAllowed() && super.shouldExtendLifetime(entry); } @Override public void onConfigChanged(Configuration newConfig) { Resources resources = mContext.getResources(); Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/AlertingNotificationManagerTest.java +21 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import android.app.ActivityManager; import android.app.Notification; Loading Loading @@ -75,6 +77,8 @@ public class AlertingNotificationManagerTest extends SysuiTestCase { @Mock protected ExpandableNotificationRow mRow; private final class TestableAlertingNotificationManager extends AlertingNotificationManager { private AlertEntry mLastCreatedEntry; private TestableAlertingNotificationManager() { mMinimumDisplayTime = TEST_MINIMUM_DISPLAY_TIME; mAutoDismissNotificationDecay = TEST_AUTO_DISMISS_TIME; Loading @@ -87,6 +91,12 @@ public class AlertingNotificationManagerTest extends SysuiTestCase { @Override protected void onAlertEntryRemoved(AlertEntry alertEntry) {} @Override protected AlertEntry createAlertEntry() { mLastCreatedEntry = spy(super.createAlertEntry()); return mLastCreatedEntry; } @Override public int getContentFlag() { return FLAG_CONTENT_VIEW_CONTRACTED; Loading Loading @@ -205,6 +215,17 @@ public class AlertingNotificationManagerTest extends SysuiTestCase { assertTrue(mAlertingNotificationManager.mExtendedLifetimeAlertEntries.contains(mEntry)); } @Test public void testSetShouldManageLifetime_setShouldManageCallsRemoval() { mAlertingNotificationManager.showNotification(mEntry); mAlertingNotificationManager.setShouldManageLifetime(mEntry, true /* shouldManage */); if (mAlertingNotificationManager instanceof TestableAlertingNotificationManager) { TestableAlertingNotificationManager testableManager = (TestableAlertingNotificationManager) mAlertingNotificationManager; verify(testableManager.mLastCreatedEntry).removeAsSoonAsPossible(); } } @Test public void testSetShouldManageLifetime_setShouldNotManage() { mAlertingNotificationManager.mExtendedLifetimeAlertEntries.add(mEntry); Loading