Merge "Scale px udfps HW related sizes to curr resolution" into tm-dev
This commit is contained in:
@@ -62,7 +62,6 @@
|
|||||||
android:id="@+id/lock_icon"
|
android:id="@+id/lock_icon"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:padding="@dimen/lock_icon_padding"
|
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:scaleType="centerCrop"/>
|
android:scaleType="centerCrop"/>
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,6 @@
|
|||||||
android:id="@+id/udfps_aod_fp"
|
android:id="@+id/udfps_aod_fp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:padding="@dimen/lock_icon_padding"
|
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
app:lottie_autoPlay="false"
|
app:lottie_autoPlay="false"
|
||||||
@@ -47,7 +46,6 @@
|
|||||||
android:id="@+id/udfps_lockscreen_fp"
|
android:id="@+id/udfps_lockscreen_fp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:padding="@dimen/lock_icon_padding"
|
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
app:lottie_autoPlay="false"
|
app:lottie_autoPlay="false"
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public class LockIconView extends FrameLayout implements Dumpable {
|
|||||||
@NonNull private final RectF mSensorRect;
|
@NonNull private final RectF mSensorRect;
|
||||||
@NonNull private PointF mLockIconCenter = new PointF(0f, 0f);
|
@NonNull private PointF mLockIconCenter = new PointF(0f, 0f);
|
||||||
private int mRadius;
|
private int mRadius;
|
||||||
|
private int mLockIconPadding;
|
||||||
|
|
||||||
private ImageView mLockIcon;
|
private ImageView mLockIcon;
|
||||||
private ImageView mBgView;
|
private ImageView mBgView;
|
||||||
@@ -125,9 +126,13 @@ public class LockIconView extends FrameLayout implements Dumpable {
|
|||||||
* Set the location of the lock icon.
|
* Set the location of the lock icon.
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public void setCenterLocation(@NonNull PointF center, int radius) {
|
public void setCenterLocation(@NonNull PointF center, int radius, int drawablePadding) {
|
||||||
mLockIconCenter = center;
|
mLockIconCenter = center;
|
||||||
mRadius = radius;
|
mRadius = radius;
|
||||||
|
mLockIconPadding = drawablePadding;
|
||||||
|
|
||||||
|
mLockIcon.setPadding(mLockIconPadding, mLockIconPadding, mLockIconPadding,
|
||||||
|
mLockIconPadding);
|
||||||
|
|
||||||
// mSensorProps coordinates assume portrait mode which is OK b/c the keyguard is always in
|
// mSensorProps coordinates assume portrait mode which is OK b/c the keyguard is always in
|
||||||
// portrait.
|
// portrait.
|
||||||
@@ -221,6 +226,7 @@ public class LockIconView extends FrameLayout implements Dumpable {
|
|||||||
pw.println(" Center in px (x, y)= ("
|
pw.println(" Center in px (x, y)= ("
|
||||||
+ mLockIconCenter.x + ", " + mLockIconCenter.y + ")");
|
+ mLockIconCenter.x + ", " + mLockIconCenter.y + ")");
|
||||||
pw.println(" Radius in pixels: " + mRadius);
|
pw.println(" Radius in pixels: " + mRadius);
|
||||||
|
pw.println(" Drawable padding: " + mLockIconPadding);
|
||||||
pw.println(" mIconType=" + typeToString(mIconType));
|
pw.println(" mIconType=" + typeToString(mIconType));
|
||||||
pw.println(" mAod=" + mAod);
|
pw.println(" mAod=" + mAod);
|
||||||
pw.println("Lock Icon View actual measurements:");
|
pw.println("Lock Icon View actual measurements:");
|
||||||
|
|||||||
@@ -31,8 +31,6 @@ import android.graphics.PointF;
|
|||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.drawable.AnimatedStateListDrawable;
|
import android.graphics.drawable.AnimatedStateListDrawable;
|
||||||
import android.hardware.biometrics.BiometricSourceType;
|
import android.hardware.biometrics.BiometricSourceType;
|
||||||
import android.hardware.biometrics.SensorLocationInternal;
|
|
||||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.VibrationAttributes;
|
import android.os.VibrationAttributes;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
@@ -125,6 +123,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
|
|||||||
private float mHeightPixels;
|
private float mHeightPixels;
|
||||||
private float mWidthPixels;
|
private float mWidthPixels;
|
||||||
private int mBottomPaddingPx;
|
private int mBottomPaddingPx;
|
||||||
|
private int mScaledPaddingPx;
|
||||||
|
|
||||||
private boolean mShowUnlockIcon;
|
private boolean mShowUnlockIcon;
|
||||||
private boolean mShowLockIcon;
|
private boolean mShowLockIcon;
|
||||||
@@ -341,6 +340,10 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
|
|||||||
mHeightPixels = bounds.bottom;
|
mHeightPixels = bounds.bottom;
|
||||||
mBottomPaddingPx = getResources().getDimensionPixelSize(R.dimen.lock_icon_margin_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(
|
mUnlockedLabel = mView.getContext().getResources().getString(
|
||||||
R.string.accessibility_unlock_button);
|
R.string.accessibility_unlock_button);
|
||||||
mLockedLabel = mView.getContext()
|
mLockedLabel = mView.getContext()
|
||||||
@@ -351,15 +354,13 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
|
|||||||
|
|
||||||
private void updateLockIconLocation() {
|
private void updateLockIconLocation() {
|
||||||
if (mUdfpsSupported) {
|
if (mUdfpsSupported) {
|
||||||
FingerprintSensorPropertiesInternal props = mAuthController.getUdfpsProps().get(0);
|
mView.setCenterLocation(mAuthController.getUdfpsLocation(),
|
||||||
final SensorLocationInternal location = props.getLocation();
|
mAuthController.getUdfpsRadius(), mScaledPaddingPx);
|
||||||
mView.setCenterLocation(new PointF(location.sensorLocationX, location.sensorLocationY),
|
|
||||||
location.sensorRadius);
|
|
||||||
} else {
|
} else {
|
||||||
mView.setCenterLocation(
|
mView.setCenterLocation(
|
||||||
new PointF(mWidthPixels / 2,
|
new PointF(mWidthPixels / 2,
|
||||||
mHeightPixels - mBottomPaddingPx - sLockIconRadiusPx),
|
mHeightPixels - mBottomPaddingPx - sLockIconRadiusPx),
|
||||||
sLockIconRadiusPx);
|
sLockIconRadiusPx, mScaledPaddingPx);
|
||||||
}
|
}
|
||||||
|
|
||||||
mView.getHitRect(mSensorTouchLocation);
|
mView.getHitRect(mSensorTouchLocation);
|
||||||
|
|||||||
@@ -443,6 +443,27 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
|
|||||||
return new PointF(mUdfpsBounds.centerX(), mUdfpsBounds.centerY());
|
return new PointF(mUdfpsBounds.centerX(), mUdfpsBounds.centerY());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the radius of UDFPS on the screen in pixels
|
||||||
|
*/
|
||||||
|
public int getUdfpsRadius() {
|
||||||
|
if (mUdfpsController == null || mUdfpsBounds == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return mUdfpsBounds.height() / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the scale factor representing the user's current resolution / the stable
|
||||||
|
* (default) resolution
|
||||||
|
*/
|
||||||
|
public float getScaleFactor() {
|
||||||
|
if (mUdfpsController == null || mUdfpsController.mOverlayParams == null) {
|
||||||
|
return 1f;
|
||||||
|
}
|
||||||
|
return mUdfpsController.mOverlayParams.getScaleFactor();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return where the fingerprint sensor exists in pixels in portrait mode. devices without an
|
* @return where the fingerprint sensor exists in pixels in portrait mode. devices without an
|
||||||
* overridden value will use the default value even if they don't have a fingerprint sensor
|
* overridden value will use the default value even if they don't have a fingerprint sensor
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ public class UdfpsKeyguardView extends UdfpsAnimationView {
|
|||||||
|
|
||||||
private AnimatorSet mBackgroundInAnimator = new AnimatorSet();
|
private AnimatorSet mBackgroundInAnimator = new AnimatorSet();
|
||||||
private int mAlpha; // 0-255
|
private int mAlpha; // 0-255
|
||||||
|
private float mScaleFactor = 1;
|
||||||
|
|
||||||
// AOD anti-burn-in offsets
|
// AOD anti-burn-in offsets
|
||||||
private final int mMaxBurnInOffsetX;
|
private final int mMaxBurnInOffsetX;
|
||||||
@@ -172,6 +173,22 @@ public class UdfpsKeyguardView extends UdfpsAnimationView {
|
|||||||
mLockScreenFp.invalidate(); // updated with a valueCallback
|
mLockScreenFp.invalidate(); // updated with a valueCallback
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setScaleFactor(float scale) {
|
||||||
|
mScaleFactor = scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
void updatePadding() {
|
||||||
|
if (mLockScreenFp == null || mAodFp == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final int defaultPaddingPx =
|
||||||
|
getResources().getDimensionPixelSize(R.dimen.lock_icon_padding);
|
||||||
|
final int padding = (int) (defaultPaddingPx * mScaleFactor);
|
||||||
|
mLockScreenFp.setPadding(padding, padding, padding, padding);
|
||||||
|
mAodFp.setPadding(padding, padding, padding, padding);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param alpha between 0 and 255
|
* @param alpha between 0 and 255
|
||||||
*/
|
*/
|
||||||
@@ -257,6 +274,7 @@ public class UdfpsKeyguardView extends UdfpsAnimationView {
|
|||||||
mLockScreenFp = view.findViewById(R.id.udfps_lockscreen_fp);
|
mLockScreenFp = view.findViewById(R.id.udfps_lockscreen_fp);
|
||||||
mBgProtection = view.findViewById(R.id.udfps_keyguard_fp_bg);
|
mBgProtection = view.findViewById(R.id.udfps_keyguard_fp_bg);
|
||||||
|
|
||||||
|
updatePadding();
|
||||||
updateColor();
|
updateColor();
|
||||||
updateAlpha();
|
updateAlpha();
|
||||||
parent.addView(view);
|
parent.addView(view);
|
||||||
|
|||||||
@@ -154,6 +154,8 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
|
|||||||
updateGenericBouncerVisibility();
|
updateGenericBouncerVisibility();
|
||||||
mConfigurationController.addCallback(mConfigurationListener);
|
mConfigurationController.addCallback(mConfigurationListener);
|
||||||
getPanelExpansionStateManager().addExpansionListener(mPanelExpansionListener);
|
getPanelExpansionStateManager().addExpansionListener(mPanelExpansionListener);
|
||||||
|
updateScaleFactor();
|
||||||
|
mView.updatePadding();
|
||||||
updateAlpha();
|
updateAlpha();
|
||||||
updatePauseAuth();
|
updatePauseAuth();
|
||||||
|
|
||||||
@@ -367,6 +369,15 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the scale factor based on the device's resolution.
|
||||||
|
*/
|
||||||
|
private void updateScaleFactor() {
|
||||||
|
if (mUdfpsController != null && mUdfpsController.mOverlayParams != null) {
|
||||||
|
mView.setScaleFactor(mUdfpsController.mOverlayParams.getScaleFactor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final StatusBarStateController.StateListener mStateListener =
|
private final StatusBarStateController.StateListener mStateListener =
|
||||||
new StatusBarStateController.StateListener() {
|
new StatusBarStateController.StateListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -486,6 +497,8 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfigChanged(Configuration newConfig) {
|
public void onConfigChanged(Configuration newConfig) {
|
||||||
|
updateScaleFactor();
|
||||||
|
mView.updatePadding();
|
||||||
mView.updateColor();
|
mView.updateColor();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSess
|
|||||||
import static com.android.keyguard.LockIconView.ICON_LOCK;
|
import static com.android.keyguard.LockIconView.ICON_LOCK;
|
||||||
import static com.android.keyguard.LockIconView.ICON_UNLOCK;
|
import static com.android.keyguard.LockIconView.ICON_UNLOCK;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertEquals;
|
|
||||||
|
|
||||||
import static org.mockito.Mockito.any;
|
import static org.mockito.Mockito.any;
|
||||||
import static org.mockito.Mockito.anyBoolean;
|
import static org.mockito.Mockito.anyBoolean;
|
||||||
import static org.mockito.Mockito.anyInt;
|
import static org.mockito.Mockito.anyInt;
|
||||||
@@ -87,6 +85,7 @@ import java.util.List;
|
|||||||
@TestableLooper.RunWithLooper
|
@TestableLooper.RunWithLooper
|
||||||
public class LockIconViewControllerTest extends SysuiTestCase {
|
public class LockIconViewControllerTest extends SysuiTestCase {
|
||||||
private static final String UNLOCKED_LABEL = "unlocked";
|
private static final String UNLOCKED_LABEL = "unlocked";
|
||||||
|
private static final int PADDING = 10;
|
||||||
|
|
||||||
private MockitoSession mStaticMockSession;
|
private MockitoSession mStaticMockSession;
|
||||||
|
|
||||||
@@ -149,6 +148,8 @@ public class LockIconViewControllerTest extends SysuiTestCase {
|
|||||||
when(mWindowManager.getCurrentWindowMetrics().getBounds()).thenReturn(windowBounds);
|
when(mWindowManager.getCurrentWindowMetrics().getBounds()).thenReturn(windowBounds);
|
||||||
when(mResources.getString(R.string.accessibility_unlock_button)).thenReturn(UNLOCKED_LABEL);
|
when(mResources.getString(R.string.accessibility_unlock_button)).thenReturn(UNLOCKED_LABEL);
|
||||||
when(mResources.getDrawable(anyInt(), any())).thenReturn(mIconDrawable);
|
when(mResources.getDrawable(anyInt(), any())).thenReturn(mIconDrawable);
|
||||||
|
when(mResources.getDimensionPixelSize(R.dimen.lock_icon_padding)).thenReturn(PADDING);
|
||||||
|
when(mAuthController.getScaleFactor()).thenReturn(1f);
|
||||||
|
|
||||||
when(mKeyguardStateController.isShowing()).thenReturn(true);
|
when(mKeyguardStateController.isShowing()).thenReturn(true);
|
||||||
when(mKeyguardStateController.isKeyguardGoingAway()).thenReturn(false);
|
when(mKeyguardStateController.isKeyguardGoingAway()).thenReturn(false);
|
||||||
@@ -181,16 +182,32 @@ public class LockIconViewControllerTest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testUpdateFingerprintLocationOnInit() {
|
public void testUpdateFingerprintLocationOnInit() {
|
||||||
// GIVEN fp sensor location is available pre-attached
|
// GIVEN fp sensor location is available pre-attached
|
||||||
Pair<Integer, PointF> udfps = setupUdfps();
|
Pair<Integer, PointF> udfps = setupUdfps(); // first = radius, second = udfps location
|
||||||
|
|
||||||
// WHEN lock icon view controller is initialized and attached
|
// WHEN lock icon view controller is initialized and attached
|
||||||
mLockIconViewController.init();
|
mLockIconViewController.init();
|
||||||
captureAttachListener();
|
captureAttachListener();
|
||||||
mAttachListener.onViewAttachedToWindow(mLockIconView);
|
mAttachListener.onViewAttachedToWindow(mLockIconView);
|
||||||
|
|
||||||
// THEN lock icon view location is updated with the same coordinates as fpProps
|
// THEN lock icon view location is updated to the udfps location with UDFPS radius
|
||||||
verify(mLockIconView).setCenterLocation(mPointCaptor.capture(), eq(udfps.first));
|
verify(mLockIconView).setCenterLocation(eq(udfps.second), eq(udfps.first),
|
||||||
assertEquals(udfps.second, mPointCaptor.getValue());
|
eq(PADDING));
|
||||||
|
}
|
||||||
|
|
||||||
|
@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
|
||||||
|
when(mAuthController.getScaleFactor()).thenReturn(5f);
|
||||||
|
|
||||||
|
// WHEN lock icon view controller is initialized and attached
|
||||||
|
mLockIconViewController.init();
|
||||||
|
captureAttachListener();
|
||||||
|
mAttachListener.onViewAttachedToWindow(mLockIconView);
|
||||||
|
|
||||||
|
// THEN lock icon view location is updated with the scaled radius
|
||||||
|
verify(mLockIconView).setCenterLocation(eq(udfps.second), eq(udfps.first),
|
||||||
|
eq(PADDING * 5));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -212,8 +229,8 @@ public class LockIconViewControllerTest extends SysuiTestCase {
|
|||||||
mDelayableExecutor.runAllReady();
|
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 fpProps
|
||||||
verify(mLockIconView).setCenterLocation(mPointCaptor.capture(), eq(udfps.first));
|
verify(mLockIconView).setCenterLocation(eq(udfps.second), eq(udfps.first),
|
||||||
assertEquals(udfps.second, mPointCaptor.getValue());
|
eq(PADDING));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -400,7 +417,7 @@ public class LockIconViewControllerTest extends SysuiTestCase {
|
|||||||
List.of(new SensorLocationInternal("" /* displayId */,
|
List.of(new SensorLocationInternal("" /* displayId */,
|
||||||
(int) udfpsLocation.x, (int) udfpsLocation.y, radius)));
|
(int) udfpsLocation.x, (int) udfpsLocation.y, radius)));
|
||||||
when(mAuthController.getUdfpsLocation()).thenReturn(udfpsLocation);
|
when(mAuthController.getUdfpsLocation()).thenReturn(udfpsLocation);
|
||||||
when(mAuthController.getUdfpsProps()).thenReturn(List.of(fpProps));
|
when(mAuthController.getUdfpsRadius()).thenReturn(radius);
|
||||||
|
|
||||||
return new Pair(radius, udfpsLocation);
|
return new Pair(radius, udfpsLocation);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user