Merge changes from topic "credential-removal-strings" into sc-dev

* changes:
  Update combined settings summary
  Update credential removal strings
This commit is contained in:
Kevin Chyn
2021-05-04 20:13:00 +00:00
committed by Android (Google) Code Review
5 changed files with 98 additions and 59 deletions

View File

@@ -16,6 +16,10 @@
package com.android.settings.biometrics.combination;
import android.content.Context;
import android.hardware.face.FaceManager;
import android.hardware.fingerprint.FingerprintManager;
import androidx.annotation.Nullable;
import com.android.settings.R;
import com.android.settings.Settings;
@@ -30,6 +34,10 @@ public class CombinedBiometricStatusPreferenceController extends
BiometricStatusPreferenceController {
private static final String KEY_BIOMETRIC_SETTINGS = "biometric_settings";
@Nullable
FingerprintManager mFingerprintManager;
@Nullable
FaceManager mFaceManager;
public CombinedBiometricStatusPreferenceController(Context context) {
this(context, KEY_BIOMETRIC_SETTINGS);
@@ -37,6 +45,8 @@ public class CombinedBiometricStatusPreferenceController extends
public CombinedBiometricStatusPreferenceController(Context context, String key) {
super(context, key);
mFingerprintManager = Utils.getFingerprintManagerOrNull(context);
mFaceManager = Utils.getFaceManagerOrNull(context);
}
@Override
@@ -51,12 +61,34 @@ public class CombinedBiometricStatusPreferenceController extends
@Override
protected String getSummaryTextEnrolled() {
return mContext.getString(R.string.security_settings_biometric_preference_summary);
// Note that this is currently never called (see the super class)
return mContext.getString(
R.string.security_settings_biometric_preference_summary_none_enrolled);
}
@Override
protected String getSummaryTextNoneEnrolled() {
return mContext.getString(R.string.security_settings_biometric_preference_summary);
final int numFingerprintsEnrolled = mFingerprintManager != null ?
mFingerprintManager.getEnrolledFingerprints(getUserId()).size() : 0;
final boolean faceEnrolled = mFaceManager != null
&& mFaceManager.hasEnrolledTemplates(getUserId());
if (faceEnrolled && numFingerprintsEnrolled > 1) {
return mContext.getString(
R.string.security_settings_biometric_preference_summary_both_fp_multiple);
} else if (faceEnrolled && numFingerprintsEnrolled == 1) {
return mContext.getString(
R.string.security_settings_biometric_preference_summary_both_fp_single);
} else if (faceEnrolled) {
return mContext.getString(R.string.security_settings_face_preference_summary);
} else if (numFingerprintsEnrolled > 0) {
return mContext.getResources().getQuantityString(
R.plurals.security_settings_fingerprint_preference_summary,
numFingerprintsEnrolled, numFingerprintsEnrolled);
} else {
return mContext.getString(
R.string.security_settings_biometric_preference_summary_none_enrolled);
}
}
@Override

View File

@@ -975,31 +975,38 @@ public class ChooseLockGeneric extends SettingsActivity {
private int getResIdForFactoryResetProtectionWarningMessage() {
final boolean hasFingerprints;
final boolean hasFace;
if (mFingerprintManager != null && mFingerprintManager.isHardwareDetected()) {
hasFingerprints = mFingerprintManager.hasEnrolledFingerprints(mUserId);
} else {
hasFingerprints = false;
}
if (mFaceManager != null && mFaceManager.isHardwareDetected()) {
hasFace = mFaceManager.hasEnrolledTemplates(mUserId);
} else {
hasFace = false;
}
switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(mUserId)) {
case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
if (hasFingerprints && mIsManagedProfile) {
return R.string
.unlock_disable_frp_warning_content_pattern_fingerprint_profile;
} else if (hasFingerprints && !mIsManagedProfile) {
if (hasFingerprints && hasFace) {
return R.string.unlock_disable_frp_warning_content_pattern_face_fingerprint;
} else if (hasFingerprints) {
return R.string.unlock_disable_frp_warning_content_pattern_fingerprint;
} else if (mIsManagedProfile) {
return R.string.unlock_disable_frp_warning_content_pattern_profile;
} else if (hasFace) {
return R.string.unlock_disable_frp_warning_content_pattern_face;
} else {
return R.string.unlock_disable_frp_warning_content_pattern;
}
case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX:
if (hasFingerprints && mIsManagedProfile) {
return R.string.unlock_disable_frp_warning_content_pin_fingerprint_profile;
} else if (hasFingerprints && !mIsManagedProfile) {
if (hasFingerprints && hasFace) {
return R.string.unlock_disable_frp_warning_content_pin_face_fingerprint;
} else if (hasFingerprints) {
return R.string.unlock_disable_frp_warning_content_pin_fingerprint;
} else if (mIsManagedProfile) {
return R.string.unlock_disable_frp_warning_content_pin_profile;
} else if (hasFace) {
return R.string.unlock_disable_frp_warning_content_pin_face;
} else {
return R.string.unlock_disable_frp_warning_content_pin;
}
@@ -1007,24 +1014,23 @@ public class ChooseLockGeneric extends SettingsActivity {
case DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC:
case DevicePolicyManager.PASSWORD_QUALITY_COMPLEX:
case DevicePolicyManager.PASSWORD_QUALITY_MANAGED:
if (hasFingerprints && mIsManagedProfile) {
if (hasFingerprints && hasFace) {
return R.string
.unlock_disable_frp_warning_content_password_fingerprint_profile;
} else if (hasFingerprints && !mIsManagedProfile) {
.unlock_disable_frp_warning_content_password_face_fingerprint;
} else if (hasFingerprints) {
return R.string.unlock_disable_frp_warning_content_password_fingerprint;
} else if (mIsManagedProfile) {
return R.string.unlock_disable_frp_warning_content_password_profile;
} else if (hasFace) {
return R.string.unlock_disable_frp_warning_content_password_face;
} else {
return R.string.unlock_disable_frp_warning_content_password;
}
default:
if (hasFingerprints && mIsManagedProfile) {
return R.string
.unlock_disable_frp_warning_content_unknown_fingerprint_profile;
} else if (hasFingerprints && !mIsManagedProfile) {
if (hasFingerprints && hasFace) {
return R.string.unlock_disable_frp_warning_content_unknown_face_fingerprint;
} else if (hasFingerprints) {
return R.string.unlock_disable_frp_warning_content_unknown_fingerprint;
} else if (mIsManagedProfile) {
return R.string.unlock_disable_frp_warning_content_unknown_profile;
} else if (hasFace) {
return R.string.unlock_disable_frp_warning_content_unknown_face;
} else {
return R.string.unlock_disable_frp_warning_content_unknown;
}