Merge "Workaround to support low-area UDFPS on BP" am: 2490ffdc5f am: b3b52c3eaf am: c48c44d2f4
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1885957 Change-Id: I2bff9a72ce2e8c94e4ba61c014aebd31529e5554
This commit is contained in:
@@ -21,12 +21,19 @@ import android.annotation.Nullable;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
||||||
import android.util.AttributeSet;
|
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
|
* Manages the layout for under-display fingerprint sensors (UDFPS). Ensures that UI elements
|
||||||
* do not overlap with
|
* do not overlap with
|
||||||
*/
|
*/
|
||||||
public class AuthBiometricUdfpsView extends AuthBiometricFingerprintView {
|
public class AuthBiometricUdfpsView extends AuthBiometricFingerprintView {
|
||||||
|
private static final String TAG = "AuthBiometricUdfpsView";
|
||||||
|
|
||||||
@Nullable private UdfpsDialogMeasureAdapter mMeasureAdapter;
|
@Nullable private UdfpsDialogMeasureAdapter mMeasureAdapter;
|
||||||
|
|
||||||
public AuthBiometricUdfpsView(Context context) {
|
public AuthBiometricUdfpsView(Context context) {
|
||||||
@@ -51,4 +58,23 @@ public class AuthBiometricUdfpsView extends AuthBiometricFingerprintView {
|
|||||||
? mMeasureAdapter.onMeasureInternal(width, height, layoutParams)
|
? mMeasureAdapter.onMeasureInternal(width, height, layoutParams)
|
||||||
: 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ public class UdfpsDialogMeasureAdapter {
|
|||||||
@NonNull private final FingerprintSensorPropertiesInternal mSensorProps;
|
@NonNull private final FingerprintSensorPropertiesInternal mSensorProps;
|
||||||
|
|
||||||
@Nullable private WindowManager mWindowManager;
|
@Nullable private WindowManager mWindowManager;
|
||||||
|
private int mBottomSpacerHeight;
|
||||||
|
|
||||||
public UdfpsDialogMeasureAdapter(
|
public UdfpsDialogMeasureAdapter(
|
||||||
@NonNull ViewGroup view, @NonNull FingerprintSensorPropertiesInternal sensorProps) {
|
@NonNull ViewGroup view, @NonNull FingerprintSensorPropertiesInternal sensorProps) {
|
||||||
@@ -74,6 +75,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
|
@NonNull
|
||||||
private AuthDialog.LayoutParams onMeasureInternalPortrait(int width, int height) {
|
private AuthDialog.LayoutParams onMeasureInternalPortrait(int width, int height) {
|
||||||
// Get the height of the everything below the icon. Currently, that's the indicator and
|
// Get the height of the everything below the icon. Currently, that's the indicator and
|
||||||
@@ -86,7 +97,7 @@ public class UdfpsDialogMeasureAdapter {
|
|||||||
final int dialogMargin = getDialogMarginPx();
|
final int dialogMargin = getDialogMarginPx();
|
||||||
final int displayHeight = getWindowBounds().height();
|
final int displayHeight = getWindowBounds().height();
|
||||||
final Insets navbarInsets = getNavbarInsets();
|
final Insets navbarInsets = getNavbarInsets();
|
||||||
final int bottomSpacerHeight = calculateBottomSpacerHeightForPortrait(
|
mBottomSpacerHeight = calculateBottomSpacerHeightForPortrait(
|
||||||
mSensorProps, displayHeight, textIndicatorHeight, buttonBarHeight,
|
mSensorProps, displayHeight, textIndicatorHeight, buttonBarHeight,
|
||||||
dialogMargin, navbarInsets.bottom);
|
dialogMargin, navbarInsets.bottom);
|
||||||
|
|
||||||
@@ -122,9 +133,10 @@ public class UdfpsDialogMeasureAdapter {
|
|||||||
MeasureSpec.EXACTLY));
|
MeasureSpec.EXACTLY));
|
||||||
} else if (child.getId() == R.id.space_below_icon) {
|
} else if (child.getId() == R.id.space_below_icon) {
|
||||||
// Set the spacer height so the fingerprint icon is on the physical sensor area
|
// Set the spacer height so the fingerprint icon is on the physical sensor area
|
||||||
|
final int clampedSpacerHeight = Math.max(mBottomSpacerHeight, 0);
|
||||||
child.measure(
|
child.measure(
|
||||||
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
||||||
MeasureSpec.makeMeasureSpec(bottomSpacerHeight, MeasureSpec.EXACTLY));
|
MeasureSpec.makeMeasureSpec(clampedSpacerHeight, MeasureSpec.EXACTLY));
|
||||||
} else {
|
} else {
|
||||||
child.measure(
|
child.measure(
|
||||||
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
||||||
|
|||||||
Reference in New Issue
Block a user