summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2019-01-30 00:21:20 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-01-30 00:21:20 +0000
commit1931fa5033d1863ab06f558826450705bee00adc (patch)
tree773782122e55211f34d362d13cedda9011d06941
parenta19463022148662498c2d3d10e36ab24a17b0389 (diff)
parentbd5590968f9b0b670735f4907cb2da08d0585a26 (diff)
Merge "Fixes an issue where users could be stuck with heads up notifications"
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/AlertingNotificationManager.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java8
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/AlertingNotificationManagerTest.java21
3 files changed, 33 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/AlertingNotificationManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/AlertingNotificationManager.java
index a776d0fbb45e..2f1963057ad4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/AlertingNotificationManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/AlertingNotificationManager.java
@@ -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);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java
index 7f75223407de..035ccf1d6b81 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java
@@ -359,6 +359,14 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
}
@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();
mStatusBarHeight = resources.getDimensionPixelSize(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/AlertingNotificationManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/AlertingNotificationManagerTest.java
index f8957b204021..660f853b3c7b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/AlertingNotificationManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/AlertingNotificationManagerTest.java
@@ -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;
@@ -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;
@@ -88,6 +92,12 @@ public class AlertingNotificationManagerTest extends SysuiTestCase {
protected void onAlertEntryRemoved(AlertEntry alertEntry) {}
@Override
+ protected AlertEntry createAlertEntry() {
+ mLastCreatedEntry = spy(super.createAlertEntry());
+ return mLastCreatedEntry;
+ }
+
+ @Override
public int getContentFlag() {
return FLAG_CONTENT_VIEW_CONTRACTED;
}
@@ -206,6 +216,17 @@ public class AlertingNotificationManagerTest extends SysuiTestCase {
}
@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);