From 42d6144c0295e5025dc1f682058e0d09286bcdcb Mon Sep 17 00:00:00 2001 From: Jacob Hobbie Date: Fri, 23 Aug 2024 16:08:42 +0000 Subject: [PATCH] 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 --- ...etrics_framework_flag_declarations.aconfig | 7 ++++++ .../CombinedBiometricSettings.java | 24 ++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/aconfig/settings_biometrics_framework_flag_declarations.aconfig b/aconfig/settings_biometrics_framework_flag_declarations.aconfig index e787da05e90..e81c68e6aa0 100644 --- a/aconfig/settings_biometrics_framework_flag_declarations.aconfig +++ b/aconfig/settings_biometrics_framework_flag_declarations.aconfig @@ -14,3 +14,10 @@ flag { 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 671a5b659fc..7b3a72446f7 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.content.Intent; 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 @@ public class CombinedBiometricSettings extends BiometricsSettingsBase { private CombinedBiometricStatusUtils mCombinedBiometricStatusUtils; @Nullable private ActiveUnlockDeviceNameListener mActiveUnlockDeviceNameListener; + private final ActivityResultLauncher mActiveUnlockPreferenceLauncher = + registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), + this::onActiveUnlockPreferenceResult); + @Override public void onAttach(Context context) { super.onAttach(context); @@ -158,12 +167,25 @@ public class CombinedBiometricSettings extends BiometricsSettingsBase { 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.