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

Commit 9f3dc638 authored by Milton Wu's avatar Milton Wu Committed by Android (Google) Code Review
Browse files

Merge "Add sensor type into UdfpsOverlayParams" into main

parents 083a693d 5b8748c5
Loading
Loading
Loading
Loading
+14 −8
Original line number Diff line number Diff line
@@ -496,7 +496,8 @@ public class UdfpsControllerTest extends SysuiTestCase {
        final float[] scaleFactor = new float[]{1f, displayHeight[1] / (float) displayHeight[0]};
        final int[] rotation = new int[]{Surface.ROTATION_0, Surface.ROTATION_90};
        final UdfpsOverlayParams oldParams = new UdfpsOverlayParams(sensorBounds[0],
                sensorBounds[0], displayWidth[0], displayHeight[0], scaleFactor[0], rotation[0]);
                sensorBounds[0], displayWidth[0], displayHeight[0], scaleFactor[0], rotation[0],
                FingerprintSensorProperties.TYPE_UDFPS_OPTICAL);

        for (int i1 = 0; i1 <= 1; ++i1) {
            for (int i2 = 0; i2 <= 1; ++i2) {
@@ -505,7 +506,8 @@ public class UdfpsControllerTest extends SysuiTestCase {
                        for (int i5 = 0; i5 <= 1; ++i5) {
                            final UdfpsOverlayParams newParams = new UdfpsOverlayParams(
                                    sensorBounds[i1], sensorBounds[i1], displayWidth[i2],
                                    displayHeight[i3], scaleFactor[i4], rotation[i5]);
                                    displayHeight[i3], scaleFactor[i4], rotation[i5],
                                    FingerprintSensorProperties.TYPE_UDFPS_OPTICAL);

                            if (newParams.equals(oldParams)) {
                                continue;
@@ -549,7 +551,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
        // Initialize the overlay.
        mUdfpsController.updateOverlayParams(mOpticalProps,
                new UdfpsOverlayParams(sensorBounds, sensorBounds, displayWidth, displayHeight,
                        scaleFactor, rotation));
                        scaleFactor, rotation, FingerprintSensorProperties.TYPE_UDFPS_OPTICAL));

        // Show the overlay.
        mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, mOpticalProps.sensorId,
@@ -560,7 +562,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
        // Update overlay with the same parameters.
        mUdfpsController.updateOverlayParams(mOpticalProps,
                new UdfpsOverlayParams(sensorBounds, sensorBounds, displayWidth, displayHeight,
                        scaleFactor, rotation));
                        scaleFactor, rotation, FingerprintSensorProperties.TYPE_UDFPS_OPTICAL));
        mFgExecutor.runAllReady();

        // Ensure the overlay was not recreated.
@@ -642,7 +644,8 @@ public class UdfpsControllerTest extends SysuiTestCase {
        // Test ROTATION_0
        mUdfpsController.updateOverlayParams(testParams.sensorProps,
                new UdfpsOverlayParams(sensorBounds, sensorBounds, displayWidth, displayHeight,
                        scaleFactor, Surface.ROTATION_0));
                        scaleFactor, Surface.ROTATION_0,
                        FingerprintSensorProperties.TYPE_UDFPS_OPTICAL));
        MotionEvent event = obtainMotionEvent(ACTION_DOWN, displayWidth, displayHeight, touchMinor,
                touchMajor);
        mTouchListenerCaptor.getValue().onTouch(mUdfpsView, event);
@@ -657,7 +660,8 @@ public class UdfpsControllerTest extends SysuiTestCase {
        reset(mFingerprintManager);
        mUdfpsController.updateOverlayParams(testParams.sensorProps,
                new UdfpsOverlayParams(sensorBounds, sensorBounds, displayWidth, displayHeight,
                        scaleFactor, Surface.ROTATION_90));
                        scaleFactor, Surface.ROTATION_90,
                        FingerprintSensorProperties.TYPE_UDFPS_OPTICAL));
        event = obtainMotionEvent(ACTION_DOWN, displayHeight, 0, touchMinor, touchMajor);
        mTouchListenerCaptor.getValue().onTouch(mUdfpsView, event);
        mBiometricExecutor.runAllReady();
