Change preference title if Active Unlock enabled
Change the title of the preference to reflect that Active Unlock can also be used to unlock the device. Test: make RunSettingsRoboTests Bug: b/271782800 Change-Id: Ie227e6dddfc024235fc3568899ef151f14f17696
This commit is contained in:
@@ -815,6 +815,10 @@
|
|||||||
<string name="biometric_settings_intro_with_fingerprint">You can unlock with your watch when your fingerprint isn\u2019t recognized.</string>
|
<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]-->
|
<!-- 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_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] -->
|
<!-- 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>
|
<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] -->
|
<!-- 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() {
|
private static String getFlagState() {
|
||||||
return DeviceConfig.getProperty(DeviceConfig.NAMESPACE_REMOTE_AUTH, CONFIG_FLAG_NAME);
|
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_UNLOCK_PHONE = "biometric_settings_biometric_keyguard";
|
||||||
private static final String KEY_USE_IN_APPS = "biometric_settings_biometric_app";
|
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_INTRO_PREFERENCE = "biometric_intro";
|
||||||
|
private static final String KEY_USE_BIOMETRIC_PREFERENCE = "biometric_ways_to_use";
|
||||||
|
|
||||||
private ActiveUnlockStatusUtils mActiveUnlockStatusUtils;
|
private ActiveUnlockStatusUtils mActiveUnlockStatusUtils;
|
||||||
private CombinedBiometricStatusUtils mCombinedBiometricStatusUtils;
|
private CombinedBiometricStatusUtils mCombinedBiometricStatusUtils;
|
||||||
@@ -83,6 +84,11 @@ public class CombinedBiometricSettings extends BiometricsSettingsBase {
|
|||||||
if (introPreference != null) {
|
if (introPreference != null) {
|
||||||
introPreference.setTitle(mActiveUnlockStatusUtils.getIntroForActiveUnlock());
|
introPreference.setTitle(mActiveUnlockStatusUtils.getIntroForActiveUnlock());
|
||||||
}
|
}
|
||||||
|
final Preference useBiometricPreference = findPreference(KEY_USE_BIOMETRIC_PREFERENCE);
|
||||||
|
if (useBiometricPreference != null) {
|
||||||
|
useBiometricPreference.setTitle(
|
||||||
|
mActiveUnlockStatusUtils.getUseBiometricTitleForActiveUnlock());
|
||||||
|
}
|
||||||
getActivity().setTitle(mActiveUnlockStatusUtils.getTitleForActiveUnlock());
|
getActivity().setTitle(mActiveUnlockStatusUtils.getTitleForActiveUnlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -222,4 +222,44 @@ public class ActiveUnlockStatusUtilsTest {
|
|||||||
.isEqualTo(mApplicationContext.getString(
|
.isEqualTo(mApplicationContext.getString(
|
||||||
R.string.biometric_settings_use_face_or_watch_preference_summary));
|
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