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

Commit 56e4c3da authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Post a notification when ACQUIRED_RECALIBRATE is received

Fixes: 130898604

Test: Builds

Change-Id: Ic157f124d8c92a2a79294dffaacdb0c2e40f03e5
parent ca45c3a8
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1507,6 +1507,13 @@
    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. [CHAR LIMIT=90] -->
    <string name="permdesc_useFaceAuthentication">Allows the app to use face authentication hardware for authentication</string>

    <!-- Notification name shown when the system requires the user to re-enroll their face. [CHAR LIMIT=NONE] -->
    <string name="face_recalibrate_notification_name">Face Authentication</string>
    <!-- Notification title shown when the system requires the user to re-enroll their face. [CHAR LIMIT=NONE] -->
    <string name="face_recalibrate_notification_title">Re-enroll your face</string>
    <!-- Notification content shown when the system requires the user to re-enroll their face. [CHAR LIMIT=NONE] -->
    <string name="face_recalibrate_notification_content">To improve recognition, please re-enroll your face</string>

    <!-- Message shown during face acquisition when the face cannot be recognized [CHAR LIMIT=50] -->
    <string name="face_acquired_insufficient">Couldn\u2019t capture accurate face data. Try again.</string>
    <!-- Message shown during face acquisition when the image is too bright [CHAR LIMIT=50] -->
+3 −0
Original line number Diff line number Diff line
@@ -2530,6 +2530,9 @@
  <java-symbol type="bool" name="config_fingerprintSupportsGestures"/>

  <!-- Face authentication messages -->
  <java-symbol type="string" name="face_recalibrate_notification_name" />
  <java-symbol type="string" name="face_recalibrate_notification_title" />
  <java-symbol type="string" name="face_recalibrate_notification_content" />
  <java-symbol type="string" name="face_error_unable_to_process" />
  <java-symbol type="string" name="face_error_hw_not_available" />
  <java-symbol type="string" name="face_error_no_space" />
+49 −1
Original line number Diff line number Diff line
@@ -23,7 +23,12 @@ import static android.Manifest.permission.USE_BIOMETRIC_INTERNAL;

import android.app.ActivityManager;
import android.app.AppOpsManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.UserInfo;
import android.hardware.biometrics.BiometricAuthenticator;
import android.hardware.biometrics.BiometricConstants;
@@ -48,10 +53,10 @@ import android.os.SELinux;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.util.Slog;
import android.util.proto.ProtoOutputStream;

import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.util.DumpUtils;
@@ -124,6 +129,49 @@ public class FaceService extends BiometricServiceBase {
            // but let's leave it as-is for now.
            return result || !authenticated;
        }

        @Override
        public boolean onAcquired(int acquireInfo, int vendorCode) {

            if (acquireInfo == FaceManager.FACE_ACQUIRED_RECALIBRATE) {
                final String name =
                        getContext().getString(R.string.face_recalibrate_notification_name);
                final String title =
                        getContext().getString(R.string.face_recalibrate_notification_title);
                final String content =
                        getContext().getString(R.string.face_recalibrate_notification_content);

                final Intent intent = new Intent("android.settings.FACE_SETTINGS");
                intent.setPackage("com.android.settings");

                final PendingIntent pendingIntent = PendingIntent.getActivityAsUser(getContext(),
                        0 /* requestCode */, intent, 0 /* flags */, null /* options */,
                        UserHandle.CURRENT);

                final String id = "FaceService";

                NotificationManager nm =
                        getContext().getSystemService(NotificationManager.class);
                NotificationChannel channel = new NotificationChannel(id, name,
                        NotificationManager.IMPORTANCE_HIGH);
                Notification notification = new Notification.Builder(getContext(), id)
                        .setSmallIcon(R.drawable.ic_lock)
                        .setContentTitle(title)
                        .setContentText(content)
                        .setSubText(name)
                        .setOnlyAlertOnce(true)
                        .setLocalOnly(true)
                        .setAutoCancel(true)
                        .setCategory(Notification.CATEGORY_SYSTEM)
                        .setContentIntent(pendingIntent)
                        .build();

                nm.createNotificationChannel(channel);
                nm.notifyAsUser(null /* tag */, 0 /* id */, notification, UserHandle.CURRENT);
            }

            return super.onAcquired(acquireInfo, vendorCode);
        }
    }

    /**