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 7fbb0f1182c07..02aa1f2fd585b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationLaunchAnimatorController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationLaunchAnimatorController.kt @@ -25,7 +25,7 @@ class NotificationLaunchAnimatorControllerProvider @Inject constructor( @JvmOverloads fun getAnimatorController( notification: ExpandableNotificationRow, - onFinishAnimationCallback: Runnable = Runnable {} + onFinishAnimationCallback: Runnable? = null ): NotificationLaunchAnimatorController { return NotificationLaunchAnimatorController( notificationShadeWindowViewController, @@ -49,7 +49,7 @@ class NotificationLaunchAnimatorController( private val headsUpManager: HeadsUpManagerPhone, private val notification: ExpandableNotificationRow, private val jankMonitor: InteractionJankMonitor, - private val onFinishAnimationCallback: Runnable + private val onFinishAnimationCallback: Runnable? ) : ActivityLaunchAnimator.Controller { companion object { @@ -123,7 +123,7 @@ class NotificationLaunchAnimatorController( if (!willAnimate) { removeHun(animate = true) - onFinishAnimationCallback.run() + onFinishAnimationCallback?.run() } } @@ -142,7 +142,7 @@ class NotificationLaunchAnimatorController( notificationShadeWindowViewController.setExpandAnimationRunning(false) notificationEntry.isExpandAnimationRunning = false removeHun(animate = true) - onFinishAnimationCallback.run() + onFinishAnimationCallback?.run() } override fun onLaunchAnimationStart(isExpandingFullyAbove: Boolean) { @@ -162,7 +162,7 @@ class NotificationLaunchAnimatorController( notificationListContainer.setExpandingNotification(null) applyParams(null) removeHun(animate = false) - onFinishAnimationCallback.run() + onFinishAnimationCallback?.run() } private fun applyParams(params: ExpandAnimationParameters?) { 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 637e4bee8948d..6fe92fafc0751 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java @@ -397,15 +397,25 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte mMainThreadHandler.post(() -> { final Runnable removeNotification = () -> { mOnUserInteractionCallback.onDismiss(entry, REASON_CLICK, summaryToRemove); + if (!animate) { + // If we're animating, this would be invoked after the activity launch + // animation completes. Since we're not animating, the launch already + // happened synchronously, so we notify the launch is complete here after + // onDismiss. + mLaunchEventsEmitter.notifyFinishLaunchNotifActivity(entry); + } }; if (mPresenter.isCollapsing()) { - // To avoid lags we're only performing the remove - // after the shade is collapsed + // To avoid lags we're only performing the remove after the shade is collapsed mShadeController.addPostCollapseAction(removeNotification); } else { removeNotification.run(); } }); + } else if (!canBubble && !animate) { + // Not animating, this is the end of the launch flow (see above comment for more info). + mMainThreadHandler.post( + () -> mLaunchEventsEmitter.notifyFinishLaunchNotifActivity(entry)); } mIsCollapsingToShowActivityOverLockscreen = false; @@ -481,8 +491,9 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte boolean isActivityIntent) { mLogger.logStartNotificationIntent(entry.getKey(), intent); try { - Runnable onFinishAnimationCallback = - () -> mLaunchEventsEmitter.notifyFinishLaunchNotifActivity(entry); + Runnable onFinishAnimationCallback = animate + ? () -> mLaunchEventsEmitter.notifyFinishLaunchNotifActivity(entry) + : null; ActivityLaunchAnimator.Controller animationController = new StatusBarLaunchAnimatorController( mNotificationAnimationProvider 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 d48ce8c6803e3..fa867e2796f7c 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 @@ -447,4 +447,15 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase { controllerCaptor.getValue().onIntentStarted(false); verify(listener).onFinishLaunchNotifActivity(mNotificationRow.getEntry()); } + + @Test + public void testNotifActivityStarterEventSourceFinishEvent_postPanelCollapse_noAnimate() { + NotifActivityLaunchEvents.Listener listener = + mock(NotifActivityLaunchEvents.Listener.class); + mLaunchEventsEmitter.registerListener(listener); + when(mCentralSurfaces.shouldAnimateLaunch(anyBoolean())).thenReturn(false); + mNotificationActivityStarter + .onNotificationClicked(mNotificationRow.getEntry().getSbn(), mNotificationRow); + verify(listener).onFinishLaunchNotifActivity(mNotificationRow.getEntry()); + } }