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

Commit 71b50a18 authored by Daniel Chapin's avatar Daniel Chapin Committed by Android Build Coastguard Worker
Browse files

Revert "Add WakeDirectlyToGoneInteractor."

This reverts commit 94eea04e.

Reason for revert: b/352221489
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:a5c2565dd98146425c432039627fa93f0b635692)
Merged-In: I916c3f670838740f20b7c57ddf6aa9f031f4b1b7
Change-Id: I916c3f670838740f20b7c57ddf6aa9f031f4b1b7
parent e8756331
Loading
Loading
Loading
Loading
+2 −7
Original line number 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.keyguard.domain.interactor.KeyguardEnabledInteractor;
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.KeyguardSurfaceBehindViewBinder;
import com.android.systemui.keyguard.ui.binder.WindowManagerLockscreenVisibilityViewBinder;
@@ -318,7 +317,7 @@ public class KeyguardService extends Service {

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

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

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

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

@@ -410,13 +386,6 @@ constructor(
        MutableStateFlow(!lockPatternUtils.isLockScreenDisabled(userTracker.userId))
    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)
    override val isDozing: StateFlow<Boolean> = _isDozing.asStateFlow()

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

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

                        if (shouldTransitionToGone) {
                            startTransitionTo(
+16 −4
Original line number Diff line number Diff line
@@ -55,7 +55,6 @@ constructor(
    private val communalInteractor: CommunalInteractor,
    keyguardOcclusionInteractor: KeyguardOcclusionInteractor,
    val deviceEntryRepository: DeviceEntryRepository,
    private val wakeToGoneInteractor: KeyguardWakeDirectlyToGoneInteractor,
) :
    TransitionInteractor(
        fromState = KeyguardState.DOZING,
@@ -182,7 +181,7 @@ constructor(
                .sample(
                    communalInteractor.isIdleOnCommunal,
                    keyguardInteractor.biometricUnlockState,
                    wakeToGoneInteractor.canWakeDirectlyToGone,
                    canTransitionToGoneOnWake,
                    keyguardInteractor.primaryBouncerShowing,
                )
                .collect {
@@ -190,14 +189,27 @@ constructor(
                        _,
                        isIdleOnCommunal,
                        biometricUnlockState,
                        canWakeDirectlyToGone,
                        canDismissLockscreen,
                        primaryBouncerShowing) ->
                    if (
                        !maybeStartTransitionToOccludedOrInsecureCamera() &&
                            // Handled by dismissFromDozing().
                            !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) {
                                // TODO(b/336576536): Check if adaptation for scene framework is
                                // needed
+18 −33
Original line number 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.qualifiers.Background
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.data.repository.KeyguardTransitionRepository
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 kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.launch

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

    @OptIn(FlowPreview::class)
    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 {
                combine(
                        keyguardInteractor.isKeyguardOccluded,
@@ -163,41 +168,21 @@ constructor(
        }
    }

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

        scope.launch {
            keyguardInteractor.isDreaming
                .filter { !it }
                .sample(deviceEntryInteractor.isUnlocked, ::Pair)
                .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"
                        )
                    }
                }
            keyguardOcclusionInteractor.isShowWhenLockedActivityOnTop
                .filterRelevantKeyguardStateAnd { onTop -> !onTop }
                .collect { startTransitionTo(KeyguardState.LOCKSCREEN) }
        }
    }

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

        if (KeyguardWmStateRefactor.isEnabled) {
            return
        }

        // TODO(b/336576536): Check if adaptation for scene framework is needed
        if (SceneContainerFlag.isEnabled) return
        scope.launch {
            keyguardInteractor.isAbleToDream
                .sampleCombine(
Loading