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

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

Merge "Change usages of SceneContainerFlag to ComposeBouncerFlag in...

Merge "Change usages of SceneContainerFlag to ComposeBouncerFlag in KeyguardDismissActionInteractor" into main
parents ef8c6a24 37b6764f
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.bouncer.shared.flag

import com.android.systemui.Flags
import com.android.systemui.flags.RefactorFlagUtils
import com.android.systemui.scene.shared.flag.SceneContainerFlag

object ComposeBouncerFlags {
@@ -33,6 +34,18 @@ object ComposeBouncerFlags {
        return SceneContainerFlag.isEnabled || Flags.composeBouncer()
    }

    /**
     * Called to ensure code is only run when the flag is enabled. This protects users from the
     * unintended behaviors caused by accidentally running new logic, while also crashing on an eng
     * build to ensure that the refactor author catches issues in testing.
     */
    @JvmStatic
    fun isUnexpectedlyInLegacyMode() =
        RefactorFlagUtils.isUnexpectedlyInLegacyMode(
            isEnabled,
            "SceneContainerFlag || ComposeBouncerFlag"
        )

    /**
     * Returns `true` if only compose bouncer is enabled and scene container framework is not
     * enabled.
+3 −15
Original line number Diff line number Diff line
@@ -47,21 +47,9 @@ constructor(
            launch {
                authenticationInteractor.onAuthenticationResult.collect { authenticationSucceeded ->
                    if (authenticationSucceeded) {
                        // Some dismiss actions require that keyguard be dismissed right away or
                        // deferred until something else later on dismisses keyguard (eg. end of
                        // a hide animation).
                        val deferKeyguardDone =
                            legacyInteractor.bouncerDismissAction?.onDismissAction?.onDismiss()
                        legacyInteractor.setDismissAction(null, null)

                        viewMediatorCallback?.let {
                            val selectedUserId = selectedUserInteractor.getSelectedUserId()
                            if (deferKeyguardDone == true) {
                                it.keyguardDonePending(selectedUserId)
                            } else {
                                it.keyguardDone(selectedUserId)
                            }
                        }
                        legacyInteractor.notifyKeyguardAuthenticatedPrimaryAuth(
                            selectedUserInteractor.getSelectedUserId()
                        )
                    }
                }
            }
+4 −4
Original line number Diff line number Diff line
@@ -164,7 +164,7 @@ constructor(
    }

    fun runAfterKeyguardGone(runnable: Runnable) {
        if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return
        if (ComposeBouncerFlags.isUnexpectedlyInLegacyMode()) return
        setDismissAction(
            DismissAction.RunAfterKeyguardGone(
                dismissAction = { runnable.run() },
@@ -176,18 +176,18 @@ constructor(
    }

    fun setDismissAction(dismissAction: DismissAction) {
        if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return
        if (ComposeBouncerFlags.isUnexpectedlyInLegacyMode()) return
        repository.dismissAction.value.onCancelAction.run()
        repository.setDismissAction(dismissAction)
    }

    fun handleDismissAction() {
        if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return
        if (ComposeBouncerFlags.isUnexpectedlyInLegacyMode()) return
        repository.setDismissAction(DismissAction.None)
    }

    suspend fun setKeyguardDone(keyguardDoneTiming: KeyguardDone) {
        if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return
        if (ComposeBouncerFlags.isUnexpectedlyInLegacyMode()) return
        dismissInteractor.setKeyguardDone(keyguardDoneTiming)
    }
}