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

Commit 64a34b69 authored by Alejandro Nijamkin's avatar Alejandro Nijamkin
Browse files

[flexiglass] Removes lock button click handling from lockscreen scene.

The lock button, when clicked, doesn't unlock the device or bring up the
bouncer in pre-Flexiglass so it shouldn't do so in Flexiglass.

Bug: 280879610
Test: unit tests updated
Test: manually verified that clicking on the lock icon in the lockscreen
scene does nothing.

Change-Id: Id68b00fba43b1495f50527131011de581cb3db26
parent cafde4f9
Loading
Loading
Loading
Loading
+1 −5
Original line number Original line Diff line number Diff line
@@ -67,7 +67,6 @@ constructor(
        modifier: Modifier,
        modifier: Modifier,
    ) {
    ) {
        LockscreenScene(
        LockscreenScene(
            viewModel = viewModel,
            viewProvider = viewProvider,
            viewProvider = viewProvider,
            modifier = modifier,
            modifier = modifier,
        )
        )
@@ -85,7 +84,6 @@ constructor(


@Composable
@Composable
private fun LockscreenScene(
private fun LockscreenScene(
    viewModel: LockscreenSceneViewModel,
    viewProvider: () -> View,
    viewProvider: () -> View,
    modifier: Modifier = Modifier,
    modifier: Modifier = Modifier,
) {
) {
@@ -98,9 +96,7 @@ private fun LockscreenScene(
            keyguardRootView
            keyguardRootView
        },
        },
        update = { keyguardRootView ->
        update = { keyguardRootView ->
            keyguardRootView.requireViewById<View>(R.id.lock_icon_view).setOnClickListener {
            keyguardRootView.requireViewById<View>(R.id.lock_icon_view)
                viewModel.onLockButtonClicked()
            }
        },
        },
        modifier = modifier,
        modifier = modifier,
    )
    )
+0 −7
Original line number Original line Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.systemui.keyguard.ui.viewmodel
package com.android.systemui.keyguard.ui.viewmodel


import com.android.systemui.authentication.domain.interactor.AuthenticationInteractor
import com.android.systemui.authentication.domain.interactor.AuthenticationInteractor
import com.android.systemui.bouncer.domain.interactor.BouncerInteractor
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.scene.shared.model.SceneKey
import com.android.systemui.scene.shared.model.SceneKey
import javax.inject.Inject
import javax.inject.Inject
@@ -30,7 +29,6 @@ class LockscreenSceneViewModel
@Inject
@Inject
constructor(
constructor(
    authenticationInteractor: AuthenticationInteractor,
    authenticationInteractor: AuthenticationInteractor,
    private val bouncerInteractor: BouncerInteractor,
) {
) {
    /** The key of the scene we should switch to when swiping up. */
    /** The key of the scene we should switch to when swiping up. */
    val upDestinationSceneKey: Flow<SceneKey> =
    val upDestinationSceneKey: Flow<SceneKey> =
@@ -41,9 +39,4 @@ constructor(
                SceneKey.Bouncer
                SceneKey.Bouncer
            }
            }
        }
        }

    /** Notifies that the lock button on the lock screen was clicked. */
    fun onLockButtonClicked() {
        bouncerInteractor.showOrUnlockDevice()
    }
}
}
+0 −34
Original line number Original line Diff line number Diff line
@@ -24,14 +24,11 @@ import com.android.systemui.scene.SceneTestUtils
import com.android.systemui.scene.shared.model.SceneKey
import com.android.systemui.scene.shared.model.SceneKey
import com.android.systemui.scene.shared.model.SceneModel
import com.android.systemui.scene.shared.model.SceneModel
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import kotlinx.coroutines.test.runTest
import org.junit.Test
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
import org.junit.runners.JUnit4


@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
@SmallTest
@RunWith(JUnit4::class)
@RunWith(JUnit4::class)
class LockscreenSceneViewModelTest : SysuiTestCase() {
class LockscreenSceneViewModelTest : SysuiTestCase() {
@@ -47,11 +44,6 @@ class LockscreenSceneViewModelTest : SysuiTestCase() {
    private val underTest =
    private val underTest =
        LockscreenSceneViewModel(
        LockscreenSceneViewModel(
            authenticationInteractor = authenticationInteractor,
            authenticationInteractor = authenticationInteractor,
            bouncerInteractor =
                utils.bouncerInteractor(
                    authenticationInteractor = authenticationInteractor,
                    sceneInteractor = sceneInteractor,
                ),
        )
        )


    @Test
    @Test
@@ -76,30 +68,4 @@ class LockscreenSceneViewModelTest : SysuiTestCase() {


            assertThat(upTransitionSceneKey).isEqualTo(SceneKey.Bouncer)
            assertThat(upTransitionSceneKey).isEqualTo(SceneKey.Bouncer)
        }
        }

    @Test
    fun onLockButtonClicked_deviceLockedSecurely_switchesToBouncer() =
        testScope.runTest {
            val currentScene by collectLastValue(sceneInteractor.desiredScene)
            utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
            utils.authenticationRepository.setUnlocked(false)
            runCurrent()

            underTest.onLockButtonClicked()

            assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
        }

    @Test
    fun onLockButtonClicked_deviceUnlocked_switchesToGone() =
        testScope.runTest {
            val currentScene by collectLastValue(sceneInteractor.desiredScene)
            utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
            utils.authenticationRepository.setUnlocked(true)
            runCurrent()

            underTest.onLockButtonClicked()

            assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Gone))
        }
}
}
+2 −8
Original line number Original line Diff line number Diff line
@@ -118,7 +118,6 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() {
    private val lockscreenSceneViewModel =
    private val lockscreenSceneViewModel =
        LockscreenSceneViewModel(
        LockscreenSceneViewModel(
            authenticationInteractor = authenticationInteractor,
            authenticationInteractor = authenticationInteractor,
            bouncerInteractor = bouncerInteractor,
        )
        )


    private val shadeSceneViewModel =
    private val shadeSceneViewModel =
@@ -167,9 +166,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() {
    @Test
    @Test
    fun clickLockButtonAndEnterCorrectPin_unlocksDevice() =
    fun clickLockButtonAndEnterCorrectPin_unlocksDevice() =
        testScope.runTest {
        testScope.runTest {
            lockscreenSceneViewModel.onLockButtonClicked()
            emulateUserDrivenTransition(SceneKey.Bouncer)
            assertCurrentScene(SceneKey.Bouncer)
            emulateUiSceneTransition()


            enterPin()
            enterPin()
            assertCurrentScene(SceneKey.Gone)
            assertCurrentScene(SceneKey.Gone)
@@ -462,10 +459,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() {
            .that(authenticationInteractor.isUnlocked.value)
            .that(authenticationInteractor.isUnlocked.value)
            .isFalse()
            .isFalse()


        lockscreenSceneViewModel.onLockButtonClicked()
        emulateUserDrivenTransition(SceneKey.Bouncer)
        runCurrent()
        emulateUiSceneTransition()

        enterPin()
        enterPin()
        emulateUiSceneTransition(
        emulateUiSceneTransition(
            expectedVisible = false,
            expectedVisible = false,