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

Commit dc1e4a97 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Update Fingerprint21, add Fingerprint21UdfpsMock

1) It may not be practical in all cases to bump the HIDL to
   fingerprint2.3. So, give the framework a way to override this
   parameter.
2) Updates Fingerprint21 so the HAL callback is a static inner class.
   This A) allows subclasses to extend/override its functionality, and
   B) is necessary now because the callback needs to be created prior
   to Fingerprint21 construction (see 3 below)
3) Changes Fingerprint21 so that several objects are created before
   its constructor. This is necessary because Fingerprint21's
   constructor requires usage of the HAL, which implies the callback
   must be ready, since using the HAL requires a valid callback. In
   other words, the callback must be created before
   Fingerprint21UdfpsMock invokes Fingerprint21's constructor.
4) UDFPS accept must be touched within 10s of sensor auth succeeding
5) Shows debug messages on UdfpsOverlay since fingerprint sensor no
   longer gives feedback, etc

Bug: 163864182
Test: adb shell settings put secure ... (see defs in
      Fingerprint21UdfpsMock)
      adb shell stop && adb shell start
Change-Id: I07c3801024087f2e8ef10f125d20cb536aefbd91
parent f3762c7b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -25,4 +25,7 @@ oneway interface IUdfpsOverlayController {

    // Hides the overlay.
    void hideUdfpsOverlay();

    // Shows debug messages on the UDFPS overlay.
    void setDebugMessage(String message);
}
+2 −0
Original line number Diff line number Diff line
@@ -4189,6 +4189,8 @@
    <string-array name="config_biometric_sensors" translatable="false" >
        <!-- <item>0:2:15</item>  ID0:Fingerprint:Strong -->
    </string-array>
    <!--If true, allows the device to load udfps components on older HIDL implementations -->
    <bool name="allow_test_udfps" translatable="false" >false</bool>

    <!-- Messages that should not be shown to the user during face auth enrollment. This should be
         used to hide messages that may be too chatty or messages that the user can't do much about.
+1 −0
Original line number Diff line number Diff line
@@ -2506,6 +2506,7 @@
  <java-symbol type="string" name="face_error_security_update_required" />

  <java-symbol type="array" name="config_biometric_sensors" />
  <java-symbol type="bool" name="allow_test_udfps" />

  <java-symbol type="array" name="config_face_acquire_enroll_ignorelist" />
  <java-symbol type="array" name="config_face_acquire_vendor_enroll_ignorelist" />
+8 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.os.Looper;
import android.os.PowerManager;
import android.os.UserHandle;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.util.MathUtils;
import android.util.Spline;
@@ -85,6 +86,11 @@ class UdfpsController {
        public void hideUdfpsOverlay() {
            UdfpsController.this.hideUdfpsOverlay();
        }

        @Override
        public void setDebugMessage(String message) {
            mView.setDebugMessage(message);
        }
    }

    @SuppressLint("ClickableViewAccessibility")
@@ -129,6 +135,8 @@ class UdfpsController {
        mHbmEnableCommand = context.getResources().getString(R.string.udfps_hbm_enable_command);
        mHbmDisableCommand = context.getResources().getString(R.string.udfps_hbm_disable_command);

        mView.setHbmSupported(!TextUtils.isEmpty(mHbmPath));

        // This range only consists of the minimum and maximum values, which only cover
        // non-high-brightness mode.
        float[] nitsRange = toFloatArray(context.getResources().obtainTypedArray(
+27 −3
Original line number Diff line number Diff line
@@ -37,11 +37,14 @@ public class UdfpsView extends View {
    private static final String TAG = "UdfpsView";

    // Values in pixels.
    private static final float SENSOR_SHADOW_OFFSET = 2.0f;
    private static final float SENSOR_SHADOW_RADIUS = 2.0f;
    private static final float SENSOR_OUTLINE_WIDTH = 2.0f;

    private static final int DEBUG_TEXT_SIZE_PX = 32;

    private final Rect mScrimRect;
    private final Paint mScrimPaint;
    private final Paint mDebugTextPaint;

    private float mSensorX;
    private float mSensorY;
@@ -55,6 +58,8 @@ public class UdfpsView extends View {
    private final ViewTreeObserver.OnComputeInternalInsetsListener mInsetsListener;

    private boolean mIsScrimShowing;
    private boolean mHbmSupported;
    private String mDebugMessage;

    public UdfpsView(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -86,12 +91,18 @@ public class UdfpsView extends View {

        mSensorRect = new RectF();
        mSensorPaint = new Paint(0 /* flags */);
        mSensorPaint.setAntiAlias(true);
        mSensorPaint.setColor(Color.WHITE);
        mSensorPaint.setStyle(Paint.Style.STROKE);
        mSensorPaint.setStrokeWidth(SENSOR_OUTLINE_WIDTH);
        mSensorPaint.setShadowLayer(SENSOR_OUTLINE_WIDTH, 0, 0, Color.BLACK);
        mSensorPaint.setShadowLayer(SENSOR_SHADOW_RADIUS, 0, 0, Color.BLACK);
        mSensorPaint.setAntiAlias(true);

        mDebugTextPaint = new Paint();
        mDebugTextPaint.setAntiAlias(true);
        mDebugTextPaint.setColor(Color.BLUE);
        mDebugTextPaint.setTextSize(DEBUG_TEXT_SIZE_PX);

        mTouchableRegion = new Rect();
        mInsetsListener = internalInsetsInfo -> {
            internalInsetsInfo.setTouchableInsets(
@@ -131,12 +142,25 @@ public class UdfpsView extends View {
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (mIsScrimShowing) {
        if (mIsScrimShowing && mHbmSupported) {
            // Only draw the scrim if HBM is supported.
            canvas.drawRect(mScrimRect, mScrimPaint);
        }

        canvas.drawText(mDebugMessage, 0, 60, mDebugTextPaint);

        canvas.drawOval(mSensorRect, mSensorPaint);
    }

    void setHbmSupported(boolean hbmSupported) {
        mHbmSupported = hbmSupported;
    }

    void setDebugMessage(String message) {
        mDebugMessage = message;
        postInvalidate();
    }

    boolean isValidTouch(float x, float y, float pressure) {
        return x > (mSensorX - mSensorRadius * mSensorTouchAreaCoefficient)
                && x < (mSensorX + mSensorRadius * mSensorTouchAreaCoefficient)
Loading