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

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

Merge "Remove pieces of device entry flag - Piece #5" into main

parents c54fc0de 16a8cea6
Loading
Loading
Loading
Loading
+17 −25
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ import com.android.systemui.keyguard.data.repository.FakeBiometricSettingsReposi
import com.android.systemui.keyguard.data.repository.FakeDeviceEntryFingerprintAuthRepository
import com.android.systemui.keyguard.data.repository.FakeTrustRepository
import com.android.systemui.kosmos.testScope
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.res.R
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.shared.model.Scenes
@@ -100,18 +99,14 @@ class DeviceEntrySideFpsOverlayInteractorTest : SysuiTestCase() {
                FakeTrustRepository(),
                testScope.backgroundScope,
                mSelectedUserInteractor,
                faceAuthInteractor
                faceAuthInteractor,
            )

        alternateBouncerInteractor =
            AlternateBouncerInteractor(
                mock(StatusBarStateController::class.java),
                mock(KeyguardStateController::class.java),
                bouncerRepository,
                FakeFingerprintPropertyRepository(),
                biometricSettingsRepository,
                FakeSystemClock(),
                keyguardUpdateMonitor,
                { mock(DeviceEntryBiometricsAllowedInteractor::class.java) },
                { mock(KeyguardInteractor::class.java) },
                { mock(KeyguardTransitionInteractor::class.java) },
@@ -121,13 +116,12 @@ class DeviceEntrySideFpsOverlayInteractorTest : SysuiTestCase() {

        underTest =
            DeviceEntrySideFpsOverlayInteractor(
                testScope.backgroundScope,
                mContext,
                deviceEntryFingerprintAuthRepository,
                kosmos.sceneInteractor,
                primaryBouncerInteractor,
                alternateBouncerInteractor,
                keyguardUpdateMonitor
                keyguardUpdateMonitor,
            )
    }

@@ -142,7 +136,7 @@ class DeviceEntrySideFpsOverlayInteractorTest : SysuiTestCase() {
                isShowing = true,
                isAnimatingAway = false,
                fpsDetectionRunning = true,
                isUnlockingWithFpAllowed = true
                isUnlockingWithFpAllowed = true,
            )
            assertThat(showIndicatorForDeviceEntry).isTrue()
        }
@@ -158,7 +152,7 @@ class DeviceEntrySideFpsOverlayInteractorTest : SysuiTestCase() {
                isShowing = false,
                isAnimatingAway = false,
                fpsDetectionRunning = true,
                isUnlockingWithFpAllowed = true
                isUnlockingWithFpAllowed = true,
            )
            assertThat(showIndicatorForDeviceEntry).isFalse()
        }
