Merge "Change preference title if Active Unlock enabled" into udc-dev am: 42deb763e0
am: 60419e72bd
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/22997141 Change-Id: I8201e20c39ef02beebb117731b7ed9dcc105bae9 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -818,6 +818,10 @@
|
||||
<string name="biometric_settings_intro_with_fingerprint">You can unlock with your watch when your fingerprint isn\u2019t recognized.</string>
|
||||
<!-- Introduction shown in face page to explain that watch unlock can be used if face isn't recognized. [CHAR LIMIT=NONE]-->
|
||||
<string name="biometric_settings_intro_with_face">You can unlock with your watch when your face isn\u2019t recognized.</string>
|
||||
<string name="biometric_settings_use_fingerprint_or_watch_for"> Use fingerprint or watch to</string>
|
||||
<string name="biometric_settings_use_face_or_watch_for"> Use face or watch to</string>
|
||||
<string name="biometric_settings_use_face_fingerprint_or_watch_for"> Use face, fingerprint, or watch to</string>
|
||||
<string name="biometric_settings_use_watch_for"> Use watch to</string>
|
||||
<!-- Message for a biometric preference toggle, indicating that an action can only be performed by using Face Unlock or Watch Unlock. [CHAR LIMIT=50] -->
|
||||
<string name="biometric_settings_use_face_or_watch_preference_summary">Using face or watch</string>
|
||||
<!-- Message for a biometric preference toggle, indicating that an action can only be performed by using Fingerprint Unlock or Watch Unlock. [CHAR LIMIT=50] -->
|
||||
|
@@ -268,6 +268,30 @@ public class ActiveUnlockStatusUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the preference title of how to use biometrics when active unlock is enabled.
|
||||
*/
|
||||
public String getUseBiometricTitleForActiveUnlock() {
|
||||
final boolean faceAllowed = Utils.hasFaceHardware(mContext);
|
||||
final boolean fingerprintAllowed = Utils.hasFingerprintHardware(mContext);
|
||||
|
||||
return mContext.getString(getUseBiometricTitleRes(faceAllowed, fingerprintAllowed));
|
||||
}
|
||||
|
||||
@StringRes
|
||||
private static int getUseBiometricTitleRes(
|
||||
boolean isFaceAllowed, boolean isFingerprintAllowed) {
|
||||
if (isFaceAllowed && isFingerprintAllowed) {
|
||||
return R.string.biometric_settings_use_face_fingerprint_or_watch_for;
|
||||
} else if (isFaceAllowed) {
|
||||
return R.string.biometric_settings_use_face_or_watch_for;
|
||||
} else if (isFingerprintAllowed) {
|
||||
return R.string.biometric_settings_use_fingerprint_or_watch_for;
|
||||
} else {
|
||||
return R.string.biometric_settings_use_watch_for;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getFlagState() {
|
||||
return DeviceConfig.getProperty(DeviceConfig.NAMESPACE_REMOTE_AUTH, CONFIG_FLAG_NAME);
|
||||
}
|
||||
|
@@ -46,6 +46,7 @@ public class CombinedBiometricSettings extends BiometricsSettingsBase {
|
||||
private static final String KEY_UNLOCK_PHONE = "biometric_settings_biometric_keyguard";
|
||||
private static final String KEY_USE_IN_APPS = "biometric_settings_biometric_app";
|
||||
private static final String KEY_INTRO_PREFERENCE = "biometric_intro";
|
||||
private static final String KEY_USE_BIOMETRIC_PREFERENCE = "biometric_ways_to_use";
|
||||
|
||||
private ActiveUnlockStatusUtils mActiveUnlockStatusUtils;
|
||||
private CombinedBiometricStatusUtils mCombinedBiometricStatusUtils;
|
||||
@@ -83,6 +84,11 @@ public class CombinedBiometricSettings extends BiometricsSettingsBase {
|
||||
if (introPreference != null) {
|
||||
introPreference.setTitle(mActiveUnlockStatusUtils.getIntroForActiveUnlock());
|
||||
}
|
||||
final Preference useBiometricPreference = findPreference(KEY_USE_BIOMETRIC_PREFERENCE);
|
||||
if (useBiometricPreference != null) {
|
||||
useBiometricPreference.setTitle(
|
||||
mActiveUnlockStatusUtils.getUseBiometricTitleForActiveUnlock());
|
||||
}
|
||||
getActivity().setTitle(mActiveUnlockStatusUtils.getTitleForActiveUnlock());
|
||||
}
|
||||
|
||||
|
@@ -222,4 +222,44 @@ public class ActiveUnlockStatusUtilsTest {
|
||||
.isEqualTo(mApplicationContext.getString(
|
||||
R.string.biometric_settings_use_face_or_watch_preference_summary));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUseBiometricTitle_faceAndFingerprintEnabled_returnsFaceFingerprintOrWatch() {
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||
|
||||
assertThat(mActiveUnlockStatusUtils.getUseBiometricTitleForActiveUnlock())
|
||||
.isEqualTo(mApplicationContext.getString(
|
||||
R.string.biometric_settings_use_face_fingerprint_or_watch_for));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUseBiometricTitle_fingerprintEnabled_returnsFingerprintOrWatch() {
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
when(mFaceManager.isHardwareDetected()).thenReturn(false);
|
||||
|
||||
assertThat(mActiveUnlockStatusUtils.getUseBiometricTitleForActiveUnlock())
|
||||
.isEqualTo(mApplicationContext.getString(
|
||||
R.string.biometric_settings_use_fingerprint_or_watch_for));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUseBiometricTitle_faceEnabled_returnsFaceOrWatch() {
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
|
||||
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||
|
||||
assertThat(mActiveUnlockStatusUtils.getUseBiometricTitleForActiveUnlock())
|
||||
.isEqualTo(mApplicationContext.getString(
|
||||
R.string.biometric_settings_use_face_or_watch_for));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUseBiometricTitle_withoutFaceOrFingerprint_returnsWatch() {
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
|
||||
when(mFaceManager.isHardwareDetected()).thenReturn(false);
|
||||
|
||||
assertThat(mActiveUnlockStatusUtils.getUseBiometricTitleForActiveUnlock())
|
||||
.isEqualTo(mApplicationContext.getString(
|
||||
R.string.biometric_settings_use_watch_for));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user