Merge "Show Class 3 consent screen in enrollment with strong face." into udc-dev am: 637ae9d983 am: fc1fe263fe

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

Change-Id: I6a0ac3df96141e23621f5c6d3f814c6f07fafd64
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Hao Dong
2023-04-03 22:52:33 +00:00
committed by Automerger Merge Worker
4 changed files with 112 additions and 27 deletions

View File

@@ -32,7 +32,9 @@ import static com.google.common.truth.Truth.assertWithMessage;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.Activity;
@@ -41,6 +43,9 @@ import android.content.Intent;
import android.content.res.Configuration;
import android.hardware.face.Face;
import android.hardware.face.FaceManager;
import android.hardware.face.FaceSensorProperties;
import android.hardware.face.FaceSensorPropertiesInternal;
import android.hardware.face.IFaceAuthenticatorsRegisteredCallback;
import android.os.UserHandle;
import android.view.View;
import android.widget.TextView;
@@ -72,6 +77,8 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
@@ -99,6 +106,8 @@ public class FaceEnrollIntroductionTest {
private FaceManager mFaceManager;
@Mock
private LockPatternUtils mLockPatternUtils;
@Captor
private ArgumentCaptor<IFaceAuthenticatorsRegisteredCallback> mCaptor;
private Context mContext;
private ActivityController<? extends Activity> mController;
@@ -127,7 +136,6 @@ public class FaceEnrollIntroductionTest {
return mConfirmingCredentials;
}
public FaceManager mOverrideFaceManager = null;
@NonNull
public GateKeeperAction mGateKeeperAction = GateKeeperAction.CALL_SUPER;
@@ -145,12 +153,6 @@ public class FaceEnrollIntroductionTest {
}
}
@Nullable
@Override
protected FaceManager getFaceManager() {
return mOverrideFaceManager;
}
@Override
protected boolean launchPostureGuidance() {
return super.launchPostureGuidance();
@@ -186,7 +188,7 @@ public class FaceEnrollIntroductionTest {
mController = Robolectric.buildActivity(
TestFaceEnrollIntroduction.class, testIntent);
mActivity = (TestFaceEnrollIntroduction) spy(mController.get());
mActivity.mOverrideFaceManager = mFaceManager;
doReturn(mFaceManager).when(mActivity).getFaceManager();
when(mActivity.getPostureGuidanceIntent()).thenReturn(null);
when(mContext.getApplicationContext()).thenReturn(mContext);
when(mContext.getSystemService(Context.FACE_SERVICE)).thenReturn(mFaceManager);
@@ -229,7 +231,6 @@ public class FaceEnrollIntroductionTest {
}).when(mFaceManager).generateChallenge(anyInt(), any());
mController = Robolectric.buildActivity(TestFaceEnrollIntroduction.class, intent);
mActivity = (TestFaceEnrollIntroduction) mController.get();
mActivity.mOverrideFaceManager = mFaceManager;
}
private GlifLayout getGlifLayout(Activity activity) {
@@ -310,12 +311,51 @@ public class FaceEnrollIntroductionTest {
}
@Test
public void testFaceEnrollIntroduction_hasDescription() {
public void testFaceEnrollIntroduction_hasDescription_weakFace() throws Exception {
setupActivity();
verify(mFaceManager).addAuthenticatorsRegisteredCallback(mCaptor.capture());
CharSequence desc = getGlifLayout(mActivity).getDescriptionText();
assertThat(desc.toString()).isEqualTo(
mContext.getString(R.string.security_settings_face_enroll_introduction_message));
List<FaceSensorPropertiesInternal> props = List.of(new FaceSensorPropertiesInternal(
0 /* id */,
FaceSensorProperties.STRENGTH_WEAK,
1 /* maxTemplatesAllowed */,
new ArrayList<>() /* componentInfo */,
FaceSensorProperties.TYPE_UNKNOWN,
true /* supportsFaceDetection */,
true /* supportsSelfIllumination */,
false /* resetLockoutRequiresChallenge */));
mCaptor.getValue().onAllAuthenticatorsRegistered(props);
desc = getGlifLayout(mActivity).getDescriptionText();
assertThat(desc.toString()).isEqualTo(
mContext.getString(R.string.security_settings_face_enroll_introduction_message));
}
@Test
public void testFaceEnrollIntroduction_hasDescriptionNoLessSecure_strongFace()
throws Exception {
setupActivity();
verify(mFaceManager).addAuthenticatorsRegisteredCallback(mCaptor.capture());
List<FaceSensorPropertiesInternal> props = List.of(new FaceSensorPropertiesInternal(
0 /* id */,
FaceSensorProperties.STRENGTH_STRONG,
1 /* maxTemplatesAllowed */,
new ArrayList<>() /* componentInfo */,
FaceSensorProperties.TYPE_UNKNOWN,
true /* supportsFaceDetection */,
true /* supportsSelfIllumination */,
false /* resetLockoutRequiresChallenge */));
mCaptor.getValue().onAllAuthenticatorsRegistered(props);
CharSequence desc = getGlifLayout(mActivity).getDescriptionText();
assertThat(desc.toString()).isEqualTo(
mContext.getString(
R.string.security_settings_face_enroll_introduction_message_class3));
}
@Test
@@ -412,7 +452,6 @@ public class FaceEnrollIntroductionTest {
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();
@@ -432,7 +471,6 @@ public class FaceEnrollIntroductionTest {
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();
@@ -450,7 +488,6 @@ public class FaceEnrollIntroductionTest {
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();
@@ -470,7 +507,6 @@ public class FaceEnrollIntroductionTest {
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();
@@ -489,7 +525,6 @@ public class FaceEnrollIntroductionTest {
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();