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

Commit 7a6e4eb5 authored by Austin Delgado's avatar Austin Delgado
Browse files

Add credential to fallback options transition

Test: atest com.android.biometrics.bp_fallback_options
Flag: android.hardware.biometrics.bp_fallback_options
Bug: 391410353

Change-Id: I0c95e9c3e49d9f38bea73d8254e12b0a84b793a7
parent ff02350e
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -718,7 +718,11 @@ private fun AuthContainerView.hasBiometricPrompt() =
    (findViewById<ScrollView>(R.id.biometric_scrollview)?.childCount ?: 0) > 0

private fun AuthContainerView.hasCredentialView() =
    if (Flags.bpFallbackOptions()) {
        (findViewById<View>(R.id.credential_view)?.visibility ?: View.GONE) == View.VISIBLE
    } else {
        hasCredentialPatternView() || hasCredentialPasswordView()
    }

private fun AuthContainerView.hasCredentialPatternView() =
    findViewById<View>(R.id.lockPattern) != null
+10 −0
Original line number Diff line number Diff line
@@ -48,6 +48,16 @@
        app:layout_constraintTop_toTopOf="@+id/topGuideline"
        app:layout_constraintVertical_bias="1.0" />

    <FrameLayout
        android:id="@+id/credential_view"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:visibility="gone"
        app:layout_constraintTop_toTopOf="@id/panel"
        app:layout_constraintBottom_toBottomOf="@id/panel"
        app:layout_constraintStart_toStartOf="@id/panel"
        app:layout_constraintEnd_toEndOf="@id/panel" />

    <com.android.systemui.deviceentry.ui.view.UdfpsAccessibilityOverlay
        android:id="@+id/biometric_prompt_udfps_accessibility_overlay"
        android:layout_width="0dp"
+10 −0
Original line number Diff line number Diff line
@@ -51,6 +51,16 @@ android:layout_height="match_parent">
        app:layout_constraintTop_toTopOf="@+id/topGuideline"
        app:layout_constraintVertical_bias="1.0" />

    <FrameLayout
        android:id="@+id/credential_view"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:visibility="gone"
        app:layout_constraintTop_toTopOf="@id/panel"
        app:layout_constraintBottom_toBottomOf="@id/panel"
        app:layout_constraintStart_toStartOf="@id/panel"
        app:layout_constraintEnd_toEndOf="@id/panel" />

    <com.android.systemui.deviceentry.ui.view.UdfpsAccessibilityOverlay
        android:id="@+id/biometric_prompt_udfps_accessibility_overlay"
        android:layout_width="0dp"
+26 −17
Original line number Diff line number Diff line
@@ -221,9 +221,9 @@ public class AuthContainerView extends LinearLayout
        @Override
        public void onUseDeviceCredential() {
            mConfig.mCallback.onDeviceCredentialPressed(getRequestId());
            addCredentialView(false /* animatePanel */, true /* animateContents */);

            if (!Flags.bpFallbackOptions()) {
                addCredentialView(false /* animatePanel */, true /* animateContents */);
                // TODO(b/313469218): Remove Config
                mConfig.mPromptInfo.setAuthenticators(
                        BiometricManager.Authenticators.DEVICE_CREDENTIAL);
@@ -265,7 +265,6 @@ public class AuthContainerView extends LinearLayout
            animateAway(BiometricPrompt.DISMISSED_REASON_CREDENTIAL_CONFIRMED);
        } else if (Flags.bpFallbackOptions()) {
            mPromptSelectorInteractorProvider.get().onSwitchToAuth();
            removeCredentialView();
            mConfig.mCallback.onResumeAuthentication(getRequestId());
        }
    }
