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

Commit dacc5692 authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge "Merge "Add onUdfpsLocationChanged callback" into tm-dev am: f637bd54 am: c97d15f8"

parents 407fe138 0fb4d5ae
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ public class LockIconView extends FrameLayout implements Dumpable {

    @NonNull private final RectF mSensorRect;
    @NonNull private PointF mLockIconCenter = new PointF(0f, 0f);
    private int mRadius;
    private float mRadius;
    private int mLockIconPadding;

    private ImageView mLockIcon;
@@ -126,7 +126,7 @@ public class LockIconView extends FrameLayout implements Dumpable {
     * Set the location of the lock icon.
     */
    @VisibleForTesting
    public void setCenterLocation(@NonNull PointF center, int radius, int drawablePadding) {
    public void setCenterLocation(@NonNull PointF center, float radius, int drawablePadding) {
        mLockIconCenter = center;
        mRadius = radius;
        mLockIconPadding = drawablePadding;
+12 −8
Original line number Diff line number Diff line
@@ -188,6 +188,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
    protected void onViewAttached() {
        updateIsUdfpsEnrolled();
        updateConfiguration();
        updateLockIconLocation();
        updateKeyguardShowing();
        mUserUnlockedWithBiometric = false;

@@ -340,20 +341,17 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
        mHeightPixels = bounds.bottom;
        mBottomPaddingPx = getResources().getDimensionPixelSize(R.dimen.lock_icon_margin_bottom);

        final int defaultPaddingPx =
                getResources().getDimensionPixelSize(R.dimen.lock_icon_padding);
        mScaledPaddingPx = (int) (defaultPaddingPx * mAuthController.getScaleFactor());

        mUnlockedLabel = mView.getContext().getResources().getString(
                R.string.accessibility_unlock_button);
        mLockedLabel = mView.getContext()
                .getResources().getString(R.string.accessibility_lock_icon);

        updateLockIconLocation();
    }

    private void updateLockIconLocation() {
        if (mUdfpsSupported) {
            final int defaultPaddingPx =
                    getResources().getDimensionPixelSize(R.dimen.lock_icon_padding);
            mScaledPaddingPx = (int) (defaultPaddingPx * mAuthController.getScaleFactor());
            mView.setCenterLocation(mAuthController.getUdfpsLocation(),
                    mAuthController.getUdfpsRadius(), mScaledPaddingPx);
        } else {
@@ -362,8 +360,6 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
                        mHeightPixels - mBottomPaddingPx - sLockIconRadiusPx),
                        sLockIconRadiusPx, mScaledPaddingPx);
        }

        mView.getHitRect(mSensorTouchLocation);
    }

    @Override
@@ -386,6 +382,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
        pw.println("  mCanDismissLockScreen: " + mCanDismissLockScreen);
        pw.println("  mStatusBarState: " + StatusBarState.toString(mStatusBarState));
        pw.println("  mInterpolatedDarkAmount: " + mInterpolatedDarkAmount);
        pw.println("  mSensorTouchLocation: " + mSensorTouchLocation);

        if (mView != null) {
            mView.dump(pw, args);
@@ -672,6 +669,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
    }

    private boolean inLockIconArea(MotionEvent event) {
        mView.getHitRect(mSensorTouchLocation);
        return mSensorTouchLocation.contains((int) event.getX(), (int) event.getY())
                && mView.getVisibility() == View.VISIBLE;
    }
@@ -692,6 +690,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
        mExecutor.execute(() -> {
            updateIsUdfpsEnrolled();
            updateConfiguration();
            updateLockIconLocation();
        });
    }

@@ -705,6 +704,11 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
        public void onEnrollmentsChanged() {
            updateUdfpsConfig();
        }

        @Override
        public void onUdfpsLocationChanged() {
            updateLockIconLocation();
        }
    };

    private final View.OnClickListener mA11yClickListener = v -> onLongPress();
+14 −2
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;

