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

Commit 40cd6e7f authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove LegacyComposeBouncer checks & code" into main

parents c2d71886 f091b0af
Loading
Loading
Loading
Loading
+12 −16
Original line number Diff line number Diff line
@@ -19,11 +19,9 @@ package com.android.systemui.bouncer.ui.viewmodel
import android.content.pm.UserInfo
import android.hardware.biometrics.BiometricFaceConstants
import android.hardware.fingerprint.FingerprintManager
import android.platform.test.annotations.EnableFlags
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.widget.LockPatternUtils
import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
import com.android.systemui.authentication.data.repository.FakeAuthenticationRepository
import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository
@@ -42,6 +40,7 @@ import com.android.systemui.deviceentry.domain.interactor.DeviceUnlockedInteract
import com.android.systemui.deviceentry.shared.model.ErrorFaceAuthenticationStatus
import com.android.systemui.deviceentry.shared.model.FailedFaceAuthenticationStatus
import com.android.systemui.deviceentry.shared.model.HelpFaceAuthenticationStatus
import com.android.systemui.flags.EnableSceneContainer
import com.android.systemui.flags.fakeSystemPropertiesHelper
import com.android.systemui.keyguard.data.repository.deviceEntryFingerprintAuthRepository
import com.android.systemui.keyguard.data.repository.fakeBiometricSettingsRepository
@@ -70,7 +69,7 @@ import org.junit.runner.RunWith

@SmallTest
@RunWith(AndroidJUnit4::class)
@EnableFlags(Flags.FLAG_COMPOSE_BOUNCER)
@EnableSceneContainer
class BouncerMessageViewModelTest : SysuiTestCase() {
    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope
@@ -84,14 +83,14 @@ class BouncerMessageViewModelTest : SysuiTestCase() {
        kosmos.fakeUserRepository.setUserInfos(listOf(PRIMARY_USER))
        overrideResource(
            R.array.config_face_acquire_device_entry_ignorelist,
            intArrayOf(ignoreHelpMessageId)
            intArrayOf(ignoreHelpMessageId),
        )
        underTest = kosmos.bouncerMessageViewModel
        underTest.activateIn(testScope)
        overrideResource(R.string.kg_trust_agent_disabled, "Trust agent is unavailable")
        kosmos.fakeSystemPropertiesHelper.set(
            DeviceUnlockedInteractor.SYS_BOOT_REASON_PROP,
            "not mainline reboot"
            "not mainline reboot",
        )
    }

@@ -199,7 +198,7 @@ class BouncerMessageViewModelTest : SysuiTestCase() {
                    .STRONG_AUTH_REQUIRED_AFTER_NON_STRONG_BIOMETRICS_TIMEOUT to
                    Pair(
                        "Enter PIN",
                        "Added security required. Device wasn’t unlocked for a while."
                        "Added security required. Device wasn’t unlocked for a while.",
                    ),
            )
        }
@@ -236,7 +235,7 @@ class BouncerMessageViewModelTest : SysuiTestCase() {
                    .STRONG_AUTH_REQUIRED_AFTER_NON_STRONG_BIOMETRICS_TIMEOUT to
                    Pair(
                        "Unlock with PIN or fingerprint",
                        "Added security required. Device wasn’t unlocked for a while."
                        "Added security required. Device wasn’t unlocked for a while.",
                    ),
            )
        }
