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 Diff line number Diff line
@@ -67,7 +67,6 @@ constructor(
        modifier: Modifier,
    ) {
        LockscreenScene(
            viewModel = viewModel,
            viewProvider = viewProvider,
            modifier = modifier,
        )
@@ -85,7 +84,6 @@ constructor(

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

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

    /** Notifies that the lock button on the lock screen was clicked. */
    fun onLockButtonClicked() {
        bouncerInteractor.showOrUnlockDevice()
    }
}
+0 −34
Original line number 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.SceneModel
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

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

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

            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 Diff line number Diff line
@@ -118,7 +118,6 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() {
    private val lockscreenSceneViewModel =
        LockscreenSceneViewModel(
            authenticationInteractor = authenticationInteractor,
            bouncerInteractor = bouncerInteractor,
        )

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

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

        lockscreenSceneViewModel.onLockButtonClicked()
        runCurrent()
        emulateUiSceneTransition()

        emulateUserDrivenTransition(SceneKey.Bouncer)
        enterPin()
        emulateUiSceneTransition(
            expectedVisible = false,