Update text when Active Unlock is enabled.

Update the security summary, intro, and unlock your phone summary when
Active Unlock is enabled and enrolled on the device.

Test: make RunSettingsRoboTests
Test: manually flip flags, confirm combined page has updated strings
Bug: 264812018
Change-Id: I2843e9f3aa0f38a9f2ebb18d60fed6293f9ce36e
This commit is contained in:
Derek Jedral
2023-01-24 22:00:01 -08:00
parent 334e48f4ff
commit 9134f24f31
7 changed files with 288 additions and 5 deletions

View File

@@ -32,6 +32,7 @@ import android.hardware.fingerprint.FingerprintManager;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
import com.android.settings.testutils.ActiveUnlockTestUtils;
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
@@ -135,4 +136,90 @@ public class ActiveUnlockStatusUtilsTest {
assertThat(mActiveUnlockStatusUtils.useUnlockIntentLayout()).isFalse();
assertThat(mActiveUnlockStatusUtils.useBiometricFailureLayout()).isTrue();
}
@Test
public void getTitle_faceEnabled_returnsFacePreferenceTitle() {
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
when(mFaceManager.isHardwareDetected()).thenReturn(true);
assertThat(mActiveUnlockStatusUtils.getTitleForActiveUnlock())
.isEqualTo(mApplicationContext.getString(
R.string.security_settings_face_preference_title));
}
@Test
public void getTitle_fingerprintEnabled_returnsFingerprintPreferenceTitle() {
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
when(mFaceManager.isHardwareDetected()).thenReturn(false);
assertThat(mActiveUnlockStatusUtils.getTitleForActiveUnlock())
.isEqualTo(mApplicationContext.getString(
R.string.security_settings_fingerprint_preference_title));
}
@Test
public void getIntro_faceEnabled_returnsIntroWithFace() {
ActiveUnlockTestUtils.enable(
mApplicationContext, ActiveUnlockStatusUtils.BIOMETRIC_FAILURE_LAYOUT);
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
when(mFaceManager.isHardwareDetected()).thenReturn(true);
assertThat(mActiveUnlockStatusUtils.getIntroForActiveUnlock())
.isEqualTo(mApplicationContext.getString(
R.string.biometric_settings_intro_with_face));
}
@Test
public void getIntro_fingerprintEnabled_returnsIntroWithFingerprint() {
ActiveUnlockTestUtils.enable(
mApplicationContext, ActiveUnlockStatusUtils.BIOMETRIC_FAILURE_LAYOUT);
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
when(mFaceManager.isHardwareDetected()).thenReturn(false);
assertThat(mActiveUnlockStatusUtils.getIntroForActiveUnlock())
.isEqualTo(mApplicationContext.getString(
R.string.biometric_settings_intro_with_fingerprint));
}
@Test
public void getIntro_unlockOnIntentAndFaceEnabled_returnsEmpty() {
ActiveUnlockTestUtils.enable(
mApplicationContext, ActiveUnlockStatusUtils.UNLOCK_INTENT_LAYOUT);
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
when(mFaceManager.isHardwareDetected()).thenReturn(false);
assertThat(mActiveUnlockStatusUtils.getIntroForActiveUnlock()).isEqualTo("");
}
@Test
public void getIntro_unlockOnIntentAndFaceAndFingerprintEnabled_returnsDefault() {
ActiveUnlockTestUtils.enable(
mApplicationContext, ActiveUnlockStatusUtils.UNLOCK_INTENT_LAYOUT);
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
when(mFaceManager.isHardwareDetected()).thenReturn(true);
assertThat(mActiveUnlockStatusUtils.getIntroForActiveUnlock())
.isEqualTo(mApplicationContext.getString(
R.string.biometric_settings_intro));
}
@Test
public void getUnlockDeviceSummary_fingerprintEnabled_returnsFingerprintOrWatch() {
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
when(mFaceManager.isHardwareDetected()).thenReturn(false);
assertThat(mActiveUnlockStatusUtils.getUnlockDeviceSummaryForActiveUnlock())
.isEqualTo(mApplicationContext.getString(
R.string.biometric_settings_use_fingerprint_or_watch_preference_summary));
}
@Test
public void getUnlockDeviceSummary_faceEnabled_returnsFaceOrWatch() {
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
when(mFaceManager.isHardwareDetected()).thenReturn(true);
assertThat(mActiveUnlockStatusUtils.getUnlockDeviceSummaryForActiveUnlock())
.isEqualTo(mApplicationContext.getString(
R.string.biometric_settings_use_face_or_watch_preference_summary));
}
}

View File

@@ -39,6 +39,8 @@ public final class FakeContentProvider extends ContentProvider {
.build();
public static final String METHOD_SUMMARY = "getSummary";
public static final String KEY_SUMMARY = "com.android.settings.summary";
private static final String METHOD_DEVICE_NAME = "getDeviceName";
private static final String KEY_DEVICE_NAME = "com.android.settings.active_unlock.device_name";
@Nullable private static String sTileSummary;
@Nullable private static String sDeviceName;
@@ -50,10 +52,15 @@ public final class FakeContentProvider extends ContentProvider {
sTileSummary = summary;
}
public static void setDeviceName(String deviceName) {
sDeviceName = deviceName;
}
public static void init(Context context) {
Settings.Secure.putString(
context.getContentResolver(), ActiveUnlockTestUtils.PROVIDER_SETTING, AUTHORITY);
sTileSummary = null;
sDeviceName = null;
}
@Override
@@ -61,6 +68,8 @@ public final class FakeContentProvider extends ContentProvider {
Bundle bundle = new Bundle();
if (METHOD_SUMMARY.equals(method)) {
bundle.putCharSequence(KEY_SUMMARY, sTileSummary);
} else if (METHOD_DEVICE_NAME.equals(method)) {
bundle.putCharSequence(KEY_DEVICE_NAME, sDeviceName);
}
return bundle;
}