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

Commit 43cef1e1 authored by Matt Pietal's avatar Matt Pietal Committed by Android (Google) Code Review
Browse files

Merge "Use State.value instead of sample()" into main

parents 0b97f3a4 d6624fb4
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -91,11 +91,11 @@ interface KeyguardRepository {
     * the z-order (which is not really above the system UI window, but rather - the lock-screen
     * becomes invisible to reveal the "occluding activity").
     */
    val isKeyguardShowing: Flow<Boolean>
    val isKeyguardShowing: StateFlow<Boolean>

    /** Is an activity showing over the keyguard? */
    @Deprecated("Use KeyguardTransitionInteractor + KeyguardState.OCCLUDED")
    val isKeyguardOccluded: Flow<Boolean>
    val isKeyguardOccluded: StateFlow<Boolean>

    /**
     * Whether the device is locked or unlocked right now. This is true when keyguard has been
+12 −24
Original line number Diff line number Diff line
@@ -36,8 +36,6 @@ import javax.inject.Inject
import kotlin.time.Duration.Companion.milliseconds
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.debounce

@SysUISingleton
@@ -73,14 +71,10 @@ constructor(
        listenForTransitionToCamera(scope, keyguardInteractor)
    }

    private val canDismissLockscreen: Flow<Boolean> =
        combine(
            keyguardInteractor.isKeyguardShowing,
            keyguardInteractor.isKeyguardDismissible,
            keyguardInteractor.biometricUnlockState,
        ) { isKeyguardShowing, isKeyguardDismissible, biometricUnlockState ->
            (isWakeAndUnlock(biometricUnlockState.mode) ||
                (!isKeyguardShowing && isKeyguardDismissible))
    private fun canDismissLockscreen(): Boolean {
        return isWakeAndUnlock(keyguardInteractor.biometricUnlockState.value.mode) ||
            (!keyguardInteractor.isKeyguardShowing.value &&
                keyguardInteractor.isKeyguardDismissible.value)
    }

    /**
@@ -96,22 +90,18 @@ constructor(
                .debounce(50L)
                .sample(
                    startedKeyguardTransitionStep,
                    keyguardInteractor.biometricUnlockState,
                    keyguardInteractor.primaryBouncerShowing,
                    keyguardInteractor.isKeyguardOccluded,
                    canDismissLockscreen,
                    wakeToGoneInteractor.canWakeDirectlyToGone,
                )
                .collect {
                    (
                        _,
                        startedStep,
                        biometricUnlockState,
                        primaryBouncerShowing,
                        isKeyguardOccludedLegacy,
                        canDismissLockscreen,
                        canWakeDirectlyToGone,
                    ) ->
                    val isKeyguardOccludedLegacy = keyguardInteractor.isKeyguardOccluded.value
                    val biometricUnlockMode = keyguardInteractor.biometricUnlockState.value.mode
                    val primaryBouncerShowing = keyguardInteractor.primaryBouncerShowing.value

                    if (!maybeHandleInsecurePowerGesture()) {
                        val shouldTransitionToLockscreen =
                            if (KeyguardWmStateRefactor.isEnabled) {
@@ -121,12 +111,10 @@ constructor(
                                // completes.
                                !maybeStartTransitionToOccludedOrInsecureCamera { state, reason ->
                                    startTransitionTo(state, ownerReason = reason)
                                } &&
                                    !isWakeAndUnlock(biometricUnlockState.mode) &&
                                    !primaryBouncerShowing
                                } && !isWakeAndUnlock(biometricUnlockMode) && !primaryBouncerShowing
                            } else {
                                !isKeyguardOccludedLegacy &&
                                    !isWakeAndUnlock(biometricUnlockState.mode) &&
                                    !isWakeAndUnlock(biometricUnlockMode) &&
                                    !primaryBouncerShowing
                            }

@@ -136,7 +124,7 @@ constructor(
                            !KeyguardWmStateRefactor.isEnabled && isKeyguardOccludedLegacy

                        val shouldTransitionToGone =
                            (!KeyguardWmStateRefactor.isEnabled && canDismissLockscreen) ||
                            (!KeyguardWmStateRefactor.isEnabled && canDismissLockscreen()) ||
                                (KeyguardWmStateRefactor.isEnabled && canWakeDirectlyToGone)

                        if (shouldTransitionToGone) {
+10 −22
Original line number Diff line number Diff line
@@ -42,8 +42,6 @@ import javax.inject.Inject
import kotlin.time.Duration.Companion.milliseconds
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.launch

@@ -83,12 +81,9 @@ constructor(
        listenForTransitionToCamera(scope, keyguardInteractor)
    }

    private val canTransitionToGoneOnWake: Flow<Boolean> =
        combine(
            keyguardInteractor.isKeyguardShowing,
            keyguardInteractor.isKeyguardDismissible,
        ) { isKeyguardShowing, isKeyguardDismissible ->
            isKeyguardDismissible && !isKeyguardShowing
    private fun canDismissLockscreen(): Boolean {
        return !keyguardInteractor.isKeyguardShowing.value &&
            keyguardInteractor.isKeyguardDismissible.value
    }

    private fun listenForDozingToGoneViaBiometrics() {
@@ -135,27 +130,20 @@ constructor(
                .debounce(50L)
                .filterRelevantKeyguardStateAnd { isAwake -> isAwake }
                .sample(
                    keyguardInteractor.isKeyguardOccluded,
                    communalInteractor.isCommunalAvailable,
                    communalSceneInteractor.isIdleOnCommunal,
                    canTransitionToGoneOnWake,
                    keyguardInteractor.primaryBouncerShowing,
                )
                .collect {
                    (
                        _,
                        occluded,
                        isCommunalAvailable,
                        isIdleOnCommunal,
                        canTransitionToGoneOnWake,
                        primaryBouncerShowing) ->
                .collect { (_, isCommunalAvailable, isIdleOnCommunal) ->
                    val isKeyguardOccludedLegacy = keyguardInteractor.isKeyguardOccluded.value
                    val primaryBouncerShowing = keyguardInteractor.primaryBouncerShowing.value

                    if (!deviceEntryInteractor.isLockscreenEnabled()) {
                        if (SceneContainerFlag.isEnabled) {
                            // TODO(b/336576536): Check if adaptation for scene framework is needed
                        } else {
                            startTransitionTo(KeyguardState.GONE)
                        }
                    } else if (canTransitionToGoneOnWake) {
                    } else if (canDismissLockscreen()) {
                        if (SceneContainerFlag.isEnabled) {
                            // TODO(b/336576536): Check if adaptation for scene framework is needed
                        } else {
@@ -167,7 +155,7 @@ constructor(
                        } else {
                            startTransitionTo(KeyguardState.PRIMARY_BOUNCER)
                        }
                    } else if (occluded) {
                    } else if (isKeyguardOccludedLegacy) {
                        startTransitionTo(KeyguardState.OCCLUDED)
                    } else if (isIdleOnCommunal && !communalSceneKtfRefactor()) {
                        if (SceneContainerFlag.isEnabled) {
+8 −9
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import com.android.systemui.keyguard.shared.model.DozeStateModel
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.power.domain.interactor.PowerInteractor
import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.util.kotlin.Utils.Companion.sample as sampleCombine
import com.android.systemui.util.kotlin.sample
import javax.inject.Inject
import kotlin.time.Duration.Companion.milliseconds
@@ -208,15 +207,15 @@ constructor(

        scope.launch {
            keyguardInteractor.isAbleToDream
                .sampleCombine(
                    keyguardInteractor.isKeyguardShowing,
                    keyguardInteractor.isKeyguardDismissible,
                )
                .filterRelevantKeyguardStateAnd {
                    (isDreaming, isKeyguardShowing, isKeyguardDismissible) ->
                    !isDreaming && isKeyguardDismissible && !isKeyguardShowing
                .filterRelevantKeyguardStateAnd { isDreaming -> !isDreaming }
                .collect {
                    if (
                        keyguardInteractor.isKeyguardDismissible.value &&
                            !keyguardInteractor.isKeyguardShowing.value
                    ) {
                        startTransitionTo(KeyguardState.GONE)
                    }
                }
                .collect { startTransitionTo(KeyguardState.GONE) }
        }
    }

+4 −4
Original line number Diff line number Diff line
@@ -216,14 +216,14 @@ constructor(

    /** Whether the keyguard is showing or not. */
    @Deprecated("Use KeyguardTransitionInteractor + KeyguardState")
    val isKeyguardShowing: Flow<Boolean> = repository.isKeyguardShowing
    val isKeyguardShowing: StateFlow<Boolean> = repository.isKeyguardShowing

    /** Whether the keyguard is dismissible or not. */
    val isKeyguardDismissible: StateFlow<Boolean> = repository.isKeyguardDismissible

    /** Whether the keyguard is occluded (covered by an activity). */
    @Deprecated("Use KeyguardTransitionInteractor + KeyguardState.OCCLUDED")
    val isKeyguardOccluded: Flow<Boolean> = repository.isKeyguardOccluded
    val isKeyguardOccluded: StateFlow<Boolean> = repository.isKeyguardOccluded

    /** Whether the keyguard is going away. */
    @Deprecated("Use KeyguardTransitionInteractor + KeyguardState.GONE")
@@ -253,7 +253,7 @@ constructor(
    val ambientIndicationVisible: Flow<Boolean> = repository.ambientIndicationVisible.asStateFlow()

    /** Whether the primary bouncer is showing or not. */
    @JvmField val primaryBouncerShowing: Flow<Boolean> = bouncerRepository.primaryBouncerShow
    @JvmField val primaryBouncerShowing: StateFlow<Boolean> = bouncerRepository.primaryBouncerShow

    /** Whether the alternate bouncer is showing or not. */
    val alternateBouncerShowing: Flow<Boolean> =
@@ -274,7 +274,7 @@ constructor(
    val statusBarState: Flow<StatusBarState> = repository.statusBarState

    /** Observable for [BiometricUnlockModel] when biometrics are used to unlock the device. */
    val biometricUnlockState: Flow<BiometricUnlockModel> = repository.biometricUnlockState
    val biometricUnlockState: StateFlow<BiometricUnlockModel> = repository.biometricUnlockState

    /** Keyguard is present and is not occluded. */
    val isKeyguardVisible: Flow<Boolean> =
Loading