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

Commit 2dae4c70 authored by helen cheuk's avatar helen cheuk
Browse files

[Action Corner] Disable action corner in lockscreen

When lockscreen is visible, action corner should not be active.

Bug: 422725271
Test: ActionCornerInteractorTest
Flag: com.android.systemui.shared.cursor_hot_corner
Change-Id: I5baa259dd133a09d11b5d24ad9fdfb6da6fc8b20
parent f1877fb1
Loading
Loading
Loading
Loading
+44 −15
Original line number Diff line number Diff line
@@ -35,6 +35,9 @@ import com.android.systemui.actioncorner.data.model.ActionCornerRegion.BOTTOM_RI
import com.android.systemui.actioncorner.data.model.ActionCornerState.ActiveActionCorner
import com.android.systemui.actioncorner.data.repository.ActionCornerSettingRepository
import com.android.systemui.actioncorner.data.repository.FakeActionCornerRepository
import com.android.systemui.keyguard.domain.interactor.windowManagerLockscreenVisibilityInteractor
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.TransitionStep
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
import com.android.systemui.kosmos.runTest
@@ -42,6 +45,9 @@ import com.android.systemui.kosmos.testDispatcher
import com.android.systemui.kosmos.testScope
import com.android.systemui.kosmos.useUnconfinedTestDispatcher
import com.android.systemui.lifecycle.activateIn
import com.android.systemui.scene.data.repository.Idle
import com.android.systemui.scene.data.repository.setTransition
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shared.system.actioncorner.ActionCornerConstants.HOME
import com.android.systemui.shared.system.actioncorner.ActionCornerConstants.OVERVIEW
import com.android.systemui.statusbar.CommandQueue
@@ -75,6 +81,7 @@ class ActionCornerInteractorTest : SysuiTestCase() {
            launcherProxyService,
            actionCornerSettingRepository,
            fakeUserSetupRepository,
            windowManagerLockscreenVisibilityInteractor,
            commandQueue,
        )
    }
@@ -87,7 +94,7 @@ class ActionCornerInteractorTest : SysuiTestCase() {

    @Test
    fun bottomLeftCornerActivated_overviewActionConfigured_notifyLauncherOfOverviewAction() =
        kosmos.runTest {
        unlockScreenAndRunTest {
            settingsRepository.setInt(
                ACTION_CORNER_BOTTOM_LEFT_ACTION,
                ACTION_CORNER_ACTION_OVERVIEW,
@@ -98,7 +105,7 @@ class ActionCornerInteractorTest : SysuiTestCase() {

    @Test
    fun bottomRightCornerActivated_homeActionConfigured_notifyLauncherOfHomeAction() =
        kosmos.runTest {
        unlockScreenAndRunTest {
            settingsRepository.setInt(ACTION_CORNER_BOTTOM_RIGHT_ACTION, ACTION_CORNER_ACTION_HOME)
            actionCornerRepository.addState(ActiveActionCorner(BOTTOM_RIGHT, DEFAULT_DISPLAY))
            verify(launcherProxyService).onActionCornerActivated(HOME, DEFAULT_DISPLAY)
@@ -106,7 +113,7 @@ class ActionCornerInteractorTest : SysuiTestCase() {

    @Test
    fun topLeftCornerActivated_notificationsActionConfigured_toggleNotificationShade() =
        kosmos.runTest {
        unlockScreenAndRunTest {
            settingsRepository.setInt(
                ACTION_CORNER_TOP_LEFT_ACTION,
                ACTION_CORNER_ACTION_NOTIFICATIONS,
@@ -120,8 +127,7 @@ class ActionCornerInteractorTest : SysuiTestCase() {
        }

    @Test
    fun topRightCornerActivated_qsActionConfigured_toggleQsPanel() =
        kosmos.runTest {
    fun topRightCornerActivated_qsActionConfigured_toggleQsPanel() = unlockScreenAndRunTest {
        settingsRepository.setInt(
            ACTION_CORNER_TOP_RIGHT_ACTION,
            ACTION_CORNER_ACTION_QUICK_SETTINGS,
@@ -136,7 +142,7 @@ class ActionCornerInteractorTest : SysuiTestCase() {

    @Test
    fun userNotSetUp_overviewActionConfigured_actionCornerActivated_actionNotTriggered() =
        kosmos.runTest {
        unlockScreenAndRunTest {
            settingsRepository.setInt(
                ACTION_CORNER_BOTTOM_LEFT_ACTION,
                ACTION_CORNER_ACTION_OVERVIEW,
@@ -145,4 +151,27 @@ class ActionCornerInteractorTest : SysuiTestCase() {
            actionCornerRepository.addState(ActiveActionCorner(BOTTOM_LEFT, DEFAULT_DISPLAY))
            verify(launcherProxyService, never()).onActionCornerActivated(OVERVIEW, DEFAULT_DISPLAY)
        }

    @Test
    fun lockscreenVisible_overviewActionConfigured_actionCornerActivated_actionNotTriggered() =
        kosmos.runTest {
            // We are in lockscreen by default
            settingsRepository.setInt(
                ACTION_CORNER_BOTTOM_LEFT_ACTION,
                ACTION_CORNER_ACTION_OVERVIEW,
            )

            actionCornerRepository.addState(ActiveActionCorner(BOTTOM_LEFT, DEFAULT_DISPLAY))
            verify(launcherProxyService, never()).onActionCornerActivated(OVERVIEW, DEFAULT_DISPLAY)
        }

    private fun unlockScreenAndRunTest(testBody: suspend Kosmos.() -> Unit) =
        kosmos.runTest {
            setTransition(
                sceneTransition = Idle(Scenes.Gone),
                stateTransition =
                    TransitionStep(from = KeyguardState.LOCKSCREEN, to = KeyguardState.GONE),
            )
            testBody()
        }
}
+12 −2
Original line number Diff line number Diff line
@@ -32,12 +32,15 @@ import com.android.systemui.actioncorner.data.model.ActionType.QUICK_SETTINGS
import com.android.systemui.actioncorner.data.repository.ActionCornerRepository
import com.android.systemui.actioncorner.data.repository.ActionCornerSettingRepository
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.domain.interactor.WindowManagerLockscreenVisibilityInteractor
import com.android.systemui.lifecycle.ExclusiveActivatable
import com.android.systemui.shared.system.actioncorner.ActionCornerConstants
import com.android.systemui.statusbar.CommandQueue
import com.android.systemui.statusbar.policy.data.repository.UserSetupRepository
import javax.inject.Inject
import kotlinx.coroutines.awaitCancellation
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.flow.filterIsInstance
import kotlinx.coroutines.flow.flatMapLatest
@@ -50,13 +53,20 @@ constructor(
    private val launcherProxyService: LauncherProxyService,
    private val actionCornerSettingRepository: ActionCornerSettingRepository,
    private val userSetupRepository: UserSetupRepository,
    private val lockscreenVisibilityInteractor: WindowManagerLockscreenVisibilityInteractor,
    private val commandQueue: CommandQueue,
) : ExclusiveActivatable() {

    override suspend fun onActivated(): Nothing {
        userSetupRepository.isUserSetUp
            .flatMapLatest {
                if (it) {
            .combine(lockscreenVisibilityInteractor.lockscreenVisibility) {
                isUserSetUp,
                isLockscreenVisible ->
                isUserSetUp && !isLockscreenVisible
            }
            .distinctUntilChanged()
            .flatMapLatest { shouldMonitorActionCorner ->
                if (shouldMonitorActionCorner) {
                    repository.actionCornerState.filterIsInstance<ActiveActionCorner>()
                } else {
                    emptyFlow()