@@ -366,7 +365,7 @@ class BouncerMessageViewModelTest : SysuiTestCase() {
            kosmos.deviceEntryFingerprintAuthRepository.setAuthenticationStatus(
                ErrorFingerprintAuthenticationStatus(
                    FingerprintManager.FINGERPRINT_ERROR_LOCKOUT,
                    "locked out"
                    "locked out",
                )
            )
            runCurrent()
@@ -393,7 +392,7 @@ class BouncerMessageViewModelTest : SysuiTestCase() {
                HelpFaceAuthenticationStatus(
                    0,
                    "some helpful message",
                    FaceHelpMessageDebouncer.DEFAULT_WINDOW_MS
                    FaceHelpMessageDebouncer.DEFAULT_WINDOW_MS,
                )
            )
            runCurrent()
@@ -403,7 +402,7 @@ class BouncerMessageViewModelTest : SysuiTestCase() {
            kosmos.fakeDeviceEntryFaceAuthRepository.setAuthenticationStatus(
                ErrorFaceAuthenticationStatus(
                    BiometricFaceConstants.FACE_ERROR_TIMEOUT,
                    "Try again"
                    "Try again",
                )
            )
            runCurrent()
@@ -420,7 +419,7 @@ class BouncerMessageViewModelTest : SysuiTestCase() {
            kosmos.fakeDeviceEntryFaceAuthRepository.setAuthenticationStatus(
                ErrorFaceAuthenticationStatus(
                    BiometricFaceConstants.FACE_ERROR_LOCKOUT,
                    "locked out"
                    "locked out",
                )
            )
            runCurrent()
@@ -466,10 +465,7 @@ class BouncerMessageViewModelTest : SysuiTestCase() {
        }
    }

    private fun assertTryAgainMessage(
        message: String?,
        time: Int,
    ) {
    private fun assertTryAgainMessage(message: String?, time: Int) {
        assertThat(message).contains("Try again in $time second")
    }

@@ -480,7 +476,7 @@ class BouncerMessageViewModelTest : SysuiTestCase() {
            UserInfo(
                /* id= */ PRIMARY_USER_ID,
                /* name= */ "primary user",
                /* flags= */ UserInfo.FLAG_PRIMARY
                /* flags= */ UserInfo.FLAG_PRIMARY,
            )
    }
}
+0 −37
Original line number Diff line number Diff line
@@ -17,9 +17,6 @@
package com.android.systemui.bouncer.ui.viewmodel

import android.content.pm.UserInfo
import android.platform.test.annotations.EnableFlags
import android.view.KeyEvent
import androidx.compose.ui.input.key.KeyEventType
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
@@ -29,8 +26,6 @@ import com.android.systemui.authentication.shared.model.AuthenticationMethodMode
import com.android.systemui.bouncer.domain.interactor.bouncerInteractor
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.coroutines.collectValues
import com.android.systemui.flags.DisableSceneContainer
import com.android.systemui.flags.EnableSceneContainer
import com.android.systemui.inputmethod.data.model.InputMethodModel
import com.android.systemui.inputmethod.data.repository.fakeInputMethodRepository
import com.android.systemui.inputmethod.domain.interactor.inputMethodInteractor
@@ -348,38 +343,6 @@ class PasswordBouncerViewModelTest : SysuiTestCase() {
            assertThat(textInputFocusRequested).isFalse()
        }

    @EnableFlags(com.android.systemui.Flags.FLAG_COMPOSE_BOUNCER)
    @DisableSceneContainer
    @Test
    fun consumeConfirmKeyEvents_toPreventItFromPropagating() =
        testScope.runTest { verifyConfirmKeyEventsBehavior(keyUpEventConsumed = true) }

    @EnableFlags(com.android.systemui.Flags.FLAG_COMPOSE_BOUNCER)
    @EnableSceneContainer
    @Test
    fun noops_whenSceneContainerIsAlsoEnabled() =
        testScope.runTest { verifyConfirmKeyEventsBehavior(keyUpEventConsumed = false) }

    private fun verifyConfirmKeyEventsBehavior(keyUpEventConsumed: Boolean) {
        assertThat(underTest.onKeyEvent(KeyEventType.KeyDown, KeyEvent.KEYCODE_DPAD_CENTER))
            .isFalse()
        assertThat(underTest.onKeyEvent(KeyEventType.KeyUp, KeyEvent.KEYCODE_DPAD_CENTER))
            .isEqualTo(keyUpEventConsumed)

        assertThat(underTest.onKeyEvent(KeyEventType.KeyDown, KeyEvent.KEYCODE_ENTER)).isFalse()
        assertThat(underTest.onKeyEvent(KeyEventType.KeyUp, KeyEvent.KEYCODE_ENTER))
            .isEqualTo(keyUpEventConsumed)

        assertThat(underTest.onKeyEvent(KeyEventType.KeyDown, KeyEvent.KEYCODE_NUMPAD_ENTER))
            .isFalse()
        assertThat(underTest.onKeyEvent(KeyEventType.KeyUp, KeyEvent.KEYCODE_NUMPAD_ENTER))
            .isEqualTo(keyUpEventConsumed)

        // space is ignored.
        assertThat(underTest.onKeyEvent(KeyEventType.KeyUp, KeyEvent.KEYCODE_SPACE)).isFalse()
        assertThat(underTest.onKeyEvent(KeyEventType.KeyDown, KeyEvent.KEYCODE_SPACE)).isFalse()
    }

    private fun TestScope.showBouncer() {
        val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
        sceneInteractor.showOverlay(Overlays.Bouncer, "reason")
+0 −15
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.systemui.bouncer.ui.viewmodel

import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import android.view.KeyEvent.KEYCODE_0
import android.view.KeyEvent.KEYCODE_4
@@ -33,7 +32,6 @@ import com.android.systemui.authentication.data.repository.fakeAuthenticationRep
import com.android.systemui.authentication.domain.interactor.authenticationInteractor
import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.bouncer.data.repository.fakeSimBouncerRepository
import com.android.systemui.classifier.fakeFalsingCollector
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.haptics.msdl.bouncerHapticPlayer
import com.android.systemui.haptics.msdl.fakeMSDLPlayer
@@ -47,7 +45,6 @@ import com.google.android.msdl.data.model.MSDLToken
import com.google.common.truth.Truth.assertThat
import kotlin.random.Random
import kotlin.random.nextInt
import kotlin.test.assertTrue
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.test.TestScope
@@ -486,18 +483,6 @@ class PinBouncerViewModelTest : SysuiTestCase() {
            assertThat(pin).containsExactly(*expectedPin)
        }

    @Test
    @EnableFlags(com.android.systemui.Flags.FLAG_COMPOSE_BOUNCER)
    @DisableFlags(com.android.systemui.Flags.FLAG_SCENE_CONTAINER)
    fun onDigitButtonDown_avoidGesture_invoked() =
        testScope.runTest {
            lockDeviceAndOpenPinBouncer()

            underTest.onDigitButtonDown(null)

            assertTrue(kosmos.fakeFalsingCollector.wasLastGestureAvoided())
        }

    @Test
    @EnableFlags(Flags.FLAG_MSDL_FEEDBACK)
    fun onDigiButtonDown_deliversKeyStandardToken() =
+2 −3
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.systemui.keyguard.domain.interactor

import android.platform.test.annotations.EnableFlags
import android.view.KeyEvent
import android.view.KeyEvent.ACTION_DOWN
import android.view.KeyEvent.ACTION_UP
@@ -25,8 +24,8 @@ import android.view.KeyEvent.KEYCODE_MEDIA_PLAY
import android.view.KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags.FLAG_COMPOSE_BOUNCER
import com.android.systemui.SysuiTestCase
import com.android.systemui.flags.EnableSceneContainer
import com.android.systemui.kosmos.testScope
import com.android.systemui.lifecycle.activateIn
import com.android.systemui.telephony.data.repository.fakeTelephonyRepository
@@ -41,7 +40,7 @@ import org.junit.runner.RunWith

@SmallTest
@RunWith(AndroidJUnit4::class)
@EnableFlags(FLAG_COMPOSE_BOUNCER)
@EnableSceneContainer
class KeyguardMediaKeyInteractorTest : SysuiTestCase() {
    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope
+0 −38
Original line number Diff line number Diff line
@@ -16,14 +16,12 @@

package com.android.systemui.shade.ui.viewmodel

import android.platform.test.annotations.EnableFlags
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.compose.animation.scene.ObservableTransitionState
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.bouncer.data.repository.fakeKeyguardBouncerRepository
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.flags.EnableSceneContainer
import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
@@ -248,21 +246,6 @@ class NotificationShadeWindowModelTest : SysuiTestCase() {
            assertThat(isOnOrGoingToDream).isFalse()
        }

    @Test
    @EnableFlags(com.android.systemui.Flags.FLAG_COMPOSE_BOUNCER)
    fun withComposeBouncer_bouncerShowing_providesTheCorrectState() =
        testScope.runTest {
            val bouncerShowing by collectLastValue(underTest.isBouncerShowing)

            kosmos.fakeKeyguardBouncerRepository.setPrimaryShow(isShowing = false)
            runCurrent()
            assertThat(bouncerShowing).isFalse()

            kosmos.fakeKeyguardBouncerRepository.setPrimaryShow(isShowing = true)
            runCurrent()
            assertThat(bouncerShowing).isTrue()
        }

    @Test
    @EnableSceneContainer
    fun withSceneContainer_doesBouncerRequireIme_providesTheCorrectState() =
@@ -294,25 +277,4 @@ class NotificationShadeWindowModelTest : SysuiTestCase() {
            runCurrent()
            assertThat(bouncerRequiresIme).isTrue()
        }

    @Test
    @EnableFlags(com.android.systemui.Flags.FLAG_COMPOSE_BOUNCER)
    fun withComposeBouncer_doesBouncerRequireIme_providesTheCorrectState() =
        testScope.runTest {
            val bouncerRequiresIme by collectLastValue(underTest.doesBouncerRequireIme)
            kosmos.fakeAuthenticationRepository.setAuthenticationMethod(
                AuthenticationMethodModel.Pin
            )

            kosmos.fakeKeyguardBouncerRepository.setPrimaryShow(isShowing = true)
            runCurrent()
            assertThat(bouncerRequiresIme).isFalse()

            kosmos.fakeAuthenticationRepository.setAuthenticationMethod(
                AuthenticationMethodModel.Password
            )
            kosmos.fakeKeyguardBouncerRepository.setPrimaryShow(isShowing = true)
            runCurrent()
            assertThat(bouncerRequiresIme).isFalse()
        }
}
Loading