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

Commit 27fa2683 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

30/n: Combine ErrorConsumer and Cancellable

Cancellable requires the ability to receive errors, and the ability
to receive errors means it could be cancelled. Thus, these two are
basically the same "property".

Bug: 157790417
Test: Builds
Change-Id: I3f021bf7c96bd57e794b0b2142d831952047fe12
parent 099b44a9
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -32,8 +32,7 @@ import android.util.Slog;
 * Abstract {@link ClientMonitor} subclass that operations eligible/interested in acquisition
 * messages should extend.
 */
public abstract class AcquisitionClient<T> extends ClientMonitor<T>
        implements ErrorConsumer, Cancellable {
public abstract class AcquisitionClient<T> extends ClientMonitor<T> implements Interruptable {

    private static final String TAG = "Biometrics/AcquisitionClient";

+5 −6
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ import android.hardware.biometrics.BiometricConstants;
import android.hardware.biometrics.BiometricManager.Authenticators;
import android.hardware.biometrics.BiometricsProtoEnums;
import android.hardware.biometrics.IBiometricService;
import android.hardware.fingerprint.Fingerprint;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
@@ -387,13 +386,13 @@ public abstract class BiometricServiceBase<T> extends SystemService
        if (DEBUG) Slog.v(getTag(), "handleError(client="
                + (client != null ? client.getOwnerString() : "null") + ", error = " + error + ")");

        if (!(client instanceof ErrorConsumer)) {
        if (!(client instanceof Interruptable)) {
            Slog.e(getTag(), "error received for non-ErrorConsumer");
            return;
        }

        final ErrorConsumer errorConsumer = (ErrorConsumer) client;
        errorConsumer.onError(error, vendorCode);
        final Interruptable interruptable = (Interruptable) client;
        interruptable.onError(error, vendorCode);

        if (error == BiometricConstants.BIOMETRIC_ERROR_CANCELED) {
            mHandler.removeCallbacks(mResetClientState);
@@ -665,8 +664,8 @@ public abstract class BiometricServiceBase<T> extends SystemService
                            + "(" + newClient.getOwnerString() + ")"
                            + ", initiatedByClient = " + initiatedByClient);
                }
            } else if (currentClient instanceof Cancellable) {
                ((Cancellable) currentClient).cancel();
            } else if (currentClient instanceof Interruptable) {
                ((Interruptable) currentClient).cancel();

                // Only post the reset runnable for non-cleanup clients. Cleanup clients should
                // never be forcibly stopped since they ensure synchronization between HAL and
+0 −27
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.biometrics.sensors;

/**
 * Interface that cancellable {@link ClientMonitor} subclasses should implement.
 */
public interface Cancellable {
    /**
     * Requests to end the ClientMonitor's lifecycle.
     */
    void cancel();
}
+2 −2
Original line number Diff line number Diff line
@@ -163,9 +163,9 @@ public abstract class ClientMonitor<T> extends LoggableMonitor implements IBinde
    // TODO(b/157790417): Move this to the scheduler
    void binderDiedInternal(boolean clearListener) {
        // If the current client dies we should cancel the current operation.
        if (this instanceof Cancellable) {
        if (this instanceof Interruptable) {
            Slog.e(TAG, "Binder died, cancelling client");
            ((Cancellable) this).cancel();
            ((Interruptable) this).cancel();
        }
        mToken = null;
        if (clearListener) {
+6 −1
Original line number Diff line number Diff line
@@ -20,7 +20,12 @@ package com.android.server.biometrics.sensors;
 * Interface that {@link ClientMonitor} subclasses eligible/interested in error callbacks should
 * implement.
 */
public interface ErrorConsumer {
public interface Interruptable {
    /**
     * Requests to end the ClientMonitor's lifecycle.
     */
    void cancel();

    /**
     * @param errorCode defined by the HIDL interface
     * @param vendorCode defined by the vendor