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

Commit 95ec6c02 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Pass operationId to LSS, add HAT to KeyStore" into rvc-dev am:...

Merge "Pass operationId to LSS, add HAT to KeyStore" into rvc-dev am: 6b7b2300 am: 02e3f9eb am: 8cb942f4

Change-Id: Iaffc2ea899ce5051b934d349934c4bd8818a3845
parents 979e8e60 8cb942f4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ oneway interface IBiometricServiceReceiverInternal {
    // Notifies that a biometric has been acquired.
    void onAcquired(int acquiredInfo, String message);
    // Notifies that the SystemUI dialog has been dismissed.
    void onDialogDismissed(int reason);
    void onDialogDismissed(int reason, in byte[] credentialAttestation);
    // Notifies that the user has pressed the "try again" button on SystemUI
    void onTryAgainPressed();
    // Notifies that the user has pressed the "use password" button on SystemUI
+2 −1
Original line number Diff line number Diff line
@@ -136,7 +136,8 @@ oneway interface IStatusBar

    // Used to show the authentication dialog (Biometrics, Device Credential)
    void showAuthenticationDialog(in Bundle bundle, IBiometricServiceReceiverInternal receiver,
            int biometricModality, boolean requireConfirmation, int userId, String opPackageName);
            int biometricModality, boolean requireConfirmation, int userId, String opPackageName,
            long operationId);
    // Used to notify the authentication dialog that a biometric has been authenticated
    void onBiometricAuthenticated();
    // Used to set a temporary message, e.g. fingerprint not recognized, finger moved too fast, etc
+2 −1
Original line number Diff line number Diff line
@@ -105,7 +105,8 @@ interface IStatusBarService

    // Used to show the authentication dialog (Biometrics, Device Credential)
    void showAuthenticationDialog(in Bundle bundle, IBiometricServiceReceiverInternal receiver,
            int biometricModality, boolean requireConfirmation, int userId, String opPackageName);
            int biometricModality, boolean requireConfirmation, int userId, String opPackageName,
            long operationId);
    // Used to notify the authentication dialog that a biometric has been authenticated
    void onBiometricAuthenticated();
    // Used to set a temporary message, e.g. fingerprint not recognized, finger moved too fast, etc
+12 −2
Original line number Diff line number Diff line
@@ -99,6 +99,8 @@ public class AuthContainerView extends LinearLayout

    // Non-null only if the dialog is in the act of dismissing and has not sent the reason yet.
    @Nullable @AuthDialogCallback.DismissedReason Integer mPendingCallbackReason;
    // HAT received from LockSettingsService when credential is verified.
    @Nullable byte[] mCredentialAttestation;

    static class Config {
        Context mContext;
@@ -109,6 +111,7 @@ public class AuthContainerView extends LinearLayout
        String mOpPackageName;
        int mModalityMask;
        boolean mSkipIntro;
        long mOperationId;
    }

    public static class Builder {
@@ -149,6 +152,11 @@ public class AuthContainerView extends LinearLayout
            return this;
        }

        public Builder setOperationId(long operationId) {
            mConfig.mOperationId = operationId;
            return this;
        }

        public AuthContainerView build(int modalityMask) {
            mConfig.mModalityMask = modalityMask;
            return new AuthContainerView(mConfig, new Injector());
@@ -224,7 +232,8 @@ public class AuthContainerView extends LinearLayout

    final class CredentialCallback implements AuthCredentialView.Callback {
        @Override
        public void onCredentialMatched() {
        public void onCredentialMatched(byte[] attestation) {
            mCredentialAttestation = attestation;
            animateAway(AuthDialogCallback.DISMISSED_CREDENTIAL_AUTHENTICATED);
        }
    }
@@ -341,6 +350,7 @@ public class AuthContainerView extends LinearLayout

        mCredentialView.setContainerView(this);
        mCredentialView.setUserId(mConfig.mUserId);
        mCredentialView.setOperationId(mConfig.mOperationId);
        mCredentialView.setEffectiveUserId(mEffectiveUserId);
        mCredentialView.setCredentialType(credentialType);
        mCredentialView.setCallback(mCredentialCallback);
@@ -558,7 +568,7 @@ public class AuthContainerView extends LinearLayout
    private void sendPendingCallbackIfNotNull() {
        Log.d(TAG, "pendingCallback: " + mPendingCallbackReason);
        if (mPendingCallbackReason != null) {
            mConfig.mCallback.onDismissed(mPendingCallbackReason);
            mConfig.mCallback.onDismissed(mPendingCallbackReason, mCredentialAttestation);
            mPendingCallbackReason = null;
        }
    }
+33 −16
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FACE;
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FINGERPRINT;
import static android.hardware.biometrics.BiometricManager.Authenticators;

import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityTaskManager;
import android.app.IActivityTaskManager;
@@ -99,7 +100,8 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,

                try {
                    if (mReceiver != null) {
                        mReceiver.onDialogDismissed(BiometricPrompt.DISMISSED_REASON_USER_CANCEL);
                        mReceiver.onDialogDismissed(BiometricPrompt.DISMISSED_REASON_USER_CANCEL,
                                null /* credentialAttestation */);
                        mReceiver = null;
                    }
                } catch (RemoteException e) {
@@ -124,7 +126,8 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
                        mCurrentDialog = null;
                        if (mReceiver != null) {
                            mReceiver.onDialogDismissed(
                                    BiometricPrompt.DISMISSED_REASON_USER_CANCEL);
                                    BiometricPrompt.DISMISSED_REASON_USER_CANCEL,
                                    null /* credentialAttestation */);
                            mReceiver = null;
                        }
                    }
@@ -162,35 +165,42 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
    }

    @Override
    public void onDismissed(@DismissedReason int reason) {
    public void onDismissed(@DismissedReason int reason, @Nullable byte[] credentialAttestation) {
        switch (reason) {
            case AuthDialogCallback.DISMISSED_USER_CANCELED:
                sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_USER_CANCEL);
                sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_USER_CANCEL,
                        credentialAttestation);
                break;

            case AuthDialogCallback.DISMISSED_BUTTON_NEGATIVE:
                sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_NEGATIVE);
                sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_NEGATIVE,
                        credentialAttestation);
                break;

            case AuthDialogCallback.DISMISSED_BUTTON_POSITIVE:
                sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_BIOMETRIC_CONFIRMED);
                sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_BIOMETRIC_CONFIRMED,
                        credentialAttestation);
                break;

            case AuthDialogCallback.DISMISSED_BIOMETRIC_AUTHENTICATED:
                sendResultAndCleanUp(
                        BiometricPrompt.DISMISSED_REASON_BIOMETRIC_CONFIRM_NOT_REQUIRED);
                        BiometricPrompt.DISMISSED_REASON_BIOMETRIC_CONFIRM_NOT_REQUIRED,
                        credentialAttestation);
                break;

            case AuthDialogCallback.DISMISSED_ERROR:
                sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_ERROR);
                sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_ERROR,
                        credentialAttestation);
                break;

            case AuthDialogCallback.DISMISSED_BY_SYSTEM_SERVER:
                sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_SERVER_REQUESTED);
                sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_SERVER_REQUESTED,
                        credentialAttestation);
                break;

            case AuthDialogCallback.DISMISSED_CREDENTIAL_AUTHENTICATED:
                sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_CREDENTIAL_CONFIRMED);
                sendResultAndCleanUp(BiometricPrompt.DISMISSED_REASON_CREDENTIAL_CONFIRMED,
                        credentialAttestation);
                break;

            default:
