diff options
| author | 2024-08-15 19:21:42 +0000 | |
|---|---|---|
| committer | 2024-08-15 19:21:42 +0000 | |
| commit | 55140738bafa4147152293437e5e8bb9972c7ca3 (patch) | |
| tree | caea0fb30a1650a1a53ef635533154c58796fe16 | |
| parent | 26db47093ccccb9c2d8e760b501174acf3f796af (diff) | |
| parent | a26b0baeba68a22de5ba814fd741ff096fcc914b (diff) | |
Merge changes I95fd75ac,I56977a66 into main
* changes:
Re-format files
Log reasons of HeadsUpManager#removeNotification
15 files changed, 446 insertions, 317 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/BaseHeadsUpManagerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/BaseHeadsUpManagerTest.java index 9005ae3c3d41..89aa670e5f0c 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/BaseHeadsUpManagerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/BaseHeadsUpManagerTest.java @@ -241,7 +241,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { alm.showNotification(entry); final boolean removedImmediately = alm.removeNotification( - entry.getKey(), /* releaseImmediately = */ false); + entry.getKey(), /* releaseImmediately = */ false, "removeDeferred"); assertFalse(removedImmediately); assertTrue(alm.isHeadsUpEntry(entry.getKey())); } @@ -254,7 +254,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { alm.showNotification(entry); final boolean removedImmediately = alm.removeNotification( - entry.getKey(), /* releaseImmediately = */ true); + entry.getKey(), /* releaseImmediately = */ true, "forceRemove"); assertTrue(removedImmediately); assertFalse(alm.isHeadsUpEntry(entry.getKey())); } @@ -430,7 +430,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { hum.showNotification(entry); final boolean removedImmediately = hum.removeNotification( - entry.getKey(), /* releaseImmediately = */ false); + entry.getKey(), /* releaseImmediately = */ false, "beforeMinimumDisplayTime"); assertFalse(removedImmediately); assertTrue(hum.isHeadsUpEntry(entry.getKey())); @@ -452,7 +452,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { assertTrue(hum.isHeadsUpEntry(entry.getKey())); final boolean removedImmediately = hum.removeNotification( - entry.getKey(), /* releaseImmediately = */ false); + entry.getKey(), /* releaseImmediately = */ false, "afterMinimumDisplayTime"); assertTrue(removedImmediately); assertFalse(hum.isHeadsUpEntry(entry.getKey())); } @@ -466,7 +466,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { hum.showNotification(entry); final boolean removedImmediately = hum.removeNotification( - entry.getKey(), /* releaseImmediately = */ true); + entry.getKey(), /* releaseImmediately = */ true, "afterMinimumDisplayTime"); assertTrue(removedImmediately); assertFalse(hum.isHeadsUpEntry(entry.getKey())); } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/HeadsUpManagerPhoneTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/HeadsUpManagerPhoneTest.kt index 7a6838a6c9ac..ca106fa01f9a 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/HeadsUpManagerPhoneTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/HeadsUpManagerPhoneTest.kt @@ -179,8 +179,8 @@ class HeadsUpManagerPhoneTest(flags: FlagsParameterization) : BaseHeadsUpManager mContext .getOrCreateTestableResources() .addOverride(R.integer.ambient_notification_extension_time, 500) - mAvalancheController = AvalancheController(dumpManager, mUiEventLogger, - mHeadsUpManagerLogger, mBgHandler) + mAvalancheController = + AvalancheController(dumpManager, mUiEventLogger, mHeadsUpManagerLogger, mBgHandler) } @Test @@ -200,7 +200,12 @@ class HeadsUpManagerPhoneTest(flags: FlagsParameterization) : BaseHeadsUpManager hmp.addSwipedOutNotification(entry.key) // Remove should succeed because the notification is swiped out - val removedImmediately = hmp.removeNotification(entry.key, /* releaseImmediately= */ false) + val removedImmediately = + hmp.removeNotification( + entry.key, + /* releaseImmediately= */ false, + /* reason= */ "swipe out" + ) Assert.assertTrue(removedImmediately) Assert.assertFalse(hmp.isHeadsUpEntry(entry.key)) } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/TestableHeadsUpManager.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/TestableHeadsUpManager.java index 69207ba07e6e..3efabd743141 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/TestableHeadsUpManager.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/TestableHeadsUpManager.java @@ -100,7 +100,7 @@ class TestableHeadsUpManager extends BaseHeadsUpManager { @Override public boolean removeNotification(@NonNull String key, boolean releaseImmediately, - boolean animate) { + boolean animate, @NonNull String reason) { throw new UnsupportedOperationException(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTransitionAnimatorController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTransitionAnimatorController.kt index 2b7df7dc937d..67c53d46b4d0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTransitionAnimatorController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTransitionAnimatorController.kt @@ -142,14 +142,15 @@ class NotificationTransitionAnimatorController( } override fun onIntentStarted(willAnimate: Boolean) { + val reason = "onIntentStarted(willAnimate=$willAnimate)" if (ActivityTransitionAnimator.DEBUG_TRANSITION_ANIMATION) { - Log.d(TAG, "onIntentStarted(willAnimate=$willAnimate)") + Log.d(TAG, reason) } notificationLaunchAnimationInteractor.setIsLaunchAnimationRunning(willAnimate) notificationEntry.isExpandAnimationRunning = willAnimate if (!willAnimate) { - removeHun(animate = true) + removeHun(animate = true, reason) onFinishAnimationCallback?.run() } } @@ -166,13 +167,18 @@ class NotificationTransitionAnimatorController( } } - private fun removeHun(animate: Boolean) { + private fun removeHun(animate: Boolean, reason: String) { val row = headsUpNotificationRow ?: return // TODO: b/297247841 - Call on the row we're removing, which may differ from notification. HeadsUpUtil.setNeedsHeadsUpDisappearAnimationAfterClick(notification, animate) - headsUpManager.removeNotification(row.entry.key, true /* releaseImmediately */, animate) + headsUpManager.removeNotification( + row.entry.key, + true /* releaseImmediately */, + animate, + reason + ) } override fun onTransitionAnimationCancelled(newKeyguardOccludedState: Boolean?) { @@ -184,7 +190,7 @@ class NotificationTransitionAnimatorController( // here? notificationLaunchAnimationInteractor.setIsLaunchAnimationRunning(false) notificationEntry.isExpandAnimationRunning = false - removeHun(animate = true) + removeHun(animate = true, "onLaunchAnimationCancelled()") onFinishAnimationCallback?.run() } @@ -206,7 +212,7 @@ class NotificationTransitionAnimatorController( notificationEntry.isExpandAnimationRunning = false notificationListContainer.setExpandingNotification(null) applyParams(null) - removeHun(animate = false) + removeHun(animate = false, "onLaunchAnimationEnd()") onFinishAnimationCallback?.run() } 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 e50d64bcb8f9..ec8566b82aea 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 @@ -496,7 +496,11 @@ constructor( if (posted?.shouldHeadsUpEver == false) { if (posted.isHeadsUpEntry) { // We don't want this to be interrupting anymore, let's remove it - mHeadsUpManager.removeNotification(posted.key, false /*removeImmediately*/) + mHeadsUpManager.removeNotification( + posted.key, + /* removeImmediately= */ false, + "onEntryUpdated" + ) } else if (posted.isBinding) { // Don't let the bind finish cancelHeadsUpBind(posted.entry) @@ -520,7 +524,11 @@ constructor( val removeImmediatelyForRemoteInput = (mRemoteInputManager.isSpinning(entryKey) && !NotificationRemoteInputManager.FORCE_REMOTE_INPUT_HISTORY) - mHeadsUpManager.removeNotification(entry.key, removeImmediatelyForRemoteInput) + mHeadsUpManager.removeNotification( + entry.key, + removeImmediatelyForRemoteInput, + "onEntryRemoved, reason: $reason" + ) } } @@ -721,7 +729,9 @@ constructor( { mHeadsUpManager.removeNotification( entry.key, /* releaseImmediately */ - true + true, + "cancel lifetime extension - extended for reason: " + + "$reason, isSticky: true" ) }, removeAfterMillis @@ -730,7 +740,9 @@ constructor( mExecutor.execute { mHeadsUpManager.removeNotification( entry.key, /* releaseImmediately */ - false + false, + "lifetime extension - extended for reason: $reason" + + ", isSticky: false" ) } mNotifsExtendingLifetime[entry] = null @@ -902,7 +914,7 @@ private class HunMutatorImpl(private val headsUpManager: HeadsUpManager) : HunMu fun commitModifications() { deferred.forEach { (key, releaseImmediately) -> - headsUpManager.removeNotification(key, releaseImmediately) + headsUpManager.removeNotification(key, releaseImmediately, "commitModifications") } deferred.clear() } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java index 41195aa0f72e..fa12bb99eac2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java @@ -638,8 +638,11 @@ public class NotificationStackScrollLayoutController implements Dumpable { if (row.isPinned() && !canChildBeDismissed(row) && row.getEntry().getSbn().getNotification().fullScreenIntent == null) { - mHeadsUpManager.removeNotification(row.getEntry().getSbn().getKey(), - true /* removeImmediately */); + mHeadsUpManager.removeNotification( + row.getEntry().getSbn().getKey(), + /* removeImmediately= */ true , + /* reason= */ "onChildSnappedBack" + ); } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java index ac1015521502..ec92990441ce 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java @@ -193,7 +193,11 @@ public final class DozeServiceHost implements DozeHost { void fireNotificationPulse(NotificationEntry entry) { Runnable pulseSuppressedListener = () -> { mHeadsUpManager.removeNotification( - entry.getKey(), /* releaseImmediately= */ true, /* animate= */ false); + entry.getKey(), + /* releaseImmediately= */ true, + /* animate= */ false, + "fireNotificationPulse" + ); }; Assert.isMainThread(); for (Callback callback : mCallbacks) { 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 25d9cc76fe3d..544a8a5e5c67 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java @@ -60,11 +60,6 @@ import com.android.systemui.util.kotlin.JavaAdapter; import com.android.systemui.util.settings.GlobalSettings; import com.android.systemui.util.time.SystemClock; -import kotlinx.coroutines.flow.Flow; -import kotlinx.coroutines.flow.MutableStateFlow; -import kotlinx.coroutines.flow.StateFlow; -import kotlinx.coroutines.flow.StateFlowKt; - import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashSet; @@ -75,6 +70,11 @@ import java.util.Stack; import javax.inject.Inject; +import kotlinx.coroutines.flow.Flow; +import kotlinx.coroutines.flow.MutableStateFlow; +import kotlinx.coroutines.flow.StateFlow; +import kotlinx.coroutines.flow.StateFlowKt; + /** A implementation of HeadsUpManager for phone. */ @SysUISingleton public class HeadsUpManagerPhone extends BaseHeadsUpManager implements @@ -365,12 +365,14 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements @Override public boolean removeNotification(@NonNull String key, boolean releaseImmediately, - boolean animate) { + boolean animate, @NonNull String reason) { if (animate) { - return removeNotification(key, releaseImmediately); + return removeNotification(key, releaseImmediately, + "removeNotification(animate: true), reason: " + reason); } else { mAnimationStateHandler.setHeadsUpGoingAwayAnimationsAllowed(false); - boolean removed = removeNotification(key, releaseImmediately); + final boolean removed = removeNotification(key, releaseImmediately, + "removeNotification(animate: false), reason: " + reason); mAnimationStateHandler.setHeadsUpGoingAwayAnimationsAllowed(true); return removed; } 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 e92058bf034a..0a6e7f59e24e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java @@ -230,7 +230,8 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit Runnable action = () -> { mBubblesManagerOptional.ifPresent(bubblesManager -> bubblesManager.onUserChangedBubble(entry, !entry.isBubble())); - mHeadsUpManager.removeNotification(entry.getKey(), /* releaseImmediately= */ true); + mHeadsUpManager.removeNotification(entry.getKey(), /* releaseImmediately= */ true, + /* reason= */ "onNotificationBubbleIconClicked"); }; if (entry.isBubble()) { // entry is being un-bubbled, no need to unlock @@ -621,7 +622,8 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit // In most cases, when FLAG_AUTO_CANCEL is set, the notification will // become canceled shortly by NoMan, but we can't assume that. - mHeadsUpManager.removeNotification(key, true /* releaseImmediately */); + mHeadsUpManager.removeNotification(key, /* releaseImmediately= */ true, + "removeHunAfterClick"); } } 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 37869587528e..f37393ac6729 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BaseHeadsUpManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BaseHeadsUpManager.java @@ -40,13 +40,14 @@ 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.statusbar.phone.ExpandHeadsUpOnInlineReply; import com.android.systemui.util.ListenerSet; import com.android.systemui.util.concurrency.DelayableExecutor; import com.android.systemui.util.settings.GlobalSettings; import com.android.systemui.util.time.SystemClock; +import org.jetbrains.annotations.NotNull; + import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; @@ -191,12 +192,14 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { * enough and needs to be kept around. * @param key the key of the notification to remove * @param releaseImmediately force a remove regardless of earliest removal time + * @param reason reason for removing the notification * @return true if notification is removed, false otherwise */ @Override - public boolean removeNotification(@NonNull String key, boolean releaseImmediately) { + public boolean removeNotification(@NotNull String key, boolean releaseImmediately, + @NonNull String reason) { final boolean isWaiting = mAvalancheController.isWaiting(key); - mLogger.logRemoveNotification(key, releaseImmediately, isWaiting); + mLogger.logRemoveNotification(key, releaseImmediately, isWaiting, reason); if (mAvalancheController.isWaiting(key)) { removeEntry(key, "removeNotification (isWaiting)"); @@ -204,6 +207,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager { } HeadsUpEntry headsUpEntry = mHeadsUpEntryMap.get(key); if (headsUpEntry == null) { + mLogger.logNullEntry(key, reason); return true; } if (releaseImmediately) { 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 fcf77d5526d4..04fe6b3e9eb7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.kt @@ -96,9 +96,10 @@ interface HeadsUpManager : Dumpable { * * @param key the key of the notification to remove * @param releaseImmediately force a remove regardless of earliest removal time + * @param reason reason for removing the notification * @return true if notification is removed, false otherwise */ - fun removeNotification(key: String, releaseImmediately: Boolean): Boolean + fun removeNotification(key: String, releaseImmediately: Boolean, reason: String): Boolean /** * Try to remove the notification. May not succeed if the notification has not been shown long @@ -107,9 +108,15 @@ interface HeadsUpManager : Dumpable { * @param key the key of the notification to remove * @param releaseImmediately force a remove regardless of earliest removal time * @param animate if true, animate the removal + * @param reason reason for removing the notification * @return true if notification is removed, false otherwise */ - fun removeNotification(key: String, releaseImmediately: Boolean, animate: Boolean): Boolean + fun removeNotification( + key: String, + releaseImmediately: Boolean, + animate: Boolean, + reason: String + ): Boolean /** Clears all managed notifications. */ fun releaseAllImmediately() @@ -246,11 +253,16 @@ class HeadsUpManagerEmptyImpl @Inject constructor() : HeadsUpManager { override fun removeListener(listener: OnHeadsUpChangedListener) {} - override fun removeNotification(key: String, releaseImmediately: Boolean) = false - - override fun removeNotification(key: String, releaseImmediately: Boolean, animate: Boolean) = + override fun removeNotification(key: String, releaseImmediately: Boolean, reason: String) = false + override fun removeNotification( + key: String, + releaseImmediately: Boolean, + animate: Boolean, + reason: String + ) = false + override fun setAnimationStateHandler(handler: AnimationStateHandler) {} override fun setExpanded(entry: NotificationEntry, expanded: Boolean) {} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManagerLogger.kt b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManagerLogger.kt index 80c595fb638b..c6fc54748cbd 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManagerLogger.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManagerLogger.kt @@ -16,244 +16,283 @@ package com.android.systemui.statusbar.policy -import com.android.systemui.log.dagger.NotificationHeadsUpLog import com.android.systemui.log.LogBuffer import com.android.systemui.log.core.LogLevel.INFO import com.android.systemui.log.core.LogLevel.VERBOSE +import com.android.systemui.log.dagger.NotificationHeadsUpLog import com.android.systemui.statusbar.notification.collection.NotificationEntry import com.android.systemui.statusbar.notification.logKey import javax.inject.Inject /** Logger for [HeadsUpManager]. */ -class HeadsUpManagerLogger @Inject constructor( - @NotificationHeadsUpLog private val buffer: LogBuffer -) { +class HeadsUpManagerLogger +@Inject +constructor(@NotificationHeadsUpLog private val buffer: LogBuffer) { fun logPackageSnoozed(snoozeKey: String) { - buffer.log(TAG, INFO, { - str1 = snoozeKey - }, { - "package snoozed $str1" - }) + buffer.log(TAG, INFO, { str1 = snoozeKey }, { "package snoozed $str1" }) } fun logPackageUnsnoozed(snoozeKey: String) { - buffer.log(TAG, INFO, { - str1 = snoozeKey - }, { - "package unsnoozed $str1" - }) + buffer.log(TAG, INFO, { str1 = snoozeKey }, { "package unsnoozed $str1" }) } fun logIsSnoozedReturned(snoozeKey: String) { - buffer.log(TAG, INFO, { - str1 = snoozeKey - }, { - "package snoozed when queried $str1" - }) + buffer.log(TAG, INFO, { str1 = snoozeKey }, { "package snoozed when queried $str1" }) } fun logReleaseAllImmediately() { - buffer.log(TAG, INFO, { }, { - "release all immediately" - }) + buffer.log(TAG, INFO, {}, { "release all immediately" }) } fun logShowNotificationRequest(entry: NotificationEntry) { - buffer.log(TAG, INFO, { - str1 = entry.logKey - }, { - "request: show notification $str1" - }) + buffer.log(TAG, INFO, { str1 = entry.logKey }, { "request: show notification $str1" }) } - fun logAvalancheUpdate(caller: String, isEnabled: Boolean, notifEntryKey: String, - outcome: String) { - buffer.log(TAG, INFO, { - str1 = caller - str2 = notifEntryKey - str3 = outcome - bool1 = isEnabled - }, { - "$str1\n\t=> AC[isEnabled:$bool1] update: $str2\n\t=> $str3" - }) + fun logAvalancheUpdate( + caller: String, + isEnabled: Boolean, + notifEntryKey: String, + outcome: String + ) { + buffer.log( + TAG, + INFO, + { + str1 = caller + str2 = notifEntryKey + str3 = outcome + bool1 = isEnabled + }, + { "$str1\n\t=> AC[isEnabled:$bool1] update: $str2\n\t=> $str3" } + ) } - fun logAvalancheDelete(caller: String, isEnabled: Boolean, notifEntryKey: String, - outcome: String) { - buffer.log(TAG, INFO, { - str1 = caller - str2 = notifEntryKey - str3 = outcome - bool1 = isEnabled - }, { - "$str1\n\t=> AC[isEnabled:$bool1] delete: $str2\n\t=> $str3" - }) + fun logAvalancheDelete( + caller: String, + isEnabled: Boolean, + notifEntryKey: String, + outcome: String + ) { + buffer.log( + TAG, + INFO, + { + str1 = caller + str2 = notifEntryKey + str3 = outcome + bool1 = isEnabled + }, + { "$str1\n\t=> AC[isEnabled:$bool1] delete: $str2\n\t=> $str3" } + ) } fun logShowNotification(entry: NotificationEntry) { - buffer.log(TAG, INFO, { - str1 = entry.logKey - }, { - "show notification $str1" - }) + buffer.log(TAG, INFO, { str1 = entry.logKey }, { "show notification $str1" }) } fun logAutoRemoveScheduled(entry: NotificationEntry, delayMillis: Long, reason: String) { - buffer.log(TAG, INFO, { - str1 = entry.logKey - long1 = delayMillis - str2 = reason - }, { - "schedule auto remove of $str1 in $long1 ms reason: $str2" - }) + buffer.log( + TAG, + INFO, + { + str1 = entry.logKey + long1 = delayMillis + str2 = reason + }, + { "schedule auto remove of $str1 in $long1 ms reason: $str2" } + ) } fun logAutoRemoveRequest(entry: NotificationEntry, reason: String) { - buffer.log(TAG, INFO, { - str1 = entry.logKey - str2 = reason - }, { - "request: reschedule auto remove of $str1 reason: $str2" - }) + buffer.log( + TAG, + INFO, + { + str1 = entry.logKey + str2 = reason + }, + { "request: reschedule auto remove of $str1 reason: $str2" } + ) } fun logAutoRemoveRescheduled(entry: NotificationEntry, delayMillis: Long, reason: String) { - buffer.log(TAG, INFO, { - str1 = entry.logKey - long1 = delayMillis - str2 = reason - }, { - "reschedule auto remove of $str1 in $long1 ms reason: $str2" - }) + buffer.log( + TAG, + INFO, + { + str1 = entry.logKey + long1 = delayMillis + str2 = reason + }, + { "reschedule auto remove of $str1 in $long1 ms reason: $str2" } + ) } fun logAutoRemoveCancelRequest(entry: NotificationEntry, reason: String?) { - buffer.log(TAG, INFO, { - str1 = entry.logKey - str2 = reason ?: "unknown" - }, { - "request: cancel auto remove of $str1 reason: $str2" - }) + buffer.log( + TAG, + INFO, + { + str1 = entry.logKey + str2 = reason ?: "unknown" + }, + { "request: cancel auto remove of $str1 reason: $str2" } + ) } fun logAutoRemoveCanceled(entry: NotificationEntry, reason: String?) { - buffer.log(TAG, INFO, { - str1 = entry.logKey - str2 = reason ?: "unknown" - }, { - "cancel auto remove of $str1 reason: $str2" - }) + buffer.log( + TAG, + INFO, + { + str1 = entry.logKey + str2 = reason ?: "unknown" + }, + { "cancel auto remove of $str1 reason: $str2" } + ) } fun logRemoveEntryRequest(key: String, reason: String, isWaiting: Boolean) { - buffer.log(TAG, INFO, { - str1 = logKey(key) - str2 = reason - bool1 = isWaiting - }, { - "request: $str2 => remove entry $str1 isWaiting: $isWaiting" - }) + buffer.log( + TAG, + INFO, + { + str1 = logKey(key) + str2 = reason + bool1 = isWaiting + }, + { "request: $str2 => remove entry $str1 isWaiting: $isWaiting" } + ) } fun logRemoveEntry(key: String, reason: String, isWaiting: Boolean) { - buffer.log(TAG, INFO, { - str1 = logKey(key) - str2 = reason - bool1 = isWaiting - }, { - "$str2 => remove entry $str1 isWaiting: $isWaiting" - }) + buffer.log( + TAG, + INFO, + { + str1 = logKey(key) + str2 = reason + bool1 = isWaiting + }, + { "$str2 => remove entry $str1 isWaiting: $isWaiting" } + ) } fun logUnpinEntryRequest(key: String) { - buffer.log(TAG, INFO, { - str1 = logKey(key) - }, { - "request: unpin entry $str1" - }) + buffer.log(TAG, INFO, { str1 = logKey(key) }, { "request: unpin entry $str1" }) } fun logUnpinEntry(key: String) { - buffer.log(TAG, INFO, { - str1 = logKey(key) - }, { - "unpin entry $str1" - }) + buffer.log(TAG, INFO, { str1 = logKey(key) }, { "unpin entry $str1" }) + } + + fun logRemoveNotification( + key: String, + releaseImmediately: Boolean, + isWaiting: Boolean, + reason: String + ) { + buffer.log( + TAG, + INFO, + { + str1 = logKey(key) + bool1 = releaseImmediately + bool2 = isWaiting + str2 = reason + }, + { + "remove notification $str1 releaseImmediately: $bool1 isWaiting: $bool2 " + + "reason: $str2" + } + ) } - fun logRemoveNotification(key: String, releaseImmediately: Boolean, isWaiting: Boolean) { - buffer.log(TAG, INFO, { - str1 = logKey(key) - bool1 = releaseImmediately - bool2 = isWaiting - }, { - "remove notification $str1 releaseImmediately: $bool1 isWaiting: $bool2" - }) + fun logNullEntry(key: String, reason: String) { + buffer.log( + TAG, + INFO, + { + str1 = logKey(key) + str2 = reason + }, + { "remove notification $str1 when headsUpEntry is null, reason: $str2" } + ) } fun logNotificationActuallyRemoved(entry: NotificationEntry) { - buffer.log(TAG, INFO, { - str1 = entry.logKey - }, { - "notification removed $str1 " - }) + buffer.log(TAG, INFO, { str1 = entry.logKey }, { "notification removed $str1 " }) } fun logUpdateNotificationRequest(key: String, alert: Boolean, hasEntry: Boolean) { - buffer.log(TAG, INFO, { - str1 = logKey(key) - bool1 = alert - bool2 = hasEntry - }, { - "request: update notification $str1 alert: $bool1 hasEntry: $bool2" - }) + buffer.log( + TAG, + INFO, + { + str1 = logKey(key) + bool1 = alert + bool2 = hasEntry + }, + { "request: update notification $str1 alert: $bool1 hasEntry: $bool2" } + ) } fun logUpdateNotification(key: String, alert: Boolean, hasEntry: Boolean) { - buffer.log(TAG, INFO, { - str1 = logKey(key) - bool1 = alert - bool2 = hasEntry - }, { - "update notification $str1 alert: $bool1 hasEntry: $bool2" - }) + buffer.log( + TAG, + INFO, + { + str1 = logKey(key) + bool1 = alert + bool2 = hasEntry + }, + { "update notification $str1 alert: $bool1 hasEntry: $bool2" } + ) } fun logUpdateEntry(entry: NotificationEntry, updatePostTime: Boolean, reason: String?) { - buffer.log(TAG, INFO, { - str1 = entry.logKey - bool1 = updatePostTime - str2 = reason ?: "unknown" - }, { - "update entry $str1 updatePostTime: $bool1 reason: $str2" - }) + buffer.log( + TAG, + INFO, + { + str1 = entry.logKey + bool1 = updatePostTime + str2 = reason ?: "unknown" + }, + { "update entry $str1 updatePostTime: $bool1 reason: $str2" } + ) } fun logSnoozeLengthChange(packageSnoozeLengthMs: Int) { - buffer.log(TAG, INFO, { - int1 = packageSnoozeLengthMs - }, { - "snooze length changed: ${int1}ms" - }) + buffer.log( + TAG, + INFO, + { int1 = packageSnoozeLengthMs }, + { "snooze length changed: ${int1}ms" } + ) } fun logSetEntryPinned(entry: NotificationEntry, isPinned: Boolean, reason: String) { - buffer.log(TAG, VERBOSE, { - str1 = entry.logKey - bool1 = isPinned - str2 = reason - }, { - "$str2 => set entry pinned $str1 pinned: $bool1" - }) + buffer.log( + TAG, + VERBOSE, + { + str1 = entry.logKey + bool1 = isPinned + str2 = reason + }, + { "$str2 => set entry pinned $str1 pinned: $bool1" } + ) } fun logUpdatePinnedMode(hasPinnedNotification: Boolean) { - buffer.log(TAG, INFO, { - bool1 = hasPinnedNotification - }, { - "has pinned notification changed to $bool1" - }) + buffer.log( + TAG, + INFO, + { bool1 = hasPinnedNotification }, + { "has pinned notification changed to $bool1" } + ) } } -private const val TAG = "HeadsUpManager"
\ No newline at end of file +private const val TAG = "HeadsUpManager" diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationTransitionAnimatorControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationTransitionAnimatorControllerTest.kt index 3abdf6212f22..cb92b7745961 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationTransitionAnimatorControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationTransitionAnimatorControllerTest.kt @@ -91,7 +91,12 @@ class NotificationTransitionAnimatorControllerTest : SysuiTestCase() { assertFalse(isExpandAnimationRunning!!) verify(headsUpManager) - .removeNotification(notificationKey, true /* releaseImmediately */, true /* animate */) + .removeNotification( + notificationKey, + /* releaseImmediately= */ true, + /* animate= */ true, + /* reason= */ "onIntentStarted(willAnimate=false)" + ) verify(onFinishAnimationCallback).run() } @@ -109,7 +114,12 @@ class NotificationTransitionAnimatorControllerTest : SysuiTestCase() { assertFalse(isExpandAnimationRunning!!) verify(headsUpManager) - .removeNotification(notificationKey, true /* releaseImmediately */, true /* animate */) + .removeNotification( + notificationKey, + /* releaseImmediately= */ true, + /* animate= */ true, + /* reason= */ "onLaunchAnimationCancelled()" + ) verify(onFinishAnimationCallback).run() } @@ -127,7 +137,12 @@ class NotificationTransitionAnimatorControllerTest : SysuiTestCase() { assertFalse(isExpandAnimationRunning!!) verify(headsUpManager) - .removeNotification(notificationKey, true /* releaseImmediately */, false /* animate */) + .removeNotification( + notificationKey, + /* releaseImmediately= */ true, + /* animate= */ false, + /* reason= */ "onLaunchAnimationEnd()" + ) verify(onFinishAnimationCallback).run() } @@ -161,12 +176,18 @@ class NotificationTransitionAnimatorControllerTest : SysuiTestCase() { controller.onTransitionAnimationEnd(isExpandingFullyAbove = true) verify(headsUpManager) - .removeNotification(summary.key, true /* releaseImmediately */, false /* animate */) + .removeNotification( + summary.key, + /* releaseImmediately= */ true, + /* animate= */ false, + /* reason= */ "onLaunchAnimationEnd()" + ) verify(headsUpManager, never()) .removeNotification( notification.entry.key, - true /* releaseImmediately */, - false /* animate */ + /* releaseImmediately= */ true, + /* animate= */ false, + /* reason= */ "onLaunchAnimationEnd()" ) } 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 8e9323fead92..b4f4138fd409 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 @@ -108,30 +108,31 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { private val executor = FakeExecutor(systemClock) private val huns: ArrayList<NotificationEntry> = ArrayList() private lateinit var helper: NotificationGroupTestHelper + @Before fun setUp() { MockitoAnnotations.initMocks(this) helper = NotificationGroupTestHelper(mContext) - coordinator = HeadsUpCoordinator( - logger, - systemClock, - headsUpManager, - headsUpViewBinder, - visualInterruptionDecisionProvider, - remoteInputManager, - launchFullScreenIntentProvider, - flags, - headerController, - executor) + coordinator = + HeadsUpCoordinator( + logger, + systemClock, + headsUpManager, + headsUpViewBinder, + visualInterruptionDecisionProvider, + remoteInputManager, + launchFullScreenIntentProvider, + flags, + headerController, + executor + ) coordinator.attach(notifPipeline) // capture arguments: collectionListener = withArgCaptor { verify(notifPipeline).addCollectionListener(capture()) } - notifPromoter = withArgCaptor { - verify(notifPipeline).addPromoter(capture()) - } + notifPromoter = withArgCaptor { verify(notifPipeline).addPromoter(capture()) } notifLifetimeExtender = withArgCaptor { verify(notifPipeline).addNotificationLifetimeExtender(capture()) } @@ -141,9 +142,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { beforeFinalizeFilterListener = withArgCaptor { verify(notifPipeline).addOnBeforeFinalizeFilterListener(capture()) } - onHeadsUpChangedListener = withArgCaptor { - verify(headsUpManager).addListener(capture()) - } + onHeadsUpChangedListener = withArgCaptor { verify(headsUpManager).addListener(capture()) } actionPressListener = withArgCaptor { verify(remoteInputManager).addActionPressListener(capture()) } @@ -187,8 +186,8 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { assertTrue(notifLifetimeExtender.maybeExtendLifetime(entry, 0)) executor.advanceClockToLast() executor.runAllReady() - verify(headsUpManager, times(0)).removeNotification(anyString(), eq(false)) - verify(headsUpManager, times(1)).removeNotification(anyString(), eq(true)) + verify(headsUpManager, times(0)).removeNotification(anyString(), eq(false), anyString()) + verify(headsUpManager, times(1)).removeNotification(anyString(), eq(true), anyString()) } @Test @@ -203,8 +202,8 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { executor.advanceClockToLast() executor.runAllReady() assertTrue(notifLifetimeExtender.maybeExtendLifetime(entry, 0)) - verify(headsUpManager, times(0)).removeNotification(anyString(), eq(false)) - verify(headsUpManager, times(0)).removeNotification(anyString(), eq(true)) + verify(headsUpManager, times(0)).removeNotification(anyString(), eq(false), anyString()) + verify(headsUpManager, times(0)).removeNotification(anyString(), eq(true), anyString()) } @Test @@ -217,7 +216,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { notifLifetimeExtender.cancelLifetimeExtension(entry) executor.advanceClockToLast() executor.runAllReady() - verify(headsUpManager, times(0)).removeNotification(anyString(), any()) + verify(headsUpManager, never()).removeNotification(anyString(), any(), anyString()) } @Test @@ -227,14 +226,14 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { whenever(headsUpManager.canRemoveImmediately(anyString())).thenReturn(false) whenever(headsUpManager.getEarliestRemovalTime(anyString())).thenReturn(1000L) - assertTrue(notifLifetimeExtender.maybeExtendLifetime(entry, /* reason = */ 0)) + assertTrue(notifLifetimeExtender.maybeExtendLifetime(entry, /* reason= */ 0)) actionPressListener.accept(entry) executor.runAllReady() verify(endLifetimeExtension, times(1)).onEndLifetimeExtension(notifLifetimeExtender, entry) - collectionListener.onEntryRemoved(entry, /* reason = */ 0) - verify(headsUpManager, times(1)).removeNotification(eq(entry.key), any()) + collectionListener.onEntryRemoved(entry, /* reason= */ 0) + verify(headsUpManager, times(1)).removeNotification(eq(entry.key), any(), anyString()) } @Test @@ -248,8 +247,8 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { whenever(headsUpManager.canRemoveImmediately(anyString())).thenReturn(true) assertFalse(notifLifetimeExtender.maybeExtendLifetime(entry, 0)) - collectionListener.onEntryRemoved(entry, /* reason = */ 0) - verify(headsUpManager, times(1)).removeNotification(eq(entry.key), any()) + collectionListener.onEntryRemoved(entry, /* reason= */ 0) + verify(headsUpManager, times(1)).removeNotification(eq(entry.key), any(), anyString()) } @Test @@ -261,8 +260,8 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { addHUN(entry) executor.advanceClockToLast() executor.runAllReady() - verify(headsUpManager, times(0)).removeNotification(anyString(), eq(false)) - verify(headsUpManager, times(0)).removeNotification(anyString(), eq(true)) + verify(headsUpManager, never()).removeNotification(anyString(), eq(false), anyString()) + verify(headsUpManager, never()).removeNotification(anyString(), eq(true), anyString()) } @Test @@ -273,8 +272,8 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { assertTrue(notifLifetimeExtender.maybeExtendLifetime(entry, 0)) executor.advanceClockToLast() executor.runAllReady() - verify(headsUpManager, times(1)).removeNotification(anyString(), eq(false)) - verify(headsUpManager, times(0)).removeNotification(anyString(), eq(true)) + verify(headsUpManager, times(1)).removeNotification(anyString(), eq(false), anyString()) + verify(headsUpManager, never()).removeNotification(anyString(), eq(true), anyString()) } @Test @@ -326,9 +325,8 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { // THEN only promote the current HUN, mEntry assertTrue(notifPromoter.shouldPromoteToTopLevel(entry)) - assertFalse(notifPromoter.shouldPromoteToTopLevel(NotificationEntryBuilder() - .setPkg("test-package2") - .build())) + val testPackage2 = NotificationEntryBuilder().setPkg("test-package2").build() + assertFalse(notifPromoter.shouldPromoteToTopLevel(testPackage2)) } @Test @@ -338,9 +336,9 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { // THEN only section the current HUN, mEntry assertTrue(notifSectioner.isInSection(entry)) - assertFalse(notifSectioner.isInSection(NotificationEntryBuilder() - .setPkg("test-package") - .build())) + assertFalse( + notifSectioner.isInSection(NotificationEntryBuilder().setPkg("test-package").build()) + ) } @Test @@ -350,10 +348,12 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { // THEN only the current HUN, mEntry, should be lifetimeExtended assertTrue(notifLifetimeExtender.maybeExtendLifetime(entry, /* cancellationReason */ 0)) - assertFalse(notifLifetimeExtender.maybeExtendLifetime( - NotificationEntryBuilder() - .setPkg("test-package") - .build(), /* cancellationReason */ 0)) + assertFalse( + notifLifetimeExtender.maybeExtendLifetime( + NotificationEntryBuilder().setPkg("test-package").build(), + /* reason= */ 0 + ) + ) } @Test @@ -366,8 +366,9 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { beforeFinalizeFilterListener.onBeforeFinalizeFilter(listOf(entry)) verify(headsUpManager, never()).showNotification(entry) withArgCaptor<BindCallback> { - verify(headsUpViewBinder).bindHeadsUpView(eq(entry), capture()) - }.onBindFinished(entry) + verify(headsUpViewBinder).bindHeadsUpView(eq(entry), capture()) + } + .onBindFinished(entry) // THEN we tell the HeadsUpManager to show the notification verify(headsUpManager).showNotification(entry) @@ -430,7 +431,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { whenever(remoteInputManager.isSpinning(any())).thenReturn(false) // THEN heads up manager should remove the entry - verify(headsUpManager).removeNotification(entry.key, false) + verify(headsUpManager).removeNotification(eq(entry.key), eq(false), anyString()) } private fun addHUN(entry: NotificationEntry) { @@ -545,19 +546,22 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { collectionListener.onEntryAdded(groupSibling1) collectionListener.onEntryAdded(groupSibling2) - val beforeTransformGroup = GroupEntryBuilder() - .setSummary(groupSummary) - .setChildren(listOf(groupSibling1, groupPriority, groupSibling2)) - .build() + val beforeTransformGroup = + GroupEntryBuilder() + .setSummary(groupSummary) + .setChildren(listOf(groupSibling1, groupPriority, groupSibling2)) + .build() beforeTransformGroupsListener.onBeforeTransformGroups(listOf(beforeTransformGroup)) verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any()) - val afterTransformGroup = GroupEntryBuilder() - .setSummary(groupSummary) - .setChildren(listOf(groupSibling1, groupSibling2)) - .build() - beforeFinalizeFilterListener - .onBeforeFinalizeFilter(listOf(groupPriority, afterTransformGroup)) + val afterTransformGroup = + GroupEntryBuilder() + .setSummary(groupSummary) + .setChildren(listOf(groupSibling1, groupSibling2)) + .build() + beforeFinalizeFilterListener.onBeforeFinalizeFilter( + listOf(groupPriority, afterTransformGroup) + ) verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSummary), any()) finishBind(groupPriority) @@ -583,19 +587,22 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { collectionListener.onEntryUpdated(groupSibling1) collectionListener.onEntryUpdated(groupSibling2) - val beforeTransformGroup = GroupEntryBuilder() - .setSummary(groupSummary) - .setChildren(listOf(groupSibling1, groupPriority, groupSibling2)) - .build() + val beforeTransformGroup = + GroupEntryBuilder() + .setSummary(groupSummary) + .setChildren(listOf(groupSibling1, groupPriority, groupSibling2)) + .build() beforeTransformGroupsListener.onBeforeTransformGroups(listOf(beforeTransformGroup)) verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any()) - val afterTransformGroup = GroupEntryBuilder() - .setSummary(groupSummary) - .setChildren(listOf(groupSibling1, groupSibling2)) - .build() - beforeFinalizeFilterListener - .onBeforeFinalizeFilter(listOf(groupPriority, afterTransformGroup)) + val afterTransformGroup = + GroupEntryBuilder() + .setSummary(groupSummary) + .setChildren(listOf(groupSibling1, groupSibling2)) + .build() + beforeFinalizeFilterListener.onBeforeFinalizeFilter( + listOf(groupPriority, afterTransformGroup) + ) verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSummary), any()) finishBind(groupPriority) @@ -618,19 +625,22 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { collectionListener.onEntryUpdated(groupSummary) collectionListener.onEntryUpdated(groupPriority) - val beforeTransformGroup = GroupEntryBuilder() - .setSummary(groupSummary) - .setChildren(listOf(groupSibling1, groupPriority, groupSibling2)) - .build() + val beforeTransformGroup = + GroupEntryBuilder() + .setSummary(groupSummary) + .setChildren(listOf(groupSibling1, groupPriority, groupSibling2)) + .build() beforeTransformGroupsListener.onBeforeTransformGroups(listOf(beforeTransformGroup)) verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any()) - val afterTransformGroup = GroupEntryBuilder() - .setSummary(groupSummary) - .setChildren(listOf(groupSibling1, groupSibling2)) - .build() - beforeFinalizeFilterListener - .onBeforeFinalizeFilter(listOf(groupPriority, afterTransformGroup)) + val afterTransformGroup = + GroupEntryBuilder() + .setSummary(groupSummary) + .setChildren(listOf(groupSibling1, groupSibling2)) + .build() + beforeFinalizeFilterListener.onBeforeFinalizeFilter( + listOf(groupPriority, afterTransformGroup) + ) verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupSummary), any()) finishBind(groupPriority) @@ -654,19 +664,22 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { collectionListener.onEntryUpdated(groupSibling1) collectionListener.onEntryUpdated(groupSibling2) - val beforeTransformGroup = GroupEntryBuilder() - .setSummary(groupSummary) - .setChildren(listOf(groupSibling1, groupPriority, groupSibling2)) - .build() + val beforeTransformGroup = + GroupEntryBuilder() + .setSummary(groupSummary) + .setChildren(listOf(groupSibling1, groupPriority, groupSibling2)) + .build() beforeTransformGroupsListener.onBeforeTransformGroups(listOf(beforeTransformGroup)) verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any()) - val afterTransformGroup = GroupEntryBuilder() - .setSummary(groupSummary) - .setChildren(listOf(groupSibling1, groupSibling2)) - .build() - beforeFinalizeFilterListener - .onBeforeFinalizeFilter(listOf(groupPriority, afterTransformGroup)) + val afterTransformGroup = + GroupEntryBuilder() + .setSummary(groupSummary) + .setChildren(listOf(groupSibling1, groupSibling2)) + .build() + beforeFinalizeFilterListener.onBeforeFinalizeFilter( + listOf(groupPriority, afterTransformGroup) + ) finishBind(groupSummary) verify(headsUpViewBinder, never()).bindHeadsUpView(eq(groupPriority), any()) @@ -688,10 +701,11 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { collectionListener.onEntryAdded(groupSummary) collectionListener.onEntryAdded(groupSibling1) collectionListener.onEntryAdded(groupSibling2) - val groupEntry = GroupEntryBuilder() - .setSummary(groupSummary) - .setChildren(listOf(groupSibling1, groupSibling2)) - .build() + val groupEntry = + GroupEntryBuilder() + .setSummary(groupSummary) + .setChildren(listOf(groupSibling1, groupSibling2)) + .build() beforeTransformGroupsListener.onBeforeTransformGroups(listOf(groupEntry)) verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any()) beforeFinalizeFilterListener.onBeforeFinalizeFilter(listOf(groupEntry)) @@ -708,16 +722,16 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { @Test fun testNoTransferTwoChildAlert_withGroupAlertAll() { setShouldHeadsUp(groupSummary) - whenever(notifPipeline.allNotifs) - .thenReturn(listOf(groupSummary, groupChild1, groupChild2)) + whenever(notifPipeline.allNotifs).thenReturn(listOf(groupSummary, groupChild1, groupChild2)) collectionListener.onEntryAdded(groupSummary) collectionListener.onEntryAdded(groupChild1) collectionListener.onEntryAdded(groupChild2) - val groupEntry = GroupEntryBuilder() - .setSummary(groupSummary) - .setChildren(listOf(groupChild1, groupChild2)) - .build() + val groupEntry = + GroupEntryBuilder() + .setSummary(groupSummary) + .setChildren(listOf(groupChild1, groupChild2)) + .build() beforeTransformGroupsListener.onBeforeTransformGroups(listOf(groupEntry)) verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any()) beforeFinalizeFilterListener.onBeforeFinalizeFilter(listOf(groupEntry)) @@ -742,10 +756,11 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { collectionListener.onEntryAdded(groupSummary) collectionListener.onEntryAdded(groupChild1) collectionListener.onEntryAdded(groupChild2) - val groupEntry = GroupEntryBuilder() - .setSummary(groupSummary) - .setChildren(listOf(groupChild1, groupChild2)) - .build() + val groupEntry = + GroupEntryBuilder() + .setSummary(groupSummary) + .setChildren(listOf(groupChild1, groupChild2)) + .build() beforeTransformGroupsListener.onBeforeTransformGroups(listOf(groupEntry)) verify(headsUpViewBinder, never()).bindHeadsUpView(any(), any()) beforeFinalizeFilterListener.onBeforeFinalizeFilter(listOf(groupEntry)) @@ -1045,9 +1060,7 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { .thenReturn(DecisionImpl.of(should)) } - private fun setDefaultShouldFullScreen( - originalDecision: FullScreenIntentDecision - ) { + private fun setDefaultShouldFullScreen(originalDecision: FullScreenIntentDecision) { val provider = visualInterruptionDecisionProvider whenever(provider.makeUnloggedFullScreenIntentDecision(any())).thenAnswer { val entry: NotificationEntry = it.getArgument(0) @@ -1059,11 +1072,8 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { entry: NotificationEntry, originalDecision: FullScreenIntentDecision ) { - whenever( - visualInterruptionDecisionProvider.makeUnloggedFullScreenIntentDecision(entry) - ).thenAnswer { - FullScreenIntentDecisionImpl(entry, originalDecision) - } + whenever(visualInterruptionDecisionProvider.makeUnloggedFullScreenIntentDecision(entry)) + .thenAnswer { FullScreenIntentDecisionImpl(entry, originalDecision) } } private fun verifyLoggedFullScreenIntentDecision( @@ -1089,7 +1099,8 @@ class HeadsUpCoordinatorTest : SysuiTestCase() { private fun finishBind(entry: NotificationEntry) { verify(headsUpManager, never()).showNotification(entry) withArgCaptor<BindCallback> { - verify(headsUpViewBinder).bindHeadsUpView(eq(entry), capture()) - }.onBindFinished(entry) + verify(headsUpViewBinder).bindHeadsUpView(eq(entry), capture()) + } + .onBindFinished(entry) } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java index 9fa392f3a337..7a34e94ab362 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java @@ -434,7 +434,11 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase { // Then verify(mBubblesManager).onUserChangedBubble(entry, false); - verify(mHeadsUpManager).removeNotification(entry.getKey(), true); + verify(mHeadsUpManager).removeNotification( + entry.getKey(), + /* releaseImmediately= */ true, + /* reason= */ "onNotificationBubbleIconClicked" + ); verifyNoMoreInteractions(mContentIntent); verifyNoMoreInteractions(mShadeController); @@ -456,7 +460,11 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase { // Then verify(mBubblesManager).onUserChangedBubble(entry, true); - verify(mHeadsUpManager).removeNotification(entry.getKey(), true); + verify(mHeadsUpManager).removeNotification( + entry.getKey(), + /* releaseImmediately= */ true, + /* reason= */ "onNotificationBubbleIconClicked" + ); verify(mContentIntent, atLeastOnce()).isActivity(); verifyNoMoreInteractions(mContentIntent); |