Update revokeChallenge together with frameworks/base

Bug: 181977689
Test: Inspect logs
Change-Id: I588ec46896d57d89489f78505a6f2c932462b2d2
This commit is contained in:
Kevin Chyn
2021-03-09 13:16:58 -08:00
parent fc037c26dd
commit e91e39b604
6 changed files with 30 additions and 1 deletions

View File

@@ -48,6 +48,8 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
public static final String EXTRA_KEY_LAUNCHED_CONFIRM = "launched_confirm_lock"; public static final String EXTRA_KEY_LAUNCHED_CONFIRM = "launched_confirm_lock";
public static final String EXTRA_KEY_REQUIRE_VISION = "accessibility_vision"; public static final String EXTRA_KEY_REQUIRE_VISION = "accessibility_vision";
public static final String EXTRA_KEY_REQUIRE_DIVERSITY = "accessibility_diversity"; public static final String EXTRA_KEY_REQUIRE_DIVERSITY = "accessibility_diversity";
public static final String EXTRA_KEY_SENSOR_ID = "sensor_id";
public static final String EXTRA_KEY_CHALLENGE = "challenge";
/** /**
* Used by the choose fingerprint wizard to indicate the wizard is * Used by the choose fingerprint wizard to indicate the wizard is
@@ -90,6 +92,8 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
protected boolean mLaunchedConfirmLock; protected boolean mLaunchedConfirmLock;
protected byte[] mToken; protected byte[] mToken;
protected int mUserId; protected int mUserId;
protected int mSensorId;
protected long mChallenge;
protected boolean mFromSettingsSummary; protected boolean mFromSettingsSummary;
protected FooterBarMixin mFooterBarMixin; protected FooterBarMixin mFooterBarMixin;
@@ -102,6 +106,8 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
if (mToken == null) { if (mToken == null) {
mToken = getIntent().getByteArrayExtra( mToken = getIntent().getByteArrayExtra(
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN); ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
mChallenge = getIntent().getLongExtra(EXTRA_KEY_CHALLENGE, 0L);
mSensorId = getIntent().getIntExtra(EXTRA_KEY_SENSOR_ID, -1);
} }
mFromSettingsSummary = getIntent().getBooleanExtra(EXTRA_FROM_SETTINGS_SUMMARY, false); mFromSettingsSummary = getIntent().getBooleanExtra(EXTRA_FROM_SETTINGS_SUMMARY, false);
if (savedInstanceState != null && mToken == null) { if (savedInstanceState != null && mToken == null) {
@@ -110,6 +116,8 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN); ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
mFromSettingsSummary = mFromSettingsSummary =
savedInstanceState.getBoolean(EXTRA_FROM_SETTINGS_SUMMARY, false); savedInstanceState.getBoolean(EXTRA_FROM_SETTINGS_SUMMARY, false);
mChallenge = savedInstanceState.getLong(EXTRA_KEY_CHALLENGE);
mSensorId = savedInstanceState.getInt(EXTRA_KEY_SENSOR_ID);
} }
mUserId = getIntent().getIntExtra(Intent.EXTRA_USER_ID, UserHandle.myUserId()); mUserId = getIntent().getIntExtra(Intent.EXTRA_USER_ID, UserHandle.myUserId());
} }
@@ -127,6 +135,8 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
outState.putBoolean(EXTRA_KEY_LAUNCHED_CONFIRM, mLaunchedConfirmLock); outState.putBoolean(EXTRA_KEY_LAUNCHED_CONFIRM, mLaunchedConfirmLock);
outState.putByteArray(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken); outState.putByteArray(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
outState.putBoolean(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary); outState.putBoolean(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
outState.putLong(EXTRA_KEY_CHALLENGE, mChallenge);
outState.putInt(EXTRA_KEY_SENSOR_ID, mSensorId);
} }
@Override @Override

View File

@@ -243,6 +243,8 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
} }
BiometricUtils.copyMultiBiometricExtras(getIntent(), intent); BiometricUtils.copyMultiBiometricExtras(getIntent(), intent);
intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary); intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
intent.putExtra(EXTRA_KEY_CHALLENGE, mChallenge);
intent.putExtra(EXTRA_KEY_SENSOR_ID, mSensorId);
startActivityForResult(intent, BIOMETRIC_FIND_SENSOR_REQUEST); startActivityForResult(intent, BIOMETRIC_FIND_SENSOR_REQUEST);
} }
@@ -262,6 +264,8 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out); overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
getNextButton().setEnabled(false); getNextButton().setEnabled(false);
getChallenge(((sensorId, challenge) -> { getChallenge(((sensorId, challenge) -> {
mSensorId = sensorId;
mChallenge = challenge;
mToken = BiometricUtils.requestGatekeeperHat(this, data, mUserId, challenge); mToken = BiometricUtils.requestGatekeeperHat(this, data, mUserId, challenge);
BiometricUtils.removeGatekeeperPasswordHandle(this, data); BiometricUtils.removeGatekeeperPasswordHandle(this, data);
getNextButton().setEnabled(true); getNextButton().setEnabled(true);
@@ -276,6 +280,8 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out); overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
getNextButton().setEnabled(false); getNextButton().setEnabled(false);
getChallenge(((sensorId, challenge) -> { getChallenge(((sensorId, challenge) -> {
mSensorId = sensorId;
mChallenge = challenge;
mToken = BiometricUtils.requestGatekeeperHat(this, data, mUserId, challenge); mToken = BiometricUtils.requestGatekeeperHat(this, data, mUserId, challenge);
BiometricUtils.removeGatekeeperPasswordHandle(this, data); BiometricUtils.removeGatekeeperPasswordHandle(this, data);
getNextButton().setEnabled(true); getNextButton().setEnabled(true);

View File

@@ -72,6 +72,8 @@ public class MultiBiometricEnrollHelper {
mGkPwHandle, mUserId, challenge); mGkPwHandle, mUserId, challenge);
final Intent faceIntent = BiometricUtils.getFaceIntroIntent(mActivity, final Intent faceIntent = BiometricUtils.getFaceIntroIntent(mActivity,
mActivity.getIntent()); mActivity.getIntent());
faceIntent.putExtra(BiometricEnrollBase.EXTRA_KEY_SENSOR_ID, sensorId);
faceIntent.putExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, challenge);
if (mRequestEnrollFingerprint) { if (mRequestEnrollFingerprint) {
// Give FaceEnroll a pendingIntent pointing to fingerprint enrollment, so that it // Give FaceEnroll a pendingIntent pointing to fingerprint enrollment, so that it

View File

@@ -183,6 +183,8 @@ public class FaceEnrollEducation extends BiometricEnrollBase {
if (mUserId != UserHandle.USER_NULL) { if (mUserId != UserHandle.USER_NULL) {
intent.putExtra(Intent.EXTRA_USER_ID, mUserId); intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
} }
intent.putExtra(EXTRA_KEY_CHALLENGE, mChallenge);
intent.putExtra(EXTRA_KEY_SENSOR_ID, mSensorId);
intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary); intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
BiometricUtils.copyMultiBiometricExtras(getIntent(), intent); BiometricUtils.copyMultiBiometricExtras(getIntent(), intent);
final String flattenedString = getString(R.string.config_face_enroll); final String flattenedString = getString(R.string.config_face_enroll);

View File

@@ -112,6 +112,8 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
// the challenge is ready. Let's just do this for now. // the challenge is ready. Let's just do this for now.
mFaceManager.generateChallenge((sensorId, challenge) -> { mFaceManager.generateChallenge((sensorId, challenge) -> {
mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge); mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge);
mSensorId = sensorId;
mChallenge = challenge;
if (BiometricUtils.isMultiBiometricEnrollmentFlow(this)) { if (BiometricUtils.isMultiBiometricEnrollmentFlow(this)) {
BiometricUtils.removeGatekeeperPasswordHandle(this, getIntent()); BiometricUtils.removeGatekeeperPasswordHandle(this, getIntent());
} }

View File

@@ -37,6 +37,7 @@ import androidx.preference.Preference;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.SettingsActivity; import com.android.settings.SettingsActivity;
import com.android.settings.Utils; import com.android.settings.Utils;
import com.android.settings.biometrics.BiometricEnrollBase;
import com.android.settings.biometrics.BiometricUtils; import com.android.settings.biometrics.BiometricUtils;
import com.android.settings.dashboard.DashboardFragment; import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory; import com.android.settings.overlay.FeatureFactory;
@@ -67,6 +68,8 @@ public class FaceSettings extends DashboardFragment {
private UserManager mUserManager; private UserManager mUserManager;
private FaceManager mFaceManager; private FaceManager mFaceManager;
private int mUserId; private int mUserId;
private int mSensorId;
private long mChallenge;
private byte[] mToken; private byte[] mToken;
private FaceSettingsAttentionPreferenceController mAttentionController; private FaceSettingsAttentionPreferenceController mAttentionController;
private FaceSettingsRemoveButtonPreferenceController mRemoveController; private FaceSettingsRemoveButtonPreferenceController mRemoveController;
@@ -147,6 +150,8 @@ public class FaceSettings extends DashboardFragment {
mUserManager = context.getSystemService(UserManager.class); mUserManager = context.getSystemService(UserManager.class);
mFaceManager = context.getSystemService(FaceManager.class); mFaceManager = context.getSystemService(FaceManager.class);
mToken = getIntent().getByteArrayExtra(KEY_TOKEN); mToken = getIntent().getByteArrayExtra(KEY_TOKEN);
mSensorId = getIntent().getIntExtra(BiometricEnrollBase.EXTRA_KEY_SENSOR_ID, -1);
mChallenge = getIntent().getLongExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, 0L);
mUserId = getActivity().getIntent().getIntExtra( mUserId = getActivity().getIntent().getIntExtra(
Intent.EXTRA_USER_ID, UserHandle.myUserId()); Intent.EXTRA_USER_ID, UserHandle.myUserId());
@@ -247,6 +252,8 @@ public class FaceSettings extends DashboardFragment {
mFaceManager.generateChallenge((sensorId, challenge) -> { mFaceManager.generateChallenge((sensorId, challenge) -> {
mToken = BiometricUtils.requestGatekeeperHat(getPrefContext(), data, mUserId, mToken = BiometricUtils.requestGatekeeperHat(getPrefContext(), data, mUserId,
challenge); challenge);
mSensorId = sensorId;
mChallenge = challenge;
BiometricUtils.removeGatekeeperPasswordHandle(getPrefContext(), data); BiometricUtils.removeGatekeeperPasswordHandle(getPrefContext(), data);
mAttentionController.setToken(mToken); mAttentionController.setToken(mToken);
mEnrollController.setToken(mToken); mEnrollController.setToken(mToken);
@@ -269,7 +276,7 @@ public class FaceSettings extends DashboardFragment {
&& !mConfirmingPassword) { && !mConfirmingPassword) {
// Revoke challenge and finish // Revoke challenge and finish
if (mToken != null) { if (mToken != null) {
mFaceManager.revokeChallenge(); mFaceManager.revokeChallenge(mSensorId, mUserId, mChallenge);
mToken = null; mToken = null;
} }
finish(); finish();