Allow Watch Unlock to exit back to Device Unlock settings.
Seeking to imitate the behavior from fingerprint and face unlock. In GMS
Core we will control when to send the RESULT_TIMEOUT resultCode, but we
should generally exit all the way out to Device Unlock, where there is a
passcode entry requirement, when we swipe away from Watch Unlock's
settings.
Flag: com.android.settings.flags.active_unlock_finish_parent
Test: Manually
Bug: 343576960
Change-Id: Ia9a1564295a44ab6925ea9fceebf92f437e03731
diff --git a/aconfig/settings_biometrics_framework_flag_declarations.aconfig b/aconfig/settings_biometrics_framework_flag_declarations.aconfig
index e787da0..e81c68e 100644
--- a/aconfig/settings_biometrics_framework_flag_declarations.aconfig
+++ b/aconfig/settings_biometrics_framework_flag_declarations.aconfig
@@ -14,3 +14,10 @@
description: "This flag enables or disables the Fingerprint v2 enrollment"
bug: "295206723"
}
+
+flag {
+ name: "active_unlock_finish_parent"
+ namespace: "biometrics_framework"
+ description: "This flag enables the Active Unlock settings activity to finish its parent activity"
+ bug: "343576960"
+}
diff --git a/src/com/android/settings/biometrics/combination/CombinedBiometricSettings.java b/src/com/android/settings/biometrics/combination/CombinedBiometricSettings.java
index 671a5b6..7b3a724 100644
--- a/src/com/android/settings/biometrics/combination/CombinedBiometricSettings.java
+++ b/src/com/android/settings/biometrics/combination/CombinedBiometricSettings.java
@@ -24,14 +24,19 @@
import android.os.Bundle;
import android.os.UserHandle;
+import androidx.activity.result.ActivityResult;
+import androidx.activity.result.ActivityResultLauncher;
+import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.Nullable;
import androidx.preference.Preference;
import com.android.settings.R;
+import com.android.settings.biometrics.BiometricEnrollBase;
import com.android.settings.biometrics.activeunlock.ActiveUnlockContentListener.OnContentChangedListener;
import com.android.settings.biometrics.activeunlock.ActiveUnlockDeviceNameListener;
import com.android.settings.biometrics.activeunlock.ActiveUnlockRequireBiometricSetup;
import com.android.settings.biometrics.activeunlock.ActiveUnlockStatusUtils;
+import com.android.settings.flags.Flags;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.SearchIndexable;
@@ -52,6 +57,10 @@
private CombinedBiometricStatusUtils mCombinedBiometricStatusUtils;
@Nullable private ActiveUnlockDeviceNameListener mActiveUnlockDeviceNameListener;
+ private final ActivityResultLauncher<Intent> mActiveUnlockPreferenceLauncher =
+ registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
+ this::onActiveUnlockPreferenceResult);
+
@Override
public void onAttach(Context context) {
super.onAttach(context);
@@ -158,12 +167,25 @@
intent = mActiveUnlockStatusUtils.getIntent();
}
if (intent != null) {
- startActivityForResult(intent, ACTIVE_UNLOCK_REQUEST);
+ if (Flags.activeUnlockFinishParent()) {
+ mActiveUnlockPreferenceLauncher.launch(intent);
+ } else {
+ startActivityForResult(intent, ACTIVE_UNLOCK_REQUEST);
+ }
}
return true;
}
+ private void onActiveUnlockPreferenceResult(@Nullable ActivityResult result) {
+ if (result != null && result.getResultCode() == BiometricEnrollBase.RESULT_TIMEOUT) {
+ mDoNotFinishActivity = false;
+ // When "Watch Unlock" is closed due to entering onStop(),
+ // "Face & Fingerprint Unlock" shall also close itself and back to "Security" page.
+ finish();
+ }
+ }
+
@Override
protected String getUseAnyBiometricSummary() {
// either Active Unlock is not enabled or no device is enrolled.