Support disable extend Fingerprint Settings
1. Disable extend fingerprint settings when all fingerprints removed 2. Refine FingerprintUnlockCategoryController logic to better determine available status Bug: 394550555 Flag: EXEMPT support interface, flag only used in impl part Test: atest FingerprintSettingsFragmentTest Change-Id: I8904e5f6d8f475ad63540eaef913407d7c0cf4ad
This commit is contained in:
@@ -332,6 +332,8 @@ public class FingerprintSettings extends SubSettings {
|
||||
private boolean mIsEnrolling;
|
||||
/** SaveInstance key if we are waiting activity result from a extension preference */
|
||||
@NonNull private String mLaunchedExtPrefKey = "";
|
||||
/** key list for changing visibility */
|
||||
@NonNull private final ArrayList<String> mExtPrefKeys = new ArrayList<>();
|
||||
|
||||
private long mChallenge;
|
||||
|
||||
@@ -474,6 +476,7 @@ public class FingerprintSettings extends SubSettings {
|
||||
if (preference instanceof PrimarySwitchIntentPreference) {
|
||||
preference.setOnPreferenceClickListener(this::onExtIntentPreferenceClick);
|
||||
}
|
||||
mExtPrefKeys.add(preference.getKey());
|
||||
mFingerprintUnlockCategory.addPreference(preference);
|
||||
}
|
||||
}
|
||||
@@ -826,8 +829,17 @@ public class FingerprintSettings extends SubSettings {
|
||||
updateAddPreference();
|
||||
}
|
||||
|
||||
/**
|
||||
* Lambda function for setCategoryHasChildrenSupplier
|
||||
*/
|
||||
private boolean fingerprintUnlockCategoryHasChild() {
|
||||
return mFingerprintUnlockCategory.getPreferenceCount() > 0;
|
||||
}
|
||||
|
||||
private void addFingerprintUnlockCategory() {
|
||||
mFingerprintUnlockCategory = findPreference(KEY_FINGERPRINT_UNLOCK_CATEGORY);
|
||||
mFingerprintUnlockCategoryPreferenceController.setCategoryHasChildrenSupplier(
|
||||
this::fingerprintUnlockCategoryHasChild);
|
||||
if (isSfps()) {
|
||||
// For both SFPS "screen on to auth" and "rest to unlock"
|
||||
final Preference restToUnlockPreference = FeatureFactory.getFeatureFactory()
|
||||
@@ -867,6 +879,14 @@ public class FingerprintSettings extends SubSettings {
|
||||
mScreenOffUnlockUdfpsPreferenceController.getAvailabilityStatus();
|
||||
updatePreferenceVisibility(status, mScreenOffUnlockUdfpsPreference);
|
||||
}
|
||||
if (!mExtPrefKeys.isEmpty()) {
|
||||
for (String key: mExtPrefKeys) {
|
||||
Preference preference = mFingerprintUnlockCategory.findPreference(key);
|
||||
if (preference != null) {
|
||||
updatePreferenceVisibility(categoryStatus, preference);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePreferenceVisibility(int availabilityStatus, Preference preference) {
|
||||
|
@@ -16,8 +16,7 @@
|
||||
|
||||
package com.android.settings.biometrics.fingerprint;
|
||||
|
||||
import static android.hardware.biometrics.Flags.screenOffUnlockUdfps;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
|
||||
@@ -25,6 +24,8 @@ import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Preference controller that controls the fingerprint unlock features to be shown / be hidden.
|
||||
*/
|
||||
@@ -34,17 +35,31 @@ public class FingerprintUnlockCategoryController extends BasePreferenceControlle
|
||||
private int mUserId;
|
||||
@VisibleForTesting
|
||||
protected FingerprintManager mFingerprintManager;
|
||||
@Nullable
|
||||
private Supplier<Boolean> mCategoryHasChildSupplier = null;
|
||||
|
||||
public FingerprintUnlockCategoryController(Context context, String key) {
|
||||
super(context, key);
|
||||
mFingerprintManager = Utils.getFingerprintManagerOrNull(context);
|
||||
}
|
||||
|
||||
public void setCategoryHasChildrenSupplier(
|
||||
@Nullable Supplier<Boolean> categoryHasChildSupplier
|
||||
) {
|
||||
mCategoryHasChildSupplier = categoryHasChildSupplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
Supplier<Boolean> categoryHasChildSupplier = mCategoryHasChildSupplier;
|
||||
boolean hasChild = false;
|
||||
if (categoryHasChildSupplier != null) {
|
||||
hasChild = categoryHasChildSupplier.get();
|
||||
}
|
||||
|
||||
if (mFingerprintManager != null
|
||||
&& mFingerprintManager.isHardwareDetected()
|
||||
&& (mFingerprintManager.isPowerbuttonFps() || screenOffUnlockUdfps())) {
|
||||
&& hasChild) {
|
||||
return mFingerprintManager.hasEnrolledTemplates(getUserId())
|
||||
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user