Fix UI bugs for udfps enroll in settings.

This CL fixes four bugs for SETTINGS_SHOW_UDFPS_ENROLL_IN_SETTINGS feature:
1. When the udfps view is big enough (i.e. landscape mode on panther), the progress bar's bottom is clipped by the footer button.
- Sets the footer button width WRAP_CONTENT and removes the space view to make the footer button short enough, not hiding the udfps view progress bar.

2. When both text size and display icon size are big enough on the portrait mode, the udfps view's position is wrong because its parent views are longer than the screen and scrollable.
- Add addOnDrawListener() on udfps view's parent view, whenever it's changed, recalculate the margins of udfps view to make sure it's aligned  with the sensor's position.

3. When the finger is down on the screen and the lighting circle on the sensor is shown, the fingerprint icon is not hidden.
- Propagates FingerprintManager#onPointerDown and #onPointerUp to UdfpsEnrollView and hide/show fingerprint drawable accordingly.

4. When rotating the screen, fingerprint location is not right because UdfpsEnrollHelper is recreated.
- Makes UdfpsEnrollHelper a fragment and call setRetainInstance(true) to keep it even though the configuration is changed.

Test: manually tested on device:
      Turn this flag on via adb command
      adb shell setprop
        sys.fflag.override.settings_show_udfps_enroll_in_settings true
Bug: 260617060
Change-Id: I15ffde6455cab7e9d4a394349ec39e72df5b2911
This commit is contained in:
Hao Dong
2022-12-15 16:04:43 +00:00
parent 599ffd0f3f
commit 967203de77
6 changed files with 185 additions and 21 deletions

View File

@@ -82,6 +82,7 @@ import com.airbnb.lottie.LottieAnimationView;
import com.airbnb.lottie.LottieCompositionFactory;
import com.airbnb.lottie.LottieProperty;
import com.airbnb.lottie.model.KeyPath;
import com.google.android.setupcompat.template.FooterActionButton;
import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupcompat.template.FooterButton;
import com.google.android.setupcompat.util.WizardManagerHelper;
@@ -101,6 +102,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
private static final String TAG = "FingerprintEnrollEnrolling";
static final String TAG_SIDECAR = "sidecar";
static final String TAG_UDFPS_HELPER = "udfps_helper";
static final String KEY_STATE_CANCELED = "is_canceled";
static final String KEY_STATE_PREVIOUS_ROTATION = "previous_rotation";
@@ -353,6 +355,24 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
.build()
);
if (FeatureFlagUtils.isEnabled(getApplicationContext(),
FeatureFlagUtils.SETTINGS_SHOW_UDFPS_ENROLL_IN_SETTINGS)) {
// Remove the space view and make the width of footer button container WRAP_CONTENT
// to avoid hiding the udfps view progress bar bottom.
final LinearLayout buttonContainer = mFooterBarMixin.getButtonContainer();
View spaceView = null;
for (int i = 0; i < buttonContainer.getChildCount(); i++) {
if (!(buttonContainer.getChildAt(i) instanceof FooterActionButton)) {
spaceView = buttonContainer.getChildAt(i);
break;
}
}
if (spaceView != null) {
spaceView.setVisibility(View.GONE);
buttonContainer.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT;
}
}
final LayerDrawable fingerprintDrawable = mProgressBar != null
? (LayerDrawable) mProgressBar.getBackground() : null;
if (fingerprintDrawable != null) {
@@ -867,6 +887,20 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
}
}
@Override
public void onPointerDown(int sensorId) {
if (mUdfpsEnrollHelper != null) {
mUdfpsEnrollHelper.onPointerDown(sensorId);
}
}
@Override
public void onPointerUp(int sensorId) {
if (mUdfpsEnrollHelper != null) {
mUdfpsEnrollHelper.onPointerUp(sensorId);
}
}
private void updateProgress(boolean animate) {
if (mSidecar == null || !mSidecar.isEnrolling()) {
Log.d(TAG, "Enrollment not started yet");
@@ -1195,7 +1229,16 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
udfpsProps.sensorType == FingerprintSensorProperties.TYPE_UDFPS_OPTICAL);
udfpsEnrollView.setOverlayParams(params);
mUdfpsEnrollHelper = new UdfpsEnrollHelper(getApplicationContext(), mFingerprintManager);
mUdfpsEnrollHelper = (UdfpsEnrollHelper) getSupportFragmentManager().findFragmentByTag(
FingerprintEnrollEnrolling.TAG_UDFPS_HELPER);
if (mUdfpsEnrollHelper == null) {
mUdfpsEnrollHelper = new UdfpsEnrollHelper(getApplicationContext(),
mFingerprintManager);
getSupportFragmentManager().beginTransaction()
.add(mUdfpsEnrollHelper, FingerprintEnrollEnrolling.TAG_UDFPS_HELPER)
.commitAllowingStateLoss();
}
udfpsEnrollView.setEnrollHelper(mUdfpsEnrollHelper);
return udfpsEnrollView;