diff options
author | 2025-01-03 01:40:46 -0800 | |
---|---|---|
committer | 2025-01-03 01:40:46 -0800 | |
commit | 8fed0eec70a3d46addf5ff86fde1f40cad582384 (patch) | |
tree | 950dcc7b4285e5f357177ffb304125843e3bcbfb | |
parent | f66127f207ec6064d614b741f3774b80d2f79d70 (diff) | |
parent | 87001674f297831aa1e91d45661611d73d965739 (diff) |
Merge "Remove the call to ShadeDisplayRepository without ShadeWindowGoesAround.isEnabled check in PhoneStatusBarViewController" into main
2 files changed, 64 insertions, 22 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 2467e0890100..ccd1b6c4e266 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewController.kt @@ -18,6 +18,7 @@ package com.android.systemui.statusbar.phone import android.app.StatusBarManager.WINDOW_STATUS_BAR import android.graphics.Point import android.util.Log +import android.view.Display.DEFAULT_DISPLAY import android.view.InputDevice import android.view.MotionEvent import android.view.View @@ -39,7 +40,6 @@ import com.android.systemui.shade.ShadeExpandsOnStatusBarLongPress import com.android.systemui.shade.ShadeLogger import com.android.systemui.shade.ShadeViewController import com.android.systemui.shade.StatusBarLongPressGestureDetector -import com.android.systemui.shade.data.repository.ShadeDisplaysRepository import com.android.systemui.shade.display.StatusBarTouchShadeDisplayPolicy import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround @@ -85,7 +85,6 @@ private constructor( private val darkIconDispatcher: DarkIconDispatcher, private val statusBarContentInsetsProvider: StatusBarContentInsetsProvider, private val lazyStatusBarShadeDisplayPolicy: Lazy<StatusBarTouchShadeDisplayPolicy>, - private val shadeDisplaysRepository: ShadeDisplaysRepository, ) : ViewController<PhoneStatusBarView>(view) { private lateinit var battery: BatteryMeterView @@ -301,12 +300,12 @@ private constructor( } // With the StatusBarConnectedDisplays changes, status bar touches should result in - // shade interaction only if ShadeWindowGoesAround.isEnabled or if touch is on the - // display which currently hosts the shade. + // shade interaction only if ShadeWindowGoesAround.isEnabled or if touch is on default + // display. return if ( !StatusBarConnectedDisplays.isEnabled || ShadeWindowGoesAround.isEnabled || - context.displayId == shadeDisplaysRepository.displayId.value + context.displayId == DEFAULT_DISPLAY ) { shadeViewController.handleExternalTouch(event) } else { @@ -367,7 +366,6 @@ private constructor( @DisplaySpecific private val darkIconDispatcher: DarkIconDispatcher, private val statusBarContentInsetsProviderStore: StatusBarContentInsetsProviderStore, private val lazyStatusBarShadeDisplayPolicy: Lazy<StatusBarTouchShadeDisplayPolicy>, - private val shadeDisplaysRepository: ShadeDisplaysRepository, ) { fun create(view: PhoneStatusBarView): PhoneStatusBarViewController { val statusBarMoveFromCenterAnimationController = @@ -396,7 +394,6 @@ private constructor( darkIconDispatcher, statusBarContentInsetsProviderStore.defaultDisplay, lazyStatusBarShadeDisplayPolicy, - shadeDisplaysRepository, ) } } 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 0ba0aeb87225..243be3dc142d 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 @@ -21,8 +21,12 @@ import android.app.StatusBarManager.WINDOW_STATE_HIDING import android.app.StatusBarManager.WINDOW_STATE_SHOWING import android.app.StatusBarManager.WINDOW_STATUS_BAR import android.graphics.Insets +import android.hardware.display.DisplayManagerGlobal import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags +import android.view.Display +import android.view.DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS +import android.view.DisplayInfo import android.view.InputDevice import android.view.LayoutInflater import android.view.MotionEvent @@ -35,6 +39,7 @@ import androidx.test.filters.SmallTest import androidx.test.platform.app.InstrumentationRegistry import com.android.systemui.Flags as AconfigFlags import com.android.systemui.SysuiTestCase +import com.android.systemui.SysuiTestableContext import com.android.systemui.battery.BatteryMeterView import com.android.systemui.flags.FeatureFlags import com.android.systemui.flags.Flags @@ -45,7 +50,6 @@ import com.android.systemui.shade.ShadeControllerImpl import com.android.systemui.shade.ShadeLogger import com.android.systemui.shade.ShadeViewController import com.android.systemui.shade.StatusBarLongPressGestureDetector -import com.android.systemui.shade.data.repository.fakeShadeDisplaysRepository import com.android.systemui.shade.display.StatusBarTouchShadeDisplayPolicy import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor import com.android.systemui.statusbar.CommandQueue @@ -78,7 +82,6 @@ import org.mockito.Mockito.spy import org.mockito.Mockito.verify import org.mockito.Mockito.`when` import org.mockito.MockitoAnnotations -import org.mockito.kotlin.verifyNoMoreInteractions @SmallTest @RunWith(AndroidJUnit4::class) @@ -88,7 +91,6 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() { private val statusBarContentInsetsProvider = statusBarContentInsetsProviderStore.defaultDisplay private val fakeDarkIconDispatcher = kosmos.fakeDarkIconDispatcher - private val fakeShadeDisplaysRepository = kosmos.fakeShadeDisplaysRepository @Mock private lateinit var shadeViewController: ShadeViewController @Mock private lateinit var panelExpansionInteractor: PanelExpansionInteractor @Mock private lateinit var featureFlags: FeatureFlags @@ -111,6 +113,8 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() { private lateinit var view: PhoneStatusBarView private lateinit var controller: PhoneStatusBarViewController + private lateinit var viewForSecondaryDisplay: PhoneStatusBarView + private val clockView: Clock get() = view.requireViewById(R.id.clock) @@ -138,6 +142,26 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() { as PhoneStatusBarView controller = createAndInitController(view) } + + val contextForSecondaryDisplay = + SysuiTestableContext( + mContext.createDisplayContext( + Display( + DisplayManagerGlobal.getInstance(), + SECONDARY_DISPLAY_ID, + DisplayInfo(), + DEFAULT_DISPLAY_ADJUSTMENTS, + ) + ) + ) + + InstrumentationRegistry.getInstrumentation().runOnMainSync { + val parent = FrameLayout(contextForSecondaryDisplay) // add parent to keep layout params + viewForSecondaryDisplay = + LayoutInflater.from(contextForSecondaryDisplay) + .inflate(R.layout.status_bar, parent, false) as PhoneStatusBarView + createAndInitController(viewForSecondaryDisplay) + } } @Test @@ -264,10 +288,9 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() { @Test @DisableFlags(AconfigFlags.FLAG_STATUS_BAR_CONNECTED_DISPLAYS) - fun handleTouchEventFromStatusBar_statusBarConnectedDisplaysDisabled_viewReceivesEvent() { + fun handleTouchEventFromStatusBar_touchOnPrimaryDisplay_statusBarConnectedDisplaysDisabled_shadeReceivesEvent() { `when`(centralSurfacesImpl.commandQueuePanelsEnabled).thenReturn(true) `when`(shadeViewController.isViewEnabled).thenReturn(true) - fakeShadeDisplaysRepository.setDisplayId(SECONDARY_DISPLAY_ID) val event = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 2f, 0) view.onTouchEvent(event) @@ -280,10 +303,9 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() { AconfigFlags.FLAG_STATUS_BAR_CONNECTED_DISPLAYS, AconfigFlags.FLAG_SHADE_WINDOW_GOES_AROUND, ) - fun handleTouchEventFromStatusBar_statusBarConnectedDisplaysEnabled_shadeWindowGoesAroundEnabled_viewReceivesEvent() { + fun handleTouchEventFromStatusBar_touchOnPrimaryDisplay_statusBarConnectedDisplaysEnabled_shadeWindowGoesAroundEnabled_shadeReceivesEvent() { `when`(centralSurfacesImpl.commandQueuePanelsEnabled).thenReturn(true) `when`(shadeViewController.isViewEnabled).thenReturn(true) - fakeShadeDisplaysRepository.setDisplayId(SECONDARY_DISPLAY_ID) val event = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 2f, 0) view.onTouchEvent(event) @@ -294,10 +316,9 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() { @Test @EnableFlags(AconfigFlags.FLAG_STATUS_BAR_CONNECTED_DISPLAYS) @DisableFlags(AconfigFlags.FLAG_SHADE_WINDOW_GOES_AROUND) - fun handleTouchEventFromStatusBar_touchOnShadeDisplay_statusBarConnectedDisplaysEnabled_shadeWindowGoesAroundDisabled_viewReceivesEvent() { + fun handleTouchEventFromStatusBar_touchOnPrimaryDisplay_statusBarConnectedDisplaysEnabled_shadeWindowGoesAroundDisabled_shadeReceivesEvent() { `when`(centralSurfacesImpl.commandQueuePanelsEnabled).thenReturn(true) `when`(shadeViewController.isViewEnabled).thenReturn(true) - fakeShadeDisplaysRepository.setDisplayId(DISPLAY_ID) val event = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 2f, 0) view.onTouchEvent(event) @@ -306,18 +327,43 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() { } @Test + @DisableFlags(AconfigFlags.FLAG_STATUS_BAR_CONNECTED_DISPLAYS) + fun handleTouchEventFromStatusBar_touchOnSecondaryDisplay_statusBarConnectedDisplaysDisabled_shadeReceivesEvent() { + `when`(centralSurfacesImpl.commandQueuePanelsEnabled).thenReturn(true) + `when`(shadeViewController.isViewEnabled).thenReturn(true) + val event = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 2f, 0) + + viewForSecondaryDisplay.onTouchEvent(event) + + verify(shadeViewController).handleExternalTouch(event) + } + + @Test + @EnableFlags( + AconfigFlags.FLAG_STATUS_BAR_CONNECTED_DISPLAYS, + AconfigFlags.FLAG_SHADE_WINDOW_GOES_AROUND, + ) + fun handleTouchEventFromStatusBar_touchOnSecondaryDisplay_statusBarConnectedDisplaysEnabled_shadeWindowGoesAroundEnabled_shadeReceivesEvent() { + `when`(centralSurfacesImpl.commandQueuePanelsEnabled).thenReturn(true) + `when`(shadeViewController.isViewEnabled).thenReturn(true) + val event = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 2f, 0) + + viewForSecondaryDisplay.onTouchEvent(event) + + verify(shadeViewController).handleExternalTouch(event) + } + + @Test @EnableFlags(AconfigFlags.FLAG_STATUS_BAR_CONNECTED_DISPLAYS) @DisableFlags(AconfigFlags.FLAG_SHADE_WINDOW_GOES_AROUND) - fun handleTouchEventFromStatusBar_touchNotOnShadeDisplay_statusBarConnectedDisplaysEnabled_shadeWindowGoesAroundDisabled_viewDoesNotReceiveEvent() { + fun handleTouchEventFromStatusBar_touchOnSecondaryDisplay_statusBarConnectedDisplaysEnabled_shadeWindowGoesAroundDisabled_shadeDoesNotReceiveEvent() { `when`(centralSurfacesImpl.commandQueuePanelsEnabled).thenReturn(true) `when`(shadeViewController.isViewEnabled).thenReturn(true) - fakeShadeDisplaysRepository.setDisplayId(SECONDARY_DISPLAY_ID) val event = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 2f, 0) - view.onTouchEvent(event) + viewForSecondaryDisplay.onTouchEvent(event) - verify(shadeViewController).isViewEnabled - verifyNoMoreInteractions(shadeViewController) + verify(shadeViewController, never()).handleExternalTouch(event) } @Test @@ -493,7 +539,6 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() { fakeDarkIconDispatcher, statusBarContentInsetsProviderStore, Lazy { statusBarTouchShadeDisplayPolicy }, - fakeShadeDisplaysRepository, ) .create(view) .also { it.init() } |