From 55b1bc3200349c70f388a69f9a0c36fc0c3dea4e Mon Sep 17 00:00:00 2001 From: Josh Tsuji Date: Tue, 9 Aug 2022 15:41:51 -0400 Subject: [PATCH] Pass keyguard occlude state to onLaunchAnimationCancelled. We need to apply this canonical occlusion state whenever an animation that occludes the lockscreen is cancelled. We usually do this via KeyguardViewMediator's occlusion launch animator, but the controls/wallet launch cases do not use this code path, so the WM occlusion value was being ignored. This is normally fine, but in an edge case where the animation is cancelled before it begins, this resulted in a temporary mismatch of the occlusion state, leaving an empty wallpaper with no lockscreen rendered. Fixes: 240347798 Test: atest SystemUITests Test: launch controls activity over lockscreen with a patch to force WM to instantly cancel all remote launch animations Change-Id: I8a11db3a3b277364c1d8415aa152b352aa8a1c36 --- .../systemui/animation/ActivityLaunchAnimator.kt | 7 +++++-- .../systemui/animation/DialogLaunchAnimator.kt | 2 +- .../systemui/keyguard/KeyguardViewMediator.java | 2 +- .../NotificationLaunchAnimatorController.kt | 2 +- .../statusbar/phone/CentralSurfacesImpl.java | 9 +++++++-- .../phone/StatusBarLaunchAnimatorController.kt | 2 +- .../animation/ActivityLaunchAnimatorTest.kt | 15 +++++++++++++-- 7 files changed, 29 insertions(+), 10 deletions(-) diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityLaunchAnimator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityLaunchAnimator.kt index 7d4dcf88542b8..ebabdf571dfd1 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityLaunchAnimator.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityLaunchAnimator.kt @@ -352,8 +352,11 @@ class ActivityLaunchAnimator( * The animation was cancelled. Note that [onLaunchAnimationEnd] will still be called after * this if the animation was already started, i.e. if [onLaunchAnimationStart] was called * before the cancellation. + * + * If this launch animation affected the occlusion state of the keyguard, WM will provide + * us with [newKeyguardOccludedState] so that we can set the occluded state appropriately. */ - fun onLaunchAnimationCancelled() {} + fun onLaunchAnimationCancelled(newKeyguardOccludedState: Boolean? = null) {} } @VisibleForTesting @@ -667,7 +670,7 @@ class ActivityLaunchAnimator( removeTimeout() context.mainExecutor.execute { animation?.cancel() - controller.onLaunchAnimationCancelled() + controller.onLaunchAnimationCancelled(newKeyguardOccludedState = isKeyguardOccluded) } } diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/DialogLaunchAnimator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/DialogLaunchAnimator.kt index eac5d275092a5..9656b8a99d413 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/animation/DialogLaunchAnimator.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/DialogLaunchAnimator.kt @@ -238,7 +238,7 @@ constructor( } } - override fun onLaunchAnimationCancelled() { + override fun onLaunchAnimationCancelled(newKeyguardOccludedState: Boolean?) { controller.onLaunchAnimationCancelled() enableDialogDismiss() dialog.dismiss() diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index d4e0f061ba060..07bfcbea2882a 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -831,7 +831,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable, public void onLaunchAnimationStart(boolean isExpandingFullyAbove) {} @Override - public void onLaunchAnimationCancelled() { + public void onLaunchAnimationCancelled(@Nullable Boolean newKeyguardOccludedState) { Log.d(TAG, "Occlude launch animation cancelled. Occluded state is now: " + mOccluded); } 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 31b21c9b53213..553826dda9196 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationLaunchAnimatorController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationLaunchAnimatorController.kt @@ -136,7 +136,7 @@ class NotificationLaunchAnimatorController( headsUpManager.removeNotification(notificationKey, true /* releaseImmediately */, animate) } - override fun onLaunchAnimationCancelled() { + override fun onLaunchAnimationCancelled(newKeyguardOccludedState: Boolean?) { // TODO(b/184121838): Should we call InteractionJankMonitor.cancel if the animation started // here? notificationShadeWindowViewController.setExpandAnimationRunning(false) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java index cebb4b76cc599..a4fc96255ec0d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -1721,13 +1721,18 @@ public class CentralSurfacesImpl extends CoreStartable implements } @Override - public void onLaunchAnimationCancelled() { + public void onLaunchAnimationCancelled(@Nullable Boolean newKeyguardOccludedState) { + if (newKeyguardOccludedState != null) { + mKeyguardViewMediator.setOccluded( + newKeyguardOccludedState, false /* animate */); + } + // Set mIsLaunchingActivityOverLockscreen to false before actually finishing the // animation so that we can assume that mIsLaunchingActivityOverLockscreen // being true means that we will collapse the shade (or at least run the // post collapse runnables) later on. CentralSurfacesImpl.this.mIsLaunchingActivityOverLockscreen = false; - getDelegate().onLaunchAnimationCancelled(); + getDelegate().onLaunchAnimationCancelled(newKeyguardOccludedState); } }; } else if (dismissShade) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarLaunchAnimatorController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarLaunchAnimatorController.kt index c0922163903fe..ee948c04df386 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarLaunchAnimatorController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarLaunchAnimatorController.kt @@ -51,7 +51,7 @@ class StatusBarLaunchAnimatorController( centralSurfaces.notificationPanelViewController.applyLaunchAnimationProgress(linearProgress) } - override fun onLaunchAnimationCancelled() { + override fun onLaunchAnimationCancelled(newKeyguardOccludedState: Boolean?) { delegate.onLaunchAnimationCancelled() centralSurfaces.notificationPanelViewController.setIsLaunchAnimationRunning(false) centralSurfaces.onLaunchAnimationCancelled(isLaunchForActivity) diff --git a/packages/SystemUI/tests/src/com/android/systemui/animation/ActivityLaunchAnimatorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/animation/ActivityLaunchAnimatorTest.kt index e2790e47fe06e..a61cd23b60fc8 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/animation/ActivityLaunchAnimatorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/animation/ActivityLaunchAnimatorTest.kt @@ -161,7 +161,18 @@ class ActivityLaunchAnimatorTest : SysuiTestCase() { runner.onAnimationStart(0, emptyArray(), emptyArray(), emptyArray(), iCallback) waitForIdleSync() - verify(controller).onLaunchAnimationCancelled() + verify(controller).onLaunchAnimationCancelled(false /* newKeyguardOccludedState */) + verify(controller, never()).onLaunchAnimationStart(anyBoolean()) + } + + @Test + fun passesOccludedStateToLaunchAnimationCancelled_ifTrue() { + val runner = activityLaunchAnimator.createRunner(controller) + runner.onAnimationCancelled(true /* isKeyguardOccluded */) + runner.onAnimationStart(0, emptyArray(), emptyArray(), emptyArray(), iCallback) + + waitForIdleSync() + verify(controller).onLaunchAnimationCancelled(true /* newKeyguardOccludedState */) verify(controller, never()).onLaunchAnimationStart(anyBoolean()) } @@ -253,7 +264,7 @@ private class TestLaunchAnimatorController(override var launchContainer: ViewGro assertOnMainThread() } - override fun onLaunchAnimationCancelled() { + override fun onLaunchAnimationCancelled(newKeyguardOccludedState: Boolean?) { assertOnMainThread() } }