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

Commit 6a7992b9 authored by Kevin Chyn's avatar Kevin Chyn Committed by Android (Google) Code Review
Browse files

Merge "Add sensorLocationX/Y and sensorRadius to SensorProps"

parents 286c33a5 cf22a0bc
Loading
Loading
Loading
Loading
+31 −2
Original line number Diff line number Diff line
@@ -28,11 +28,40 @@ import android.os.Parcel;
 * @hide
 */
public class FingerprintSensorPropertiesInternal extends SensorPropertiesInternal {
    /**
     * See {@link FingerprintSensorProperties.SensorType}.
     */
    public final @FingerprintSensorProperties.SensorType int sensorType;
    // IBiometricsFingerprint@2.1 does not manage timeout below the HAL, so the Gatekeeper HAT
    // cannot be checked

    /**
     * IBiometricsFingerprint@2.1 does not manage timeout below the HAL, so the Gatekeeper HAT
     * cannot be checked
     */
    public final boolean resetLockoutRequiresHardwareAuthToken;

    /**
     * The location of the center of the sensor if applicable. For example, sensors of type
     * {@link FingerprintSensorProperties#TYPE_UDFPS_OPTICAL} would report this value as the
     * distance in pixels, measured from the left edge of the screen.
     * TODO: Value should be provided from the HAL
     */
    public final int sensorLocationX = 540;

    /**
     * The location of the center of the sensor if applicable. For example, sensors of type
     * {@link FingerprintSensorProperties#TYPE_UDFPS_OPTICAL} would report this value as the
     * distance in pixels, measured from the top edge of the screen.
     * TODO: Value should be provided from the HAL
     */
    public final int sensorLocationY = 1636;

    /**
     * The radius of the sensor if applicable. For example, sensors of type
     * {@link FingerprintSensorProperties#TYPE_UDFPS_OPTICAL} would report this value as the radius
     * of the sensor, in pixels.
     */
    public final int sensorRadius = 130;

    /**
     * Initializes SensorProperties with specified values
     */
+0 −2
Original line number Diff line number Diff line
@@ -5,6 +5,4 @@
    android:id="@+id/udfps_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    systemui:sensorRadius="130px"
    systemui:sensorCenterY="1636px"
    systemui:sensorTouchAreaCoefficient="0.5"/>
+0 −2
Original line number Diff line number Diff line
@@ -158,8 +158,6 @@
    </declare-styleable>

