Loading packages/SystemUI/src/com/android/keyguard/LockIconView.java +2 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading packages/SystemUI/src/com/android/keyguard/LockIconViewController.java +12 −8 Original line number Diff line number Diff line Loading @@ -188,6 +188,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme protected void onViewAttached() { updateIsUdfpsEnrolled(); updateConfiguration(); updateLockIconLocation(); updateKeyguardShowing(); mUserUnlockedWithBiometric = false; Loading Loading @@ -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 { Loading @@ -362,8 +360,6 @@ public class LockIconViewController extends ViewController<LockIconView> impleme mHeightPixels - mBottomPaddingPx - sLockIconRadiusPx), sLockIconRadiusPx, mScaledPaddingPx); } mView.getHitRect(mSensorTouchLocation); } @Override Loading @@ -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); Loading Loading @@ -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; } Loading @@ -692,6 +690,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme mExecutor.execute(() -> { updateIsUdfpsEnrolled(); updateConfiguration(); updateLockIconLocation(); }); } Loading @@ -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(); Loading packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java +14 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } /** Loading Loading @@ -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(); } } } } Loading Loading @@ -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() {} } } packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt +4 −2 Original line number Diff line number Diff line Loading @@ -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) Loading packages/SystemUI/tests/src/com/android/systemui/keyguard/LockIconViewControllerTest.java +7 −24 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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(); Loading @@ -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 Loading @@ -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)); } Loading Loading @@ -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); Loading Loading
packages/SystemUI/src/com/android/keyguard/LockIconView.java +2 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading
packages/SystemUI/src/com/android/keyguard/LockIconViewController.java +12 −8 Original line number Diff line number Diff line Loading @@ -188,6 +188,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme protected void onViewAttached() { updateIsUdfpsEnrolled(); updateConfiguration(); updateLockIconLocation(); updateKeyguardShowing(); mUserUnlockedWithBiometric = false; Loading Loading @@ -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 { Loading @@ -362,8 +360,6 @@ public class LockIconViewController extends ViewController<LockIconView> impleme mHeightPixels - mBottomPaddingPx - sLockIconRadiusPx), sLockIconRadiusPx, mScaledPaddingPx); } mView.getHitRect(mSensorTouchLocation); } @Override Loading @@ -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); Loading Loading @@ -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; } Loading @@ -692,6 +690,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme mExecutor.execute(() -> { updateIsUdfpsEnrolled(); updateConfiguration(); updateLockIconLocation(); }); } Loading @@ -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(); Loading
packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java +14 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } /** Loading Loading @@ -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(); } } } } Loading Loading @@ -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() {} } }
packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt +4 −2 Original line number Diff line number Diff line Loading @@ -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) Loading
packages/SystemUI/tests/src/com/android/systemui/keyguard/LockIconViewControllerTest.java +7 −24 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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(); Loading @@ -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 Loading @@ -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)); } Loading Loading @@ -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); Loading