Settings: Retain udfps overlay shown state on restoring activity

Prevent udfps view from disappearing if the activity is recreated due
to theme or configuration change while enrolling fingerprint.

Change-Id: I0bb0a3cf90c8119bab566fdb0f35db0ee858b75e
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
Signed-off-by: Dmitrii <bankersenator@gmail.com>
This commit is contained in:
Adithya R
2025-01-15 17:48:50 +01:00
committed by Joey
parent f0ca40ccab
commit b726c64318

View File

@@ -104,6 +104,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
static final String ICON_TOUCH_DIALOG = "fps_icon_touch_dialog"; static final String ICON_TOUCH_DIALOG = "fps_icon_touch_dialog";
static final String KEY_STATE_CANCELED = "is_canceled"; static final String KEY_STATE_CANCELED = "is_canceled";
static final String KEY_STATE_PREVIOUS_ROTATION = "previous_rotation"; static final String KEY_STATE_PREVIOUS_ROTATION = "previous_rotation";
static final String KEY_STATE_OVERLAY_SHOWN = "overlay_shown";
private static final int PROGRESS_BAR_MAX = 10000; private static final int PROGRESS_BAR_MAX = 10000;
@@ -193,6 +194,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
private boolean mHaveShownSfpsLeftEdgeLottie; private boolean mHaveShownSfpsLeftEdgeLottie;
private boolean mHaveShownSfpsRightEdgeLottie; private boolean mHaveShownSfpsRightEdgeLottie;
private boolean mShouldShowLottie; private boolean mShouldShowLottie;
private boolean mOverlayShown;
private Animator mHelpAnimation; private Animator mHelpAnimation;
@@ -379,12 +381,14 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
protected void onSaveInstanceState(Bundle outState) { protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
outState.putBoolean(KEY_STATE_CANCELED, mIsCanceled); outState.putBoolean(KEY_STATE_CANCELED, mIsCanceled);
outState.putBoolean(KEY_STATE_OVERLAY_SHOWN, mOverlayShown);
outState.putInt(KEY_STATE_PREVIOUS_ROTATION, mPreviousRotation); outState.putInt(KEY_STATE_PREVIOUS_ROTATION, mPreviousRotation);
} }
private void restoreSavedState(Bundle savedInstanceState) { private void restoreSavedState(Bundle savedInstanceState) {
mRestoring = true; mRestoring = true;
mIsCanceled = savedInstanceState.getBoolean(KEY_STATE_CANCELED, false); mIsCanceled = savedInstanceState.getBoolean(KEY_STATE_CANCELED, false);
mOverlayShown = savedInstanceState.getBoolean(KEY_STATE_OVERLAY_SHOWN, false);
mPreviousRotation = savedInstanceState.getInt(KEY_STATE_PREVIOUS_ROTATION, mPreviousRotation = savedInstanceState.getInt(KEY_STATE_PREVIOUS_ROTATION,
getDisplay().getRotation()); getDisplay().getRotation());
} }
@@ -398,6 +402,9 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
if (mRestoring) { if (mRestoring) {
startIconAnimation(); startIconAnimation();
} }
if (mOverlayShown) {
onUdfpsOverlayShown();
}
} }
private void setupScreenFoldCallbackWhenNecessary() { private void setupScreenFoldCallbackWhenNecessary() {
@@ -443,6 +450,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
// showErrorDialog() will cause onWindowFocusChanged(false), set mIsCanceled to false // showErrorDialog() will cause onWindowFocusChanged(false), set mIsCanceled to false
// before showErrorDialog() to prevent that another error dialog is triggered again. // before showErrorDialog() to prevent that another error dialog is triggered again.
mIsCanceled = true; mIsCanceled = true;
mOverlayShown = false;
FingerprintErrorDialog.showErrorDialog(this, errorMsgId, FingerprintErrorDialog.showErrorDialog(this, errorMsgId,
this instanceof SetupFingerprintEnrollEnrolling); this instanceof SetupFingerprintEnrollEnrolling);
cancelEnrollment(); cancelEnrollment();
@@ -456,6 +464,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
@Override @Override
protected void onStop() { protected void onStop() {
if (!isChangingConfigurations()) { if (!isChangingConfigurations()) {
mOverlayShown = false;
if (!WizardManagerHelper.isAnySetupWizard(getIntent()) if (!WizardManagerHelper.isAnySetupWizard(getIntent())
&& !BiometricUtils.isAnyMultiBiometricFlow(this) && !BiometricUtils.isAnyMultiBiometricFlow(this)
&& !mFromSettingsSummary) { && !mFromSettingsSummary) {
@@ -921,6 +930,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
public void onUdfpsOverlayShown() { public void onUdfpsOverlayShown() {
if (mCanAssumeUdfps) { if (mCanAssumeUdfps) {
findViewById(R.id.udfps_animation_view).setVisibility(View.VISIBLE); findViewById(R.id.udfps_animation_view).setVisibility(View.VISIBLE);
mOverlayShown = true;
} }
} }
@@ -1095,6 +1105,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
mOverlayShown = false;
stopIconAnimation(); stopIconAnimation();
if (mProgressBar.getProgress() >= PROGRESS_BAR_MAX) { if (mProgressBar.getProgress() >= PROGRESS_BAR_MAX) {