diff options
15 files changed, 119 insertions, 120 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationLaunchAnimatorController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationLaunchAnimatorController.kt index 96279e2d2e44..5983fc17d4c3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationLaunchAnimatorController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationLaunchAnimatorController.kt @@ -157,9 +157,9 @@ class NotificationLaunchAnimatorController( val summaryEntry = notificationEntry.parent?.summary return when { - headsUpManager.isAlerting(notificationKey) -> notification + headsUpManager.isHeadsUpEntry(notificationKey) -> notification summaryEntry == null -> null - headsUpManager.isAlerting(summaryEntry.key) -> summaryEntry.row + headsUpManager.isHeadsUpEntry(summaryEntry.key) -> summaryEntry.row else -> null } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java index cfe9fbe3af29..cdacb10e1676 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java @@ -171,7 +171,7 @@ public final class NotificationEntry extends ListEntry { private int mBucket = BUCKET_ALERTING; @Nullable private Long mPendingAnimationDuration; private boolean mIsMarkedForUserTriggeredMovement; - private boolean mIsAlerting; + private boolean mIsHeadsUpEntry; public boolean mRemoteEditImeAnimatingAway; public boolean mRemoteEditImeVisible; @@ -965,12 +965,12 @@ public final class NotificationEntry extends ListEntry { mIsMarkedForUserTriggeredMovement = marked; } - public void setIsAlerting(boolean isAlerting) { - mIsAlerting = isAlerting; + public void setIsHeadsUpEntry(boolean isHeadsUpEntry) { + mIsHeadsUpEntry = isHeadsUpEntry; } - public boolean isAlerting() { - return mIsAlerting; + public boolean isHeadsUpEntry() { + return mIsHeadsUpEntry; } /** Set whether this notification is currently used to animate a launch. */ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/HeadsUpCoordinator.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/HeadsUpCoordinator.kt index 314566eaf8d0..46806e66cb8c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/HeadsUpCoordinator.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/HeadsUpCoordinator.kt @@ -221,7 +221,7 @@ class HeadsUpCoordinator @Inject constructor( wasUpdated = false, shouldHeadsUpEver = false, shouldHeadsUpAgain = false, - isAlerting = mHeadsUpManager.isAlerting(logicalSummary.key), + isAlerting = mHeadsUpManager.isHeadsUpEntry(logicalSummary.key), isBinding = isEntryBinding(logicalSummary), ) // If we transfer the alert and the summary isn't even attached, that means we @@ -268,7 +268,7 @@ class HeadsUpCoordinator @Inject constructor( wasUpdated = false, shouldHeadsUpEver = true, shouldHeadsUpAgain = true, - isAlerting = mHeadsUpManager.isAlerting(childToReceiveParentAlert.key), + isAlerting = mHeadsUpManager.isHeadsUpEntry(childToReceiveParentAlert.key), isBinding = isEntryBinding(childToReceiveParentAlert), ) handlePostedEntry( @@ -425,7 +425,7 @@ class HeadsUpCoordinator @Inject constructor( val shouldHeadsUpEver = mVisualInterruptionDecisionProvider.makeAndLogHeadsUpDecision(entry).shouldInterrupt val shouldHeadsUpAgain = shouldHunAgain(entry) - val isAlerting = mHeadsUpManager.isAlerting(entry.key) + val isAlerting = mHeadsUpManager.isHeadsUpEntry(entry.key) val isBinding = isEntryBinding(entry) val posted = mPostedEntries.compute(entry.key) { _, value -> value?.also { update -> @@ -469,7 +469,7 @@ class HeadsUpCoordinator @Inject constructor( mEntriesUpdateTimes.remove(entry.key) cancelHeadsUpBind(entry) val entryKey = entry.key - if (mHeadsUpManager.isAlerting(entryKey)) { + if (mHeadsUpManager.isHeadsUpEntry(entryKey)) { // TODO: This should probably know the RemoteInputCoordinator's conditions, // or otherwise reference that coordinator's state, rather than replicate its logic val removeImmediatelyForRemoteInput = (mRemoteInputManager.isSpinning(entryKey) && @@ -719,7 +719,7 @@ class HeadsUpCoordinator @Inject constructor( * Whether the notification is already alerting or binding so that it can imminently alert */ private fun isAttemptingToShowHun(entry: ListEntry) = - mHeadsUpManager.isAlerting(entry.key) || isEntryBinding(entry) + mHeadsUpManager.isHeadsUpEntry(entry.key) || isEntryBinding(entry) /** * Whether the notification is already alerting/binding per [isAttemptingToShowHun] OR if it diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinator.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinator.java index a0129ff5cd90..8189fe03b2ed 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinator.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinator.java @@ -134,7 +134,7 @@ public class VisualStabilityCoordinator implements Coordinator, Dumpable { private final NotifStabilityManager mNotifStabilityManager = new NotifStabilityManager("VisualStabilityCoordinator") { private boolean canMoveForHeadsUp(NotificationEntry entry) { - return entry != null && mHeadsUpManager.isAlerting(entry.getKey()) + return entry != null && mHeadsUpManager.isHeadsUpEntry(entry.getKey()) && !mVisibilityLocationProvider.isInVisibleLocation(entry); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/OnUserInteractionCallbackImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/OnUserInteractionCallbackImpl.java index e71d80c130da..5743ab0eae27 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/OnUserInteractionCallbackImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/OnUserInteractionCallbackImpl.java @@ -68,7 +68,7 @@ public class OnUserInteractionCallbackImpl implements OnUserInteractionCallback @NonNull private DismissedByUserStats getDismissedByUserStats(NotificationEntry entry) { int dismissalSurface = NotificationStats.DISMISSAL_SHADE; - if (mHeadsUpManager.isAlerting(entry.getKey())) { + if (mHeadsUpManager.isHeadsUpEntry(entry.getKey())) { dismissalSurface = NotificationStats.DISMISSAL_PEEK; } else if (mStatusBarStateController.isDozing()) { dismissalSurface = NotificationStats.DISMISSAL_AOD; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java index c527bb537f19..20fae88b6f33 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java @@ -578,7 +578,7 @@ public class AmbientState implements Dumpable { } public boolean isPulsing(NotificationEntry entry) { - return mPulsing && entry.isAlerting(); + return mPulsing && entry.isHeadsUpEntry(); } public void setPulsingRow(ExpandableNotificationRow row) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java index f5983ed6ffb7..b07ba3c5b326 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java @@ -222,9 +222,9 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements OnHeadsUp mReleaseOnExpandFinish = false; } else { for (NotificationEntry entry : mEntriesToRemoveAfterExpand) { - if (isAlerting(entry.getKey())) { + if (isHeadsUpEntry(entry.getKey())) { // Maybe the heads-up was removed already - removeAlertEntry(entry.getKey()); + removeEntry(entry.getKey()); } } } @@ -357,9 +357,9 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements OnHeadsUp private final OnReorderingAllowedListener mOnReorderingAllowedListener = () -> { mAnimationStateHandler.setHeadsUpGoingAwayAnimationsAllowed(false); for (NotificationEntry entry : mEntriesToRemoveWhenReorderingAllowed) { - if (isAlerting(entry.getKey())) { + if (isHeadsUpEntry(entry.getKey())) { // Maybe the heads-up was removed already - removeAlertEntry(entry.getKey()); + removeEntry(entry.getKey()); } } mEntriesToRemoveWhenReorderingAllowed.clear(); @@ -370,13 +370,13 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements OnHeadsUp // HeadsUpManager utility (protected) methods overrides: @Override - protected HeadsUpEntry createAlertEntry() { + protected HeadsUpEntry createHeadsUpEntry() { return mEntryPool.acquire(); } @Override - protected void onAlertEntryRemoved(HeadsUpEntry headsUpEntry) { - super.onAlertEntryRemoved(headsUpEntry); + protected void onEntryRemoved(HeadsUpEntry headsUpEntry) { + super.onEntryRemoved(headsUpEntry); mEntryPool.release((HeadsUpEntryPhone) headsUpEntry); } @@ -403,7 +403,7 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements OnHeadsUp @Nullable private HeadsUpEntryPhone getHeadsUpEntryPhone(@NonNull String key) { - return (HeadsUpEntryPhone) mAlertEntries.get(key); + return (HeadsUpEntryPhone) mHeadsUpEntryMap.get(key); } @Nullable @@ -455,7 +455,7 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements OnHeadsUp } else if (mTrackingHeadsUp) { mEntriesToRemoveAfterExpand.add(entry); } else { - removeAlertEntry(entry.getKey()); + removeEntry(entry.getKey()); } }; @@ -529,13 +529,13 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements OnHeadsUp mStatusBarState = newState; if (wasKeyguard && !isKeyguard && mBypassController.getBypassEnabled()) { ArrayList<String> keysToRemove = new ArrayList<>(); - for (HeadsUpEntry entry : mAlertEntries.values()) { + for (HeadsUpEntry entry : mHeadsUpEntryMap.values()) { if (entry.mEntry != null && entry.mEntry.isBubble() && !entry.isSticky()) { keysToRemove.add(entry.mEntry.getKey()); } } for (String key : keysToRemove) { - removeAlertEntry(key); + removeEntry(key); } } } @@ -545,7 +545,7 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements OnHeadsUp if (!isDozing) { // Let's make sure all huns we got while dozing time out within the normal timeout // duration. Otherwise they could get stuck for a very long time - for (HeadsUpEntry entry : mAlertEntries.values()) { + for (HeadsUpEntry entry : mHeadsUpEntryMap.values()) { entry.updateEntry(true /* updatePostTime */, "onDozingChanged(false)"); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java index 9da61112fd0c..4ee061d05a3b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java @@ -562,7 +562,7 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit private void removeHunAfterClick(ExpandableNotificationRow row) { String key = row.getEntry().getSbn().getKey(); - if (mHeadsUpManager != null && mHeadsUpManager.isAlerting(key)) { + if (mHeadsUpManager != null && mHeadsUpManager.isHeadsUpEntry(key)) { // Release the HUN notification to the shade. if (mPresenter.isPresenterFullyCollapsed()) { HeadsUpUtil.setNeedsHeadsUpDisappearAnimationAfterClick(row, true); 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 a5fd55982746..1528c9befda7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BaseHeadsUpManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BaseHeadsUpManager.java @@ -70,7 +70,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { private final UiEventLogger mUiEventLogger; protected final SystemClock mSystemClock; - protected final ArrayMap<String, HeadsUpEntry> mAlertEntries = new ArrayMap<>(); + protected final ArrayMap<String, HeadsUpEntry> mHeadsUpEntryMap = new ArrayMap<>(); protected final HeadsUpManagerLogger mLogger; protected int mMinimumDisplayTime; protected int mStickyForSomeTimeAutoDismissTime; @@ -151,15 +151,15 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { } /** - * Called when posting a new notification that should alert the user and appear on screen. + * Called when posting a new notification that should appear on screen. * Adds the notification to be managed. * @param entry entry to show */ @Override public void showNotification(@NonNull NotificationEntry entry) { mLogger.logShowNotification(entry); - addAlertEntry(entry); - updateNotification(entry.getKey(), true /* alert */); + addEntry(entry); + updateNotification(entry.getKey(), true /* show */); entry.setInterruption(); } @@ -173,12 +173,12 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { @Override public boolean removeNotification(@NonNull String key, boolean releaseImmediately) { mLogger.logRemoveNotification(key, releaseImmediately); - HeadsUpEntry headsUpEntry = mAlertEntries.get(key); + HeadsUpEntry headsUpEntry = mHeadsUpEntryMap.get(key); if (headsUpEntry == null) { return true; } if (releaseImmediately || canRemoveImmediately(key)) { - removeAlertEntry(key); + removeEntry(key); } else { headsUpEntry.removeAsSoonAsPossible(); return false; @@ -190,12 +190,12 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { /** * Called when the notification state has been updated. * @param key the key of the entry that was updated - * @param alert whether the notification should alert again and force reevaluation of + * @param show whether the notification should show again and force reevaluation of * removal time */ - public void updateNotification(@NonNull String key, boolean alert) { - HeadsUpEntry headsUpEntry = mAlertEntries.get(key); - mLogger.logUpdateNotification(key, alert, headsUpEntry != null); + public void updateNotification(@NonNull String key, boolean show) { + HeadsUpEntry headsUpEntry = mHeadsUpEntryMap.get(key); + mLogger.logUpdateNotification(key, show, headsUpEntry != null); if (headsUpEntry == null) { // the entry was released before this update (i.e by a listener) This can happen // with the groupmanager @@ -204,7 +204,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { headsUpEntry.mEntry.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); - if (alert) { + if (show) { headsUpEntry.updateEntry(true /* updatePostTime */, "updateNotification"); if (headsUpEntry != null) { setEntryPinned(headsUpEntry, shouldHeadsUpBecomePinned(headsUpEntry.mEntry)); @@ -219,9 +219,9 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { mLogger.logReleaseAllImmediately(); // A copy is necessary here as we are changing the underlying map. This would cause // undefined behavior if we iterated over the key set directly. - ArraySet<String> keysToRemove = new ArraySet<>(mAlertEntries.keySet()); + ArraySet<String> keysToRemove = new ArraySet<>(mHeadsUpEntryMap.keySet()); for (String key : keysToRemove) { - removeAlertEntry(key); + removeEntry(key); } } @@ -232,7 +232,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { */ @Nullable public NotificationEntry getEntry(@NonNull String key) { - HeadsUpEntry headsUpEntry = mAlertEntries.get(key); + HeadsUpEntry headsUpEntry = mHeadsUpEntryMap.get(key); return headsUpEntry != null ? headsUpEntry.mEntry : null; } @@ -243,24 +243,23 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { @NonNull @Override public Stream<NotificationEntry> getAllEntries() { - return mAlertEntries.values().stream().map(headsUpEntry -> headsUpEntry.mEntry); + return mHeadsUpEntryMap.values().stream().map(headsUpEntry -> headsUpEntry.mEntry); } /** - * Whether or not there are any active alerting notifications. - * @return true if there is an alert, false otherwise + * Whether or not there are any active notifications. + * @return true if there is an entry, false otherwise */ @Override public boolean hasNotifications() { - return !mAlertEntries.isEmpty(); + return !mHeadsUpEntryMap.isEmpty(); } /** - * Whether or not the given notification is alerting and managed by this manager. - * @return true if the notification is alerting + * @return true if the notification is managed by this manager */ - public boolean isAlerting(@NonNull String key) { - return mAlertEntries.containsKey(key); + public boolean isHeadsUpEntry(@NonNull String key) { + return mHeadsUpEntryMap.containsKey(key); } /** @@ -269,7 +268,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { */ @Override public long getEarliestRemovalTime(String key) { - HeadsUpEntry entry = mAlertEntries.get(key); + HeadsUpEntry entry = mHeadsUpEntryMap.get(key); if (entry != null) { return Math.max(0, entry.mEarliestRemovalTime - mSystemClock.elapsedRealtime()); } @@ -280,7 +279,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { final HeadsUpEntry headsUpEntry = getHeadsUpEntry(entry.getKey()); if (headsUpEntry == null) { // This should not happen since shouldHeadsUpBecomePinned is always called after adding - // the NotificationEntry into AlertingNotificationManager's mAlertEntries map. + // the NotificationEntry into mHeadsUpEntryMap. return hasFullScreenIntent(entry); } return hasFullScreenIntent(entry) && !headsUpEntry.mWasUnpinned; @@ -323,20 +322,20 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { * Add a new entry and begin managing it. * @param entry the entry to add */ - protected final void addAlertEntry(@NonNull NotificationEntry entry) { - HeadsUpEntry headsUpEntry = createAlertEntry(); + protected final void addEntry(@NonNull NotificationEntry entry) { + HeadsUpEntry headsUpEntry = createHeadsUpEntry(); headsUpEntry.setEntry(entry); - mAlertEntries.put(entry.getKey(), headsUpEntry); - onAlertEntryAdded(headsUpEntry); + mHeadsUpEntryMap.put(entry.getKey(), headsUpEntry); + onEntryAdded(headsUpEntry); entry.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); - entry.setIsAlerting(true); + entry.setIsHeadsUpEntry(true); } /** * Manager-specific logic that should occur when an entry is added. * @param headsUpEntry entry added */ - protected void onAlertEntryAdded(HeadsUpEntry headsUpEntry) { + protected void onEntryAdded(HeadsUpEntry headsUpEntry) { NotificationEntry entry = headsUpEntry.mEntry; entry.setHeadsUp(true); @@ -349,11 +348,11 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { } /** - * Remove a notification and reset the alert entry. + * Remove a notification and reset the entry. * @param key key of notification to remove */ - protected final void removeAlertEntry(@NonNull String key) { - HeadsUpEntry headsUpEntry = mAlertEntries.get(key); + protected final void removeEntry(@NonNull String key) { + HeadsUpEntry headsUpEntry = mHeadsUpEntryMap.get(key); if (headsUpEntry == null) { return; } @@ -364,17 +363,17 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { return; } entry.demoteStickyHun(); - mAlertEntries.remove(key); - onAlertEntryRemoved(headsUpEntry); + mHeadsUpEntryMap.remove(key); + onEntryRemoved(headsUpEntry); entry.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); headsUpEntry.reset(); } /** - * Manager-specific logic that should occur when an alert entry is removed. + * Manager-specific logic that should occur when an entry is removed. * @param headsUpEntry entry removed */ - protected void onAlertEntryRemoved(HeadsUpEntry headsUpEntry) { + protected void onEntryRemoved(HeadsUpEntry headsUpEntry) { NotificationEntry entry = headsUpEntry.mEntry; entry.setHeadsUp(false); setEntryPinned(headsUpEntry, false /* isPinned */); @@ -421,7 +420,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { * Snoozes all current Heads Up Notifications. */ public void snooze() { - for (String key : mAlertEntries.keySet()) { + for (String key : mHeadsUpEntryMap.keySet()) { HeadsUpEntry entry = getHeadsUpEntry(key); String packageName = entry.mEntry.getSbn().getPackageName(); String snoozeKey = snoozeKey(packageName, mUser); @@ -437,7 +436,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { @Nullable protected HeadsUpEntry getHeadsUpEntry(@NonNull String key) { - return (HeadsUpEntry) mAlertEntries.get(key); + return (HeadsUpEntry) mHeadsUpEntryMap.get(key); } /** @@ -451,11 +450,11 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { @Nullable protected HeadsUpEntry getTopHeadsUpEntry() { - if (mAlertEntries.isEmpty()) { + if (mHeadsUpEntryMap.isEmpty()) { return null; } HeadsUpEntry topEntry = null; - for (HeadsUpEntry entry: mAlertEntries.values()) { + for (HeadsUpEntry entry: mHeadsUpEntryMap.values()) { if (topEntry == null || entry.compareTo(topEntry) < 0) { topEntry = (HeadsUpEntry) entry; } @@ -486,7 +485,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { pw.print(" mSnoozeLengthMs="); pw.println(mSnoozeLengthMs); pw.print(" now="); pw.println(mSystemClock.elapsedRealtime()); pw.print(" mUser="); pw.println(mUser); - for (HeadsUpEntry entry: mAlertEntries.values()) { + for (HeadsUpEntry entry: mHeadsUpEntryMap.values()) { pw.print(" HeadsUpEntry="); pw.println(entry.mEntry); } int n = mSnoozedPackages.size(); @@ -505,7 +504,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { } private boolean hasPinnedNotificationInternal() { - for (String key : mAlertEntries.keySet()) { + for (String key : mHeadsUpEntryMap.keySet()) { HeadsUpEntry entry = getHeadsUpEntry(key); if (entry.mEntry.isRowPinned()) { return true; @@ -519,7 +518,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { * @param userUnPinned The unpinned action is trigger by user real operation. */ public void unpinAll(boolean userUnPinned) { - for (String key : mAlertEntries.keySet()) { + for (String key : mHeadsUpEntryMap.keySet()) { HeadsUpEntry entry = getHeadsUpEntry(key); setEntryPinned(entry, false /* isPinned */); // maybe it got un sticky @@ -590,10 +589,10 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { } /** - * Whether or not the alert can be removed currently. If it hasn't been on screen long enough + * Whether or not the entry can be removed currently. If it hasn't been on screen long enough * it should not be removed unless forced * @param key the key to check if removable - * @return true if the alert entry can be removed + * @return true if the entry can be removed */ @Override public boolean canRemoveImmediately(@NonNull String key) { @@ -611,7 +610,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { */ @Override public boolean isSticky(String key) { - HeadsUpEntry headsUpEntry = mAlertEntries.get(key); + HeadsUpEntry headsUpEntry = mHeadsUpEntryMap.get(key); if (headsUpEntry != null) { return headsUpEntry.isSticky(); } @@ -619,7 +618,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { } @NonNull - protected HeadsUpEntry createAlertEntry() { + protected HeadsUpEntry createHeadsUpEntry() { return new HeadsUpEntry(); } @@ -651,18 +650,18 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { public long mPostTime; public long mEarliestRemovalTime; - @Nullable protected Runnable mRemoveAlertRunnable; + @Nullable protected Runnable mRemoveRunnable; - @Nullable private Runnable mCancelRemoveAlertRunnable; + @Nullable private Runnable mCancelRemoveRunnable; public void setEntry(@NonNull final NotificationEntry entry) { - setEntry(entry, () -> removeAlertEntry(entry.getKey())); + setEntry(entry, () -> removeEntry(entry.getKey())); } public void setEntry(@NonNull final NotificationEntry entry, - @Nullable Runnable removeAlertRunnable) { + @Nullable Runnable removeRunnable) { mEntry = entry; - mRemoveAlertRunnable = removeAlertRunnable; + mRemoveRunnable = removeRunnable; mPostTime = calculatePostTime(); updateEntry(true /* updatePostTime */, "setEntry"); @@ -762,7 +761,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { public void reset() { removeAutoRemovalCallbacks("reset()"); mEntry = null; - mRemoveAlertRunnable = null; + mRemoveRunnable = null; mExpanded = false; mRemoteInputActive = false; } @@ -779,7 +778,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { } public void scheduleAutoRemovalCallback(long delayMillis, @NonNull String reason) { - if (mRemoveAlertRunnable == null) { + if (mRemoveRunnable == null) { Log.wtf(TAG, "scheduleAutoRemovalCallback with no callback set"); return; } @@ -792,26 +791,26 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { mLogger.logAutoRemoveScheduled(mEntry, delayMillis, reason); } - mCancelRemoveAlertRunnable = mExecutor.executeDelayed(mRemoveAlertRunnable, + mCancelRemoveRunnable = mExecutor.executeDelayed(mRemoveRunnable, delayMillis); } public boolean removeAutoRemovalCallbackInternal() { - final boolean scheduled = (mCancelRemoveAlertRunnable != null); + final boolean scheduled = (mCancelRemoveRunnable != null); if (scheduled) { - mCancelRemoveAlertRunnable.run(); - mCancelRemoveAlertRunnable = null; + mCancelRemoveRunnable.run(); + mCancelRemoveRunnable = null; } return scheduled; } /** - * Remove the alert at the earliest allowed removal time. + * Remove the entry at the earliest allowed removal time. */ public void removeAsSoonAsPossible() { - if (mRemoveAlertRunnable != null) { + if (mRemoveRunnable != null) { final long timeLeft = mEarliestRemovalTime - mSystemClock.elapsedRealtime(); scheduleAutoRemovalCallback(timeLeft, "removeAsSoonAsPossible"); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.kt b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.kt index d9527fe98b1a..b8c7e202ce7c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.kt @@ -71,7 +71,7 @@ interface HeadsUpManager : Dumpable { fun hasPinnedHeadsUp(): Boolean /** Returns whether or not the given notification is alerting and managed by this manager. */ - fun isAlerting(key: String): Boolean + fun isHeadsUpEntry(key: String): Boolean fun isHeadsUpGoingAway(): Boolean @@ -213,7 +213,7 @@ class HeadsUpManagerEmptyImpl @Inject constructor() : HeadsUpManager { override fun getTouchableRegion(): Region? = null override fun getTopEntry() = null override fun hasPinnedHeadsUp() = false - override fun isAlerting(key: String) = false + override fun isHeadsUpEntry(key: String) = false override fun isHeadsUpGoingAway() = false override fun isSnoozed(packageName: String) = false override fun isSticky(key: String?) = false diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationLaunchAnimatorControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationLaunchAnimatorControllerTest.kt index 605936372e7a..cd744100770e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationLaunchAnimatorControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationLaunchAnimatorControllerTest.kt @@ -73,7 +73,7 @@ class NotificationLaunchAnimatorControllerTest : SysuiTestCase() { } private fun flagNotificationAsHun() { - `when`(headsUpManager.isAlerting(notificationKey)).thenReturn(true) + `when`(headsUpManager.isHeadsUpEntry(notificationKey)).thenReturn(true) } @Test @@ -151,8 +151,8 @@ class NotificationLaunchAnimatorControllerTest : SysuiTestCase() { .build() assertSame(summary, notification.entry.parent?.summary) - `when`(headsUpManager.isAlerting(notificationKey)).thenReturn(false) - `when`(headsUpManager.isAlerting(summary.key)).thenReturn(true) + `when`(headsUpManager.isHeadsUpEntry(notificationKey)).thenReturn(false) + `when`(headsUpManager.isHeadsUpEntry(summary.key)).thenReturn(true) assertNotSame(GROUP_ALERT_SUMMARY, summary.sbn.notification.groupAlertBehavior) assertNotSame(GROUP_ALERT_SUMMARY, notification.entry.sbn.notification.groupAlertBehavior) diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/HeadsUpCoordinatorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/HeadsUpCoordinatorTest.kt index a8be62b367b4..cd75e0811fff 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/HeadsUpCoordinatorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/HeadsUpCoordinatorTest.kt @@ -148,7 +148,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { verify(remoteInputManager).addActionPressListener(capture()) } given(headsUpManager.allEntries).willAnswer { huns.stream() } - given(headsUpManager.isAlerting(anyString())).willAnswer { invocation -> + given(headsUpManager.isHeadsUpEntry(anyString())).willAnswer { invocation -> val key = invocation.getArgument<String>(0) huns.any { entry -> entry.key == key } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinatorTest.java index 2e74d119849e..ea5a6e72557a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinatorTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinatorTest.java @@ -140,7 +140,7 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase { .setSummary(mEntry) .build(); - when(mHeadsUpManager.isAlerting(mEntry.getKey())).thenReturn(false); + when(mHeadsUpManager.isHeadsUpEntry(mEntry.getKey())).thenReturn(false); // Whenever we invalidate, the pipeline runs again, so we invalidate the state doAnswer(i -> { @@ -373,7 +373,7 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase { setSleepy(false); // WHEN a notification is alerting and visible - when(mHeadsUpManager.isAlerting(mEntry.getKey())).thenReturn(true); + when(mHeadsUpManager.isHeadsUpEntry(mEntry.getKey())).thenReturn(true); when(mVisibilityLocationProvider.isInVisibleLocation(any(NotificationEntry.class))) .thenReturn(true); @@ -389,7 +389,7 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase { setSleepy(false); // WHEN a notification is alerting but not visible - when(mHeadsUpManager.isAlerting(mEntry.getKey())).thenReturn(true); + when(mHeadsUpManager.isHeadsUpEntry(mEntry.getKey())).thenReturn(true); when(mVisibilityLocationProvider.isInVisibleLocation(any(NotificationEntry.class))) .thenReturn(false); @@ -537,7 +537,7 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase { assertFalse(mNotifStabilityManager.isSectionChangeAllowed(mEntry)); // GIVEN mEntry is a HUN - when(mHeadsUpManager.isAlerting(mEntry.getKey())).thenReturn(true); + when(mHeadsUpManager.isHeadsUpEntry(mEntry.getKey())).thenReturn(true); // THEN group + section changes are allowed assertTrue(mNotifStabilityManager.isGroupChangeAllowed(mEntry)); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java index 95a05ef29914..c350de21dda5 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhoneTest.java @@ -173,7 +173,7 @@ public class HeadsUpManagerPhoneTest extends BaseHeadsUpManagerTest { /* releaseImmediately = */ false); assertTrue(removedImmediately); - assertFalse(hmp.isAlerting(entry.getKey())); + assertFalse(hmp.isHeadsUpEntry(entry.getKey())); } @Test @@ -212,6 +212,6 @@ public class HeadsUpManagerPhoneTest extends BaseHeadsUpManagerTest { hmp.extendHeadsUp(); mSystemClock.advanceTime(TEST_AUTO_DISMISS_TIME + hmp.mExtensionTime / 2); - assertTrue(hmp.isAlerting(entry.getKey())); + assertTrue(hmp.isHeadsUpEntry(entry.getKey())); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/BaseHeadsUpManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/BaseHeadsUpManagerTest.java index a27fff2dfde3..4c824c0d130a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/BaseHeadsUpManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/BaseHeadsUpManagerTest.java @@ -132,8 +132,8 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { } @Override - protected HeadsUpEntry createAlertEntry() { - mLastCreatedEntry = spy(super.createAlertEntry()); + protected HeadsUpEntry createHeadsUpEntry() { + mLastCreatedEntry = spy(super.createHeadsUpEntry()); return mLastCreatedEntry; } @@ -300,7 +300,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { alm.showNotification(entry); - assertTrue(alm.isAlerting(entry.getKey())); + assertTrue(alm.isHeadsUpEntry(entry.getKey())); assertTrue(alm.hasNotifications()); assertEquals(entry, alm.getEntry(entry.getKey())); } @@ -313,7 +313,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { alm.showNotification(entry); mSystemClock.advanceTime(TEST_AUTO_DISMISS_TIME * 3 / 2); - assertFalse(alm.isAlerting(entry.getKey())); + assertFalse(alm.isHeadsUpEntry(entry.getKey())); } @Test @@ -326,7 +326,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { final boolean removedImmediately = alm.removeNotification( entry.getKey(), /* releaseImmediately = */ false); assertFalse(removedImmediately); - assertTrue(alm.isAlerting(entry.getKey())); + assertTrue(alm.isHeadsUpEntry(entry.getKey())); } @Test @@ -339,7 +339,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { final boolean removedImmediately = alm.removeNotification( entry.getKey(), /* releaseImmediately = */ true); assertTrue(removedImmediately); - assertFalse(alm.isAlerting(entry.getKey())); + assertFalse(alm.isHeadsUpEntry(entry.getKey())); } @Test @@ -375,7 +375,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { BaseHeadsUpManager.HeadsUpEntry.class); headsUpEntry.mEntry = notifEntry; - hum.onAlertEntryRemoved(headsUpEntry); + hum.onEntryRemoved(headsUpEntry); verify(mLogger, times(1)).logNotificationActuallyRemoved(eq(notifEntry)); } @@ -428,7 +428,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { hum.showNotification(entry); mSystemClock.advanceTime(TEST_TOUCH_ACCEPTANCE_TIME / 2 + TEST_AUTO_DISMISS_TIME); - assertTrue(hum.isAlerting(entry.getKey())); + assertTrue(hum.isHeadsUpEntry(entry.getKey())); } @@ -442,7 +442,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { mSystemClock.advanceTime(TEST_TOUCH_ACCEPTANCE_TIME + (TEST_AUTO_DISMISS_TIME + TEST_A11Y_AUTO_DISMISS_TIME) / 2); - assertFalse(hum.isAlerting(entry.getKey())); + assertFalse(hum.isHeadsUpEntry(entry.getKey())); } @@ -456,7 +456,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { mSystemClock.advanceTime(TEST_TOUCH_ACCEPTANCE_TIME + (TEST_AUTO_DISMISS_TIME + TEST_STICKY_AUTO_DISMISS_TIME) / 2); - assertTrue(hum.isAlerting(entry.getKey())); + assertTrue(hum.isHeadsUpEntry(entry.getKey())); } @@ -469,7 +469,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { hum.showNotification(entry); mSystemClock.advanceTime(TEST_TOUCH_ACCEPTANCE_TIME + 2 * TEST_A11Y_AUTO_DISMISS_TIME); - assertTrue(hum.isAlerting(entry.getKey())); + assertTrue(hum.isHeadsUpEntry(entry.getKey())); } @@ -483,7 +483,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { mSystemClock.advanceTime(TEST_TOUCH_ACCEPTANCE_TIME + (TEST_AUTO_DISMISS_TIME + TEST_A11Y_AUTO_DISMISS_TIME) / 2); - assertTrue(hum.isAlerting(entry.getKey())); + assertTrue(hum.isHeadsUpEntry(entry.getKey())); } @@ -497,7 +497,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { mSystemClock.advanceTime(TEST_TOUCH_ACCEPTANCE_TIME + (TEST_STICKY_AUTO_DISMISS_TIME + TEST_A11Y_AUTO_DISMISS_TIME) / 2); - assertTrue(hum.isAlerting(entry.getKey())); + assertTrue(hum.isHeadsUpEntry(entry.getKey())); } @@ -512,11 +512,11 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { final boolean removedImmediately = hum.removeNotification( entry.getKey(), /* releaseImmediately = */ false); assertFalse(removedImmediately); - assertTrue(hum.isAlerting(entry.getKey())); + assertTrue(hum.isHeadsUpEntry(entry.getKey())); mSystemClock.advanceTime((TEST_MINIMUM_DISPLAY_TIME + TEST_AUTO_DISMISS_TIME) / 2); - assertFalse(hum.isAlerting(entry.getKey())); + assertFalse(hum.isHeadsUpEntry(entry.getKey())); } @@ -529,12 +529,12 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { hum.showNotification(entry); mSystemClock.advanceTime((TEST_MINIMUM_DISPLAY_TIME + TEST_AUTO_DISMISS_TIME) / 2); - assertTrue(hum.isAlerting(entry.getKey())); + assertTrue(hum.isHeadsUpEntry(entry.getKey())); final boolean removedImmediately = hum.removeNotification( entry.getKey(), /* releaseImmediately = */ false); assertTrue(removedImmediately); - assertFalse(hum.isAlerting(entry.getKey())); + assertFalse(hum.isHeadsUpEntry(entry.getKey())); } @@ -548,7 +548,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { final boolean removedImmediately = hum.removeNotification( entry.getKey(), /* releaseImmediately = */ true); assertTrue(removedImmediately); - assertFalse(hum.isAlerting(entry.getKey())); + assertFalse(hum.isHeadsUpEntry(entry.getKey())); } @@ -702,7 +702,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { // the notification and then updates it; in order to not log twice, the entry needs // to have a functional ExpandableNotificationRow that can keep track of whether it's // pinned or not (via isRowPinned()). That feels like a lot to pull in to test this one bit. - hum.onAlertEntryAdded(entryToPin); + hum.onEntryAdded(entryToPin); assertEquals(1, mUiEventLoggerFake.numLogs()); assertEquals(BaseHeadsUpManager.NotificationPeekEvent.NOTIFICATION_PEEK.getId(), |