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

Commit 4130c6d4 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

27/n: Slightly update/fix ClientMonitor.FinishCallback

1) Adds "success" parameter so callers can know if the operation
   succeeded. This can be used for operations like remove, where
   the authenticatorId needs to be updated when all templates are
   remove.
2) Moves ClientMonitor#stopHalOperation to AcquisitionClient, since
   AcquisitionClient (and its subclasses Enroll/Auth) are the only
   cancellable tasks.

Bug: 157790417

Test: Builds
Change-Id: Idaffc65f491dcdff2aacb4934b7d1cfa89807a79
parent 40983d08
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -47,6 +47,11 @@ public abstract class AcquisitionClient<T> extends ClientMonitor<T>
    private final VibrationEffect mSuccessVibrationEffect;
    private final VibrationEffect mErrorVibrationEffect;

    /**
     * Stops the HAL operation specific to the ClientMonitor subclass.
     */
    protected abstract void stopHalOperation();

    AcquisitionClient(@NonNull Context context, @NonNull LazyDaemon<T> lazyDaemon,
            @NonNull IBinder token, @NonNull ClientMonitorCallbackConverter listener, int userId,
            @NonNull String owner, int cookie, int sensorId, int statsModality,
@@ -78,7 +83,7 @@ public abstract class AcquisitionClient<T> extends ClientMonitor<T>
        } catch (RemoteException e) {
            Slog.w(TAG, "Failed to invoke sendError", e);
        }
        mFinishCallback.onClientFinished(this);
        mFinishCallback.onClientFinished(this, false /* success */);
    }

    /**
@@ -110,7 +115,7 @@ public abstract class AcquisitionClient<T> extends ClientMonitor<T>
            }
        } catch (RemoteException e) {
            Slog.w(TAG, "Failed to invoke sendAcquired", e);
            mFinishCallback.onClientFinished(this);
            mFinishCallback.onClientFinished(this, false /* success */);
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -180,7 +180,7 @@ public abstract class AuthenticationClient<T> extends AcquisitionClient<T> {
            }
        } catch (RemoteException e) {
            Slog.e(TAG, "Unable to notify listener, finishing", e);
            mFinishCallback.onClientFinished(this);
            mFinishCallback.onClientFinished(this, false /* success */);
        }
    }

+2 −1
Original line number Diff line number Diff line
@@ -102,7 +102,8 @@ public abstract class BiometricServiceBase<T> extends SystemService
        }
    };

    protected final ClientMonitor.FinishCallback mClientFinishCallback = clientMonitor -> {
    protected final ClientMonitor.FinishCallback mClientFinishCallback =
            (clientMonitor, success) -> {
        if (clientMonitor instanceof RemovalConsumer) {
            // When the last biometric of a group is removed, update the authenticator id.
            // Note that 1) multiple ClientMonitors may be cause onRemoved (e.g. internal cleanup),
+2 −6
Original line number Diff line number Diff line
@@ -47,8 +47,9 @@ public abstract class ClientMonitor<T> extends LoggableMonitor implements IBinde
         * implementation.
         *
         * @param clientMonitor Reference of the ClientMonitor that finished.
         * @param success True if the operation completed successfully.
         */
        void onClientFinished(ClientMonitor clientMonitor);
        void onClientFinished(ClientMonitor clientMonitor, boolean success);
    }

    /**
@@ -137,11 +138,6 @@ public abstract class ClientMonitor<T> extends LoggableMonitor implements IBinde
     */
    protected abstract void startHalOperation();

    /**
     * Stops the HAL operation specific to the ClientMonitor subclass.
     */
    protected abstract void stopHalOperation();

    public boolean isAlreadyDone() {
        return mAlreadyDone;
    }
+2 −6
Original line number Diff line number Diff line
@@ -53,14 +53,10 @@ public abstract class GenerateChallengeClient<T> extends ClientMonitor<T> {
        startHalOperation();
        try {
            getListener().onChallengeGenerated(mChallenge);
            mFinishCallback.onClientFinished(this, true /* success */);
        } catch (RemoteException e) {
            Slog.e(TAG, "Remote exception", e);
            mFinishCallback.onClientFinished(this, false /* success */);
        }
        mFinishCallback.onClientFinished(this);
    }

    @Override
    protected void stopHalOperation() {
        // Not supported for GenerateChallenge
    }
}
Loading