Support face unlock for PS if class2 biometric and above
With this change it is checked if face unlock is supported as a class2 or class3 biometrics on the device. If face is convenience biometrics then face unlock for private space controller is not added. Bug: 329044103 Test: atest UtilsTest and verified Face unlock is not added if face is convenience Change-Id: I6e1a6557774be1173ad3ee7ff7b14d51f9fe1716
This commit is contained in:
@@ -16,6 +16,10 @@
|
||||
|
||||
package com.android.settings;
|
||||
|
||||
import static android.hardware.biometrics.SensorProperties.STRENGTH_CONVENIENCE;
|
||||
import static android.hardware.biometrics.SensorProperties.STRENGTH_STRONG;
|
||||
import static android.hardware.biometrics.SensorProperties.STRENGTH_WEAK;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.junit.Assert.assertNull;
|
||||
@@ -43,6 +47,9 @@ import android.graphics.Color;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.VectorDrawable;
|
||||
import android.hardware.face.FaceManager;
|
||||
import android.hardware.face.FaceSensorProperties;
|
||||
import android.hardware.face.FaceSensorPropertiesInternal;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.LinkAddress;
|
||||
import android.net.LinkProperties;
|
||||
@@ -433,6 +440,69 @@ public class UtilsTest {
|
||||
assertNull(confirmCredentialString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isFaceNotConvenienceBiometric_faceStrengthStrong_shouldReturnTrue() {
|
||||
FaceManager mockFaceManager = mock(FaceManager.class);
|
||||
when(mContext.getSystemService(Context.FACE_SERVICE)).thenReturn(mockFaceManager);
|
||||
doReturn(true).when(mPackageManager).hasSystemFeature(anyString());
|
||||
List<FaceSensorPropertiesInternal> props = List.of(new FaceSensorPropertiesInternal(
|
||||
0 /* id */,
|
||||
STRENGTH_STRONG,
|
||||
1 /* maxTemplatesAllowed */,
|
||||
new ArrayList<>() /* componentInfo */,
|
||||
FaceSensorProperties.TYPE_UNKNOWN,
|
||||
true /* supportsFaceDetection */,
|
||||
true /* supportsSelfIllumination */,
|
||||
false /* resetLockoutRequiresChallenge */));
|
||||
doReturn(props).when(mockFaceManager).getSensorPropertiesInternal();
|
||||
|
||||
assertThat(Utils.isFaceNotConvenienceBiometric(mContext)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isFaceNotConvenienceBiometric_faceStrengthWeak_shouldReturnTrue() {
|
||||
FaceManager mockFaceManager = mock(FaceManager.class);
|
||||
when(mContext.getSystemService(Context.FACE_SERVICE)).thenReturn(mockFaceManager);
|
||||
doReturn(true).when(mPackageManager).hasSystemFeature(anyString());
|
||||
List<FaceSensorPropertiesInternal> props = List.of(new FaceSensorPropertiesInternal(
|
||||
0 /* id */,
|
||||
STRENGTH_WEAK,
|
||||
1 /* maxTemplatesAllowed */,
|
||||
new ArrayList<>() /* componentInfo */,
|
||||
FaceSensorProperties.TYPE_UNKNOWN,
|
||||
true /* supportsFaceDetection */,
|
||||
true /* supportsSelfIllumination */,
|
||||
false /* resetLockoutRequiresChallenge */));
|
||||
doReturn(props).when(mockFaceManager).getSensorPropertiesInternal();
|
||||
|
||||
assertThat(Utils.isFaceNotConvenienceBiometric(mContext)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isFaceNotConvenienceBiometric_faceStrengthConvenience_shouldReturnFalse() {
|
||||
FaceManager mockFaceManager = mock(FaceManager.class);
|
||||
when(mContext.getSystemService(Context.FACE_SERVICE)).thenReturn(mockFaceManager);
|
||||
doReturn(true).when(mPackageManager).hasSystemFeature(anyString());
|
||||
List<FaceSensorPropertiesInternal> props = List.of(new FaceSensorPropertiesInternal(
|
||||
0 /* id */,
|
||||
STRENGTH_CONVENIENCE,
|
||||
1 /* maxTemplatesAllowed */,
|
||||
new ArrayList<>() /* componentInfo */,
|
||||
FaceSensorProperties.TYPE_UNKNOWN,
|
||||
true /* supportsFaceDetection */,
|
||||
true /* supportsSelfIllumination */,
|
||||
false /* resetLockoutRequiresChallenge */));
|
||||
doReturn(props).when(mockFaceManager).getSensorPropertiesInternal();
|
||||
|
||||
assertThat(Utils.isFaceNotConvenienceBiometric(mContext)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isFaceNotConvenienceBiometric_faceManagerNull_shouldReturnFalse() {
|
||||
when(mContext.getSystemService(Context.FACE_SERVICE)).thenReturn(null);
|
||||
assertThat(Utils.isFaceNotConvenienceBiometric(mContext)).isFalse();
|
||||
}
|
||||
|
||||
private void setUpForConfirmCredentialString(boolean isEffectiveUserManagedProfile) {
|
||||
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mMockUserManager);
|
||||
when(mMockUserManager.getCredentialOwnerProfile(USER_ID)).thenReturn(USER_ID);
|
||||
|
Reference in New Issue
Block a user