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
This commit is contained in:
Lyn
2023-02-22 00:04:06 +00:00
committed by Lyn Han
parent c59405e7ed
commit 1ba1c39cc3
2 changed files with 27 additions and 34 deletions

View File

@@ -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();
final long finishTime = calculateFinishTime();
final long timeRemaining = isSticky()
? finishTime - mClock.currentTimeMillis()
: Math.max(finishTime - now, mMinimumDisplayTime);
mHandler.postDelayed(mRemoveAlertRunnable, timeRemaining);
if (!isSticky()) {
final long finishTime = calculateFinishTime();
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);
}
}

View File

@@ -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;
}
/**