Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1931fa50 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fixes an issue where users could be stuck with heads up notifications"

parents a1946302 bd559096
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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);
        }
+8 −0
Original line number Diff line number Diff line
@@ -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();
+21 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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);