Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b86d49c authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Make status bar touches should result in shade interaction only if...

Merge "Make status bar touches should result in  shade interaction only if ShadeWindowGoesAround.isEnabled or if touch is on the display which currently hosts the shade." into main
parents fc821225 ba6fb64d
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -39,10 +39,12 @@ 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
import com.android.systemui.shared.animation.UnfoldMoveFromCenterAnimator
import com.android.systemui.statusbar.core.StatusBarConnectedDisplays
import com.android.systemui.statusbar.data.repository.StatusBarContentInsetsProviderStore
import com.android.systemui.statusbar.policy.Clock
import com.android.systemui.statusbar.policy.ConfigurationController
@@ -83,6 +85,7 @@ 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
@@ -296,7 +299,19 @@ private constructor(
                    return true
                }
            }
            return shadeViewController.handleExternalTouch(event)

            // 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.
            return if (
                !StatusBarConnectedDisplays.isEnabled ||
                    ShadeWindowGoesAround.isEnabled ||
                    context.displayId == shadeDisplaysRepository.displayId.value
            ) {
                shadeViewController.handleExternalTouch(event)
            } else {
                false
            }
        }
    }

@@ -352,6 +367,7 @@ 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 =
@@ -380,6 +396,7 @@ private constructor(
                darkIconDispatcher,
                statusBarContentInsetsProviderStore.defaultDisplay,
                lazyStatusBarShadeDisplayPolicy,
                shadeDisplaysRepository,
            )
        }
    }
+64 −1
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ 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
@@ -77,6 +78,7 @@ 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)
@@ -86,6 +88,7 @@ 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
@@ -259,6 +262,64 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() {
        verify(shadeViewController, never()).handleExternalTouch(any())
    }

    @Test
    @DisableFlags(AconfigFlags.FLAG_STATUS_BAR_CONNECTED_DISPLAYS)
    fun handleTouchEventFromStatusBar_statusBarConnectedDisplaysDisabled_viewReceivesEvent() {
        `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)

        verify(shadeViewController).handleExternalTouch(event)
    }

    @Test
    @EnableFlags(
        AconfigFlags.FLAG_STATUS_BAR_CONNECTED_DISPLAYS,
        AconfigFlags.FLAG_SHADE_WINDOW_GOES_AROUND,
    )
    fun handleTouchEventFromStatusBar_statusBarConnectedDisplaysEnabled_shadeWindowGoesAroundEnabled_viewReceivesEvent() {
        `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)

        verify(shadeViewController).handleExternalTouch(event)
    }

    @Test
    @EnableFlags(AconfigFlags.FLAG_STATUS_BAR_CONNECTED_DISPLAYS)
    @DisableFlags(AconfigFlags.FLAG_SHADE_WINDOW_GOES_AROUND)
    fun handleTouchEventFromStatusBar_touchOnShadeDisplay_statusBarConnectedDisplaysEnabled_shadeWindowGoesAroundDisabled_viewReceivesEvent() {
        `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)

        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() {
        `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)

        verify(shadeViewController).isViewEnabled
        verifyNoMoreInteractions(shadeViewController)
    }

    @Test
    @DisableFlags(com.android.systemui.Flags.FLAG_STATUS_BAR_SWIPE_OVER_CHIP)
    fun handleInterceptTouchEventFromStatusBar_shadeReturnsFalse_flagOff_viewReturnsFalse() {
@@ -432,6 +493,7 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() {
                fakeDarkIconDispatcher,
                statusBarContentInsetsProviderStore,
                Lazy { statusBarTouchShadeDisplayPolicy },
                fakeShadeDisplaysRepository,
            )
            .create(view)
            .also { it.init() }
@@ -445,6 +507,7 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() {
    }

    private companion object {
        const val DISPLAY_ID = 1
        const val DISPLAY_ID = 0
        const val SECONDARY_DISPLAY_ID = 2
    }
}