Provide a way to customize biometric SafetySourceIssue

Add a new FeatureProvider for biometrics in FeatureFactory to provide a way to customize biometric SafetySourceIssue

Bug: 370940762
Test: m Settings
Test: m SettingsGoogle
Test: m SettingsSpaUnitTests
Test: m SettingsRoboTests
Flag: com.android.settings.flags.biometrics_onboarding_education
Change-Id: I4d11f3d3522ce5ac2f975cca7c041339f3ea6031
This commit is contained in:
Shawn Lin
2025-02-02 08:15:59 +00:00
parent e06acaab1d
commit 7c3559d37f
10 changed files with 136 additions and 4 deletions

View File

@@ -21,6 +21,7 @@ import android.content.Context;
import android.content.Intent;
import android.safetycenter.SafetyEvent;
import android.safetycenter.SafetySourceData;
import android.safetycenter.SafetySourceIssue;
import android.safetycenter.SafetySourceStatus;
/** Static helpers for setting SafetyCenter data for biometric safety sources. */
@@ -42,6 +43,30 @@ public final class BiometricSourcesUtils {
boolean enabled,
boolean hasEnrolled,
SafetyEvent safetyEvent) {
setBiometricSafetySourceData(
safetySourceId,
context,
title,
summary,
pendingIntent,
enabled,
hasEnrolled,
safetyEvent,
null
);
}
/** Sets data for one of the biometrics sources */
public static void setBiometricSafetySourceData(
String safetySourceId,
Context context,
String title,
String summary,
PendingIntent pendingIntent,
boolean enabled,
boolean hasEnrolled,
SafetyEvent safetyEvent,
SafetySourceIssue safetySourceIssue) {
int severityLevel =
enabled && hasEnrolled
? SafetySourceData.SEVERITY_LEVEL_INFORMATION
@@ -52,8 +77,13 @@ public final class BiometricSourcesUtils {
.setPendingIntent(pendingIntent)
.setEnabled(enabled)
.build();
SafetySourceData safetySourceData =
new SafetySourceData.Builder().setStatus(status).build();
SafetySourceData.Builder builder = new SafetySourceData.Builder().setStatus(status);
if (safetySourceIssue != null) {
builder.addIssue(safetySourceIssue);
}
SafetySourceData safetySourceData = builder.build();
SafetyCenterManagerWrapper.get()
.setSafetySourceData(context, safetySourceId, safetySourceData, safetyEvent);