Remove remainder of generateChallengeBlocking
Test: make -j56 RunSettingsRoboTests Face Tests: Test: Open face settings, remove face, add face Test: Open face settings, but cancel credential confirmation. Face settings does not show up Test: adb shell am start -a android.app.action.SET_NEW_PASSWORD Able to enroll face Fingerprint Tests: Test: Open fingerprint settings, add button is shown Test: Open fingerprint settings, but cancel credential confirmation. Fingerprint settings does not show up Test: adb shell am start -a android.app.action.SET_NEW_PASSWORD Able to enroll fingerprint Bug: 162533680 Change-Id: Ie448ed086e73b0b545bd3a2e62437c543f7aad6c
This commit is contained in:
@@ -164,7 +164,7 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
|
||||
// No password registered, launch into enrollment wizard.
|
||||
mConfirmingCredentials = true;
|
||||
launchChooseLock();
|
||||
} else if (mToken == null) {
|
||||
} else if (!BiometricUtils.containsGatekeeperPassword(getIntent()) && mToken == null) {
|
||||
// It's possible to have a token but mLaunchedConfirmLock == false, since
|
||||
// ChooseLockGeneric can pass us a token.
|
||||
mConfirmingCredentials = true;
|
||||
|
@@ -46,19 +46,9 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
mFaceManager = Utils.getFaceManagerOrNull(this);
|
||||
// Check if the Gateekeper Password exists. If so, request for a Gatekeeper HAT to be
|
||||
// created. This needs to be cleaned up, since currently it's not very clear which
|
||||
// superclass is responsible for what. Doing the check here is the least risky way.
|
||||
if (mToken == null && BiometricUtils.containsGatekeeperPassword(getIntent())) {
|
||||
// We either block on generateChallenge, or need to gray out the "next" button until
|
||||
// the challenge is ready. Let's just do this for now.
|
||||
final long challenge = mFaceManager.generateChallengeBlocking();
|
||||
mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge);
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mFaceManager = Utils.getFaceManagerOrNull(this);
|
||||
mFaceFeatureProvider = FeatureFactory.getFactory(getApplicationContext())
|
||||
.getFaceFeatureProvider();
|
||||
|
||||
@@ -106,6 +96,18 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
|
||||
? R.string.security_settings_face_enroll_introduction_footer_part_2
|
||||
: R.string.security_settings_face_settings_footer_attention_not_supported;
|
||||
footer2.setText(footer2TextResource);
|
||||
|
||||
// This path is an entry point for SetNewPasswordController, e.g.
|
||||
// adb shell am start -a android.app.action.SET_NEW_PASSWORD
|
||||
if (mToken == null && BiometricUtils.containsGatekeeperPassword(getIntent())) {
|
||||
mFooterBarMixin.getPrimaryButton().setEnabled(false);
|
||||
// We either block on generateChallenge, or need to gray out the "next" button until
|
||||
// the challenge is ready. Let's just do this for now.
|
||||
mFaceManager.generateChallenge(challenge -> {
|
||||
mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge);
|
||||
mFooterBarMixin.getPrimaryButton().setEnabled(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -61,19 +61,25 @@ public class FingerprintEnrollFindSensor extends BiometricEnrollBase {
|
||||
|
||||
setHeaderText(R.string.security_settings_fingerprint_enroll_find_sensor_title);
|
||||
|
||||
// This is an entry point for SetNewPasswordController, e.g.
|
||||
// adb shell am start -a android.app.action.SET_NEW_PASSWORD
|
||||
if (mToken == null && BiometricUtils.containsGatekeeperPassword(getIntent())) {
|
||||
final FingerprintManager fpm = getSystemService(FingerprintManager.class);
|
||||
final long challenge = fpm.generateChallengeBlocking();
|
||||
mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge);
|
||||
fpm.generateChallenge(challenge -> {
|
||||
mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge);
|
||||
|
||||
// Put this into the intent. This is really just to work around the fact that the
|
||||
// enrollment sidecar gets the HAT from the activity's intent, rather than having
|
||||
// it passed in.
|
||||
getIntent().putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
|
||||
// Put this into the intent. This is really just to work around the fact that the
|
||||
// enrollment sidecar gets the HAT from the activity's intent, rather than having
|
||||
// it passed in.
|
||||
getIntent().putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
|
||||
|
||||
startLookingForFingerprint();
|
||||
});
|
||||
} else if (mToken != null) {
|
||||
// HAT passed in from somewhere else, such as FingerprintEnrollIntroduction
|
||||
startLookingForFingerprint();
|
||||
}
|
||||
|
||||
startLookingForFingerprint(); // already confirmed, so start looking for fingerprint
|
||||
|
||||
View animationView = findViewById(R.id.fingerprint_sensor_location_animation);
|
||||
if (animationView instanceof FingerprintFindSensorAnimation) {
|
||||
mAnimation = (FingerprintFindSensorAnimation) animationView;
|
||||
|
@@ -411,6 +411,8 @@ public class FingerprintSettings extends SubSettings {
|
||||
private void updateAddPreference() {
|
||||
if (getActivity() == null) return; // Activity went away
|
||||
|
||||
final Preference addPreference = findPreference(KEY_FINGERPRINT_ADD);
|
||||
|
||||
/* Disable preference if too many fingerprints added */
|
||||
final int max = getContext().getResources().getInteger(
|
||||
com.android.internal.R.integer.config_fingerprintMaxTemplatesPerUser);
|
||||
@@ -420,9 +422,8 @@ public class FingerprintSettings extends SubSettings {
|
||||
final boolean removalInProgress = mRemovalSidecar.inProgress();
|
||||
CharSequence maxSummary = tooMany ?
|
||||
getContext().getString(R.string.fingerprint_add_max, max) : "";
|
||||
Preference addPreference = findPreference(KEY_FINGERPRINT_ADD);
|
||||
addPreference.setSummary(maxSummary);
|
||||
addPreference.setEnabled(!tooMany && !removalInProgress);
|
||||
addPreference.setEnabled(!tooMany && !removalInProgress && mToken != null);
|
||||
}
|
||||
|
||||
private void createFooterPreference(PreferenceGroup root) {
|
||||
@@ -569,11 +570,19 @@ public class FingerprintSettings extends SubSettings {
|
||||
if (requestCode == CONFIRM_REQUEST || requestCode == CHOOSE_LOCK_GENERIC_REQUEST) {
|
||||
mLaunchedConfirm = false;
|
||||
if (resultCode == RESULT_FINISHED || resultCode == RESULT_OK) {
|
||||
if (data != null) {
|
||||
final long challenge = mFingerprintManager.generateChallengeBlocking();
|
||||
mToken = BiometricUtils.requestGatekeeperHat(getActivity(), data, mUserId,
|
||||
challenge);
|
||||
if (data != null && BiometricUtils.containsGatekeeperPassword(data)) {
|
||||
mFingerprintManager.generateChallenge(challenge -> {
|
||||
mToken = BiometricUtils.requestGatekeeperHat(getActivity(), data,
|
||||
mUserId, challenge);
|
||||
updateAddPreference();
|
||||
});
|
||||
} else {
|
||||
Log.d(TAG, "Data null or GK PW missing");
|
||||
finish();
|
||||
}
|
||||
} else {
|
||||
Log.d(TAG, "Password not confirmed");
|
||||
finish();
|
||||
}
|
||||
} else if (requestCode == ADD_FINGERPRINT_REQUEST) {
|
||||
mEnrollClicked = false;
|
||||
@@ -583,11 +592,6 @@ public class FingerprintSettings extends SubSettings {
|
||||
activity.finish();
|
||||
}
|
||||
}
|
||||
|
||||
if (mToken == null) {
|
||||
// Didn't get an authentication, finishing
|
||||
getActivity().finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -54,8 +54,6 @@ import org.robolectric.RobolectricTestRunner;
|
||||
public final class SetNewPasswordControllerTest {
|
||||
|
||||
private static final int CURRENT_USER_ID = 101;
|
||||
private static final long FINGERPRINT_CHALLENGE = -9876512313131L;
|
||||
private static final long FACE_CHALLENGE = 1352057789L;
|
||||
|
||||
@Mock
|
||||
private PackageManager mPackageManager;
|
||||
@@ -76,11 +74,7 @@ public final class SetNewPasswordControllerTest {
|
||||
mSetNewPasswordController = new SetNewPasswordController(
|
||||
CURRENT_USER_ID, mPackageManager, mFingerprintManager, mFaceManager,
|
||||
mDevicePolicyManager, mUi);
|
||||
|
||||
when(mFingerprintManager.generateChallengeBlocking()).thenReturn(FINGERPRINT_CHALLENGE);
|
||||
when(mPackageManager.hasSystemFeature(eq(FEATURE_FINGERPRINT))).thenReturn(true);
|
||||
|
||||
when(mFaceManager.generateChallengeBlocking()).thenReturn(FACE_CHALLENGE);
|
||||
when(mPackageManager.hasSystemFeature(eq(FEATURE_FACE))).thenReturn(true);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user