Merge "[BiometricsV2] IconTouchDialog continue enroll" into udc-dev am: eb3e62f639

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/22552762

Change-Id: I0cf610f65f2c374812665ea34141e22cce909c45
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2023-04-12 07:39:49 +00:00
committed by Automerger Merge Worker
5 changed files with 147 additions and 81 deletions

View File

@@ -18,14 +18,11 @@ package com.android.settings.biometrics2.ui.view;
import android.app.Dialog;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.os.Bundle;
import androidx.appcompat.app.AlertDialog;
import androidx.lifecycle.ViewModelProvider;
import com.android.settings.R;
import com.android.settings.biometrics2.ui.viewmodel.FingerprintEnrollEnrollingViewModel;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
/**
@@ -33,15 +30,6 @@ import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
*/
public class FingerprintEnrollEnrollingIconTouchDialog extends InstrumentedDialogFragment {
private FingerprintEnrollEnrollingViewModel mViewModel;
@Override
public void onAttach(Context context) {
mViewModel = new ViewModelProvider(getActivity()).get(
FingerprintEnrollEnrollingViewModel.class);
super.onAttach(context);
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(),
@@ -50,10 +38,7 @@ public class FingerprintEnrollEnrollingIconTouchDialog extends InstrumentedDialo
.setMessage(R.string.security_settings_fingerprint_enroll_touch_dialog_message)
.setPositiveButton(
R.string.security_settings_fingerprint_enroll_dialog_ok,
(dialog, which) -> {
dialog.dismiss();
mViewModel.onIconTouchDialogDismiss();
});
(dialog, which) -> dialog.dismiss());
return builder.create();
}

View File

