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();
|
||||
|
Reference in New Issue
Block a user