@@ -199,13 +209,14 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
        }
    }

    private void sendResultAndCleanUp(@DismissedReason int reason) {
    private void sendResultAndCleanUp(@DismissedReason int reason,
            @Nullable byte[] credentialAttestation) {
        if (mReceiver == null) {
            Log.e(TAG, "sendResultAndCleanUp: Receiver is null");
            return;
        }
        try {
            mReceiver.onDialogDismissed(reason);
            mReceiver.onDialogDismissed(reason, credentialAttestation);
        } catch (RemoteException e) {
            Log.w(TAG, "Remote exception", e);
        }
@@ -251,13 +262,15 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,

    @Override
    public void showAuthenticationDialog(Bundle bundle, IBiometricServiceReceiverInternal receiver,
            int biometricModality, boolean requireConfirmation, int userId, String opPackageName) {
            int biometricModality, boolean requireConfirmation, int userId, String opPackageName,
            long operationId) {
        final int authenticators = Utils.getAuthenticators(bundle);

        if (DEBUG) {
            Log.d(TAG, "showAuthenticationDialog, authenticators: " + authenticators
                    + ", biometricModality: " + biometricModality
                    + ", requireConfirmation: " + requireConfirmation);
                    + ", requireConfirmation: " + requireConfirmation
                    + ", operationId: " + operationId);
        }
        SomeArgs args = SomeArgs.obtain();
        args.arg1 = bundle;
@@ -266,6 +279,7 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
        args.arg3 = requireConfirmation;
        args.argi2 = userId;
        args.arg4 = opPackageName;
        args.arg5 = operationId;

        boolean skipAnimation = false;
        if (mCurrentDialog != null) {
@@ -354,6 +368,7 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
        final boolean requireConfirmation = (boolean) args.arg3;
        final int userId = args.argi2;
        final String opPackageName = (String) args.arg4;
        final long operationId = (long) args.arg5;

        // Create a new dialog but do not replace the current one yet.
        final AuthDialog newDialog = buildDialog(
@@ -362,7 +377,8 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
                userId,
                type,
                opPackageName,
                skipAnimation);
                skipAnimation,
                operationId);

        if (newDialog == null) {
            Log.e(TAG, "Unsupported type: " + type);
@@ -429,7 +445,7 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
    }

    protected AuthDialog buildDialog(Bundle biometricPromptBundle, boolean requireConfirmation,
            int userId, int type, String opPackageName, boolean skipIntro) {
            int userId, int type, String opPackageName, boolean skipIntro, long operationId) {
        return new AuthContainerView.Builder(mContext)
                .setCallback(this)
                .setBiometricPromptBundle(biometricPromptBundle)
@@ -437,6 +453,7 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
                .setUserId(userId)
                .setOpPackageName(opPackageName)
                .setSkipIntro(skipIntro)
                .setOperationId(operationId)
                .build(type);
    }
}
Loading