Merge "Fix tests in Settings that break with the changes in ParentalControlsUtils introduced in ag/31121556." into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
4f4e2da16b
@@ -26,6 +26,7 @@ import static org.mockito.Mockito.spy;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
|
import android.app.supervision.SupervisionManager;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
@@ -34,6 +35,8 @@ import android.hardware.fingerprint.Fingerprint;
|
|||||||
import android.hardware.fingerprint.FingerprintManager;
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
import android.platform.test.annotations.DisableFlags;
|
||||||
|
import android.platform.test.annotations.EnableFlags;
|
||||||
import android.platform.test.flag.junit.SetFlagsRule;
|
import android.platform.test.flag.junit.SetFlagsRule;
|
||||||
|
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
@@ -70,6 +73,8 @@ public class CombinedBiometricStatusUtilsTest {
|
|||||||
private FingerprintManager mFingerprintManager;
|
private FingerprintManager mFingerprintManager;
|
||||||
@Mock
|
@Mock
|
||||||
private FaceManager mFaceManager;
|
private FaceManager mFaceManager;
|
||||||
|
@Mock
|
||||||
|
private SupervisionManager mSupervisionManager;
|
||||||
|
|
||||||
private Context mApplicationContext;
|
private Context mApplicationContext;
|
||||||
private CombinedBiometricStatusUtils mCombinedBiometricStatusUtils;
|
private CombinedBiometricStatusUtils mCombinedBiometricStatusUtils;
|
||||||
@@ -83,13 +88,13 @@ public class CombinedBiometricStatusUtilsTest {
|
|||||||
when(mApplicationContext.getPackageManager()).thenReturn(mPackageManager);
|
when(mApplicationContext.getPackageManager()).thenReturn(mPackageManager);
|
||||||
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)).thenReturn(true);
|
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)).thenReturn(true);
|
||||||
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FACE)).thenReturn(true);
|
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FACE)).thenReturn(true);
|
||||||
when(mDevicePolicyManager.getProfileOwnerOrDeviceOwnerSupervisionComponent(USER_HANDLE))
|
|
||||||
.thenReturn(COMPONENT_NAME);
|
|
||||||
when(mApplicationContext.getSystemService(Context.FINGERPRINT_SERVICE))
|
when(mApplicationContext.getSystemService(Context.FINGERPRINT_SERVICE))
|
||||||
.thenReturn(mFingerprintManager);
|
.thenReturn(mFingerprintManager);
|
||||||
when(mApplicationContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
|
when(mApplicationContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
|
||||||
.thenReturn(mDevicePolicyManager);
|
.thenReturn(mDevicePolicyManager);
|
||||||
when(mApplicationContext.getSystemService(Context.FACE_SERVICE)).thenReturn(mFaceManager);
|
when(mApplicationContext.getSystemService(Context.FACE_SERVICE)).thenReturn(mFaceManager);
|
||||||
|
when(mApplicationContext.getSystemService(Context.SUPERVISION_SERVICE))
|
||||||
|
.thenReturn(mSupervisionManager);
|
||||||
mCombinedBiometricStatusUtils = new CombinedBiometricStatusUtils(
|
mCombinedBiometricStatusUtils = new CombinedBiometricStatusUtils(
|
||||||
mApplicationContext, USER_ID);
|
mApplicationContext, USER_ID);
|
||||||
}
|
}
|
||||||
@@ -175,7 +180,10 @@ public class CombinedBiometricStatusUtilsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@DisableFlags(android.app.supervision.flags.Flags.FLAG_DEPRECATE_DPM_SUPERVISION_APIS)
|
||||||
public void getDisabledAdmin_whenFingerprintDisabled_whenFaceDisabled_returnsEnforcedAdmin() {
|
public void getDisabledAdmin_whenFingerprintDisabled_whenFaceDisabled_returnsEnforcedAdmin() {
|
||||||
|
when(mDevicePolicyManager.getProfileOwnerOrDeviceOwnerSupervisionComponent(USER_HANDLE))
|
||||||
|
.thenReturn(COMPONENT_NAME);
|
||||||
when(mDevicePolicyManager.getKeyguardDisabledFeatures(COMPONENT_NAME))
|
when(mDevicePolicyManager.getKeyguardDisabledFeatures(COMPONENT_NAME))
|
||||||
.thenReturn(KEYGUARD_DISABLE_FACE | KEYGUARD_DISABLE_FINGERPRINT);
|
.thenReturn(KEYGUARD_DISABLE_FACE | KEYGUARD_DISABLE_FINGERPRINT);
|
||||||
|
|
||||||
@@ -186,6 +194,20 @@ public class CombinedBiometricStatusUtilsTest {
|
|||||||
COMPONENT_NAME, UserManager.DISALLOW_BIOMETRIC, USER_HANDLE));
|
COMPONENT_NAME, UserManager.DISALLOW_BIOMETRIC, USER_HANDLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(android.app.supervision.flags.Flags.FLAG_DEPRECATE_DPM_SUPERVISION_APIS)
|
||||||
|
public void getDisabledAdmin_whenFingerprintDisabled_whenFaceDisabled_returnsRestrictions() {
|
||||||
|
when(mSupervisionManager.isSupervisionEnabledForUser(USER_ID)).thenReturn(true);
|
||||||
|
when(mDevicePolicyManager.getKeyguardDisabledFeatures(null))
|
||||||
|
.thenReturn(KEYGUARD_DISABLE_FACE | KEYGUARD_DISABLE_FINGERPRINT);
|
||||||
|
|
||||||
|
final RestrictedLockUtils.EnforcedAdmin admin =
|
||||||
|
mCombinedBiometricStatusUtils.getDisablingAdmin();
|
||||||
|
|
||||||
|
assertThat(admin.enforcedRestriction).isEqualTo(UserManager.DISALLOW_BIOMETRIC);
|
||||||
|
assertThat(admin.user).isEqualTo(USER_HANDLE);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getDisabledAdmin_whenFingerprintDisabled_whenFaceEnabled_returnsNull() {
|
public void getDisabledAdmin_whenFingerprintDisabled_whenFaceEnabled_returnsNull() {
|
||||||
when(mDevicePolicyManager.getKeyguardDisabledFeatures(COMPONENT_NAME))
|
when(mDevicePolicyManager.getKeyguardDisabledFeatures(COMPONENT_NAME))
|
||||||
|
@@ -23,6 +23,7 @@ import static org.mockito.Mockito.spy;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
|
import android.app.supervision.SupervisionManager;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
@@ -30,6 +31,9 @@ import android.hardware.face.FaceManager;
|
|||||||
import android.hardware.fingerprint.FingerprintManager;
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
import android.platform.test.annotations.DisableFlags;
|
||||||
|
import android.platform.test.annotations.EnableFlags;
|
||||||
|
import android.platform.test.flag.junit.SetFlagsRule;
|
||||||
|
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
@@ -39,6 +43,7 @@ import com.android.settings.testutils.ResourcesUtils;
|
|||||||
import com.android.settingslib.RestrictedLockUtils;
|
import com.android.settingslib.RestrictedLockUtils;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
@@ -47,12 +52,14 @@ import org.mockito.MockitoAnnotations;
|
|||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class FaceStatusUtilsTest {
|
public class FaceStatusUtilsTest {
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||||
|
|
||||||
private static final ComponentName COMPONENT_NAME =
|
private static final ComponentName COMPONENT_NAME =
|
||||||
new ComponentName("package", "class");
|
new ComponentName("package", "class");
|
||||||
private static final int USER_ID = UserHandle.myUserId();
|
private static final int USER_ID = UserHandle.myUserId();
|
||||||
private static final UserHandle USER_HANDLE = new UserHandle(USER_ID);
|
private static final UserHandle USER_HANDLE = new UserHandle(USER_ID);
|
||||||
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private PackageManager mPackageManager;
|
private PackageManager mPackageManager;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -61,6 +68,8 @@ public class FaceStatusUtilsTest {
|
|||||||
private FingerprintManager mFingerprintManager;
|
private FingerprintManager mFingerprintManager;
|
||||||
@Mock
|
@Mock
|
||||||
private FaceManager mFaceManager;
|
private FaceManager mFaceManager;
|
||||||
|
@Mock
|
||||||
|
private SupervisionManager mSupervisionManager;
|
||||||
|
|
||||||
private Context mApplicationContext;
|
private Context mApplicationContext;
|
||||||
private FaceStatusUtils mFaceStatusUtils;
|
private FaceStatusUtils mFaceStatusUtils;
|
||||||
@@ -72,13 +81,13 @@ public class FaceStatusUtilsTest {
|
|||||||
when(mApplicationContext.getPackageManager()).thenReturn(mPackageManager);
|
when(mApplicationContext.getPackageManager()).thenReturn(mPackageManager);
|
||||||
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)).thenReturn(true);
|
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)).thenReturn(true);
|
||||||
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FACE)).thenReturn(true);
|
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FACE)).thenReturn(true);
|
||||||
when(mDevicePolicyManager.getProfileOwnerOrDeviceOwnerSupervisionComponent(USER_HANDLE))
|
|
||||||
.thenReturn(COMPONENT_NAME);
|
|
||||||
when(mApplicationContext.getSystemService(Context.FINGERPRINT_SERVICE))
|
when(mApplicationContext.getSystemService(Context.FINGERPRINT_SERVICE))
|
||||||
.thenReturn(mFingerprintManager);
|
.thenReturn(mFingerprintManager);
|
||||||
when(mApplicationContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
|
when(mApplicationContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
|
||||||
.thenReturn(mDevicePolicyManager);
|
.thenReturn(mDevicePolicyManager);
|
||||||
when(mApplicationContext.getSystemService(Context.FACE_SERVICE)).thenReturn(mFaceManager);
|
when(mApplicationContext.getSystemService(Context.FACE_SERVICE)).thenReturn(mFaceManager);
|
||||||
|
when(mApplicationContext.getSystemService(Context.SUPERVISION_SERVICE))
|
||||||
|
.thenReturn(mSupervisionManager);
|
||||||
mFaceStatusUtils = new FaceStatusUtils(mApplicationContext, mFaceManager, USER_ID);
|
mFaceStatusUtils = new FaceStatusUtils(mApplicationContext, mFaceManager, USER_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +138,10 @@ public class FaceStatusUtilsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@DisableFlags(android.app.supervision.flags.Flags.FLAG_DEPRECATE_DPM_SUPERVISION_APIS)
|
||||||
public void getDisabledAdmin_whenFaceDisabled_returnsEnforcedAdmin() {
|
public void getDisabledAdmin_whenFaceDisabled_returnsEnforcedAdmin() {
|
||||||
|
when(mDevicePolicyManager.getProfileOwnerOrDeviceOwnerSupervisionComponent(USER_HANDLE))
|
||||||
|
.thenReturn(COMPONENT_NAME);
|
||||||
when(mDevicePolicyManager.getKeyguardDisabledFeatures(COMPONENT_NAME))
|
when(mDevicePolicyManager.getKeyguardDisabledFeatures(COMPONENT_NAME))
|
||||||
.thenReturn(DevicePolicyManager.KEYGUARD_DISABLE_FACE);
|
.thenReturn(DevicePolicyManager.KEYGUARD_DISABLE_FACE);
|
||||||
|
|
||||||
@@ -139,6 +151,19 @@ public class FaceStatusUtilsTest {
|
|||||||
COMPONENT_NAME, UserManager.DISALLOW_BIOMETRIC, USER_HANDLE));
|
COMPONENT_NAME, UserManager.DISALLOW_BIOMETRIC, USER_HANDLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(android.app.supervision.flags.Flags.FLAG_DEPRECATE_DPM_SUPERVISION_APIS)
|
||||||
|
public void getDisabledAdmin_whenFaceDisabled_returnsRestriction() {
|
||||||
|
when(mSupervisionManager.isSupervisionEnabledForUser(USER_ID)).thenReturn(true);
|
||||||
|
when(mDevicePolicyManager.getKeyguardDisabledFeatures(null))
|
||||||
|
.thenReturn(DevicePolicyManager.KEYGUARD_DISABLE_FACE);
|
||||||
|
|
||||||
|
final RestrictedLockUtils.EnforcedAdmin admin = mFaceStatusUtils.getDisablingAdmin();
|
||||||
|
|
||||||
|
assertThat(admin.enforcedRestriction).isEqualTo(UserManager.DISALLOW_BIOMETRIC);
|
||||||
|
assertThat(admin.user).isEqualTo(USER_HANDLE);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getDisabledAdmin_withFaceEnabled_returnsNull() {
|
public void getDisabledAdmin_withFaceEnabled_returnsNull() {
|
||||||
when(mDevicePolicyManager.getKeyguardDisabledFeatures(COMPONENT_NAME)).thenReturn(0);
|
when(mDevicePolicyManager.getKeyguardDisabledFeatures(COMPONENT_NAME)).thenReturn(0);
|
||||||
|
@@ -23,6 +23,7 @@ import static org.mockito.Mockito.spy;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
|
import android.app.supervision.SupervisionManager;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
@@ -31,6 +32,9 @@ import android.hardware.fingerprint.Fingerprint;
|
|||||||
import android.hardware.fingerprint.FingerprintManager;
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
import android.platform.test.annotations.DisableFlags;
|
||||||
|
import android.platform.test.annotations.EnableFlags;
|
||||||
|
import android.platform.test.flag.junit.SetFlagsRule;
|
||||||
|
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
@@ -40,6 +44,7 @@ import com.android.settingslib.RestrictedLockUtils;
|
|||||||
import com.android.settingslib.utils.StringUtil;
|
import com.android.settingslib.utils.StringUtil;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
@@ -51,12 +56,14 @@ import java.util.List;
|
|||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class FingerprintStatusUtilsTest {
|
public class FingerprintStatusUtilsTest {
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||||
|
|
||||||
private static final ComponentName COMPONENT_NAME =
|
private static final ComponentName COMPONENT_NAME =
|
||||||
new ComponentName("package", "class");
|
new ComponentName("package", "class");
|
||||||
private static final int USER_ID = UserHandle.myUserId();
|
private static final int USER_ID = UserHandle.myUserId();
|
||||||
private static final UserHandle USER_HANDLE = new UserHandle(USER_ID);
|
private static final UserHandle USER_HANDLE = new UserHandle(USER_ID);
|
||||||
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private PackageManager mPackageManager;
|
private PackageManager mPackageManager;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -65,6 +72,8 @@ public class FingerprintStatusUtilsTest {
|
|||||||
private FingerprintManager mFingerprintManager;
|
private FingerprintManager mFingerprintManager;
|
||||||
@Mock
|
@Mock
|
||||||
private FaceManager mFaceManager;
|
private FaceManager mFaceManager;
|
||||||
|
@Mock
|
||||||
|
private SupervisionManager mSupervisionManager;
|
||||||
|
|
||||||
private Context mApplicationContext;
|
private Context mApplicationContext;
|
||||||
private FingerprintStatusUtils mFingerprintStatusUtils;
|
private FingerprintStatusUtils mFingerprintStatusUtils;
|
||||||
@@ -76,13 +85,13 @@ public class FingerprintStatusUtilsTest {
|
|||||||
when(mApplicationContext.getPackageManager()).thenReturn(mPackageManager);
|
when(mApplicationContext.getPackageManager()).thenReturn(mPackageManager);
|
||||||
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)).thenReturn(true);
|
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)).thenReturn(true);
|
||||||
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FACE)).thenReturn(true);
|
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FACE)).thenReturn(true);
|
||||||
when(mDevicePolicyManager.getProfileOwnerOrDeviceOwnerSupervisionComponent(USER_HANDLE))
|
|
||||||
.thenReturn(COMPONENT_NAME);
|
|
||||||
when(mApplicationContext.getSystemService(Context.FINGERPRINT_SERVICE))
|
when(mApplicationContext.getSystemService(Context.FINGERPRINT_SERVICE))
|
||||||
.thenReturn(mFingerprintManager);
|
.thenReturn(mFingerprintManager);
|
||||||
when(mApplicationContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
|
when(mApplicationContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
|
||||||
.thenReturn(mDevicePolicyManager);
|
.thenReturn(mDevicePolicyManager);
|
||||||
when(mApplicationContext.getSystemService(Context.FACE_SERVICE)).thenReturn(mFaceManager);
|
when(mApplicationContext.getSystemService(Context.FACE_SERVICE)).thenReturn(mFaceManager);
|
||||||
|
when(mApplicationContext.getSystemService(Context.SUPERVISION_SERVICE))
|
||||||
|
.thenReturn(mSupervisionManager);
|
||||||
mFingerprintStatusUtils =
|
mFingerprintStatusUtils =
|
||||||
new FingerprintStatusUtils(mApplicationContext, mFingerprintManager, USER_ID);
|
new FingerprintStatusUtils(mApplicationContext, mFingerprintManager, USER_ID);
|
||||||
}
|
}
|
||||||
@@ -134,7 +143,10 @@ public class FingerprintStatusUtilsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@DisableFlags(android.app.supervision.flags.Flags.FLAG_DEPRECATE_DPM_SUPERVISION_APIS)
|
||||||
public void getDisabledAdmin_whenFingerprintDisabled_returnsEnforcedAdmin() {
|
public void getDisabledAdmin_whenFingerprintDisabled_returnsEnforcedAdmin() {
|
||||||
|
when(mDevicePolicyManager.getProfileOwnerOrDeviceOwnerSupervisionComponent(USER_HANDLE))
|
||||||
|
.thenReturn(COMPONENT_NAME);
|
||||||
when(mDevicePolicyManager.getKeyguardDisabledFeatures(COMPONENT_NAME))
|
when(mDevicePolicyManager.getKeyguardDisabledFeatures(COMPONENT_NAME))
|
||||||
.thenReturn(DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT);
|
.thenReturn(DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT);
|
||||||
|
|
||||||
@@ -145,6 +157,20 @@ public class FingerprintStatusUtilsTest {
|
|||||||
COMPONENT_NAME, UserManager.DISALLOW_BIOMETRIC, USER_HANDLE));
|
COMPONENT_NAME, UserManager.DISALLOW_BIOMETRIC, USER_HANDLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(android.app.supervision.flags.Flags.FLAG_DEPRECATE_DPM_SUPERVISION_APIS)
|
||||||
|
public void getDisabledAdmin_whenFingerprintDisabled_returnsRestriction() {
|
||||||
|
when(mSupervisionManager.isSupervisionEnabledForUser(USER_ID)).thenReturn(true);
|
||||||
|
when(mDevicePolicyManager.getKeyguardDisabledFeatures(null))
|
||||||
|
.thenReturn(DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT);
|
||||||
|
|
||||||
|
final RestrictedLockUtils.EnforcedAdmin admin =
|
||||||
|
mFingerprintStatusUtils.getDisablingAdmin();
|
||||||
|
|
||||||
|
assertThat(admin.enforcedRestriction).isEqualTo(UserManager.DISALLOW_BIOMETRIC);
|
||||||
|
assertThat(admin.user).isEqualTo(USER_HANDLE);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getDisabledAdmin_withFingerprintEnabled_returnsNull() {
|
public void getDisabledAdmin_withFingerprintEnabled_returnsNull() {
|
||||||
when(mDevicePolicyManager.getKeyguardDisabledFeatures(COMPONENT_NAME)).thenReturn(0);
|
when(mDevicePolicyManager.getKeyguardDisabledFeatures(COMPONENT_NAME)).thenReturn(0);
|
||||||
|
@@ -31,15 +31,17 @@ import static org.mockito.Mockito.verify;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
|
import android.app.supervision.SupervisionManager;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.hardware.face.FaceManager;
|
import android.hardware.face.FaceManager;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
|
import android.platform.test.annotations.DisableFlags;
|
||||||
|
import android.platform.test.annotations.EnableFlags;
|
||||||
import android.platform.test.annotations.RequiresFlagsEnabled;
|
import android.platform.test.annotations.RequiresFlagsEnabled;
|
||||||
import android.platform.test.flag.junit.CheckFlagsRule;
|
import android.platform.test.flag.junit.SetFlagsRule;
|
||||||
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
|
|
||||||
import android.safetycenter.SafetyEvent;
|
import android.safetycenter.SafetyEvent;
|
||||||
import android.safetycenter.SafetySourceData;
|
import android.safetycenter.SafetySourceData;
|
||||||
import android.safetycenter.SafetySourceStatus;
|
import android.safetycenter.SafetySourceStatus;
|
||||||
@@ -68,12 +70,13 @@ import org.mockito.MockitoAnnotations;
|
|||||||
public class FaceSafetySourceTest {
|
public class FaceSafetySourceTest {
|
||||||
|
|
||||||
private static final ComponentName COMPONENT_NAME = new ComponentName("package", "class");
|
private static final ComponentName COMPONENT_NAME = new ComponentName("package", "class");
|
||||||
private static final UserHandle USER_HANDLE = new UserHandle(UserHandle.myUserId());
|
private static final int USER_ID = UserHandle.myUserId();
|
||||||
|
private static final UserHandle USER_HANDLE = new UserHandle(USER_ID);
|
||||||
private static final SafetyEvent EVENT_SOURCE_STATE_CHANGED =
|
private static final SafetyEvent EVENT_SOURCE_STATE_CHANGED =
|
||||||
new SafetyEvent.Builder(SAFETY_EVENT_TYPE_SOURCE_STATE_CHANGED).build();
|
new SafetyEvent.Builder(SAFETY_EVENT_TYPE_SOURCE_STATE_CHANGED).build();
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
|
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||||
|
|
||||||
private Context mApplicationContext;
|
private Context mApplicationContext;
|
||||||
|
|
||||||
@@ -82,6 +85,7 @@ public class FaceSafetySourceTest {
|
|||||||
@Mock private FaceManager mFaceManager;
|
@Mock private FaceManager mFaceManager;
|
||||||
@Mock private LockPatternUtils mLockPatternUtils;
|
@Mock private LockPatternUtils mLockPatternUtils;
|
||||||
@Mock private SafetyCenterManagerWrapper mSafetyCenterManagerWrapper;
|
@Mock private SafetyCenterManagerWrapper mSafetyCenterManagerWrapper;
|
||||||
|
@Mock private SupervisionManager mSupervisionManager;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
@@ -90,11 +94,11 @@ public class FaceSafetySourceTest {
|
|||||||
when(mApplicationContext.getPackageManager()).thenReturn(mPackageManager);
|
when(mApplicationContext.getPackageManager()).thenReturn(mPackageManager);
|
||||||
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)).thenReturn(true);
|
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)).thenReturn(true);
|
||||||
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FACE)).thenReturn(true);
|
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FACE)).thenReturn(true);
|
||||||
when(mDevicePolicyManager.getProfileOwnerOrDeviceOwnerSupervisionComponent(USER_HANDLE))
|
|
||||||
.thenReturn(COMPONENT_NAME);
|
|
||||||
when(mApplicationContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
|
when(mApplicationContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
|
||||||
.thenReturn(mDevicePolicyManager);
|
.thenReturn(mDevicePolicyManager);
|
||||||
when(mApplicationContext.getSystemService(Context.FACE_SERVICE)).thenReturn(mFaceManager);
|
when(mApplicationContext.getSystemService(Context.FACE_SERVICE)).thenReturn(mFaceManager);
|
||||||
|
when(mApplicationContext.getSystemService(Context.SUPERVISION_SERVICE))
|
||||||
|
.thenReturn(mSupervisionManager);
|
||||||
FakeFeatureFactory featureFactory = FakeFeatureFactory.setupForTest();
|
FakeFeatureFactory featureFactory = FakeFeatureFactory.setupForTest();
|
||||||
when(featureFactory.securityFeatureProvider.getLockPatternUtils(mApplicationContext))
|
when(featureFactory.securityFeatureProvider.getLockPatternUtils(mApplicationContext))
|
||||||
.thenReturn(mLockPatternUtils);
|
.thenReturn(mLockPatternUtils);
|
||||||
@@ -153,7 +157,10 @@ public class FaceSafetySourceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@DisableFlags(android.app.supervision.flags.Flags.FLAG_DEPRECATE_DPM_SUPERVISION_APIS)
|
||||||
public void setSafetySourceData_withFaceNotEnrolled_whenDisabledByAdmin_setsData() {
|
public void setSafetySourceData_withFaceNotEnrolled_whenDisabledByAdmin_setsData() {
|
||||||
|
when(mDevicePolicyManager.getProfileOwnerOrDeviceOwnerSupervisionComponent(USER_HANDLE))
|
||||||
|
.thenReturn(COMPONENT_NAME);
|
||||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||||
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||||
when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(false);
|
when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(false);
|
||||||
@@ -167,6 +174,23 @@ public class FaceSafetySourceTest {
|
|||||||
"security_settings_face_preference_summary_none");
|
"security_settings_face_preference_summary_none");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(android.app.supervision.flags.Flags.FLAG_DEPRECATE_DPM_SUPERVISION_APIS)
|
||||||
|
public void setSafetySourceData_withFaceNotEnrolled_whenSupervisionIsOn_setsData() {
|
||||||
|
when(mSupervisionManager.isSupervisionEnabledForUser(USER_ID)).thenReturn(true);
|
||||||
|
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||||
|
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||||
|
when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(false);
|
||||||
|
when(mDevicePolicyManager.getKeyguardDisabledFeatures(null))
|
||||||
|
.thenReturn(DevicePolicyManager.KEYGUARD_DISABLE_FACE);
|
||||||
|
|
||||||
|
FaceSafetySource.setSafetySourceData(mApplicationContext, EVENT_SOURCE_STATE_CHANGED);
|
||||||
|
|
||||||
|
assertSafetySourceDisabledDataSetWithSingularSummary(
|
||||||
|
"security_settings_face_preference_title_new",
|
||||||
|
"security_settings_face_preference_summary_none");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setSafetySourceData_withFaceNotEnrolled_whenNotDisabledByAdmin_setsData() {
|
public void setSafetySourceData_withFaceNotEnrolled_whenNotDisabledByAdmin_setsData() {
|
||||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||||
@@ -183,7 +207,10 @@ public class FaceSafetySourceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@DisableFlags(android.app.supervision.flags.Flags.FLAG_DEPRECATE_DPM_SUPERVISION_APIS)
|
||||||
public void setSafetySourceData_withFaceEnrolled_whenDisabledByAdmin_setsData() {
|
public void setSafetySourceData_withFaceEnrolled_whenDisabledByAdmin_setsData() {
|
||||||
|
when(mDevicePolicyManager.getProfileOwnerOrDeviceOwnerSupervisionComponent(USER_HANDLE))
|
||||||
|
.thenReturn(COMPONENT_NAME);
|
||||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||||
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||||
when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(true);
|
when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(true);
|
||||||
@@ -197,6 +224,23 @@ public class FaceSafetySourceTest {
|
|||||||
"security_settings_face_preference_summary");
|
"security_settings_face_preference_summary");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(android.app.supervision.flags.Flags.FLAG_DEPRECATE_DPM_SUPERVISION_APIS)
|
||||||
|
public void setSafetySourceData_withFaceEnrolled_whenSupervisionIsOn_setsData() {
|
||||||
|
when(mSupervisionManager.isSupervisionEnabledForUser(USER_ID)).thenReturn(true);
|
||||||
|
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||||
|
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||||
|
when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(true);
|
||||||
|
when(mDevicePolicyManager.getKeyguardDisabledFeatures(null))
|
||||||
|
.thenReturn(DevicePolicyManager.KEYGUARD_DISABLE_FACE);
|
||||||
|
|
||||||
|
FaceSafetySource.setSafetySourceData(mApplicationContext, EVENT_SOURCE_STATE_CHANGED);
|
||||||
|
|
||||||
|
assertSafetySourceDisabledDataSetWithSingularSummary(
|
||||||
|
"security_settings_face_preference_title_new",
|
||||||
|
"security_settings_face_preference_summary");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setSafetySourceData_withFaceEnrolled_whenNotDisabledByAdmin_setsData() {
|
public void setSafetySourceData_withFaceEnrolled_whenNotDisabledByAdmin_setsData() {
|
||||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||||
|
@@ -31,6 +31,7 @@ import static org.mockito.Mockito.verify;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
|
import android.app.supervision.SupervisionManager;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -38,9 +39,10 @@ import android.content.pm.PackageManager;
|
|||||||
import android.hardware.fingerprint.Fingerprint;
|
import android.hardware.fingerprint.Fingerprint;
|
||||||
import android.hardware.fingerprint.FingerprintManager;
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
|
import android.platform.test.annotations.DisableFlags;
|
||||||
|
import android.platform.test.annotations.EnableFlags;
|
||||||
import android.platform.test.annotations.RequiresFlagsEnabled;
|
import android.platform.test.annotations.RequiresFlagsEnabled;
|
||||||
import android.platform.test.flag.junit.CheckFlagsRule;
|
import android.platform.test.flag.junit.SetFlagsRule;
|
||||||
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
|
|
||||||
import android.safetycenter.SafetyEvent;
|
import android.safetycenter.SafetyEvent;
|
||||||
import android.safetycenter.SafetySourceData;
|
import android.safetycenter.SafetySourceData;
|
||||||
import android.safetycenter.SafetySourceStatus;
|
import android.safetycenter.SafetySourceStatus;
|
||||||
@@ -72,12 +74,13 @@ import java.util.List;
|
|||||||
public class FingerprintSafetySourceTest {
|
public class FingerprintSafetySourceTest {
|
||||||
|
|
||||||
private static final ComponentName COMPONENT_NAME = new ComponentName("package", "class");
|
private static final ComponentName COMPONENT_NAME = new ComponentName("package", "class");
|
||||||
private static final UserHandle USER_HANDLE = new UserHandle(UserHandle.myUserId());
|
private static final int USER_ID = UserHandle.myUserId();
|
||||||
|
private static final UserHandle USER_HANDLE = new UserHandle(USER_ID);
|
||||||
private static final SafetyEvent EVENT_SOURCE_STATE_CHANGED =
|
private static final SafetyEvent EVENT_SOURCE_STATE_CHANGED =
|
||||||
new SafetyEvent.Builder(SAFETY_EVENT_TYPE_SOURCE_STATE_CHANGED).build();
|
new SafetyEvent.Builder(SAFETY_EVENT_TYPE_SOURCE_STATE_CHANGED).build();
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
|
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||||
|
|
||||||
private Context mApplicationContext;
|
private Context mApplicationContext;
|
||||||
|
|
||||||
@@ -86,6 +89,7 @@ public class FingerprintSafetySourceTest {
|
|||||||
@Mock private FingerprintManager mFingerprintManager;
|
@Mock private FingerprintManager mFingerprintManager;
|
||||||
@Mock private LockPatternUtils mLockPatternUtils;
|
@Mock private LockPatternUtils mLockPatternUtils;
|
||||||
@Mock private SafetyCenterManagerWrapper mSafetyCenterManagerWrapper;
|
@Mock private SafetyCenterManagerWrapper mSafetyCenterManagerWrapper;
|
||||||
|
@Mock private SupervisionManager mSupervisionManager;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
@@ -94,12 +98,12 @@ public class FingerprintSafetySourceTest {
|
|||||||
when(mApplicationContext.getPackageManager()).thenReturn(mPackageManager);
|
when(mApplicationContext.getPackageManager()).thenReturn(mPackageManager);
|
||||||
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)).thenReturn(true);
|
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)).thenReturn(true);
|
||||||
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FACE)).thenReturn(true);
|
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FACE)).thenReturn(true);
|
||||||
when(mDevicePolicyManager.getProfileOwnerOrDeviceOwnerSupervisionComponent(USER_HANDLE))
|
|
||||||
.thenReturn(COMPONENT_NAME);
|
|
||||||
when(mApplicationContext.getSystemService(Context.FINGERPRINT_SERVICE))
|
when(mApplicationContext.getSystemService(Context.FINGERPRINT_SERVICE))
|
||||||
.thenReturn(mFingerprintManager);
|
.thenReturn(mFingerprintManager);
|
||||||
when(mApplicationContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
|
when(mApplicationContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
|
||||||
.thenReturn(mDevicePolicyManager);
|
.thenReturn(mDevicePolicyManager);
|
||||||
|
when(mApplicationContext.getSystemService(Context.SUPERVISION_SERVICE))
|
||||||
|
.thenReturn(mSupervisionManager);
|
||||||
FakeFeatureFactory featureFactory = FakeFeatureFactory.setupForTest();
|
FakeFeatureFactory featureFactory = FakeFeatureFactory.setupForTest();
|
||||||
when(featureFactory.securityFeatureProvider.getLockPatternUtils(mApplicationContext))
|
when(featureFactory.securityFeatureProvider.getLockPatternUtils(mApplicationContext))
|
||||||
.thenReturn(mLockPatternUtils);
|
.thenReturn(mLockPatternUtils);
|
||||||
@@ -166,7 +170,10 @@ public class FingerprintSafetySourceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@DisableFlags(android.app.supervision.flags.Flags.FLAG_DEPRECATE_DPM_SUPERVISION_APIS)
|
||||||
public void setSafetySourceData_withFingerprintNotEnrolled_whenDisabledByAdmin_setsData() {
|
public void setSafetySourceData_withFingerprintNotEnrolled_whenDisabledByAdmin_setsData() {
|
||||||
|
when(mDevicePolicyManager.getProfileOwnerOrDeviceOwnerSupervisionComponent(USER_HANDLE))
|
||||||
|
.thenReturn(COMPONENT_NAME);
|
||||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||||
when(mFingerprintManager.hasEnrolledFingerprints(anyInt())).thenReturn(false);
|
when(mFingerprintManager.hasEnrolledFingerprints(anyInt())).thenReturn(false);
|
||||||
@@ -181,6 +188,24 @@ public class FingerprintSafetySourceTest {
|
|||||||
"security_settings_fingerprint_preference_summary_none");
|
"security_settings_fingerprint_preference_summary_none");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(android.app.supervision.flags.Flags.FLAG_DEPRECATE_DPM_SUPERVISION_APIS)
|
||||||
|
public void setSafetySourceData_withFingerprintNotEnrolled_whenSupervisionIsOn_setsData() {
|
||||||
|
when(mSupervisionManager.isSupervisionEnabledForUser(USER_ID)).thenReturn(true);
|
||||||
|
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||||
|
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||||
|
when(mFingerprintManager.hasEnrolledFingerprints(anyInt())).thenReturn(false);
|
||||||
|
when(mDevicePolicyManager.getKeyguardDisabledFeatures(null))
|
||||||
|
.thenReturn(DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT);
|
||||||
|
|
||||||
|
FingerprintSafetySource.setSafetySourceData(
|
||||||
|
mApplicationContext, EVENT_SOURCE_STATE_CHANGED);
|
||||||
|
|
||||||
|
assertSafetySourceDisabledDataSetWithSingularSummary(
|
||||||
|
"security_settings_fingerprint",
|
||||||
|
"security_settings_fingerprint_preference_summary_none");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setSafetySourceData_withFingerprintNotEnrolled_whenNotDisabledByAdmin_setsData() {
|
public void setSafetySourceData_withFingerprintNotEnrolled_whenNotDisabledByAdmin_setsData() {
|
||||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||||
@@ -198,8 +223,11 @@ public class FingerprintSafetySourceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@DisableFlags(android.app.supervision.flags.Flags.FLAG_DEPRECATE_DPM_SUPERVISION_APIS)
|
||||||
public void setSafetySourceData_withFingerprintsEnrolled_whenDisabledByAdmin_setsData() {
|
public void setSafetySourceData_withFingerprintsEnrolled_whenDisabledByAdmin_setsData() {
|
||||||
int enrolledFingerprintsCount = 2;
|
int enrolledFingerprintsCount = 2;
|
||||||
|
when(mDevicePolicyManager.getProfileOwnerOrDeviceOwnerSupervisionComponent(USER_HANDLE))
|
||||||
|
.thenReturn(COMPONENT_NAME);
|
||||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||||
when(mFingerprintManager.hasEnrolledFingerprints(anyInt())).thenReturn(true);
|
when(mFingerprintManager.hasEnrolledFingerprints(anyInt())).thenReturn(true);
|
||||||
@@ -217,6 +245,28 @@ public class FingerprintSafetySourceTest {
|
|||||||
enrolledFingerprintsCount);
|
enrolledFingerprintsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(android.app.supervision.flags.Flags.FLAG_DEPRECATE_DPM_SUPERVISION_APIS)
|
||||||
|
public void setSafetySourceData_withFingerprintsEnrolled_whenSupervisionIsOn_setsData() {
|
||||||
|
int enrolledFingerprintsCount = 2;
|
||||||
|
when(mSupervisionManager.isSupervisionEnabledForUser(USER_ID)).thenReturn(true);
|
||||||
|
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||||
|
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||||
|
when(mFingerprintManager.hasEnrolledFingerprints(anyInt())).thenReturn(true);
|
||||||
|
when(mFingerprintManager.getEnrolledFingerprints(anyInt()))
|
||||||
|
.thenReturn(createFingerprintList(enrolledFingerprintsCount));
|
||||||
|
when(mDevicePolicyManager.getKeyguardDisabledFeatures(null))
|
||||||
|
.thenReturn(DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT);
|
||||||
|
|
||||||
|
FingerprintSafetySource.setSafetySourceData(
|
||||||
|
mApplicationContext, EVENT_SOURCE_STATE_CHANGED);
|
||||||
|
|
||||||
|
assertSafetySourceDisabledDataSetWithPluralSummary(
|
||||||
|
"security_settings_fingerprint",
|
||||||
|
"security_settings_fingerprint_preference_summary",
|
||||||
|
enrolledFingerprintsCount);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setSafetySourceData_withFingerprintsEnrolled_whenNotDisabledByAdmin_setsData() {
|
public void setSafetySourceData_withFingerprintsEnrolled_whenNotDisabledByAdmin_setsData() {
|
||||||
int enrolledFingerprintsCount = 2;
|
int enrolledFingerprintsCount = 2;
|
||||||
|
Reference in New Issue
Block a user