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

Commit 40c5cbaa authored by Helen Cheuk's avatar Helen Cheuk Committed by Android (Google) Code Review
Browse files

Merge "[Action Corner] Add lockscreen action for action corner" into main

parents efd1f729 4d40d737
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.actioncorner.data.repository

import android.provider.Settings.Secure.ACTION_CORNER_ACTION_HOME
import android.provider.Settings.Secure.ACTION_CORNER_ACTION_LOCKSCREEN
import android.provider.Settings.Secure.ACTION_CORNER_ACTION_NOTIFICATIONS
import android.provider.Settings.Secure.ACTION_CORNER_ACTION_OVERVIEW
import android.provider.Settings.Secure.ACTION_CORNER_ACTION_QUICK_SETTINGS
@@ -28,6 +29,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.actioncorner.data.model.ActionType.HOME
import com.android.systemui.actioncorner.data.model.ActionType.LOCKSCREEN
import com.android.systemui.actioncorner.data.model.ActionType.NONE
import com.android.systemui.actioncorner.data.model.ActionType.NOTIFICATIONS
import com.android.systemui.actioncorner.data.model.ActionType.OVERVIEW
@@ -116,4 +118,15 @@ class ActionCornerSettingRepositoryTest : SysuiTestCase() {
            val model by collectLastValue(underTest.bottomRightCornerAction)
            assertThat(model).isEqualTo(HOME)
        }

    @Test
    fun testLockscreenActionOnBottomRightCorner() =
        kosmos.runTest {
            settingsRepository.setInt(
                ACTION_CORNER_BOTTOM_RIGHT_ACTION,
                ACTION_CORNER_ACTION_LOCKSCREEN,
            )
            val model by collectLastValue(underTest.bottomRightCornerAction)
            assertThat(model).isEqualTo(LOCKSCREEN)
        }
}
+15 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.actioncorner.domain.interactor

import android.provider.Settings.Secure.ACTION_CORNER_ACTION_HOME
import android.provider.Settings.Secure.ACTION_CORNER_ACTION_LOCKSCREEN
import android.provider.Settings.Secure.ACTION_CORNER_ACTION_NOTIFICATIONS
import android.provider.Settings.Secure.ACTION_CORNER_ACTION_OVERVIEW
import android.provider.Settings.Secure.ACTION_CORNER_ACTION_QUICK_SETTINGS
@@ -25,6 +26,7 @@ import android.provider.Settings.Secure.ACTION_CORNER_BOTTOM_RIGHT_ACTION
import android.provider.Settings.Secure.ACTION_CORNER_TOP_LEFT_ACTION
import android.provider.Settings.Secure.ACTION_CORNER_TOP_RIGHT_ACTION
import android.view.Display.DEFAULT_DISPLAY
import android.view.IWindowManager
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.LauncherProxyService
@@ -58,6 +60,7 @@ import com.android.systemui.util.settings.data.repository.userAwareSecureSetting
import kotlin.test.Test
import org.junit.Before
import org.junit.runner.RunWith
import org.mockito.kotlin.eq
import org.mockito.kotlin.mock
import org.mockito.kotlin.never
import org.mockito.kotlin.times
@@ -75,6 +78,7 @@ class ActionCornerInteractorTest : SysuiTestCase() {
    }

    private val Kosmos.launcherProxyService by Fixture { mock<LauncherProxyService>() }
    private val Kosmos.windowManager by Fixture { mock<IWindowManager>() }
    private val Kosmos.commandQueue by Fixture { mock<CommandQueue>() }
    private val Kosmos.fakePointerRepository by Fixture { FakePointerDeviceRepository() }

@@ -87,6 +91,7 @@ class ActionCornerInteractorTest : SysuiTestCase() {
            windowManagerLockscreenVisibilityInteractor,
            fakeUserSetupRepository,
            commandQueue,
            windowManager,
        )
    }

