Split biometrics resource into three.
Bug: 388476345 Test: Treehugger Flag: com.android.settings.flags.biometrics_onboarding_education Relnote: N/a Change-Id: Ie6761f318e64e1cf2782c538d7b6af5b5094faa1
This commit is contained in:
@@ -26,12 +26,11 @@ import com.android.settings.R;
|
||||
import com.android.settings.Settings;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.biometrics.ParentalControlsUtils;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
|
||||
/**
|
||||
* Utilities for face details shared between Security Settings and Safety Center.
|
||||
*/
|
||||
/** Utilities for face details shared between Security Settings and Safety Center. */
|
||||
public class FaceStatusUtils {
|
||||
|
||||
private final int mUserId;
|
||||
@@ -44,9 +43,7 @@ public class FaceStatusUtils {
|
||||
mUserId = userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the face settings entity should be shown.
|
||||
*/
|
||||
/** Returns whether the face settings entity should be shown. */
|
||||
public boolean isAvailable() {
|
||||
return !Utils.isMultipleBiometricsSupported(mContext) && Utils.hasFaceHardware(mContext);
|
||||
}
|
||||
@@ -61,55 +58,70 @@ public class FaceStatusUtils {
|
||||
mContext, BiometricAuthenticator.TYPE_FACE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the title of face settings entity.
|
||||
*/
|
||||
/** Returns the title of face settings entity. */
|
||||
public String getTitle() {
|
||||
UserManager userManager = mContext.getSystemService(UserManager.class);
|
||||
if (userManager != null && userManager.isProfile()) {
|
||||
return mContext.getString(
|
||||
Utils.isPrivateProfile(mUserId, mContext)
|
||||
? R.string.private_space_face_unlock_title
|
||||
: R.string.security_settings_face_profile_preference_title);
|
||||
? getPrivateSpaceTitle()
|
||||
: getWorkProfileTitle());
|
||||
} else {
|
||||
return mContext.getString(R.string.security_settings_face_preference_title);
|
||||
return mContext.getString(getRegularTitle());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the summary of face settings entity.
|
||||
*/
|
||||
private int getPrivateSpaceTitle() {
|
||||
if (Flags.biometricsOnboardingEducation()) {
|
||||
return R.string.private_space_face_unlock_title_new;
|
||||
}
|
||||
return R.string.private_space_face_unlock_title;
|
||||
}
|
||||
|
||||
private int getWorkProfileTitle() {
|
||||
if (Flags.biometricsOnboardingEducation()) {
|
||||
return R.string.security_settings_face_profile_preference_title_new;
|
||||
}
|
||||
return R.string.security_settings_face_profile_preference_title;
|
||||
}
|
||||
|
||||
private int getRegularTitle() {
|
||||
if (Flags.biometricsOnboardingEducation()) {
|
||||
return R.string.security_settings_face_preference_title_new;
|
||||
}
|
||||
return R.string.security_settings_face_preference_title;
|
||||
}
|
||||
|
||||
/** Returns the summary of face settings entity. */
|
||||
public String getSummary() {
|
||||
if (shouldShowDisabledByAdminStr()) {
|
||||
return mContext.getString(
|
||||
com.android.settingslib.widget.restricted.R.string.disabled_by_admin);
|
||||
} else {
|
||||
return mContext.getResources().getString(hasEnrolled()
|
||||
? R.string.security_settings_face_preference_summary
|
||||
: R.string.security_settings_face_preference_summary_none);
|
||||
return mContext.getResources()
|
||||
.getString(
|
||||
hasEnrolled()
|
||||
? R.string.security_settings_face_preference_summary
|
||||
: R.string.security_settings_face_preference_summary_none);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the class name of the Settings page corresponding to face settings.
|
||||
*/
|
||||
/** Returns the class name of the Settings page corresponding to face settings. */
|
||||
public String getSettingsClassName() {
|
||||
return hasEnrolled() ? Settings.FaceSettingsInternalActivity.class.getName()
|
||||
return hasEnrolled()
|
||||
? Settings.FaceSettingsInternalActivity.class.getName()
|
||||
: FaceEnrollIntroductionInternal.class.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether at least one face template has been enrolled.
|
||||
*/
|
||||
/** Returns whether at least one face template has been enrolled. */
|
||||
public boolean hasEnrolled() {
|
||||
return mFaceManager.hasEnrolledTemplates(mUserId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the face feature is enabled or disabled by the Device Admin.
|
||||
*/
|
||||
/** Indicates if the face feature is enabled or disabled by the Device Admin. */
|
||||
private boolean shouldShowDisabledByAdminStr() {
|
||||
return RestrictedLockUtilsInternal.checkIfKeyguardFeaturesDisabled(
|
||||
mContext, DevicePolicyManager.KEYGUARD_DISABLE_FACE, mUserId) != null;
|
||||
mContext, DevicePolicyManager.KEYGUARD_DISABLE_FACE, mUserId)
|
||||
!= null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,9 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.biometrics.BiometricUtils;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.safetycenter.BiometricsSafetySource;
|
||||
import com.android.settings.safetycenter.FaceSafetySource;
|
||||
|
||||
/**
|
||||
* Responsible for making {@link FaceManager#enroll} and {@link FaceManager#remove} calls and thus
|
||||
@@ -51,20 +53,43 @@ public class FaceUpdater {
|
||||
}
|
||||
|
||||
/** Wrapper around the {@link FaceManager#enroll} method. */
|
||||
public void enroll(int userId, byte[] hardwareAuthToken, CancellationSignal cancel,
|
||||
FaceManager.EnrollmentCallback callback, int[] disabledFeatures, Intent intent) {
|
||||
this.enroll(userId, hardwareAuthToken, cancel,
|
||||
new NotifyingEnrollmentCallback(mContext, callback), disabledFeatures,
|
||||
null, false, intent);
|
||||
public void enroll(
|
||||
int userId,
|
||||
byte[] hardwareAuthToken,
|
||||
CancellationSignal cancel,
|
||||
FaceManager.EnrollmentCallback callback,
|
||||
int[] disabledFeatures,
|
||||
Intent intent) {
|
||||
this.enroll(
|
||||
userId,
|
||||
hardwareAuthToken,
|
||||
cancel,
|
||||
new NotifyingEnrollmentCallback(mContext, callback),
|
||||
disabledFeatures,
|
||||
null,
|
||||
false,
|
||||
intent);
|
||||
}
|
||||
|
||||
/** Wrapper around the {@link FaceManager#enroll} method. */
|
||||
public void enroll(int userId, byte[] hardwareAuthToken, CancellationSignal cancel,
|
||||
FaceManager.EnrollmentCallback callback, int[] disabledFeatures,
|
||||
@Nullable Surface previewSurface, boolean debugConsent, Intent intent) {
|
||||
mFaceManager.enroll(userId, hardwareAuthToken, cancel,
|
||||
new NotifyingEnrollmentCallback(mContext, callback), disabledFeatures,
|
||||
previewSurface, debugConsent, toFaceEnrollOptions(intent));
|
||||
public void enroll(
|
||||
int userId,
|
||||
byte[] hardwareAuthToken,
|
||||
CancellationSignal cancel,
|
||||
FaceManager.EnrollmentCallback callback,
|
||||
int[] disabledFeatures,
|
||||
@Nullable Surface previewSurface,
|
||||
boolean debugConsent,
|
||||
Intent intent) {
|
||||
mFaceManager.enroll(
|
||||
userId,
|
||||
hardwareAuthToken,
|
||||
cancel,
|
||||
new NotifyingEnrollmentCallback(mContext, callback),
|
||||
disabledFeatures,
|
||||
previewSurface,
|
||||
debugConsent,
|
||||
toFaceEnrollOptions(intent));
|
||||
}
|
||||
|
||||
/** Wrapper around the {@link FaceManager#remove} method. */
|
||||
@@ -73,17 +98,15 @@ public class FaceUpdater {
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorator of the {@link FaceManager.EnrollmentCallback} class that notifies other
|
||||
* interested parties that a face setting has changed.
|
||||
* Decorator of the {@link FaceManager.EnrollmentCallback} class that notifies other interested
|
||||
* parties that a face setting has changed.
|
||||
*/
|
||||
private static class NotifyingEnrollmentCallback
|
||||
extends FaceManager.EnrollmentCallback {
|
||||
private static class NotifyingEnrollmentCallback extends FaceManager.EnrollmentCallback {
|
||||
|
||||
private final Context mContext;
|
||||
private final FaceManager.EnrollmentCallback mCallback;
|
||||
|
||||
NotifyingEnrollmentCallback(Context context,
|
||||
FaceManager.EnrollmentCallback callback) {
|
||||
NotifyingEnrollmentCallback(Context context, FaceManager.EnrollmentCallback callback) {
|
||||
mContext = context;
|
||||
mCallback = callback;
|
||||
}
|
||||
@@ -99,8 +122,14 @@ public class FaceUpdater {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnrollmentFrame(int helpCode, @Nullable CharSequence helpMessage,
|
||||
@Nullable FaceEnrollCell cell, int stage, float pan, float tilt, float distance) {
|
||||
public void onEnrollmentFrame(
|
||||
int helpCode,
|
||||
@Nullable CharSequence helpMessage,
|
||||
@Nullable FaceEnrollCell cell,
|
||||
int stage,
|
||||
float pan,
|
||||
float tilt,
|
||||
float distance) {
|
||||
mCallback.onEnrollmentFrame(helpCode, helpMessage, cell, stage, pan, tilt, distance);
|
||||
}
|
||||
|
||||
@@ -108,14 +137,18 @@ public class FaceUpdater {
|
||||
public void onEnrollmentProgress(int remaining) {
|
||||
mCallback.onEnrollmentProgress(remaining);
|
||||
if (remaining == 0) {
|
||||
BiometricsSafetySource.onBiometricsChanged(mContext); // biometrics data changed
|
||||
if (Flags.biometricsOnboardingEducation()) {
|
||||
FaceSafetySource.onBiometricsChanged(mContext);
|
||||
} else {
|
||||
BiometricsSafetySource.onBiometricsChanged(mContext); // biometrics data changed
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorator of the {@link FaceManager.RemovalCallback} class that notifies other
|
||||
* interested parties that a face setting has changed.
|
||||
* Decorator of the {@link FaceManager.RemovalCallback} class that notifies other interested
|
||||
* parties that a face setting has changed.
|
||||
*/
|
||||
private static class NotifyingRemovalCallback extends FaceManager.RemovalCallback {
|
||||
|
||||
@@ -135,7 +168,11 @@ public class FaceUpdater {
|
||||
@Override
|
||||
public void onRemovalSucceeded(@Nullable Face fp, int remaining) {
|
||||
mCallback.onRemovalSucceeded(fp, remaining);
|
||||
BiometricsSafetySource.onBiometricsChanged(mContext); // biometrics data changed
|
||||
if (Flags.biometricsOnboardingEducation()) {
|
||||
FaceSafetySource.onBiometricsChanged(mContext);
|
||||
} else {
|
||||
BiometricsSafetySource.onBiometricsChanged(mContext); // biometrics data changed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,29 +25,26 @@ import android.os.UserManager;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.biometrics.ParentalControlsUtils;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
import com.android.settingslib.utils.StringUtil;
|
||||
|
||||
/**
|
||||
* Utilities for fingerprint details shared between Security Settings and Safety Center.
|
||||
*/
|
||||
/** Utilities for fingerprint details shared between Security Settings and Safety Center. */
|
||||
public class FingerprintStatusUtils {
|
||||
|
||||
private final int mUserId;
|
||||
private final Context mContext;
|
||||
private final FingerprintManager mFingerprintManager;
|
||||
|
||||
public FingerprintStatusUtils(Context context, FingerprintManager fingerprintManager,
|
||||
int userId) {
|
||||
public FingerprintStatusUtils(
|
||||
Context context, FingerprintManager fingerprintManager, int userId) {
|
||||
mContext = context;
|
||||
mFingerprintManager = fingerprintManager;
|
||||
mUserId = userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the fingerprint settings entity should be shown.
|
||||
*/
|
||||
/** Returns whether the fingerprint settings entity should be shown. */
|
||||
public boolean isAvailable() {
|
||||
return !Utils.isMultipleBiometricsSupported(mContext)
|
||||
&& Utils.hasFingerprintHardware(mContext);
|
||||
@@ -62,24 +59,42 @@ public class FingerprintStatusUtils {
|
||||
return ParentalControlsUtils.parentConsentRequired(
|
||||
mContext, BiometricAuthenticator.TYPE_FINGERPRINT);
|
||||
}
|
||||
/**
|
||||
* Returns the title of fingerprint settings entity.
|
||||
*/
|
||||
|
||||
/** Returns the title of fingerprint settings entity. */
|
||||
public String getTitle() {
|
||||
UserManager userManager = mContext.getSystemService(UserManager.class);
|
||||
if (userManager != null && userManager.isProfile()) {
|
||||
return mContext.getString(
|
||||
Utils.isPrivateProfile(mUserId, mContext)
|
||||
? R.string.private_space_fingerprint_unlock_title
|
||||
: R.string.security_settings_work_fingerprint_preference_title);
|
||||
? getPrivateSpaceTitle()
|
||||
: getWorkProfileTitle());
|
||||
} else {
|
||||
return mContext.getString(R.string.security_settings_fingerprint_preference_title);
|
||||
return mContext.getString(getRegularTitle());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the summary of fingerprint settings entity.
|
||||
*/
|
||||
private int getPrivateSpaceTitle() {
|
||||
if (Flags.biometricsOnboardingEducation()) {
|
||||
return R.string.private_space_fingerprint_unlock_title_new;
|
||||
}
|
||||
return R.string.private_space_fingerprint_unlock_title;
|
||||
}
|
||||
|
||||
private int getWorkProfileTitle() {
|
||||
if (Flags.biometricsOnboardingEducation()) {
|
||||
return R.string.security_settings_work_fingerprint_preference_title_new;
|
||||
}
|
||||
return R.string.security_settings_work_fingerprint_preference_title;
|
||||
}
|
||||
|
||||
private int getRegularTitle() {
|
||||
if (Flags.biometricsOnboardingEducation()) {
|
||||
return R.string.security_settings_fingerprint; // doesn't have an overlay
|
||||
}
|
||||
return R.string.security_settings_fingerprint_preference_title;
|
||||
}
|
||||
|
||||
/** Returns the summary of fingerprint settings entity. */
|
||||
public String getSummary() {
|
||||
if (shouldShowDisabledByAdminStr()) {
|
||||
return mContext.getString(
|
||||
@@ -87,7 +102,9 @@ public class FingerprintStatusUtils {
|
||||
}
|
||||
if (hasEnrolled()) {
|
||||
final int numEnrolled = mFingerprintManager.getEnrolledFingerprints(mUserId).size();
|
||||
return StringUtil.getIcuPluralsString(mContext, numEnrolled,
|
||||
return StringUtil.getIcuPluralsString(
|
||||
mContext,
|
||||
numEnrolled,
|
||||
R.string.security_settings_fingerprint_preference_summary);
|
||||
} else {
|
||||
return mContext.getString(
|
||||
@@ -95,25 +112,20 @@ public class FingerprintStatusUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the class name of the Settings page corresponding to fingerprint settings.
|
||||
*/
|
||||
/** Returns the class name of the Settings page corresponding to fingerprint settings. */
|
||||
public String getSettingsClassName() {
|
||||
return FingerprintSettings.class.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether at least one fingerprint has been enrolled.
|
||||
*/
|
||||
/** Returns whether at least one fingerprint has been enrolled. */
|
||||
public boolean hasEnrolled() {
|
||||
return mFingerprintManager.hasEnrolledFingerprints(mUserId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the fingerprint feature should show the "Disabled by Admin" string.
|
||||
*/
|
||||
/** Indicates if the fingerprint feature should show the "Disabled by Admin" string. */
|
||||
private boolean shouldShowDisabledByAdminStr() {
|
||||
return RestrictedLockUtilsInternal.checkIfKeyguardFeaturesDisabled(
|
||||
mContext, DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT, mUserId) != null;
|
||||
mContext, DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT, mUserId)
|
||||
!= null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,9 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.biometrics.BiometricUtils;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.safetycenter.BiometricsSafetySource;
|
||||
import com.android.settings.safetycenter.FingerprintSafetySource;
|
||||
|
||||
/**
|
||||
* Responsible for making {@link FingerprintManager#enroll} and {@link FingerprintManager#remove}
|
||||
@@ -49,11 +51,19 @@ public class FingerprintUpdater {
|
||||
}
|
||||
|
||||
/** Wrapper around the {@link FingerprintManager#enroll} method. */
|
||||
public void enroll(byte [] hardwareAuthToken, CancellationSignal cancel, int userId,
|
||||
public void enroll(
|
||||
byte[] hardwareAuthToken,
|
||||
CancellationSignal cancel,
|
||||
int userId,
|
||||
FingerprintManager.EnrollmentCallback callback,
|
||||
@FingerprintManager.EnrollReason int enrollReason, Intent intent) {
|
||||
mFingerprintManager.enroll(hardwareAuthToken, cancel, userId,
|
||||
new NotifyingEnrollmentCallback(mContext, callback), enrollReason,
|
||||
@FingerprintManager.EnrollReason int enrollReason,
|
||||
Intent intent) {
|
||||
mFingerprintManager.enroll(
|
||||
hardwareAuthToken,
|
||||
cancel,
|
||||
userId,
|
||||
new NotifyingEnrollmentCallback(mContext, callback),
|
||||
enrollReason,
|
||||
toFingerprintEnrollOptions(intent));
|
||||
}
|
||||
|
||||
@@ -66,14 +76,13 @@ public class FingerprintUpdater {
|
||||
* Decorator of the {@link FingerprintManager.EnrollmentCallback} class that notifies other
|
||||
* interested parties that a fingerprint setting has changed.
|
||||
*/
|
||||
private static class NotifyingEnrollmentCallback
|
||||
extends FingerprintManager.EnrollmentCallback {
|
||||
private static class NotifyingEnrollmentCallback extends FingerprintManager.EnrollmentCallback {
|
||||
|
||||
private final Context mContext;
|
||||
private final FingerprintManager.EnrollmentCallback mCallback;
|
||||
|
||||
NotifyingEnrollmentCallback(Context context,
|
||||
FingerprintManager.EnrollmentCallback callback) {
|
||||
NotifyingEnrollmentCallback(
|
||||
Context context, FingerprintManager.EnrollmentCallback callback) {
|
||||
mContext = context;
|
||||
mCallback = callback;
|
||||
}
|
||||
@@ -92,7 +101,11 @@ public class FingerprintUpdater {
|
||||
public void onEnrollmentProgress(int remaining) {
|
||||
mCallback.onEnrollmentProgress(remaining);
|
||||
if (remaining == 0) {
|
||||
BiometricsSafetySource.onBiometricsChanged(mContext); // biometrics data changed
|
||||
if (Flags.biometricsOnboardingEducation()) {
|
||||
FingerprintSafetySource.onBiometricsChanged(mContext);
|
||||
} else {
|
||||
BiometricsSafetySource.onBiometricsChanged(mContext); // biometrics data changed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +152,11 @@ public class FingerprintUpdater {
|
||||
@Override
|
||||
public void onRemovalSucceeded(@Nullable Fingerprint fp, int remaining) {
|
||||
mCallback.onRemovalSucceeded(fp, remaining);
|
||||
BiometricsSafetySource.onBiometricsChanged(mContext); // biometrics data changed
|
||||
if (Flags.biometricsOnboardingEducation()) {
|
||||
FingerprintSafetySource.onBiometricsChanged(mContext);
|
||||
} else {
|
||||
BiometricsSafetySource.onBiometricsChanged(mContext); // biometrics data changed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2025 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.safetycenter;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.safetycenter.SafetyEvent;
|
||||
import android.safetycenter.SafetySourceData;
|
||||
import android.safetycenter.SafetySourceStatus;
|
||||
|
||||
/** Static helpers for setting SafetyCenter data for biometric safety sources. */
|
||||
public final class BiometricSourcesUtils {
|
||||
|
||||
public static final int REQUEST_CODE_COMBINED_BIOMETRIC_SETTING = 10;
|
||||
public static final int REQUEST_CODE_FACE_SETTING = 20;
|
||||
public static final int REQUEST_CODE_FINGERPRINT_SETTING = 30;
|
||||
|
||||
private BiometricSourcesUtils() {}
|
||||
|
||||
/** 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) {
|
||||
int severityLevel =
|
||||
enabled && hasEnrolled
|
||||
? SafetySourceData.SEVERITY_LEVEL_INFORMATION
|
||||
: SafetySourceData.SEVERITY_LEVEL_UNSPECIFIED;
|
||||
|
||||
SafetySourceStatus status =
|
||||
new SafetySourceStatus.Builder(title, summary, severityLevel)
|
||||
.setPendingIntent(pendingIntent)
|
||||
.setEnabled(enabled)
|
||||
.build();
|
||||
SafetySourceData safetySourceData =
|
||||
new SafetySourceData.Builder().setStatus(status).build();
|
||||
|
||||
SafetyCenterManagerWrapper.get()
|
||||
.setSafetySourceData(context, safetySourceId, safetySourceData, safetyEvent);
|
||||
}
|
||||
|
||||
/** Helper method for creating a pending intent. */
|
||||
public static PendingIntent createPendingIntent(
|
||||
Context context, Intent intent, int requestCode) {
|
||||
return PendingIntent.getActivity(
|
||||
context, requestCode, intent, PendingIntent.FLAG_IMMUTABLE);
|
||||
}
|
||||
}
|
||||
@@ -16,9 +16,11 @@
|
||||
|
||||
package com.android.settings.safetycenter;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import static com.android.settings.safetycenter.BiometricSourcesUtils.REQUEST_CODE_COMBINED_BIOMETRIC_SETTING;
|
||||
import static com.android.settings.safetycenter.BiometricSourcesUtils.REQUEST_CODE_FACE_SETTING;
|
||||
import static com.android.settings.safetycenter.BiometricSourcesUtils.REQUEST_CODE_FINGERPRINT_SETTING;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.hardware.face.FaceManager;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.os.Bundle;
|
||||
@@ -26,8 +28,6 @@ import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.safetycenter.SafetyEvent;
|
||||
import android.safetycenter.SafetySourceData;
|
||||
import android.safetycenter.SafetySourceStatus;
|
||||
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.biometrics.BiometricNavigationUtils;
|
||||
@@ -41,9 +41,6 @@ import com.android.settingslib.RestrictedLockUtils;
|
||||
public final class BiometricsSafetySource {
|
||||
|
||||
public static final String SAFETY_SOURCE_ID = "AndroidBiometrics";
|
||||
private static final int REQUEST_CODE_COMBINED_BIOMETRIC_SETTING = 10;
|
||||
private static final int REQUEST_CODE_FACE_SETTING = 20;
|
||||
private static final int REQUEST_CODE_FINGERPRINT_SETTING = 30;
|
||||
|
||||
private BiometricsSafetySource() {}
|
||||
|
||||
@@ -53,42 +50,38 @@ public final class BiometricsSafetySource {
|
||||
return;
|
||||
}
|
||||
|
||||
final UserHandle userHandle = Process.myUserHandle();
|
||||
final int userId = userHandle.getIdentifier();
|
||||
final UserManager userManager = UserManager.get(context);
|
||||
UserHandle userHandle = Process.myUserHandle();
|
||||
int userId = userHandle.getIdentifier();
|
||||
UserManager userManager = UserManager.get(context);
|
||||
UserHandle profileParentUserHandle = userManager.getProfileParent(userHandle);
|
||||
if (profileParentUserHandle == null) {
|
||||
profileParentUserHandle = userHandle;
|
||||
}
|
||||
final Context profileParentContext =
|
||||
context.createContextAsUser(profileParentUserHandle, 0);
|
||||
Context profileParentContext = context.createContextAsUser(profileParentUserHandle, 0);
|
||||
if (android.os.Flags.allowPrivateProfile()
|
||||
&& android.multiuser.Flags.enablePrivateSpaceFeatures()
|
||||
&& userManager.isPrivateProfile()) {
|
||||
// SC always expects a response from the source if the broadcast has been sent for this
|
||||
// source, therefore, we need to send a null SafetySourceData.
|
||||
SafetyCenterManagerWrapper.get().setSafetySourceData(
|
||||
context,
|
||||
SAFETY_SOURCE_ID,
|
||||
/* safetySourceData= */ null,
|
||||
safetyEvent);
|
||||
SafetyCenterManagerWrapper.get()
|
||||
.setSafetySourceData(
|
||||
context, SAFETY_SOURCE_ID, /* safetySourceData= */ null, safetyEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
final BiometricNavigationUtils biometricNavigationUtils =
|
||||
new BiometricNavigationUtils(userId);
|
||||
final CombinedBiometricStatusUtils combinedBiometricStatusUtils =
|
||||
BiometricNavigationUtils biometricNavigationUtils = new BiometricNavigationUtils(userId);
|
||||
CombinedBiometricStatusUtils combinedBiometricStatusUtils =
|
||||
new CombinedBiometricStatusUtils(context, userId);
|
||||
final ActiveUnlockStatusUtils activeUnlockStatusUtils =
|
||||
new ActiveUnlockStatusUtils(context);
|
||||
ActiveUnlockStatusUtils activeUnlockStatusUtils = new ActiveUnlockStatusUtils(context);
|
||||
if (!userManager.isProfile() && activeUnlockStatusUtils.isAvailable()) {
|
||||
final RestrictedLockUtils.EnforcedAdmin disablingAdmin =
|
||||
RestrictedLockUtils.EnforcedAdmin disablingAdmin =
|
||||
combinedBiometricStatusUtils.getDisablingAdmin();
|
||||
setBiometricSafetySourceData(
|
||||
BiometricSourcesUtils.setBiometricSafetySourceData(
|
||||
SAFETY_SOURCE_ID,
|
||||
context,
|
||||
activeUnlockStatusUtils.getTitleForActiveUnlock(),
|
||||
combinedBiometricStatusUtils.getSummary(),
|
||||
createPendingIntent(
|
||||
BiometricSourcesUtils.createPendingIntent(
|
||||
context,
|
||||
biometricNavigationUtils.getBiometricSettingsIntent(
|
||||
context,
|
||||
@@ -102,13 +95,14 @@ public final class BiometricsSafetySource {
|
||||
return;
|
||||
}
|
||||
if (combinedBiometricStatusUtils.isAvailable()) {
|
||||
final RestrictedLockUtils.EnforcedAdmin disablingAdmin =
|
||||
RestrictedLockUtils.EnforcedAdmin disablingAdmin =
|
||||
combinedBiometricStatusUtils.getDisablingAdmin();
|
||||
setBiometricSafetySourceData(
|
||||
BiometricSourcesUtils.setBiometricSafetySourceData(
|
||||
SAFETY_SOURCE_ID,
|
||||
context,
|
||||
combinedBiometricStatusUtils.getTitle(),
|
||||
combinedBiometricStatusUtils.getSummary(),
|
||||
createPendingIntent(
|
||||
BiometricSourcesUtils.createPendingIntent(
|
||||
profileParentContext,
|
||||
biometricNavigationUtils
|
||||
.getBiometricSettingsIntent(
|
||||
@@ -125,17 +119,17 @@ public final class BiometricsSafetySource {
|
||||
return;
|
||||
}
|
||||
|
||||
final FaceManager faceManager = Utils.getFaceManagerOrNull(context);
|
||||
final FaceStatusUtils faceStatusUtils = new FaceStatusUtils(context, faceManager, userId);
|
||||
FaceManager faceManager = Utils.getFaceManagerOrNull(context);
|
||||
FaceStatusUtils faceStatusUtils = new FaceStatusUtils(context, faceManager, userId);
|
||||
|
||||
if (faceStatusUtils.isAvailable()) {
|
||||
final RestrictedLockUtils.EnforcedAdmin disablingAdmin =
|
||||
faceStatusUtils.getDisablingAdmin();
|
||||
setBiometricSafetySourceData(
|
||||
RestrictedLockUtils.EnforcedAdmin disablingAdmin = faceStatusUtils.getDisablingAdmin();
|
||||
BiometricSourcesUtils.setBiometricSafetySourceData(
|
||||
SAFETY_SOURCE_ID,
|
||||
context,
|
||||
faceStatusUtils.getTitle(),
|
||||
faceStatusUtils.getSummary(),
|
||||
createPendingIntent(
|
||||
BiometricSourcesUtils.createPendingIntent(
|
||||
profileParentContext,
|
||||
biometricNavigationUtils
|
||||
.getBiometricSettingsIntent(
|
||||
@@ -152,18 +146,19 @@ public final class BiometricsSafetySource {
|
||||
return;
|
||||
}
|
||||
|
||||
final FingerprintManager fingerprintManager = Utils.getFingerprintManagerOrNull(context);
|
||||
final FingerprintStatusUtils fingerprintStatusUtils =
|
||||
FingerprintManager fingerprintManager = Utils.getFingerprintManagerOrNull(context);
|
||||
FingerprintStatusUtils fingerprintStatusUtils =
|
||||
new FingerprintStatusUtils(context, fingerprintManager, userId);
|
||||
|
||||
if (fingerprintStatusUtils.isAvailable()) {
|
||||
final RestrictedLockUtils.EnforcedAdmin disablingAdmin =
|
||||
RestrictedLockUtils.EnforcedAdmin disablingAdmin =
|
||||
fingerprintStatusUtils.getDisablingAdmin();
|
||||
setBiometricSafetySourceData(
|
||||
BiometricSourcesUtils.setBiometricSafetySourceData(
|
||||
SAFETY_SOURCE_ID,
|
||||
context,
|
||||
fingerprintStatusUtils.getTitle(),
|
||||
fingerprintStatusUtils.getSummary(),
|
||||
createPendingIntent(
|
||||
BiometricSourcesUtils.createPendingIntent(
|
||||
profileParentContext,
|
||||
biometricNavigationUtils
|
||||
.getBiometricSettingsIntent(
|
||||
@@ -191,35 +186,4 @@ public final class BiometricsSafetySource {
|
||||
new SafetyEvent.Builder(SafetyEvent.SAFETY_EVENT_TYPE_SOURCE_STATE_CHANGED)
|
||||
.build());
|
||||
}
|
||||
|
||||
private static void setBiometricSafetySourceData(
|
||||
Context context,
|
||||
String title,
|
||||
String summary,
|
||||
PendingIntent pendingIntent,
|
||||
boolean enabled,
|
||||
boolean hasEnrolled,
|
||||
SafetyEvent safetyEvent) {
|
||||
final int severityLevel =
|
||||
enabled && hasEnrolled
|
||||
? SafetySourceData.SEVERITY_LEVEL_INFORMATION
|
||||
: SafetySourceData.SEVERITY_LEVEL_UNSPECIFIED;
|
||||
|
||||
final SafetySourceStatus status =
|
||||
new SafetySourceStatus.Builder(title, summary, severityLevel)
|
||||
.setPendingIntent(pendingIntent)
|
||||
.setEnabled(enabled)
|
||||
.build();
|
||||
final SafetySourceData safetySourceData =
|
||||
new SafetySourceData.Builder().setStatus(status).build();
|
||||
|
||||
SafetyCenterManagerWrapper.get()
|
||||
.setSafetySourceData(context, SAFETY_SOURCE_ID, safetySourceData, safetyEvent);
|
||||
}
|
||||
|
||||
private static PendingIntent createPendingIntent(
|
||||
Context context, Intent intent, int requestCode) {
|
||||
return PendingIntent.getActivity(
|
||||
context, requestCode, intent, PendingIntent.FLAG_IMMUTABLE);
|
||||
}
|
||||
}
|
||||
|
||||
107
src/com/android/settings/safetycenter/FaceSafetySource.java
Normal file
107
src/com/android/settings/safetycenter/FaceSafetySource.java
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (C) 2025 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.safetycenter;
|
||||
|
||||
import static com.android.settings.safetycenter.BiometricSourcesUtils.REQUEST_CODE_FACE_SETTING;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.face.FaceManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.safetycenter.SafetyEvent;
|
||||
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.biometrics.BiometricNavigationUtils;
|
||||
import com.android.settings.biometrics.face.FaceStatusUtils;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
|
||||
/** Face biometrics Safety Source for Safety Center. */
|
||||
public final class FaceSafetySource {
|
||||
|
||||
public static final String SAFETY_SOURCE_ID = "AndroidFaceUnlock";
|
||||
|
||||
private FaceSafetySource() {}
|
||||
|
||||
/** Sets biometric safety data for Safety Center. */
|
||||
public static void setSafetySourceData(Context context, SafetyEvent safetyEvent) {
|
||||
if (!SafetyCenterManagerWrapper.get().isEnabled(context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle private profile case
|
||||
UserManager userManager = UserManager.get(context);
|
||||
if (android.os.Flags.allowPrivateProfile()
|
||||
&& android.multiuser.Flags.enablePrivateSpaceFeatures()
|
||||
&& userManager.isPrivateProfile()) {
|
||||
// SC always expects a response from the source if the broadcast has been sent for this
|
||||
// source, therefore, we need to send a null SafetySourceData.
|
||||
SafetyCenterManagerWrapper.get()
|
||||
.setSafetySourceData(
|
||||
context, SAFETY_SOURCE_ID, /* safetySourceData= */ null, safetyEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
UserHandle userHandle = Process.myUserHandle();
|
||||
int userId = userHandle.getIdentifier();
|
||||
FaceManager faceManager = Utils.getFaceManagerOrNull(context);
|
||||
FaceStatusUtils faceStatusUtils = new FaceStatusUtils(context, faceManager, userId);
|
||||
BiometricNavigationUtils biometricNavigationUtils = new BiometricNavigationUtils(userId);
|
||||
UserHandle profileParentUserHandle = userManager.getProfileParent(userHandle);
|
||||
if (profileParentUserHandle == null) {
|
||||
profileParentUserHandle = userHandle;
|
||||
}
|
||||
Context profileParentContext = context.createContextAsUser(profileParentUserHandle, 0);
|
||||
|
||||
if (Utils.hasFaceHardware(context)) {
|
||||
RestrictedLockUtils.EnforcedAdmin disablingAdmin = faceStatusUtils.getDisablingAdmin();
|
||||
BiometricSourcesUtils.setBiometricSafetySourceData(
|
||||
SAFETY_SOURCE_ID,
|
||||
context,
|
||||
faceStatusUtils.getTitle(),
|
||||
faceStatusUtils.getSummary(),
|
||||
BiometricSourcesUtils.createPendingIntent(
|
||||
profileParentContext,
|
||||
biometricNavigationUtils
|
||||
.getBiometricSettingsIntent(
|
||||
context,
|
||||
faceStatusUtils.getSettingsClassName(),
|
||||
disablingAdmin,
|
||||
Bundle.EMPTY)
|
||||
.setIdentifier(Integer.toString(userId)),
|
||||
REQUEST_CODE_FACE_SETTING),
|
||||
disablingAdmin == null /* enabled */,
|
||||
faceStatusUtils.hasEnrolled(),
|
||||
safetyEvent);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
SafetyCenterManagerWrapper.get()
|
||||
.setSafetySourceData(
|
||||
context, SAFETY_SOURCE_ID, /* safetySourceData= */ null, safetyEvent);
|
||||
}
|
||||
|
||||
/** Notifies Safety Center of a change in face biometrics settings. */
|
||||
public static void onBiometricsChanged(Context context) {
|
||||
setSafetySourceData(
|
||||
context,
|
||||
new SafetyEvent.Builder(SafetyEvent.SAFETY_EVENT_TYPE_SOURCE_STATE_CHANGED)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright (C) 2025 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.safetycenter;
|
||||
|
||||
import static com.android.settings.safetycenter.BiometricSourcesUtils.REQUEST_CODE_FINGERPRINT_SETTING;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.safetycenter.SafetyEvent;
|
||||
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.biometrics.BiometricNavigationUtils;
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintStatusUtils;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
|
||||
/** Fingerprint biometrics Safety Source for Safety Center. */
|
||||
public final class FingerprintSafetySource {
|
||||
|
||||
public static final String SAFETY_SOURCE_ID = "AndroidFingerprintUnlock";
|
||||
|
||||
private FingerprintSafetySource() {}
|
||||
|
||||
/** Sets biometric safety data for Safety Center. */
|
||||
public static void setSafetySourceData(Context context, SafetyEvent safetyEvent) {
|
||||
if (!SafetyCenterManagerWrapper.get().isEnabled(context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle private profile case
|
||||
UserManager userManager = UserManager.get(context);
|
||||
if (android.os.Flags.allowPrivateProfile()
|
||||
&& android.multiuser.Flags.enablePrivateSpaceFeatures()
|
||||
&& userManager.isPrivateProfile()) {
|
||||
// SC always expects a response from the source if the broadcast has been sent for this
|
||||
// source, therefore, we need to send a null SafetySourceData.
|
||||
SafetyCenterManagerWrapper.get()
|
||||
.setSafetySourceData(
|
||||
context, SAFETY_SOURCE_ID, /* safetySourceData= */ null, safetyEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
UserHandle userHandle = Process.myUserHandle();
|
||||
int userId = userHandle.getIdentifier();
|
||||
FingerprintManager fingerprintManager = Utils.getFingerprintManagerOrNull(context);
|
||||
FingerprintStatusUtils fingerprintStatusUtils =
|
||||
new FingerprintStatusUtils(context, fingerprintManager, userId);
|
||||
BiometricNavigationUtils biometricNavigationUtils = new BiometricNavigationUtils(userId);
|
||||
UserHandle profileParentUserHandle = userManager.getProfileParent(userHandle);
|
||||
if (profileParentUserHandle == null) {
|
||||
profileParentUserHandle = userHandle;
|
||||
}
|
||||
Context profileParentContext = context.createContextAsUser(profileParentUserHandle, 0);
|
||||
|
||||
if (Utils.hasFingerprintHardware(context)) {
|
||||
RestrictedLockUtils.EnforcedAdmin disablingAdmin =
|
||||
fingerprintStatusUtils.getDisablingAdmin();
|
||||
BiometricSourcesUtils.setBiometricSafetySourceData(
|
||||
SAFETY_SOURCE_ID,
|
||||
context,
|
||||
fingerprintStatusUtils.getTitle(),
|
||||
fingerprintStatusUtils.getSummary(),
|
||||
BiometricSourcesUtils.createPendingIntent(
|
||||
profileParentContext,
|
||||
biometricNavigationUtils
|
||||
.getBiometricSettingsIntent(
|
||||
context,
|
||||
fingerprintStatusUtils.getSettingsClassName(),
|
||||
disablingAdmin,
|
||||
Bundle.EMPTY)
|
||||
.setIdentifier(Integer.toString(userId)),
|
||||
REQUEST_CODE_FINGERPRINT_SETTING),
|
||||
disablingAdmin == null /* enabled */,
|
||||
fingerprintStatusUtils.hasEnrolled(),
|
||||
safetyEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
SafetyCenterManagerWrapper.get()
|
||||
.setSafetySourceData(
|
||||
context, SAFETY_SOURCE_ID, /* safetySourceData= */ null, safetyEvent);
|
||||
}
|
||||
|
||||
/** Notifies Safety Center of a change in fingerprint biometrics settings. */
|
||||
public static void onBiometricsChanged(Context context) {
|
||||
setSafetySourceData(
|
||||
context,
|
||||
new SafetyEvent.Builder(SafetyEvent.SAFETY_EVENT_TYPE_SOURCE_STATE_CHANGED)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import android.safetycenter.SafetySourceStatus;
|
||||
import android.safetycenter.SafetySourceStatus.IconAction;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.security.ScreenLockPreferenceDetailsUtils;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
@@ -122,7 +123,12 @@ public final class LockScreenSafetySource {
|
||||
|
||||
// Also send refreshed safety center data for biometrics, since changing lockscreen settings
|
||||
// can unset biometrics.
|
||||
BiometricsSafetySource.onBiometricsChanged(context);
|
||||
if (Flags.biometricsOnboardingEducation()) {
|
||||
FaceSafetySource.onBiometricsChanged(context);
|
||||
FingerprintSafetySource.onBiometricsChanged(context);
|
||||
} else {
|
||||
BiometricsSafetySource.onBiometricsChanged(context);
|
||||
}
|
||||
}
|
||||
|
||||
private static IconAction createGearMenuIconAction(
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.content.Intent;
|
||||
import android.safetycenter.SafetyCenterManager;
|
||||
import android.safetycenter.SafetyEvent;
|
||||
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.privatespace.PrivateSpaceSafetySource;
|
||||
import com.android.settings.security.ScreenLockPreferenceDetailsUtils;
|
||||
|
||||
@@ -48,48 +49,60 @@ public class SafetySourceBroadcastReceiver extends BroadcastReceiver {
|
||||
}
|
||||
|
||||
if (ACTION_REFRESH_SAFETY_SOURCES.equals(intent.getAction())) {
|
||||
String[] sourceIdsExtra =
|
||||
intent.getStringArrayExtra(EXTRA_REFRESH_SAFETY_SOURCE_IDS);
|
||||
final String refreshBroadcastId = intent.getStringExtra(
|
||||
SafetyCenterManager.EXTRA_REFRESH_SAFETY_SOURCES_BROADCAST_ID);
|
||||
String[] sourceIdsExtra = intent.getStringArrayExtra(EXTRA_REFRESH_SAFETY_SOURCE_IDS);
|
||||
final String refreshBroadcastId =
|
||||
intent.getStringExtra(
|
||||
SafetyCenterManager.EXTRA_REFRESH_SAFETY_SOURCES_BROADCAST_ID);
|
||||
if (sourceIdsExtra != null && sourceIdsExtra.length > 0 && refreshBroadcastId != null) {
|
||||
final SafetyEvent safetyEvent = new SafetyEvent.Builder(
|
||||
SAFETY_EVENT_TYPE_REFRESH_REQUESTED)
|
||||
.setRefreshBroadcastId(refreshBroadcastId).build();
|
||||
refreshSafetySources(
|
||||
context,
|
||||
ImmutableList.copyOf(sourceIdsExtra),
|
||||
safetyEvent);
|
||||
final SafetyEvent safetyEvent =
|
||||
new SafetyEvent.Builder(SAFETY_EVENT_TYPE_REFRESH_REQUESTED)
|
||||
.setRefreshBroadcastId(refreshBroadcastId)
|
||||
.build();
|
||||
refreshSafetySources(context, ImmutableList.copyOf(sourceIdsExtra), safetyEvent);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
|
||||
refreshAllSafetySources(context, EVENT_DEVICE_REBOOTED);
|
||||
}
|
||||
}
|
||||
|
||||
private static void refreshSafetySources(Context context, List<String> sourceIds,
|
||||
SafetyEvent safetyEvent) {
|
||||
private static void refreshSafetySources(
|
||||
Context context, List<String> sourceIds, SafetyEvent safetyEvent) {
|
||||
if (sourceIds.contains(LockScreenSafetySource.SAFETY_SOURCE_ID)) {
|
||||
LockScreenSafetySource.setSafetySourceData(context,
|
||||
new ScreenLockPreferenceDetailsUtils(context), safetyEvent);
|
||||
LockScreenSafetySource.setSafetySourceData(
|
||||
context, new ScreenLockPreferenceDetailsUtils(context), safetyEvent);
|
||||
}
|
||||
|
||||
if (sourceIds.contains(BiometricsSafetySource.SAFETY_SOURCE_ID)) {
|
||||
if (sourceIds.contains(BiometricsSafetySource.SAFETY_SOURCE_ID)
|
||||
&& !Flags.biometricsOnboardingEducation()) {
|
||||
BiometricsSafetySource.setSafetySourceData(context, safetyEvent);
|
||||
}
|
||||
|
||||
if (sourceIds.contains(PrivateSpaceSafetySource.SAFETY_SOURCE_ID)) {
|
||||
PrivateSpaceSafetySource.setSafetySourceData(context, safetyEvent);
|
||||
}
|
||||
if (sourceIds.contains(FaceSafetySource.SAFETY_SOURCE_ID)
|
||||
&& Flags.biometricsOnboardingEducation()) {
|
||||
FaceSafetySource.setSafetySourceData(context, safetyEvent);
|
||||
}
|
||||
if (sourceIds.contains(FingerprintSafetySource.SAFETY_SOURCE_ID)
|
||||
&& Flags.biometricsOnboardingEducation()) {
|
||||
FingerprintSafetySource.setSafetySourceData(context, safetyEvent);
|
||||
}
|
||||
}
|
||||
|
||||
private static void refreshAllSafetySources(Context context, SafetyEvent safetyEvent) {
|
||||
LockScreenSafetySource.setSafetySourceData(context,
|
||||
new ScreenLockPreferenceDetailsUtils(context), safetyEvent);
|
||||
BiometricsSafetySource.setSafetySourceData(context, safetyEvent);
|
||||
LockScreenSafetySource.setSafetySourceData(
|
||||
context, new ScreenLockPreferenceDetailsUtils(context), safetyEvent);
|
||||
if (!Flags.biometricsOnboardingEducation()) {
|
||||
BiometricsSafetySource.setSafetySourceData(context, safetyEvent);
|
||||
}
|
||||
PrivateSpaceSafetySource.setSafetySourceData(context, safetyEvent);
|
||||
if (Flags.biometricsOnboardingEducation()) {
|
||||
FaceSafetySource.setSafetySourceData(context, safetyEvent);
|
||||
FingerprintSafetySource.setSafetySourceData(context, safetyEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user