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

Commit df8a3663 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
Fixes: 327570518
Test: test with and without udfps_refactor enabled
Test: atest StatusBarKeyguardViewManagerTest AlternateBouncerViewModelTest
Change-Id: I24c98eeec6c76f777033be88ee2d0d54d31e71f4
Merged-In: I24c98eeec6c76f777033be88ee2d0d54d31e71f4
(cherry picked from commit d553f16a)
parent ce4f1155
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -93,6 +93,8 @@ constructor(
    val keyguardAuthenticatedPrimaryAuth: Flow<Int> = repository.keyguardAuthenticatedPrimaryAuth
    val keyguardAuthenticatedBiometrics: Flow<Boolean> =
        repository.keyguardAuthenticatedBiometrics.filterNotNull()
    val keyguardAuthenticatedBiometricsHandled: Flow<Unit> =
        repository.keyguardAuthenticatedBiometrics.filter { it == null }.map {}
    val userRequestedBouncerWhenAlreadyAuthenticated: Flow<Int> =
        repository.userRequestedBouncerWhenAlreadyAuthenticated.filterNotNull()
    val isShowing: StateFlow<Boolean> = repository.primaryBouncerShow
+2 −0
Original line number 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.BouncerViewDelegate
import javax.inject.Inject
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge

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

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

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

    fun hideAlternateBouncer() {
        statusBarKeyguardViewManager.hideAlternateBouncer(false)
    }
}
+44 −1
Original line number 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.shared.model.DismissAction;
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.NavigationModeController;
import com.android.systemui.navigationbar.TaskbarDelegate;
@@ -101,6 +103,8 @@ import com.android.systemui.util.kotlin.JavaAdapter;

import dagger.Lazy;

import kotlin.Unit;

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

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

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

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

    // Local cache of expansion events, to avoid duplicates
    private float mFraction = -1f;
    private boolean mTracking = false;
@@ -482,6 +490,26 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
            mDockManager.addListener(mDockEventListener);
            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()) {
            // Show the keyguard views whenever we've told WM that the lockscreen is visible.
@@ -500,6 +528,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) {
        if (show != mLastShowing) {
            if (show) {
@@ -1441,7 +1485,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
        mPrimaryBouncerInteractor.notifyKeyguardAuthenticatedBiometrics(strongAuth);

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