@@ -145,6 +150,16 @@ class ActionCornerInteractorTest : SysuiTestCase() {
        verify(commandQueue).toggleQuickSettingsPanel()
    }

    @Test
    fun actionCornerActivated_lockscreenActionConfigured_lockScreen() = unlockScreenAndRunTest {
        settingsRepository.setInt(
            ACTION_CORNER_BOTTOM_RIGHT_ACTION,
            ACTION_CORNER_ACTION_LOCKSCREEN,
        )
        actionCornerRepository.addState(ActiveActionCorner(BOTTOM_RIGHT, DEFAULT_DISPLAY))
        verify(windowManager).lockNow(eq(null))
    }

    @Test
    fun userNotSetUp_overviewActionConfigured_actionCornerActivated_actionNotTriggered() =
        unlockScreenAndRunTest {
+1 −0
Original line number Diff line number Diff line
@@ -55,4 +55,5 @@ enum class ActionType {
    OVERVIEW,
    NOTIFICATIONS,
    QUICK_SETTINGS,
    LOCKSCREEN,
}
+3 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.actioncorner.data.repository

import android.provider.Settings.Secure.ACTION_CORNER_ACTION_HOME
import android.provider.Settings.Secure.ACTION_CORNER_ACTION_LOCKSCREEN
import android.provider.Settings.Secure.ACTION_CORNER_ACTION_NOTIFICATIONS
import android.provider.Settings.Secure.ACTION_CORNER_ACTION_OVERVIEW
import android.provider.Settings.Secure.ACTION_CORNER_ACTION_QUICK_SETTINGS
@@ -27,6 +28,7 @@ import android.provider.Settings.Secure.ACTION_CORNER_TOP_RIGHT_ACTION
import android.provider.Settings.Secure.ActionCornerActionType
import com.android.systemui.actioncorner.data.model.ActionType
import com.android.systemui.actioncorner.data.model.ActionType.HOME
import com.android.systemui.actioncorner.data.model.ActionType.LOCKSCREEN
import com.android.systemui.actioncorner.data.model.ActionType.NONE
import com.android.systemui.actioncorner.data.model.ActionType.NOTIFICATIONS
import com.android.systemui.actioncorner.data.model.ActionType.OVERVIEW
@@ -94,6 +96,7 @@ constructor(
            ACTION_CORNER_ACTION_OVERVIEW -> OVERVIEW
            ACTION_CORNER_ACTION_NOTIFICATIONS -> NOTIFICATIONS
            ACTION_CORNER_ACTION_QUICK_SETTINGS -> QUICK_SETTINGS
            ACTION_CORNER_ACTION_LOCKSCREEN -> LOCKSCREEN
            else -> NONE
        }
}
+4 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.actioncorner.domain.interactor

import android.view.IWindowManager
import com.android.systemui.LauncherProxyService
import com.android.systemui.actioncorner.data.model.ActionCornerRegion
import com.android.systemui.actioncorner.data.model.ActionCornerRegion.BOTTOM_LEFT
@@ -25,6 +26,7 @@ import com.android.systemui.actioncorner.data.model.ActionCornerRegion.TOP_RIGHT
import com.android.systemui.actioncorner.data.model.ActionCornerState.ActiveActionCorner
import com.android.systemui.actioncorner.data.model.ActionType
import com.android.systemui.actioncorner.data.model.ActionType.HOME
import com.android.systemui.actioncorner.data.model.ActionType.LOCKSCREEN
import com.android.systemui.actioncorner.data.model.ActionType.NONE
import com.android.systemui.actioncorner.data.model.ActionType.NOTIFICATIONS
import com.android.systemui.actioncorner.data.model.ActionType.OVERVIEW
@@ -59,6 +61,7 @@ constructor(
    private val lockscreenVisibilityInteractor: WindowManagerLockscreenVisibilityInteractor,
    private val userSetupRepository: UserSetupRepository,
    private val commandQueue: CommandQueue,
    private val windowManager: IWindowManager,
) : ExclusiveActivatable() {

    override suspend fun onActivated(): Nothing {
@@ -101,6 +104,7 @@ constructor(
                        )
                    NOTIFICATIONS -> commandQueue.toggleNotificationsPanel()
                    QUICK_SETTINGS -> commandQueue.toggleQuickSettingsPanel()
                    LOCKSCREEN -> windowManager.lockNow(/* bundle= */ null)
                    NONE -> {}
                }
            }