From 101e73a1cf001cae9a4b5be681a28357ea9cc39f Mon Sep 17 00:00:00 2001 From: Nicolo' Mazzucato Date: Mon, 17 Mar 2025 14:49:26 +0000 Subject: Move the shade if expanded from mouse click on the the side statusbar chips The mouse click event was triggering the expansion, but not the move of the shade, causing potential shade expansion in the wrong display. Now we're first moving the shade and then triggering the expansion. Bug: 362719719 Bug: 403581574 Test: PhoneStatusBarViewControllerTest Flag: com.android.systemui.shade_window_goes_around Change-Id: I18f44973078092be8ff5dc64f5db54ea7908d29b --- .../phone/PhoneStatusBarViewController.kt | 16 ++++++-- .../phone/PhoneStatusBarViewControllerTest.kt | 45 ++++++++++++++++++++++ 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewController.kt index caf8a43b2aaf..67a7eee2977a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewController.kt @@ -104,6 +104,7 @@ private constructor( // intercepted. See [View.OnTouchEvent] if (event.source == InputDevice.SOURCE_MOUSE) { if (event.action == MotionEvent.ACTION_UP) { + dispatchEventToShadeDisplayPolicy(event) v.performClick() shadeController.animateExpandShade() } @@ -113,6 +114,15 @@ private constructor( } } + private fun dispatchEventToShadeDisplayPolicy(event: MotionEvent) { + if (ShadeWindowGoesAround.isEnabled) { + // Notify the shade display policy that the status bar was touched. This may cause + // the shade to change display if the touch was in a display different than the shade + // one. + lazyStatusBarShadeDisplayPolicy.get().onStatusBarTouched(event, mView.width) + } + } + private val configurationListener = object : ConfigurationController.ConfigurationListener { override fun onDensityOrFontScaleChanged() { @@ -232,9 +242,6 @@ private constructor( !upOrCancel || shadeController.isExpandedVisible, ) } - if (ShadeWindowGoesAround.isEnabled && event.action == MotionEvent.ACTION_DOWN) { - lazyStatusBarShadeDisplayPolicy.get().onStatusBarTouched(event, mView.width) - } } private fun addDarkReceivers() { @@ -249,6 +256,9 @@ private constructor( inner class PhoneStatusBarViewTouchHandler : Gefingerpoken { override fun onInterceptTouchEvent(event: MotionEvent): Boolean { + if (event.action == MotionEvent.ACTION_DOWN) { + dispatchEventToShadeDisplayPolicy(event) + } return if (Flags.statusBarSwipeOverChip()) { shadeViewController.handleExternalInterceptTouch(event) } else { diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewControllerTest.kt index 68f66611c981..574b2c010a37 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewControllerTest.kt @@ -470,6 +470,51 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() { verify(statusBarTouchShadeDisplayPolicy, never()).onStatusBarTouched(eq(event), any()) } + @Test + @EnableFlags(ShadeWindowGoesAround.FLAG_NAME) + fun onTouch_withMouseOnEndSideIcons_flagOn_propagatedToShadeDisplayPolicy() { + val view = createViewMock() + InstrumentationRegistry.getInstrumentation().runOnMainSync { + controller = createAndInitController(view) + } + val event = getActionUpEventFromSource(InputDevice.SOURCE_MOUSE) + + val statusContainer = view.requireViewById(R.id.system_icons) + statusContainer.dispatchTouchEvent(event) + + verify(statusBarTouchShadeDisplayPolicy).onStatusBarTouched(eq(event), any()) + } + + @Test + @EnableFlags(ShadeWindowGoesAround.FLAG_NAME) + fun onTouch_withMouseOnStartSideIcons_flagOn_propagatedToShadeDisplayPolicy() { + val view = createViewMock() + InstrumentationRegistry.getInstrumentation().runOnMainSync { + controller = createAndInitController(view) + } + val event = getActionUpEventFromSource(InputDevice.SOURCE_MOUSE) + + val statusContainer = view.requireViewById(R.id.status_bar_start_side_content) + statusContainer.dispatchTouchEvent(event) + + verify(statusBarTouchShadeDisplayPolicy).onStatusBarTouched(eq(event), any()) + } + + @Test + @DisableFlags(ShadeWindowGoesAround.FLAG_NAME) + fun onTouch_withMouseOnSystemIcons_flagOff_notPropagatedToShadeDisplayPolicy() { + val view = createViewMock() + InstrumentationRegistry.getInstrumentation().runOnMainSync { + controller = createAndInitController(view) + } + val event = getActionUpEventFromSource(InputDevice.SOURCE_MOUSE) + + val statusContainer = view.requireViewById(R.id.system_icons) + statusContainer.dispatchTouchEvent(event) + + verify(statusBarTouchShadeDisplayPolicy, never()).onStatusBarTouched(eq(event), any()) + } + @Test fun shadeIsExpandedOnStatusIconMouseClick() { val view = createViewMock() -- cgit v1.2.3-59-g8ed1b