import javax.inject.Inject;
@@ -446,11 +447,11 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
    /**
     * @return the radius of UDFPS on the screen in pixels
     */
    public int getUdfpsRadius() {
    public float getUdfpsRadius() {
        if (mUdfpsController == null || mUdfpsBounds == null) {
            return -1;
        }
        return mUdfpsBounds.height() / 2;
        return mUdfpsBounds.height() / 2f;
    }

    /**
@@ -634,11 +635,17 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
                    displayInfo.getNaturalHeight());

            final FingerprintSensorPropertiesInternal udfpsProp = mUdfpsProps.get(0);
            final Rect previousUdfpsBounds = mUdfpsBounds;
            mUdfpsBounds = udfpsProp.getLocation().getRect();
            mUdfpsBounds.scale(scaleFactor);
            mUdfpsController.updateOverlayParams(udfpsProp.sensorId,
                    new UdfpsOverlayParams(mUdfpsBounds, displayInfo.getNaturalWidth(),
                            displayInfo.getNaturalHeight(), scaleFactor, displayInfo.rotation));
            if (!Objects.equals(previousUdfpsBounds, mUdfpsBounds)) {
                for (Callback cb : mCallbacks) {
                    cb.onUdfpsLocationChanged();
                }
            }
        }
    }

@@ -1054,5 +1061,10 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
         * Called when the biometric prompt is no longer showing.
         */
        default void onBiometricPromptDismissed() {}

        /**
         * The location in pixels can change due to resolution changes.
         */
        default void onUdfpsLocationChanged() {}
    }
}
+4 −2
Original line number Diff line number Diff line
@@ -335,15 +335,17 @@ class AuthRippleController @Inject constructor(
                updateSensorLocation()
            }

            override fun onEnrollmentsChanged() {
            override fun onUdfpsLocationChanged() {
                updateUdfpsDependentParams()
                updateSensorLocation()
            }
        }

    private fun updateUdfpsDependentParams() {
        authController.udfpsProps?.let {
            if (it.size > 0) {
                udfpsRadius = it[0].location.sensorRadius.toFloat()
                udfpsController = udfpsControllerProvider.get()
                udfpsRadius = authController.udfpsRadius

                if (mView.isAttachedToWindow) {
                    udfpsController?.addCallback(udfpsControllerCallback)
+7 −24
Original line number Diff line number Diff line
@@ -34,8 +34,6 @@ import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.drawable.AnimatedStateListDrawable;
import android.hardware.biometrics.BiometricSourceType;
import android.hardware.biometrics.SensorLocationInternal;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.util.Pair;
@@ -77,9 +75,6 @@ import org.mockito.MockitoAnnotations;
import org.mockito.MockitoSession;
import org.mockito.quality.Strictness;

import java.util.ArrayList;
import java.util.List;

@SmallTest
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
@@ -182,7 +177,7 @@ public class LockIconViewControllerTest extends SysuiTestCase {
    @Test
    public void testUpdateFingerprintLocationOnInit() {
        // GIVEN fp sensor location is available pre-attached
        Pair<Integer, PointF> udfps = setupUdfps(); // first = radius, second = udfps location
        Pair<Float, PointF> udfps = setupUdfps(); // first = radius, second = udfps location

        // WHEN lock icon view controller is initialized and attached
        mLockIconViewController.init();
@@ -197,7 +192,7 @@ public class LockIconViewControllerTest extends SysuiTestCase {
    @Test
    public void testUpdatePaddingBasedOnResolutionScale() {
        // GIVEN fp sensor location is available pre-attached & scaled resolution factor is 5
        Pair<Integer, PointF> udfps = setupUdfps(); // first = radius, second = udfps location
        Pair<Float, PointF> udfps = setupUdfps(); // first = radius, second = udfps location
        when(mAuthController.getScaleFactor()).thenReturn(5f);

        // WHEN lock icon view controller is initialized and attached
@@ -215,20 +210,19 @@ public class LockIconViewControllerTest extends SysuiTestCase {
        // GIVEN fp sensor location is not available pre-init
        when(mKeyguardUpdateMonitor.isUdfpsSupported()).thenReturn(false);
        when(mAuthController.getFingerprintSensorLocation()).thenReturn(null);
        when(mAuthController.getUdfpsProps()).thenReturn(null);
        mLockIconViewController.init();
        captureAttachListener();
        mAttachListener.onViewAttachedToWindow(mLockIconView);

        // GIVEN fp sensor location is available post-atttached
        // GIVEN fp sensor location is available post-attached
        captureAuthControllerCallback();
        Pair<Integer, PointF> udfps = setupUdfps();
        Pair<Float, PointF> udfps = setupUdfps();

        // WHEN all authenticators are registered
        mAuthControllerCallback.onAllAuthenticatorsRegistered();
        mDelayableExecutor.runAllReady();

        // THEN lock icon view location is updated with the same coordinates as fpProps
        // THEN lock icon view location is updated with the same coordinates as auth controller vals
        verify(mLockIconView).setCenterLocation(eq(udfps.second), eq(udfps.first),
                eq(PADDING));
    }
@@ -402,21 +396,10 @@ public class LockIconViewControllerTest extends SysuiTestCase {
        verify(mLockIconView).setTranslationX(0);

    }
    private Pair<Integer, PointF> setupUdfps() {
    private Pair<Float, PointF> setupUdfps() {
        when(mKeyguardUpdateMonitor.isUdfpsSupported()).thenReturn(true);
        final PointF udfpsLocation = new PointF(50, 75);
        final int radius = 33;
        final FingerprintSensorPropertiesInternal fpProps =
                new FingerprintSensorPropertiesInternal(
                        /* sensorId */ 0,
                        /* strength */ 0,
                        /* max enrollments per user */ 5,
                        /* component info */ new ArrayList<>(),
                        /* sensorType */ 3,
                        /* halControlsIllumination */ true,
                        /* resetLockoutRequiresHwToken */ false,
                        List.of(new SensorLocationInternal("" /* displayId */,
                                (int) udfpsLocation.x, (int) udfpsLocation.y, radius)));
        final float radius = 33f;
        when(mAuthController.getUdfpsLocation()).thenReturn(udfpsLocation);
        when(mAuthController.getUdfpsRadius()).thenReturn(radius);