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

Commit 9f09df69 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Add null checks in BiometricService

We should catch bad HAL states and log an errorinstead of potentially
letting SystemServer crash. e.g. HAL sends something up after user has
already canceled authentication.

Change-Id: Ibff5b56fbf3f584ae889ef70baeb4abba275ebc1
Fixes: 122119836
Test: manual
parent 6bb2077f
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -373,6 +373,13 @@ public class BiometricService extends SystemService {
            public void onAuthenticationSucceeded(boolean requireConfirmation, byte[] token)
                    throws RemoteException {
                try {
                    // Should never happen, log this to catch bad HAL behavior (e.g. auth succeeded
                    // after user dismissed/canceled dialog).
                    if (mCurrentAuthSession == null) {
                        Slog.e(TAG, "onAuthenticationSucceeded(): Auth session is null");
                        return;
                    }

                    if (!requireConfirmation) {
                        mActivityTaskManager.unregisterTaskStackListener(mTaskStackListener);
                        KeyStore.getInstance().addAuthToken(token);
@@ -398,6 +405,13 @@ public class BiometricService extends SystemService {
            public void onAuthenticationFailed(int cookie, boolean requireConfirmation)
                    throws RemoteException {
                try {
                    // Should never happen, log this to catch bad HAL behavior (e.g. auth succeeded
                    // after user dismissed/canceled dialog).
                    if (mCurrentAuthSession == null) {
                        Slog.e(TAG, "onAuthenticationFailed(): Auth session is null");
                        return;
                    }

                    mStatusBarService.onBiometricHelp(getContext().getResources().getString(
                            com.android.internal.R.string.biometric_not_recognized));
                    if (requireConfirmation) {
@@ -486,6 +500,13 @@ public class BiometricService extends SystemService {

            @Override
            public void onAcquired(int acquiredInfo, String message) throws RemoteException {
                // Should never happen, log this to catch bad HAL behavior (e.g. auth succeeded
                // after user dismissed/canceled dialog).
                if (mCurrentAuthSession == null) {
                    Slog.e(TAG, "onAcquired(): Auth session is null");
                    return;
                }

                if (acquiredInfo != BiometricConstants.BIOMETRIC_ACQUIRED_GOOD) {
                    try {
                        mStatusBarService.onBiometricHelp(message);