From 7f6bc03f00e97a1da82d46107d25b3c4b2a94851 Mon Sep 17 00:00:00 2001 From: Jordan Demeulenaere Date: Mon, 26 Apr 2021 11:21:53 +0200 Subject: [PATCH] Close the shade when launch animation is cancelled. This CL makes sure that we close the shade when a launch animation is cancelled. It also combines what we do when a launch animation won't run (i.e. it is cancelled, aborted or timed out). Bug: 184457208 Test: Manual Change-Id: Id9b26e65e455e5b806a223575c31a9401cf91052 --- .../animation/ActivityLaunchAnimator.kt | 22 +++++-------------- .../NotificationLaunchAnimatorController.kt | 8 ------- .../systemui/statusbar/phone/StatusBar.java | 18 +++++---------- .../StatusBarLaunchAnimatorController.kt | 12 +--------- .../animation/ActivityLaunchAnimatorTest.kt | 12 ++-------- 5 files changed, 13 insertions(+), 59 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 947ae8af8f752..6d6bc07c01b52 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityLaunchAnimator.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityLaunchAnimator.kt @@ -191,23 +191,11 @@ class ActivityLaunchAnimator(context: Context) { fun onLaunchAnimationEnd(isExpandingFullyAbove: Boolean) {} /** - * The animation was cancelled remotely. Note that [onLaunchAnimationEnd] will still be - * called after this if the animation was already started, i.e. if [onLaunchAnimationStart] - * was called before the cancellation. + * 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. */ fun onLaunchAnimationCancelled() {} - - /** - * The remote animation was not started within the expected time. It timed out and will - * never [start][onLaunchAnimationStart]. - */ - fun onLaunchAnimationTimedOut() {} - - /** - * The animation was aborted because the opening window was not found. It will never - * [start][onLaunchAnimationStart]. - */ - fun onLaunchAnimationAborted() {} } /** The state of an expandable view during an [ActivityLaunchAnimator] animation. */ @@ -332,7 +320,7 @@ class ActivityLaunchAnimator(context: Context) { if (window == null) { removeTimeout() invokeCallback(iCallback) - controller.onLaunchAnimationAborted() + controller.onLaunchAnimationCancelled() return } @@ -486,7 +474,7 @@ class ActivityLaunchAnimator(context: Context) { } timedOut = true - controller.onLaunchAnimationTimedOut() + controller.onLaunchAnimationCancelled() } override fun onAnimationCancelled() { 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 d925a93d982a8..c85b62fc0d9a8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationLaunchAnimatorController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationLaunchAnimatorController.kt @@ -84,14 +84,6 @@ class NotificationLaunchAnimatorController( notificationShadeWindowViewController.setExpandAnimationRunning(false) } - override fun onLaunchAnimationTimedOut() { - notificationShadeWindowViewController.setExpandAnimationRunning(false) - } - - override fun onLaunchAnimationAborted() { - notificationShadeWindowViewController.setExpandAnimationRunning(false) - } - override fun onLaunchAnimationStart(isExpandingFullyAbove: Boolean) { notification.isExpandAnimationRunning = true notificationListContainer.setExpandingNotification(notification) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index 026072bf0d6a9..71d80b165fe70 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -21,7 +21,6 @@ import static android.app.StatusBarManager.WINDOW_STATE_SHOWING; import static android.app.StatusBarManager.WindowType; import static android.app.StatusBarManager.WindowVisibleState; import static android.app.StatusBarManager.windowStateToString; -import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY; import static android.hardware.biometrics.BiometricSourceType.FINGERPRINT; import static android.view.InsetsState.ITYPE_STATUS_BAR; import static android.view.InsetsState.containsType; @@ -2016,9 +2015,12 @@ public class StatusBar extends SystemUI implements DemoMode, /** A launch animation was cancelled. */ //TODO: These can / should probably be moved to NotificationPresenter or ShadeController - public void onLaunchAnimationCancelled() { - if (!mPresenter.isCollapsing()) { + public void onLaunchAnimationCancelled(boolean isLaunchForActivity) { + if (mPresenter.isPresenterFullyCollapsed() && !mPresenter.isCollapsing() + && isLaunchForActivity) { onClosingFinished(); + } else { + mShadeController.collapsePanel(true /* animate */); } } @@ -2032,16 +2034,6 @@ public class StatusBar extends SystemUI implements DemoMode, } } - /** A launch animation timed out. */ - public void onLaunchAnimationTimedOut(boolean isLaunchForActivity) { - if (mPresenter.isPresenterFullyCollapsed() && !mPresenter.isCollapsing() - && isLaunchForActivity) { - onClosingFinished(); - } else { - mShadeController.collapsePanel(true /* animate */); - } - } - /** Whether we should animate an activity launch. */ public boolean areLaunchAnimationsEnabled() { // TODO(b/184121838): Support lock screen launch animations. 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 4a56020aebce9..b2ab30785b4e4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarLaunchAnimatorController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarLaunchAnimatorController.kt @@ -43,16 +43,6 @@ class StatusBarLaunchAnimatorController( override fun onLaunchAnimationCancelled() { delegate.onLaunchAnimationCancelled() - statusBar.onLaunchAnimationCancelled() - } - - override fun onLaunchAnimationTimedOut() { - delegate.onLaunchAnimationTimedOut() - statusBar.onLaunchAnimationTimedOut(isLaunchForActivity) - } - - override fun onLaunchAnimationAborted() { - delegate.onLaunchAnimationAborted() - statusBar.collapsePanelOnMainThread() + statusBar.onLaunchAnimationCancelled(isLaunchForActivity) } } \ No newline at end of file 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 6420c4e2c481c..c023610b6052b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/animation/ActivityLaunchAnimatorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/animation/ActivityLaunchAnimatorTest.kt @@ -106,12 +106,12 @@ class ActivityLaunchAnimatorTest : SysuiTestCase() { } @Test - fun abortsIfNoOpeningWindowIsFound() { + fun cancelsIfNoOpeningWindowIsFound() { val runner = activityLaunchAnimator.createRunner(controller) runner.onAnimationStart(0, emptyArray(), emptyArray(), emptyArray(), iCallback) waitForIdleSync() - verify(controller).onLaunchAnimationAborted() + verify(controller).onLaunchAnimationCancelled() verify(controller, never()).onLaunchAnimationStart(anyBoolean()) } @@ -177,12 +177,4 @@ private class TestLaunchAnimatorController( override fun onLaunchAnimationCancelled() { assertOnMainThread() } - - override fun onLaunchAnimationTimedOut() { - assertOnMainThread() - } - - override fun onLaunchAnimationAborted() { - assertOnMainThread() - } }