Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6faaf802 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Allow Watch Unlock to exit back to Device Unlock settings." into main

parents 4f8e95fb 42d6144c
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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"
}
+23 −1
Original line number Diff line number Diff line
@@ -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<Intent> 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) {
            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.