Send metric intent back to SUW
Add metric intent if ChooseLockGeneric is triggered in SUW. 1. Save the result bundle data from ChooseLockGeneric to cache inside BiometricEnrollActivity and pass back to SUW after all finished. 2. Since fingerprint enrollment trigger points in SUW for fingerprint-only or fingerprint + faceAuth devices are all moved from SetupFingerprintEnrollIntroduction to BiometricEnrollActivity, remove deprecated code from SetupFingerprintEnrollIntroduction. Bug: 235458700 Test: Manually test fingerprint enroll with SUW or w/o SUW Test: Manually test fingerprint enroll with unicorn SUW Test: atest BiometricEnrollActivityTest Test: robo tests FingerprintEnrollIntroductionTest Change-Id: I34b2884ab4c2c65d464d91eaef0f58c72dad438b
This commit is contained in:
@@ -95,6 +95,8 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
|||||||
private static final String SAVED_STATE_CONFIRMING_CREDENTIALS = "confirming_credentials";
|
private static final String SAVED_STATE_CONFIRMING_CREDENTIALS = "confirming_credentials";
|
||||||
private static final String SAVED_STATE_FINGERPRINT_ONLY_ENROLLING =
|
private static final String SAVED_STATE_FINGERPRINT_ONLY_ENROLLING =
|
||||||
"fingerprint_only_enrolling";
|
"fingerprint_only_enrolling";
|
||||||
|
private static final String SAVED_STATE_PASS_THROUGH_EXTRAS_FROM_CHOSEN_LOCK_IN_SUW =
|
||||||
|
"pass_through_extras_from_chosen_lock_in_suw";
|
||||||
private static final String SAVED_STATE_ENROLL_ACTION_LOGGED = "enroll_action_logged";
|
private static final String SAVED_STATE_ENROLL_ACTION_LOGGED = "enroll_action_logged";
|
||||||
private static final String SAVED_STATE_PARENTAL_OPTIONS = "enroll_preferences";
|
private static final String SAVED_STATE_PARENTAL_OPTIONS = "enroll_preferences";
|
||||||
private static final String SAVED_STATE_GK_PW_HANDLE = "gk_pw_handle";
|
private static final String SAVED_STATE_GK_PW_HANDLE = "gk_pw_handle";
|
||||||
@@ -104,6 +106,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
|||||||
private int mUserId = UserHandle.myUserId();
|
private int mUserId = UserHandle.myUserId();
|
||||||
private boolean mConfirmingCredentials;
|
private boolean mConfirmingCredentials;
|
||||||
private boolean mFingerprintOnlyEnrolling;
|
private boolean mFingerprintOnlyEnrolling;
|
||||||
|
private Bundle mPassThroughExtrasFromChosenLockInSuw = null;
|
||||||
private boolean mIsEnrollActionLogged;
|
private boolean mIsEnrollActionLogged;
|
||||||
private boolean mHasFeatureFace = false;
|
private boolean mHasFeatureFace = false;
|
||||||
private boolean mHasFeatureFingerprint = false;
|
private boolean mHasFeatureFingerprint = false;
|
||||||
@@ -134,6 +137,8 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
|||||||
SAVED_STATE_CONFIRMING_CREDENTIALS, false);
|
SAVED_STATE_CONFIRMING_CREDENTIALS, false);
|
||||||
mFingerprintOnlyEnrolling = savedInstanceState.getBoolean(
|
mFingerprintOnlyEnrolling = savedInstanceState.getBoolean(
|
||||||
SAVED_STATE_FINGERPRINT_ONLY_ENROLLING, false);
|
SAVED_STATE_FINGERPRINT_ONLY_ENROLLING, false);
|
||||||
|
mPassThroughExtrasFromChosenLockInSuw = savedInstanceState.getBundle(
|
||||||
|
SAVED_STATE_PASS_THROUGH_EXTRAS_FROM_CHOSEN_LOCK_IN_SUW);
|
||||||
mIsEnrollActionLogged = savedInstanceState.getBoolean(
|
mIsEnrollActionLogged = savedInstanceState.getBoolean(
|
||||||
SAVED_STATE_ENROLL_ACTION_LOGGED, false);
|
SAVED_STATE_ENROLL_ACTION_LOGGED, false);
|
||||||
mParentalOptions = savedInstanceState.getBundle(SAVED_STATE_PARENTAL_OPTIONS);
|
mParentalOptions = savedInstanceState.getBundle(SAVED_STATE_PARENTAL_OPTIONS);
|
||||||
@@ -330,6 +335,8 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
|||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putBoolean(SAVED_STATE_CONFIRMING_CREDENTIALS, mConfirmingCredentials);
|
outState.putBoolean(SAVED_STATE_CONFIRMING_CREDENTIALS, mConfirmingCredentials);
|
||||||
outState.putBoolean(SAVED_STATE_FINGERPRINT_ONLY_ENROLLING, mFingerprintOnlyEnrolling);
|
outState.putBoolean(SAVED_STATE_FINGERPRINT_ONLY_ENROLLING, mFingerprintOnlyEnrolling);
|
||||||
|
outState.putBundle(SAVED_STATE_PASS_THROUGH_EXTRAS_FROM_CHOSEN_LOCK_IN_SUW,
|
||||||
|
mPassThroughExtrasFromChosenLockInSuw);
|
||||||
outState.putBoolean(SAVED_STATE_ENROLL_ACTION_LOGGED, mIsEnrollActionLogged);
|
outState.putBoolean(SAVED_STATE_ENROLL_ACTION_LOGGED, mIsEnrollActionLogged);
|
||||||
if (mParentalOptions != null) {
|
if (mParentalOptions != null) {
|
||||||
outState.putBundle(SAVED_STATE_PARENTAL_OPTIONS, mParentalOptions);
|
outState.putBundle(SAVED_STATE_PARENTAL_OPTIONS, mParentalOptions);
|
||||||
@@ -343,6 +350,12 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
|||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
|
||||||
|
if (isSuccessfulChooseCredential(requestCode, resultCode)
|
||||||
|
&& data != null && data.getExtras() != null && data.getExtras().size() > 0
|
||||||
|
&& WizardManagerHelper.isAnySetupWizard(getIntent())) {
|
||||||
|
mPassThroughExtrasFromChosenLockInSuw = data.getExtras();
|
||||||
|
}
|
||||||
|
|
||||||
Log.d(TAG,
|
Log.d(TAG,
|
||||||
"onActivityResult(requestCode=" + requestCode + ", resultCode=" + resultCode + ")");
|
"onActivityResult(requestCode=" + requestCode + ", resultCode=" + resultCode + ")");
|
||||||
// single enrollment is handled entirely by the launched activity
|
// single enrollment is handled entirely by the launched activity
|
||||||
@@ -416,7 +429,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "Unknown or cancelled parental consent");
|
Log.d(TAG, "Unknown or cancelled parental consent");
|
||||||
setResult(RESULT_CANCELED);
|
setResult(RESULT_CANCELED, newResultIntent());
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -452,7 +465,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
|||||||
launchFingerprintOnlyEnroll();
|
launchFingerprintOnlyEnroll();
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "Unknown result for set/choose lock: " + resultCode);
|
Log.d(TAG, "Unknown result for set/choose lock: " + resultCode);
|
||||||
setResult(resultCode);
|
setResult(resultCode, newResultIntent());
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -480,25 +493,37 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setResult(resultCode);
|
setResult(resultCode, newResultIntent());
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
private Intent newResultIntent() {
|
private Intent newResultIntent() {
|
||||||
final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
final Bundle consentStatus = mParentalOptions.deepCopy();
|
if (mParentalOptionsRequired && mParentalOptions != null) {
|
||||||
intent.putExtra(EXTRA_PARENTAL_CONSENT_STATUS, consentStatus);
|
final Bundle consentStatus = mParentalOptions.deepCopy();
|
||||||
Log.v(TAG, "Result consent status: " + consentStatus);
|
intent.putExtra(EXTRA_PARENTAL_CONSENT_STATUS, consentStatus);
|
||||||
|
Log.v(TAG, "Result consent status: " + consentStatus);
|
||||||
|
}
|
||||||
|
if (mPassThroughExtrasFromChosenLockInSuw != null) {
|
||||||
|
intent.putExtras(mPassThroughExtrasFromChosenLockInSuw);
|
||||||
|
}
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isSuccessfulConfirmOrChooseCredential(int requestCode, int resultCode) {
|
private static boolean isSuccessfulConfirmOrChooseCredential(int requestCode, int resultCode) {
|
||||||
final boolean okChoose = requestCode == REQUEST_CHOOSE_LOCK
|
return isSuccessfulChooseCredential(requestCode, resultCode)
|
||||||
|
|| isSuccessfulConfirmCredential(requestCode, resultCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isSuccessfulChooseCredential(int requestCode, int resultCode) {
|
||||||
|
return requestCode == REQUEST_CHOOSE_LOCK
|
||||||
&& resultCode == ChooseLockPattern.RESULT_FINISHED;
|
&& resultCode == ChooseLockPattern.RESULT_FINISHED;
|
||||||
final boolean okConfirm = requestCode == REQUEST_CONFIRM_LOCK
|
}
|
||||||
&& resultCode == RESULT_OK;
|
|
||||||
return okChoose || okConfirm;
|
private static boolean isSuccessfulConfirmCredential(int requestCode, int resultCode) {
|
||||||
|
return requestCode == REQUEST_CONFIRM_LOCK && resultCode == RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -16,21 +16,16 @@
|
|||||||
|
|
||||||
package com.android.settings.biometrics.fingerprint;
|
package com.android.settings.biometrics.fingerprint;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.KeyguardManager;
|
import android.app.KeyguardManager;
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.hardware.fingerprint.FingerprintManager;
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.UserHandle;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.android.internal.widget.LockPatternUtils;
|
|
||||||
import com.android.settings.SetupWizardUtils;
|
import com.android.settings.SetupWizardUtils;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.biometrics.BiometricUtils;
|
import com.android.settings.biometrics.BiometricUtils;
|
||||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||||
import com.android.settings.password.SetupChooseLockGeneric;
|
|
||||||
import com.android.settings.password.SetupSkipDialog;
|
import com.android.settings.password.SetupSkipDialog;
|
||||||
|
|
||||||
public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntroduction {
|
public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntroduction {
|
||||||
@@ -40,24 +35,6 @@ public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntrodu
|
|||||||
private static final String EXTRA_FINGERPRINT_ENROLLED_COUNT = "fingerprint_enrolled_count";
|
private static final String EXTRA_FINGERPRINT_ENROLLED_COUNT = "fingerprint_enrolled_count";
|
||||||
|
|
||||||
private static final String KEY_LOCK_SCREEN_PRESENT = "wasLockScreenPresent";
|
private static final String KEY_LOCK_SCREEN_PRESENT = "wasLockScreenPresent";
|
||||||
private boolean mAlreadyHadLockScreenSetup = false;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
if (savedInstanceState == null) {
|
|
||||||
mAlreadyHadLockScreenSetup = isKeyguardSecure();
|
|
||||||
} else {
|
|
||||||
mAlreadyHadLockScreenSetup = savedInstanceState.getBoolean(
|
|
||||||
KEY_LOCK_SCREEN_PRESENT, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
|
||||||
super.onSaveInstanceState(outState);
|
|
||||||
outState.putBoolean(KEY_LOCK_SCREEN_PRESENT, mAlreadyHadLockScreenSetup);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Intent getEnrollingIntent() {
|
protected Intent getEnrollingIntent() {
|
||||||
@@ -85,12 +62,6 @@ public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntrodu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (requestCode == BIOMETRIC_FIND_SENSOR_REQUEST && isKeyguardSecure()) {
|
if (requestCode == BIOMETRIC_FIND_SENSOR_REQUEST && isKeyguardSecure()) {
|
||||||
// if lock was already present, do not return intent data since it must have been
|
|
||||||
// reported in previous attempts
|
|
||||||
if (!mAlreadyHadLockScreenSetup) {
|
|
||||||
data = getMetricIntent(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Report fingerprint count if user adding a new fingerprint
|
// Report fingerprint count if user adding a new fingerprint
|
||||||
if (resultCode == RESULT_FINISHED) {
|
if (resultCode == RESULT_FINISHED) {
|
||||||
data = setFingerprintCount(data);
|
data = setFingerprintCount(data);
|
||||||
@@ -127,18 +98,6 @@ public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntrodu
|
|||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Intent getMetricIntent(Intent data) {
|
|
||||||
if (data == null) {
|
|
||||||
data = new Intent();
|
|
||||||
}
|
|
||||||
LockPatternUtils lockPatternUtils = new LockPatternUtils(this);
|
|
||||||
data.putExtra(SetupChooseLockGeneric.
|
|
||||||
SetupChooseLockGenericFragment.EXTRA_PASSWORD_QUALITY,
|
|
||||||
lockPatternUtils.getKeyguardStoredPasswordQuality(UserHandle.myUserId()));
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Intent setFingerprintCount(Intent data) {
|
private Intent setFingerprintCount(Intent data) {
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
data = new Intent();
|
data = new Intent();
|
||||||
@@ -161,8 +120,7 @@ public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntrodu
|
|||||||
if (!BiometricUtils.tryStartingNextBiometricEnroll(
|
if (!BiometricUtils.tryStartingNextBiometricEnroll(
|
||||||
this, ENROLL_NEXT_BIOMETRIC_REQUEST, "cancel")) {
|
this, ENROLL_NEXT_BIOMETRIC_REQUEST, "cancel")) {
|
||||||
resultCode = RESULT_SKIP;
|
resultCode = RESULT_SKIP;
|
||||||
data = mAlreadyHadLockScreenSetup ? null : getMetricIntent(null);
|
setResult(resultCode);
|
||||||
setResult(resultCode, data);
|
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -176,18 +134,6 @@ public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntrodu
|
|||||||
// User has explicitly canceled enroll. Don't restart it automatically.
|
// User has explicitly canceled enroll. Don't restart it automatically.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Propagate lock screen metrics if the user goes back from the fingerprint setup screen
|
|
||||||
* after having added lock screen to his device.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onBackPressed() {
|
|
||||||
if (!mAlreadyHadLockScreenSetup && isKeyguardSecure()) {
|
|
||||||
setResult(Activity.RESULT_CANCELED, getMetricIntent(null));
|
|
||||||
}
|
|
||||||
super.onBackPressed();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isKeyguardSecure() {
|
private boolean isKeyguardSecure() {
|
||||||
return getSystemService(KeyguardManager.class).isKeyguardSecure();
|
return getSystemService(KeyguardManager.class).isKeyguardSecure();
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,6 @@ import android.widget.Button;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.biometrics.BiometricEnrollBase;
|
import com.android.settings.biometrics.BiometricEnrollBase;
|
||||||
import com.android.settings.biometrics.BiometricEnrollIntroduction;
|
import com.android.settings.biometrics.BiometricEnrollIntroduction;
|
||||||
import com.android.settings.password.SetupChooseLockGeneric.SetupChooseLockGenericFragment;
|
|
||||||
import com.android.settings.password.SetupSkipDialog;
|
import com.android.settings.password.SetupSkipDialog;
|
||||||
import com.android.settings.testutils.FakeFeatureFactory;
|
import com.android.settings.testutils.FakeFeatureFactory;
|
||||||
import com.android.settings.testutils.shadow.ShadowFingerprintManager;
|
import com.android.settings.testutils.shadow.ShadowFingerprintManager;
|
||||||
@@ -160,8 +159,6 @@ public class SetupFingerprintEnrollIntroductionTest {
|
|||||||
|
|
||||||
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
||||||
assertThat(shadowActivity.getResultIntent()).isNotNull();
|
assertThat(shadowActivity.getResultIntent()).isNotNull();
|
||||||
assertThat(shadowActivity.getResultIntent().hasExtra(
|
|
||||||
SetupChooseLockGenericFragment.EXTRA_PASSWORD_QUALITY)).isTrue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -191,8 +188,6 @@ public class SetupFingerprintEnrollIntroductionTest {
|
|||||||
|
|
||||||
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
||||||
assertThat(shadowActivity.getResultIntent()).isNotNull();
|
assertThat(shadowActivity.getResultIntent()).isNotNull();
|
||||||
assertThat(shadowActivity.getResultIntent().hasExtra(
|
|
||||||
SetupChooseLockGenericFragment.EXTRA_PASSWORD_QUALITY)).isTrue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -218,8 +213,6 @@ public class SetupFingerprintEnrollIntroductionTest {
|
|||||||
BiometricEnrollBase.RESULT_FINISHED, null);
|
BiometricEnrollBase.RESULT_FINISHED, null);
|
||||||
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
||||||
assertThat(shadowActivity.getResultIntent()).isNotNull();
|
assertThat(shadowActivity.getResultIntent()).isNotNull();
|
||||||
assertThat(shadowActivity.getResultIntent().hasExtra(
|
|
||||||
SetupChooseLockGenericFragment.EXTRA_PASSWORD_QUALITY)).isFalse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -260,8 +253,6 @@ public class SetupFingerprintEnrollIntroductionTest {
|
|||||||
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
||||||
IntentForResult startedActivity = shadowActivity.getNextStartedActivityForResult();
|
IntentForResult startedActivity = shadowActivity.getNextStartedActivityForResult();
|
||||||
assertThat(startedActivity).isNotNull();
|
assertThat(startedActivity).isNotNull();
|
||||||
assertThat(startedActivity.intent.hasExtra(
|
|
||||||
SetupChooseLockGenericFragment.EXTRA_PASSWORD_QUALITY)).isFalse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ShadowKeyguardManager getShadowKeyguardManager() {
|
private ShadowKeyguardManager getShadowKeyguardManager() {
|
||||||
|
Reference in New Issue
Block a user