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

Commit d5aaa442 authored by Carlo Savignano's avatar Carlo Savignano Committed by Bruno Martins
Browse files

fingerprint: notify client when cancelling succeeded



* Some fingerprint hardware hals might not notify userspace in time
  in some scenarios when successful authentication cancel is performed.
* This is observed for example in some devices that have power and/or home
  buttons merged with fingerprint sensor, but not limited to such cases.
* Add a opt-in configuration to enable client authentication cancel from
  fingerprint service when successful.
* This addresses originally an issue where requesting fingerprint to be
  disabled and then enabled will wait till cancelling timeout before changing
  fingerprint sensor state and start authenticating again.

Change-Id: I6a6795fbb795f0c6a4ff8ad27ac807e2f744c2d9
Signed-off-by: default avatarCarlo Savignano <carlosavignano@aospa.co>
parent 0c700bb7
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -30,4 +30,7 @@
    <!-- The list of components which should be forced to be enabled. -->
    <string-array name="config_forceEnabledComponents" translatable="false">
    </string-array>

    <!-- Whether notify fingerprint client of successful cancelled authentication -->
    <bool name="config_notifyClientOnFingerprintCancelSuccess">false</bool>
</resources>
+3 −0
Original line number Diff line number Diff line
@@ -30,4 +30,7 @@
    <!-- Package Manager -->
    <java-symbol type="array" name="config_disabledComponents" />
    <java-symbol type="array" name="config_forceEnabledComponents" />

    <!-- Whether notify fingerprint client of successful cancelled authentication -->
    <java-symbol type="bool" name="config_notifyClientOnFingerprintCancelSuccess" />
</resources>
+8 −1
Original line number Diff line number Diff line
@@ -146,6 +146,7 @@ public class FingerprintService extends SystemService implements IHwBinder.Death
    private ClientMonitor mCurrentClient;
    private ClientMonitor mPendingClient;
    private PerformanceStats mPerformanceStats;
    private final boolean mNotifyClient;

    private IBinder mToken = new Binder(); // used for internal FingerprintService enumeration
    private ArrayList<UserFingerprint> mUnknownFingerprints = new ArrayList<>(); // hw fingerprints
@@ -261,6 +262,8 @@ public class FingerprintService extends SystemService implements IHwBinder.Death
                ServiceManager.getService(Context.STATUS_BAR_SERVICE));
        mActivityManager = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE))
                .getService();
        mNotifyClient = mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_notifyClientOnFingerprintCancelSuccess);
    }

    @Override
@@ -1223,7 +1226,11 @@ public class FingerprintService extends SystemService implements IHwBinder.Death
                    if (client instanceof AuthenticationClient) {
                        if (client.getToken() == token) {
                            if (DEBUG) Slog.v(TAG, "stop client " + client.getOwnerString());
                            client.stop(client.getToken() == token);
                            final int stopResult = client.stop(client.getToken() == token);
                            if (mNotifyClient && (stopResult == 0)) {
                                handleError(mHalDeviceId,
                                        FingerprintManager.FINGERPRINT_ERROR_CANCELED, 0);
                            }
                        } else {
                            if (DEBUG) Slog.v(TAG, "can't stop client "
                                    + client.getOwnerString() + " since tokens don't match");