diff --git a/tests/uitests/Android.bp b/tests/uitests/Android.bp
index d4f09a3..407b5ec 100644
--- a/tests/uitests/Android.bp
+++ b/tests/uitests/Android.bp
@@ -26,7 +26,10 @@
     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 @@
     ],
 
     static_libs: [
+        "androidx.test.ext.junit",
         "androidx.test.rules",
         "androidx.test.uiautomator_uiautomator",
         "app-helpers-core",
diff --git a/tests/uitests/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivityTest.java b/tests/uitests/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivityTest.java
deleted file mode 100644
index 0a84c15..0000000
--- a/tests/uitests/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivityTest.java
+++ /dev/null
@@ -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;
-    }
-}
diff --git a/tests/uitests/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivityTest.kt b/tests/uitests/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivityTest.kt
new file mode 100644
index 0000000..49c5ac9
--- /dev/null
+++ b/tests/uitests/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivityTest.kt
@@ -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
+    }
+}
