Loading src/com/android/settings/biometrics/BiometricEnrollActivity.java +35 −10 Original line number Diff line number Diff line Loading @@ -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_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_PARENTAL_OPTIONS = "enroll_preferences"; private static final String SAVED_STATE_GK_PW_HANDLE = "gk_pw_handle"; Loading @@ -104,6 +106,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity { private int mUserId = UserHandle.myUserId(); private boolean mConfirmingCredentials; private boolean mFingerprintOnlyEnrolling; private Bundle mPassThroughExtrasFromChosenLockInSuw = null; private boolean mIsEnrollActionLogged; private boolean mHasFeatureFace = false; private boolean mHasFeatureFingerprint = false; Loading Loading @@ -134,6 +137,8 @@ public class BiometricEnrollActivity extends InstrumentedActivity { SAVED_STATE_CONFIRMING_CREDENTIALS, false); mFingerprintOnlyEnrolling = savedInstanceState.getBoolean( SAVED_STATE_FINGERPRINT_ONLY_ENROLLING, false); mPassThroughExtrasFromChosenLockInSuw = savedInstanceState.getBundle( SAVED_STATE_PASS_THROUGH_EXTRAS_FROM_CHOSEN_LOCK_IN_SUW); mIsEnrollActionLogged = savedInstanceState.getBoolean( SAVED_STATE_ENROLL_ACTION_LOGGED, false); mParentalOptions = savedInstanceState.getBundle(SAVED_STATE_PARENTAL_OPTIONS); Loading Loading @@ -330,6 +335,8 @@ public class BiometricEnrollActivity extends InstrumentedActivity { super.onSaveInstanceState(outState); outState.putBoolean(SAVED_STATE_CONFIRMING_CREDENTIALS, mConfirmingCredentials); 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); if (mParentalOptions != null) { outState.putBundle(SAVED_STATE_PARENTAL_OPTIONS, mParentalOptions); Loading @@ -343,6 +350,12 @@ public class BiometricEnrollActivity extends InstrumentedActivity { protected void onActivityResult(int requestCode, int resultCode, Intent 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, "onActivityResult(requestCode=" + requestCode + ", resultCode=" + resultCode + ")"); // single enrollment is handled entirely by the launched activity Loading Loading @@ -416,7 +429,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity { } } else { Log.d(TAG, "Unknown or cancelled parental consent"); setResult(RESULT_CANCELED); setResult(RESULT_CANCELED, newResultIntent()); finish(); } break; Loading Loading @@ -452,7 +465,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity { launchFingerprintOnlyEnroll(); } else { Log.d(TAG, "Unknown result for set/choose lock: " + resultCode); setResult(resultCode); setResult(resultCode, newResultIntent()); finish(); } break; Loading Loading @@ -480,25 +493,37 @@ public class BiometricEnrollActivity extends InstrumentedActivity { finish(); } } else { setResult(resultCode); setResult(resultCode, newResultIntent()); finish(); } } @NonNull private Intent newResultIntent() { final Intent intent = new Intent(); if (mParentalOptionsRequired && mParentalOptions != null) { final Bundle consentStatus = mParentalOptions.deepCopy(); intent.putExtra(EXTRA_PARENTAL_CONSENT_STATUS, consentStatus); Log.v(TAG, "Result consent status: " + consentStatus); } if (mPassThroughExtrasFromChosenLockInSuw != null) { intent.putExtras(mPassThroughExtrasFromChosenLockInSuw); } return intent; } 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; 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 Loading src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroduction.java +1 −55 Original line number Diff line number Diff line Loading @@ -16,21 +16,16 @@ package com.android.settings.biometrics.fingerprint; import android.app.Activity; import android.app.KeyguardManager; import android.app.settings.SettingsEnums; import android.content.Intent; import android.hardware.fingerprint.FingerprintManager; import android.os.Bundle; import android.os.UserHandle; import android.view.View; import com.android.internal.widget.LockPatternUtils; import com.android.settings.SetupWizardUtils; import com.android.settings.Utils; import com.android.settings.biometrics.BiometricUtils; import com.android.settings.password.ChooseLockSettingsHelper; import com.android.settings.password.SetupChooseLockGeneric; import com.android.settings.password.SetupSkipDialog; public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntroduction { Loading @@ -40,24 +35,6 @@ public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntrodu private static final String EXTRA_FINGERPRINT_ENROLLED_COUNT = "fingerprint_enrolled_count"; 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 protected Intent getEnrollingIntent() { Loading Loading @@ -85,12 +62,6 @@ public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntrodu } } 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 if (resultCode == RESULT_FINISHED) { data = setFingerprintCount(data); Loading Loading @@ -127,18 +98,6 @@ public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntrodu 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) { if (data == null) { data = new Intent(); Loading @@ -161,8 +120,7 @@ public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntrodu if (!BiometricUtils.tryStartingNextBiometricEnroll( this, ENROLL_NEXT_BIOMETRIC_REQUEST, "cancel")) { resultCode = RESULT_SKIP; data = mAlreadyHadLockScreenSetup ? null : getMetricIntent(null); setResult(resultCode, data); setResult(resultCode); finish(); return; } Loading @@ -176,18 +134,6 @@ public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntrodu // 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() { return getSystemService(KeyguardManager.class).isKeyguardSecure(); } Loading tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroductionTest.java +0 −9 Original line number Diff line number Diff line Loading @@ -34,7 +34,6 @@ import android.widget.Button; import com.android.settings.R; import com.android.settings.biometrics.BiometricEnrollBase; import com.android.settings.biometrics.BiometricEnrollIntroduction; import com.android.settings.password.SetupChooseLockGeneric.SetupChooseLockGenericFragment; import com.android.settings.password.SetupSkipDialog; import com.android.settings.testutils.FakeFeatureFactory; import com.android.settings.testutils.shadow.ShadowFingerprintManager; Loading Loading @@ -160,8 +159,6 @@ public class SetupFingerprintEnrollIntroductionTest { ShadowActivity shadowActivity = Shadows.shadowOf(activity); assertThat(shadowActivity.getResultIntent()).isNotNull(); assertThat(shadowActivity.getResultIntent().hasExtra( SetupChooseLockGenericFragment.EXTRA_PASSWORD_QUALITY)).isTrue(); } @Test Loading Loading @@ -191,8 +188,6 @@ public class SetupFingerprintEnrollIntroductionTest { ShadowActivity shadowActivity = Shadows.shadowOf(activity); assertThat(shadowActivity.getResultIntent()).isNotNull(); assertThat(shadowActivity.getResultIntent().hasExtra( SetupChooseLockGenericFragment.EXTRA_PASSWORD_QUALITY)).isTrue(); } @Test Loading @@ -218,8 +213,6 @@ public class SetupFingerprintEnrollIntroductionTest { BiometricEnrollBase.RESULT_FINISHED, null); ShadowActivity shadowActivity = Shadows.shadowOf(activity); assertThat(shadowActivity.getResultIntent()).isNotNull(); assertThat(shadowActivity.getResultIntent().hasExtra( SetupChooseLockGenericFragment.EXTRA_PASSWORD_QUALITY)).isFalse(); } @Test Loading Loading @@ -260,8 +253,6 @@ public class SetupFingerprintEnrollIntroductionTest { ShadowActivity shadowActivity = Shadows.shadowOf(activity); IntentForResult startedActivity = shadowActivity.getNextStartedActivityForResult(); assertThat(startedActivity).isNotNull(); assertThat(startedActivity.intent.hasExtra( SetupChooseLockGenericFragment.EXTRA_PASSWORD_QUALITY)).isFalse(); } private ShadowKeyguardManager getShadowKeyguardManager() { Loading Loading
src/com/android/settings/biometrics/BiometricEnrollActivity.java +35 −10 Original line number Diff line number Diff line Loading @@ -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_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_PARENTAL_OPTIONS = "enroll_preferences"; private static final String SAVED_STATE_GK_PW_HANDLE = "gk_pw_handle"; Loading @@ -104,6 +106,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity { private int mUserId = UserHandle.myUserId(); private boolean mConfirmingCredentials; private boolean mFingerprintOnlyEnrolling; private Bundle mPassThroughExtrasFromChosenLockInSuw = null; private boolean mIsEnrollActionLogged; private boolean mHasFeatureFace = false; private boolean mHasFeatureFingerprint = false; Loading Loading @@ -134,6 +137,8 @@ public class BiometricEnrollActivity extends InstrumentedActivity { SAVED_STATE_CONFIRMING_CREDENTIALS, false); mFingerprintOnlyEnrolling = savedInstanceState.getBoolean( SAVED_STATE_FINGERPRINT_ONLY_ENROLLING, false); mPassThroughExtrasFromChosenLockInSuw = savedInstanceState.getBundle( SAVED_STATE_PASS_THROUGH_EXTRAS_FROM_CHOSEN_LOCK_IN_SUW); mIsEnrollActionLogged = savedInstanceState.getBoolean( SAVED_STATE_ENROLL_ACTION_LOGGED, false); mParentalOptions = savedInstanceState.getBundle(SAVED_STATE_PARENTAL_OPTIONS); Loading Loading @@ -330,6 +335,8 @@ public class BiometricEnrollActivity extends InstrumentedActivity { super.onSaveInstanceState(outState); outState.putBoolean(SAVED_STATE_CONFIRMING_CREDENTIALS, mConfirmingCredentials); 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); if (mParentalOptions != null) { outState.putBundle(SAVED_STATE_PARENTAL_OPTIONS, mParentalOptions); Loading @@ -343,6 +350,12 @@ public class BiometricEnrollActivity extends InstrumentedActivity { protected void onActivityResult(int requestCode, int resultCode, Intent 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, "onActivityResult(requestCode=" + requestCode + ", resultCode=" + resultCode + ")"); // single enrollment is handled entirely by the launched activity Loading Loading @@ -416,7 +429,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity { } } else { Log.d(TAG, "Unknown or cancelled parental consent"); setResult(RESULT_CANCELED); setResult(RESULT_CANCELED, newResultIntent()); finish(); } break; Loading Loading @@ -452,7 +465,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity { launchFingerprintOnlyEnroll(); } else { Log.d(TAG, "Unknown result for set/choose lock: " + resultCode); setResult(resultCode); setResult(resultCode, newResultIntent()); finish(); } break; Loading Loading @@ -480,25 +493,37 @@ public class BiometricEnrollActivity extends InstrumentedActivity { finish(); } } else { setResult(resultCode); setResult(resultCode, newResultIntent()); finish(); } } @NonNull private Intent newResultIntent() { final Intent intent = new Intent(); if (mParentalOptionsRequired && mParentalOptions != null) { final Bundle consentStatus = mParentalOptions.deepCopy(); intent.putExtra(EXTRA_PARENTAL_CONSENT_STATUS, consentStatus); Log.v(TAG, "Result consent status: " + consentStatus); } if (mPassThroughExtrasFromChosenLockInSuw != null) { intent.putExtras(mPassThroughExtrasFromChosenLockInSuw); } return intent; } 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; 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 Loading
src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroduction.java +1 −55 Original line number Diff line number Diff line Loading @@ -16,21 +16,16 @@ package com.android.settings.biometrics.fingerprint; import android.app.Activity; import android.app.KeyguardManager; import android.app.settings.SettingsEnums; import android.content.Intent; import android.hardware.fingerprint.FingerprintManager; import android.os.Bundle; import android.os.UserHandle; import android.view.View; import com.android.internal.widget.LockPatternUtils; import com.android.settings.SetupWizardUtils; import com.android.settings.Utils; import com.android.settings.biometrics.BiometricUtils; import com.android.settings.password.ChooseLockSettingsHelper; import com.android.settings.password.SetupChooseLockGeneric; import com.android.settings.password.SetupSkipDialog; public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntroduction { Loading @@ -40,24 +35,6 @@ public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntrodu private static final String EXTRA_FINGERPRINT_ENROLLED_COUNT = "fingerprint_enrolled_count"; 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 protected Intent getEnrollingIntent() { Loading Loading @@ -85,12 +62,6 @@ public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntrodu } } 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 if (resultCode == RESULT_FINISHED) { data = setFingerprintCount(data); Loading Loading @@ -127,18 +98,6 @@ public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntrodu 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) { if (data == null) { data = new Intent(); Loading @@ -161,8 +120,7 @@ public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntrodu if (!BiometricUtils.tryStartingNextBiometricEnroll( this, ENROLL_NEXT_BIOMETRIC_REQUEST, "cancel")) { resultCode = RESULT_SKIP; data = mAlreadyHadLockScreenSetup ? null : getMetricIntent(null); setResult(resultCode, data); setResult(resultCode); finish(); return; } Loading @@ -176,18 +134,6 @@ public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntrodu // 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() { return getSystemService(KeyguardManager.class).isKeyguardSecure(); } Loading
tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroductionTest.java +0 −9 Original line number Diff line number Diff line Loading @@ -34,7 +34,6 @@ import android.widget.Button; import com.android.settings.R; import com.android.settings.biometrics.BiometricEnrollBase; import com.android.settings.biometrics.BiometricEnrollIntroduction; import com.android.settings.password.SetupChooseLockGeneric.SetupChooseLockGenericFragment; import com.android.settings.password.SetupSkipDialog; import com.android.settings.testutils.FakeFeatureFactory; import com.android.settings.testutils.shadow.ShadowFingerprintManager; Loading Loading @@ -160,8 +159,6 @@ public class SetupFingerprintEnrollIntroductionTest { ShadowActivity shadowActivity = Shadows.shadowOf(activity); assertThat(shadowActivity.getResultIntent()).isNotNull(); assertThat(shadowActivity.getResultIntent().hasExtra( SetupChooseLockGenericFragment.EXTRA_PASSWORD_QUALITY)).isTrue(); } @Test Loading Loading @@ -191,8 +188,6 @@ public class SetupFingerprintEnrollIntroductionTest { ShadowActivity shadowActivity = Shadows.shadowOf(activity); assertThat(shadowActivity.getResultIntent()).isNotNull(); assertThat(shadowActivity.getResultIntent().hasExtra( SetupChooseLockGenericFragment.EXTRA_PASSWORD_QUALITY)).isTrue(); } @Test Loading @@ -218,8 +213,6 @@ public class SetupFingerprintEnrollIntroductionTest { BiometricEnrollBase.RESULT_FINISHED, null); ShadowActivity shadowActivity = Shadows.shadowOf(activity); assertThat(shadowActivity.getResultIntent()).isNotNull(); assertThat(shadowActivity.getResultIntent().hasExtra( SetupChooseLockGenericFragment.EXTRA_PASSWORD_QUALITY)).isFalse(); } @Test Loading Loading @@ -260,8 +253,6 @@ public class SetupFingerprintEnrollIntroductionTest { ShadowActivity shadowActivity = Shadows.shadowOf(activity); IntentForResult startedActivity = shadowActivity.getNextStartedActivityForResult(); assertThat(startedActivity).isNotNull(); assertThat(startedActivity.intent.hasExtra( SetupChooseLockGenericFragment.EXTRA_PASSWORD_QUALITY)).isFalse(); } private ShadowKeyguardManager getShadowKeyguardManager() { Loading