[BiometricsV2] Rewrite Activity to Kotlin

Refactor FingerprintEnrollmentActivity as kotlin

Bug: 286197261
Test: atest FingerprintEnrollmentActivity
Test: atest biometrics-enrollment-test
Change-Id: I45d2db832b0111cb865b657aee56f84b0b295efa
This commit is contained in:
Milton Wu
2023-06-16 17:21:22 +08:00
parent 5cc530b6d5
commit 940e5d04a6
5 changed files with 1281 additions and 1260 deletions

View File

@@ -26,7 +26,10 @@ android_test {
platform_apis: true,
certificate: "platform",
test_suites: ["device-tests"],
srcs: ["src/**/*.java"],
srcs: [
"src/**/*.java",
"src/**/*.kt",
],
libs: [
"android.test.runner",
@@ -34,6 +37,7 @@ android_test {
],
static_libs: [
"androidx.test.ext.junit",
"androidx.test.rules",
"androidx.test.uiautomator_uiautomator",
"app-helpers-core",

View File

@@ -1,622 +0,0 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.biometrics2.ui.view;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeTrue;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.hardware.fingerprint.FingerprintManager;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.hardware.fingerprint.IFingerprintAuthenticatorsRegisteredCallback;
import android.os.UserHandle;
import android.support.test.uiautomator.By;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject2;
import android.support.test.uiautomator.Until;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import com.android.internal.widget.LockPatternChecker;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockscreenCredential;
import com.android.settings.biometrics2.utils.LockScreenUtil;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.io.IOException;
import java.util.List;
@RunWith(AndroidJUnit4.class)
public class FingerprintEnrollmentActivityTest {
private static final String TAG = "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";
private static final String SUW_ACTIVITY_CLASS_NAME = ACTIVITY_CLASS_NAME + "$SetupActivity";
private static final String EXTRA_IS_SETUP_FLOW = "isSetupFlow";
private static final String EXTRA_SKIP_INTRO = "skip_intro";
private static final String EXTRA_SKIP_FIND_SENSOR = "skip_find_sensor";
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 DO_IT_LATER = "Do it later";
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;
@Before
public void setUp() throws InterruptedException {
mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
mContext = InstrumentationRegistry.getContext();
// Stop every test if it is not a fingerprint device
assumeTrue(mContext.getPackageManager().hasSystemFeature(
PackageManager.FEATURE_FINGERPRINT));
final FingerprintManager fingerprintManager = mContext.getSystemService(
FingerprintManager.class);
mFingerprintPropCallbackLaunched = false;
fingerprintManager.addAuthenticatorsRegisteredCallback(
new IFingerprintAuthenticatorsRegisteredCallback.Stub() {
@Override
public void onAllAuthenticatorsRegistered(
List<FingerprintSensorPropertiesInternal> list) {
mFingerprintPropCallbackLaunched = true;
assertThat(list).isNotNull();
assertThat(list).isNotEmpty();
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;
}
}
});
for (long i = 0; i < IDLE_TIMEOUT && !mFingerprintPropCallbackLaunched; i += 100L) {
Thread.sleep(100L);
}
assertThat(mFingerprintPropCallbackLaunched).isTrue();
mDevice.pressHome();
// Stop settings before performing test
try {
mDevice.executeShellCommand("am force-stop " + SETTINGS_PACKAGE_NAME);
} catch (IOException e) {
Log.e(TAG, "Fail to stop settings app", e);
}
}
@After
public void tearDown() throws Exception {
LockScreenUtil.resetLockscreen(TEST_PIN);
mDevice.pressHome();
}
@Test
public void testIntroChooseLock() {
final Intent intent = newActivityIntent(false);
mContext.startActivity(intent);
assertThat(mDevice.wait(Until.hasObject(By.text("Choose your backup screen lock method")),
IDLE_TIMEOUT)).isTrue();
}
private void verifyIntroPage() {
mDevice.waitForIdle();
for (long i = 0; i < IDLE_TIMEOUT; i += 100L) {
if (mDevice.wait(Until.hasObject(By.text("More")), 50L)) {
break;
} else if (mDevice.wait(Until.hasObject(By.text("I agree")), 50L)) {
break;
}
}
// Click more btn at most twice and the introduction should stay in the last page
UiObject2 moreBtn;
for (int i = 0; i < 2 && (moreBtn = mDevice.findObject(By.text("More"))) != null; ++i) {
moreBtn.click();
mDevice.waitForIdle();
mDevice.wait(Until.hasObject(By.text("More")), IDLE_TIMEOUT);
}
assertThat(mDevice.wait(Until.hasObject(By.text("No thanks")), IDLE_TIMEOUT)).isTrue();
assertThat(mDevice.wait(Until.hasObject(By.text("I agree")), IDLE_TIMEOUT)).isTrue();
}
@Test
public void testIntroWithGkPwHandle_withUdfps_clickStart() {
assumeTrue(mCanAssumeUdfps);
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchIntroWithGkPwHandle(false);
// Intro page
verifyIntroPage();
final UiObject2 agreeBtn = mDevice.findObject(By.text("I agree"));
assertThat(agreeBtn).isNotNull();
agreeBtn.click();
// FindUdfps page
assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
final UiObject2 lottie = mDevice.findObject(By.res(SETTINGS_PACKAGE_NAME,
"illustration_lottie"));
assertThat(lottie).isNotNull();
assertThat(lottie.isClickable()).isTrue();
final UiObject2 startBtn = mDevice.findObject(By.text("Start"));
assertThat(startBtn.isClickable()).isTrue();
startBtn.click();
// Enrolling page
assertThat(mDevice.wait(Until.hasObject(By.text(mEnrollingTitle)), IDLE_TIMEOUT)).isTrue();
}
@Test
public void testIntroWithGkPwHandle_withUdfps_clickLottie() {
assumeTrue(mCanAssumeUdfps);
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchIntroWithGkPwHandle(false);
// Intro page
verifyIntroPage();
final UiObject2 agreeBtn = mDevice.findObject(By.text("I agree"));
assertThat(agreeBtn).isNotNull();
agreeBtn.click();
// FindUdfps page
assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
final UiObject2 lottie = mDevice.findObject(By.res(SETTINGS_PACKAGE_NAME,
"illustration_lottie"));
assertThat(lottie).isNotNull();
assertThat(lottie.isClickable()).isTrue();
final UiObject2 startBtn = mDevice.findObject(By.text("Start"));
assertThat(startBtn.isClickable()).isTrue();
lottie.click();
// Enrolling page
assertThat(mDevice.wait(Until.hasObject(By.text(mEnrollingTitle)), IDLE_TIMEOUT)).isTrue();
}
@Test
public void testIntroWithGkPwHandle_withSfps() {
assumeTrue(mCanAssumeSfps);
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchIntroWithGkPwHandle(false);
// Intro page
verifyIntroPage();
final UiObject2 agreeBtn = mDevice.findObject(By.text("I agree"));
assertThat(agreeBtn).isNotNull();
agreeBtn.click();
// FindSfps page
assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
final UiObject2 lottie = mDevice.findObject(By.res(SETTINGS_PACKAGE_NAME,
"illustration_lottie"));
assertThat(lottie).isNotNull();
// We don't have view which can be clicked to run to next page, stop at here.
}
@Test
public void testIntroWithGkPwHandle_withRfps() {
assumeFalse(mCanAssumeUdfps || mCanAssumeSfps);
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchIntroWithGkPwHandle(false);
// Intro page
verifyIntroPage();
final UiObject2 agreeBtn = mDevice.findObject(By.text("I agree"));
assertThat(agreeBtn).isNotNull();
agreeBtn.click();
// FindRfps page
assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
final UiObject2 lottie = mDevice.findObject(By.res(SETTINGS_PACKAGE_NAME,
"illustration_lottie"));
if (lottie == null) {
// FindSfps page shall have an animation view if no lottie view
assertThat(mDevice.findObject(By.res(SETTINGS_PACKAGE_NAME,
"fingerprint_sensor_location_animation"))).isNotNull();
}
}
@Test
public void testIntroWithGkPwHandle_clickNoThanksInIntroPage() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchIntroWithGkPwHandle(false);
// Intro page
verifyIntroPage();
final UiObject2 noThanksBtn = mDevice.findObject(By.text("No thanks"));
assertThat(noThanksBtn).isNotNull();
noThanksBtn.click();
// Back to home
mDevice.waitForWindowUpdate("com.android.settings", IDLE_TIMEOUT);
assertThat(mDevice.findObject(By.text("No thanks"))).isNull();
}
@Test
public void testIntroWithGkPwHandle_clickSkipInFindSensor() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchIntroWithGkPwHandle(false);
// Intro page
verifyIntroPage();
final UiObject2 agreeBtn = mDevice.findObject(By.text("I agree"));
assertThat(agreeBtn).isNotNull();
agreeBtn.click();
// FindSensor page
assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
final UiObject2 doItLaterBtn = mDevice.findObject(By.text(DO_IT_LATER));
assertThat(doItLaterBtn).isNotNull();
assertThat(doItLaterBtn.isClickable()).isTrue();
doItLaterBtn.click();
// Back to home
mDevice.waitForWindowUpdate("com.android.settings", IDLE_TIMEOUT);
assertThat(mDevice.findObject(By.text(DO_IT_LATER))).isNull();
}
@Test
public void testIntroWithGkPwHandle_clickSkipAnywayInFindFpsDialog_whenIsSuw() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchIntroWithGkPwHandle(true);
// Intro page
verifyIntroPage();
final UiObject2 agreeBtn = mDevice.findObject(By.text("I agree"));
assertThat(agreeBtn).isNotNull();
agreeBtn.click();
// FindSensor page
assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
final UiObject2 doItLaterBtn = mDevice.findObject(By.text(DO_IT_LATER));
assertThat(doItLaterBtn).isNotNull();
assertThat(doItLaterBtn.isClickable()).isTrue();
doItLaterBtn.click();
// SkipSetupFindFpsDialog
assertThat(mDevice.wait(Until.hasObject(By.text("Skip fingerprint?")),
IDLE_TIMEOUT)).isTrue();
final UiObject2 skipAnywayBtn = mDevice.findObject(By.text("Skip anyway"));
assertThat(skipAnywayBtn).isNotNull();
assertThat(skipAnywayBtn.isClickable()).isTrue();
skipAnywayBtn.click();
// Back to home
mDevice.waitForWindowUpdate("com.android.settings", IDLE_TIMEOUT);
assertThat(mDevice.findObject(By.text("Skip anyway"))).isNull();
assertThat(mDevice.findObject(By.text(DO_IT_LATER))).isNull();
}
@Test
public void testIntroWithGkPwHandle_clickGoBackInFindFpsDialog_whenIsSuw() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchIntroWithGkPwHandle(true);
// Intro page
verifyIntroPage();
final UiObject2 agreeBtn = mDevice.findObject(By.text("I agree"));
assertThat(agreeBtn).isNotNull();
agreeBtn.click();
// FindSensor page
assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
final UiObject2 doItLaterBtn = mDevice.findObject(By.text(DO_IT_LATER));
assertThat(doItLaterBtn).isNotNull();
assertThat(doItLaterBtn.isClickable()).isTrue();
doItLaterBtn.click();
// SkipSetupFindFpsDialog
assertThat(mDevice.wait(Until.hasObject(By.text("Skip fingerprint?")), IDLE_TIMEOUT))
.isTrue();
final UiObject2 goBackBtn = mDevice.findObject(By.text("Go back"));
assertThat(goBackBtn).isNotNull();
assertThat(goBackBtn.isClickable()).isTrue();
goBackBtn.click();
// FindSensor page again
assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
}
@Test
public void testIntroCheckPin() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
final Intent intent = newActivityIntent(false);
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();
}
@Test
public void testFindUdfpsWithGkPwHandle_clickStart() {
assumeTrue(mCanAssumeUdfps);
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchFindSensorWithGkPwHandle();
// FindUdfps page
assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
final UiObject2 lottie = mDevice.findObject(By.res(SETTINGS_PACKAGE_NAME,
"illustration_lottie"));
assertThat(lottie).isNotNull();
assertThat(lottie.isClickable()).isTrue();
final UiObject2 startBtn = mDevice.findObject(By.text("Start"));
assertThat(startBtn.isClickable()).isTrue();
startBtn.click();
// Enrolling page
assertThat(mDevice.wait(Until.hasObject(By.text(mEnrollingTitle)), IDLE_TIMEOUT)).isTrue();
}
@Test
public void testFindUdfpsWithGkPwHandle_clickLottie() {
assumeTrue(mCanAssumeUdfps);
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchFindSensorWithGkPwHandle();
// FindUdfps page
assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
final UiObject2 lottie = mDevice.findObject(By.res(SETTINGS_PACKAGE_NAME,
"illustration_lottie"));
assertThat(lottie).isNotNull();
assertThat(lottie.isClickable()).isTrue();
final UiObject2 startBtn = mDevice.findObject(By.text("Start"));
assertThat(startBtn.isClickable()).isTrue();
lottie.click();
// Enrolling page
assertThat(mDevice.wait(Until.hasObject(By.text(mEnrollingTitle)), IDLE_TIMEOUT)).isTrue();
}
@Test
public void testFindSfpsWithGkPwHandle() {
assumeTrue(mCanAssumeSfps);
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchFindSensorWithGkPwHandle();
// FindSfps page
assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
final UiObject2 lottie = mDevice.findObject(By.res(SETTINGS_PACKAGE_NAME,
"illustration_lottie"));
assertThat(lottie).isNotNull();
// We don't have view which can be clicked to run to next page, stop at here.
}
@Test
public void testFindRfpsWithGkPwHandle() {
assumeFalse(mCanAssumeUdfps || mCanAssumeSfps);
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchFindSensorWithGkPwHandle();
// FindRfps page
assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
final UiObject2 lottie = mDevice.findObject(By.res(SETTINGS_PACKAGE_NAME,
"illustration_lottie"));
if (lottie == null) {
// FindSfps page shall have an animation view if no lottie view
assertThat(mDevice.findObject(By.res(SETTINGS_PACKAGE_NAME,
"fingerprint_sensor_location_animation"))).isNotNull();
}
}
@Test
public void testFindSensorWithGkPwHandle_clickSkipInFindSensor() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
launchFindSensorWithGkPwHandle();
// FindSensor page
assertThat(mDevice.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
final UiObject2 doItLaterBtn = mDevice.findObject(By.text(DO_IT_LATER));
assertThat(doItLaterBtn).isNotNull();
assertThat(doItLaterBtn.isClickable()).isTrue();
doItLaterBtn.click();
// Back to home
mDevice.waitForWindowUpdate("com.android.settings", IDLE_TIMEOUT);
assertThat(mDevice.wait(Until.gone(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
}
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) -> {
final Intent intent = newActivityIntent(isSuw);
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 launchFindSensorWithGkPwHandle() {
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(false);
intent.putExtra(EXTRA_SKIP_INTRO, 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 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(false);
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(boolean isSuw) {
Intent intent = new Intent();
intent.setClassName(SETTINGS_PACKAGE_NAME,
isSuw ? SUW_ACTIVITY_CLASS_NAME : ACTIVITY_CLASS_NAME);
if (isSuw) {
intent.putExtra(EXTRA_IS_SETUP_FLOW, true);
}
intent.putExtra(EXTRA_PAGE_TRANSITION_TYPE, 1);
intent.putExtra(Intent.EXTRA_USER_ID, mContext.getUserId());
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
return intent;
}
}

View File

@@ -0,0 +1,632 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.biometrics2.ui.view
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager.FEATURE_FINGERPRINT
import android.hardware.fingerprint.FingerprintManager
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal
import android.hardware.fingerprint.IFingerprintAuthenticatorsRegisteredCallback
import android.os.UserHandle
import android.support.test.uiautomator.By
import android.support.test.uiautomator.UiDevice
import android.support.test.uiautomator.UiObject2
import android.support.test.uiautomator.Until
import android.util.Log
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.android.internal.widget.LockPatternChecker
import com.android.internal.widget.LockPatternUtils
import com.android.internal.widget.LockscreenCredential
import com.android.internal.widget.VerifyCredentialResponse
import com.android.settings.biometrics2.utils.LockScreenUtil
import com.google.common.truth.Truth.assertThat
import org.junit.After
import org.junit.Assume
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import java.io.IOException
@RunWith(AndroidJUnit4::class)
class FingerprintEnrollmentActivityTest {
private val context: Context by lazy {
InstrumentationRegistry.getInstrumentation().context
}
private val fingerprintManager: FingerprintManager by lazy {
context.getSystemService(FingerprintManager::class.java)!!
}
private var fingerprintPropCallbackLaunched = false
private var canAssumeUdfps = false
private var canAssumeSfps = false
private var enrollingPageTitle: String = ""
private val device: UiDevice by lazy {
UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
}
@Before
@Throws(InterruptedException::class)
fun setUp() {
// Stop every test if it is not a fingerprint device
Assume.assumeTrue(context.packageManager.hasSystemFeature(FEATURE_FINGERPRINT))
fingerprintPropCallbackLaunched = false
fingerprintManager.addAuthenticatorsRegisteredCallback(
object : IFingerprintAuthenticatorsRegisteredCallback.Stub() {
override fun onAllAuthenticatorsRegistered(
list: List<FingerprintSensorPropertiesInternal>
) {
fingerprintPropCallbackLaunched = true
assertThat(list).isNotNull()
assertThat(list).isNotEmpty()
val prop = list[0]
canAssumeUdfps = prop.isAnyUdfpsType
canAssumeSfps = prop.isAnySidefpsType
enrollingPageTitle = if (canAssumeUdfps) {
UDFPS_ENROLLING_TITLE
} else if (canAssumeSfps) {
SFPS_ENROLLING_TITLE
} else {
RFPS_ENROLLING_TITLE
}
}
})
var i: Long = 0
while (i < IDLE_TIMEOUT && !fingerprintPropCallbackLaunched) {
Thread.sleep(100L)
i += 100L
}
assertThat(fingerprintPropCallbackLaunched).isTrue()
device.pressHome()
// Stop settings before performing test
try {
device.executeShellCommand("am force-stop $SETTINGS_PACKAGE_NAME")
} catch (e: IOException) {
Log.e(TAG, "Fail to stop settings app", e)
}
}
@After
@Throws(Exception::class)
fun tearDown() {
LockScreenUtil.resetLockscreen(TEST_PIN)
device.pressHome()
}
@Test
fun testIntroChooseLock() {
val intent = newActivityIntent(false)
context.startActivity(intent)
assertThat(
device.wait(
Until.hasObject(By.text("Choose your backup screen lock method")),
IDLE_TIMEOUT
)
).isTrue()
}
private fun verifyIntroPage() {
device.waitForIdle()
run {
var i: Long = 0
while (i < IDLE_TIMEOUT) {
if (device.wait(Until.hasObject(By.text("More")), 50L)) {
break
} else if (device.wait(Until.hasObject(By.text("I agree")), 50L)) {
break
}
i += 100L
}
}
// Click more btn at most twice and the introduction should stay in the last page
var moreBtn: UiObject2? = null
var i = 0
while (i < 2 && device.findObject(By.text("More")).also { moreBtn = it } != null) {
moreBtn!!.click()
device.waitForIdle()
device.wait(Until.hasObject(By.text("More")), IDLE_TIMEOUT)
++i
}
assertThat(device.wait(Until.hasObject(By.text("No thanks")), IDLE_TIMEOUT)).isTrue()
assertThat(device.wait(Until.hasObject(By.text("I agree")), IDLE_TIMEOUT)).isTrue()
}
@Test
fun testIntroWithGkPwHandle_withUdfps_clickStart() {
Assume.assumeTrue(canAssumeUdfps)
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true)
launchIntroWithGkPwHandle(false)
// Intro page
verifyIntroPage()
val agreeBtn = device.findObject(By.text("I agree"))
assertThat(agreeBtn).isNotNull()
agreeBtn.click()
// FindUdfps page
assertThat(device.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue()
val lottie = device.findObject(
By.res(SETTINGS_PACKAGE_NAME, "illustration_lottie")
)
assertThat(lottie).isNotNull()
assertThat(lottie.isClickable).isTrue()
val startBtn = device.findObject(By.text("Start"))
assertThat(startBtn.isClickable).isTrue()
startBtn.click()
// Enrolling page
assertThat(device.wait(Until.hasObject(By.text(enrollingPageTitle)), IDLE_TIMEOUT)).isTrue()
}
@Test
fun testIntroWithGkPwHandle_withUdfps_clickLottie() {
Assume.assumeTrue(canAssumeUdfps)
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true)
launchIntroWithGkPwHandle(false)
// Intro page
verifyIntroPage()
val agreeBtn = device.findObject(By.text("I agree"))
assertThat(agreeBtn).isNotNull()
agreeBtn.click()
// FindUdfps page
assertThat(device.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue()
val lottie = device.findObject(By.res(SETTINGS_PACKAGE_NAME, "illustration_lottie"))
assertThat(lottie).isNotNull()
assertThat(lottie.isClickable).isTrue()
val startBtn = device.findObject(By.text("Start"))
assertThat(startBtn.isClickable).isTrue()
lottie.click()
// Enrolling page
assertThat(device.wait(Until.hasObject(By.text(enrollingPageTitle)), IDLE_TIMEOUT)).isTrue()
}
@Test
fun testIntroWithGkPwHandle_withSfps() {
Assume.assumeTrue(canAssumeSfps)
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true)
launchIntroWithGkPwHandle(false)
// Intro page
verifyIntroPage()
val agreeBtn = device.findObject(By.text("I agree"))
assertThat(agreeBtn).isNotNull()
agreeBtn.click()
// FindSfps page
assertThat(device.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue()
val lottie = device.findObject(
By.res(SETTINGS_PACKAGE_NAME,"illustration_lottie")
)
assertThat(lottie).isNotNull()
// We don't have view which can be clicked to run to next page, stop at here.
}
@Test
fun testIntroWithGkPwHandle_withRfps() {
Assume.assumeFalse(canAssumeUdfps || canAssumeSfps)
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true)
launchIntroWithGkPwHandle(false)
// Intro page
verifyIntroPage()
val agreeBtn = device.findObject(By.text("I agree"))
assertThat(agreeBtn).isNotNull()
agreeBtn.click()
// FindRfps page
assertThat(device.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue()
val lottie = device.findObject(
By.res(SETTINGS_PACKAGE_NAME, "illustration_lottie")
)
if (lottie == null) {
// FindSfps page shall have an animation view if no lottie view
assertThat(
device.findObject(
By.res(SETTINGS_PACKAGE_NAME, "fingerprint_sensor_location_animation")
)
).isNotNull()
}
}
@Test
fun testIntroWithGkPwHandle_clickNoThanksInIntroPage() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true)
launchIntroWithGkPwHandle(false)
// Intro page
verifyIntroPage()
val noThanksBtn = device.findObject(By.text("No thanks"))
assertThat(noThanksBtn).isNotNull()
noThanksBtn.click()
// Back to home
device.waitForWindowUpdate(SETTINGS_PACKAGE_NAME, IDLE_TIMEOUT)
assertThat(device.findObject(By.text("No thanks"))).isNull()
}
@Test
fun testIntroWithGkPwHandle_clickSkipInFindSensor() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true)
launchIntroWithGkPwHandle(false)
// Intro page
verifyIntroPage()
val agreeBtn = device.findObject(By.text("I agree"))
assertThat(agreeBtn).isNotNull()
agreeBtn.click()
// FindSensor page
assertThat(device.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue()
val doItLaterBtn = device.findObject(By.text(DO_IT_LATER))
assertThat(doItLaterBtn).isNotNull()
assertThat(doItLaterBtn.isClickable).isTrue()
doItLaterBtn.click()
// Back to home
device.waitForWindowUpdate(SETTINGS_PACKAGE_NAME, IDLE_TIMEOUT)
assertThat(device.findObject(By.text(DO_IT_LATER))).isNull()
}
@Test
fun testIntroWithGkPwHandle_clickSkipAnywayInFindFpsDialog_whenIsSuw() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true)
launchIntroWithGkPwHandle(true)
// Intro page
verifyIntroPage()
val agreeBtn = device.findObject(By.text("I agree"))
assertThat(agreeBtn).isNotNull()
agreeBtn.click()
// FindSensor page
assertThat(device.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue()
val doItLaterBtn = device.findObject(By.text(DO_IT_LATER))
assertThat(doItLaterBtn).isNotNull()
assertThat(doItLaterBtn.isClickable).isTrue()
doItLaterBtn.click()
// SkipSetupFindFpsDialog
assertThat(device.wait(Until.hasObject(By.text("Skip fingerprint?")), IDLE_TIMEOUT)).isTrue()
val skipAnywayBtn = device.findObject(By.text("Skip anyway"))
assertThat(skipAnywayBtn).isNotNull()
assertThat(skipAnywayBtn.isClickable).isTrue()
skipAnywayBtn.click()
// Back to home
device.waitForWindowUpdate(SETTINGS_PACKAGE_NAME, IDLE_TIMEOUT)
assertThat(device.findObject(By.text("Skip anyway"))).isNull()
assertThat(device.findObject(By.text(DO_IT_LATER))).isNull()
}
@Test
fun testIntroWithGkPwHandle_clickGoBackInFindFpsDialog_whenIsSuw() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true)
launchIntroWithGkPwHandle(true)
// Intro page
verifyIntroPage()
val agreeBtn = device.findObject(By.text("I agree"))
assertThat(agreeBtn).isNotNull()
agreeBtn.click()
// FindSensor page
assertThat(device.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue()
val doItLaterBtn = device.findObject(By.text(DO_IT_LATER))
assertThat(doItLaterBtn).isNotNull()
assertThat(doItLaterBtn.isClickable).isTrue()
doItLaterBtn.click()
// SkipSetupFindFpsDialog
assertThat(device.wait(Until.hasObject(By.text("Skip fingerprint?")), IDLE_TIMEOUT)).isTrue()
val goBackBtn = device.findObject(By.text("Go back"))
assertThat(goBackBtn).isNotNull()
assertThat(goBackBtn.isClickable).isTrue()
goBackBtn.click()
// FindSensor page again
assertThat(device.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue()
}
@Test
fun testIntroCheckPin() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true)
val intent = newActivityIntent(false)
context.startActivity(intent)
assertThat(
device.wait(
Until.hasObject(By.text("Enter your device PIN to continue")),
IDLE_TIMEOUT
)
).isTrue()
}
@Test
fun testEnrollingWithGkPwHandle() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true)
launchEnrollingWithGkPwHandle()
// Enrolling screen
device.waitForIdle()
assertThat(device.wait(Until.hasObject(By.text(enrollingPageTitle)), IDLE_TIMEOUT)).isTrue()
}
@Test
fun testEnrollingIconTouchDialog_withSfps() {
Assume.assumeTrue(canAssumeSfps)
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true)
launchEnrollingWithGkPwHandle()
// Enrolling screen
device.waitForIdle()
assertThat(device.wait(Until.hasObject(By.text(enrollingPageTitle)), IDLE_TIMEOUT)).isTrue()
val lottie = device.findObject(
By.res(SETTINGS_PACKAGE_NAME, "illustration_lottie")
)
assertThat(lottie).isNotNull()
lottie.click()
lottie.click()
lottie.click()
// IconTouchDialog
device.waitForIdle()
assertThat(
device.wait(
Until.hasObject(By.text("Touch the sensor instead")),
IDLE_TIMEOUT
)
)
.isTrue()
val okButton = device.findObject(By.text("OK"))
assertThat(okButton).isNotNull()
okButton.click()
// Enrolling screen again
device.waitForIdle()
assertThat(device.wait(Until.hasObject(By.text(enrollingPageTitle)), IDLE_TIMEOUT)).isTrue()
}
@Test
fun testEnrollingIconTouchDialog_withRfps() {
Assume.assumeFalse(canAssumeUdfps || canAssumeSfps)
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true)
launchEnrollingWithGkPwHandle()
// Enrolling screen
device.waitForIdle()
assertThat(device.wait(Until.hasObject(By.text(enrollingPageTitle)), IDLE_TIMEOUT)).isTrue()
val lottie = device.findObject(
By.res(SETTINGS_PACKAGE_NAME, "fingerprint_progress_bar")
)
assertThat(lottie).isNotNull()
lottie.click()
lottie.click()
lottie.click()
// IconTouchDialog
device.waitForIdle()
assertThat(
device.wait(
Until.hasObject(By.text("Whoops, that\u2019s not the sensor")),
IDLE_TIMEOUT
)
).isTrue()
val okButton = device.findObject(By.text("OK"))
assertThat(okButton).isNotNull()
okButton.click()
// Enrolling screen again
device.waitForIdle()
assertThat(device.wait(Until.hasObject(By.text(enrollingPageTitle)), IDLE_TIMEOUT)).isTrue()
}
@Test
fun testFindUdfpsWithGkPwHandle_clickStart() {
Assume.assumeTrue(canAssumeUdfps)
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true)
launchFindSensorWithGkPwHandle()
// FindUdfps page
assertThat(device.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue()
val lottie = device.findObject(
By.res(SETTINGS_PACKAGE_NAME, "illustration_lottie")
)
assertThat(lottie).isNotNull()
assertThat(lottie.isClickable).isTrue()
val startBtn = device.findObject(By.text("Start"))
assertThat(startBtn.isClickable).isTrue()
startBtn.click()
// Enrolling page
assertThat(device.wait(Until.hasObject(By.text(enrollingPageTitle)), IDLE_TIMEOUT)).isTrue()
}
@Test
fun testFindUdfpsWithGkPwHandle_clickLottie() {
Assume.assumeTrue(canAssumeUdfps)
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true)
launchFindSensorWithGkPwHandle()
// FindUdfps page
assertThat(device.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue()
val lottie = device.findObject(
By.res(SETTINGS_PACKAGE_NAME, "illustration_lottie")
)
assertThat(lottie).isNotNull()
assertThat(lottie.isClickable).isTrue()
val startBtn = device.findObject(By.text("Start"))
assertThat(startBtn.isClickable).isTrue()
lottie.click()
// Enrolling page
assertThat(device.wait(Until.hasObject(By.text(enrollingPageTitle)), IDLE_TIMEOUT)).isTrue()
}
@Test
fun testFindSfpsWithGkPwHandle() {
Assume.assumeTrue(canAssumeSfps)
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true)
launchFindSensorWithGkPwHandle()
// FindSfps page
assertThat(device.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue()
val lottie = device.findObject(
By.res(SETTINGS_PACKAGE_NAME, "illustration_lottie")
)
assertThat(lottie).isNotNull()
// We don't have view which can be clicked to run to next page, stop at here.
}
@Test
fun testFindRfpsWithGkPwHandle() {
Assume.assumeFalse(canAssumeUdfps || canAssumeSfps)
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true)
launchFindSensorWithGkPwHandle()
// FindRfps page
assertThat(device.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue()
val lottie = device.findObject(
By.res(
SETTINGS_PACKAGE_NAME,
"illustration_lottie"
)
)
if (lottie == null) {
// FindSfps page shall have an animation view if no lottie view
assertThat(
device.findObject(
By.res(
SETTINGS_PACKAGE_NAME,
"fingerprint_sensor_location_animation"
)
)
).isNotNull()
}
}
@Test
fun testFindSensorWithGkPwHandle_clickSkipInFindSensor() {
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true)
launchFindSensorWithGkPwHandle()
// FindSensor page
assertThat(device.wait(Until.hasObject(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue()
val doItLaterBtn = device.findObject(By.text(DO_IT_LATER))
assertThat(doItLaterBtn).isNotNull()
assertThat(doItLaterBtn.isClickable).isTrue()
doItLaterBtn.click()
// Back to home
device.waitForWindowUpdate(SETTINGS_PACKAGE_NAME, IDLE_TIMEOUT)
assertThat(device.wait(Until.gone(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue()
}
private fun launchIntroWithGkPwHandle(isSuw: Boolean) {
val lockPatternUtils = LockPatternUtils(context)
val lockscreenCredential = LockscreenCredential.createPin(TEST_PIN)
val userId = UserHandle.myUserId()
val onVerifyCallback =
LockPatternChecker.OnVerifyCallback { response: VerifyCredentialResponse, _: Int ->
val intent = newActivityIntent(isSuw)
intent.putExtra(EXTRA_KEY_GK_PW_HANDLE, response.gatekeeperPasswordHandle)
context.startActivity(intent)
}
LockPatternChecker.verifyCredential(
lockPatternUtils, lockscreenCredential,
userId, LockPatternUtils.VERIFY_FLAG_REQUEST_GK_PW_HANDLE, onVerifyCallback
)
}
private fun launchFindSensorWithGkPwHandle() {
val lockPatternUtils = LockPatternUtils(context)
val lockscreenCredential = LockscreenCredential.createPin(TEST_PIN)
val userId = UserHandle.myUserId()
val onVerifyCallback =
LockPatternChecker.OnVerifyCallback { response: VerifyCredentialResponse, _: Int ->
val intent = newActivityIntent(false)
intent.putExtra(EXTRA_SKIP_INTRO, true)
intent.putExtra(EXTRA_KEY_GK_PW_HANDLE, response.gatekeeperPasswordHandle)
context.startActivity(intent)
}
LockPatternChecker.verifyCredential(
lockPatternUtils, lockscreenCredential,
userId, LockPatternUtils.VERIFY_FLAG_REQUEST_GK_PW_HANDLE, onVerifyCallback
)
}
private fun launchEnrollingWithGkPwHandle() {
val lockPatternUtils = LockPatternUtils(context)
val lockscreenCredential = LockscreenCredential.createPin(TEST_PIN)
val userId = UserHandle.myUserId()
val onVerifyCallback =
LockPatternChecker.OnVerifyCallback { response: VerifyCredentialResponse, _: Int ->
val intent = newActivityIntent(false)
intent.putExtra(EXTRA_SKIP_FIND_SENSOR, true)
intent.putExtra(EXTRA_KEY_GK_PW_HANDLE, response.gatekeeperPasswordHandle)
context.startActivity(intent)
}
LockPatternChecker.verifyCredential(
lockPatternUtils, lockscreenCredential,
userId, LockPatternUtils.VERIFY_FLAG_REQUEST_GK_PW_HANDLE, onVerifyCallback
)
}
private fun newActivityIntent(isSuw: Boolean): Intent {
val intent = Intent()
intent.setClassName(
SETTINGS_PACKAGE_NAME,
if (isSuw) SUW_ACTIVITY_CLASS_NAME else ACTIVITY_CLASS_NAME
)
if (isSuw) {
intent.putExtra(EXTRA_IS_SETUP_FLOW, true)
}
intent.putExtra(EXTRA_PAGE_TRANSITION_TYPE, 1)
intent.putExtra(Intent.EXTRA_USER_ID, context.userId)
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
return intent
}
companion object {
private const val TAG = "FingerprintEnrollmentActivityTest"
const val SETTINGS_PACKAGE_NAME = "com.android.settings"
private const val ACTIVITY_CLASS_NAME =
"com.android.settings.biometrics2.ui.view.FingerprintEnrollmentActivity"
private const val SUW_ACTIVITY_CLASS_NAME = "$ACTIVITY_CLASS_NAME\$SetupActivity"
private const val EXTRA_IS_SETUP_FLOW = "isSetupFlow"
private const val EXTRA_SKIP_INTRO = "skip_intro"
private const val EXTRA_SKIP_FIND_SENSOR = "skip_find_sensor"
private const val EXTRA_PAGE_TRANSITION_TYPE = "page_transition_type"
private const val EXTRA_KEY_GK_PW_HANDLE = "gk_pw_handle"
private const val TEST_PIN = "1234"
private const val DO_IT_LATER = "Do it later"
private const val UDFPS_ENROLLING_TITLE = "Touch & hold the fingerprint sensor"
private const val SFPS_ENROLLING_TITLE =
"Lift, then touch. Move your finger slightly each time."
private const val RFPS_ENROLLING_TITLE = "Lift, then touch again"
private const val IDLE_TIMEOUT = 10000L
}
}