Hide SFPS wakeup setting when it's not supported

Change-Id: I22d4eb745379a6ca56b8fe23e1584131c4e945a6
This commit is contained in:
Michael Bestas
2023-03-20 02:40:07 +02:00
parent 1062719df9
commit acd39854ce
2 changed files with 15 additions and 8 deletions

View File

@@ -217,7 +217,7 @@ public class FingerprintSettings extends SubSettings {
if (manager == null || !manager.isHardwareDetected()) { if (manager == null || !manager.isHardwareDetected()) {
return null; return null;
} }
if (manager.isPowerbuttonFps()) { if (manager.isPowerbuttonFps() && isScreenOffUnlcokSupported()) {
controllers.add( controllers.add(
new FingerprintUnlockCategoryController( new FingerprintUnlockCategoryController(
context, context,
@@ -658,7 +658,7 @@ public class FingerprintSettings extends SubSettings {
column2.mTitle = getText( column2.mTitle = getText(
R.string.security_fingerprint_disclaimer_lockscreen_disabled_2 R.string.security_fingerprint_disclaimer_lockscreen_disabled_2
); );
if (isSfps()) { if (isSfps() && isScreenOffUnlcokSupported()) {
column2.mLearnMoreOverrideText = getText( column2.mLearnMoreOverrideText = getText(
R.string.security_settings_fingerprint_settings_footer_learn_more); R.string.security_settings_fingerprint_settings_footer_learn_more);
} }
@@ -706,6 +706,9 @@ public class FingerprintSettings extends SubSettings {
if (isUdfps()) { if (isUdfps()) {
return getContext().getResources().getBoolean( return getContext().getResources().getBoolean(
com.android.internal.R.bool.config_screen_off_udfps_enabled); com.android.internal.R.bool.config_screen_off_udfps_enabled);
} else if (isSfps()) {
return getContext().getResources().getBoolean(
org.lineageos.platform.internal.R.bool.config_fingerprintWakeAndUnlock);
} }
return false; return false;
} }
@@ -752,7 +755,8 @@ public class FingerprintSettings extends SubSettings {
// This needs to be after setting ids, otherwise // This needs to be after setting ids, otherwise
// |mRequireScreenOnToAuthPreferenceController.isChecked| is always checking the primary // |mRequireScreenOnToAuthPreferenceController.isChecked| is always checking the primary
// user instead of the user with |mUserId|. // user instead of the user with |mUserId|.
if (isSfps() || (screenOffUnlockUdfps() && isScreenOffUnlcokSupported()) if ((isSfps() && isScreenOffUnlcokSupported())
|| (screenOffUnlockUdfps() && isScreenOffUnlcokSupported())
|| getExtPreferenceProvider().getSize() > 0) { || getExtPreferenceProvider().getSize() > 0) {
scrollToPreference(fpPrefKey); scrollToPreference(fpPrefKey);
addFingerprintUnlockCategory(); addFingerprintUnlockCategory();
@@ -851,7 +855,7 @@ public class FingerprintSettings extends SubSettings {
mFingerprintUnlockCategory = findPreference(KEY_FINGERPRINT_UNLOCK_CATEGORY); mFingerprintUnlockCategory = findPreference(KEY_FINGERPRINT_UNLOCK_CATEGORY);
mFingerprintUnlockCategoryPreferenceController.setCategoryHasChildrenSupplier( mFingerprintUnlockCategoryPreferenceController.setCategoryHasChildrenSupplier(
this::fingerprintUnlockCategoryHasChild); this::fingerprintUnlockCategoryHasChild);
if (isSfps()) { if (isSfps() && isScreenOffUnlcokSupported()) {
// 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()
.getFingerprintFeatureProvider() .getFingerprintFeatureProvider()
@@ -872,7 +876,9 @@ public class FingerprintSettings extends SubSettings {
setupFingerprintUnlockCategoryPreferencesForScreenOffUnlock(); setupFingerprintUnlockCategoryPreferencesForScreenOffUnlock();
} }
setupExtFingerprintPreferences(); setupExtFingerprintPreferences();
updateFingerprintUnlockCategoryVisibility(); if (mFingerprintUnlockCategoryPreferenceController != null) {
updateFingerprintUnlockCategoryVisibility();
}
} }
private void updateFingerprintUnlockCategoryVisibility() { private void updateFingerprintUnlockCategoryVisibility() {
@@ -979,7 +985,8 @@ public class FingerprintSettings extends SubSettings {
private void updatePreferencesAfterFingerprintRemoved() { private void updatePreferencesAfterFingerprintRemoved() {
updateAddPreference(); updateAddPreference();
updateUseFingerprintToEnableStatus(); updateUseFingerprintToEnableStatus();
if (isSfps() || (screenOffUnlockUdfps() && isScreenOffUnlcokSupported())) { if ((isSfps() && isScreenOffUnlcokSupported()) ||
(screenOffUnlockUdfps() && isScreenOffUnlcokSupported())) {
updateFingerprintUnlockCategoryVisibility(); updateFingerprintUnlockCategoryVisibility();
} }
updatePreferences(); updatePreferences();
@@ -1246,7 +1253,7 @@ public class FingerprintSettings extends SubSettings {
private List<AbstractPreferenceController> buildPreferenceControllers(Context context) { private List<AbstractPreferenceController> buildPreferenceControllers(Context context) {
final List<AbstractPreferenceController> controllers = final List<AbstractPreferenceController> controllers =
createThePreferenceControllers(context); createThePreferenceControllers(context);
if (isSfps()) { if (isSfps() && isScreenOffUnlcokSupported()) {
for (AbstractPreferenceController controller : controllers) { for (AbstractPreferenceController controller : controllers) {
if (controller.getPreferenceKey() == KEY_FINGERPRINT_UNLOCK_CATEGORY) { if (controller.getPreferenceKey() == KEY_FINGERPRINT_UNLOCK_CATEGORY) {
mFingerprintUnlockCategoryPreferenceController = mFingerprintUnlockCategoryPreferenceController =

View File

@@ -61,7 +61,7 @@ public class FingerprintSettingsRequireScreenOnToAuthPreferenceController
getUserHandle()); getUserHandle());
if (toReturn == -1) { if (toReturn == -1) {
toReturn = mContext.getResources().getBoolean( toReturn = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_performantAuthDefault) ? 1 : 0; org.lineageos.platform.internal.R.bool.config_fingerprintWakeAndUnlock) ? 1 : 0;
Settings.Secure.putIntForUser(mContext.getContentResolver(), Settings.Secure.putIntForUser(mContext.getContentResolver(),
Settings.Secure.SFPS_PERFORMANT_AUTH_ENABLED, toReturn, getUserHandle()); Settings.Secure.SFPS_PERFORMANT_AUTH_ENABLED, toReturn, getUserHandle());
} }