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

Commit 1ba1c39c authored by Lyn's avatar Lyn Committed by Lyn Han
Browse files

Show FSI HUN for 60 more seconds after update

Fixes: 269781055

Test: show forever
- Send FSI HUN (permission GRANTED)
- Send any HUN and expand it
- Send any HUN, tap reply button to focus input

Test: show 60s
- Send FSI HUN (permission DENIED)
- Update FSI HUN (permission DENIED) (shows for 60s since update)

Test: show 5s
- Send non-FSI HUN
- Send FSI hun after demotion

Test: call via duo, hang up => HUN hides (no regression)

Change-Id: Id30dbfa78c6973f0f019207a5f44151363d6c3aa
parent c59405e7
Loading
Loading
Loading
Loading
+16 −26
Original line number Original line Diff line number Diff line
@@ -234,7 +234,7 @@ public abstract class AlertingNotificationManager {


    /**
    /**
     * @param key
     * @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) {
    public boolean isSticky(String key) {
        AlertEntry alerting = mAlertEntries.get(key);
        AlertEntry alerting = mAlertEntries.get(key);
@@ -256,15 +256,6 @@ public abstract class AlertingNotificationManager {
        return 0;
        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> {
    protected class AlertEntry implements Comparable<AlertEntry> {
        @Nullable public NotificationEntry mEntry;
        @Nullable public NotificationEntry mEntry;
        public long mPostTime;
        public long mPostTime;
@@ -285,11 +276,6 @@ public abstract class AlertingNotificationManager {
            updateEntry(true /* updatePostTime */);
            updateEntry(true /* updatePostTime */);
        }
        }


        @VisibleForTesting
        long getEarliestRemovaltime() {
            return mEarliestRemovaltime;
        }

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


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

            mHandler.postDelayed(mRemoveAlertRunnable, timeRemaining);
        }
        }


        /**
        /**
         * Whether or not the notification is "sticky" i.e. should stay on screen regardless
         * 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
         * @return true if the notification is sticky
         */
         */
        public boolean isSticky() {
        public boolean isSticky() {
            // This implementation is overridden by HeadsUpManager HeadsUpEntry #isSticky
            // This implementation is overridden by HeadsUpManager HeadsUpEntry #isSticky
            // but we keep this here for use by unit tests.
            return false;
            return mEntry.isStickyAndNotDemoted();
        }

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


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

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


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


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

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


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

            return mPostTime + getRecommendedHeadsUpTimeoutMs(mAutoDismissNotificationDecay);
            return mPostTime + duration;
        }
        }


        /**
        /**