Handle "Blocked by your IT admin" better.
Instead of allowing the user to click the entry, make the entry non-clickable and mention that it's blocked by IT admin. Bug: 297965563 Test: atest LockScreenSafetySourceTest Change-Id: I821d661dd924358a5e7b033118b63e104ade9eaf
This commit is contained in:
@@ -46,11 +46,11 @@ public final class LockScreenSafetySource {
|
|||||||
private static final int REQUEST_CODE_SCREEN_LOCK = 1;
|
private static final int REQUEST_CODE_SCREEN_LOCK = 1;
|
||||||
private static final int REQUEST_CODE_SCREEN_LOCK_SETTINGS = 2;
|
private static final int REQUEST_CODE_SCREEN_LOCK_SETTINGS = 2;
|
||||||
|
|
||||||
private LockScreenSafetySource() {
|
private LockScreenSafetySource() {}
|
||||||
}
|
|
||||||
|
|
||||||
/** Sets lock screen safety data for Safety Center. */
|
/** Sets lock screen safety data for Safety Center. */
|
||||||
public static void setSafetySourceData(Context context,
|
public static void setSafetySourceData(
|
||||||
|
Context context,
|
||||||
ScreenLockPreferenceDetailsUtils screenLockPreferenceDetailsUtils,
|
ScreenLockPreferenceDetailsUtils screenLockPreferenceDetailsUtils,
|
||||||
SafetyEvent safetyEvent) {
|
SafetyEvent safetyEvent) {
|
||||||
if (!SafetyCenterManagerWrapper.get().isEnabled(context)) {
|
if (!SafetyCenterManagerWrapper.get().isEnabled(context)) {
|
||||||
@@ -63,59 +63,61 @@ public final class LockScreenSafetySource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!screenLockPreferenceDetailsUtils.isAvailable()) {
|
if (!screenLockPreferenceDetailsUtils.isAvailable()) {
|
||||||
SafetyCenterManagerWrapper.get().setSafetySourceData(
|
SafetyCenterManagerWrapper.get()
|
||||||
context,
|
.setSafetySourceData(
|
||||||
SAFETY_SOURCE_ID,
|
context, SAFETY_SOURCE_ID, /* safetySourceData= */ null, safetyEvent);
|
||||||
/* safetySourceData= */ null,
|
|
||||||
safetyEvent
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int userId = UserHandle.myUserId();
|
final int userId = UserHandle.myUserId();
|
||||||
final RestrictedLockUtils.EnforcedAdmin admin = RestrictedLockUtilsInternal
|
final RestrictedLockUtils.EnforcedAdmin admin =
|
||||||
.checkIfPasswordQualityIsSet(context, userId);
|
RestrictedLockUtilsInternal.checkIfPasswordQualityIsSet(context, userId);
|
||||||
final PendingIntent pendingIntent = createPendingIntent(context,
|
final PendingIntent pendingIntent =
|
||||||
screenLockPreferenceDetailsUtils.getLaunchChooseLockGenericFragmentIntent(
|
createPendingIntent(
|
||||||
SettingsEnums.SAFETY_CENTER), REQUEST_CODE_SCREEN_LOCK);
|
context,
|
||||||
final IconAction gearMenuIconAction = createGearMenuIconAction(context,
|
screenLockPreferenceDetailsUtils.getLaunchChooseLockGenericFragmentIntent(
|
||||||
screenLockPreferenceDetailsUtils);
|
SettingsEnums.SAFETY_CENTER),
|
||||||
final boolean enabled =
|
REQUEST_CODE_SCREEN_LOCK);
|
||||||
|
final IconAction gearMenuIconAction =
|
||||||
|
createGearMenuIconAction(context, screenLockPreferenceDetailsUtils);
|
||||||
|
final boolean lockScreenAllowedByAdmin =
|
||||||
!screenLockPreferenceDetailsUtils.isPasswordQualityManaged(userId, admin);
|
!screenLockPreferenceDetailsUtils.isPasswordQualityManaged(userId, admin);
|
||||||
final boolean isLockPatternSecure = screenLockPreferenceDetailsUtils.isLockPatternSecure();
|
final boolean isLockPatternSecure = screenLockPreferenceDetailsUtils.isLockPatternSecure();
|
||||||
final int severityLevel = enabled
|
final int severityLevel =
|
||||||
? isLockPatternSecure
|
lockScreenAllowedByAdmin
|
||||||
? SafetySourceData.SEVERITY_LEVEL_INFORMATION
|
? isLockPatternSecure
|
||||||
: SafetySourceData.SEVERITY_LEVEL_RECOMMENDATION
|
? SafetySourceData.SEVERITY_LEVEL_INFORMATION
|
||||||
: SafetySourceData.SEVERITY_LEVEL_UNSPECIFIED;
|
: SafetySourceData.SEVERITY_LEVEL_RECOMMENDATION
|
||||||
|
: SafetySourceData.SEVERITY_LEVEL_UNSPECIFIED;
|
||||||
|
|
||||||
|
final SafetySourceStatus status =
|
||||||
final SafetySourceStatus status = new SafetySourceStatus.Builder(
|
new SafetySourceStatus.Builder(
|
||||||
context.getString(R.string.unlock_set_unlock_launch_picker_title),
|
context.getString(R.string.unlock_set_unlock_launch_picker_title),
|
||||||
screenLockPreferenceDetailsUtils.getSummary(UserHandle.myUserId()),
|
lockScreenAllowedByAdmin
|
||||||
severityLevel)
|
? screenLockPreferenceDetailsUtils.getSummary(
|
||||||
.setPendingIntent(pendingIntent)
|
UserHandle.myUserId())
|
||||||
.setEnabled(enabled)
|
: context.getString(R.string.disabled_by_policy_title),
|
||||||
.setIconAction(gearMenuIconAction).build();
|
severityLevel)
|
||||||
|
.setPendingIntent(lockScreenAllowedByAdmin ? pendingIntent : null)
|
||||||
|
.setEnabled(lockScreenAllowedByAdmin)
|
||||||
|
.setIconAction(lockScreenAllowedByAdmin ? gearMenuIconAction : null)
|
||||||
|
.build();
|
||||||
final SafetySourceData.Builder safetySourceDataBuilder =
|
final SafetySourceData.Builder safetySourceDataBuilder =
|
||||||
new SafetySourceData.Builder().setStatus(status);
|
new SafetySourceData.Builder().setStatus(status);
|
||||||
if (enabled && !isLockPatternSecure) {
|
if (lockScreenAllowedByAdmin && !isLockPatternSecure) {
|
||||||
safetySourceDataBuilder.addIssue(createNoScreenLockIssue(context, pendingIntent));
|
safetySourceDataBuilder.addIssue(createNoScreenLockIssue(context, pendingIntent));
|
||||||
}
|
}
|
||||||
final SafetySourceData safetySourceData = safetySourceDataBuilder.build();
|
final SafetySourceData safetySourceData = safetySourceDataBuilder.build();
|
||||||
|
|
||||||
SafetyCenterManagerWrapper.get().setSafetySourceData(
|
SafetyCenterManagerWrapper.get()
|
||||||
context,
|
.setSafetySourceData(context, SAFETY_SOURCE_ID, safetySourceData, safetyEvent);
|
||||||
SAFETY_SOURCE_ID,
|
|
||||||
safetySourceData,
|
|
||||||
safetyEvent
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Notifies Safety Center of a change in lock screen settings. */
|
/** Notifies Safety Center of a change in lock screen settings. */
|
||||||
public static void onLockScreenChange(Context context) {
|
public static void onLockScreenChange(Context context) {
|
||||||
setSafetySourceData(
|
setSafetySourceData(
|
||||||
context, new ScreenLockPreferenceDetailsUtils(context),
|
context,
|
||||||
|
new ScreenLockPreferenceDetailsUtils(context),
|
||||||
new SafetyEvent.Builder(SAFETY_EVENT_TYPE_SOURCE_STATE_CHANGED).build());
|
new SafetyEvent.Builder(SAFETY_EVENT_TYPE_SOURCE_STATE_CHANGED).build());
|
||||||
|
|
||||||
// Also send refreshed safety center data for biometrics, since changing lockscreen settings
|
// Also send refreshed safety center data for biometrics, since changing lockscreen settings
|
||||||
@@ -123,45 +125,45 @@ public final class LockScreenSafetySource {
|
|||||||
BiometricsSafetySource.onBiometricsChanged(context);
|
BiometricsSafetySource.onBiometricsChanged(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IconAction createGearMenuIconAction(Context context,
|
private static IconAction createGearMenuIconAction(
|
||||||
ScreenLockPreferenceDetailsUtils screenLockPreferenceDetailsUtils) {
|
Context context, ScreenLockPreferenceDetailsUtils screenLockPreferenceDetailsUtils) {
|
||||||
return screenLockPreferenceDetailsUtils.shouldShowGearMenu() ? new IconAction(
|
return screenLockPreferenceDetailsUtils.shouldShowGearMenu()
|
||||||
IconAction.ICON_TYPE_GEAR,
|
? new IconAction(
|
||||||
createPendingIntent(context,
|
IconAction.ICON_TYPE_GEAR,
|
||||||
screenLockPreferenceDetailsUtils.getLaunchScreenLockSettingsIntent(
|
createPendingIntent(
|
||||||
SettingsEnums.SAFETY_CENTER),
|
context,
|
||||||
REQUEST_CODE_SCREEN_LOCK_SETTINGS))
|
screenLockPreferenceDetailsUtils.getLaunchScreenLockSettingsIntent(
|
||||||
|
SettingsEnums.SAFETY_CENTER),
|
||||||
|
REQUEST_CODE_SCREEN_LOCK_SETTINGS))
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PendingIntent createPendingIntent(Context context, Intent intent,
|
private static PendingIntent createPendingIntent(
|
||||||
int requestCode) {
|
Context context, Intent intent, int requestCode) {
|
||||||
return PendingIntent
|
return PendingIntent.getActivity(
|
||||||
.getActivity(
|
context, requestCode, intent, PendingIntent.FLAG_IMMUTABLE);
|
||||||
context,
|
|
||||||
requestCode,
|
|
||||||
intent,
|
|
||||||
PendingIntent.FLAG_IMMUTABLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SafetySourceIssue createNoScreenLockIssue(Context context,
|
private static SafetySourceIssue createNoScreenLockIssue(
|
||||||
PendingIntent pendingIntent) {
|
Context context, PendingIntent pendingIntent) {
|
||||||
final SafetySourceIssue.Action action = new SafetySourceIssue.Action.Builder(
|
final SafetySourceIssue.Action action =
|
||||||
SET_SCREEN_LOCK_ACTION_ID,
|
new SafetySourceIssue.Action.Builder(
|
||||||
context.getString(R.string.no_screen_lock_issue_action_label),
|
SET_SCREEN_LOCK_ACTION_ID,
|
||||||
pendingIntent).build();
|
context.getString(R.string.no_screen_lock_issue_action_label),
|
||||||
|
pendingIntent)
|
||||||
|
.build();
|
||||||
// Custom notification deliberately has zero actions
|
// Custom notification deliberately has zero actions
|
||||||
final SafetySourceIssue.Notification customNotification =
|
final SafetySourceIssue.Notification customNotification =
|
||||||
new SafetySourceIssue.Notification.Builder(
|
new SafetySourceIssue.Notification.Builder(
|
||||||
context.getString(R.string.no_screen_lock_issue_notification_title),
|
context.getString(R.string.no_screen_lock_issue_notification_title),
|
||||||
context.getString(R.string.no_screen_lock_issue_notification_text))
|
context.getString(R.string.no_screen_lock_issue_notification_text))
|
||||||
.build();
|
.build();
|
||||||
return new SafetySourceIssue.Builder(
|
return new SafetySourceIssue.Builder(
|
||||||
NO_SCREEN_LOCK_ISSUE_ID,
|
NO_SCREEN_LOCK_ISSUE_ID,
|
||||||
context.getString(R.string.no_screen_lock_issue_title),
|
context.getString(R.string.no_screen_lock_issue_title),
|
||||||
context.getString(R.string.no_screen_lock_issue_summary),
|
context.getString(R.string.no_screen_lock_issue_summary),
|
||||||
SafetySourceData.SEVERITY_LEVEL_RECOMMENDATION,
|
SafetySourceData.SEVERITY_LEVEL_RECOMMENDATION,
|
||||||
NO_SCREEN_LOCK_ISSUE_TYPE_ID)
|
NO_SCREEN_LOCK_ISSUE_TYPE_ID)
|
||||||
.setIssueCategory(SafetySourceIssue.ISSUE_CATEGORY_DEVICE)
|
.setIssueCategory(SafetySourceIssue.ISSUE_CATEGORY_DEVICE)
|
||||||
.addAction(action)
|
.addAction(action)
|
||||||
.setIssueActionability(SafetySourceIssue.ISSUE_ACTIONABILITY_MANUAL)
|
.setIssueActionability(SafetySourceIssue.ISSUE_ACTIONABILITY_MANUAL)
|
||||||
|
@@ -64,14 +64,11 @@ public class LockScreenSafetySourceTest {
|
|||||||
|
|
||||||
private Context mApplicationContext;
|
private Context mApplicationContext;
|
||||||
|
|
||||||
@Mock
|
@Mock private SafetyCenterManagerWrapper mSafetyCenterManagerWrapper;
|
||||||
private SafetyCenterManagerWrapper mSafetyCenterManagerWrapper;
|
|
||||||
|
|
||||||
@Mock
|
@Mock private ScreenLockPreferenceDetailsUtils mScreenLockPreferenceDetailsUtils;
|
||||||
private ScreenLockPreferenceDetailsUtils mScreenLockPreferenceDetailsUtils;
|
|
||||||
|
|
||||||
@Mock
|
@Mock private LockPatternUtils mLockPatternUtils;
|
||||||
private LockPatternUtils mLockPatternUtils;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
@@ -94,11 +91,11 @@ public class LockScreenSafetySourceTest {
|
|||||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(false);
|
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(false);
|
||||||
when(mScreenLockPreferenceDetailsUtils.isAvailable()).thenReturn(true);
|
when(mScreenLockPreferenceDetailsUtils.isAvailable()).thenReturn(true);
|
||||||
|
|
||||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
LockScreenSafetySource.setSafetySourceData(
|
||||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
mApplicationContext, mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||||
|
|
||||||
verify(mSafetyCenterManagerWrapper, never()).setSafetySourceData(
|
verify(mSafetyCenterManagerWrapper, never())
|
||||||
any(), any(), any(), any());
|
.setSafetySourceData(any(), any(), any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -106,11 +103,12 @@ public class LockScreenSafetySourceTest {
|
|||||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||||
when(mScreenLockPreferenceDetailsUtils.isAvailable()).thenReturn(false);
|
when(mScreenLockPreferenceDetailsUtils.isAvailable()).thenReturn(false);
|
||||||
|
|
||||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
LockScreenSafetySource.setSafetySourceData(
|
||||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
mApplicationContext, mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||||
|
|
||||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
verify(mSafetyCenterManagerWrapper)
|
||||||
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), eq(null), any());
|
.setSafetySourceData(
|
||||||
|
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), eq(null), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -118,11 +116,12 @@ public class LockScreenSafetySourceTest {
|
|||||||
whenScreenLockIsEnabled();
|
whenScreenLockIsEnabled();
|
||||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||||
|
|
||||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
LockScreenSafetySource.setSafetySourceData(
|
||||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
mApplicationContext, mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||||
|
|
||||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
verify(mSafetyCenterManagerWrapper)
|
||||||
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), any(), any());
|
.setSafetySourceData(
|
||||||
|
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -130,11 +129,11 @@ public class LockScreenSafetySourceTest {
|
|||||||
whenScreenLockIsEnabled();
|
whenScreenLockIsEnabled();
|
||||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||||
|
|
||||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
LockScreenSafetySource.setSafetySourceData(
|
||||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
mApplicationContext, mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||||
|
|
||||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
verify(mSafetyCenterManagerWrapper)
|
||||||
any(), any(), any(), eq(EVENT_SOURCE_STATE_CHANGED));
|
.setSafetySourceData(any(), any(), any(), eq(EVENT_SOURCE_STATE_CHANGED));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -142,26 +141,28 @@ public class LockScreenSafetySourceTest {
|
|||||||
whenScreenLockIsEnabled();
|
whenScreenLockIsEnabled();
|
||||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||||
|
|
||||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
LockScreenSafetySource.setSafetySourceData(
|
||||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
mApplicationContext, mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||||
|
|
||||||
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
||||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
verify(mSafetyCenterManagerWrapper)
|
||||||
any(), any(), captor.capture(), any());
|
.setSafetySourceData(any(), any(), captor.capture(), any());
|
||||||
SafetySourceData safetySourceData = captor.getValue();
|
SafetySourceData safetySourceData = captor.getValue();
|
||||||
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
|
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
|
||||||
|
|
||||||
assertThat(safetySourceStatus.getTitle().toString())
|
assertThat(safetySourceStatus.getTitle().toString())
|
||||||
.isEqualTo(ResourcesUtils.getResourcesString(
|
.isEqualTo(
|
||||||
mApplicationContext,
|
ResourcesUtils.getResourcesString(
|
||||||
"unlock_set_unlock_launch_picker_title"));
|
mApplicationContext, "unlock_set_unlock_launch_picker_title"));
|
||||||
assertThat(safetySourceStatus.getSummary().toString())
|
assertThat(safetySourceStatus.getSummary().toString()).isEqualTo(SUMMARY);
|
||||||
.isEqualTo(SUMMARY);
|
|
||||||
assertThat(safetySourceStatus.getPendingIntent().getIntent()).isNotNull();
|
assertThat(safetySourceStatus.getPendingIntent().getIntent()).isNotNull();
|
||||||
assertThat(safetySourceStatus.getPendingIntent().getIntent().getAction())
|
assertThat(safetySourceStatus.getPendingIntent().getIntent().getAction())
|
||||||
.isEqualTo(FAKE_ACTION_OPEN_SUB_SETTING);
|
.isEqualTo(FAKE_ACTION_OPEN_SUB_SETTING);
|
||||||
assertThat(
|
assertThat(
|
||||||
safetySourceStatus.getPendingIntent().getIntent().getStringExtra(EXTRA_DESTINATION))
|
safetySourceStatus
|
||||||
|
.getPendingIntent()
|
||||||
|
.getIntent()
|
||||||
|
.getStringExtra(EXTRA_DESTINATION))
|
||||||
.isEqualTo(FAKE_CHOOSE_LOCK_GENERIC_FRAGMENT);
|
.isEqualTo(FAKE_CHOOSE_LOCK_GENERIC_FRAGMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,12 +174,16 @@ public class LockScreenSafetySourceTest {
|
|||||||
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
||||||
.thenReturn(false);
|
.thenReturn(false);
|
||||||
|
|
||||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
LockScreenSafetySource.setSafetySourceData(
|
||||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
mApplicationContext, mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||||
|
|
||||||
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
||||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
verify(mSafetyCenterManagerWrapper)
|
||||||
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
|
.setSafetySourceData(
|
||||||
|
any(),
|
||||||
|
eq(LockScreenSafetySource.SAFETY_SOURCE_ID),
|
||||||
|
captor.capture(),
|
||||||
|
any());
|
||||||
SafetySourceData safetySourceData = captor.getValue();
|
SafetySourceData safetySourceData = captor.getValue();
|
||||||
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
|
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
|
||||||
|
|
||||||
@@ -194,12 +199,16 @@ public class LockScreenSafetySourceTest {
|
|||||||
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
||||||
.thenReturn(false);
|
.thenReturn(false);
|
||||||
|
|
||||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
LockScreenSafetySource.setSafetySourceData(
|
||||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
mApplicationContext, mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||||
|
|
||||||
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
||||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
verify(mSafetyCenterManagerWrapper)
|
||||||
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
|
.setSafetySourceData(
|
||||||
|
any(),
|
||||||
|
eq(LockScreenSafetySource.SAFETY_SOURCE_ID),
|
||||||
|
captor.capture(),
|
||||||
|
any());
|
||||||
SafetySourceData safetySourceData = captor.getValue();
|
SafetySourceData safetySourceData = captor.getValue();
|
||||||
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
|
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
|
||||||
|
|
||||||
@@ -215,12 +224,16 @@ public class LockScreenSafetySourceTest {
|
|||||||
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
||||||
.thenReturn(true);
|
.thenReturn(true);
|
||||||
|
|
||||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
LockScreenSafetySource.setSafetySourceData(
|
||||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
mApplicationContext, mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||||
|
|
||||||
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
||||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
verify(mSafetyCenterManagerWrapper)
|
||||||
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
|
.setSafetySourceData(
|
||||||
|
any(),
|
||||||
|
eq(LockScreenSafetySource.SAFETY_SOURCE_ID),
|
||||||
|
captor.capture(),
|
||||||
|
any());
|
||||||
SafetySourceData safetySourceData = captor.getValue();
|
SafetySourceData safetySourceData = captor.getValue();
|
||||||
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
|
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
|
||||||
|
|
||||||
@@ -236,12 +249,16 @@ public class LockScreenSafetySourceTest {
|
|||||||
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
||||||
.thenReturn(true);
|
.thenReturn(true);
|
||||||
|
|
||||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
LockScreenSafetySource.setSafetySourceData(
|
||||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
mApplicationContext, mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||||
|
|
||||||
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
||||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
verify(mSafetyCenterManagerWrapper)
|
||||||
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
|
.setSafetySourceData(
|
||||||
|
any(),
|
||||||
|
eq(LockScreenSafetySource.SAFETY_SOURCE_ID),
|
||||||
|
captor.capture(),
|
||||||
|
any());
|
||||||
SafetySourceData safetySourceData = captor.getValue();
|
SafetySourceData safetySourceData = captor.getValue();
|
||||||
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
|
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
|
||||||
|
|
||||||
@@ -257,12 +274,12 @@ public class LockScreenSafetySourceTest {
|
|||||||
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
||||||
.thenReturn(false);
|
.thenReturn(false);
|
||||||
|
|
||||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
LockScreenSafetySource.setSafetySourceData(
|
||||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
mApplicationContext, mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||||
|
|
||||||
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
||||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
verify(mSafetyCenterManagerWrapper)
|
||||||
any(), any(), captor.capture(), any());
|
.setSafetySourceData(any(), any(), captor.capture(), any());
|
||||||
SafetySourceData safetySourceData = captor.getValue();
|
SafetySourceData safetySourceData = captor.getValue();
|
||||||
|
|
||||||
assertThat(safetySourceData.getIssues()).isEmpty();
|
assertThat(safetySourceData.getIssues()).isEmpty();
|
||||||
@@ -276,34 +293,41 @@ public class LockScreenSafetySourceTest {
|
|||||||
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
||||||
.thenReturn(false);
|
.thenReturn(false);
|
||||||
|
|
||||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
LockScreenSafetySource.setSafetySourceData(
|
||||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
mApplicationContext, mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||||
|
|
||||||
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
||||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
verify(mSafetyCenterManagerWrapper)
|
||||||
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
|
.setSafetySourceData(
|
||||||
|
any(),
|
||||||
|
eq(LockScreenSafetySource.SAFETY_SOURCE_ID),
|
||||||
|
captor.capture(),
|
||||||
|
any());
|
||||||
SafetySourceData safetySourceData = captor.getValue();
|
SafetySourceData safetySourceData = captor.getValue();
|
||||||
|
|
||||||
assertThat(safetySourceData.getIssues()).hasSize(1);
|
assertThat(safetySourceData.getIssues()).hasSize(1);
|
||||||
SafetySourceIssue issue = safetySourceData.getIssues().get(0);
|
SafetySourceIssue issue = safetySourceData.getIssues().get(0);
|
||||||
assertThat(issue.getId()).isEqualTo(LockScreenSafetySource.NO_SCREEN_LOCK_ISSUE_ID);
|
assertThat(issue.getId()).isEqualTo(LockScreenSafetySource.NO_SCREEN_LOCK_ISSUE_ID);
|
||||||
assertThat(issue.getTitle().toString()).isEqualTo(
|
assertThat(issue.getTitle().toString())
|
||||||
ResourcesUtils.getResourcesString(mApplicationContext,
|
.isEqualTo(
|
||||||
"no_screen_lock_issue_title"));
|
ResourcesUtils.getResourcesString(
|
||||||
assertThat(issue.getSummary().toString()).isEqualTo(
|
mApplicationContext, "no_screen_lock_issue_title"));
|
||||||
ResourcesUtils.getResourcesString(mApplicationContext,
|
assertThat(issue.getSummary().toString())
|
||||||
"no_screen_lock_issue_summary"));
|
.isEqualTo(
|
||||||
assertThat(issue.getSeverityLevel()).isEqualTo(
|
ResourcesUtils.getResourcesString(
|
||||||
SafetySourceData.SEVERITY_LEVEL_RECOMMENDATION);
|
mApplicationContext, "no_screen_lock_issue_summary"));
|
||||||
assertThat(issue.getIssueTypeId()).isEqualTo(
|
assertThat(issue.getSeverityLevel())
|
||||||
LockScreenSafetySource.NO_SCREEN_LOCK_ISSUE_TYPE_ID);
|
.isEqualTo(SafetySourceData.SEVERITY_LEVEL_RECOMMENDATION);
|
||||||
|
assertThat(issue.getIssueTypeId())
|
||||||
|
.isEqualTo(LockScreenSafetySource.NO_SCREEN_LOCK_ISSUE_TYPE_ID);
|
||||||
assertThat(issue.getIssueCategory()).isEqualTo(SafetySourceIssue.ISSUE_CATEGORY_DEVICE);
|
assertThat(issue.getIssueCategory()).isEqualTo(SafetySourceIssue.ISSUE_CATEGORY_DEVICE);
|
||||||
assertThat(issue.getActions()).hasSize(1);
|
assertThat(issue.getActions()).hasSize(1);
|
||||||
SafetySourceIssue.Action action = issue.getActions().get(0);
|
SafetySourceIssue.Action action = issue.getActions().get(0);
|
||||||
assertThat(action.getId()).isEqualTo(LockScreenSafetySource.SET_SCREEN_LOCK_ACTION_ID);
|
assertThat(action.getId()).isEqualTo(LockScreenSafetySource.SET_SCREEN_LOCK_ACTION_ID);
|
||||||
assertThat(action.getLabel().toString()).isEqualTo(
|
assertThat(action.getLabel().toString())
|
||||||
ResourcesUtils.getResourcesString(mApplicationContext,
|
.isEqualTo(
|
||||||
"no_screen_lock_issue_action_label"));
|
ResourcesUtils.getResourcesString(
|
||||||
|
mApplicationContext, "no_screen_lock_issue_action_label"));
|
||||||
assertThat(action.getPendingIntent().getIntent().getAction())
|
assertThat(action.getPendingIntent().getIntent().getAction())
|
||||||
.isEqualTo(FAKE_ACTION_OPEN_SUB_SETTING);
|
.isEqualTo(FAKE_ACTION_OPEN_SUB_SETTING);
|
||||||
assertThat(action.getPendingIntent().getIntent().getStringExtra(EXTRA_DESTINATION))
|
assertThat(action.getPendingIntent().getIntent().getStringExtra(EXTRA_DESTINATION))
|
||||||
@@ -318,12 +342,12 @@ public class LockScreenSafetySourceTest {
|
|||||||
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
||||||
.thenReturn(true);
|
.thenReturn(true);
|
||||||
|
|
||||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
LockScreenSafetySource.setSafetySourceData(
|
||||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
mApplicationContext, mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||||
|
|
||||||
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
||||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
verify(mSafetyCenterManagerWrapper)
|
||||||
any(), any(), captor.capture(), any());
|
.setSafetySourceData(any(), any(), captor.capture(), any());
|
||||||
SafetySourceData safetySourceData = captor.getValue();
|
SafetySourceData safetySourceData = captor.getValue();
|
||||||
|
|
||||||
assertThat(safetySourceData.getIssues()).isEmpty();
|
assertThat(safetySourceData.getIssues()).isEmpty();
|
||||||
@@ -337,12 +361,16 @@ public class LockScreenSafetySourceTest {
|
|||||||
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
||||||
.thenReturn(true);
|
.thenReturn(true);
|
||||||
|
|
||||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
LockScreenSafetySource.setSafetySourceData(
|
||||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
mApplicationContext, mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||||
|
|
||||||
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
||||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
verify(mSafetyCenterManagerWrapper)
|
||||||
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
|
.setSafetySourceData(
|
||||||
|
any(),
|
||||||
|
eq(LockScreenSafetySource.SAFETY_SOURCE_ID),
|
||||||
|
captor.capture(),
|
||||||
|
any());
|
||||||
SafetySourceData safetySourceData = captor.getValue();
|
SafetySourceData safetySourceData = captor.getValue();
|
||||||
|
|
||||||
assertThat(safetySourceData.getIssues()).isEmpty();
|
assertThat(safetySourceData.getIssues()).isEmpty();
|
||||||
@@ -355,16 +383,28 @@ public class LockScreenSafetySourceTest {
|
|||||||
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
||||||
.thenReturn(true);
|
.thenReturn(true);
|
||||||
|
|
||||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
LockScreenSafetySource.setSafetySourceData(
|
||||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
mApplicationContext, mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||||
|
|
||||||
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
||||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
verify(mSafetyCenterManagerWrapper)
|
||||||
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
|
.setSafetySourceData(
|
||||||
|
any(),
|
||||||
|
eq(LockScreenSafetySource.SAFETY_SOURCE_ID),
|
||||||
|
captor.capture(),
|
||||||
|
any());
|
||||||
SafetySourceData safetySourceData = captor.getValue();
|
SafetySourceData safetySourceData = captor.getValue();
|
||||||
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
|
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
|
||||||
|
|
||||||
assertThat(safetySourceStatus.isEnabled()).isFalse();
|
assertThat(safetySourceStatus.isEnabled()).isFalse();
|
||||||
|
assertThat(safetySourceStatus.getPendingIntent()).isNull();
|
||||||
|
assertThat(safetySourceStatus.getIconAction()).isNull();
|
||||||
|
assertThat(safetySourceStatus.getSeverityLevel())
|
||||||
|
.isEqualTo(SafetySourceData.SEVERITY_LEVEL_UNSPECIFIED);
|
||||||
|
assertThat(safetySourceStatus.getSummary().toString())
|
||||||
|
.isEqualTo(
|
||||||
|
ResourcesUtils.getResourcesString(
|
||||||
|
mApplicationContext, "disabled_by_policy_title"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -374,16 +414,25 @@ public class LockScreenSafetySourceTest {
|
|||||||
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
when(mScreenLockPreferenceDetailsUtils.isPasswordQualityManaged(anyInt(), any()))
|
||||||
.thenReturn(false);
|
.thenReturn(false);
|
||||||
|
|
||||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
LockScreenSafetySource.setSafetySourceData(
|
||||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
mApplicationContext, mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||||
|
|
||||||
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
||||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
verify(mSafetyCenterManagerWrapper)
|
||||||
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
|
.setSafetySourceData(
|
||||||
|
any(),
|
||||||
|
eq(LockScreenSafetySource.SAFETY_SOURCE_ID),
|
||||||
|
captor.capture(),
|
||||||
|
any());
|
||||||
SafetySourceData safetySourceData = captor.getValue();
|
SafetySourceData safetySourceData = captor.getValue();
|
||||||
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
|
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
|
||||||
|
|
||||||
assertThat(safetySourceStatus.isEnabled()).isTrue();
|
assertThat(safetySourceStatus.isEnabled()).isTrue();
|
||||||
|
assertThat(safetySourceStatus.getPendingIntent()).isNotNull();
|
||||||
|
assertThat(safetySourceStatus.getIconAction()).isNotNull();
|
||||||
|
assertThat(safetySourceStatus.getSeverityLevel())
|
||||||
|
.isEqualTo(SafetySourceData.SEVERITY_LEVEL_INFORMATION);
|
||||||
|
assertThat(safetySourceStatus.getSummary().toString()).isEqualTo(SUMMARY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -392,20 +441,23 @@ public class LockScreenSafetySourceTest {
|
|||||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||||
when(mScreenLockPreferenceDetailsUtils.shouldShowGearMenu()).thenReturn(true);
|
when(mScreenLockPreferenceDetailsUtils.shouldShowGearMenu()).thenReturn(true);
|
||||||
|
|
||||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
LockScreenSafetySource.setSafetySourceData(
|
||||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
mApplicationContext, mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||||
|
|
||||||
final ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(
|
final ArgumentCaptor<SafetySourceData> captor =
|
||||||
SafetySourceData.class);
|
ArgumentCaptor.forClass(SafetySourceData.class);
|
||||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
verify(mSafetyCenterManagerWrapper)
|
||||||
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
|
.setSafetySourceData(
|
||||||
|
any(),
|
||||||
|
eq(LockScreenSafetySource.SAFETY_SOURCE_ID),
|
||||||
|
captor.capture(),
|
||||||
|
any());
|
||||||
final IconAction iconAction = captor.getValue().getStatus().getIconAction();
|
final IconAction iconAction = captor.getValue().getStatus().getIconAction();
|
||||||
|
|
||||||
assertThat(iconAction.getIconType()).isEqualTo(IconAction.ICON_TYPE_GEAR);
|
assertThat(iconAction.getIconType()).isEqualTo(IconAction.ICON_TYPE_GEAR);
|
||||||
assertThat(iconAction.getPendingIntent().getIntent().getAction())
|
assertThat(iconAction.getPendingIntent().getIntent().getAction())
|
||||||
.isEqualTo(FAKE_ACTION_OPEN_SUB_SETTING);
|
.isEqualTo(FAKE_ACTION_OPEN_SUB_SETTING);
|
||||||
assertThat(
|
assertThat(iconAction.getPendingIntent().getIntent().getStringExtra(EXTRA_DESTINATION))
|
||||||
iconAction.getPendingIntent().getIntent().getStringExtra(EXTRA_DESTINATION))
|
|
||||||
.isEqualTo(FAKE_SCREEN_LOCK_SETTINGS);
|
.isEqualTo(FAKE_SCREEN_LOCK_SETTINGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,12 +467,16 @@ public class LockScreenSafetySourceTest {
|
|||||||
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
|
||||||
when(mScreenLockPreferenceDetailsUtils.shouldShowGearMenu()).thenReturn(false);
|
when(mScreenLockPreferenceDetailsUtils.shouldShowGearMenu()).thenReturn(false);
|
||||||
|
|
||||||
LockScreenSafetySource.setSafetySourceData(mApplicationContext,
|
LockScreenSafetySource.setSafetySourceData(
|
||||||
mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
mApplicationContext, mScreenLockPreferenceDetailsUtils, EVENT_SOURCE_STATE_CHANGED);
|
||||||
|
|
||||||
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
ArgumentCaptor<SafetySourceData> captor = ArgumentCaptor.forClass(SafetySourceData.class);
|
||||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
verify(mSafetyCenterManagerWrapper)
|
||||||
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), captor.capture(), any());
|
.setSafetySourceData(
|
||||||
|
any(),
|
||||||
|
eq(LockScreenSafetySource.SAFETY_SOURCE_ID),
|
||||||
|
captor.capture(),
|
||||||
|
any());
|
||||||
SafetySourceData safetySourceData = captor.getValue();
|
SafetySourceData safetySourceData = captor.getValue();
|
||||||
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
|
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
|
||||||
|
|
||||||
@@ -434,10 +490,12 @@ public class LockScreenSafetySourceTest {
|
|||||||
|
|
||||||
LockScreenSafetySource.onLockScreenChange(mApplicationContext);
|
LockScreenSafetySource.onLockScreenChange(mApplicationContext);
|
||||||
|
|
||||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
verify(mSafetyCenterManagerWrapper)
|
||||||
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), any(), any());
|
.setSafetySourceData(
|
||||||
verify(mSafetyCenterManagerWrapper).setSafetySourceData(
|
any(), eq(LockScreenSafetySource.SAFETY_SOURCE_ID), any(), any());
|
||||||
any(), eq(BiometricsSafetySource.SAFETY_SOURCE_ID), any(), any());
|
verify(mSafetyCenterManagerWrapper)
|
||||||
|
.setSafetySourceData(
|
||||||
|
any(), eq(BiometricsSafetySource.SAFETY_SOURCE_ID), any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -447,8 +505,8 @@ public class LockScreenSafetySourceTest {
|
|||||||
|
|
||||||
LockScreenSafetySource.onLockScreenChange(mApplicationContext);
|
LockScreenSafetySource.onLockScreenChange(mApplicationContext);
|
||||||
|
|
||||||
verify(mSafetyCenterManagerWrapper, never()).setSafetySourceData(
|
verify(mSafetyCenterManagerWrapper, never())
|
||||||
any(), any(), any(), any());
|
.setSafetySourceData(any(), any(), any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void whenScreenLockIsEnabled() {
|
private void whenScreenLockIsEnabled() {
|
||||||
@@ -456,8 +514,8 @@ public class LockScreenSafetySourceTest {
|
|||||||
when(mScreenLockPreferenceDetailsUtils.getSummary(anyInt())).thenReturn(SUMMARY);
|
when(mScreenLockPreferenceDetailsUtils.getSummary(anyInt())).thenReturn(SUMMARY);
|
||||||
|
|
||||||
Intent launchChooseLockGenericFragment = new Intent(FAKE_ACTION_OPEN_SUB_SETTING);
|
Intent launchChooseLockGenericFragment = new Intent(FAKE_ACTION_OPEN_SUB_SETTING);
|
||||||
launchChooseLockGenericFragment.putExtra(EXTRA_DESTINATION,
|
launchChooseLockGenericFragment.putExtra(
|
||||||
FAKE_CHOOSE_LOCK_GENERIC_FRAGMENT);
|
EXTRA_DESTINATION, FAKE_CHOOSE_LOCK_GENERIC_FRAGMENT);
|
||||||
when(mScreenLockPreferenceDetailsUtils.getLaunchChooseLockGenericFragmentIntent(anyInt()))
|
when(mScreenLockPreferenceDetailsUtils.getLaunchChooseLockGenericFragmentIntent(anyInt()))
|
||||||
.thenReturn(launchChooseLockGenericFragment);
|
.thenReturn(launchChooseLockGenericFragment);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user