Merge "Support disable extend Fingerprint Settings" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
fb4be96958
@@ -332,6 +332,8 @@ public class FingerprintSettings extends SubSettings {
|
|||||||
private boolean mIsEnrolling;
|
private boolean mIsEnrolling;
|
||||||
/** SaveInstance key if we are waiting activity result from a extension preference */
|
/** SaveInstance key if we are waiting activity result from a extension preference */
|
||||||
@NonNull private String mLaunchedExtPrefKey = "";
|
@NonNull private String mLaunchedExtPrefKey = "";
|
||||||
|
/** key list for changing visibility */
|
||||||
|
@NonNull private final ArrayList<String> mExtPrefKeys = new ArrayList<>();
|
||||||
|
|
||||||
private long mChallenge;
|
private long mChallenge;
|
||||||
|
|
||||||
@@ -474,6 +476,7 @@ public class FingerprintSettings extends SubSettings {
|
|||||||
if (preference instanceof PrimarySwitchIntentPreference) {
|
if (preference instanceof PrimarySwitchIntentPreference) {
|
||||||
preference.setOnPreferenceClickListener(this::onExtIntentPreferenceClick);
|
preference.setOnPreferenceClickListener(this::onExtIntentPreferenceClick);
|
||||||
}
|
}
|
||||||
|
mExtPrefKeys.add(preference.getKey());
|
||||||
mFingerprintUnlockCategory.addPreference(preference);
|
mFingerprintUnlockCategory.addPreference(preference);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -826,8 +829,17 @@ public class FingerprintSettings extends SubSettings {
|
|||||||
updateAddPreference();
|
updateAddPreference();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lambda function for setCategoryHasChildrenSupplier
|
||||||
|
*/
|
||||||
|
private boolean fingerprintUnlockCategoryHasChild() {
|
||||||
|
return mFingerprintUnlockCategory.getPreferenceCount() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
private void addFingerprintUnlockCategory() {
|
private void addFingerprintUnlockCategory() {
|
||||||
mFingerprintUnlockCategory = findPreference(KEY_FINGERPRINT_UNLOCK_CATEGORY);
|
mFingerprintUnlockCategory = findPreference(KEY_FINGERPRINT_UNLOCK_CATEGORY);
|
||||||
|
mFingerprintUnlockCategoryPreferenceController.setCategoryHasChildrenSupplier(
|
||||||
|
this::fingerprintUnlockCategoryHasChild);
|
||||||
if (isSfps()) {
|
if (isSfps()) {
|
||||||
// For both SFPS "screen on to auth" and "rest to unlock"
|
// For both SFPS "screen on to auth" and "rest to unlock"
|
||||||
final Preference restToUnlockPreference = FeatureFactory.getFeatureFactory()
|
final Preference restToUnlockPreference = FeatureFactory.getFeatureFactory()
|
||||||
@@ -867,6 +879,14 @@ public class FingerprintSettings extends SubSettings {
|
|||||||
mScreenOffUnlockUdfpsPreferenceController.getAvailabilityStatus();
|
mScreenOffUnlockUdfpsPreferenceController.getAvailabilityStatus();
|
||||||
updatePreferenceVisibility(status, mScreenOffUnlockUdfpsPreference);
|
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) {
|
private void updatePreferenceVisibility(int availabilityStatus, Preference preference) {
|
||||||
|
@@ -16,8 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.biometrics.fingerprint;
|
package com.android.settings.biometrics.fingerprint;
|
||||||
|
|
||||||
import static android.hardware.biometrics.Flags.screenOffUnlockUdfps;
|
import android.annotation.Nullable;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.hardware.fingerprint.FingerprintManager;
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
|
|
||||||
@@ -25,6 +24,8 @@ import com.android.internal.annotations.VisibleForTesting;
|
|||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preference controller that controls the fingerprint unlock features to be shown / be hidden.
|
* 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;
|
private int mUserId;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected FingerprintManager mFingerprintManager;
|
protected FingerprintManager mFingerprintManager;
|
||||||
|
@Nullable
|
||||||
|
private Supplier<Boolean> mCategoryHasChildSupplier = null;
|
||||||
|
|
||||||
public FingerprintUnlockCategoryController(Context context, String key) {
|
public FingerprintUnlockCategoryController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
mFingerprintManager = Utils.getFingerprintManagerOrNull(context);
|
mFingerprintManager = Utils.getFingerprintManagerOrNull(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCategoryHasChildrenSupplier(
|
||||||
|
@Nullable Supplier<Boolean> categoryHasChildSupplier
|
||||||
|
) {
|
||||||
|
mCategoryHasChildSupplier = categoryHasChildSupplier;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
|
Supplier<Boolean> categoryHasChildSupplier = mCategoryHasChildSupplier;
|
||||||
|
boolean hasChild = false;
|
||||||
|
if (categoryHasChildSupplier != null) {
|
||||||
|
hasChild = categoryHasChildSupplier.get();
|
||||||
|
}
|
||||||
|
|
||||||
if (mFingerprintManager != null
|
if (mFingerprintManager != null
|
||||||
&& mFingerprintManager.isHardwareDetected()
|
&& mFingerprintManager.isHardwareDetected()
|
||||||
&& (mFingerprintManager.isPowerbuttonFps() || screenOffUnlockUdfps())) {
|
&& hasChild) {
|
||||||
return mFingerprintManager.hasEnrolledTemplates(getUserId())
|
return mFingerprintManager.hasEnrolledTemplates(getUserId())
|
||||||
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user