summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2021-02-03 05:44:57 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2021-02-03 05:44:57 +0000
commitba8bc8e90d17f23806c1089df43514b6623bc72f (patch)
treecbad71369eaf9c3616988a66e2197e0ad2cc1d67
parent421ce84db7ef4e081cfd4eece04ed5c42efea5d4 (diff)
parenta5f7aadf07d3e5bbc9e8ef5ed0f852bd7d0979ea (diff)
Merge "Fix UDFPS enrollment shadow" into sc-dev
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimation.java14
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationEnroll.java15
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java18
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java1
4 files changed, 40 insertions, 8 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimation.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimation.java
index 40fe7b17f37d..3ea8140427cb 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimation.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimation.java
@@ -52,4 +52,18 @@ public abstract class UdfpsAnimation extends Drawable {
public void setAlpha(int alpha) {
mFingerprintDrawable.setAlpha(alpha);
}
+
+ /**
+ * @return The amount of padding that's needed on each side of the sensor, in pixels.
+ */
+ public int getPaddingX() {
+ return 0;
+ }
+
+ /**
+ * @return The amount of padding that's needed on each side of the sensor, in pixels.
+ */
+ public int getPaddingY() {
+ return 0;
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationEnroll.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationEnroll.java
index 52662ae93376..68f14148ffc7 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationEnroll.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationEnroll.java
@@ -70,6 +70,9 @@ public class UdfpsAnimationEnroll extends UdfpsAnimation {
@Override
public void draw(@NonNull Canvas canvas) {
+ canvas.save();
+ canvas.translate(getPaddingX(), getPaddingY());
+
final boolean isNightMode = (mContext.getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_YES) != 0;
if (!isNightMode) {
@@ -78,6 +81,18 @@ public class UdfpsAnimationEnroll extends UdfpsAnimation {
}
}
mFingerprintDrawable.draw(canvas);
+
+ canvas.restore();
+ }
+
+ @Override
+ public int getPaddingX() {
+ return (int) Math.ceil(SHADOW_RADIUS);
+ }
+
+ @Override
+ public int getPaddingY() {
+ return (int) Math.ceil(SHADOW_RADIUS);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java
index 6ce3e7570c08..ac4b93a684e1 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java
@@ -242,12 +242,15 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
}
}
- private WindowManager.LayoutParams computeLayoutParams() {
+ private WindowManager.LayoutParams computeLayoutParams(@Nullable UdfpsAnimation animation) {
+ final int paddingX = animation != null ? animation.getPaddingX() : 0;
+ final int paddingY = animation != null ? animation.getPaddingY() : 0;
+
// Default dimensions assume portrait mode.
- mCoreLayoutParams.x = mSensorProps.sensorLocationX - mSensorProps.sensorRadius;
- mCoreLayoutParams.y = mSensorProps.sensorLocationY - mSensorProps.sensorRadius;
- mCoreLayoutParams.height = 2 * mSensorProps.sensorRadius;
- mCoreLayoutParams.width = 2 * mSensorProps.sensorRadius;
+ mCoreLayoutParams.x = mSensorProps.sensorLocationX - mSensorProps.sensorRadius - paddingX;
+ mCoreLayoutParams.y = mSensorProps.sensorLocationY - mSensorProps.sensorRadius - paddingY;
+ mCoreLayoutParams.height = 2 * mSensorProps.sensorRadius + 2 * paddingX;
+ mCoreLayoutParams.width = 2 * mSensorProps.sensorRadius + 2 * paddingY;
Point p = new Point();
// Gets the size based on the current rotation of the display.
@@ -289,8 +292,9 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
if (!mIsOverlayShowing) {
try {
Log.v(TAG, "showUdfpsOverlay | adding window");
- mView.setUdfpsAnimation(getUdfpsAnimationForReason(reason));
- mWindowManager.addView(mView, computeLayoutParams());
+ final UdfpsAnimation animation = getUdfpsAnimationForReason(reason);
+ mView.setUdfpsAnimation(animation);
+ mWindowManager.addView(mView, computeLayoutParams(animation));
mView.setOnTouchListener(mOnTouchListener);
mIsOverlayShowing = true;
} catch (RuntimeException e) {
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java
index 3fbbb840900a..d448ed8d550c 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java
@@ -56,7 +56,6 @@ public class UdfpsView extends FrameLayout implements DozeReceiver, UdfpsIllumin
@NonNull private final RectF mSensorRect;
@NonNull private final Paint mDebugTextPaint;
-
// Used to obtain the sensor location.
@NonNull private FingerprintSensorPropertiesInternal mSensorProps;