Pass Timeout back to upper biometric preference
When FaceSettings or FingerprintSettings are closed because of onStop(), this information can't been passed back to previous Preference screen, CombinedBiometricSettings, because handlePreferenceTreeClick() from AbstractPreferenceController class only can launchActivity() throguh preference's Context. In order to recevice the activity result code from FaceSettings or FingerprintSettings, add handleBiometricPreferenceTreeClick() method in BiometricStatusPreferenceController. Then CombinedBiometricSettings uses this method to show FaceSettings or FingerprintSettings through launchActivityForResult(). Bug: 263057093 Test: atest BiometricNavigationUtilsTest Test: Manually open camera through double-click power key on different pages inside "Face & Fingerprint Unlock" Change-Id: I99167739766ad5ea5f204b0f0543ba6ad18fac31
This commit is contained in:
@@ -17,10 +17,14 @@
|
||||
package com.android.settings.biometrics;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
@@ -29,6 +33,8 @@ import com.android.settings.biometrics.activeunlock.ActiveUnlockStatusUtils;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public abstract class BiometricStatusPreferenceController extends BasePreferenceController {
|
||||
|
||||
protected final UserManager mUm;
|
||||
@@ -39,6 +45,8 @@ public abstract class BiometricStatusPreferenceController extends BasePreference
|
||||
|
||||
private final BiometricNavigationUtils mBiometricNavigationUtils;
|
||||
private final ActiveUnlockStatusUtils mActiveUnlockStatusUtils;
|
||||
@NonNull private WeakReference<ActivityResultLauncher<Intent>> mLauncherWeakReference =
|
||||
new WeakReference<>(null);
|
||||
|
||||
/**
|
||||
* @return true if the controller should be shown exclusively.
|
||||
@@ -118,14 +126,31 @@ public abstract class BiometricStatusPreferenceController extends BasePreference
|
||||
preference.setSummary(getSummaryText());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ActivityResultLauncher that will be used later during handlePreferenceTreeClick()
|
||||
*
|
||||
* @param preference the preference being compared
|
||||
* @param launcher the ActivityResultLauncher
|
||||
* @return {@code true} if matched preference.
|
||||
*/
|
||||
public boolean setPreferenceTreeClickLauncher(@NonNull Preference preference,
|
||||
@Nullable ActivityResultLauncher<Intent> launcher) {
|
||||
if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mLauncherWeakReference = new WeakReference<>(launcher);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
|
||||
return super.handlePreferenceTreeClick(preference);
|
||||
}
|
||||
|
||||
return mBiometricNavigationUtils.launchBiometricSettings(
|
||||
preference.getContext(), getSettingsClassName(), preference.getExtras());
|
||||
return mBiometricNavigationUtils.launchBiometricSettings(preference.getContext(),
|
||||
getSettingsClassName(), preference.getExtras(), mLauncherWeakReference.get());
|
||||
}
|
||||
|
||||
protected int getUserId() {
|
||||
|
Reference in New Issue
Block a user