Merge "Always set source status, even when null." into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
6fd9cd771b
@@ -35,6 +35,7 @@ import com.android.settings.biometrics.activeunlock.ActiveUnlockStatusUtils;
|
||||
import com.android.settings.biometrics.combination.CombinedBiometricStatusUtils;
|
||||
import com.android.settings.biometrics.face.FaceStatusUtils;
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintStatusUtils;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
|
||||
/** Combined Biometrics Safety Source for Safety Center. */
|
||||
@@ -49,6 +50,10 @@ public final class BiometricsSafetySource {
|
||||
if (!SafetyCenterManagerWrapper.get().isEnabled(context)) {
|
||||
return;
|
||||
}
|
||||
if (Flags.biometricsOnboardingEducation()) { // this source is effectively turned off
|
||||
sendNullData(context, safetyEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
UserHandle userHandle = Process.myUserHandle();
|
||||
int userId = userHandle.getIdentifier();
|
||||
@@ -63,9 +68,7 @@ public final class BiometricsSafetySource {
|
||||
&& userManager.isPrivateProfile()) {
|
||||
// SC always expects a response from the source if the broadcast has been sent for this
|
||||
// source, therefore, we need to send a null SafetySourceData.
|
||||
SafetyCenterManagerWrapper.get()
|
||||
.setSafetySourceData(
|
||||
context, SAFETY_SOURCE_ID, /* safetySourceData= */ null, safetyEvent);
|
||||
sendNullData(context, safetyEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -174,6 +177,10 @@ public final class BiometricsSafetySource {
|
||||
return;
|
||||
}
|
||||
|
||||
sendNullData(context, safetyEvent);
|
||||
}
|
||||
|
||||
private static void sendNullData(Context context, SafetyEvent safetyEvent) {
|
||||
SafetyCenterManagerWrapper.get()
|
||||
.setSafetySourceData(
|
||||
context, SAFETY_SOURCE_ID, /* safetySourceData= */ null, safetyEvent);
|
||||
|
@@ -29,6 +29,7 @@ import android.safetycenter.SafetyEvent;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.biometrics.BiometricNavigationUtils;
|
||||
import com.android.settings.biometrics.face.FaceStatusUtils;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
|
||||
@@ -44,6 +45,10 @@ public final class FaceSafetySource {
|
||||
if (!SafetyCenterManagerWrapper.get().isEnabled(context)) {
|
||||
return;
|
||||
}
|
||||
if (!Flags.biometricsOnboardingEducation()) { // this source is effectively turned off
|
||||
sendNullData(context, safetyEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle private profile case
|
||||
UserManager userManager = UserManager.get(context);
|
||||
@@ -52,9 +57,7 @@ public final class FaceSafetySource {
|
||||
&& userManager.isPrivateProfile()) {
|
||||
// SC always expects a response from the source if the broadcast has been sent for this
|
||||
// source, therefore, we need to send a null SafetySourceData.
|
||||
SafetyCenterManagerWrapper.get()
|
||||
.setSafetySourceData(
|
||||
context, SAFETY_SOURCE_ID, /* safetySourceData= */ null, safetyEvent);
|
||||
sendNullData(context, safetyEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -95,6 +98,10 @@ public final class FaceSafetySource {
|
||||
return;
|
||||
}
|
||||
|
||||
sendNullData(context, safetyEvent);
|
||||
}
|
||||
|
||||
private static void sendNullData(Context context, SafetyEvent safetyEvent) {
|
||||
SafetyCenterManagerWrapper.get()
|
||||
.setSafetySourceData(
|
||||
context, SAFETY_SOURCE_ID, /* safetySourceData= */ null, safetyEvent);
|
||||
|
@@ -29,6 +29,7 @@ import android.safetycenter.SafetyEvent;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.biometrics.BiometricNavigationUtils;
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintStatusUtils;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
|
||||
@@ -44,6 +45,10 @@ public final class FingerprintSafetySource {
|
||||
if (!SafetyCenterManagerWrapper.get().isEnabled(context)) {
|
||||
return;
|
||||
}
|
||||
if (!Flags.biometricsOnboardingEducation()) { // this source is effectively turned off
|
||||
sendNullData(context, safetyEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle private profile case
|
||||
UserManager userManager = UserManager.get(context);
|
||||
@@ -52,9 +57,7 @@ public final class FingerprintSafetySource {
|
||||
&& userManager.isPrivateProfile()) {
|
||||
// SC always expects a response from the source if the broadcast has been sent for this
|
||||
// source, therefore, we need to send a null SafetySourceData.
|
||||
SafetyCenterManagerWrapper.get()
|
||||
.setSafetySourceData(
|
||||
context, SAFETY_SOURCE_ID, /* safetySourceData= */ null, safetyEvent);
|
||||
sendNullData(context, safetyEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -96,6 +99,10 @@ public final class FingerprintSafetySource {
|
||||
return;
|
||||
}
|
||||
|
||||
sendNullData(context, safetyEvent);
|
||||
}
|
||||
|
||||
private static void sendNullData(Context context, SafetyEvent safetyEvent) {
|
||||
SafetyCenterManagerWrapper.get()
|
||||
.setSafetySourceData(
|
||||
context, SAFETY_SOURCE_ID, /* safetySourceData= */ null, safetyEvent);
|
||||
|
@@ -28,7 +28,6 @@ import android.content.Intent;
|
||||
import android.safetycenter.SafetyCenterManager;
|
||||
import android.safetycenter.SafetyEvent;
|
||||
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.privatespace.PrivateSpaceSafetySource;
|
||||
import com.android.settings.security.ScreenLockPreferenceDetailsUtils;
|
||||
|
||||
@@ -75,20 +74,16 @@ public class SafetySourceBroadcastReceiver extends BroadcastReceiver {
|
||||
context, new ScreenLockPreferenceDetailsUtils(context), safetyEvent);
|
||||
}
|
||||
|
||||
if (sourceIds.contains(BiometricsSafetySource.SAFETY_SOURCE_ID)
|
||||
&& !Flags.biometricsOnboardingEducation()) {
|
||||
if (sourceIds.contains(BiometricsSafetySource.SAFETY_SOURCE_ID)) {
|
||||
BiometricsSafetySource.setSafetySourceData(context, safetyEvent);
|
||||
}
|
||||
|
||||
if (sourceIds.contains(PrivateSpaceSafetySource.SAFETY_SOURCE_ID)) {
|
||||
PrivateSpaceSafetySource.setSafetySourceData(context, safetyEvent);
|
||||
}
|
||||
if (sourceIds.contains(FaceSafetySource.SAFETY_SOURCE_ID)
|
||||
&& Flags.biometricsOnboardingEducation()) {
|
||||
if (sourceIds.contains(FaceSafetySource.SAFETY_SOURCE_ID)) {
|
||||
FaceSafetySource.setSafetySourceData(context, safetyEvent);
|
||||
}
|
||||
if (sourceIds.contains(FingerprintSafetySource.SAFETY_SOURCE_ID)
|
||||
&& Flags.biometricsOnboardingEducation()) {
|
||||
if (sourceIds.contains(FingerprintSafetySource.SAFETY_SOURCE_ID)) {
|
||||
FingerprintSafetySource.setSafetySourceData(context, safetyEvent);
|
||||
}
|
||||
}
|
||||
@@ -96,13 +91,9 @@ public class SafetySourceBroadcastReceiver extends BroadcastReceiver {
|
||||
private static void refreshAllSafetySources(Context context, SafetyEvent safetyEvent) {
|
||||
LockScreenSafetySource.setSafetySourceData(
|
||||
context, new ScreenLockPreferenceDetailsUtils(context), safetyEvent);
|
||||
if (!Flags.biometricsOnboardingEducation()) {
|
||||
BiometricsSafetySource.setSafetySourceData(context, safetyEvent);
|
||||
}
|
||||
PrivateSpaceSafetySource.setSafetySourceData(context, safetyEvent);
|
||||
if (Flags.biometricsOnboardingEducation()) {
|
||||
FaceSafetySource.setSafetySourceData(context, safetyEvent);
|
||||
FingerprintSafetySource.setSafetySourceData(context, safetyEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -40,6 +40,7 @@ import android.hardware.fingerprint.Fingerprint;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.os.UserHandle;
|
||||
import android.platform.test.annotations.RequiresFlagsDisabled;
|
||||
import android.platform.test.annotations.RequiresFlagsEnabled;
|
||||
import android.platform.test.flag.junit.CheckFlagsRule;
|
||||
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
|
||||
import android.safetycenter.SafetyEvent;
|
||||
@@ -72,7 +73,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class BiometricsSafetySourceTest {
|
||||
|
||||
@@ -130,6 +130,19 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_whenSeparateBiometricsFlagOn_setsNullData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
|
||||
BiometricsSafetySource.setSafetySourceData(mApplicationContext, EVENT_SOURCE_STATE_CHANGED);
|
||||
|
||||
verify(mSafetyCenterManagerWrapper)
|
||||
.setSafetySourceData(
|
||||
any(), eq(BiometricsSafetySource.SAFETY_SOURCE_ID), eq(null), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_whenSafetyCenterIsEnabled_withoutBiometrics_setsNullData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
|
||||
@@ -143,6 +156,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_setsDataForBiometricSource() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -158,6 +172,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_setsDataWithCorrectSafetyEvent() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -172,6 +187,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_withFingerprintNotEnrolled_whenDisabledByAdmin_setsData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -188,6 +204,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_withFingerprintNotEnrolled_whenNotDisabledByAdmin_setsData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -204,6 +221,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_withFingerprintsEnrolled_whenDisabledByAdmin_setsData() {
|
||||
int enrolledFingerprintsCount = 2;
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
@@ -224,6 +242,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_withFingerprintsEnrolled_whenNotDisabledByAdmin_setsData() {
|
||||
int enrolledFingerprintsCount = 2;
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
@@ -244,6 +263,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_withFaceNotEnrolled_whenDisabledByAdmin_setsData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
|
||||
@@ -260,6 +280,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_withFaceNotEnrolled_whenNotDisabledByAdmin_setsData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
|
||||
@@ -276,6 +297,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_withFaceEnrolled_whenDisabledByAdmin_setsData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
|
||||
@@ -292,6 +314,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_withFaceEnrolled_whenNotDisabledByAdmin_setsData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
|
||||
@@ -308,6 +331,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_withFaceAndFingerprint_whenBothNotDisabledByAdmin_setsData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -323,6 +347,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_withFaceAndFingerprint_whenFaceDisabledByAdmin_setsData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -339,6 +364,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_faceAndFingerprint_whenFingerprintDisabledByAdmin_setsData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -355,6 +381,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_faceAndFingerprint_whenBothDisabledByAdmin_setsData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -372,6 +399,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_faceAndFingerprint_whenFaceEnrolled_withMpFingers_setsData() {
|
||||
int enrolledFingerprintsCount = 2;
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
@@ -390,6 +418,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_faceAndFingerprint_whenFaceEnrolled_withOneFinger_setsData() {
|
||||
int enrolledFingerprintsCount = 1;
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
@@ -408,6 +437,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_faceAndFingerprint_whenFaceEnrolled_withNoFingers_setsData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -425,6 +455,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_activeUnlockEnabled_withFingerprintOnly_setsData() {
|
||||
int enrolledFingerprintsCount = 1;
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
@@ -445,6 +476,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_activeUnlockEnabled_withFaceOnly_setsData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
|
||||
@@ -461,6 +493,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_activeUnlockEnabled_withFaceAndFingerprint_setsData() {
|
||||
int enrolledFingerprintsCount = 1;
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
@@ -480,6 +513,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_faceAndFingerprint_whenNoFaceEnrolled_withFingers_setsData() {
|
||||
int enrolledFingerprintsCount = 1;
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
@@ -499,6 +533,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_faceAndFingerprint_whenFaceEnrolled_setsInfoSeverity() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -521,6 +556,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_faceAndFingerprint_whenFingerprintEnrolled_setsInfoSeverity() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -543,6 +579,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_faceAndFingerprint_whenNotEnrolled_setsUnspSeverity() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -565,6 +602,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_fingerprint_whenEnrolled_setsInfoSeverity() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -586,6 +624,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_fingerprint_whenNotEnrolled_setsUnspSeverity() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -607,6 +646,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_face_whenEnrolled_setsInfoSeverity() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
|
||||
@@ -628,6 +668,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_face_whenNotEnrolled_setsUnspSeverity() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
|
||||
|
@@ -40,6 +40,7 @@ import android.hardware.face.FaceManager;
|
||||
import android.os.UserHandle;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.annotations.RequiresFlagsDisabled;
|
||||
import android.platform.test.annotations.RequiresFlagsEnabled;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.safetycenter.SafetyEvent;
|
||||
@@ -65,7 +66,6 @@ import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class FaceSafetySourceTest {
|
||||
|
||||
@@ -112,6 +112,7 @@ public class FaceSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetyData_whenSafetyCenterIsDisabled_doesNotSetData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(false);
|
||||
|
||||
@@ -122,6 +123,18 @@ public class FaceSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_whenSeparateBiometricsFlagOff_setsNullData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
|
||||
FaceSafetySource.setSafetySourceData(mApplicationContext, EVENT_SOURCE_STATE_CHANGED);
|
||||
|
||||
verify(mSafetyCenterManagerWrapper)
|
||||
.setSafetySourceData(any(), eq(FaceSafetySource.SAFETY_SOURCE_ID), eq(null), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_whenSafetyCenterIsEnabled_withoutFaceHardware_setsNullData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFaceManager.isHardwareDetected()).thenReturn(false);
|
||||
@@ -133,6 +146,7 @@ public class FaceSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_setsDataForFaceSource() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -145,6 +159,7 @@ public class FaceSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_setsDataWithCorrectSafetyEvent() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -157,6 +172,7 @@ public class FaceSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
@DisableFlags(android.app.supervision.flags.Flags.FLAG_DEPRECATE_DPM_SUPERVISION_APIS)
|
||||
public void setSafetySourceData_withFaceNotEnrolled_whenDisabledByAdmin_setsData() {
|
||||
when(mDevicePolicyManager.getProfileOwnerOrDeviceOwnerSupervisionComponent(USER_HANDLE))
|
||||
@@ -175,6 +191,7 @@ public class FaceSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
@EnableFlags(android.app.supervision.flags.Flags.FLAG_DEPRECATE_DPM_SUPERVISION_APIS)
|
||||
public void setSafetySourceData_withFaceNotEnrolled_whenSupervisionIsOn_setsData() {
|
||||
when(mSupervisionManager.isSupervisionEnabledForUser(USER_ID)).thenReturn(true);
|
||||
@@ -192,6 +209,7 @@ public class FaceSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_withFaceNotEnrolled_whenNotDisabledByAdmin_setsData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -207,6 +225,7 @@ public class FaceSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
@DisableFlags(android.app.supervision.flags.Flags.FLAG_DEPRECATE_DPM_SUPERVISION_APIS)
|
||||
public void setSafetySourceData_withFaceEnrolled_whenDisabledByAdmin_setsData() {
|
||||
when(mDevicePolicyManager.getProfileOwnerOrDeviceOwnerSupervisionComponent(USER_HANDLE))
|
||||
@@ -225,6 +244,7 @@ public class FaceSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
@EnableFlags(android.app.supervision.flags.Flags.FLAG_DEPRECATE_DPM_SUPERVISION_APIS)
|
||||
public void setSafetySourceData_withFaceEnrolled_whenSupervisionIsOn_setsData() {
|
||||
when(mSupervisionManager.isSupervisionEnabledForUser(USER_ID)).thenReturn(true);
|
||||
@@ -242,6 +262,7 @@ public class FaceSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_withFaceEnrolled_whenNotDisabledByAdmin_setsData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -257,6 +278,7 @@ public class FaceSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_face_whenEnrolled_setsInfoSeverity() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -274,6 +296,7 @@ public class FaceSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_face_whenNotEnrolled_setsUnspSeverity() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||
|
@@ -41,6 +41,7 @@ import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.os.UserHandle;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.annotations.RequiresFlagsDisabled;
|
||||
import android.platform.test.annotations.RequiresFlagsEnabled;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.safetycenter.SafetyEvent;
|
||||
@@ -69,7 +70,6 @@ import org.mockito.MockitoAnnotations;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class FingerprintSafetySourceTest {
|
||||
|
||||
@@ -117,6 +117,7 @@ public class FingerprintSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetyData_whenSafetyCenterIsDisabled_doesNotSetData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(false);
|
||||
|
||||
@@ -128,6 +129,20 @@ public class FingerprintSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_whenSeparateBiometricsFlagOff_setsNullData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
|
||||
FingerprintSafetySource.setSafetySourceData(
|
||||
mApplicationContext, EVENT_SOURCE_STATE_CHANGED);
|
||||
|
||||
verify(mSafetyCenterManagerWrapper)
|
||||
.setSafetySourceData(
|
||||
any(), eq(FingerprintSafetySource.SAFETY_SOURCE_ID), eq(null), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_whenSafetyCenterIsEnabled_withoutFingerprint_setsNullData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
|
||||
@@ -141,6 +156,7 @@ public class FingerprintSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_setsDataForFingerprintSource() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -156,6 +172,7 @@ public class FingerprintSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_setsDataWithCorrectSafetyEvent() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -170,6 +187,7 @@ public class FingerprintSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
@DisableFlags(android.app.supervision.flags.Flags.FLAG_DEPRECATE_DPM_SUPERVISION_APIS)
|
||||
public void setSafetySourceData_withFingerprintNotEnrolled_whenDisabledByAdmin_setsData() {
|
||||
when(mDevicePolicyManager.getProfileOwnerOrDeviceOwnerSupervisionComponent(USER_HANDLE))
|
||||
@@ -189,6 +207,7 @@ public class FingerprintSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
@EnableFlags(android.app.supervision.flags.Flags.FLAG_DEPRECATE_DPM_SUPERVISION_APIS)
|
||||
public void setSafetySourceData_withFingerprintNotEnrolled_whenSupervisionIsOn_setsData() {
|
||||
when(mSupervisionManager.isSupervisionEnabledForUser(USER_ID)).thenReturn(true);
|
||||
@@ -207,6 +226,7 @@ public class FingerprintSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_withFingerprintNotEnrolled_whenNotDisabledByAdmin_setsData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -223,6 +243,7 @@ public class FingerprintSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
@DisableFlags(android.app.supervision.flags.Flags.FLAG_DEPRECATE_DPM_SUPERVISION_APIS)
|
||||
public void setSafetySourceData_withFingerprintsEnrolled_whenDisabledByAdmin_setsData() {
|
||||
int enrolledFingerprintsCount = 2;
|
||||
@@ -246,6 +267,7 @@ public class FingerprintSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
@EnableFlags(android.app.supervision.flags.Flags.FLAG_DEPRECATE_DPM_SUPERVISION_APIS)
|
||||
public void setSafetySourceData_withFingerprintsEnrolled_whenSupervisionIsOn_setsData() {
|
||||
int enrolledFingerprintsCount = 2;
|
||||
@@ -268,6 +290,7 @@ public class FingerprintSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_withFingerprintsEnrolled_whenNotDisabledByAdmin_setsData() {
|
||||
int enrolledFingerprintsCount = 2;
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
@@ -288,6 +311,7 @@ public class FingerprintSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_fingerprint_whenEnrolled_setsInfoSeverity() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -309,6 +333,7 @@ public class FingerprintSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void setSafetySourceData_fingerprint_whenNotEnrolled_setsUnspSeverity() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
|
@@ -33,8 +33,6 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.platform.test.annotations.RequiresFlagsDisabled;
|
||||
import android.platform.test.annotations.RequiresFlagsEnabled;
|
||||
import android.platform.test.flag.junit.CheckFlagsRule;
|
||||
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
@@ -45,7 +43,6 @@ import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.privatespace.PrivateSpaceSafetySource;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
|
||||
@@ -211,7 +208,6 @@ public class SafetySourceBroadcastReceiverTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void onReceive_onRefresh_withBiometricsSourceId_setsBiometricData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
Intent intent =
|
||||
@@ -231,7 +227,6 @@ public class SafetySourceBroadcastReceiverTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void onReceive_onRefresh_withFaceUnlockSourceId_setsFaceUnlockData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
Intent intent =
|
||||
@@ -251,7 +246,6 @@ public class SafetySourceBroadcastReceiverTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void onReceive_onRefresh_withFingerprintUnlockSourceId_setsFingerprintUnlockData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
Intent intent =
|
||||
@@ -332,14 +326,13 @@ public class SafetySourceBroadcastReceiverTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void onReceive_onBootCompleted_flagOn_sendsAllSafetySourcesData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
Intent intent = new Intent().setAction(Intent.ACTION_BOOT_COMPLETED);
|
||||
|
||||
new SafetySourceBroadcastReceiver().onReceive(mApplicationContext, intent);
|
||||
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
|
||||
verify(mSafetyCenterManagerWrapper, times(4))
|
||||
verify(mSafetyCenterManagerWrapper, times(5))
|
||||
.setSafetySourceData(any(), captor.capture(), any(), any());
|
||||
List<String> safetySourceIdList = captor.getAllValues();
|
||||
|
||||
@@ -347,6 +340,10 @@ public class SafetySourceBroadcastReceiverTest {
|
||||
safetySourceIdList.stream()
|
||||
.anyMatch(id -> id.equals(LockScreenSafetySource.SAFETY_SOURCE_ID)))
|
||||
.isTrue();
|
||||
assertThat(
|
||||
safetySourceIdList.stream()
|
||||
.anyMatch(id -> id.equals(BiometricsSafetySource.SAFETY_SOURCE_ID)))
|
||||
.isTrue();
|
||||
assertThat(
|
||||
safetySourceIdList.stream()
|
||||
.anyMatch(id -> id.equals(FaceSafetySource.SAFETY_SOURCE_ID)))
|
||||
@@ -362,31 +359,4 @@ public class SafetySourceBroadcastReceiverTest {
|
||||
id -> id.equals(PrivateSpaceSafetySource.SAFETY_SOURCE_ID)))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_BIOMETRICS_ONBOARDING_EDUCATION)
|
||||
public void onReceive_onBootCompleted_flagOff_sendsAllSafetySourcesData() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
Intent intent = new Intent().setAction(Intent.ACTION_BOOT_COMPLETED);
|
||||
|
||||
new SafetySourceBroadcastReceiver().onReceive(mApplicationContext, intent);
|
||||
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
|
||||
verify(mSafetyCenterManagerWrapper, times(3))
|
||||
.setSafetySourceData(any(), captor.capture(), any(), any());
|
||||
List<String> safetySourceIdList = captor.getAllValues();
|
||||
|
||||
assertThat(
|
||||
safetySourceIdList.stream()
|
||||
.anyMatch(id -> id.equals(LockScreenSafetySource.SAFETY_SOURCE_ID)))
|
||||
.isTrue();
|
||||
assertThat(
|
||||
safetySourceIdList.stream()
|
||||
.anyMatch(id -> id.equals(BiometricsSafetySource.SAFETY_SOURCE_ID)))
|
||||
.isTrue();
|
||||
assertThat(
|
||||
safetySourceIdList.stream()
|
||||
.anyMatch(
|
||||
id -> id.equals(PrivateSpaceSafetySource.SAFETY_SOURCE_ID)))
|
||||
.isTrue();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user