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

Commit 70362fc4 authored by Vincent Wang's avatar Vincent Wang Committed by Automerger Merge Worker
Browse files

Merge "Fix biometric prompt disappeared by itself after rotate 180 degrees"...

Merge "Fix biometric prompt disappeared by itself after rotate 180 degrees" into tm-qpr-dev am: 10813312 am: d30ccf00

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20351207



Change-Id: Ief6fceab7d3d94209e051ce11e1a06b99ee2ea5d
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 25d697a1 d30ccf00
Loading
Loading
Loading
Loading
+6 −11
Original line number Diff line number Diff line
@@ -141,8 +141,7 @@ public class AuthContainerView extends LinearLayout
    private final OnBackInvokedCallback mBackCallback = this::onBackInvoked;

    private final @Background DelayableExecutor mBackgroundExecutor;
    private int mOrientation;
    private boolean mSkipFirstLostFocus = false;
    private boolean mIsOrientationChanged = false;

    // Non-null only if the dialog is in the act of dismissing and has not sent the reason yet.
    @Nullable @AuthDialogCallback.DismissedReason private Integer mPendingCallbackReason;
@@ -491,6 +490,7 @@ public class AuthContainerView extends LinearLayout
    @Override
    public void onOrientationChanged() {
        maybeUpdatePositionForUdfps(true /* invalidate */);
        mIsOrientationChanged = true;
    }

    @Override
@@ -499,8 +499,8 @@ public class AuthContainerView extends LinearLayout
        if (!hasWindowFocus) {
            //it's a workaround to avoid closing BP incorrectly
            //BP gets a onWindowFocusChanged(false) and then gets a onWindowFocusChanged(true)
            if (mSkipFirstLostFocus) {
                mSkipFirstLostFocus = false;
            if (mIsOrientationChanged) {
                mIsOrientationChanged = false;
                return;
            }
            Log.v(TAG, "Lost window focus, dismissing the dialog");
@@ -512,9 +512,6 @@ public class AuthContainerView extends LinearLayout
    public void onAttachedToWindow() {
        super.onAttachedToWindow();

        //save the first orientation
        mOrientation = getResources().getConfiguration().orientation;

        mWakefulnessLifecycle.addObserver(this);

        if (Utils.isBiometricAllowed(mConfig.mPromptInfo)) {
@@ -670,7 +667,7 @@ public class AuthContainerView extends LinearLayout
        }

        if (savedState != null) {
            mSkipFirstLostFocus = savedState.getBoolean(
            mIsOrientationChanged = savedState.getBoolean(
                    AuthDialog.KEY_BIOMETRIC_ORIENTATION_CHANGED);
        }

@@ -764,9 +761,7 @@ public class AuthContainerView extends LinearLayout
                mBiometricView != null && mCredentialView == null);
        outState.putBoolean(AuthDialog.KEY_CREDENTIAL_SHOWING, mCredentialView != null);

        if (mOrientation != getResources().getConfiguration().orientation) {
            outState.putBoolean(AuthDialog.KEY_BIOMETRIC_ORIENTATION_CHANGED, true);
        }
        outState.putBoolean(AuthDialog.KEY_BIOMETRIC_ORIENTATION_CHANGED, mIsOrientationChanged);

        if (mBiometricView != null) {
            mBiometricView.onSaveState(outState);
+19 −0
Original line number Diff line number Diff line
@@ -174,6 +174,25 @@ class AuthContainerViewTest : SysuiTestCase() {
        assertThat(container.parent).isNull()
    }

    @Test
    fun testFocusLossAfterRotating() {
        val container = initializeFingerprintContainer()
        waitForIdleSync()

        val requestID = authContainer?.requestId ?: 0L

        verify(callback).onDialogAnimatedIn(requestID)
        container.onOrientationChanged()
        container.onWindowFocusChanged(false)
        waitForIdleSync()

        verify(callback, never()).onDismissed(
                eq(AuthDialogCallback.DISMISSED_USER_CANCELED),
                eq<ByteArray?>(null), /* credentialAttestation */
                eq(requestID)
        )
    }

    @Test
    fun testDismissesOnFocusLoss_hidesKeyboardWhenVisible() {
        val container = initializeFingerprintContainer(