@@ -357,7 +356,7 @@ public class AuthContainerView extends LinearLayout

        final LayoutInflater layoutInflater = LayoutInflater.from(mContext);
        final PromptKind kind = mPromptViewModel.getPromptKind().getValue();
        if (kind.isBiometric()) {
        if (kind.isBiometric() || Flags.bpFallbackOptions()) {
            if (kind.isTwoPaneLandscapeBiometric()) {
                mLayout = (ConstraintLayout) layoutInflater.inflate(
                        R.layout.biometric_prompt_two_pane_layout, this, false /* attachToRoot */);
@@ -396,7 +395,10 @@ public class AuthContainerView extends LinearLayout

    private void showPrompt(@NonNull PromptViewModel viewModel,
            @NonNull VibratorHelper vibratorHelper) {
        if (mPromptViewModel.getPromptKind().getValue().isBiometric()) {
        if (Flags.bpFallbackOptions()) {
            addBiometricView(viewModel, vibratorHelper);
            addCredentialView(false, false);
        } else if (mPromptViewModel.getPromptKind().getValue().isBiometric()) {
            addBiometricView(viewModel, vibratorHelper);
        } else if (mPromptViewModel.getPromptKind().getValue().isCredential()) {
            addCredentialView(true, false);
@@ -452,8 +454,15 @@ public class AuthContainerView extends LinearLayout
        }
        // TODO(b/288175645): Once AuthContainerView is removed, set 0dp in credential view xml
        //  files with the corresponding left/right or top/bottom constraints being set to "parent".
        if (Flags.bpFallbackOptions()) {
            final FrameLayout credentialView = mLayout.findViewById(R.id.credential_view);
            mCredentialView = factory.inflate(layoutResourceId, credentialView, false);
            final CredentialViewModel vm = mCredentialViewModelProvider.get();
            ((CredentialView) mCredentialView).init(vm, this, mPanelController, false,
                    mBiometricCallback, mAuthContextPlugins);
            credentialView.addView(mCredentialView);
        } else {
            mCredentialView = factory.inflate(layoutResourceId, mLayout, false);

            // The background is used for detecting taps / cancelling authentication. Since the
            // credential view is full-screen and should not be canceled from background taps,
            // disable it.
@@ -463,9 +472,9 @@ public class AuthContainerView extends LinearLayout
            vm.setAnimateContents(animateContents);
            ((CredentialView) mCredentialView).init(vm, this, mPanelController, animatePanel,
                    mBiometricCallback, mAuthContextPlugins);

            mLayout.addView(mCredentialView);
        }
    }

    /** Removes the credential view from the biometric prompt */
    private void removeCredentialView() {
+39 −22
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import androidx.core.view.doOnLayout
import androidx.lifecycle.lifecycleScope
import com.android.app.tracing.coroutines.launchTraced as launch
import com.android.systemui.biometrics.Utils
import com.android.systemui.biometrics.domain.interactor.BiometricPromptView
import com.android.systemui.biometrics.ui.viewmodel.PromptPosition
import com.android.systemui.biometrics.ui.viewmodel.PromptSize
import com.android.systemui.biometrics.ui.viewmodel.PromptViewModel
@@ -103,7 +104,7 @@ object BiometricViewSizeBinder {

        var currentSize: PromptSize? = null
        var currentPosition: PromptPosition = PromptPosition.Bottom
        var fallbackCurrentlyShowing: Boolean = false
        var currentView: BiometricPromptView? = null
        panelView.outlineProvider =
            object : ViewOutlineProvider() {
                override fun getOutline(view: View, outline: Outline) {
@@ -152,6 +153,11 @@ object BiometricViewSizeBinder {
        largeConstraintSet.constrainMaxWidth(R.id.panel, 0)
        largeConstraintSet.setGuidelineBegin(R.id.leftGuideline, 0)
        largeConstraintSet.setGuidelineEnd(R.id.rightGuideline, 0)
        if (Flags.bpFallbackOptions()) {
            largeConstraintSet.setVisibility(R.id.auth_screen, View.GONE)
            largeConstraintSet.setVisibility(R.id.credential_view, View.VISIBLE)
            largeConstraintSet.setVisibility(R.id.fallback_view, View.GONE)
        }

        // TODO: Investigate better way to handle 180 rotations
        val flipConstraintSet = ConstraintSet()
@@ -350,21 +356,23 @@ object BiometricViewSizeBinder {
                    combine(
                            viewModel.position,
                            viewModel.size,
                            viewModel.fallbackShowing,
                            viewModel.currentView,
                            viewModel.hideSensorIcon,
                            ::Quad,
                        )
                        .collect { (position, size, fallbackShowing, hideSensor) ->
                        .collect { (position, size, activeView, hideSensor) ->
                            if (Flags.bpFallbackOptions()) {
                                setVisibilities(hideSensor, size)
                                if (fallbackShowing) {
                                when (activeView) {
                                    BiometricPromptView.FALLBACK -> {
                                        mediumConstraintSet.setVisibility(R.id.auth_screen, View.GONE)
                                        mediumConstraintSet.setVisibility(iconHolderView.id, View.GONE)
                                        mediumConstraintSet.setVisibility(
                                            R.id.fallback_view,
                                            View.VISIBLE,
                                        )
                                } else {
                                    }
                                    BiometricPromptView.BIOMETRIC -> {
                                        mediumConstraintSet.setVisibility(
                                            R.id.auth_screen,
                                            View.VISIBLE,
@@ -375,6 +383,15 @@ object BiometricViewSizeBinder {
                                        )
                                        mediumConstraintSet.setVisibility(R.id.fallback_view, View.GONE)
                                    }
                                    BiometricPromptView.CREDENTIAL -> {
                                        mediumConstraintSet.setVisibility(R.id.auth_screen, View.GONE)
                                        mediumConstraintSet.setVisibility(iconHolderView.id, View.GONE)
                                        mediumConstraintSet.setVisibility(
                                            R.id.fallback_view,
                                            View.GONE,
                                        )
                                    }
                                }
                            }

                            if (position.isLeft) {
@@ -455,7 +472,7 @@ object BiometricViewSizeBinder {
                                    }

                                    // Animate between auth and fallback screen if we just changed
                                    if (fallbackCurrentlyShowing != fallbackShowing) {
                                    if (currentView != activeView) {
                                        val autoTransition = AutoTransition()
                                        autoTransition.setDuration(
                                            ANIMATE_SMALL_TO_MEDIUM_DURATION_MS.toLong()
@@ -483,7 +500,7 @@ object BiometricViewSizeBinder {

                            currentSize = size
                            currentPosition = position
                            fallbackCurrentlyShowing = fallbackShowing
                            currentView = activeView
                            notifyAccessibilityChanged()

                            panelView.invalidateOutline()
Loading