Merge "Fix incorrect choose screen lock during unicorn" into tm-qpr-dev

This commit is contained in:
TreeHugger Robot
2022-09-13 06:23:40 +00:00
committed by Android (Google) Code Review
2 changed files with 20 additions and 4 deletions

View File

@@ -564,7 +564,13 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
Intent intent = BiometricUtils.getChooseLockIntent(this, getIntent()); Intent intent = BiometricUtils.getChooseLockIntent(this, getIntent());
intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_INSECURE_OPTIONS, true); intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_INSECURE_OPTIONS, true);
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_REQUEST_GK_PW_HANDLE, true); intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_REQUEST_GK_PW_HANDLE, true);
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_BIOMETRICS, true); if (mHasFeatureFingerprint && mHasFeatureFace) {
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_BIOMETRICS, true);
} else if (mHasFeatureFace) {
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FACE, true);
} else if (mHasFeatureFingerprint) {
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, true);
}
if (mUserId != UserHandle.USER_NULL) { if (mUserId != UserHandle.USER_NULL) {
intent.putExtra(Intent.EXTRA_USER_ID, mUserId); intent.putExtra(Intent.EXTRA_USER_ID, mUserId);

View File

@@ -20,6 +20,11 @@ import static android.provider.Settings.ACTION_BIOMETRIC_ENROLL;
import static androidx.test.espresso.intent.Intents.intended; import static androidx.test.espresso.intent.Intents.intended;
import static androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent; import static androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent;
import static androidx.test.espresso.intent.matcher.IntentMatchers.hasExtra;
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_FOR_BIOMETRICS;
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_FOR_FACE;
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
@@ -83,6 +88,13 @@ public class BiometricEnrollActivityTest {
try (ActivityScenario<BiometricEnrollActivity> scenario = try (ActivityScenario<BiometricEnrollActivity> scenario =
ActivityScenario.launch(getIntent())) { ActivityScenario.launch(getIntent())) {
intended(hasComponent(ChooseLockGeneric.class.getName())); intended(hasComponent(ChooseLockGeneric.class.getName()));
if (mHasFace && mHasFingerprint) {
intended(hasExtra(EXTRA_KEY_FOR_BIOMETRICS, true));
} else if (mHasFace) {
intended(hasExtra(EXTRA_KEY_FOR_FACE, true));
} else if (mHasFingerprint) {
intended(hasExtra(EXTRA_KEY_FOR_FINGERPRINT, true));
}
} }
} }
@@ -109,11 +121,9 @@ public class BiometricEnrollActivityTest {
response.getGatekeeperPasswordHandle()); response.getGatekeeperPasswordHandle());
}).get(); }).get();
try (ActivityScenario<BiometricEnrollActivity> scenario = try (ActivityScenario<BiometricEnrollActivity> scenario =
ActivityScenario.launch(intent)) { ActivityScenario.launch(intent)) {
intended(hasComponent(mHasFace intended(hasComponent(mHasFace && !mHasFingerprint
? FaceEnrollIntroduction.class.getName() ? FaceEnrollIntroduction.class.getName()
: FingerprintEnrollIntroduction.class.getName())); : FingerprintEnrollIntroduction.class.getName()));
} }