diff options
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/policy/AvalancheController.kt | 8 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/policy/BaseHeadsUpManager.java | 36 |
2 files changed, 32 insertions, 12 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/AvalancheController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/policy/AvalancheController.kt index f44e7f3da6f0..8b48bd32e089 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/AvalancheController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/AvalancheController.kt @@ -22,6 +22,7 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dump.DumpManager import com.android.systemui.statusbar.notification.shared.NotificationThrottleHun import com.android.systemui.statusbar.policy.BaseHeadsUpManager.HeadsUpEntry +import com.android.systemui.util.Compile import java.io.PrintWriter import javax.inject.Inject @@ -37,7 +38,7 @@ constructor( ) : Dumpable { private val tag = "AvalancheController" - private val debug = false + private val debug = Compile.IS_DEBUG && Log.isLoggable(tag, Log.DEBUG) // HUN showing right now, in the floating state where full shade is hidden, on launcher or AOD @VisibleForTesting var headsUpEntryShowing: HeadsUpEntry? = null @@ -108,7 +109,10 @@ constructor( if (isOnlyNextEntry) { // HeadsUpEntry.updateEntry recursively calls AvalancheController#update // and goes to the isShowing case above - headsUpEntryShowing!!.updateEntry(false, "avalanche duration update") + headsUpEntryShowing!!.updateEntry( + /* updatePostTime= */ false, + /* updateEarliestRemovalTime= */ false, + /* reason= */ "avalanche duration update") } } logState("after $fn") diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BaseHeadsUpManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BaseHeadsUpManager.java index b8318a7dfb61..a7fe49b54602 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BaseHeadsUpManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BaseHeadsUpManager.java @@ -39,6 +39,7 @@ import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.res.R; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.InflationFlag; +import com.android.systemui.statusbar.notification.shared.NotificationThrottleHun; import com.android.systemui.statusbar.notification.shared.NotificationsHeadsUpRefactor; import com.android.systemui.util.ListenerSet; import com.android.systemui.util.concurrency.DelayableExecutor; @@ -114,7 +115,8 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { mUiEventLogger = uiEventLogger; mAvalancheController = avalancheController; Resources resources = context.getResources(); - mMinimumDisplayTime = resources.getInteger(R.integer.heads_up_notification_minimum_time); + mMinimumDisplayTime = NotificationThrottleHun.isEnabled() + ? 500 : resources.getInteger(R.integer.heads_up_notification_minimum_time); mStickyForSomeTimeAutoDismissTime = resources.getInteger( R.integer.sticky_heads_up_notification_time); mAutoDismissTime = resources.getInteger(R.integer.heads_up_notification_decay); @@ -765,11 +767,23 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { * @param updatePostTime whether or not to refresh the post time */ public void updateEntry(boolean updatePostTime, @Nullable String reason) { + updateEntry(updatePostTime, /* updateEarliestRemovalTime= */ true, reason); + } + + /** + * Updates an entry's removal time. + * @param updatePostTime whether or not to refresh the post time + * @param updateEarliestRemovalTime whether this update should further delay removal + */ + public void updateEntry(boolean updatePostTime, boolean updateEarliestRemovalTime, + @Nullable String reason) { Runnable runnable = () -> { mLogger.logUpdateEntry(mEntry, updatePostTime, reason); final long now = mSystemClock.elapsedRealtime(); - mEarliestRemovalTime = now + mMinimumDisplayTime; + if (updateEarliestRemovalTime) { + mEarliestRemovalTime = now + mMinimumDisplayTime; + } if (updatePostTime) { mPostTime = Math.max(mPostTime, now); @@ -785,7 +799,9 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { FinishTimeUpdater finishTimeCalculator = () -> { final long finishTime = calculateFinishTime(); final long now = mSystemClock.elapsedRealtime(); - final long timeLeft = Math.max(finishTime - now, mMinimumDisplayTime); + final long timeLeft = NotificationThrottleHun.isEnabled() + ? Math.max(finishTime, mEarliestRemovalTime) - now + : Math.max(finishTime - now, mMinimumDisplayTime); return timeLeft; }; scheduleAutoRemovalCallback(finishTimeCalculator, "updateEntry (not sticky)"); @@ -818,13 +834,6 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { } public int compareNonTimeFields(HeadsUpEntry headsUpEntry) { - boolean isPinned = mEntry.isRowPinned(); - boolean otherPinned = headsUpEntry.mEntry.isRowPinned(); - if (isPinned && !otherPinned) { - return -1; - } else if (!isPinned && otherPinned) { - return 1; - } boolean selfFullscreen = hasFullScreenIntent(mEntry); boolean otherFullscreen = hasFullScreenIntent(headsUpEntry.mEntry); if (selfFullscreen && !otherFullscreen) { @@ -851,6 +860,13 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { } public int compareTo(@NonNull HeadsUpEntry headsUpEntry) { + boolean isPinned = mEntry.isRowPinned(); + boolean otherPinned = headsUpEntry.mEntry.isRowPinned(); + if (isPinned && !otherPinned) { + return -1; + } else if (!isPinned && otherPinned) { + return 1; + } int nonTimeCompareResult = compareNonTimeFields(headsUpEntry); if (nonTimeCompareResult != 0) { return nonTimeCompareResult; |