From 02fdb756873be61cd1e2703546d98e9c0bbca1f4 Mon Sep 17 00:00:00 2001 From: Liran Binyamin Date: Thu, 15 Aug 2024 08:18:42 +0000 Subject: [PATCH] Revert^2 "Synchronize bar expansion with WM Shell" 799802cb7e44ee856a972bbf1664deb3352ac3d4 Flag: com.android.wm.shell.enable_bubble_bar Fixes: 339683389 Test: atest BubbleBarViewAnimatorTest Change-Id: Icd853eb76b20ee5ca035bd20c9360f5b60ecc00d --- .../taskbar/bubbles/BubbleBarController.java | 5 + .../bubbles/BubbleBarViewController.java | 3 +- .../animation/BubbleBarViewAnimator.kt | 14 +- .../com/android/quickstep/SystemUiProxy.java | 11 ++ .../animation/BubbleBarViewAnimatorTest.kt | 147 ++++++++++++++++-- 5 files changed, 158 insertions(+), 22 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java index 33d8a8430f..1a51861b36 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java @@ -495,6 +495,11 @@ public class BubbleBarController extends IBubblesListener.Stub { () -> mBubbleBarViewController.animateBubbleBarLocation(bubbleBarLocation)); } + /** Notifies WMShell to show the expanded view. */ + void showExpandedView() { + mSystemUiProxy.showExpandedView(); + } + // // Loading data for the bubbles // diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java index 3261262621..17ccfc56eb 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java @@ -119,7 +119,8 @@ public class BubbleBarViewController { mBubbleDragController = bubbleControllers.bubbleDragController; mTaskbarStashController = controllers.taskbarStashController; mTaskbarInsetsController = controllers.taskbarInsetsController; - mBubbleBarViewAnimator = new BubbleBarViewAnimator(mBarView, mBubbleStashController); + mBubbleBarViewAnimator = new BubbleBarViewAnimator( + mBarView, mBubbleStashController, mBubbleBarController::showExpandedView); mTaskbarViewPropertiesProvider = taskbarViewPropertiesProvider; onBubbleBarConfigurationChanged(/* animate= */ false); mActivity.addOnDeviceProfileChangeListener( diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimator.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimator.kt index 2ed88d83f1..99c50f248d 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimator.kt +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimator.kt @@ -36,6 +36,7 @@ class BubbleBarViewAnimator constructor( private val bubbleBarView: BubbleBarView, private val bubbleStashController: BubbleStashController, + private val onExpanded: Runnable, private val scheduler: Scheduler = HandlerScheduler(bubbleBarView) ) { @@ -406,7 +407,7 @@ constructor( springBackAnimation.spring(DynamicAnimation.TRANSLATION_Y, ty) springBackAnimation.addEndListener { _, _, _, _, _, _, _ -> if (animatingBubble?.expand == true) { - bubbleBarView.isExpanded = true + expandBubbleBar() cancelHideAnimation() } else { moveToState(AnimatingBubble.State.IN) @@ -417,7 +418,7 @@ constructor( ObjectAnimator.ofFloat(bubbleBarView, View.TRANSLATION_Y, ty - bubbleBarBounceDistanceInPx) .withDuration(BUBBLE_BAR_BOUNCE_ANIMATION_DURATION_MS) .withEndAction { - if (animatingBubble?.expand == true) bubbleBarView.isExpanded = true + if (animatingBubble?.expand == true) expandBubbleBar() springBackAnimation.start() } .start() @@ -451,7 +452,7 @@ constructor( this.animatingBubble = animatingBubble.copy(expand = true) // if we're fully in and waiting to hide, cancel the hide animation and clean up if (animatingBubble.state == AnimatingBubble.State.IN) { - bubbleBarView.isExpanded = true + expandBubbleBar() cancelHideAnimation() } } @@ -489,6 +490,11 @@ constructor( this.animatingBubble = animatingBubble.copy(state = state) } + private fun expandBubbleBar() { + bubbleBarView.isExpanded = true + onExpanded.run() + } + /** * Tracks the translation Y of the bubble bar during the animation. When the bubble bar expands * as part of the animation, the expansion should start after the bubble bar reaches the peak @@ -510,7 +516,7 @@ constructor( } val expand = animatingBubble?.expand ?: false if (reachedPeak && expand && !startedExpanding) { - bubbleBarView.isExpanded = true + expandBubbleBar() startedExpanding = true } previousTy = ty diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java index 59e9f054c8..fb19aa27a0 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.java +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java @@ -923,6 +923,17 @@ public class SystemUiProxy implements ISystemUiProxy, NavHandle, SafeCloseable { } } + /** Tells SysUI to show the expanded view. */ + public void showExpandedView() { + try { + if (mBubbles != null) { + mBubbles.showExpandedView(); + } + } catch (RemoteException e) { + Log.w(TAG, "Failed to call showExpandedView"); + } + } + // // Splitscreen // diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimatorTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimatorTest.kt index 4da06e1286..7928ce92b4 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimatorTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimatorTest.kt @@ -64,6 +64,7 @@ class BubbleBarViewAnimatorTest { private lateinit var bubble: BubbleBarBubble private lateinit var bubbleBarView: BubbleBarView private lateinit var bubbleStashController: BubbleStashController + private val onExpandedNoOp = Runnable {} @Before fun setUp() { @@ -81,7 +82,12 @@ class BubbleBarViewAnimatorTest { whenever(bubbleStashController.getStashedHandlePhysicsAnimator()).thenReturn(handleAnimator) val animator = - BubbleBarViewAnimator(bubbleBarView, bubbleStashController, animatorScheduler) + BubbleBarViewAnimator( + bubbleBarView, + bubbleStashController, + onExpandedNoOp, + animatorScheduler + ) InstrumentationRegistry.getInstrumentation().runOnMainSync { animator.animateBubbleInForStashed(bubble, isExpanding = false) @@ -125,7 +131,12 @@ class BubbleBarViewAnimatorTest { whenever(bubbleStashController.getStashedHandlePhysicsAnimator()).thenReturn(handleAnimator) val animator = - BubbleBarViewAnimator(bubbleBarView, bubbleStashController, animatorScheduler) + BubbleBarViewAnimator( + bubbleBarView, + bubbleStashController, + onExpandedNoOp, + animatorScheduler + ) InstrumentationRegistry.getInstrumentation().runOnMainSync { animator.animateBubbleInForStashed(bubble, isExpanding = false) @@ -168,7 +179,12 @@ class BubbleBarViewAnimatorTest { whenever(bubbleStashController.getStashedHandlePhysicsAnimator()).thenReturn(handleAnimator) val animator = - BubbleBarViewAnimator(bubbleBarView, bubbleStashController, animatorScheduler) + BubbleBarViewAnimator( + bubbleBarView, + bubbleStashController, + onExpandedNoOp, + animatorScheduler + ) InstrumentationRegistry.getInstrumentation().runOnMainSync { animator.animateBubbleInForStashed(bubble, isExpanding = false) @@ -208,7 +224,12 @@ class BubbleBarViewAnimatorTest { whenever(bubbleStashController.getStashedHandlePhysicsAnimator()).thenReturn(handleAnimator) val animator = - BubbleBarViewAnimator(bubbleBarView, bubbleStashController, animatorScheduler) + BubbleBarViewAnimator( + bubbleBarView, + bubbleStashController, + onExpandedNoOp, + animatorScheduler + ) InstrumentationRegistry.getInstrumentation().runOnMainSync { animator.animateBubbleInForStashed(bubble, isExpanding = false) @@ -249,7 +270,12 @@ class BubbleBarViewAnimatorTest { whenever(bubbleStashController.getStashedHandlePhysicsAnimator()).thenReturn(handleAnimator) val animator = - BubbleBarViewAnimator(bubbleBarView, bubbleStashController, animatorScheduler) + BubbleBarViewAnimator( + bubbleBarView, + bubbleStashController, + onExpandedNoOp, + animatorScheduler + ) InstrumentationRegistry.getInstrumentation().runOnMainSync { animator.animateBubbleInForStashed(bubble, isExpanding = false) @@ -278,8 +304,15 @@ class BubbleBarViewAnimatorTest { val handleAnimator = PhysicsAnimator.getInstance(handle) whenever(bubbleStashController.getStashedHandlePhysicsAnimator()).thenReturn(handleAnimator) + var notifiedExpanded = false + val onExpanded = Runnable { notifiedExpanded = true } val animator = - BubbleBarViewAnimator(bubbleBarView, bubbleStashController, animatorScheduler) + BubbleBarViewAnimator( + bubbleBarView, + bubbleStashController, + onExpanded, + animatorScheduler + ) InstrumentationRegistry.getInstrumentation().runOnMainSync { animator.animateBubbleInForStashed(bubble, isExpanding = true) @@ -303,6 +336,7 @@ class BubbleBarViewAnimatorTest { assertThat(animatorScheduler.delayedBlock).isNull() verify(bubbleStashController).showBubbleBarImmediate() + assertThat(notifiedExpanded).isTrue() } @Test @@ -314,8 +348,15 @@ class BubbleBarViewAnimatorTest { val handleAnimator = PhysicsAnimator.getInstance(handle) whenever(bubbleStashController.getStashedHandlePhysicsAnimator()).thenReturn(handleAnimator) + var notifiedExpanded = false + val onExpanded = Runnable { notifiedExpanded = true } val animator = - BubbleBarViewAnimator(bubbleBarView, bubbleStashController, animatorScheduler) + BubbleBarViewAnimator( + bubbleBarView, + bubbleStashController, + onExpanded, + animatorScheduler + ) InstrumentationRegistry.getInstrumentation().runOnMainSync { animator.animateBubbleInForStashed(bubble, isExpanding = false) @@ -345,6 +386,7 @@ class BubbleBarViewAnimatorTest { .isEqualTo(DIFF_BETWEEN_HANDLE_AND_BAR_CENTERS + BAR_TRANSLATION_Y_FOR_TASKBAR) verifyBubbleBarIsExpandedWithTranslation(BAR_TRANSLATION_Y_FOR_TASKBAR) assertThat(animator.isAnimating).isFalse() + assertThat(notifiedExpanded).isTrue() } @Test @@ -356,8 +398,15 @@ class BubbleBarViewAnimatorTest { val handleAnimator = PhysicsAnimator.getInstance(handle) whenever(bubbleStashController.getStashedHandlePhysicsAnimator()).thenReturn(handleAnimator) + var notifiedExpanded = false + val onExpanded = Runnable { notifiedExpanded = true } val animator = - BubbleBarViewAnimator(bubbleBarView, bubbleStashController, animatorScheduler) + BubbleBarViewAnimator( + bubbleBarView, + bubbleStashController, + onExpanded, + animatorScheduler + ) InstrumentationRegistry.getInstrumentation().runOnMainSync { animator.animateBubbleInForStashed(bubble, isExpanding = false) @@ -384,6 +433,7 @@ class BubbleBarViewAnimatorTest { .isEqualTo(DIFF_BETWEEN_HANDLE_AND_BAR_CENTERS + BAR_TRANSLATION_Y_FOR_TASKBAR) verifyBubbleBarIsExpandedWithTranslation(BAR_TRANSLATION_Y_FOR_TASKBAR) assertThat(animator.isAnimating).isFalse() + assertThat(notifiedExpanded).isTrue() } @Test @@ -400,7 +450,12 @@ class BubbleBarViewAnimatorTest { val barAnimator = PhysicsAnimator.getInstance(bubbleBarView) val animator = - BubbleBarViewAnimator(bubbleBarView, bubbleStashController, animatorScheduler) + BubbleBarViewAnimator( + bubbleBarView, + bubbleStashController, + onExpandedNoOp, + animatorScheduler + ) InstrumentationRegistry.getInstrumentation().runOnMainSync { animator.animateToInitialState(bubble, isInApp = true, isExpanding = false) @@ -442,8 +497,15 @@ class BubbleBarViewAnimatorTest { val barAnimator = PhysicsAnimator.getInstance(bubbleBarView) + var notifiedExpanded = false + val onExpanded = Runnable { notifiedExpanded = true } val animator = - BubbleBarViewAnimator(bubbleBarView, bubbleStashController, animatorScheduler) + BubbleBarViewAnimator( + bubbleBarView, + bubbleStashController, + onExpanded, + animatorScheduler + ) InstrumentationRegistry.getInstrumentation().runOnMainSync { animator.animateToInitialState(bubble, isInApp = true, isExpanding = true) @@ -459,6 +521,7 @@ class BubbleBarViewAnimatorTest { assertThat(animatorScheduler.delayedBlock).isNull() verify(bubbleStashController).showBubbleBarImmediate() + assertThat(notifiedExpanded).isTrue() } @Test @@ -471,7 +534,12 @@ class BubbleBarViewAnimatorTest { val barAnimator = PhysicsAnimator.getInstance(bubbleBarView) val animator = - BubbleBarViewAnimator(bubbleBarView, bubbleStashController, animatorScheduler) + BubbleBarViewAnimator( + bubbleBarView, + bubbleStashController, + onExpandedNoOp, + animatorScheduler + ) InstrumentationRegistry.getInstrumentation().runOnMainSync { animator.animateToInitialState(bubble, isInApp = false, isExpanding = false) @@ -502,8 +570,15 @@ class BubbleBarViewAnimatorTest { whenever(bubbleStashController.bubbleBarTranslationY) .thenReturn(BAR_TRANSLATION_Y_FOR_HOTSEAT) + var notifiedExpanded = false + val onExpanded = Runnable { notifiedExpanded = true } val animator = - BubbleBarViewAnimator(bubbleBarView, bubbleStashController, animatorScheduler) + BubbleBarViewAnimator( + bubbleBarView, + bubbleStashController, + onExpanded, + animatorScheduler + ) InstrumentationRegistry.getInstrumentation().runOnMainSync { animator.animateToInitialState(bubble, isInApp = false, isExpanding = false) @@ -533,6 +608,7 @@ class BubbleBarViewAnimatorTest { verifyBubbleBarIsExpandedWithTranslation(BAR_TRANSLATION_Y_FOR_HOTSEAT) assertThat(animator.isAnimating).isFalse() verify(bubbleStashController).showBubbleBarImmediate() + assertThat(notifiedExpanded).isTrue() } @Test @@ -542,8 +618,15 @@ class BubbleBarViewAnimatorTest { whenever(bubbleStashController.bubbleBarTranslationY) .thenReturn(BAR_TRANSLATION_Y_FOR_HOTSEAT) + var notifiedExpanded = false + val onExpanded = Runnable { notifiedExpanded = true } val animator = - BubbleBarViewAnimator(bubbleBarView, bubbleStashController, animatorScheduler) + BubbleBarViewAnimator( + bubbleBarView, + bubbleStashController, + onExpanded, + animatorScheduler + ) InstrumentationRegistry.getInstrumentation().runOnMainSync { animator.animateToInitialState(bubble, isInApp = false, isExpanding = false) @@ -566,6 +649,7 @@ class BubbleBarViewAnimatorTest { verifyBubbleBarIsExpandedWithTranslation(BAR_TRANSLATION_Y_FOR_HOTSEAT) assertThat(animator.isAnimating).isFalse() + assertThat(notifiedExpanded).isTrue() } @Test @@ -578,7 +662,12 @@ class BubbleBarViewAnimatorTest { val barAnimator = PhysicsAnimator.getInstance(bubbleBarView) val animator = - BubbleBarViewAnimator(bubbleBarView, bubbleStashController, animatorScheduler) + BubbleBarViewAnimator( + bubbleBarView, + bubbleStashController, + onExpandedNoOp, + animatorScheduler + ) InstrumentationRegistry.getInstrumentation().runOnMainSync { animator.animateBubbleBarForCollapsed(bubble, isExpanding = false) @@ -617,8 +706,15 @@ class BubbleBarViewAnimatorTest { val barAnimator = PhysicsAnimator.getInstance(bubbleBarView) + var notifiedExpanded = false + val onExpanded = Runnable { notifiedExpanded = true } val animator = - BubbleBarViewAnimator(bubbleBarView, bubbleStashController, animatorScheduler) + BubbleBarViewAnimator( + bubbleBarView, + bubbleStashController, + onExpanded, + animatorScheduler + ) InstrumentationRegistry.getInstrumentation().runOnMainSync { animator.animateBubbleBarForCollapsed(bubble, isExpanding = true) @@ -645,6 +741,7 @@ class BubbleBarViewAnimatorTest { assertThat(bubbleBarView.translationY).isEqualTo(BAR_TRANSLATION_Y_FOR_HOTSEAT) assertThat(bubbleBarView.isExpanded).isTrue() verify(bubbleStashController).showBubbleBarImmediate() + assertThat(notifiedExpanded).isTrue() } @Test @@ -656,8 +753,15 @@ class BubbleBarViewAnimatorTest { val barAnimator = PhysicsAnimator.getInstance(bubbleBarView) + var notifiedExpanded = false + val onExpanded = Runnable { notifiedExpanded = true } val animator = - BubbleBarViewAnimator(bubbleBarView, bubbleStashController, animatorScheduler) + BubbleBarViewAnimator( + bubbleBarView, + bubbleStashController, + onExpanded, + animatorScheduler + ) InstrumentationRegistry.getInstrumentation().runOnMainSync { animator.animateBubbleBarForCollapsed(bubble, isExpanding = false) @@ -695,6 +799,7 @@ class BubbleBarViewAnimatorTest { assertThat(bubbleBarView.translationY).isEqualTo(BAR_TRANSLATION_Y_FOR_HOTSEAT) assertThat(bubbleBarView.isExpanded).isTrue() verify(bubbleStashController).showBubbleBarImmediate() + assertThat(notifiedExpanded).isTrue() } @Test @@ -706,8 +811,15 @@ class BubbleBarViewAnimatorTest { val barAnimator = PhysicsAnimator.getInstance(bubbleBarView) + var notifiedExpanded = false + val onExpanded = Runnable { notifiedExpanded = true } val animator = - BubbleBarViewAnimator(bubbleBarView, bubbleStashController, animatorScheduler) + BubbleBarViewAnimator( + bubbleBarView, + bubbleStashController, + onExpanded, + animatorScheduler + ) InstrumentationRegistry.getInstrumentation().runOnMainSync { animator.animateBubbleBarForCollapsed(bubble, isExpanding = false) @@ -742,6 +854,7 @@ class BubbleBarViewAnimatorTest { assertThat(bubbleBarView.translationY).isEqualTo(BAR_TRANSLATION_Y_FOR_HOTSEAT) assertThat(bubbleBarView.isExpanded).isTrue() verify(bubbleStashController).showBubbleBarImmediate() + assertThat(notifiedExpanded).isTrue() } private fun setUpBubbleBar() {