Merge changes from topics "fp-revokeChallenge", "new-revokeChallenge" into sc-dev

* changes:
  Update fingerprint revokeChallenge with frameworks/base
  Update revokeChallenge together with frameworks/base
This commit is contained in:
Kevin Chyn
2021-03-11 01:14:15 +00:00
committed by Android (Google) Code Review
11 changed files with 48 additions and 3 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,12 +92,16 @@ 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;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
mChallenge = getIntent().getLongExtra(EXTRA_KEY_CHALLENGE, -1L);
mSensorId = getIntent().getIntExtra(EXTRA_KEY_SENSOR_ID, -1);
// Don't need to retrieve the HAT if it already exists. In some cases, the extras do not // Don't need to retrieve the HAT if it already exists. In some cases, the extras do not
// contain EXTRA_KEY_CHALLENGE_TOKEN but contain EXTRA_KEY_GK_PW, in which case enrollment // contain EXTRA_KEY_CHALLENGE_TOKEN but contain EXTRA_KEY_GK_PW, in which case enrollment
// classes may request a HAT to be created (as opposed to being passed in) // classes may request a HAT to be created (as opposed to being passed in)
@@ -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
@@ -192,6 +202,8 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
intent.setClassName(SETTINGS_PACKAGE_NAME, FingerprintEnrollEnrolling.class.getName()); intent.setClassName(SETTINGS_PACKAGE_NAME, FingerprintEnrollEnrolling.class.getName());
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken); intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
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);
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

@@ -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

@@ -121,6 +121,8 @@ public abstract class BiometricsEnrollEnrolling extends BiometricEnrollBase
| Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP); | Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token); intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
intent.putExtra(BiometricEnrollBase.EXTRA_KEY_SENSOR_ID, mSensorId);
intent.putExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, mChallenge);
intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary); intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
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

@@ -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
@@ -97,6 +99,8 @@ public class MultiBiometricEnrollHelper {
mGkPwHandle, mUserId, challenge); mGkPwHandle, mUserId, challenge);
final Intent intent = BiometricUtils.getFingerprintIntroIntent(mActivity, final Intent intent = BiometricUtils.getFingerprintIntroIntent(mActivity,
mActivity.getIntent()); mActivity.getIntent());
intent.putExtra(BiometricEnrollBase.EXTRA_KEY_SENSOR_ID, sensorId);
intent.putExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, challenge);
BiometricUtils.launchEnrollForResult(mActivity, intent, REQUEST_FINGERPRINT_ENROLL, BiometricUtils.launchEnrollForResult(mActivity, intent, REQUEST_FINGERPRINT_ENROLL,
hardwareAuthToken, mGkPwHandle, mUserId); hardwareAuthToken, mGkPwHandle, mUserId);
})); }));

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();

View File

@@ -81,6 +81,8 @@ public class FingerprintEnrollFindSensor extends BiometricEnrollBase {
if (mToken == null && BiometricUtils.containsGatekeeperPasswordHandle(getIntent())) { if (mToken == null && BiometricUtils.containsGatekeeperPasswordHandle(getIntent())) {
final FingerprintManager fpm = getSystemService(FingerprintManager.class); final FingerprintManager fpm = getSystemService(FingerprintManager.class);
fpm.generateChallenge(mUserId, (sensorId, challenge) -> { fpm.generateChallenge(mUserId, (sensorId, challenge) -> {
mChallenge = challenge;
mSensorId = sensorId;
mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge); mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge);
BiometricUtils.removeGatekeeperPasswordHandle(this, getIntent()); BiometricUtils.removeGatekeeperPasswordHandle(this, getIntent());

View File

@@ -141,7 +141,7 @@ public class FingerprintEnrollFinish extends BiometricEnrollBase {
private void postEnroll() { private void postEnroll() {
final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(this); final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(this);
if (fpm != null) { if (fpm != null) {
fpm.revokeChallenge(mUserId); fpm.revokeChallenge(mUserId, mChallenge);
} }
} }
@@ -151,6 +151,7 @@ public class FingerprintEnrollFinish extends BiometricEnrollBase {
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken); intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtra(Intent.EXTRA_USER_ID, mUserId); intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
intent.putExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, mChallenge);
startActivity(intent); startActivity(intent);
} }

View File

@@ -138,6 +138,8 @@ public class FingerprintSettings extends SubSettings {
private CharSequence mFooterTitle; private CharSequence mFooterTitle;
private boolean mEnrollClicked; private boolean mEnrollClicked;
private long mChallenge;
private static final String TAG_AUTHENTICATE_SIDECAR = "authenticate_sidecar"; private static final String TAG_AUTHENTICATE_SIDECAR = "authenticate_sidecar";
private static final String TAG_REMOVAL_SIDECAR = "removal_sidecar"; private static final String TAG_REMOVAL_SIDECAR = "removal_sidecar";
private FingerprintAuthenticateSidecar mAuthenticateSidecar; private FingerprintAuthenticateSidecar mAuthenticateSidecar;
@@ -287,6 +289,8 @@ public class FingerprintSettings extends SubSettings {
mToken = getIntent().getByteArrayExtra( mToken = getIntent().getByteArrayExtra(
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN); ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
mChallenge = activity.getIntent()
.getLongExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, -1L);
mAuthenticateSidecar = (FingerprintAuthenticateSidecar) mAuthenticateSidecar = (FingerprintAuthenticateSidecar)
getFragmentManager().findFragmentByTag(TAG_AUTHENTICATE_SIDECAR); getFragmentManager().findFragmentByTag(TAG_AUTHENTICATE_SIDECAR);
@@ -577,6 +581,7 @@ public class FingerprintSettings extends SubSettings {
mFingerprintManager.generateChallenge(mUserId, (sensorId, challenge) -> { mFingerprintManager.generateChallenge(mUserId, (sensorId, challenge) -> {
mToken = BiometricUtils.requestGatekeeperHat(getActivity(), data, mToken = BiometricUtils.requestGatekeeperHat(getActivity(), data,
mUserId, challenge); mUserId, challenge);
mChallenge = challenge;
BiometricUtils.removeGatekeeperPasswordHandle(getActivity(), data); BiometricUtils.removeGatekeeperPasswordHandle(getActivity(), data);
updateAddPreference(); updateAddPreference();
}); });
@@ -602,7 +607,7 @@ public class FingerprintSettings extends SubSettings {
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
if (getActivity().isFinishing()) { if (getActivity().isFinishing()) {
mFingerprintManager.revokeChallenge(mUserId); mFingerprintManager.revokeChallenge(mUserId, mChallenge);
} }
} }

View File

@@ -40,6 +40,8 @@ public class SetupFingerprintEnrollFindSensor extends FingerprintEnrollFindSenso
protected Intent getFingerprintEnrollingIntent() { protected Intent getFingerprintEnrollingIntent() {
Intent intent = new Intent(this, SetupFingerprintEnrollEnrolling.class); Intent intent = new Intent(this, SetupFingerprintEnrollEnrolling.class);
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken); intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
intent.putExtra(EXTRA_KEY_CHALLENGE, mChallenge);
intent.putExtra(EXTRA_KEY_SENSOR_ID, mSensorId);
if (mUserId != UserHandle.USER_NULL) { if (mUserId != UserHandle.USER_NULL) {
intent.putExtra(Intent.EXTRA_USER_ID, mUserId); intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
} }