Use new severity levels and builders
Test: atest SettingsUnitTests Bug: 218817241 Bug: 220367542 Change-Id: I9fa4b22e0ca1ca63e75eab427a7beedd95b744da Merged-In: I9fa4b22e0ca1ca63e75eab427a7beedd95b744da
This commit is contained in:
@@ -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();
|
||||
|
Reference in New Issue
Block a user