    <declare-styleable name="UdfpsView">
        <attr name="sensorRadius" format="dimension"/>
        <attr name="sensorCenterY" format="dimension"/>
        <attr name="sensorPressureCoefficient" format="float"/>
        <attr name="sensorTouchAreaCoefficient" format="float"/>
    </declare-styleable>
+17 −13
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ class UdfpsController implements DozeReceiver {
    // Currently the UdfpsController supports a single UDFPS sensor. If devices have multiple
    // sensors, this, in addition to a lot of the code here, will be updated.
    @VisibleForTesting
    final int mUdfpsSensorId;
    final FingerprintSensorPropertiesInternal mSensorProps;
    private final WindowManager mWindowManager;
    private final SystemSettings mSystemSettings;
    private final DelayableExecutor mFgExecutor;
@@ -180,19 +180,12 @@ class UdfpsController implements DozeReceiver {
        mFgExecutor = fgExecutor;
        mLayoutParams = createLayoutParams(context);

        int udfpsSensorId = -1;
        for (FingerprintSensorPropertiesInternal props :
                mFingerprintManager.getSensorPropertiesInternal()) {
            if (props.isAnyUdfpsType()) {
                udfpsSensorId = props.sensorId;
                break;
            }
        }
        mSensorProps = findFirstUdfps();
        // At least one UDFPS sensor exists
        checkArgument(udfpsSensorId != -1);
        mUdfpsSensorId = udfpsSensorId;
        checkArgument(mSensorProps != null);

        mView = (UdfpsView) inflater.inflate(R.layout.udfps_view, null, false);
        mView.setSensorProperties(mSensorProps);

        mHbmPath = resources.getString(R.string.udfps_hbm_sysfs_path);
        mHbmEnableCommand = resources.getString(R.string.udfps_hbm_enable_command);
@@ -235,6 +228,17 @@ class UdfpsController implements DozeReceiver {
        mIsOverlayShowing = false;
    }

    @Nullable
    private FingerprintSensorPropertiesInternal findFirstUdfps() {
        for (FingerprintSensorPropertiesInternal props :
                mFingerprintManager.getSensorPropertiesInternal()) {
            if (props.isAnyUdfpsType()) {
                return props;
            }
        }
        return null;
    }

    @Override
    public void dozeTimeTick() {
        mView.dozeTimeTick();
@@ -374,7 +378,7 @@ class UdfpsController implements DozeReceiver {
                fw.write(mHbmEnableCommand);
                fw.close();
            }
            mFingerprintManager.onPointerDown(mUdfpsSensorId, x, y, minor, major);
            mFingerprintManager.onPointerDown(mSensorProps.sensorId, x, y, minor, major);
        } catch (IOException e) {
            mView.hideScrimAndDot();
            Log.e(TAG, "onFingerDown | failed to enable HBM: " + e.getMessage());
@@ -382,7 +386,7 @@ class UdfpsController implements DozeReceiver {
    }

    private void onFingerUp() {
        mFingerprintManager.onPointerUp(mUdfpsSensorId);
        mFingerprintManager.onPointerUp(mSensorProps.sensorId);
        // Hiding the scrim before disabling HBM results in less noticeable flicker.
        mView.hideScrimAndDot();
        if (mHbmSupported) {
+15 −20
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.biometrics;

import static com.android.systemui.doze.util.BurnInHelperKt.getBurnInOffset;

import android.annotation.NonNull;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
@@ -25,6 +26,7 @@ import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
@@ -55,8 +57,6 @@ public class UdfpsView extends View implements DozeReceiver,

    private final RectF mSensorRect;
    private final Paint mSensorPaint;
    private final float mSensorRadius;
    private final float mSensorCenterY;
    private final float mSensorTouchAreaCoefficient;
    private final int mMaxBurnInOffsetX;
    private final int mMaxBurnInOffsetY;
@@ -64,9 +64,7 @@ public class UdfpsView extends View implements DozeReceiver,
    private final Rect mTouchableRegion;
    private final ViewTreeObserver.OnComputeInternalInsetsListener mInsetsListener;

    // This is calculated from the screen's dimensions at runtime, as opposed to mSensorCenterY,
    // which is defined in layout.xml
    private float mSensorCenterX;
    @NonNull private FingerprintSensorPropertiesInternal mProps;

    // AOD anti-burn-in offsets
    private float mInterpolatedDarkAmount;
@@ -83,18 +81,10 @@ public class UdfpsView extends View implements DozeReceiver,
        TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.UdfpsView, 0,
                0);
        try {
            if (!a.hasValue(R.styleable.UdfpsView_sensorRadius)) {
                throw new IllegalArgumentException("UdfpsView must contain sensorRadius");
            }
            if (!a.hasValue(R.styleable.UdfpsView_sensorCenterY)) {
                throw new IllegalArgumentException("UdfpsView must contain sensorMarginBottom");
            }
            if (!a.hasValue(R.styleable.UdfpsView_sensorTouchAreaCoefficient)) {
                throw new IllegalArgumentException(
                        "UdfpsView must contain sensorTouchAreaCoefficient");
            }
            mSensorRadius = a.getDimension(R.styleable.UdfpsView_sensorRadius, 0f);
            mSensorCenterY = a.getDimension(R.styleable.UdfpsView_sensorCenterY, 0f);
            mSensorTouchAreaCoefficient = a.getFloat(
                    R.styleable.UdfpsView_sensorTouchAreaCoefficient, 0f);
        } finally {
@@ -134,6 +124,10 @@ public class UdfpsView extends View implements DozeReceiver,
        mIsScrimShowing = false;
    }

    void setSensorProperties(@NonNull FingerprintSensorPropertiesInternal properties) {
        mProps = properties;
    }

    @Override
    public void dozeTimeTick() {
        updateAodPosition();
@@ -165,9 +159,10 @@ public class UdfpsView extends View implements DozeReceiver,
        final int h = getLayoutParams().height;
        final int w = getLayoutParams().width;
        mScrimRect.set(0 /* left */, 0 /* top */, w, h);
        mSensorCenterX = w / 2f;
        mSensorRect.set(mSensorCenterX - mSensorRadius, mSensorCenterY - mSensorRadius,
                mSensorCenterX + mSensorRadius, mSensorCenterY + mSensorRadius);
        mSensorRect.set(mProps.sensorLocationX - mProps.sensorRadius,
                mProps.sensorLocationY - mProps.sensorRadius,
                mProps.sensorLocationX + mProps.sensorRadius,
                mProps.sensorLocationY + mProps.sensorRadius);

        // Sets mTouchableRegion with rounded up values from mSensorRect.
        mSensorRect.roundOut(mTouchableRegion);
@@ -211,10 +206,10 @@ public class UdfpsView extends View implements DozeReceiver,
    }

    boolean isValidTouch(float x, float y, float pressure) {
        return x > (mSensorCenterX - mSensorRadius * mSensorTouchAreaCoefficient)
                && x < (mSensorCenterX + mSensorRadius * mSensorTouchAreaCoefficient)
                && y > (mSensorCenterY - mSensorRadius * mSensorTouchAreaCoefficient)
                && y < (mSensorCenterY + mSensorRadius * mSensorTouchAreaCoefficient);
        return x > (mProps.sensorLocationX - mProps.sensorRadius * mSensorTouchAreaCoefficient)
                && x < (mProps.sensorLocationX + mProps.sensorRadius * mSensorTouchAreaCoefficient)
                && y > (mProps.sensorLocationY - mProps.sensorRadius * mSensorTouchAreaCoefficient)
                && y < (mProps.sensorLocationY + mProps.sensorRadius * mSensorTouchAreaCoefficient);
    }

    void setScrimAlpha(int alpha) {
Loading