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

Commit 4a31ee0a authored by Jim Miller's avatar Jim Miller Committed by Android Git Automerger
Browse files

am 091f0e5c: Make FingerprintService more tolerant of fingerprintd crashes.

* commit '091f0e5c':
  Make FingerprintService more tolerant of fingerprintd crashes.
parents 010b53c0 091f0e5c
Loading
Loading
Loading
Loading
+15 −16
Original line number Diff line number Diff line
@@ -123,20 +123,29 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
    public void binderDied() {
        Slog.v(TAG, "fingerprintd died");
        mDaemon = null;
        dispatchError(mHalDeviceId, FingerprintManager.FINGERPRINT_ERROR_HW_UNAVAILABLE);
    }

    public IFingerprintDaemon getFingerprintDaemon() {
        if (mDaemon == null) {
            mDaemon = IFingerprintDaemon.Stub.asInterface(ServiceManager.getService(FINGERPRINTD));
            if (mDaemon == null) {
                Slog.w(TAG, "fingerprind service not available");
            } else {
            if (mDaemon != null) {
                try {
                    mDaemon.asBinder().linkToDeath(this, 0);
                    mDaemon.init(mDaemonCallback);
                    mHalDeviceId = mDaemon.openHal();
                    if (mHalDeviceId != 0) {
                        updateActiveGroup(ActivityManager.getCurrentUser());
                    } else {
                        Slog.w(TAG, "Failed to open Fingerprint HAL!");
                        mDaemon = null;
                    }
                } catch (RemoteException e) {
                    Slog.w(TAG, "caught remote exception in linkToDeath: ", e);
                    mDaemon = null; // try again!
                    Slog.e(TAG, "Failed to open fingeprintd HAL", e);
                    mDaemon = null; // try again later!
                }
            } else {
                Slog.w(TAG, "fingerprint service not available");
            }
        }
        return mDaemon;
@@ -155,7 +164,6 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
    protected void dispatchRemoved(long deviceId, int fingerId, int groupId) {
        final ClientMonitor client = mRemoveClient;
        if (fingerId != 0) {
            ContentResolver res = mContext.getContentResolver();
            removeTemplateForUser(mRemoveClient, fingerId);
        }
        if (client != null && client.sendRemoved(fingerId, groupId)) {
@@ -813,15 +821,6 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
    public void onStart() {
        publishBinderService(Context.FINGERPRINT_SERVICE, new FingerprintServiceWrapper());
        IFingerprintDaemon daemon = getFingerprintDaemon();
        if (daemon != null) {
            try {
                daemon.init(mDaemonCallback);
                mHalDeviceId = daemon.openHal();
            	updateActiveGroup(ActivityManager.getCurrentUser());
            } catch (RemoteException e) {
                Slog.e(TAG, "Failed to open fingeprintd HAL", e);
            }
        }
        if (DEBUG) Slog.v(TAG, "Fingerprint HAL id: " + mHalDeviceId);
        listenForUserSwitches();
    }