Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenUserActionsViewModelTest.kt +13 −15 Original line number Diff line number Diff line Loading @@ -32,12 +32,11 @@ import com.android.systemui.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository import com.android.systemui.authentication.shared.model.AuthenticationMethodModel import com.android.systemui.communal.domain.interactor.communalInteractor import com.android.systemui.communal.domain.interactor.setCommunalAvailable import com.android.systemui.coroutines.collectLastValue import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepository import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.keyguard.data.repository.keyguardOcclusionRepository import com.android.systemui.kosmos.testScope import com.android.systemui.lifecycle.activateIn import com.android.systemui.power.data.repository.fakePowerRepository Loading @@ -48,7 +47,6 @@ import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.TransitionKeys import com.android.systemui.scene.ui.viewmodel.SceneContainerEdge import com.android.systemui.shade.data.repository.shadeRepository import com.android.systemui.shade.domain.interactor.shadeInteractor import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.math.pow Loading @@ -69,12 +67,13 @@ import platform.test.runner.parameterized.Parameters class LockscreenUserActionsViewModelTest : SysuiTestCase() { companion object { private const val parameterCount = 6 private const val parameterCount = 7 @Parameters( name = "canSwipeToEnter={0}, downWithTwoPointers={1}, downFromEdge={2}," + " isSingleShade={3}, isCommunalAvailable={4}, isShadeTouchable={5}" " isSingleShade={3}, isCommunalAvailable={4}, isShadeTouchable={5}," + " isOccluded={6}" ) @JvmStatic fun combinations() = buildList { Loading @@ -87,6 +86,7 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { /* isSingleShade= */ combination and 8 != 0, /* isCommunalAvailable= */ combination and 16 != 0, /* isShadeTouchable= */ combination and 32 != 0, /* isOccluded= */ combination and 64 != 0, ) .also { check(it.size == parameterCount) } ) Loading Loading @@ -116,10 +116,12 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { downFromEdge: Boolean, isNarrowScreen: Boolean, isShadeTouchable: Boolean, isOccluded: Boolean, ): SceneKey? { return when { !isShadeTouchable -> null downFromEdge && isNarrowScreen -> Scenes.QuickSettings downFromEdge && isNarrowScreen && !isOccluded -> Scenes.QuickSettings downFromEdge && isNarrowScreen && isOccluded -> null else -> Scenes.Shade } } Loading Loading @@ -168,8 +170,9 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { @JvmField @Parameter(3) var isNarrowScreen: Boolean = true @JvmField @Parameter(4) var isCommunalAvailable: Boolean = false @JvmField @Parameter(5) var isShadeTouchable: Boolean = false @JvmField @Parameter(6) var isOccluded: Boolean = false private val underTest by lazy { createLockscreenSceneViewModel() } private val underTest by lazy { kosmos.lockscreenUserActionsViewModel } @Test @EnableFlags(Flags.FLAG_COMMUNAL_HUB) Loading @@ -196,6 +199,7 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { WakefulnessState.ASLEEP } ) kosmos.keyguardOcclusionRepository.setShowWhenLockedActivityInfo(onTop = isOccluded) val userActions by collectLastValue(underTest.actions) val downDestination = Loading @@ -217,6 +221,7 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { downFromEdge = downFromEdge, isNarrowScreen = isNarrowScreen, isShadeTouchable = isShadeTouchable, isOccluded = isOccluded, ) ) Loading Loading @@ -285,6 +290,7 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { WakefulnessState.ASLEEP } ) kosmos.keyguardOcclusionRepository.setShowWhenLockedActivityInfo(onTop = isOccluded) val userActions by collectLastValue(underTest.actions) Loading Loading @@ -354,12 +360,4 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { ) ) } private fun createLockscreenSceneViewModel(): LockscreenUserActionsViewModel { return LockscreenUserActionsViewModel( deviceEntryInteractor = kosmos.deviceEntryInteractor, communalInteractor = kosmos.communalInteractor, shadeInteractor = kosmos.shadeInteractor, ) } } packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenUserActionsViewModel.kt +6 −2 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import com.android.compose.animation.scene.UserAction import com.android.compose.animation.scene.UserActionResult import com.android.systemui.communal.domain.interactor.CommunalInteractor import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor import com.android.systemui.scene.domain.interactor.SceneContainerOcclusionInteractor import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.ui.viewmodel.UserActionsViewModel import com.android.systemui.shade.domain.interactor.ShadeInteractor Loading @@ -44,6 +45,7 @@ constructor( private val deviceEntryInteractor: DeviceEntryInteractor, private val communalInteractor: CommunalInteractor, private val shadeInteractor: ShadeInteractor, private val occlusionInteractor: SceneContainerOcclusionInteractor, ) : UserActionsViewModel() { override suspend fun hydrateActions(setActions: (Map<UserAction, UserActionResult>) -> Unit) { Loading @@ -57,7 +59,8 @@ constructor( deviceEntryInteractor.isUnlocked, communalInteractor.isCommunalAvailable, shadeInteractor.shadeMode, ) { isDeviceUnlocked, isCommunalAvailable, shadeMode -> occlusionInteractor.isOccludingActivityShown, ) { isDeviceUnlocked, isCommunalAvailable, shadeMode, isOccluded -> buildList { if (isCommunalAvailable) { add(Swipe.Start to Scenes.Communal) Loading @@ -67,7 +70,8 @@ constructor( addAll( when (shadeMode) { ShadeMode.Single -> singleShadeActions() ShadeMode.Single -> singleShadeActions(isDownFromTopEdgeEnabled = !isOccluded) ShadeMode.Split -> splitShadeActions() ShadeMode.Dual -> dualShadeActions() } Loading packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeUserActions.kt +19 −15 Original line number Diff line number Diff line Loading @@ -27,24 +27,28 @@ import com.android.systemui.scene.ui.viewmodel.SceneContainerEdge /** Returns collection of [UserAction] to [UserActionResult] pairs for opening the single shade. */ fun singleShadeActions( requireTwoPointersForTopEdgeForQs: Boolean = false isDownFromTopEdgeEnabled: Boolean = true, requireTwoPointersForTopEdgeForQs: Boolean = false, ): Array<Pair<UserAction, UserActionResult>> { val shadeUserActionResult = UserActionResult(Scenes.Shade, isIrreversible = true) val qsSceneUserActionResult = UserActionResult(Scenes.QuickSettings, isIrreversible = true) return arrayOf( return buildList { // Swiping down, not from the edge, always goes to shade. Swipe.Down to shadeUserActionResult, Swipe.Down(pointerCount = 2) to shadeUserActionResult, // Swiping down from the top edge. add(Swipe.Down to shadeUserActionResult) add(Swipe.Down(pointerCount = 2) to shadeUserActionResult) if (isDownFromTopEdgeEnabled) { add( swipeDownFromTop(pointerCount = 1) to if (requireTwoPointersForTopEdgeForQs) { shadeUserActionResult } else { qsSceneUserActionResult }, swipeDownFromTop(pointerCount = 2) to qsSceneUserActionResult, } ) add(swipeDownFromTop(pointerCount = 2) to qsSceneUserActionResult) } } .toTypedArray() } /** Returns collection of [UserAction] to [UserActionResult] pairs for opening the split shade. */ Loading packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenUserActionsViewModelKosmos.kt +2 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import com.android.systemui.communal.domain.interactor.communalInteractor import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.Kosmos.Fixture import com.android.systemui.scene.domain.interactor.sceneContainerOcclusionInteractor import com.android.systemui.shade.domain.interactor.shadeInteractor val Kosmos.lockscreenUserActionsViewModel by Fixture { Loading @@ -27,5 +28,6 @@ val Kosmos.lockscreenUserActionsViewModel by Fixture { deviceEntryInteractor = deviceEntryInteractor, communalInteractor = communalInteractor, shadeInteractor = shadeInteractor, occlusionInteractor = sceneContainerOcclusionInteractor, ) } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenUserActionsViewModelTest.kt +13 −15 Original line number Diff line number Diff line Loading @@ -32,12 +32,11 @@ import com.android.systemui.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository import com.android.systemui.authentication.shared.model.AuthenticationMethodModel import com.android.systemui.communal.domain.interactor.communalInteractor import com.android.systemui.communal.domain.interactor.setCommunalAvailable import com.android.systemui.coroutines.collectLastValue import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepository import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.keyguard.data.repository.keyguardOcclusionRepository import com.android.systemui.kosmos.testScope import com.android.systemui.lifecycle.activateIn import com.android.systemui.power.data.repository.fakePowerRepository Loading @@ -48,7 +47,6 @@ import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.TransitionKeys import com.android.systemui.scene.ui.viewmodel.SceneContainerEdge import com.android.systemui.shade.data.repository.shadeRepository import com.android.systemui.shade.domain.interactor.shadeInteractor import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.math.pow Loading @@ -69,12 +67,13 @@ import platform.test.runner.parameterized.Parameters class LockscreenUserActionsViewModelTest : SysuiTestCase() { companion object { private const val parameterCount = 6 private const val parameterCount = 7 @Parameters( name = "canSwipeToEnter={0}, downWithTwoPointers={1}, downFromEdge={2}," + " isSingleShade={3}, isCommunalAvailable={4}, isShadeTouchable={5}" " isSingleShade={3}, isCommunalAvailable={4}, isShadeTouchable={5}," + " isOccluded={6}" ) @JvmStatic fun combinations() = buildList { Loading @@ -87,6 +86,7 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { /* isSingleShade= */ combination and 8 != 0, /* isCommunalAvailable= */ combination and 16 != 0, /* isShadeTouchable= */ combination and 32 != 0, /* isOccluded= */ combination and 64 != 0, ) .also { check(it.size == parameterCount) } ) Loading Loading @@ -116,10 +116,12 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { downFromEdge: Boolean, isNarrowScreen: Boolean, isShadeTouchable: Boolean, isOccluded: Boolean, ): SceneKey? { return when { !isShadeTouchable -> null downFromEdge && isNarrowScreen -> Scenes.QuickSettings downFromEdge && isNarrowScreen && !isOccluded -> Scenes.QuickSettings downFromEdge && isNarrowScreen && isOccluded -> null else -> Scenes.Shade } } Loading Loading @@ -168,8 +170,9 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { @JvmField @Parameter(3) var isNarrowScreen: Boolean = true @JvmField @Parameter(4) var isCommunalAvailable: Boolean = false @JvmField @Parameter(5) var isShadeTouchable: Boolean = false @JvmField @Parameter(6) var isOccluded: Boolean = false private val underTest by lazy { createLockscreenSceneViewModel() } private val underTest by lazy { kosmos.lockscreenUserActionsViewModel } @Test @EnableFlags(Flags.FLAG_COMMUNAL_HUB) Loading @@ -196,6 +199,7 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { WakefulnessState.ASLEEP } ) kosmos.keyguardOcclusionRepository.setShowWhenLockedActivityInfo(onTop = isOccluded) val userActions by collectLastValue(underTest.actions) val downDestination = Loading @@ -217,6 +221,7 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { downFromEdge = downFromEdge, isNarrowScreen = isNarrowScreen, isShadeTouchable = isShadeTouchable, isOccluded = isOccluded, ) ) Loading Loading @@ -285,6 +290,7 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { WakefulnessState.ASLEEP } ) kosmos.keyguardOcclusionRepository.setShowWhenLockedActivityInfo(onTop = isOccluded) val userActions by collectLastValue(underTest.actions) Loading Loading @@ -354,12 +360,4 @@ class LockscreenUserActionsViewModelTest : SysuiTestCase() { ) ) } private fun createLockscreenSceneViewModel(): LockscreenUserActionsViewModel { return LockscreenUserActionsViewModel( deviceEntryInteractor = kosmos.deviceEntryInteractor, communalInteractor = kosmos.communalInteractor, shadeInteractor = kosmos.shadeInteractor, ) } }
packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenUserActionsViewModel.kt +6 −2 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import com.android.compose.animation.scene.UserAction import com.android.compose.animation.scene.UserActionResult import com.android.systemui.communal.domain.interactor.CommunalInteractor import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor import com.android.systemui.scene.domain.interactor.SceneContainerOcclusionInteractor import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.ui.viewmodel.UserActionsViewModel import com.android.systemui.shade.domain.interactor.ShadeInteractor Loading @@ -44,6 +45,7 @@ constructor( private val deviceEntryInteractor: DeviceEntryInteractor, private val communalInteractor: CommunalInteractor, private val shadeInteractor: ShadeInteractor, private val occlusionInteractor: SceneContainerOcclusionInteractor, ) : UserActionsViewModel() { override suspend fun hydrateActions(setActions: (Map<UserAction, UserActionResult>) -> Unit) { Loading @@ -57,7 +59,8 @@ constructor( deviceEntryInteractor.isUnlocked, communalInteractor.isCommunalAvailable, shadeInteractor.shadeMode, ) { isDeviceUnlocked, isCommunalAvailable, shadeMode -> occlusionInteractor.isOccludingActivityShown, ) { isDeviceUnlocked, isCommunalAvailable, shadeMode, isOccluded -> buildList { if (isCommunalAvailable) { add(Swipe.Start to Scenes.Communal) Loading @@ -67,7 +70,8 @@ constructor( addAll( when (shadeMode) { ShadeMode.Single -> singleShadeActions() ShadeMode.Single -> singleShadeActions(isDownFromTopEdgeEnabled = !isOccluded) ShadeMode.Split -> splitShadeActions() ShadeMode.Dual -> dualShadeActions() } Loading
packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeUserActions.kt +19 −15 Original line number Diff line number Diff line Loading @@ -27,24 +27,28 @@ import com.android.systemui.scene.ui.viewmodel.SceneContainerEdge /** Returns collection of [UserAction] to [UserActionResult] pairs for opening the single shade. */ fun singleShadeActions( requireTwoPointersForTopEdgeForQs: Boolean = false isDownFromTopEdgeEnabled: Boolean = true, requireTwoPointersForTopEdgeForQs: Boolean = false, ): Array<Pair<UserAction, UserActionResult>> { val shadeUserActionResult = UserActionResult(Scenes.Shade, isIrreversible = true) val qsSceneUserActionResult = UserActionResult(Scenes.QuickSettings, isIrreversible = true) return arrayOf( return buildList { // Swiping down, not from the edge, always goes to shade. Swipe.Down to shadeUserActionResult, Swipe.Down(pointerCount = 2) to shadeUserActionResult, // Swiping down from the top edge. add(Swipe.Down to shadeUserActionResult) add(Swipe.Down(pointerCount = 2) to shadeUserActionResult) if (isDownFromTopEdgeEnabled) { add( swipeDownFromTop(pointerCount = 1) to if (requireTwoPointersForTopEdgeForQs) { shadeUserActionResult } else { qsSceneUserActionResult }, swipeDownFromTop(pointerCount = 2) to qsSceneUserActionResult, } ) add(swipeDownFromTop(pointerCount = 2) to qsSceneUserActionResult) } } .toTypedArray() } /** Returns collection of [UserAction] to [UserActionResult] pairs for opening the split shade. */ Loading
packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenUserActionsViewModelKosmos.kt +2 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import com.android.systemui.communal.domain.interactor.communalInteractor import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.Kosmos.Fixture import com.android.systemui.scene.domain.interactor.sceneContainerOcclusionInteractor import com.android.systemui.shade.domain.interactor.shadeInteractor val Kosmos.lockscreenUserActionsViewModel by Fixture { Loading @@ -27,5 +28,6 @@ val Kosmos.lockscreenUserActionsViewModel by Fixture { deviceEntryInteractor = deviceEntryInteractor, communalInteractor = communalInteractor, shadeInteractor = shadeInteractor, occlusionInteractor = sceneContainerOcclusionInteractor, ) }