Merge "Use new severity levels and builders" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
d5d6846846
@@ -25,6 +25,7 @@ import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.safetycenter.SafetyEvent;
|
||||
import android.safetycenter.SafetySourceData;
|
||||
import android.safetycenter.SafetySourceSeverity;
|
||||
import android.safetycenter.SafetySourceStatus;
|
||||
|
||||
import com.android.settings.R;
|
||||
@@ -40,7 +41,8 @@ public final class BiometricsSafetySource {
|
||||
|
||||
public static final String SAFETY_SOURCE_ID = "Biometrics";
|
||||
|
||||
private BiometricsSafetySource() {}
|
||||
private BiometricsSafetySource() {
|
||||
}
|
||||
|
||||
/** Sets biometric safety data for Safety Center. */
|
||||
public static void setSafetySourceData(Context context, SafetyEvent safetyEvent) {
|
||||
@@ -119,12 +121,12 @@ public final class BiometricsSafetySource {
|
||||
private static void setBiometricSafetySourceData(Context context, String title, String summary,
|
||||
Intent clickIntent, boolean enabled, boolean hasEnrolled, SafetyEvent safetyEvent) {
|
||||
final PendingIntent pendingIntent = createPendingIntent(context, clickIntent);
|
||||
final int statusLevel =
|
||||
enabled && hasEnrolled ? SafetySourceStatus.STATUS_LEVEL_OK
|
||||
: SafetySourceStatus.STATUS_LEVEL_NONE;
|
||||
final int severityLevel =
|
||||
enabled && hasEnrolled ? SafetySourceSeverity.LEVEL_INFORMATION
|
||||
: SafetySourceSeverity.LEVEL_UNSPECIFIED;
|
||||
|
||||
final SafetySourceStatus status = new SafetySourceStatus.Builder(
|
||||
title, summary, statusLevel, pendingIntent).setEnabled(enabled).build();
|
||||
final SafetySourceStatus status = new SafetySourceStatus.Builder(title, summary,
|
||||
severityLevel).setPendingIntent(pendingIntent).setEnabled(enabled).build();
|
||||
final SafetySourceData safetySourceData =
|
||||
new SafetySourceData.Builder().setStatus(status).build();
|
||||
|
||||
|
@@ -26,6 +26,7 @@ import android.os.UserHandle;
|
||||
import android.safetycenter.SafetyEvent;
|
||||
import android.safetycenter.SafetySourceData;
|
||||
import android.safetycenter.SafetySourceIssue;
|
||||
import android.safetycenter.SafetySourceSeverity;
|
||||
import android.safetycenter.SafetySourceStatus;
|
||||
import android.safetycenter.SafetySourceStatus.IconAction;
|
||||
|
||||
@@ -64,20 +65,26 @@ public final class LockScreenSafetySource {
|
||||
screenLockPreferenceDetailsUtils.getLaunchChooseLockGenericFragmentIntent());
|
||||
final IconAction gearMenuIconAction = createGearMenuIconAction(context,
|
||||
screenLockPreferenceDetailsUtils);
|
||||
final boolean enabled =
|
||||
!screenLockPreferenceDetailsUtils.isPasswordQualityManaged(userId, admin);
|
||||
final boolean isLockPatternSecure = screenLockPreferenceDetailsUtils.isLockPatternSecure();
|
||||
final int severityLevel = enabled
|
||||
? isLockPatternSecure
|
||||
? SafetySourceSeverity.LEVEL_INFORMATION
|
||||
: SafetySourceSeverity.LEVEL_RECOMMENDATION
|
||||
: SafetySourceSeverity.LEVEL_UNSPECIFIED;
|
||||
|
||||
|
||||
final SafetySourceStatus status = new SafetySourceStatus.Builder(
|
||||
context.getString(R.string.unlock_set_unlock_launch_picker_title),
|
||||
screenLockPreferenceDetailsUtils.getSummary(UserHandle.myUserId()),
|
||||
screenLockPreferenceDetailsUtils.isLockPatternSecure()
|
||||
? SafetySourceStatus.STATUS_LEVEL_OK
|
||||
: SafetySourceStatus.STATUS_LEVEL_RECOMMENDATION,
|
||||
pendingIntent)
|
||||
.setEnabled(
|
||||
!screenLockPreferenceDetailsUtils.isPasswordQualityManaged(userId, admin))
|
||||
severityLevel)
|
||||
.setPendingIntent(pendingIntent)
|
||||
.setEnabled(enabled)
|
||||
.setIconAction(gearMenuIconAction).build();
|
||||
final SafetySourceData.Builder safetySourceDataBuilder =
|
||||
new SafetySourceData.Builder().setStatus(status);
|
||||
if (!screenLockPreferenceDetailsUtils.isLockPatternSecure()) {
|
||||
if (enabled && !isLockPatternSecure) {
|
||||
safetySourceDataBuilder.addIssue(createNoScreenLockIssue(context, pendingIntent));
|
||||
}
|
||||
final SafetySourceData safetySourceData = safetySourceDataBuilder.build();
|
||||
@@ -130,7 +137,7 @@ public final class LockScreenSafetySource {
|
||||
NO_SCREEN_LOCK_ISSUE_ID,
|
||||
context.getString(R.string.no_screen_lock_issue_title),
|
||||
context.getString(R.string.no_screen_lock_issue_summary),
|
||||
SafetySourceIssue.SEVERITY_LEVEL_RECOMMENDATION,
|
||||
SafetySourceSeverity.LEVEL_RECOMMENDATION,
|
||||
NO_SCREEN_LOCK_ISSUE_TYPE_ID)
|
||||
.setIssueCategory(SafetySourceIssue.ISSUE_CATEGORY_DEVICE)
|
||||
.addAction(action).build();
|
||||
|
@@ -40,6 +40,7 @@ import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.os.UserHandle;
|
||||
import android.safetycenter.SafetyEvent;
|
||||
import android.safetycenter.SafetySourceData;
|
||||
import android.safetycenter.SafetySourceSeverity;
|
||||
import android.safetycenter.SafetySourceStatus;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
@@ -427,7 +428,7 @@ public class BiometricsSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setSafetySourceData_faceAndFingerprint_whenFaceEnrolled_setsOkStatus() {
|
||||
public void setSafetySourceData_faceAndFingerprint_whenFaceEnrolled_setsInfoSeverity() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -440,12 +441,12 @@ public class BiometricsSafetySourceTest {
|
||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
||||
any(), eq(BiometricsSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
|
||||
SafetySourceStatus safetySourceStatus = captor.getValue().getStatus();
|
||||
assertThat(safetySourceStatus.getStatusLevel())
|
||||
.isEqualTo(SafetySourceStatus.STATUS_LEVEL_OK);
|
||||
assertThat(safetySourceStatus.getSeverityLevel())
|
||||
.isEqualTo(SafetySourceSeverity.LEVEL_INFORMATION);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setSafetySourceData_faceAndFingerprint_whenFingerprintEnrolled_setsOkStatus() {
|
||||
public void setSafetySourceData_faceAndFingerprint_whenFingerprintEnrolled_setsInfoSeverity() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -458,12 +459,12 @@ public class BiometricsSafetySourceTest {
|
||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
||||
any(), eq(BiometricsSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
|
||||
SafetySourceStatus safetySourceStatus = captor.getValue().getStatus();
|
||||
assertThat(safetySourceStatus.getStatusLevel())
|
||||
.isEqualTo(SafetySourceStatus.STATUS_LEVEL_OK);
|
||||
assertThat(safetySourceStatus.getSeverityLevel())
|
||||
.isEqualTo(SafetySourceSeverity.LEVEL_INFORMATION);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setSafetySourceData_faceAndFingerprint_whenNotEnrolled_setsNoneStatus() {
|
||||
public void setSafetySourceData_faceAndFingerprint_whenNotEnrolled_setsUnspSeverity() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -476,12 +477,12 @@ public class BiometricsSafetySourceTest {
|
||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
||||
any(), eq(BiometricsSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
|
||||
SafetySourceStatus safetySourceStatus = captor.getValue().getStatus();
|
||||
assertThat(safetySourceStatus.getStatusLevel())
|
||||
.isEqualTo(SafetySourceStatus.STATUS_LEVEL_NONE);
|
||||
assertThat(safetySourceStatus.getSeverityLevel())
|
||||
.isEqualTo(SafetySourceSeverity.LEVEL_UNSPECIFIED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setSafetySourceData_fingerprint_whenEnrolled_setsOKStatus() {
|
||||
public void setSafetySourceData_fingerprint_whenEnrolled_setsInfoSeverity() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
when(mFaceManager.isHardwareDetected()).thenReturn(false);
|
||||
@@ -493,12 +494,12 @@ public class BiometricsSafetySourceTest {
|
||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
||||
any(), eq(BiometricsSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
|
||||
SafetySourceStatus safetySourceStatus = captor.getValue().getStatus();
|
||||
assertThat(safetySourceStatus.getStatusLevel())
|
||||
.isEqualTo(SafetySourceStatus.STATUS_LEVEL_OK);
|
||||
assertThat(safetySourceStatus.getSeverityLevel())
|
||||
.isEqualTo(SafetySourceSeverity.LEVEL_INFORMATION);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setSafetySourceData_fingerprint_whenNotEnrolled_setsNoneStatus() {
|
||||
public void setSafetySourceData_fingerprint_whenNotEnrolled_setsUnspSeverity() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
when(mFaceManager.isHardwareDetected()).thenReturn(false);
|
||||
@@ -510,12 +511,12 @@ public class BiometricsSafetySourceTest {
|
||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
||||
any(), eq(BiometricsSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
|
||||
SafetySourceStatus safetySourceStatus = captor.getValue().getStatus();
|
||||
assertThat(safetySourceStatus.getStatusLevel())
|
||||
.isEqualTo(SafetySourceStatus.STATUS_LEVEL_NONE);
|
||||
assertThat(safetySourceStatus.getSeverityLevel())
|
||||
.isEqualTo(SafetySourceSeverity.LEVEL_UNSPECIFIED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setSafetySourceData_face_whenEnrolled_setsOKStatus() {
|
||||
public void setSafetySourceData_face_whenEnrolled_setsInfoSeverity() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
|
||||
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -527,12 +528,12 @@ public class BiometricsSafetySourceTest {
|
||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
||||
any(), eq(BiometricsSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
|
||||
SafetySourceStatus safetySourceStatus = captor.getValue().getStatus();
|
||||
assertThat(safetySourceStatus.getStatusLevel())
|
||||
.isEqualTo(SafetySourceStatus.STATUS_LEVEL_OK);
|
||||
assertThat(safetySourceStatus.getSeverityLevel())
|
||||
.isEqualTo(SafetySourceSeverity.LEVEL_INFORMATION);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setSafetySourceData_face_whenNotEnrolled_setsNoneStatus() {
|
||||
public void setSafetySourceData_face_whenNotEnrolled_setsUnspSeverity() {
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
|
||||
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||
@@ -544,8 +545,8 @@ public class BiometricsSafetySourceTest {
|
||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
||||
any(), eq(BiometricsSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
|
||||
SafetySourceStatus safetySourceStatus = captor.getValue().getStatus();
|
||||
assertThat(safetySourceStatus.getStatusLevel())
|
||||
.isEqualTo(SafetySourceStatus.STATUS_LEVEL_NONE);
|
||||
assertThat(safetySourceStatus.getSeverityLevel())
|
||||
.isEqualTo(SafetySourceSeverity.LEVEL_UNSPECIFIED);
|
||||
}
|
||||
|
||||
private void assertSafetySourceDisabledDataSetWithSingularSummary(String expectedTitleResName,
|
||||
@@ -604,8 +605,8 @@ public class BiometricsSafetySourceTest {
|
||||
assertThat(safetySourceStatus.getTitle().toString()).isEqualTo(expectedTitle);
|
||||
assertThat(safetySourceStatus.getSummary().toString()).isEqualTo(expectedSummary);
|
||||
assertThat(safetySourceStatus.isEnabled()).isFalse();
|
||||
assertThat(safetySourceStatus.getStatusLevel())
|
||||
.isEqualTo(SafetySourceStatus.STATUS_LEVEL_NONE);
|
||||
assertThat(safetySourceStatus.getSeverityLevel())
|
||||
.isEqualTo(SafetySourceSeverity.LEVEL_UNSPECIFIED);
|
||||
|
||||
final Intent clickIntent = safetySourceStatus.getPendingIntent().getIntent();
|
||||
assertThat(clickIntent).isNotNull();
|
||||
|
@@ -32,6 +32,7 @@ import android.content.Intent;
|
||||
import android.safetycenter.SafetyEvent;
|
||||
import android.safetycenter.SafetySourceData;
|
||||
import android.safetycenter.SafetySourceIssue;
|
||||
import android.safetycenter.SafetySourceSeverity;
|
||||
import android.safetycenter.SafetySourceStatus;
|
||||
import android.safetycenter.SafetySourceStatus.IconAction;
|
||||
|
||||
@@ -161,10 +162,12 @@ public class LockScreenSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setSafetySourceData_whenLockPatternIsSecure_setStatusLevelOk() {
|
||||
public void setSafetySourceData_whenPwdQualIsNotMan_whenLockPattIsSec_setStatusLevelInfo() {
|
||||
whenScreenLockIsEnabled();
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mScreenLockPreferenceDetailsUtils.isLockPatternSecure()).thenReturn(true);
|
||||
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
||||
.thenReturn(false);
|
||||
|
||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||
@@ -175,15 +178,17 @@ public class LockScreenSafetySourceTest {
|
||||
SafetySourceData safetySourceData = captor.getValue();
|
||||
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
|
||||
|
||||
assertThat(safetySourceStatus.getStatusLevel())
|
||||
.isEqualTo(SafetySourceStatus.STATUS_LEVEL_OK);
|
||||
assertThat(safetySourceStatus.getSeverityLevel())
|
||||
.isEqualTo(SafetySourceSeverity.LEVEL_INFORMATION);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setSafetySourceData_whenLockPatternIsNotSecure_setStatusLevelRecommendation() {
|
||||
public void setSafetySourceData_whenPwdQualIsNotMan_whenLockPattIsNotSec_setStatusLevelRec() {
|
||||
whenScreenLockIsEnabled();
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mScreenLockPreferenceDetailsUtils.isLockPatternSecure()).thenReturn(false);
|
||||
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
||||
.thenReturn(false);
|
||||
|
||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||
@@ -194,15 +199,59 @@ public class LockScreenSafetySourceTest {
|
||||
SafetySourceData safetySourceData = captor.getValue();
|
||||
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
|
||||
|
||||
assertThat(safetySourceStatus.getStatusLevel())
|
||||
.isEqualTo(SafetySourceStatus.STATUS_LEVEL_RECOMMENDATION);
|
||||
assertThat(safetySourceStatus.getSeverityLevel())
|
||||
.isEqualTo(SafetySourceSeverity.LEVEL_RECOMMENDATION);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setSafetySourceData_whenLockPatternIsSecure_doesNotSetIssues() {
|
||||
public void setSafetySourceData_whenPwdQualIsMan_whenLockPattIsSec_setStatusLevelUnsp() {
|
||||
whenScreenLockIsEnabled();
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mScreenLockPreferenceDetailsUtils.isLockPatternSecure()).thenReturn(true);
|
||||
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
||||
.thenReturn(true);
|
||||
|
||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||
|
||||
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
||||
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
|
||||
SafetySourceData safetySourceData = captor.getValue();
|
||||
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
|
||||
|
||||
assertThat(safetySourceStatus.getSeverityLevel())
|
||||
.isEqualTo(SafetySourceSeverity.LEVEL_UNSPECIFIED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setSafetySourceData_whenPwdQualIsMan_whenLockPattIsNotSec_setStatusLevelUnsp() {
|
||||
whenScreenLockIsEnabled();
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mScreenLockPreferenceDetailsUtils.isLockPatternSecure()).thenReturn(false);
|
||||
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
||||
.thenReturn(true);
|
||||
|
||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||
|
||||
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
||||
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
|
||||
SafetySourceData safetySourceData = captor.getValue();
|
||||
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
|
||||
|
||||
assertThat(safetySourceStatus.getSeverityLevel())
|
||||
.isEqualTo(SafetySourceSeverity.LEVEL_UNSPECIFIED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setSafetySourceData_whenPwdQualIsNotMan_whenLockPattIsSec_doesNotSetIssues() {
|
||||
whenScreenLockIsEnabled();
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mScreenLockPreferenceDetailsUtils.isLockPatternSecure()).thenReturn(true);
|
||||
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
||||
.thenReturn(false);
|
||||
|
||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||
@@ -216,10 +265,12 @@ public class LockScreenSafetySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setSafetySourceData_whenLockPatternIsNotSecure_setsIssue() {
|
||||
public void setSafetySourceData_whenPwdQualIsNotMan_whenLockPattIsNotSec_setsIssue() {
|
||||
whenScreenLockIsEnabled();
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mScreenLockPreferenceDetailsUtils.isLockPatternSecure()).thenReturn(false);
|
||||
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
||||
.thenReturn(false);
|
||||
|
||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||
@@ -238,8 +289,7 @@ public class LockScreenSafetySourceTest {
|
||||
assertThat(issue.getSummary().toString()).isEqualTo(
|
||||
ResourcesUtils.getResourcesString(mApplicationContext,
|
||||
"no_screen_lock_issue_summary"));
|
||||
assertThat(issue.getSeverityLevel()).isEqualTo(
|
||||
SafetySourceIssue.SEVERITY_LEVEL_RECOMMENDATION);
|
||||
assertThat(issue.getSeverityLevel()).isEqualTo(SafetySourceSeverity.LEVEL_RECOMMENDATION);
|
||||
assertThat(issue.getIssueTypeId()).isEqualTo(
|
||||
LockScreenSafetySource.NO_SCREEN_LOCK_ISSUE_TYPE_ID);
|
||||
assertThat(issue.getIssueCategory()).isEqualTo(SafetySourceIssue.ISSUE_CATEGORY_DEVICE);
|
||||
@@ -253,6 +303,44 @@ public class LockScreenSafetySourceTest {
|
||||
.isEqualTo(FAKE_ACTION_CHOOSE_LOCK_GENERIC_FRAGMENT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setSafetySourceData_whenPwdQualIsMan_whenLockPattIsSec_doesNotSetIssues() {
|
||||
whenScreenLockIsEnabled();
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mScreenLockPreferenceDetailsUtils.isLockPatternSecure()).thenReturn(true);
|
||||
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
||||
.thenReturn(true);
|
||||
|
||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||
|
||||
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
||||
any(), any(), captor.capture(), any());
|
||||
SafetySourceData safetySourceData = captor.getValue();
|
||||
|
||||
assertThat(safetySourceData.getIssues()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setSafetySourceData_whenPwdQualIsMan_whenLockPattIsNotSec_doesNotSetIssues() {
|
||||
whenScreenLockIsEnabled();
|
||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||
when(mScreenLockPreferenceDetailsUtils.isLockPatternSecure()).thenReturn(false);
|
||||
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
||||
.thenReturn(true);
|
||||
|
||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||
|
||||
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
||||
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
|
||||
SafetySourceData safetySourceData = captor.getValue();
|
||||
|
||||
assertThat(safetySourceData.getIssues()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setSafetySourceData_whenPasswordQualityIsManaged_setDisabled() {
|
||||
whenScreenLockIsEnabled();
|
||||
|
Reference in New Issue
Block a user