@@ -671,7 +675,8 @@ public class UdfpsControllerTest extends SysuiTestCase {
        reset(mFingerprintManager);
        mUdfpsController.updateOverlayParams(testParams.sensorProps,
                new UdfpsOverlayParams(sensorBounds, sensorBounds, displayWidth, displayHeight,
                        scaleFactor, Surface.ROTATION_270));
                        scaleFactor, Surface.ROTATION_270,
                        FingerprintSensorProperties.TYPE_UDFPS_OPTICAL));
        event = obtainMotionEvent(ACTION_DOWN, 0, displayWidth, touchMinor, touchMajor);
        mTouchListenerCaptor.getValue().onTouch(mUdfpsView, event);
        mBiometricExecutor.runAllReady();
@@ -685,7 +690,8 @@ public class UdfpsControllerTest extends SysuiTestCase {
        reset(mFingerprintManager);
        mUdfpsController.updateOverlayParams(testParams.sensorProps,
                new UdfpsOverlayParams(sensorBounds, sensorBounds, displayWidth, displayHeight,
                        scaleFactor, Surface.ROTATION_180));
                        scaleFactor, Surface.ROTATION_180,
                        FingerprintSensorProperties.TYPE_UDFPS_OPTICAL));
        // ROTATION_180 is not supported. It should be treated like ROTATION_0.
        event = obtainMotionEvent(ACTION_DOWN, displayWidth, displayHeight, touchMinor, touchMajor);
        mTouchListenerCaptor.getValue().onTouch(mUdfpsView, event);
+6 −1
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package com.android.systemui.biometrics.shared.model

import android.graphics.Rect
import android.hardware.fingerprint.FingerprintSensorProperties.SensorType
import android.hardware.fingerprint.FingerprintSensorProperties.TYPE_UDFPS_OPTICAL
import android.view.Surface
import android.view.Surface.Rotation

@@ -39,6 +41,8 @@ import android.view.Surface.Rotation
 * the native resolution.
 *
 * [rotation] current rotation of the display.
 *
 * [sensorType] fingerprint sensor type
 */
data class UdfpsOverlayParams(
    val sensorBounds: Rect = Rect(),
@@ -46,7 +50,8 @@ data class UdfpsOverlayParams(
    val naturalDisplayWidth: Int = 0,
    val naturalDisplayHeight: Int = 0,
    val scaleFactor: Float = 1f,
    @Rotation val rotation: Int = Surface.ROTATION_0
    @Rotation val rotation: Int = Surface.ROTATION_0,
    @SensorType val sensorType: Int = TYPE_UDFPS_OPTICAL
) {

    /** Same as [sensorBounds], but in native resolution. */
+2 −1
Original line number Diff line number Diff line
@@ -868,7 +868,8 @@ public class AuthController implements
                    mCachedDisplayInfo.getNaturalWidth(),
                    mCachedDisplayInfo.getNaturalHeight(),
                    mScaleFactor,
                    mCachedDisplayInfo.rotation);
                    mCachedDisplayInfo.rotation,
                    udfpsProp.sensorType);

            mUdfpsController.updateOverlayParams(udfpsProp, mUdfpsOverlayParams);
            if (!Objects.equals(previousUdfpsBounds, mUdfpsBounds) || !Objects.equals(
+25 −12
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertThat;

import android.content.res.Resources;
import android.graphics.Rect;
import android.hardware.fingerprint.FingerprintSensorProperties;
import android.view.Surface;

import androidx.test.filters.SmallTest;
@@ -63,28 +64,32 @@ public class UdfpsUtilsTest extends SysuiTestCase {
        assertThat(
                mUdfpsUtils.onTouchOutsideOfSensorArea(true, mContext,
                        0 /* touchX */, 0/* touchY */,
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation)
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation,
                                FingerprintSensorProperties.TYPE_UDFPS_OPTICAL)
                )
        ).isEqualTo(mTouchHints[0]);
        // touch at 90 degrees
        assertThat(
                mUdfpsUtils.onTouchOutsideOfSensorArea(true, mContext,
                        0 /* touchX */, -1/* touchY */,
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation)
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation,
                                FingerprintSensorProperties.TYPE_UDFPS_OPTICAL)
                )
        ).isEqualTo(mTouchHints[1]);
        // touch at 180 degrees
        assertThat(
                mUdfpsUtils.onTouchOutsideOfSensorArea(true, mContext,
                        -1 /* touchX */, 0/* touchY */,
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation)
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation,
                                FingerprintSensorProperties.TYPE_UDFPS_OPTICAL)
                )
        ).isEqualTo(mTouchHints[2]);
        // touch at 270 degrees
        assertThat(
                mUdfpsUtils.onTouchOutsideOfSensorArea(true, mContext,
                        0 /* touchX */, 1/* touchY */,
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation)
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation,
                                FingerprintSensorProperties.TYPE_UDFPS_OPTICAL)
                )
        ).isEqualTo(mTouchHints[3]);
    }