@@ -169,13 +163,12 @@ class DeviceEntrySideFpsOverlayInteractorTest : SysuiTestCase() {
        testScope.runTest {
            underTest =
                DeviceEntrySideFpsOverlayInteractor(
                    testScope.backgroundScope,
                    mContext,
                    deviceEntryFingerprintAuthRepository,
                    kosmos.sceneInteractor,
                    primaryBouncerInteractor,
                    alternateBouncerInteractor,
                    keyguardUpdateMonitor
                    keyguardUpdateMonitor,
                )

            val showIndicatorForDeviceEntry by
@@ -185,7 +178,7 @@ class DeviceEntrySideFpsOverlayInteractorTest : SysuiTestCase() {
            updateBouncerScene(
                isActive = true,
                fpsDetectionRunning = true,
                isUnlockingWithFpAllowed = true
                isUnlockingWithFpAllowed = true,
            )
            assertThat(showIndicatorForDeviceEntry).isTrue()
        }
@@ -196,13 +189,12 @@ class DeviceEntrySideFpsOverlayInteractorTest : SysuiTestCase() {
        testScope.runTest {
            underTest =
                DeviceEntrySideFpsOverlayInteractor(
                    testScope.backgroundScope,
                    mContext,
                    deviceEntryFingerprintAuthRepository,
                    kosmos.sceneInteractor,
                    primaryBouncerInteractor,
                    alternateBouncerInteractor,
                    keyguardUpdateMonitor
                    keyguardUpdateMonitor,
                )

            val showIndicatorForDeviceEntry by
@@ -212,7 +204,7 @@ class DeviceEntrySideFpsOverlayInteractorTest : SysuiTestCase() {
            updateBouncerScene(
                isActive = false,
                fpsDetectionRunning = true,
                isUnlockingWithFpAllowed = true
                isUnlockingWithFpAllowed = true,
            )
            assertThat(showIndicatorForDeviceEntry).isFalse()
        }
@@ -228,7 +220,7 @@ class DeviceEntrySideFpsOverlayInteractorTest : SysuiTestCase() {
                isShowing = true,
                isAnimatingAway = false,
                fpsDetectionRunning = false,
                isUnlockingWithFpAllowed = true
                isUnlockingWithFpAllowed = true,
            )
            assertThat(showIndicatorForDeviceEntry).isFalse()
        }
@@ -245,7 +237,7 @@ class DeviceEntrySideFpsOverlayInteractorTest : SysuiTestCase() {
                isShowing = true,
                isAnimatingAway = false,
                fpsDetectionRunning = true,
                isUnlockingWithFpAllowed = false
                isUnlockingWithFpAllowed = false,
            )
            assertThat(showIndicatorForDeviceEntry).isFalse()
        }
@@ -261,7 +253,7 @@ class DeviceEntrySideFpsOverlayInteractorTest : SysuiTestCase() {
            updateBouncerScene(
                isActive = true,
                fpsDetectionRunning = false,
                isUnlockingWithFpAllowed = true
                isUnlockingWithFpAllowed = true,
            )
            assertThat(showIndicatorForDeviceEntry).isFalse()
        }
@@ -277,7 +269,7 @@ class DeviceEntrySideFpsOverlayInteractorTest : SysuiTestCase() {
            updateBouncerScene(
                isActive = true,
                fpsDetectionRunning = true,
                isUnlockingWithFpAllowed = false
                isUnlockingWithFpAllowed = false,
            )
            assertThat(showIndicatorForDeviceEntry).isFalse()
        }
@@ -294,7 +286,7 @@ class DeviceEntrySideFpsOverlayInteractorTest : SysuiTestCase() {
                isShowing = true,
                isAnimatingAway = true,
                fpsDetectionRunning = true,
                isUnlockingWithFpAllowed = true
                isUnlockingWithFpAllowed = true,
            )
            assertThat(showIndicatorForDeviceEntry).isFalse()
        }
@@ -325,7 +317,7 @@ class DeviceEntrySideFpsOverlayInteractorTest : SysuiTestCase() {
                isShowing = true,
                isAnimatingAway = false,
                fpsDetectionRunning = true,
                isUnlockingWithFpAllowed = true
                isUnlockingWithFpAllowed = true,
            )

            // Another request to show indicator for deviceEntryFingerprintAuthRepository update
@@ -355,7 +347,7 @@ class DeviceEntrySideFpsOverlayInteractorTest : SysuiTestCase() {
            .thenReturn(isUnlockingWithFpAllowed)
        mContext.orCreateTestableResources.addOverride(
            R.bool.config_show_sidefps_hint_on_bouncer,
            true
            true,
        )
    }

@@ -366,7 +358,7 @@ class DeviceEntrySideFpsOverlayInteractorTest : SysuiTestCase() {
    ) {
        kosmos.sceneInteractor.changeScene(
            if (isActive) Scenes.Bouncer else Scenes.Lockscreen,
            "reason"
            "reason",
        )

        whenever(keyguardUpdateMonitor.isFingerprintDetectionRunning)
@@ -375,7 +367,7 @@ class DeviceEntrySideFpsOverlayInteractorTest : SysuiTestCase() {
            .thenReturn(isUnlockingWithFpAllowed)
        mContext.orCreateTestableResources.addOverride(
            R.bool.config_show_sidefps_hint_on_bouncer,
            true
            true,
        )
        runCurrent()
    }
+5 −31
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.systemui.keyguard.ui.viewmodel

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
import com.android.systemui.biometrics.data.repository.fakeFingerprintPropertyRepository
import com.android.systemui.coroutines.collectLastValue
@@ -34,7 +33,6 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

@ExperimentalCoroutinesApi
@RunWith(AndroidJUnit4::class)
@@ -49,7 +47,6 @@ class AlternateBouncerWindowViewModelTest : SysuiTestCase() {
    @Test
    fun alternateBouncerTransition_alternateBouncerWindowRequiredTrue() =
        testScope.runTest {
            mSetFlagsRule.enableFlags(Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR)
            val alternateBouncerWindowRequired by
                collectLastValue(underTest.alternateBouncerWindowRequired)
            fingerprintPropertyRepository.supportsUdfps()
@@ -64,28 +61,7 @@ class AlternateBouncerWindowViewModelTest : SysuiTestCase() {
            assertThat(alternateBouncerWindowRequired).isTrue()

            transitionRepository.sendTransitionSteps(
                listOf(
                    stepFromAlternateBouncer(1.0f, TransitionState.FINISHED),
                ),
                testScope,
            )
            assertThat(alternateBouncerWindowRequired).isFalse()
        }

    @Test
    fun deviceEntryUdfpsFlagDisabled_alternateBouncerWindowRequiredFalse() =
        testScope.runTest {
            mSetFlagsRule.disableFlags(Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR)
            val alternateBouncerWindowRequired by
                collectLastValue(underTest.alternateBouncerWindowRequired)
            fingerprintPropertyRepository.supportsUdfps()
            transitionRepository.sendTransitionSteps(
                listOf(
                    stepFromAlternateBouncer(0f, TransitionState.STARTED),
                    stepFromAlternateBouncer(.4f),
                    stepFromAlternateBouncer(.6f),
                    stepFromAlternateBouncer(1f),
                ),
                listOf(stepFromAlternateBouncer(1.0f, TransitionState.FINISHED)),
                testScope,
            )
            assertThat(alternateBouncerWindowRequired).isFalse()
@@ -94,7 +70,6 @@ class AlternateBouncerWindowViewModelTest : SysuiTestCase() {
    @Test
    fun lockscreenTransition_alternateBouncerWindowRequiredFalse() =
        testScope.runTest {
            mSetFlagsRule.enableFlags(Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR)
            val alternateBouncerWindowRequired by
                collectLastValue(underTest.alternateBouncerWindowRequired)
            fingerprintPropertyRepository.supportsUdfps()
@@ -113,7 +88,6 @@ class AlternateBouncerWindowViewModelTest : SysuiTestCase() {
    @Test
    fun rearFps_alternateBouncerWindowRequiredFalse() =
        testScope.runTest {
            mSetFlagsRule.enableFlags(Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR)
            val alternateBouncerWindowRequired by
                collectLastValue(underTest.alternateBouncerWindowRequired)
            fingerprintPropertyRepository.supportsRearFps()
@@ -131,7 +105,7 @@ class AlternateBouncerWindowViewModelTest : SysuiTestCase() {

    private fun stepFromAlternateBouncer(
        value: Float,
        state: TransitionState = TransitionState.RUNNING
        state: TransitionState = TransitionState.RUNNING,
    ): TransitionStep {
        return step(
            from = KeyguardState.ALTERNATE_BOUNCER,
@@ -143,7 +117,7 @@ class AlternateBouncerWindowViewModelTest : SysuiTestCase() {

    private fun stepFromDozingToLockscreen(
        value: Float,
        state: TransitionState = TransitionState.RUNNING
        state: TransitionState = TransitionState.RUNNING,
    ): TransitionStep {
        return step(
            from = KeyguardState.DOZING,
@@ -157,14 +131,14 @@ class AlternateBouncerWindowViewModelTest : SysuiTestCase() {
        from: KeyguardState,
        to: KeyguardState,
        value: Float,
        transitionState: TransitionState
        transitionState: TransitionState,
    ): TransitionStep {
        return TransitionStep(
            from = from,
            to = to,
            value = value,
            transitionState = transitionState,
            ownerName = "AlternateBouncerViewModelTest"
            ownerName = "AlternateBouncerViewModelTest",
        )
    }
}
+0 −15
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import com.android.systemui.bouncer.shared.model.BouncerDismissActionModel
import com.android.systemui.bouncer.shared.model.BouncerShowMessageModel
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.deviceentry.shared.DeviceEntryUdfpsRefactor
import com.android.systemui.log.dagger.BouncerTableLog
import com.android.systemui.log.table.TableLogBuffer
import com.android.systemui.log.table.logDiffsForTable
@@ -88,7 +87,6 @@ interface KeyguardBouncerRepository {
    val showMessage: StateFlow<BouncerShowMessageModel?>
    val resourceUpdateRequests: StateFlow<Boolean>
    val alternateBouncerVisible: StateFlow<Boolean>
    val alternateBouncerUIAvailable: StateFlow<Boolean>

    /** Last shown security mode of the primary bouncer (ie: pin/pattern/password/SIM) */
    val lastShownSecurityMode: StateFlow<KeyguardSecurityModel.SecurityMode>
@@ -126,8 +124,6 @@ interface KeyguardBouncerRepository {

    fun setAlternateVisible(isVisible: Boolean)

    fun setAlternateBouncerUIAvailable(isAvailable: Boolean)

    fun setLastShownSecurityMode(securityMode: KeyguardSecurityModel.SecurityMode)
}

@@ -199,9 +195,6 @@ constructor(
    private val _alternateBouncerVisible = MutableStateFlow(false)
    override val alternateBouncerVisible = _alternateBouncerVisible.asStateFlow()
    override var lastAlternateBouncerVisibleTime: Long = NOT_VISIBLE
    private val _alternateBouncerUIAvailable = MutableStateFlow(false)
    override val alternateBouncerUIAvailable: StateFlow<Boolean> =
        _alternateBouncerUIAvailable.asStateFlow()

    init {
        setUpLogging()
@@ -220,11 +213,6 @@ constructor(
        _alternateBouncerVisible.value = isVisible
    }

    override fun setAlternateBouncerUIAvailable(isAvailable: Boolean) {
        DeviceEntryUdfpsRefactor.assertInLegacyMode()
        _alternateBouncerUIAvailable.value = isAvailable
    }

    override fun setPrimaryShow(isShowing: Boolean) {
        _primaryBouncerShow.value = isShowing
    }
@@ -320,9 +308,6 @@ constructor(
        resourceUpdateRequests
            .logDiffsForTable(buffer, "", "ResourceUpdateRequests", false)
            .launchIn(applicationScope)
        alternateBouncerUIAvailable
            .logDiffsForTable(buffer, "", "IsAlternateBouncerUIAvailable", false)
            .launchIn(applicationScope)
        alternateBouncerVisible
            .logDiffsForTable(buffer, "", "AlternateBouncerVisible", false)
            .launchIn(applicationScope)
+8 −64
Original line number Diff line number Diff line
@@ -17,22 +17,17 @@
package com.android.systemui.bouncer.domain.interactor

import android.util.Log
import com.android.keyguard.KeyguardUpdateMonitor
import com.android.systemui.biometrics.data.repository.FingerprintPropertyRepository
import com.android.systemui.bouncer.data.repository.KeyguardBouncerRepository
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryBiometricsAllowedInteractor
import com.android.systemui.deviceentry.shared.DeviceEntryUdfpsRefactor
import com.android.systemui.keyguard.data.repository.BiometricSettingsRepository
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.scene.domain.interactor.SceneInteractor
import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.util.kotlin.BooleanFlowOperators.anyOf
import com.android.systemui.util.time.SystemClock
import dagger.Lazy
@@ -55,13 +50,9 @@ import kotlinx.coroutines.flow.stateIn
class AlternateBouncerInteractor
@Inject
constructor(
    private val statusBarStateController: StatusBarStateController,
    private val keyguardStateController: KeyguardStateController,
    private val bouncerRepository: KeyguardBouncerRepository,
    fingerprintPropertyRepository: FingerprintPropertyRepository,
    private val biometricSettingsRepository: BiometricSettingsRepository,
    private val systemClock: SystemClock,
    private val keyguardUpdateMonitor: KeyguardUpdateMonitor,
    private val deviceEntryBiometricsAllowedInteractor:
        Lazy<DeviceEntryBiometricsAllowedInteractor>,
    private val keyguardInteractor: Lazy<KeyguardInteractor>,
@@ -73,17 +64,10 @@ constructor(
    val isVisible: Flow<Boolean> = bouncerRepository.alternateBouncerVisible
    private val alternateBouncerUiAvailableFromSource: HashSet<String> = HashSet()
    val alternateBouncerSupported: StateFlow<Boolean> =
        if (DeviceEntryUdfpsRefactor.isEnabled) {
        fingerprintPropertyRepository.sensorType
            .map { sensorType -> sensorType.isUdfps() || sensorType.isPowerButton() }
                .stateIn(
                    scope = scope,
                    started = SharingStarted.Eagerly,
                    initialValue = false,
                )
        } else {
            bouncerRepository.alternateBouncerUIAvailable
        }
            .stateIn(scope = scope, started = SharingStarted.Eagerly, initialValue = false)

    private val isDozingOrAod: Flow<Boolean> =
        anyOf(
                keyguardTransitionInteractor.get().transitionValue(KeyguardState.DOZING).map {
@@ -106,7 +90,7 @@ constructor(
                    combine(
                            keyguardTransitionInteractor.get().currentKeyguardState,
                            sceneInteractor.get().currentScene,
                            ::Pair
                            ::Pair,
                        )
                        .flatMapLatest { (currentKeyguardState, transitionState) ->
                            if (currentKeyguardState == KeyguardState.GONE) {
@@ -122,7 +106,7 @@ constructor(
                                        .isFingerprintAuthCurrentlyAllowed,
                                    keyguardInteractor.get().isKeyguardDismissible,
                                    bouncerRepository.primaryBouncerShow,
                                    isDozingOrAod
                                    isDozingOrAod,
                                ) {
                                    fingerprintAllowed,
                                    keyguardDismissible,
@@ -141,36 +125,16 @@ constructor(
            }
            .distinctUntilChanged()
            .onEach { Log.d(TAG, "canShowAlternateBouncer changed to $it") }
            .stateIn(
                scope = scope,
                started = WhileSubscribed(),
                initialValue = false,
            )
            .stateIn(scope = scope, started = WhileSubscribed(), initialValue = false)

    /**
     * Always shows the alternate bouncer. Requesters must check [canShowAlternateBouncer]` before
     * calling this.
     */
    fun forceShow() {
        if (DeviceEntryUdfpsRefactor.isUnexpectedlyInLegacyMode()) {
            show()
            return
        }
        bouncerRepository.setAlternateVisible(true)
    }

    /**
     * Sets the correct bouncer states to show the alternate bouncer if it can show.
     *
     * @return whether alternateBouncer is visible
     * @deprecated use [forceShow] and manually check [canShowAlternateBouncer] beforehand
     */
    fun show(): Boolean {
        DeviceEntryUdfpsRefactor.assertInLegacyMode()
        bouncerRepository.setAlternateVisible(canShowAlternateBouncerForFingerprint())
        return isVisibleState()
    }

    /**
     * Sets the correct bouncer states to hide the bouncer. Should only be called through
     * StatusBarKeyguardViewManager until ScrimController is refactored to use
@@ -189,29 +153,9 @@ constructor(
        return bouncerRepository.alternateBouncerVisible.value
    }

    fun setAlternateBouncerUIAvailable(isAvailable: Boolean, token: String) {
        DeviceEntryUdfpsRefactor.assertInLegacyMode()
        if (isAvailable) {
            alternateBouncerUiAvailableFromSource.add(token)
        } else {
            alternateBouncerUiAvailableFromSource.remove(token)
        }
        bouncerRepository.setAlternateBouncerUIAvailable(
            alternateBouncerUiAvailableFromSource.isNotEmpty()
        )
    }

    fun canShowAlternateBouncerForFingerprint(): Boolean {
        if (DeviceEntryUdfpsRefactor.isEnabled) {
        return canShowAlternateBouncer.value
    }
        return alternateBouncerSupported.value &&
            biometricSettingsRepository.isFingerprintAuthCurrentlyAllowed.value &&
            !keyguardUpdateMonitor.isFingerprintLockedOut &&
            !keyguardStateController.isUnlocked &&
            !statusBarStateController.isDozing &&
            !bouncerRepository.primaryBouncerShow.value
    }

    /**
     * Whether the alt bouncer has shown for a minimum time before allowing touches to dismiss the
+3 −16
Original line number Diff line number Diff line
@@ -17,25 +17,17 @@
package com.android.systemui.deviceentry

import com.android.keyguard.EmptyLockIconViewController
import com.android.keyguard.LegacyLockIconViewController
import com.android.keyguard.LockIconViewController
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.deviceentry.data.repository.DeviceEntryRepositoryModule
import com.android.systemui.deviceentry.data.repository.FaceWakeUpTriggersConfigModule
import com.android.systemui.deviceentry.shared.DeviceEntryUdfpsRefactor
import com.android.systemui.keyguard.ui.transitions.DeviceEntryIconTransition
import dagger.Lazy
import dagger.Module
import dagger.Provides
import dagger.multibindings.Multibinds

@Module(
    includes =
        [
            DeviceEntryRepositoryModule::class,
            FaceWakeUpTriggersConfigModule::class,
        ],
)
@Module(includes = [DeviceEntryRepositoryModule::class, FaceWakeUpTriggersConfigModule::class])
abstract class DeviceEntryModule {
    /**
     * A set of DeviceEntryIconTransitions. Ensures that this can be injected even if it's empty.
@@ -46,14 +38,9 @@ abstract class DeviceEntryModule {
        @Provides
        @SysUISingleton
        fun provideLockIconViewController(
            legacyLockIconViewController: Lazy<LegacyLockIconViewController>,
            emptyLockIconViewController: Lazy<EmptyLockIconViewController>,
            emptyLockIconViewController: Lazy<EmptyLockIconViewController>
        ): LockIconViewController {
            return if (DeviceEntryUdfpsRefactor.isEnabled) {
                emptyLockIconViewController.get()
            } else {
                legacyLockIconViewController.get()
            }
            return emptyLockIconViewController.get()
        }
    }
}
Loading