[BiometricsV2] Refine fingerprint activities
Seperate FingerprintEnrollmentActivity to another InternalActivity and SetupActivity. InternalActivity is used for FingerprintSettings. SetupActivity is used for setupwizard flow. Bug: 284248001 Test: atest FingerprintEnrollmentActivityTest Test: atest for biometrics/biometrics2 in unit tests Test: settingRoboTest for biometrics Change-Id: I9fb5dc34300060b9ccf857a3335b81a5d4bf5c7b
This commit is contained in:
@@ -2528,6 +2528,15 @@
|
|||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name=".biometrics2.ui.view.FingerprintEnrollmentActivity"
|
<activity android:name=".biometrics2.ui.view.FingerprintEnrollmentActivity"
|
||||||
|
android:exported="true"
|
||||||
|
android:theme="@style/GlifTheme.Light" />
|
||||||
|
|
||||||
|
<activity android:name=".biometrics2.ui.view.FingerprintEnrollmentActivity$InternalActivity"
|
||||||
|
android:exported="false"
|
||||||
|
android:theme="@style/GlifTheme.Light"
|
||||||
|
android:taskAffinity="com.android.settings.root" />
|
||||||
|
|
||||||
|
<activity android:name=".biometrics2.ui.view.FingerprintEnrollmentActivity$SetupActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:permission="android.permission.MANAGE_FINGERPRINT"
|
android:permission="android.permission.MANAGE_FINGERPRINT"
|
||||||
android:theme="@style/GlifTheme.Light" />
|
android:theme="@style/GlifTheme.Light" />
|
||||||
|
@@ -251,6 +251,7 @@ public class ActivityEmbeddingRulesController {
|
|||||||
addActivityFilter(activityFilters, searchIntent);
|
addActivityFilter(activityFilters, searchIntent);
|
||||||
}
|
}
|
||||||
addActivityFilter(activityFilters, FingerprintEnrollmentActivity.class);
|
addActivityFilter(activityFilters, FingerprintEnrollmentActivity.class);
|
||||||
|
addActivityFilter(activityFilters, FingerprintEnrollmentActivity.InternalActivity.class);
|
||||||
addActivityFilter(activityFilters, FingerprintEnrollIntroduction.class);
|
addActivityFilter(activityFilters, FingerprintEnrollIntroduction.class);
|
||||||
addActivityFilter(activityFilters, FingerprintEnrollIntroductionInternal.class);
|
addActivityFilter(activityFilters, FingerprintEnrollIntroductionInternal.class);
|
||||||
addActivityFilter(activityFilters, FingerprintEnrollEnrolling.class);
|
addActivityFilter(activityFilters, FingerprintEnrollEnrolling.class);
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.settings.biometrics;
|
package com.android.settings.biometrics;
|
||||||
|
|
||||||
|
import static android.util.FeatureFlagUtils.SETTINGS_BIOMETRICS2_ENROLLMENT;
|
||||||
|
|
||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
@@ -249,20 +251,22 @@ public class BiometricUtils {
|
|||||||
*/
|
*/
|
||||||
public static Intent getFingerprintFindSensorIntent(@NonNull Context context,
|
public static Intent getFingerprintFindSensorIntent(@NonNull Context context,
|
||||||
@NonNull Intent activityIntent) {
|
@NonNull Intent activityIntent) {
|
||||||
if (FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SETTINGS_BIOMETRICS2_ENROLLMENT)) {
|
final boolean isSuw = WizardManagerHelper.isAnySetupWizard(activityIntent);
|
||||||
final Intent intent = new Intent(context, FingerprintEnrollmentActivity.class);
|
final Intent intent;
|
||||||
|
if (FeatureFlagUtils.isEnabled(context, SETTINGS_BIOMETRICS2_ENROLLMENT)) {
|
||||||
|
intent = new Intent(context, isSuw
|
||||||
|
? FingerprintEnrollmentActivity.SetupActivity.class
|
||||||
|
: FingerprintEnrollmentActivity.class);
|
||||||
intent.putExtra(BiometricEnrollActivity.EXTRA_SKIP_INTRO, true);
|
intent.putExtra(BiometricEnrollActivity.EXTRA_SKIP_INTRO, true);
|
||||||
if (WizardManagerHelper.isAnySetupWizard(activityIntent)) {
|
|
||||||
SetupWizardUtils.copySetupExtras(activityIntent, intent);
|
|
||||||
}
|
|
||||||
return intent;
|
|
||||||
} else if (WizardManagerHelper.isAnySetupWizard(activityIntent)) {
|
|
||||||
Intent intent = new Intent(context, SetupFingerprintEnrollFindSensor.class);
|
|
||||||
SetupWizardUtils.copySetupExtras(activityIntent, intent);
|
|
||||||
return intent;
|
|
||||||
} else {
|
} else {
|
||||||
return new Intent(context, FingerprintEnrollFindSensor.class);
|
intent = new Intent(context, isSuw
|
||||||
|
? SetupFingerprintEnrollFindSensor.class
|
||||||
|
: FingerprintEnrollFindSensor.class);
|
||||||
}
|
}
|
||||||
|
if (isSuw) {
|
||||||
|
SetupWizardUtils.copySetupExtras(activityIntent, intent);
|
||||||
|
}
|
||||||
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -272,19 +276,21 @@ public class BiometricUtils {
|
|||||||
*/
|
*/
|
||||||
public static Intent getFingerprintIntroIntent(@NonNull Context context,
|
public static Intent getFingerprintIntroIntent(@NonNull Context context,
|
||||||
@NonNull Intent activityIntent) {
|
@NonNull Intent activityIntent) {
|
||||||
if (FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SETTINGS_BIOMETRICS2_ENROLLMENT)) {
|
final boolean isSuw = WizardManagerHelper.isAnySetupWizard(activityIntent);
|
||||||
final Intent intent = new Intent(context, FingerprintEnrollmentActivity.class);
|
final Intent intent;
|
||||||
if (WizardManagerHelper.isAnySetupWizard(activityIntent)) {
|
if (FeatureFlagUtils.isEnabled(context, SETTINGS_BIOMETRICS2_ENROLLMENT)) {
|
||||||
WizardManagerHelper.copyWizardManagerExtras(activityIntent, intent);
|
intent = new Intent(context, isSuw
|
||||||
}
|
? FingerprintEnrollmentActivity.SetupActivity.class
|
||||||
return intent;
|
: FingerprintEnrollmentActivity.class);
|
||||||
} else if (WizardManagerHelper.isAnySetupWizard(activityIntent)) {
|
|
||||||
Intent intent = new Intent(context, SetupFingerprintEnrollIntroduction.class);
|
|
||||||
WizardManagerHelper.copyWizardManagerExtras(activityIntent, intent);
|
|
||||||
return intent;
|
|
||||||
} else {
|
} else {
|
||||||
return new Intent(context, FingerprintEnrollIntroduction.class);
|
intent = new Intent(context, isSuw
|
||||||
|
? SetupFingerprintEnrollIntroduction.class
|
||||||
|
: FingerprintEnrollIntroduction.class);
|
||||||
}
|
}
|
||||||
|
if (isSuw) {
|
||||||
|
WizardManagerHelper.copyWizardManagerExtras(activityIntent, intent);
|
||||||
|
}
|
||||||
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -751,7 +751,7 @@ public class FingerprintSettings extends SubSettings {
|
|||||||
if (FeatureFlagUtils.isEnabled(getContext(),
|
if (FeatureFlagUtils.isEnabled(getContext(),
|
||||||
FeatureFlagUtils.SETTINGS_BIOMETRICS2_ENROLLMENT)) {
|
FeatureFlagUtils.SETTINGS_BIOMETRICS2_ENROLLMENT)) {
|
||||||
intent.setClassName(SETTINGS_PACKAGE_NAME,
|
intent.setClassName(SETTINGS_PACKAGE_NAME,
|
||||||
FingerprintEnrollmentActivity.class.getName());
|
FingerprintEnrollmentActivity.InternalActivity.class.getName());
|
||||||
intent.putExtra(EnrollmentRequest.EXTRA_SKIP_FIND_SENSOR, true);
|
intent.putExtra(EnrollmentRequest.EXTRA_SKIP_FIND_SENSOR, true);
|
||||||
} else {
|
} else {
|
||||||
intent.setClassName(SETTINGS_PACKAGE_NAME,
|
intent.setClassName(SETTINGS_PACKAGE_NAME,
|
||||||
@@ -1025,7 +1025,7 @@ public class FingerprintSettings extends SubSettings {
|
|||||||
intent.setClassName(SETTINGS_PACKAGE_NAME,
|
intent.setClassName(SETTINGS_PACKAGE_NAME,
|
||||||
FeatureFlagUtils.isEnabled(getActivity(),
|
FeatureFlagUtils.isEnabled(getActivity(),
|
||||||
FeatureFlagUtils.SETTINGS_BIOMETRICS2_ENROLLMENT)
|
FeatureFlagUtils.SETTINGS_BIOMETRICS2_ENROLLMENT)
|
||||||
? FingerprintEnrollmentActivity.class.getName()
|
? FingerprintEnrollmentActivity.InternalActivity.class.getName()
|
||||||
: FingerprintEnrollIntroductionInternal.class.getName()
|
: FingerprintEnrollIntroductionInternal.class.getName()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settings.biometrics2.ui.model;
|
package com.android.settings.biometrics2.ui.model;
|
||||||
|
|
||||||
import static com.android.settings.biometrics.BiometricEnrollBase.EXTRA_FROM_SETTINGS_SUMMARY;
|
|
||||||
|
|
||||||
import static com.google.android.setupcompat.util.WizardManagerHelper.EXTRA_IS_SUW_SUGGESTED_ACTION_FLOW;
|
import static com.google.android.setupcompat.util.WizardManagerHelper.EXTRA_IS_SUW_SUGGESTED_ACTION_FLOW;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -47,19 +45,20 @@ public final class EnrollmentRequest {
|
|||||||
|
|
||||||
private final boolean mIsSuw;
|
private final boolean mIsSuw;
|
||||||
private final boolean mIsAfterSuwOrSuwSuggestedAction;
|
private final boolean mIsAfterSuwOrSuwSuggestedAction;
|
||||||
private final boolean mIsFromSettingsSummery;
|
|
||||||
private final boolean mIsSkipIntro;
|
private final boolean mIsSkipIntro;
|
||||||
private final boolean mIsSkipFindSensor;
|
private final boolean mIsSkipFindSensor;
|
||||||
private final int mTheme;
|
private final int mTheme;
|
||||||
private final Bundle mSuwExtras;
|
private final Bundle mSuwExtras;
|
||||||
|
|
||||||
public EnrollmentRequest(@NonNull Intent intent, @NonNull Context context) {
|
public EnrollmentRequest(@NonNull Intent intent, @NonNull Context context,
|
||||||
mIsSuw = WizardManagerHelper.isAnySetupWizard(intent);
|
boolean isSetupActivity) {
|
||||||
mIsAfterSuwOrSuwSuggestedAction = WizardManagerHelper.isDeferredSetupWizard(intent)
|
// Only allow mIsSuw to be enabled through SetupActivity for security reason
|
||||||
|
mIsSuw = isSetupActivity && WizardManagerHelper.isAnySetupWizard(intent);
|
||||||
|
mIsAfterSuwOrSuwSuggestedAction = isSetupActivity
|
||||||
|
&& (WizardManagerHelper.isDeferredSetupWizard(intent)
|
||||||
|| WizardManagerHelper.isPortalSetupWizard(intent)
|
|| WizardManagerHelper.isPortalSetupWizard(intent)
|
||||||
|| intent.getBooleanExtra(EXTRA_IS_SUW_SUGGESTED_ACTION_FLOW, false);
|
|| intent.getBooleanExtra(EXTRA_IS_SUW_SUGGESTED_ACTION_FLOW, false));
|
||||||
mSuwExtras = getSuwExtras(mIsSuw, intent);
|
mSuwExtras = getSuwExtras(mIsSuw, intent);
|
||||||
mIsFromSettingsSummery = intent.getBooleanExtra(EXTRA_FROM_SETTINGS_SUMMARY, false);
|
|
||||||
mIsSkipIntro = intent.getBooleanExtra(BiometricEnrollActivity.EXTRA_SKIP_INTRO, false);
|
mIsSkipIntro = intent.getBooleanExtra(BiometricEnrollActivity.EXTRA_SKIP_INTRO, false);
|
||||||
mIsSkipFindSensor = intent.getBooleanExtra(EXTRA_SKIP_FIND_SENSOR, false);
|
mIsSkipFindSensor = intent.getBooleanExtra(EXTRA_SKIP_FIND_SENSOR, false);
|
||||||
mTheme = SetupWizardUtils.getTheme(context, intent);
|
mTheme = SetupWizardUtils.getTheme(context, intent);
|
||||||
@@ -73,10 +72,6 @@ public final class EnrollmentRequest {
|
|||||||
return mIsAfterSuwOrSuwSuggestedAction;
|
return mIsAfterSuwOrSuwSuggestedAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFromSettingsSummery() {
|
|
||||||
return mIsFromSettingsSummery;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSkipIntro() {
|
public boolean isSkipIntro() {
|
||||||
return mIsSkipIntro;
|
return mIsSkipIntro;
|
||||||
}
|
}
|
||||||
@@ -101,7 +96,6 @@ public final class EnrollmentRequest {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return getClass().getSimpleName() + ":{isSuw:" + mIsSuw
|
return getClass().getSimpleName() + ":{isSuw:" + mIsSuw
|
||||||
+ ", isAfterSuwOrSuwSuggestedAction:" + mIsAfterSuwOrSuwSuggestedAction
|
+ ", isAfterSuwOrSuwSuggestedAction:" + mIsAfterSuwOrSuwSuggestedAction
|
||||||
+ ", isFromSettingsSummery:" + mIsFromSettingsSummery
|
|
||||||
+ "}";
|
+ "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -97,6 +97,16 @@ import com.google.android.setupdesign.util.ThemeHelper;
|
|||||||
*/
|
*/
|
||||||
public class FingerprintEnrollmentActivity extends FragmentActivity {
|
public class FingerprintEnrollmentActivity extends FragmentActivity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setupwizard activity
|
||||||
|
*/
|
||||||
|
public static class SetupActivity extends FingerprintEnrollmentActivity {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal activity for FingerprintSettings
|
||||||
|
*/
|
||||||
|
public static class InternalActivity extends FingerprintEnrollmentActivity {}
|
||||||
|
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
private static final String TAG = "FingerprintEnrollmentActivity";
|
private static final String TAG = "FingerprintEnrollmentActivity";
|
||||||
|
|
||||||
@@ -583,8 +593,8 @@ public class FingerprintEnrollmentActivity extends FragmentActivity {
|
|||||||
.getBiometricsRepositoryProvider().getFingerprintRepository(application);
|
.getBiometricsRepositoryProvider().getFingerprintRepository(application);
|
||||||
ret.set(CHALLENGE_GENERATOR_KEY, new FingerprintChallengeGenerator(repository));
|
ret.set(CHALLENGE_GENERATOR_KEY, new FingerprintChallengeGenerator(repository));
|
||||||
|
|
||||||
ret.set(ENROLLMENT_REQUEST_KEY, new EnrollmentRequest(getIntent(),
|
ret.set(ENROLLMENT_REQUEST_KEY, new EnrollmentRequest(getIntent(), getApplicationContext(),
|
||||||
getApplicationContext()));
|
this instanceof SetupActivity));
|
||||||
|
|
||||||
Bundle extras = getIntent().getExtras();
|
Bundle extras = getIntent().getExtras();
|
||||||
final CredentialModel credentialModel = new CredentialModel(extras,
|
final CredentialModel credentialModel = new CredentialModel(extras,
|
||||||
|
@@ -32,6 +32,7 @@ import android.support.test.uiautomator.By;
|
|||||||
import android.support.test.uiautomator.UiDevice;
|
import android.support.test.uiautomator.UiDevice;
|
||||||
import android.support.test.uiautomator.UiObject2;
|
import android.support.test.uiautomator.UiObject2;
|
||||||
import android.support.test.uiautomator.Until;
|
import android.support.test.uiautomator.Until;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.test.InstrumentationRegistry;
|
import androidx.test.InstrumentationRegistry;
|
||||||
@@ -47,18 +48,21 @@ import org.junit.Before;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class FingerprintEnrollmentActivityTest {
|
public class FingerprintEnrollmentActivityTest {
|
||||||
|
|
||||||
|
private static final String TAG = "FingerprintEnrollmentActivityTest";
|
||||||
|
|
||||||
private static final String SETTINGS_PACKAGE_NAME = "com.android.settings";
|
private static final String SETTINGS_PACKAGE_NAME = "com.android.settings";
|
||||||
private static final String ACTIVITY_CLASS_NAME =
|
private static final String ACTIVITY_CLASS_NAME =
|
||||||
"com.android.settings.biometrics2.ui.view.FingerprintEnrollmentActivity";
|
"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_IS_SETUP_FLOW = "isSetupFlow";
|
||||||
private static final String EXTRA_SKIP_INTRO = "skip_intro";
|
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_SKIP_FIND_SENSOR = "skip_find_sensor";
|
||||||
private static final String EXTRA_FROM_SETTINGS_SUMMARY = "from_settings_summary";
|
|
||||||
private static final String EXTRA_PAGE_TRANSITION_TYPE = "page_transition_type";
|
private static final String EXTRA_PAGE_TRANSITION_TYPE = "page_transition_type";
|
||||||
private static final String EXTRA_KEY_GK_PW_HANDLE = "gk_pw_handle";
|
private static final String EXTRA_KEY_GK_PW_HANDLE = "gk_pw_handle";
|
||||||
private static final String TEST_PIN = "1234";
|
private static final String TEST_PIN = "1234";
|
||||||
@@ -83,7 +87,6 @@ public class FingerprintEnrollmentActivityTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() throws InterruptedException {
|
public void setUp() throws InterruptedException {
|
||||||
mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
|
mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
|
||||||
|
|
||||||
mContext = InstrumentationRegistry.getContext();
|
mContext = InstrumentationRegistry.getContext();
|
||||||
|
|
||||||
// Stop every test if it is not a fingerprint device
|
// Stop every test if it is not a fingerprint device
|
||||||
@@ -121,6 +124,13 @@ public class FingerprintEnrollmentActivityTest {
|
|||||||
assertThat(mFingerprintPropCallbackLaunched).isTrue();
|
assertThat(mFingerprintPropCallbackLaunched).isTrue();
|
||||||
|
|
||||||
mDevice.pressHome();
|
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
|
@After
|
||||||
@@ -131,7 +141,7 @@ public class FingerprintEnrollmentActivityTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIntroChooseLock() {
|
public void testIntroChooseLock() {
|
||||||
final Intent intent = newActivityIntent();
|
final Intent intent = newActivityIntent(false);
|
||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
assertThat(mDevice.wait(Until.hasObject(By.text("Choose your backup screen lock method")),
|
assertThat(mDevice.wait(Until.hasObject(By.text("Choose your backup screen lock method")),
|
||||||
IDLE_TIMEOUT)).isTrue();
|
IDLE_TIMEOUT)).isTrue();
|
||||||
@@ -371,7 +381,7 @@ public class FingerprintEnrollmentActivityTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testIntroCheckPin() {
|
public void testIntroCheckPin() {
|
||||||
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
|
LockScreenUtil.setLockscreen(LockScreenUtil.LockscreenType.PIN, TEST_PIN, true);
|
||||||
final Intent intent = newActivityIntent();
|
final Intent intent = newActivityIntent(false);
|
||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
assertThat(mDevice.wait(Until.hasObject(By.text("Enter your device PIN to continue")),
|
assertThat(mDevice.wait(Until.hasObject(By.text("Enter your device PIN to continue")),
|
||||||
IDLE_TIMEOUT)).isTrue();
|
IDLE_TIMEOUT)).isTrue();
|
||||||
@@ -552,7 +562,7 @@ public class FingerprintEnrollmentActivityTest {
|
|||||||
|
|
||||||
// Back to home
|
// Back to home
|
||||||
mDevice.waitForWindowUpdate("com.android.settings", IDLE_TIMEOUT);
|
mDevice.waitForWindowUpdate("com.android.settings", IDLE_TIMEOUT);
|
||||||
assertThat(mDevice.findObject(By.text(DO_IT_LATER))).isNull();
|
assertThat(mDevice.wait(Until.gone(By.text(DO_IT_LATER)), IDLE_TIMEOUT)).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void launchIntroWithGkPwHandle(boolean isSuw) {
|
private void launchIntroWithGkPwHandle(boolean isSuw) {
|
||||||
@@ -560,10 +570,7 @@ public class FingerprintEnrollmentActivityTest {
|
|||||||
final LockscreenCredential lockscreenCredential = LockscreenCredential.createPin(TEST_PIN);
|
final LockscreenCredential lockscreenCredential = LockscreenCredential.createPin(TEST_PIN);
|
||||||
final int userId = UserHandle.myUserId();
|
final int userId = UserHandle.myUserId();
|
||||||
final LockPatternChecker.OnVerifyCallback onVerifyCallback = (response, timeoutMs) -> {
|
final LockPatternChecker.OnVerifyCallback onVerifyCallback = (response, timeoutMs) -> {
|
||||||
final Intent intent = newActivityIntent();
|
final Intent intent = newActivityIntent(isSuw);
|
||||||
if (isSuw) {
|
|
||||||
intent.putExtra(EXTRA_IS_SETUP_FLOW, true);
|
|
||||||
}
|
|
||||||
intent.putExtra(EXTRA_KEY_GK_PW_HANDLE, response.getGatekeeperPasswordHandle());
|
intent.putExtra(EXTRA_KEY_GK_PW_HANDLE, response.getGatekeeperPasswordHandle());
|
||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
};
|
};
|
||||||
@@ -576,7 +583,7 @@ public class FingerprintEnrollmentActivityTest {
|
|||||||
final LockscreenCredential lockscreenCredential = LockscreenCredential.createPin(TEST_PIN);
|
final LockscreenCredential lockscreenCredential = LockscreenCredential.createPin(TEST_PIN);
|
||||||
final int userId = UserHandle.myUserId();
|
final int userId = UserHandle.myUserId();
|
||||||
final LockPatternChecker.OnVerifyCallback onVerifyCallback = (response, timeoutMs) -> {
|
final LockPatternChecker.OnVerifyCallback onVerifyCallback = (response, timeoutMs) -> {
|
||||||
final Intent intent = newActivityIntent();
|
final Intent intent = newActivityIntent(false);
|
||||||
intent.putExtra(EXTRA_SKIP_INTRO, true);
|
intent.putExtra(EXTRA_SKIP_INTRO, true);
|
||||||
intent.putExtra(EXTRA_KEY_GK_PW_HANDLE, response.getGatekeeperPasswordHandle());
|
intent.putExtra(EXTRA_KEY_GK_PW_HANDLE, response.getGatekeeperPasswordHandle());
|
||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
@@ -590,7 +597,7 @@ public class FingerprintEnrollmentActivityTest {
|
|||||||
final LockscreenCredential lockscreenCredential = LockscreenCredential.createPin(TEST_PIN);
|
final LockscreenCredential lockscreenCredential = LockscreenCredential.createPin(TEST_PIN);
|
||||||
final int userId = UserHandle.myUserId();
|
final int userId = UserHandle.myUserId();
|
||||||
final LockPatternChecker.OnVerifyCallback onVerifyCallback = (response, timeoutMs) -> {
|
final LockPatternChecker.OnVerifyCallback onVerifyCallback = (response, timeoutMs) -> {
|
||||||
final Intent intent = newActivityIntent();
|
final Intent intent = newActivityIntent(false);
|
||||||
intent.putExtra(EXTRA_SKIP_FIND_SENSOR, true);
|
intent.putExtra(EXTRA_SKIP_FIND_SENSOR, true);
|
||||||
intent.putExtra(EXTRA_KEY_GK_PW_HANDLE, response.getGatekeeperPasswordHandle());
|
intent.putExtra(EXTRA_KEY_GK_PW_HANDLE, response.getGatekeeperPasswordHandle());
|
||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
@@ -600,14 +607,16 @@ public class FingerprintEnrollmentActivityTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private Intent newActivityIntent() {
|
private Intent newActivityIntent(boolean isSuw) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setClassName(SETTINGS_PACKAGE_NAME, ACTIVITY_CLASS_NAME);
|
intent.setClassName(SETTINGS_PACKAGE_NAME,
|
||||||
intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, true);
|
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(EXTRA_PAGE_TRANSITION_TYPE, 1);
|
||||||
intent.putExtra(Intent.EXTRA_USER_ID, mContext.getUserId());
|
intent.putExtra(Intent.EXTRA_USER_ID, mContext.getUserId());
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
return intent;
|
return intent;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,174 @@
|
|||||||
|
/*
|
||||||
|
* 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.model;
|
||||||
|
|
||||||
|
import static com.android.settings.biometrics.BiometricEnrollActivity.EXTRA_SKIP_INTRO;
|
||||||
|
import static com.android.settings.biometrics2.ui.model.EnrollmentRequest.EXTRA_SKIP_FIND_SENSOR;
|
||||||
|
|
||||||
|
import static com.google.android.setupcompat.util.WizardManagerHelper.EXTRA_IS_DEFERRED_SETUP;
|
||||||
|
import static com.google.android.setupcompat.util.WizardManagerHelper.EXTRA_IS_PORTAL_SETUP;
|
||||||
|
import static com.google.android.setupcompat.util.WizardManagerHelper.EXTRA_IS_SETUP_FLOW;
|
||||||
|
import static com.google.android.setupcompat.util.WizardManagerHelper.EXTRA_IS_SUW_SUGGESTED_ACTION_FLOW;
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class EnrollmentRequestTest {
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsSuw() {
|
||||||
|
// Default false
|
||||||
|
assertThat(new EnrollmentRequest(new Intent(), mContext, true).isSuw()).isFalse();
|
||||||
|
assertThat(new EnrollmentRequest(new Intent(), mContext, false).isSuw()).isFalse();
|
||||||
|
|
||||||
|
final Intent trueIntent = new Intent();
|
||||||
|
trueIntent.putExtra(EXTRA_IS_SETUP_FLOW, true);
|
||||||
|
assertThat(new EnrollmentRequest(trueIntent, mContext, true).isSuw()).isTrue();
|
||||||
|
assertThat(new EnrollmentRequest(trueIntent, mContext, false).isSuw()).isFalse();
|
||||||
|
|
||||||
|
final Intent falseIntent = new Intent();
|
||||||
|
trueIntent.putExtra(EXTRA_IS_SETUP_FLOW, false);
|
||||||
|
assertThat(new EnrollmentRequest(falseIntent, mContext, true).isSuw()).isFalse();
|
||||||
|
assertThat(new EnrollmentRequest(falseIntent, mContext, false).isSuw()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsAfterSuwOrSuwSuggestedAction() {
|
||||||
|
// Default false
|
||||||
|
assertThat(new EnrollmentRequest(new Intent(), mContext, true)
|
||||||
|
.isAfterSuwOrSuwSuggestedAction()).isFalse();
|
||||||
|
assertThat(new EnrollmentRequest(new Intent(), mContext, false)
|
||||||
|
.isAfterSuwOrSuwSuggestedAction()).isFalse();
|
||||||
|
|
||||||
|
final Intent deferredTrueIntent = new Intent();
|
||||||
|
deferredTrueIntent.putExtra(EXTRA_IS_DEFERRED_SETUP, true);
|
||||||
|
assertThat(new EnrollmentRequest(deferredTrueIntent, mContext, true)
|
||||||
|
.isAfterSuwOrSuwSuggestedAction()).isTrue();
|
||||||
|
assertThat(new EnrollmentRequest(deferredTrueIntent, mContext, false)
|
||||||
|
.isAfterSuwOrSuwSuggestedAction()).isFalse();
|
||||||
|
|
||||||
|
final Intent deferredFalseIntent = new Intent();
|
||||||
|
deferredFalseIntent.putExtra(EXTRA_IS_DEFERRED_SETUP, false);
|
||||||
|
assertThat(new EnrollmentRequest(deferredFalseIntent, mContext, false)
|
||||||
|
.isAfterSuwOrSuwSuggestedAction()).isFalse();
|
||||||
|
assertThat(new EnrollmentRequest(deferredFalseIntent, mContext, false)
|
||||||
|
.isAfterSuwOrSuwSuggestedAction()).isFalse();
|
||||||
|
|
||||||
|
final Intent portalTrueIntent = new Intent();
|
||||||
|
portalTrueIntent.putExtra(EXTRA_IS_PORTAL_SETUP, true);
|
||||||
|
assertThat(new EnrollmentRequest(portalTrueIntent, mContext, true)
|
||||||
|
.isAfterSuwOrSuwSuggestedAction()).isTrue();
|
||||||
|
assertThat(new EnrollmentRequest(portalTrueIntent, mContext, false)
|
||||||
|
.isAfterSuwOrSuwSuggestedAction()).isFalse();
|
||||||
|
|
||||||
|
final Intent portalFalseIntent = new Intent();
|
||||||
|
portalFalseIntent.putExtra(EXTRA_IS_PORTAL_SETUP, false);
|
||||||
|
assertThat(new EnrollmentRequest(portalFalseIntent, mContext, false)
|
||||||
|
.isAfterSuwOrSuwSuggestedAction()).isFalse();
|
||||||
|
assertThat(new EnrollmentRequest(portalFalseIntent, mContext, false)
|
||||||
|
.isAfterSuwOrSuwSuggestedAction()).isFalse();
|
||||||
|
|
||||||
|
final Intent suggestedTrueIntent = new Intent();
|
||||||
|
suggestedTrueIntent.putExtra(EXTRA_IS_SUW_SUGGESTED_ACTION_FLOW, true);
|
||||||
|
assertThat(new EnrollmentRequest(suggestedTrueIntent, mContext, true)
|
||||||
|
.isAfterSuwOrSuwSuggestedAction()).isTrue();
|
||||||
|
assertThat(new EnrollmentRequest(suggestedTrueIntent, mContext, false)
|
||||||
|
.isAfterSuwOrSuwSuggestedAction()).isFalse();
|
||||||
|
|
||||||
|
final Intent suggestedFalseIntent = new Intent();
|
||||||
|
suggestedFalseIntent.putExtra(EXTRA_IS_SUW_SUGGESTED_ACTION_FLOW, false);
|
||||||
|
assertThat(new EnrollmentRequest(suggestedFalseIntent, mContext, false)
|
||||||
|
.isAfterSuwOrSuwSuggestedAction()).isFalse();
|
||||||
|
assertThat(new EnrollmentRequest(suggestedFalseIntent, mContext, false)
|
||||||
|
.isAfterSuwOrSuwSuggestedAction()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetSuwExtras_inSuw() {
|
||||||
|
final Intent suwIntent = new Intent();
|
||||||
|
suwIntent.putExtra(EXTRA_IS_SETUP_FLOW, true);
|
||||||
|
final EnrollmentRequest setupRequest = new EnrollmentRequest(suwIntent, mContext, true);
|
||||||
|
|
||||||
|
final Bundle bundle = setupRequest.getSuwExtras();
|
||||||
|
assertThat(bundle).isNotNull();
|
||||||
|
assertThat(bundle.size()).isAtLeast(1);
|
||||||
|
assertThat(bundle.getBoolean(EXTRA_IS_SETUP_FLOW)).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetSuwExtras_notInSuw() {
|
||||||
|
final Intent suwIntent = new Intent();
|
||||||
|
suwIntent.putExtra(EXTRA_IS_SETUP_FLOW, true);
|
||||||
|
final EnrollmentRequest setupRequest = new EnrollmentRequest(suwIntent, mContext, false);
|
||||||
|
|
||||||
|
final Bundle bundle = setupRequest.getSuwExtras();
|
||||||
|
assertThat(bundle).isNotNull();
|
||||||
|
assertThat(bundle.size()).isEqualTo(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsSkipIntro() {
|
||||||
|
// Default false
|
||||||
|
assertThat(new EnrollmentRequest(new Intent(), mContext, true).isSkipIntro()).isFalse();
|
||||||
|
assertThat(new EnrollmentRequest(new Intent(), mContext, false).isSkipIntro()).isFalse();
|
||||||
|
|
||||||
|
final Intent trueIntent = new Intent();
|
||||||
|
trueIntent.putExtra(EXTRA_SKIP_INTRO, true);
|
||||||
|
assertThat(new EnrollmentRequest(trueIntent, mContext, true).isSkipIntro()).isTrue();
|
||||||
|
assertThat(new EnrollmentRequest(trueIntent, mContext, false).isSkipIntro()).isTrue();
|
||||||
|
|
||||||
|
final Intent falseIntent = new Intent();
|
||||||
|
falseIntent.putExtra(EXTRA_SKIP_INTRO, false);
|
||||||
|
assertThat(new EnrollmentRequest(falseIntent, mContext, false).isSkipIntro()).isFalse();
|
||||||
|
assertThat(new EnrollmentRequest(falseIntent, mContext, false).isSkipIntro()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsSkipFindSensor() {
|
||||||
|
// Default false
|
||||||
|
assertThat(new EnrollmentRequest(new Intent(), mContext, true).isSkipFindSensor())
|
||||||
|
.isFalse();
|
||||||
|
assertThat(new EnrollmentRequest(new Intent(), mContext, false).isSkipFindSensor())
|
||||||
|
.isFalse();
|
||||||
|
|
||||||
|
final Intent trueIntent = new Intent();
|
||||||
|
trueIntent.putExtra(EXTRA_SKIP_FIND_SENSOR, true);
|
||||||
|
assertThat(new EnrollmentRequest(trueIntent, mContext, true).isSkipFindSensor()).isTrue();
|
||||||
|
assertThat(new EnrollmentRequest(trueIntent, mContext, false).isSkipFindSensor()).isTrue();
|
||||||
|
|
||||||
|
final Intent falseIntent = new Intent();
|
||||||
|
falseIntent.putExtra(EXTRA_SKIP_FIND_SENSOR, false);
|
||||||
|
assertThat(new EnrollmentRequest(falseIntent, mContext, false).isSkipFindSensor())
|
||||||
|
.isFalse();
|
||||||
|
assertThat(new EnrollmentRequest(falseIntent, mContext, false).isSkipFindSensor())
|
||||||
|
.isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -64,7 +64,7 @@ public class FingerprintEnrollFinishViewModelTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mApplication = ApplicationProvider.getApplicationContext();
|
mApplication = ApplicationProvider.getApplicationContext();
|
||||||
mRequest = new EnrollmentRequest(new Intent(), mApplication);
|
mRequest = new EnrollmentRequest(new Intent(), mApplication, true);
|
||||||
mViewModel = new FingerprintEnrollFinishViewModel(mApplication, USER_ID, mRequest,
|
mViewModel = new FingerprintEnrollFinishViewModel(mApplication, USER_ID, mRequest,
|
||||||
newFingerprintRepository(mFingerprintManager, TYPE_UDFPS_OPTICAL, MAX_ENROLLABLE));
|
newFingerprintRepository(mFingerprintManager, TYPE_UDFPS_OPTICAL, MAX_ENROLLABLE));
|
||||||
}
|
}
|
||||||
|
@@ -75,7 +75,7 @@ public class EnrollmentRequestUtils {
|
|||||||
if (!TextUtils.isEmpty(theme)) {
|
if (!TextUtils.isEmpty(theme)) {
|
||||||
i.putExtra(EXTRA_THEME, theme);
|
i.putExtra(EXTRA_THEME, theme);
|
||||||
}
|
}
|
||||||
return new EnrollmentRequest(i, context);
|
return new EnrollmentRequest(i, context, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user