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

Commit 5d3be7c0 authored by Lyn Han's avatar Lyn Han Committed by Android (Google) Code Review
Browse files

Merge "Show FSI HUN for 60 more seconds after update" into udc-dev

parents d1afe0f0 1ba1c39c
Loading
Loading
Loading
Loading
+16 −26
Original line number Diff line number Diff line
@@ -234,7 +234,7 @@ public abstract class AlertingNotificationManager {

    /**
     * @param key
     * @return true if the entry is pinned
     * @return true if the entry is (pinned and expanded) or (has an active remote input)
     */
    public boolean isSticky(String key) {
        AlertEntry alerting = mAlertEntries.get(key);
@@ -256,15 +256,6 @@ public abstract class AlertingNotificationManager {
        return 0;
    }

    @VisibleForTesting
    public long getCalculatedEarliestRemovalTime(String key) {
        AlertEntry alerting = mAlertEntries.get(key);
        if (alerting != null) {
            return alerting.mEarliestRemovaltime;
        }
        return 0;
    }

    protected class AlertEntry implements Comparable<AlertEntry> {
        @Nullable public NotificationEntry mEntry;
        public long mPostTime;
@@ -285,11 +276,6 @@ public abstract class AlertingNotificationManager {
            updateEntry(true /* updatePostTime */);
        }

        @VisibleForTesting
        long getEarliestRemovaltime() {
            return mEarliestRemovaltime;
        }

        /**
         * Updates an entry's removal time.
         * @param updatePostTime whether or not to refresh the post time
@@ -305,23 +291,26 @@ public abstract class AlertingNotificationManager {
            }
            removeAutoRemovalCallbacks();

            if (!isSticky()) {
                final long finishTime = calculateFinishTime();
            final long timeRemaining = isSticky()
                    ? finishTime - mClock.currentTimeMillis()
                    : Math.max(finishTime - now, mMinimumDisplayTime);

            mHandler.postDelayed(mRemoveAlertRunnable, timeRemaining);
                final long timeLeft = Math.max(finishTime - now, mMinimumDisplayTime);
                mHandler.postDelayed(mRemoveAlertRunnable, timeLeft);
            }
        }

        /**
         * Whether or not the notification is "sticky" i.e. should stay on screen regardless
         * of the timer and should be removed externally.
         * of the timer (forever) and should be removed externally.
         * @return true if the notification is sticky
         */
        public boolean isSticky() {
            // This implementation is overridden by HeadsUpManager HeadsUpEntry #isSticky
            // but we keep this here for use by unit tests.
            return mEntry.isStickyAndNotDemoted();
            return false;
        }

        public boolean isStickyForSomeTime() {
            // This implementation is overridden by HeadsUpManager HeadsUpEntry #isStickyForSomeTime
            return false;
        }

        /**
@@ -360,8 +349,9 @@ public abstract class AlertingNotificationManager {
        public void removeAsSoonAsPossible() {
            if (mRemoveAlertRunnable != null) {
                removeAutoRemovalCallbacks();
                mHandler.postDelayed(mRemoveAlertRunnable,
                        mEarliestRemovaltime - mClock.currentTimeMillis());

                final long timeLeft = mEarliestRemovaltime - mClock.currentTimeMillis();
                mHandler.postDelayed(mRemoveAlertRunnable, timeLeft);
            }
        }

+11 −8
Original line number Diff line number Diff line
@@ -410,11 +410,14 @@ public abstract class HeadsUpManager extends AlertingNotificationManager {

        @Override
        public boolean isSticky() {
            final boolean isSticky = (mEntry.isRowPinned() && expanded)
            return (mEntry.isRowPinned() && expanded)
                    || remoteInputActive
                    || hasFullScreenIntent(mEntry)
                    || mEntry.isStickyAndNotDemoted();
            return isSticky;
                    || hasFullScreenIntent(mEntry);
        }

        @Override
        public boolean isStickyForSomeTime() {
            return mEntry.isStickyAndNotDemoted();
        }

        @Override
@@ -476,10 +479,10 @@ public abstract class HeadsUpManager extends AlertingNotificationManager {
         */
        @Override
        protected long calculateFinishTime() {
            if (isSticky()) {
                return mEntry.mCreationElapsedRealTime + mStickyDisplayTime;
            }
            return mPostTime + getRecommendedHeadsUpTimeoutMs(mAutoDismissNotificationDecay);
            final long duration = getRecommendedHeadsUpTimeoutMs(
                    isStickyForSomeTime() ? mStickyDisplayTime : mAutoDismissNotificationDecay);

            return mPostTime + duration;
        }

        /**