diff options
author | Kevin Chyn <kchyn@google.com> | 2021-11-09 13:51:38 -0800 |
---|---|---|
committer | alk3pInjection <webmaster@raspii.tech> | 2022-05-02 09:56:20 +0800 |
commit | 0f6396e814a1dd97ed04fc89ebb271a2329c34ae (patch) | |
tree | 5073e670871d62e2f565f18e4ac4260d01195d01 | |
parent | 38fb0b344704070a2da17fb58a4d33059de17211 (diff) |
Workaround to support low-area UDFPS on BP
1) Ensure the spacer measurement is clamped to 0. Negative values
cause the layout to exhibit undefined behavior.
2) Instead of making the layout xml even more complicated, for low-area
sensor devices, we just have onLayoutInternal() translate the icon
and indicator to where it should be. Note that this can definitely
cause overlap with the button bar, but at least this implementation
allows the button bar to be shown (and thus pass curent CTS
requirements). We can have additional refinement in the future.
Bug: 201510778
Test: atest CtsBiometricsTestCases
Change-Id: Ie9869f15fc3afddc3bd4392a2fd08efbf136cd6c
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/biometrics/AuthBiometricUdfpsView.java | 26 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/biometrics/UdfpsDialogMeasureAdapter.java | 16 |
2 files changed, 40 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthBiometricUdfpsView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthBiometricUdfpsView.java index 376368fbf9d4..d80d9cc9d62d 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthBiometricUdfpsView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthBiometricUdfpsView.java @@ -21,12 +21,19 @@ import android.annotation.Nullable; import android.content.Context; import android.hardware.fingerprint.FingerprintSensorPropertiesInternal; import android.util.AttributeSet; +import android.util.Log; +import android.widget.FrameLayout; +import android.widget.TextView; + +import com.android.systemui.R; /** * Manages the layout for under-display fingerprint sensors (UDFPS). Ensures that UI elements * do not overlap with */ public class AuthBiometricUdfpsView extends AuthBiometricFingerprintView { + private static final String TAG = "AuthBiometricUdfpsView"; + @Nullable private UdfpsDialogMeasureAdapter mMeasureAdapter; public AuthBiometricUdfpsView(Context context) { @@ -51,4 +58,23 @@ public class AuthBiometricUdfpsView extends AuthBiometricFingerprintView { ? mMeasureAdapter.onMeasureInternal(width, height, layoutParams) : layoutParams; } + + @Override + void onLayoutInternal() { + super.onLayoutInternal(); + + // Move the UDFPS icon and indicator text if necessary. This probably only needs to happen + // for devices where the UDFPS sensor is too low. + // TODO(b/201510778): Update this logic to support cases where the sensor or text overlap + // the button bar area. + final int bottomSpacerHeight = mMeasureAdapter.getBottomSpacerHeight(); + Log.w(TAG, "bottomSpacerHeight: " + bottomSpacerHeight); + if (bottomSpacerHeight < 0) { + FrameLayout iconFrame = findViewById(R.id.biometric_icon_frame); + iconFrame.setTranslationY(-bottomSpacerHeight); + + TextView indicator = findViewById(R.id.indicator); + indicator.setTranslationY(-bottomSpacerHeight); + } + } } diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsDialogMeasureAdapter.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsDialogMeasureAdapter.java index 6cc8acf07c50..1624d5f68c35 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsDialogMeasureAdapter.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsDialogMeasureAdapter.java @@ -46,6 +46,7 @@ public class UdfpsDialogMeasureAdapter { @NonNull private final FingerprintSensorPropertiesInternal mSensorProps; @Nullable private WindowManager mWindowManager; + private int mBottomSpacerHeight; public UdfpsDialogMeasureAdapter( @NonNull ViewGroup view, @NonNull FingerprintSensorPropertiesInternal sensorProps) { @@ -75,6 +76,16 @@ public class UdfpsDialogMeasureAdapter { } } + /** + * @return the actual (and possibly negative) bottom spacer height. If negative, this indicates + * that the UDFPS sensor is too low. Our current xml and custom measurement logic is very hard + * too cleanly support this case. So, let's have the onLayout code translate the sensor location + * instead. + */ + int getBottomSpacerHeight() { + return mBottomSpacerHeight; + } + @NonNull private AuthDialog.LayoutParams onMeasureInternalPortrait(int width, int height) { // Get the height of the everything below the icon. Currently, that's the indicator and @@ -87,7 +98,7 @@ public class UdfpsDialogMeasureAdapter { final int dialogMargin = getDialogMarginPx(); final int displayHeight = getWindowBounds().height(); final Insets navbarInsets = getNavbarInsets(); - final int bottomSpacerHeight = calculateBottomSpacerHeightForPortrait( + mBottomSpacerHeight = calculateBottomSpacerHeightForPortrait( mSensorProps, displayHeight, textIndicatorHeight, buttonBarHeight, dialogMargin, navbarInsets.bottom); @@ -123,9 +134,10 @@ public class UdfpsDialogMeasureAdapter { MeasureSpec.EXACTLY)); } else if (child.getId() == R.id.space_below_icon) { // Set the spacer height so the fingerprint icon is on the physical sensor area + final int clampedSpacerHeight = Math.max(mBottomSpacerHeight, 0); child.measure( MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), - MeasureSpec.makeMeasureSpec(bottomSpacerHeight, MeasureSpec.EXACTLY)); + MeasureSpec.makeMeasureSpec(clampedSpacerHeight, MeasureSpec.EXACTLY)); } else { child.measure( MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), |