Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7c3559d3 authored by Shawn Lin's avatar Shawn Lin
Browse files

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
parent e06acaab
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
/*
 * 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.biometrics;

import android.safetycenter.SafetySourceIssue;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public interface BiometricsFeatureProvider {

    /** Returns a SafetySourceIssue for biometrics. */
    @Nullable
    SafetySourceIssue getSafetySourceIssue(@NonNull String sourceId);

    /** Notifies that the action of an issue is launched */
    void notifySafetyIssueActionLaunched();
}
+33 −0
Original line number Diff line number Diff line
/*
 * 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.biometrics;

import android.safetycenter.SafetySourceIssue;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class BiometricsFeatureProviderImpl implements BiometricsFeatureProvider {
    @Nullable
    @Override
    public SafetySourceIssue getSafetySourceIssue(@NonNull String sourceId) {
        return null;
    }

    @Override
    public void notifySafetyIssueActionLaunched() {}
}
+6 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import com.android.settings.accessibility.AccessibilityMetricsFeatureProvider
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider
import com.android.settings.accounts.AccountFeatureProvider
import com.android.settings.applications.ApplicationFeatureProvider
import com.android.settings.biometrics.BiometricsFeatureProvider
import com.android.settings.biometrics.face.FaceFeatureProvider
import com.android.settings.biometrics.fingerprint.FingerprintFeatureProvider
import com.android.settings.bluetooth.BluetoothFeatureProvider
@@ -107,6 +108,11 @@ abstract class FeatureFactory {
     */
    abstract val bluetoothFeatureProvider: BluetoothFeatureProvider

    /**
     * Retrieves implementation for Biometrics feature.
     */
    abstract val biometricsFeatureProvider: BiometricsFeatureProvider

    /**
     * Retrieves implementation for Face feature.
     */
+6 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import com.android.settings.accessibility.AccessibilitySearchFeatureProviderImpl
import com.android.settings.accounts.AccountFeatureProvider
import com.android.settings.accounts.AccountFeatureProviderImpl
import com.android.settings.applications.ApplicationFeatureProviderImpl
import com.android.settings.biometrics.BiometricsFeatureProvider
import com.android.settings.biometrics.BiometricsFeatureProviderImpl
import com.android.settings.biometrics.face.FaceFeatureProvider
import com.android.settings.biometrics.face.FaceFeatureProviderImpl
import com.android.settings.biometrics.fingerprint.FingerprintFeatureProvider
@@ -145,6 +147,10 @@ open class FeatureFactoryImpl : FeatureFactory() {
        BluetoothFeatureProviderImpl()
    }

    override val biometricsFeatureProvider: BiometricsFeatureProvider by lazy {
        BiometricsFeatureProviderImpl()
    }

    override val faceFeatureProvider: FaceFeatureProvider by lazy { FaceFeatureProviderImpl() }

    override val fingerprintFeatureProvider: FingerprintFeatureProvider by lazy {
+32 −2
Original line number Diff line number Diff line
@@ -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);
Loading