Merge "Launch Face Settings when device enrolled face" into tm-qpr-dev am: 1d68fbf007
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/21294281 Change-Id: I1a80e569626469eaca583007ee94fb77bf36f03a Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -51,6 +51,8 @@ import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Settings;
|
||||
import com.android.settings.biometrics.BiometricEnrollBase;
|
||||
import com.android.settings.biometrics.BiometricUtils;
|
||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
@@ -62,6 +64,7 @@ import com.android.settings.testutils.shadow.ShadowUtils;
|
||||
|
||||
import com.google.android.setupcompat.template.FooterBarMixin;
|
||||
import com.google.android.setupcompat.template.FooterButton;
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
import com.google.android.setupdesign.GlifLayout;
|
||||
import com.google.android.setupdesign.view.BottomScrollView;
|
||||
|
||||
@@ -168,6 +171,7 @@ public class FaceEnrollIntroductionTest {
|
||||
@After
|
||||
public void tearDown() {
|
||||
ShadowUtils.reset();
|
||||
ShadowLockPatternUtils.reset();
|
||||
}
|
||||
|
||||
private void setupActivity() {
|
||||
@@ -315,7 +319,7 @@ public class FaceEnrollIntroductionTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFaceEnrollEducation_hasBottomScrollView() {
|
||||
public void testFaceEnrollIntroduction_hasBottomScrollView() {
|
||||
setupActivity();
|
||||
BottomScrollView scrollView = getGlifLayout(mActivity).findViewById(R.id.sud_scroll_view);
|
||||
|
||||
@@ -387,7 +391,7 @@ public class FaceEnrollIntroductionTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFaceEnrollEducation_onFoldedUpdated_folded() {
|
||||
public void testFaceEnrollIntroduction_onFoldedUpdated_folded() {
|
||||
final Configuration newConfig = new Configuration();
|
||||
newConfig.smallestScreenWidthDp = DENSITY_DEFAULT;
|
||||
setupActivityForPosture();
|
||||
@@ -400,4 +404,97 @@ public class FaceEnrollIntroductionTest {
|
||||
|
||||
assertThat(mSpyActivity.getDevicePostureState()).isEqualTo(DEVICE_POSTURE_CLOSED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFaceEnrollIntroduction_maxFacesEnrolled_launchFaceSettings() {
|
||||
setFaceManagerToHave(1 /* numEnrollments */);
|
||||
final Intent intent = new Intent();
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, new byte[0]);
|
||||
mController = Robolectric.buildActivity(TestFaceEnrollIntroduction.class, intent);
|
||||
mActivity = (TestFaceEnrollIntroduction) mController.get();
|
||||
mActivity.mOverrideFaceManager = mFaceManager;
|
||||
|
||||
mController.create();
|
||||
|
||||
ShadowActivity shadowActivity = Shadows.shadowOf(mActivity);
|
||||
final Intent nextStartedActivity = shadowActivity.getNextStartedActivity();
|
||||
assertThat(nextStartedActivity).isNotNull();
|
||||
assertThat(nextStartedActivity.getComponent().getClassName())
|
||||
.isEqualTo(Settings.FaceSettingsInternalActivity.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFaceEnrollIntroduction_maxFacesEnrolled_isSuw_notLaunchFaceSettings() {
|
||||
setFaceManagerToHave(1 /* numEnrollments */);
|
||||
ShadowLockPatternUtils.setActivePasswordQuality(PASSWORD_QUALITY_NUMERIC);
|
||||
final Intent intent = new Intent();
|
||||
intent.putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true);
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, new byte[0]);
|
||||
mController = Robolectric.buildActivity(TestFaceEnrollIntroduction.class, intent);
|
||||
mActivity = (TestFaceEnrollIntroduction) mController.get();
|
||||
mActivity.mOverrideFaceManager = mFaceManager;
|
||||
|
||||
mController.create();
|
||||
|
||||
ShadowActivity shadowActivity = Shadows.shadowOf(mActivity);
|
||||
final Intent nextStartedActivity = shadowActivity.getNextStartedActivity();
|
||||
assertThat(nextStartedActivity).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFaceEnrollIntroduction_maxFacesEnrolled_fromSettings_notLaunchFaceSettings() {
|
||||
setFaceManagerToHave(1 /* numEnrollments */);
|
||||
ShadowLockPatternUtils.setActivePasswordQuality(PASSWORD_QUALITY_NUMERIC);
|
||||
final Intent intent = new Intent();
|
||||
intent.putExtra(BiometricEnrollBase.EXTRA_FROM_SETTINGS_SUMMARY, true);
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, new byte[0]);
|
||||
mController = Robolectric.buildActivity(TestFaceEnrollIntroduction.class, intent);
|
||||
mActivity = (TestFaceEnrollIntroduction) mController.get();
|
||||
mActivity.mOverrideFaceManager = mFaceManager;
|
||||
|
||||
mController.create();
|
||||
|
||||
ShadowActivity shadowActivity = Shadows.shadowOf(mActivity);
|
||||
final Intent nextStartedActivity = shadowActivity.getNextStartedActivity();
|
||||
assertThat(nextStartedActivity).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFaceEnrollIntroduction_hasPostureCallback() {
|
||||
when(mFakeFeatureFactory.mFaceFeatureProvider.getPostureGuidanceIntent(any()))
|
||||
.thenReturn(new Intent());
|
||||
setFaceManagerToHave(0 /* numEnrollments */);
|
||||
ShadowLockPatternUtils.setActivePasswordQuality(PASSWORD_QUALITY_NUMERIC);
|
||||
final Intent intent = new Intent();
|
||||
intent.putExtra(BiometricEnrollBase.EXTRA_FROM_SETTINGS_SUMMARY, true);
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, new byte[0]);
|
||||
mController = Robolectric.buildActivity(TestFaceEnrollIntroduction.class, intent);
|
||||
mActivity = (TestFaceEnrollIntroduction) mController.get();
|
||||
mActivity.mOverrideFaceManager = mFaceManager;
|
||||
|
||||
mController.create();
|
||||
mController.start();
|
||||
|
||||
assertThat(mActivity.getPostureCallback()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFaceEnrollIntroduction_maxFacesEnrolled_noPostureCallback() {
|
||||
when(mFakeFeatureFactory.mFaceFeatureProvider.getPostureGuidanceIntent(any()))
|
||||
.thenReturn(new Intent());
|
||||
setFaceManagerToHave(1 /* numEnrollments */);
|
||||
ShadowLockPatternUtils.setActivePasswordQuality(PASSWORD_QUALITY_NUMERIC);
|
||||
final Intent intent = new Intent();
|
||||
intent.putExtra(BiometricEnrollBase.EXTRA_FROM_SETTINGS_SUMMARY, true);
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, new byte[0]);
|
||||
mController = Robolectric.buildActivity(TestFaceEnrollIntroduction.class, intent);
|
||||
mActivity = (TestFaceEnrollIntroduction) mController.get();
|
||||
mActivity.mOverrideFaceManager = mFaceManager;
|
||||
|
||||
mController.create();
|
||||
mController.start();
|
||||
|
||||
assertThat(mActivity.getPostureCallback()).isNull();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -36,6 +36,7 @@ import java.util.Map;
|
||||
public class ShadowLockPatternUtils {
|
||||
|
||||
private static boolean sDeviceEncryptionEnabled;
|
||||
private static Map<Integer, Integer> sUserToActivePasswordQualityMap = new HashMap<>();
|
||||
private static Map<Integer, Integer> sUserToComplexityMap = new HashMap<>();
|
||||
private static Map<Integer, Integer> sUserToProfileComplexityMap = new HashMap<>();
|
||||
private static Map<Integer, PasswordMetrics> sUserToMetricsMap = new HashMap<>();
|
||||
@@ -44,6 +45,7 @@ public class ShadowLockPatternUtils {
|
||||
|
||||
@Resetter
|
||||
public static void reset() {
|
||||
sUserToActivePasswordQualityMap.clear();
|
||||
sUserToComplexityMap.clear();
|
||||
sUserToProfileComplexityMap.clear();
|
||||
sUserToMetricsMap.clear();
|
||||
@@ -72,7 +74,11 @@ public class ShadowLockPatternUtils {
|
||||
|
||||
@Implementation
|
||||
protected int getActivePasswordQuality(int userId) {
|
||||
return DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
|
||||
final Integer activePasswordQuality = sUserToActivePasswordQualityMap.get(userId);
|
||||
if (activePasswordQuality == null) {
|
||||
return DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
|
||||
}
|
||||
return activePasswordQuality;
|
||||
}
|
||||
|
||||
@Implementation
|
||||
@@ -153,6 +159,10 @@ public class ShadowLockPatternUtils {
|
||||
sUserToProfileMetricsMap.put(UserHandle.myUserId(), metrics);
|
||||
}
|
||||
|
||||
public static void setActivePasswordQuality(int quality) {
|
||||
sUserToActivePasswordQualityMap.put(UserHandle.myUserId(), quality);
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public boolean isLockScreenDisabled(int userId) {
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user