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

Commit d553f16a authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

Hide the alternate bouncer after dismiss actions have run

If we hide the alternate bouncer too early, then
sometimes the dismiss action intent will fail. This
CL moves the logic for hiding the alternate bouncer
after a successful biometric auth to when the keyguard
transition to gone is finished.

Flag: None
Flag: ACONFIG com.android.systemui.device_entry_udfps_refactor TEAMFOOD
Bug: 327570518
Test: test with and without udfps_refactor enabled
Test: atest StatusBarKeyguardViewManagerTest AlternateBouncerViewModelTest
Change-Id: I24c98eeec6c76f777033be88ee2d0d54d31e71f4
parent 4127d641
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -93,6 +93,8 @@ constructor(
    val keyguardAuthenticatedPrimaryAuth: Flow<Int> = repository.keyguardAuthenticatedPrimaryAuth
    val keyguardAuthenticatedPrimaryAuth: Flow<Int> = repository.keyguardAuthenticatedPrimaryAuth
    val keyguardAuthenticatedBiometrics: Flow<Boolean> =
    val keyguardAuthenticatedBiometrics: Flow<Boolean> =
        repository.keyguardAuthenticatedBiometrics.filterNotNull()
        repository.keyguardAuthenticatedBiometrics.filterNotNull()
    val keyguardAuthenticatedBiometricsHandled: Flow<Unit> =
        repository.keyguardAuthenticatedBiometrics.filter { it == null }.map {}
    val userRequestedBouncerWhenAlreadyAuthenticated: Flow<Int> =
    val userRequestedBouncerWhenAlreadyAuthenticated: Flow<Int> =
        repository.userRequestedBouncerWhenAlreadyAuthenticated.filterNotNull()
        repository.userRequestedBouncerWhenAlreadyAuthenticated.filterNotNull()
    val isShowing: StateFlow<Boolean> = repository.primaryBouncerShow
    val isShowing: StateFlow<Boolean> = repository.primaryBouncerShow
+2 −0
Original line number Original line Diff line number Diff line
@@ -23,12 +23,14 @@ import com.android.systemui.bouncer.shared.model.BouncerShowMessageModel
import com.android.systemui.bouncer.ui.BouncerView
import com.android.systemui.bouncer.ui.BouncerView
import com.android.systemui.bouncer.ui.BouncerViewDelegate
import com.android.systemui.bouncer.ui.BouncerViewDelegate
import javax.inject.Inject
import javax.inject.Inject
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge
import kotlinx.coroutines.flow.merge


/** Models UI state for the lock screen bouncer; handles user input. */
/** Models UI state for the lock screen bouncer; handles user input. */
@ExperimentalCoroutinesApi
class KeyguardBouncerViewModel
class KeyguardBouncerViewModel
@Inject
@Inject
constructor(
constructor(
+7 −0
Original line number Original line Diff line number Diff line
@@ -102,9 +102,16 @@ object AlternateBouncerViewBinder {


                launch {
                launch {
                    viewModel.scrimAlpha.collect {
                    viewModel.scrimAlpha.collect {
                        val wasVisible = alternateBouncerViewContainer.visibility == View.VISIBLE
                        alternateBouncerViewContainer.visibility =
                        alternateBouncerViewContainer.visibility =
                            if (it < .1f) View.INVISIBLE else View.VISIBLE
                            if (it < .1f) View.INVISIBLE else View.VISIBLE
                        scrim.viewAlpha = it
                        scrim.viewAlpha = it
                        if (
                            wasVisible && alternateBouncerViewContainer.visibility == View.INVISIBLE
                        ) {
                            // view is no longer visible
                            viewModel.hideAlternateBouncer()
                        }
                    }
                    }
                }
                }


+4 −0
Original line number Original line Diff line number Diff line
@@ -89,4 +89,8 @@ constructor(
    fun showPrimaryBouncer() {
    fun showPrimaryBouncer() {
        statusBarKeyguardViewManager.showPrimaryBouncer(/* scrimmed */ true)
        statusBarKeyguardViewManager.showPrimaryBouncer(/* scrimmed */ true)
    }
    }

    fun hideAlternateBouncer() {
        statusBarKeyguardViewManager.hideAlternateBouncer(false)
    }
}
}
+44 −1
Original line number Original line Diff line number Diff line
@@ -76,6 +76,8 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInterac
import com.android.systemui.keyguard.domain.interactor.WindowManagerLockscreenVisibilityInteractor;
import com.android.systemui.keyguard.domain.interactor.WindowManagerLockscreenVisibilityInteractor;
import com.android.systemui.keyguard.shared.model.DismissAction;
import com.android.systemui.keyguard.shared.model.DismissAction;
import com.android.systemui.keyguard.shared.model.KeyguardDone;
import com.android.systemui.keyguard.shared.model.KeyguardDone;
import com.android.systemui.keyguard.shared.model.KeyguardState;
import com.android.systemui.keyguard.shared.model.TransitionStep;
import com.android.systemui.navigationbar.NavigationBarView;
import com.android.systemui.navigationbar.NavigationBarView;
import com.android.systemui.navigationbar.NavigationModeController;
import com.android.systemui.navigationbar.NavigationModeController;
import com.android.systemui.navigationbar.TaskbarDelegate;
import com.android.systemui.navigationbar.TaskbarDelegate;
@@ -105,6 +107,8 @@ import com.android.systemui.util.kotlin.JavaAdapter;


import dagger.Lazy;
import dagger.Lazy;


import kotlin.Unit;

import java.io.PrintWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.HashSet;
@@ -116,6 +120,7 @@ import javax.inject.Inject;


import kotlinx.coroutines.CoroutineDispatcher;
import kotlinx.coroutines.CoroutineDispatcher;
import kotlinx.coroutines.ExperimentalCoroutinesApi;
import kotlinx.coroutines.ExperimentalCoroutinesApi;
import kotlinx.coroutines.Job;


/**
/**
 * Manages creating, showing, hiding and resetting the keyguard within the status bar. Calls back
 * Manages creating, showing, hiding and resetting the keyguard within the status bar. Calls back
@@ -163,6 +168,9 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
    private final Lazy<ShadeController> mShadeController;
    private final Lazy<ShadeController> mShadeController;
    private final Lazy<SceneInteractor> mSceneInteractorLazy;
    private final Lazy<SceneInteractor> mSceneInteractorLazy;


    private Job mListenForAlternateBouncerTransitionSteps = null;
    private Job mListenForKeyguardAuthenticatedBiometricsHandled = null;

    // Local cache of expansion events, to avoid duplicates
    // Local cache of expansion events, to avoid duplicates
    private float mFraction = -1f;
    private float mFraction = -1f;
    private boolean mTracking = false;
    private boolean mTracking = false;
@@ -491,6 +499,26 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
            mDockManager.addListener(mDockEventListener);
            mDockManager.addListener(mDockEventListener);
            mIsDocked = mDockManager.isDocked();
            mIsDocked = mDockManager.isDocked();
        }
        }
        if (mListenForAlternateBouncerTransitionSteps != null) {
            mListenForAlternateBouncerTransitionSteps.cancel(null);
        }
        mListenForAlternateBouncerTransitionSteps = null;
        if (mListenForKeyguardAuthenticatedBiometricsHandled != null) {
            mListenForKeyguardAuthenticatedBiometricsHandled.cancel(null);
        }
        mListenForKeyguardAuthenticatedBiometricsHandled = null;
        if (!DeviceEntryUdfpsRefactor.isEnabled()) {
            mListenForAlternateBouncerTransitionSteps = mJavaAdapter.alwaysCollectFlow(
                    mKeyguardTransitionInteractor.transitionStepsFromState(
                            KeyguardState.ALTERNATE_BOUNCER),
                    this::consumeFromAlternateBouncerTransitionSteps
            );

            mListenForKeyguardAuthenticatedBiometricsHandled = mJavaAdapter.alwaysCollectFlow(
                    mPrimaryBouncerInteractor.getKeyguardAuthenticatedBiometricsHandled(),
                    this::consumeKeyguardAuthenticatedBiometricsHandled
            );
        }


        if (KeyguardWmStateRefactor.isEnabled()) {
        if (KeyguardWmStateRefactor.isEnabled()) {
            // Show the keyguard views whenever we've told WM that the lockscreen is visible.
            // Show the keyguard views whenever we've told WM that the lockscreen is visible.
@@ -514,6 +542,22 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
        }
        }
    }
    }


    @VisibleForTesting
    void consumeFromAlternateBouncerTransitionSteps(TransitionStep step) {
        hideAlternateBouncer(false);
    }

    /**
     * Required without fix for b/328643370: missing AlternateBouncer (when occluded) => Gone
     * transition.
     */
    @VisibleForTesting
    void consumeKeyguardAuthenticatedBiometricsHandled(Unit handled) {
        if (mAlternateBouncerInteractor.isVisibleState()) {
            hideAlternateBouncer(false);
        }
    }

    private void consumeShowStatusBarKeyguardView(boolean show) {
    private void consumeShowStatusBarKeyguardView(boolean show) {
        if (show != mLastShowing) {
        if (show != mLastShowing) {
            if (show) {
            if (show) {
@@ -1458,7 +1502,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
        mPrimaryBouncerInteractor.notifyKeyguardAuthenticatedBiometrics(strongAuth);
        mPrimaryBouncerInteractor.notifyKeyguardAuthenticatedBiometrics(strongAuth);


        if (mAlternateBouncerInteractor.isVisibleState()) {
        if (mAlternateBouncerInteractor.isVisibleState()) {
            hideAlternateBouncer(false);
            executeAfterKeyguardGoneAction();
            executeAfterKeyguardGoneAction();
        }
        }


Loading