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

Commit a5c2565d authored by Daniel Chapin's avatar Daniel Chapin Committed by Android (Google) Code Review
Browse files

Revert "Add WakeDirectlyToGoneInteractor."

This reverts commit 94eea04e.

Reason for revert: b/352221489

Change-Id: I916c3f670838740f20b7c57ddf6aa9f031f4b1b7
parent 94eea04e
Loading
Loading
Loading
Loading
+2 −7
Original line number Original line Diff line number Diff line
@@ -81,7 +81,6 @@ import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.keyguard.domain.interactor.KeyguardEnabledInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardEnabledInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardWakeDirectlyToGoneInteractor;
import com.android.systemui.keyguard.ui.binder.KeyguardSurfaceBehindParamsApplier;
import com.android.systemui.keyguard.ui.binder.KeyguardSurfaceBehindParamsApplier;
import com.android.systemui.keyguard.ui.binder.KeyguardSurfaceBehindViewBinder;
import com.android.systemui.keyguard.ui.binder.KeyguardSurfaceBehindViewBinder;
import com.android.systemui.keyguard.ui.binder.WindowManagerLockscreenVisibilityViewBinder;
import com.android.systemui.keyguard.ui.binder.WindowManagerLockscreenVisibilityViewBinder;
@@ -318,7 +317,7 @@ public class KeyguardService extends Service {


    private final WindowManagerOcclusionManager mWmOcclusionManager;
    private final WindowManagerOcclusionManager mWmOcclusionManager;
    private final KeyguardEnabledInteractor mKeyguardEnabledInteractor;
    private final KeyguardEnabledInteractor mKeyguardEnabledInteractor;
    private final KeyguardWakeDirectlyToGoneInteractor mKeyguardWakeDirectlyToGoneInteractor;

    private final Lazy<FoldGracePeriodProvider> mFoldGracePeriodProvider = new Lazy<>() {
    private final Lazy<FoldGracePeriodProvider> mFoldGracePeriodProvider = new Lazy<>() {
        @Override
        @Override
        public FoldGracePeriodProvider get() {
        public FoldGracePeriodProvider get() {
@@ -345,8 +344,7 @@ public class KeyguardService extends Service {
            @Main Executor mainExecutor,
            @Main Executor mainExecutor,
            KeyguardInteractor keyguardInteractor,
            KeyguardInteractor keyguardInteractor,
            KeyguardEnabledInteractor keyguardEnabledInteractor,
            KeyguardEnabledInteractor keyguardEnabledInteractor,
            Lazy<KeyguardStateCallbackStartable> keyguardStateCallbackStartableLazy,
            Lazy<KeyguardStateCallbackStartable> keyguardStateCallbackStartableLazy) {
            KeyguardWakeDirectlyToGoneInteractor keyguardWakeDirectlyToGoneInteractor) {
        super();
        super();
        mKeyguardViewMediator = keyguardViewMediator;
        mKeyguardViewMediator = keyguardViewMediator;
        mKeyguardLifecyclesDispatcher = keyguardLifecyclesDispatcher;
        mKeyguardLifecyclesDispatcher = keyguardLifecyclesDispatcher;
@@ -374,7 +372,6 @@ public class KeyguardService extends Service {


        mWmOcclusionManager = windowManagerOcclusionManager;
        mWmOcclusionManager = windowManagerOcclusionManager;
        mKeyguardEnabledInteractor = keyguardEnabledInteractor;
        mKeyguardEnabledInteractor = keyguardEnabledInteractor;
        mKeyguardWakeDirectlyToGoneInteractor = keyguardWakeDirectlyToGoneInteractor;
    }
    }


    @Override
    @Override
@@ -489,7 +486,6 @@ public class KeyguardService extends Service {
        public void onDreamingStarted() {
        public void onDreamingStarted() {
            trace("onDreamingStarted");
            trace("onDreamingStarted");
            checkPermission();
            checkPermission();
            mKeyguardWakeDirectlyToGoneInteractor.onDreamingStarted();
            mKeyguardInteractor.setDreaming(true);
            mKeyguardInteractor.setDreaming(true);
            mKeyguardViewMediator.onDreamingStarted();
            mKeyguardViewMediator.onDreamingStarted();
        }
        }
@@ -498,7 +494,6 @@ public class KeyguardService extends Service {
        public void onDreamingStopped() {
        public void onDreamingStopped() {
            trace("onDreamingStopped");
            trace("onDreamingStopped");
            checkPermission();
            checkPermission();
            mKeyguardWakeDirectlyToGoneInteractor.onDreamingStopped();
            mKeyguardInteractor.setDreaming(false);
            mKeyguardInteractor.setDreaming(false);
            mKeyguardViewMediator.onDreamingStopped();
            mKeyguardViewMediator.onDreamingStopped();
        }
        }
+0 −31
Original line number Original line Diff line number Diff line
@@ -127,30 +127,6 @@ interface KeyguardRepository {
     */
     */
    val isKeyguardEnabled: StateFlow<Boolean>
    val isKeyguardEnabled: StateFlow<Boolean>


    /**
     * Whether we can transition directly back to GONE from AOD/DOZING without any authentication
     * events (such as a fingerprint wake and unlock), even though authentication would normally be
     * required. This means that if you tap the screen or press the power button, you'll return
     * directly to the unlocked app content without seeing the lockscreen, even if a secure
     * authentication method (PIN/password/biometrics) is set.
     *
     * This is true in these cases:
     * - The screen timed out, but the "lock after screen timeout" duration (default 5 seconds) has
     *   not yet elapsed.
     * - The power button was pressed, but "power button instantly locks" is not enabled, and the
     *   "lock after screen timeout" duration has not elapsed.
     *
     * Note that this value specifically tells us if we can *ignore* authentication that would
     * otherwise be required to transition from AOD/DOZING -> GONE. AOD/DOZING -> GONE is also
     * possible if keyguard is disabled, either from an app request or because security is set to
     * "none", but in that case, auth is not required so this boolean is not relevant.
     *
     * See [KeyguardWakeToGoneInteractor].
     */
    val canIgnoreAuthAndReturnToGone: StateFlow<Boolean>

    fun setCanIgnoreAuthAndReturnToGone(canWake: Boolean)

    /** Is the always-on display available to be used? */
    /** Is the always-on display available to be used? */
    val isAodAvailable: StateFlow<Boolean>
    val isAodAvailable: StateFlow<Boolean>


@@ -410,13 +386,6 @@ constructor(
        MutableStateFlow(!lockPatternUtils.isLockScreenDisabled(userTracker.userId))
        MutableStateFlow(!lockPatternUtils.isLockScreenDisabled(userTracker.userId))
    override val isKeyguardEnabled: StateFlow<Boolean> = _isKeyguardEnabled.asStateFlow()
    override val isKeyguardEnabled: StateFlow<Boolean> = _isKeyguardEnabled.asStateFlow()


    private val _canIgnoreAuthAndReturnToGone = MutableStateFlow(false)
    override val canIgnoreAuthAndReturnToGone = _canIgnoreAuthAndReturnToGone.asStateFlow()

    override fun setCanIgnoreAuthAndReturnToGone(canWakeToGone: Boolean) {
        _canIgnoreAuthAndReturnToGone.value = canWakeToGone
    }

    private val _isDozing = MutableStateFlow(statusBarStateController.isDozing)
    private val _isDozing = MutableStateFlow(statusBarStateController.isDozing)
    override val isDozing: StateFlow<Boolean> = _isDozing.asStateFlow()
    override val isDozing: StateFlow<Boolean> = _isDozing.asStateFlow()


+2 −4
Original line number Original line Diff line number Diff line
@@ -53,7 +53,6 @@ constructor(
    powerInteractor: PowerInteractor,
    powerInteractor: PowerInteractor,
    keyguardOcclusionInteractor: KeyguardOcclusionInteractor,
    keyguardOcclusionInteractor: KeyguardOcclusionInteractor,
    val deviceEntryRepository: DeviceEntryRepository,
    val deviceEntryRepository: DeviceEntryRepository,
    private val wakeToGoneInteractor: KeyguardWakeDirectlyToGoneInteractor,
) :
) :
    TransitionInteractor(
    TransitionInteractor(
        fromState = KeyguardState.AOD,
        fromState = KeyguardState.AOD,
@@ -99,7 +98,6 @@ constructor(
                    keyguardInteractor.primaryBouncerShowing,
                    keyguardInteractor.primaryBouncerShowing,
                    keyguardInteractor.isKeyguardOccluded,
                    keyguardInteractor.isKeyguardOccluded,
                    canDismissLockscreen,
                    canDismissLockscreen,
                    wakeToGoneInteractor.canWakeDirectlyToGone,
                )
                )
                .collect {
                .collect {
                    (
                    (
@@ -109,7 +107,6 @@ constructor(
                        primaryBouncerShowing,
                        primaryBouncerShowing,
                        isKeyguardOccludedLegacy,
                        isKeyguardOccludedLegacy,
                        canDismissLockscreen,
                        canDismissLockscreen,
                        canWakeDirectlyToGone,
                    ) ->
                    ) ->
                    if (!maybeHandleInsecurePowerGesture()) {
                    if (!maybeHandleInsecurePowerGesture()) {
                        val shouldTransitionToLockscreen =
                        val shouldTransitionToLockscreen =
@@ -134,7 +131,8 @@ constructor(


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


                        if (shouldTransitionToGone) {
                        if (shouldTransitionToGone) {
                            startTransitionTo(
                            startTransitionTo(
+16 −4
Original line number Original line Diff line number Diff line
@@ -55,7 +55,6 @@ constructor(
    private val communalInteractor: CommunalInteractor,
    private val communalInteractor: CommunalInteractor,
    keyguardOcclusionInteractor: KeyguardOcclusionInteractor,
    keyguardOcclusionInteractor: KeyguardOcclusionInteractor,
    val deviceEntryRepository: DeviceEntryRepository,
    val deviceEntryRepository: DeviceEntryRepository,
    private val wakeToGoneInteractor: KeyguardWakeDirectlyToGoneInteractor,
) :
) :
    TransitionInteractor(
    TransitionInteractor(
        fromState = KeyguardState.DOZING,
        fromState = KeyguardState.DOZING,
@@ -182,7 +181,7 @@ constructor(
                .sample(
                .sample(
                    communalInteractor.isIdleOnCommunal,
                    communalInteractor.isIdleOnCommunal,
                    keyguardInteractor.biometricUnlockState,
                    keyguardInteractor.biometricUnlockState,
                    wakeToGoneInteractor.canWakeDirectlyToGone,
                    canTransitionToGoneOnWake,
                    keyguardInteractor.primaryBouncerShowing,
                    keyguardInteractor.primaryBouncerShowing,
                )
                )
                .collect {
                .collect {
@@ -190,14 +189,27 @@ constructor(
                        _,
                        _,
                        isIdleOnCommunal,
                        isIdleOnCommunal,
                        biometricUnlockState,
                        biometricUnlockState,
                        canWakeDirectlyToGone,
                        canDismissLockscreen,
                        primaryBouncerShowing) ->
                        primaryBouncerShowing) ->
                    if (
                    if (
                        !maybeStartTransitionToOccludedOrInsecureCamera() &&
                        !maybeStartTransitionToOccludedOrInsecureCamera() &&
                            // Handled by dismissFromDozing().
                            // Handled by dismissFromDozing().
                            !isWakeAndUnlock(biometricUnlockState.mode)
                            !isWakeAndUnlock(biometricUnlockState.mode)
                    ) {
                    ) {
                        if (canWakeDirectlyToGone) {
                        if (!KeyguardWmStateRefactor.isEnabled && canDismissLockscreen) {
                            if (SceneContainerFlag.isEnabled) {
                                // TODO(b/336576536): Check if adaptation for scene framework is
                                // needed
                            } else {
                                startTransitionTo(
                                    KeyguardState.GONE,
                                    ownerReason = "waking from dozing"
                                )
                            }
                        } else if (
                            KeyguardWmStateRefactor.isEnabled &&
                                !deviceEntryRepository.isLockscreenEnabled()
                        ) {
                            if (SceneContainerFlag.isEnabled) {
                            if (SceneContainerFlag.isEnabled) {
                                // TODO(b/336576536): Check if adaptation for scene framework is
                                // TODO(b/336576536): Check if adaptation for scene framework is
                                // needed
                                // needed
+18 −33
Original line number Original line Diff line number Diff line
@@ -23,7 +23,6 @@ import com.android.systemui.Flags.communalHub
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor
import com.android.systemui.keyguard.KeyguardWmStateRefactor
import com.android.systemui.keyguard.KeyguardWmStateRefactor
import com.android.systemui.keyguard.data.repository.KeyguardTransitionRepository
import com.android.systemui.keyguard.data.repository.KeyguardTransitionRepository
import com.android.systemui.keyguard.shared.model.BiometricUnlockMode
import com.android.systemui.keyguard.shared.model.BiometricUnlockMode
@@ -38,14 +37,11 @@ import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.seconds
import kotlin.time.Duration.Companion.seconds
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.launch
import kotlinx.coroutines.launch


@OptIn(ExperimentalCoroutinesApi::class)
@SysUISingleton
@SysUISingleton
class FromDreamingTransitionInteractor
class FromDreamingTransitionInteractor
@Inject
@Inject
@@ -60,7 +56,6 @@ constructor(
    private val glanceableHubTransitions: GlanceableHubTransitions,
    private val glanceableHubTransitions: GlanceableHubTransitions,
    powerInteractor: PowerInteractor,
    powerInteractor: PowerInteractor,
    keyguardOcclusionInteractor: KeyguardOcclusionInteractor,
    keyguardOcclusionInteractor: KeyguardOcclusionInteractor,
    private val deviceEntryInteractor: DeviceEntryInteractor,
) :
) :
    TransitionInteractor(
    TransitionInteractor(
        fromState = KeyguardState.DREAMING,
        fromState = KeyguardState.DREAMING,
@@ -77,7 +72,7 @@ constructor(
        listenForDreamingToOccluded()
        listenForDreamingToOccluded()
        listenForDreamingToGoneWhenDismissable()
        listenForDreamingToGoneWhenDismissable()
        listenForDreamingToGoneFromBiometricUnlock()
        listenForDreamingToGoneFromBiometricUnlock()
        listenForDreamingToLockscreenOrGone()
        listenForDreamingToLockscreen()
        listenForDreamingToAodOrDozing()
        listenForDreamingToAodOrDozing()
        listenForTransitionToCamera(scope, keyguardInteractor)
        listenForTransitionToCamera(scope, keyguardInteractor)
        listenForDreamingToGlanceableHub()
        listenForDreamingToGlanceableHub()
@@ -137,7 +132,17 @@ constructor(


    @OptIn(FlowPreview::class)
    @OptIn(FlowPreview::class)
    private fun listenForDreamingToOccluded() {
    private fun listenForDreamingToOccluded() {
        if (!KeyguardWmStateRefactor.isEnabled) {
        if (KeyguardWmStateRefactor.isEnabled) {
            scope.launch {
                combine(
                        keyguardInteractor.isDreaming,
                        keyguardOcclusionInteractor.isShowWhenLockedActivityOnTop,
                        ::Pair
                    )
                    .filterRelevantKeyguardStateAnd { (isDreaming, _) -> !isDreaming }
                    .collect { maybeStartTransitionToOccludedOrInsecureCamera() }
            }
        } else {
            scope.launch {
            scope.launch {
                combine(
                combine(
                        keyguardInteractor.isKeyguardOccluded,
                        keyguardInteractor.isKeyguardOccluded,
@@ -163,41 +168,21 @@ constructor(
        }
        }
    }
    }


    private fun listenForDreamingToLockscreenOrGone() {
    private fun listenForDreamingToLockscreen() {
        if (!KeyguardWmStateRefactor.isEnabled) {
        if (!KeyguardWmStateRefactor.isEnabled) {
            return
            return
        }
        }


        scope.launch {
        scope.launch {
            keyguardInteractor.isDreaming
            keyguardOcclusionInteractor.isShowWhenLockedActivityOnTop
                .filter { !it }
                .filterRelevantKeyguardStateAnd { onTop -> !onTop }
                .sample(deviceEntryInteractor.isUnlocked, ::Pair)
                .collect { startTransitionTo(KeyguardState.LOCKSCREEN) }
                .collect { (_, dismissable) ->
                    // TODO(b/349837588): Add check for -> OCCLUDED.
                    if (dismissable) {
                        startTransitionTo(
                            KeyguardState.GONE,
                            ownerReason = "No longer dreaming; dismissable"
                        )
                    } else {
                        startTransitionTo(
                            KeyguardState.LOCKSCREEN,
                            ownerReason = "No longer dreaming"
                        )
                    }
                }
        }
        }
    }
    }


    private fun listenForDreamingToGoneWhenDismissable() {
    private fun listenForDreamingToGoneWhenDismissable() {
        if (SceneContainerFlag.isEnabled) {
        // TODO(b/336576536): Check if adaptation for scene framework is needed
            return // TODO(b/336576536): Check if adaptation for scene framework is needed
        if (SceneContainerFlag.isEnabled) return
        }

        if (KeyguardWmStateRefactor.isEnabled) {
            return
        }

        scope.launch {
        scope.launch {
            keyguardInteractor.isAbleToDream
            keyguardInteractor.isAbleToDream
                .sampleCombine(
                .sampleCombine(
Loading