@@ -97,28 +102,32 @@ public class UdfpsUtilsTest extends SysuiTestCase {
        assertThat(
                mUdfpsUtils.onTouchOutsideOfSensorArea(true, mContext,
                        0 /* touchX */, 0 /* touchY */,
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation)
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation,
                                FingerprintSensorProperties.TYPE_UDFPS_OPTICAL)
                )
        ).isEqualTo(mTouchHints[1]);
        // touch at 90 degrees -> 180 degrees
        assertThat(
                mUdfpsUtils.onTouchOutsideOfSensorArea(true, mContext,
                        0 /* touchX */, -1 /* touchY */,
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation)
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation,
                                FingerprintSensorProperties.TYPE_UDFPS_OPTICAL)
                )
        ).isEqualTo(mTouchHints[2]);
        // touch at 180 degrees -> 270 degrees
        assertThat(
                mUdfpsUtils.onTouchOutsideOfSensorArea(true, mContext,
                        -1 /* touchX */, 0 /* touchY */,
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation)
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation,
                                FingerprintSensorProperties.TYPE_UDFPS_OPTICAL)
                )
        ).isEqualTo(mTouchHints[3]);
        // touch at 270 degrees -> 0 degrees
        assertThat(
                mUdfpsUtils.onTouchOutsideOfSensorArea(true, mContext,
                        0 /* touchX */, 1/* touchY */,
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation)
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation,
                                FingerprintSensorProperties.TYPE_UDFPS_OPTICAL)
                )
        ).isEqualTo(mTouchHints[0]);
    }
@@ -131,28 +140,32 @@ public class UdfpsUtilsTest extends SysuiTestCase {
        assertThat(
                mUdfpsUtils.onTouchOutsideOfSensorArea(true, mContext,
                        0 /* touchX */, 0/* touchY */,
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation)
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation,
                                FingerprintSensorProperties.TYPE_UDFPS_OPTICAL)
                )
        ).isEqualTo(mTouchHints[3]);
        // touch at 90 degrees -> 0 degrees
        assertThat(
                mUdfpsUtils.onTouchOutsideOfSensorArea(true, mContext,
                        0 /* touchX */, -1/* touchY */,
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation)
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation,
                                FingerprintSensorProperties.TYPE_UDFPS_OPTICAL)
                )
        ).isEqualTo(mTouchHints[0]);
        // touch at 180 degrees -> 90 degrees
        assertThat(
                mUdfpsUtils.onTouchOutsideOfSensorArea(true, mContext,
                        -1 /* touchX */, 0/* touchY */,
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation)
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation,
                                FingerprintSensorProperties.TYPE_UDFPS_OPTICAL)
                )
        ).isEqualTo(mTouchHints[1]);
        // touch at 270 degrees -> 180 degrees
        assertThat(
                mUdfpsUtils.onTouchOutsideOfSensorArea(true, mContext,
                        0 /* touchX */, 1/* touchY */,
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation)
                        new UdfpsOverlayParams(new Rect(), new Rect(), 0, 0, 1f, rotation,
                                FingerprintSensorProperties.TYPE_UDFPS_OPTICAL)
                )
        ).isEqualTo(mTouchHints[2]);
    }