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

Commit 0f9da353 authored by Ilya Matyukhin's avatar Ilya Matyukhin
Browse files

Remove strings from low level onError(...) calls

In order to get a correctly translated error messages, getString(...)
should be called on the application context, as opposed to the system
context. This is because the system context is unaware of the user's
locale.

Bug: 141025588
Test: Face Unlock works E2E
Test: Works with BiometricPromptDemo
Test: atest BiometricServiceTest
Test: atest AuthControllerTest
Test: atest CommandQueueTest

Change-Id: Ic228bb7ebb0d6a4ebaf96b9f1d2d70ed4e9dd79a
parent f2da1a11
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -36,23 +36,30 @@ public interface BiometricAuthenticator {
     * @hide
     */
    int TYPE_NONE = 0;

    /**
     * Constant representing credential (PIN, pattern, or password).
     * @hide
     */
    int TYPE_CREDENTIAL = 1 << 0;

    /**
     * Constant representing fingerprint.
     * @hide
     */
    int TYPE_FINGERPRINT = 1 << 0;
    int TYPE_FINGERPRINT = 1 << 1;

    /**
     * Constant representing iris.
     * @hide
     */
    int TYPE_IRIS = 1 << 1;
    int TYPE_IRIS = 1 << 2;

    /**
     * Constant representing face.
     * @hide
     */
    int TYPE_FACE = 1 << 2;
    int TYPE_FACE = 1 << 3;

    /**
     * Container for biometric data
+7 −0
Original line number Diff line number Diff line
@@ -133,6 +133,13 @@ public interface BiometricConstants {
     */
    int BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL = 14;

    /**
     * This constant is only used by SystemUI. It notifies SystemUI that authentication was paused
     * because the authentication attempt was unsuccessful.
     * @hide
     */
    int BIOMETRIC_PAUSED_REJECTED = 100;

    /**
     * @hide
     */
+18 −2
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import android.annotation.RequiresPermission;
import android.app.KeyguardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.hardware.face.FaceManager;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Binder;
import android.os.Bundle;
import android.os.CancellationSignal;
@@ -339,9 +341,23 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
        }

        @Override
        public void onError(int error, String message) throws RemoteException {
        public void onError(int modality, int error, int vendorCode) throws RemoteException {
            mExecutor.execute(() -> {
                mAuthenticationCallback.onAuthenticationError(error, message);
                String errorMessage;
                switch (modality) {
                    case TYPE_FACE:
                        errorMessage = FaceManager.getErrorString(mContext, error, vendorCode);
                        break;

                    case TYPE_FINGERPRINT:
                        errorMessage = FingerprintManager.getErrorString(mContext, error,
                                vendorCode);
                        break;

                    default:
                        errorMessage = "";
                }
                mAuthenticationCallback.onAuthenticationError(error, errorMessage);
            });
        }

+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ oneway interface IBiometricServiceReceiver {
    // Noties that authentication failed.
    void onAuthenticationFailed();
    // Notify BiometricPrompt that an error has occurred.
    void onError(int error, String message);
    void onError(int modality, int error, int vendorCode);
    // Notifies that a biometric has been acquired.
    void onAcquired(int acquiredInfo, String message);
    // Notifies that the SystemUI dialog has been dismissed.
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ oneway interface IBiometricServiceReceiverInternal {
    void onAuthenticationFailed();
    // Notify BiometricService than an error has occured. Forward to the correct receiver depending
    // on the cookie.
    void onError(int cookie, int error, String message);
    void onError(int cookie, int modality, int error, int vendorCode);
    // Notifies that a biometric has been acquired.
    void onAcquired(int acquiredInfo, String message);
    // Notifies that the SystemUI dialog has been dismissed.
Loading