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

Commit 37b6764f authored by Chandru S's avatar Chandru S
Browse files

Change usages of SceneContainerFlag to ComposeBouncerFlag in KeyguardDismissActionInteractor

Other changes:
 - Removes code that is not needed anymore to run dismiss actions

Bug: 310005730
Test: 1. Lock the device
 2. Tap on a notification that will launch an app
 3. bouncer should show up
 4. after authentication, lockscreen should be dismissed and the app should be launched.
Flag: com.android.systemui.compose_bouncer
Change-Id: Ie7b134ca8747a73e7a114d9c4b5d935591dca1af
parent d2ec7794
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)
    }
}