@@ -27,7 +27,6 @@ import static com.android.settings.biometrics2.ui.viewmodel.AutoCredentialViewMo
import static com.android.settings.biometrics2.ui.viewmodel.AutoCredentialViewModel.CREDENTIAL_IS_GENERATING_CHALLENGE;
import static com.android.settings.biometrics2.ui.viewmodel.AutoCredentialViewModel.CREDENTIAL_VALID;
import static com.android.settings.biometrics2.ui.viewmodel.FingerprintEnrollEnrollingViewModel.ErrorDialogData;
import static com.android.settings.biometrics2.ui.viewmodel.FingerprintEnrollEnrollingViewModel.FINGERPRINT_ENROLL_ENROLLING_ACTION_DISMISS_ICON_TOUCH_DIALOG;
import static com.android.settings.biometrics2.ui.viewmodel.FingerprintEnrollEnrollingViewModel.FINGERPRINT_ENROLL_ENROLLING_ACTION_DONE;
import static com.android.settings.biometrics2.ui.viewmodel.FingerprintEnrollEnrollingViewModel.FINGERPRINT_ENROLL_ENROLLING_ACTION_SHOW_ICON_TOUCH_DIALOG;
import static com.android.settings.biometrics2.ui.viewmodel.FingerprintEnrollEnrollingViewModel.FINGERPRINT_ENROLL_ENROLLING_CANCELED_BECAUSE_BACK_PRESSED;
@@ -518,10 +517,6 @@ public class FingerprintEnrollmentActivity extends FragmentActivity {
SKIP_SETUP_FIND_FPS_DIALOG_TAG);
break;
}
case FINGERPRINT_ENROLL_ENROLLING_ACTION_DISMISS_ICON_TOUCH_DIALOG: {
onSetActivityResult(new ActivityResult(BiometricEnrollBase.RESULT_TIMEOUT, null));
break;
}
case FINGERPRINT_ENROLL_ENROLLING_CANCELED_BECAUSE_BACK_PRESSED: {
if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
getSupportFragmentManager().popBackStack();

View File

@@ -60,25 +60,19 @@ public class FingerprintEnrollEnrollingViewModel extends AndroidViewModel {
*/
public static final int FINGERPRINT_ENROLL_ENROLLING_ACTION_SHOW_ICON_TOUCH_DIALOG = 1;
/**
* Icon touch dialog dismiss
*/
public static final int FINGERPRINT_ENROLL_ENROLLING_ACTION_DISMISS_ICON_TOUCH_DIALOG = 2;
/**
* Has got latest cancelled event due to user skip
*/
public static final int FINGERPRINT_ENROLL_ENROLLING_CANCELED_BECAUSE_USER_SKIP = 3;
public static final int FINGERPRINT_ENROLL_ENROLLING_CANCELED_BECAUSE_USER_SKIP = 2;
/**
* Has got latest cancelled event due to back key
*/
public static final int FINGERPRINT_ENROLL_ENROLLING_CANCELED_BECAUSE_BACK_PRESSED = 4;
public static final int FINGERPRINT_ENROLL_ENROLLING_CANCELED_BECAUSE_BACK_PRESSED = 3;
@IntDef(prefix = { "FINGERPRINT_ENROLL_ENROLLING_ACTION_" }, value = {
FINGERPRINT_ENROLL_ENROLLING_ACTION_DONE,
FINGERPRINT_ENROLL_ENROLLING_ACTION_SHOW_ICON_TOUCH_DIALOG,
FINGERPRINT_ENROLL_ENROLLING_ACTION_DISMISS_ICON_TOUCH_DIALOG,
FINGERPRINT_ENROLL_ENROLLING_CANCELED_BECAUSE_USER_SKIP,
FINGERPRINT_ENROLL_ENROLLING_CANCELED_BECAUSE_BACK_PRESSED
})
@@ -116,7 +110,6 @@ public class FingerprintEnrollEnrollingViewModel extends AndroidViewModel {
private final Vibrator mVibrator;
private final MutableLiveData<Integer> mActionLiveData = new MutableLiveData<>();
private final MutableLiveData<Integer> mIconTouchDialogLiveData = new MutableLiveData<>();
private final MutableLiveData<ErrorDialogData> mErrorDialogLiveData = new MutableLiveData<>();
private final MutableLiveData<Integer> mErrorDialogActionLiveData = new MutableLiveData<>();
@@ -233,17 +226,6 @@ public class FingerprintEnrollEnrollingViewModel extends AndroidViewModel {
mActionLiveData.postValue(action);
}
/**
* Icon touch dialog dismiss
*/
public void onIconTouchDialogDismiss() {
final int action = FINGERPRINT_ENROLL_ENROLLING_ACTION_DISMISS_ICON_TOUCH_DIALOG;
if (DEBUG) {
Log.d(TAG, "onIconTouchDialogDismiss, post action " + action);
}
mActionLiveData.postValue(action);
}
/**
* get enroll stage threshold
*/

View File

@@ -33,6 +33,7 @@ import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject2;
import android.support.test.uiautomator.Until;
import androidx.annotation.NonNull;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
@@ -54,18 +55,25 @@ public class FingerprintEnrollmentActivityTest {
private static final String SETTINGS_PACKAGE_NAME = "com.android.settings";
private static final String ACTIVITY_CLASS_NAME =
"com.android.settings.biometrics2.ui.view.FingerprintEnrollmentActivity";
public static final String EXTRA_IS_SETUP_FLOW = "isSetupFlow";
private static final String EXTRA_IS_SETUP_FLOW = "isSetupFlow";
private static final String EXTRA_SKIP_FIND_SENSOR = "skip_find_sensor";
private static final String EXTRA_FROM_SETTINGS_SUMMARY = "from_settings_summary";
private static final String EXTRA_PAGE_TRANSITION_TYPE = "page_transition_type";
private static final String EXTRA_KEY_GK_PW_HANDLE = "gk_pw_handle";
private static final String TEST_PIN = "1234";
private static final String UDFPS_ENROLLING_TITLE = "Touch & hold the fingerprint sensor";
private static final String SFPS_ENROLLING_TITLE =
"Lift, then touch. Move your finger slightly each time.";
private static final String RFPS_ENROLLING_TITLE = "Lift, then touch again";
private UiDevice mDevice;
private byte[] mToken = new byte[]{};
private Context mContext;
private boolean mFingerprintPropCallbackLaunched;
private boolean mCanAssumeUdfps;
private boolean mCanAssumeSfps;
private String mEnrollingTitle;
private static final int IDLE_TIMEOUT = 10000;
@@ -94,6 +102,13 @@ public class FingerprintEnrollmentActivityTest {
final FingerprintSensorPropertiesInternal prop = list.get(0);
mCanAssumeUdfps = prop.isAnyUdfpsType();
mCanAssumeSfps = prop.isAnySidefpsType();
if (mCanAssumeUdfps) {
mEnrollingTitle = UDFPS_ENROLLING_TITLE;
} else if (mCanAssumeSfps) {
mEnrollingTitle = SFPS_ENROLLING_TITLE;
} else {
mEnrollingTitle = RFPS_ENROLLING_TITLE;
}
}
});
@@ -106,8 +121,9 @@ public class FingerprintEnrollmentActivityTest {
}
@Test
public void testLaunchChooseLock() {
launchFingerprintEnrollActivity(false, null);
public void testIntroChooseLock() {
final Intent intent = newActivityIntent();
mContext.startActivity(intent);
assertThat(mDevice.wait(Until.hasObject(By.text("Choose your backup screen lock method")),
IDLE_TIMEOUT)).isTrue();
}
@@ -135,12 +151,12 @@ public class FingerprintEnrollmentActivityTest {
}
@Test
public void testLaunchWithGkPwHandle_withUdfps_clickStart() {
public void testIntroWithGkPwHandle_withUdfps_clickStart() {
assumeTrue(mCanAssumeUdfps);
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchFingerprintEnrollActivityWithGkPwHandle(false);
launchIntroWithGkPwHandle(false);
// Intro page
verifyIntroPage();
@@ -159,17 +175,16 @@ public class FingerprintEnrollmentActivityTest {
startBtn.click();
// Enrolling page
assertThat(mDevice.wait(Until.hasObject(By.text("Touch & hold the fingerprint sensor")),
IDLE_TIMEOUT)).isTrue();
assertThat(mDevice.wait(Until.hasObject(By.text(mEnrollingTitle)), IDLE_TIMEOUT)).isTrue();
}
@Test
public void testLaunchWithGkPwHandle_withUdfps_clickLottie() {
public void testIntroWithGkPwHandle_withUdfps_clickLottie() {
assumeTrue(mCanAssumeUdfps);
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchFingerprintEnrollActivityWithGkPwHandle(false);
launchIntroWithGkPwHandle(false);
// Intro page
verifyIntroPage();
@@ -188,17 +203,16 @@ public class FingerprintEnrollmentActivityTest {
lottie.click();
// Enrolling page
assertThat(mDevice.wait(Until.hasObject(By.text("Touch & hold the fingerprint sensor")),
IDLE_TIMEOUT)).isTrue();
assertThat(mDevice.wait(Until.hasObject(By.text(mEnrollingTitle)), IDLE_TIMEOUT)).isTrue();
}
@Test
public void testLaunchWithGkPwHandle_withSfps() {
public void testIntroWithGkPwHandle_withSfps() {
assumeTrue(mCanAssumeSfps);
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchFingerprintEnrollActivityWithGkPwHandle(false);
launchIntroWithGkPwHandle(false);
// Intro page
verifyIntroPage();
@@ -216,12 +230,12 @@ public class FingerprintEnrollmentActivityTest {
}
@Test
public void testLaunchWithGkPwHandle_withRfps() {
public void testIntroWithGkPwHandle_withRfps() {
assumeFalse(mCanAssumeUdfps || mCanAssumeSfps);
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchFingerprintEnrollActivityWithGkPwHandle(false);
launchIntroWithGkPwHandle(false);
// Intro page
verifyIntroPage();
@@ -241,10 +255,10 @@ public class FingerprintEnrollmentActivityTest {
}
@Test
public void testLaunchWithGkPwHandle_clickNoThanksInIntroPage() {
public void testIntroWithGkPwHandle_clickNoThanksInIntroPage() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchFingerprintEnrollActivityWithGkPwHandle(false);
launchIntroWithGkPwHandle(false);
// Intro page
verifyIntroPage();
@@ -258,10 +272,10 @@ public class FingerprintEnrollmentActivityTest {
}
@Test
public void testLaunchWithGkPwHandle_clickSkipInFindSensor() {
public void testIntroWithGkPwHandle_clickSkipInFindSensor() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchFingerprintEnrollActivityWithGkPwHandle(false);
launchIntroWithGkPwHandle(false);
// Intro page
verifyIntroPage();
@@ -282,10 +296,10 @@ public class FingerprintEnrollmentActivityTest {
}
@Test
public void testLaunchWithGkPwHandle_clickSkipAnywayInFindFpsDialog_whenIsSuw() {
public void testIntroWithGkPwHandle_clickSkipAnywayInFindFpsDialog_whenIsSuw() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchFingerprintEnrollActivityWithGkPwHandle(true);
launchIntroWithGkPwHandle(true);
// Intro page
verifyIntroPage();
@@ -315,10 +329,10 @@ public class FingerprintEnrollmentActivityTest {
}
@Test
public void testLaunchWithGkPwHandle_clickGoBackInFindFpsDialog_whenIsSuw() {
public void testIntroWithGkPwHandle_clickGoBackInFindFpsDialog_whenIsSuw() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchFingerprintEnrollActivityWithGkPwHandle(true);
launchIntroWithGkPwHandle(true);
// Intro page
verifyIntroPage();
@@ -346,43 +360,138 @@ public class FingerprintEnrollmentActivityTest {
}
@Test
public void testLaunchCheckPin() {
public void testIntroCheckPin() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchFingerprintEnrollActivity(false, null);
final Intent intent = newActivityIntent();
mContext.startActivity(intent);
assertThat(mDevice.wait(Until.hasObject(By.text("Enter your device PIN to continue")),
IDLE_TIMEOUT)).isTrue();
}
@Test
public void testEnrollingWithGkPwHandle() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchEnrollingWithGkPwHandle();
// Enrolling screen
mDevice.waitForIdle();
assertThat(mDevice.wait(Until.hasObject(By.text(mEnrollingTitle)), IDLE_TIMEOUT)).isTrue();
}
@Test
public void testEnrollingIconTouchDialog_withSfps() {
assumeTrue(mCanAssumeSfps);
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchEnrollingWithGkPwHandle();
// Enrolling screen
mDevice.waitForIdle();
assertThat(mDevice.wait(Until.hasObject(By.text(mEnrollingTitle)), IDLE_TIMEOUT)).isTrue();
final UiObject2 lottie = mDevice.findObject(By.res(SETTINGS_PACKAGE_NAME,
"illustration_lottie"));
assertThat(lottie).isNotNull();
lottie.click();
lottie.click();
lottie.click();
// IconTouchDialog
mDevice.waitForIdle();
assertThat(mDevice.wait(Until.hasObject(By.text("Touch the sensor instead")), IDLE_TIMEOUT))
.isTrue();
final UiObject2 okButton = mDevice.findObject(By.text("OK"));
assertThat(okButton).isNotNull();
okButton.click();
// Enrolling screen again
mDevice.waitForIdle();
assertThat(mDevice.wait(Until.hasObject(By.text(mEnrollingTitle)), IDLE_TIMEOUT)).isTrue();
}
@Test
public void testEnrollingIconTouchDialog_withRfps() {
assumeFalse(mCanAssumeUdfps || mCanAssumeSfps);
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchEnrollingWithGkPwHandle();
// Enrolling screen
mDevice.waitForIdle();
assertThat(mDevice.wait(Until.hasObject(By.text(mEnrollingTitle)), IDLE_TIMEOUT)).isTrue();
final UiObject2 lottie = mDevice.findObject(By.res(SETTINGS_PACKAGE_NAME,
"fingerprint_progress_bar"));
assertThat(lottie).isNotNull();
lottie.click();
lottie.click();
lottie.click();
// IconTouchDialog
mDevice.waitForIdle();
assertThat(mDevice.wait(Until.hasObject(By.text("Whoops, that\u2019s not the sensor")),
IDLE_TIMEOUT)).isTrue();
final UiObject2 okButton = mDevice.findObject(By.text("OK"));
assertThat(okButton).isNotNull();
okButton.click();
// Enrolling screen again
mDevice.waitForIdle();
assertThat(mDevice.wait(Until.hasObject(By.text(mEnrollingTitle)), IDLE_TIMEOUT)).isTrue();
}
@After
public void tearDown() throws Exception {
LockScreenUtil.resetLockscreen(TEST_PIN);
mDevice.pressHome();
}
private void launchFingerprintEnrollActivityWithGkPwHandle(boolean isSuw) {
private void launchIntroWithGkPwHandle(boolean isSuw) {
LockPatternUtils lockPatternUtils = new LockPatternUtils(mContext);
final LockscreenCredential lockscreenCredential = LockscreenCredential.createPin(TEST_PIN);
final int userId = UserHandle.myUserId();
final LockPatternChecker.OnVerifyCallback onVerifyCallback = (response, timeoutMs) -> {
launchFingerprintEnrollActivity(isSuw, response.getGatekeeperPasswordHandle());
final Intent intent = newActivityIntent();
if (isSuw) {
intent.putExtra(EXTRA_IS_SETUP_FLOW, true);
}
intent.putExtra(EXTRA_KEY_GK_PW_HANDLE, response.getGatekeeperPasswordHandle());
mContext.startActivity(intent);
};
LockPatternChecker.verifyCredential(lockPatternUtils, lockscreenCredential,
userId, LockPatternUtils.VERIFY_FLAG_REQUEST_GK_PW_HANDLE, onVerifyCallback);
}
private void launchFingerprintEnrollActivity(boolean isSuw, Long gkPwHandle) {
private void launchEnrollingWithGkPwHandle() {
LockPatternUtils lockPatternUtils = new LockPatternUtils(mContext);
final LockscreenCredential lockscreenCredential = LockscreenCredential.createPin(TEST_PIN);
final int userId = UserHandle.myUserId();
final LockPatternChecker.OnVerifyCallback onVerifyCallback = (response, timeoutMs) -> {
final Intent intent = newActivityIntent();
intent.putExtra(EXTRA_SKIP_FIND_SENSOR, true);
intent.putExtra(EXTRA_KEY_GK_PW_HANDLE, response.getGatekeeperPasswordHandle());
mContext.startActivity(intent);
};
LockPatternChecker.verifyCredential(lockPatternUtils, lockscreenCredential,
userId, LockPatternUtils.VERIFY_FLAG_REQUEST_GK_PW_HANDLE, onVerifyCallback);
}
@NonNull
private Intent newActivityIntent() {
Intent intent = new Intent();
intent.setClassName(SETTINGS_PACKAGE_NAME, ACTIVITY_CLASS_NAME);
if (isSuw) {
intent.putExtra(EXTRA_IS_SETUP_FLOW, true);
}
intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, true);
intent.putExtra(EXTRA_PAGE_TRANSITION_TYPE, 1);
intent.putExtra(Intent.EXTRA_USER_ID, mContext.getUserId());
if (gkPwHandle != null) {
intent.putExtra(EXTRA_KEY_GK_PW_HANDLE, gkPwHandle);
}
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
return intent;
}
}

View File

@@ -21,7 +21,6 @@ import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_UDFP
import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_UDFPS_ULTRASONIC;
import static com.android.settings.biometrics2.ui.viewmodel.FingerprintEnrollEnrollingViewModel.ErrorDialogData;
import static com.android.settings.biometrics2.ui.viewmodel.FingerprintEnrollEnrollingViewModel.FINGERPRINT_ENROLL_ENROLLING_ACTION_DISMISS_ICON_TOUCH_DIALOG;
import static com.android.settings.biometrics2.ui.viewmodel.FingerprintEnrollEnrollingViewModel.FINGERPRINT_ENROLL_ENROLLING_ACTION_SHOW_ICON_TOUCH_DIALOG;
import static com.android.settings.biometrics2.ui.viewmodel.FingerprintEnrollEnrollingViewModel.FINGERPRINT_ENROLL_ENROLLING_CANCELED_BECAUSE_BACK_PRESSED;
import static com.android.settings.biometrics2.ui.viewmodel.FingerprintEnrollEnrollingViewModel.FINGERPRINT_ENROLL_ENROLLING_CANCELED_BECAUSE_USER_SKIP;
@@ -103,10 +102,6 @@ public class FingerprintEnrollEnrollingViewModelTest {
mViewModel.showIconTouchDialog();
assertThat(actionLiveData.getValue()).isEqualTo(
FINGERPRINT_ENROLL_ENROLLING_ACTION_SHOW_ICON_TOUCH_DIALOG);
mViewModel.onIconTouchDialogDismiss();
assertThat(actionLiveData.getValue()).isEqualTo(
FINGERPRINT_ENROLL_ENROLLING_ACTION_DISMISS_ICON_TOUCH_DIALOG);
}
@Test