Fix BiometricPrompt for face + non-UDFPS fingerprint

Currently, the dual-sensor config for BiometricPrompt requires a face
sensor and under-display fingerprint sensor. This commit loosens the
restriction to also accept non-UDFPS fingerprint sensors. The fallback
logic in this case is the same as for face + UDFPS.

Test: Manually verified that BiometricPrompt no longer crashes

Fixes: 185301549
Change-Id: I8d90e8e10ae64adb29f7d3c7ce51004aa7a6f1b8
diff --git a/packages/SystemUI/res/layout/auth_biometric_face_to_udfps_view.xml b/packages/SystemUI/res/layout/auth_biometric_face_to_fingerprint_view.xml
similarity index 86%
rename from packages/SystemUI/res/layout/auth_biometric_face_to_udfps_view.xml
rename to packages/SystemUI/res/layout/auth_biometric_face_to_fingerprint_view.xml
index 87affde..7cf1789 100644
--- a/packages/SystemUI/res/layout/auth_biometric_face_to_udfps_view.xml
+++ b/packages/SystemUI/res/layout/auth_biometric_face_to_fingerprint_view.xml
@@ -14,7 +14,7 @@
   ~ limitations under the License.
   -->
 
-<com.android.systemui.biometrics.AuthBiometricFaceToUdfpsView
+<com.android.systemui.biometrics.AuthBiometricFaceToFingerprintView
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
@@ -22,4 +22,4 @@
 
     <include layout="@layout/auth_biometric_contents"/>
 
-</com.android.systemui.biometrics.AuthBiometricFaceToUdfpsView>
\ No newline at end of file
+</com.android.systemui.biometrics.AuthBiometricFaceToFingerprintView>
\ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthBiometricFaceToUdfpsView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthBiometricFaceToFingerprintView.java
similarity index 83%
rename from packages/SystemUI/src/com/android/systemui/biometrics/AuthBiometricFaceToUdfpsView.java
rename to packages/SystemUI/src/com/android/systemui/biometrics/AuthBiometricFaceToFingerprintView.java
index 197f35b..71260de 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthBiometricFaceToUdfpsView.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthBiometricFaceToFingerprintView.java
@@ -32,12 +32,12 @@
 import com.android.systemui.R;
 
 /**
- * Manages the layout of an auth dialog for devices with a face sensor and an under-display
- * fingerprint sensor (UDFPS). Face authentication is attempted first, followed by fingerprint if
- * the initial attempt is unsuccessful.
+ * Manages the layout of an auth dialog for devices with both a face sensor and a fingerprint
+ * sensor. Face authentication is attempted first, followed by fingerprint if the initial attempt is
+ * unsuccessful.
  */
-public class AuthBiometricFaceToUdfpsView extends AuthBiometricFaceView {
-    private static final String TAG = "BiometricPrompt/AuthBiometricFaceToUdfpsView";
+public class AuthBiometricFaceToFingerprintView extends AuthBiometricFaceView {
+    private static final String TAG = "BiometricPrompt/AuthBiometricFaceToFingerprintView";
 
     protected static class UdfpsIconController extends IconController {
         protected UdfpsIconController(
@@ -87,20 +87,23 @@
 
     @BiometricAuthenticator.Modality private int mActiveSensorType = TYPE_FACE;
 
-    @Nullable UdfpsDialogMeasureAdapter mMeasureAdapter;
-    @Nullable private UdfpsIconController mUdfpsIconController;
+    @Nullable UdfpsDialogMeasureAdapter mUdfpsMeasureAdapter;
 
-    public AuthBiometricFaceToUdfpsView(Context context) {
+    public AuthBiometricFaceToFingerprintView(Context context) {
         super(context);
     }
 
-    public AuthBiometricFaceToUdfpsView(Context context, AttributeSet attrs) {
+    public AuthBiometricFaceToFingerprintView(Context context, AttributeSet attrs) {
         super(context, attrs);
     }
 
     void setFingerprintSensorProps(@NonNull FingerprintSensorPropertiesInternal sensorProps) {
-        if (mMeasureAdapter == null || mMeasureAdapter.getSensorProps() != sensorProps) {
-            mMeasureAdapter = new UdfpsDialogMeasureAdapter(this, sensorProps);
+        if (!sensorProps.isAnyUdfpsType()) {
+            return;
+        }
+
+        if (mUdfpsMeasureAdapter == null || mUdfpsMeasureAdapter.getSensorProps() != sensorProps) {
+            mUdfpsMeasureAdapter = new UdfpsDialogMeasureAdapter(this, sensorProps);
         }
     }
 
@@ -140,8 +143,8 @@
     @NonNull
     AuthDialog.LayoutParams onMeasureInternal(int width, int height) {
         final AuthDialog.LayoutParams layoutParams = super.onMeasureInternal(width, height);
-        return mMeasureAdapter != null
-                ? mMeasureAdapter.onMeasureInternal(width, height, layoutParams)
+        return mUdfpsMeasureAdapter != null
+                ? mUdfpsMeasureAdapter.onMeasureInternal(width, height, layoutParams)
                 : layoutParams;
     }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java
index 72db6cd..9e72310 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java
@@ -348,14 +348,14 @@
                     }
                 }
 
-                if (fingerprintSensorProps != null && fingerprintSensorProps.isAnyUdfpsType()) {
-                    final AuthBiometricFaceToUdfpsView faceToUdfpsView =
-                            (AuthBiometricFaceToUdfpsView) factory.inflate(
-                                    R.layout.auth_biometric_face_to_udfps_view, null, false);
-                    faceToUdfpsView.setFingerprintSensorProps(fingerprintSensorProps);
-                    mBiometricView = faceToUdfpsView;
+                if (fingerprintSensorProps != null) {
+                    final AuthBiometricFaceToFingerprintView faceToFingerprintView =
+                            (AuthBiometricFaceToFingerprintView) factory.inflate(
+                                    R.layout.auth_biometric_face_to_fingerprint_view, null, false);
+                    faceToFingerprintView.setFingerprintSensorProps(fingerprintSensorProps);
+                    mBiometricView = faceToFingerprintView;
                 } else {
-                    Log.e(TAG, "Fingerprint must be UDFPS for dual-sensor config");
+                    Log.e(TAG, "Fingerprint props not found for sensor ID: " + fingerprintSensorId);
                     mBiometricView = null;
                     mBackgroundView = null;
                     mBiometricScrollView = null;