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

Commit 64362b9d authored by Diya Bera's avatar Diya Bera
Browse files

Removed Interruptable interface.

Added a method instead of the interface.

Test: atest BiometricSchedulerTest
Fixes: 243445002
Change-Id: I71abbebd1513058ef41771bfd82e7f6a2700eed2
parent 9951b551
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -38,8 +38,7 @@ import java.util.function.Supplier;
 * Abstract {@link HalClientMonitor} subclass that operations eligible/interested in acquisition
 * Abstract {@link HalClientMonitor} subclass that operations eligible/interested in acquisition
 * messages should extend.
 * messages should extend.
 */
 */
public abstract class AcquisitionClient<T> extends HalClientMonitor<T> implements Interruptable,
public abstract class AcquisitionClient<T> extends HalClientMonitor<T> implements ErrorConsumer {
        ErrorConsumer {


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


@@ -217,4 +216,9 @@ public abstract class AcquisitionClient<T> extends HalClientMonitor<T> implement
                    HARDWARE_FEEDBACK_VIBRATION_ATTRIBUTES);
                    HARDWARE_FEEDBACK_VIBRATION_ATTRIBUTES);
        }
        }
    }
    }

    @Override
    public boolean isInterruptable() {
        return true;
    }
}
}
+10 −2
Original line number Original line Diff line number Diff line
@@ -193,9 +193,9 @@ public abstract class BaseClientMonitor implements IBinder.DeathRecipient {
        }
        }


        // If the current client dies we should cancel the current operation.
        // If the current client dies we should cancel the current operation.
        if (this instanceof Interruptable) {
        if (this.isInterruptable()) {
            Slog.e(TAG, "Binder died, cancelling client");
            Slog.e(TAG, "Binder died, cancelling client");
            ((Interruptable) this).cancel();
            this.cancel();
        }
        }
        mToken = null;
        mToken = null;
        if (clearListener) {
        if (clearListener) {
@@ -320,4 +320,12 @@ public abstract class BaseClientMonitor implements IBinder.DeathRecipient {
        }
        }
        callback.onClientFinished(this, true /* success */);
        callback.onClientFinished(this, true /* success */);
    }
    }

    /**
     * Checks if other client monitor can interrupt current client monitor
     * @return if current client can be interrupted
     */
    public boolean isInterruptable() {
        return false;
    }
}
}
+3 −3
Original line number Original line Diff line number Diff line
@@ -46,7 +46,7 @@ public class BiometricSchedulerOperation {


    /**
    /**
     * The operation is added to the list of pending operations, but a subsequent operation
     * The operation is added to the list of pending operations, but a subsequent operation
     * has been added. This state only applies to {@link Interruptable} operations. When this
     * has been added. This state only applies to interruptable operations. When this
     * operation reaches the head of the queue, it will send ERROR_CANCELED and finish.
     * operation reaches the head of the queue, it will send ERROR_CANCELED and finish.
     */
     */
    protected static final int STATE_WAITING_IN_QUEUE_CANCELING = 1;
    protected static final int STATE_WAITING_IN_QUEUE_CANCELING = 1;
@@ -347,9 +347,9 @@ public class BiometricSchedulerOperation {
        return mClientMonitor == clientMonitor;
        return mClientMonitor == clientMonitor;
    }
    }


    /** If this operation is {@link Interruptable}. */
    /** If this operation is interruptable. */
    public boolean isInterruptable() {
    public boolean isInterruptable() {
        return mClientMonitor instanceof Interruptable;
        return mClientMonitor.isInterruptable();
    }
    }


    private boolean isHalOperation() {
    private boolean isHalOperation() {
+0 −43
Original line number Original line 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;

import android.annotation.NonNull;

/**
 * Interface that {@link BaseClientMonitor} subclasses eligible for cancellation should implement.
 */
public interface Interruptable {
    /**
     * Requests to end the ClientMonitor's lifecycle.
     */
    void cancel();

    /**
     * Notifies the client that it needs to finish before
     * {@link BaseClientMonitor#start(ClientMonitorCallback)} was invoked. This usually happens
     * if the client is still waiting in the pending queue and got notified that a subsequent
     * operation is preempting it.
     *
     * This method must invoke
     * {@link ClientMonitorCallback#onClientFinished(BaseClientMonitor, boolean)} on the
     * given callback (with success).
     *
     * @param callback invoked when the operation is completed.
     */
    void cancelWithoutStarting(@NonNull ClientMonitorCallback callback);
}
+1 −2
Original line number Original line Diff line number Diff line
@@ -59,7 +59,6 @@ import com.android.server.biometrics.sensors.BaseClientMonitor;
import com.android.server.biometrics.sensors.BiometricScheduler;
import com.android.server.biometrics.sensors.BiometricScheduler;
import com.android.server.biometrics.sensors.EnumerateConsumer;
import com.android.server.biometrics.sensors.EnumerateConsumer;
import com.android.server.biometrics.sensors.ErrorConsumer;
import com.android.server.biometrics.sensors.ErrorConsumer;
import com.android.server.biometrics.sensors.Interruptable;
import com.android.server.biometrics.sensors.LockoutCache;
import com.android.server.biometrics.sensors.LockoutCache;
import com.android.server.biometrics.sensors.LockoutConsumer;
import com.android.server.biometrics.sensors.LockoutConsumer;
import com.android.server.biometrics.sensors.LockoutResetDispatcher;
import com.android.server.biometrics.sensors.LockoutResetDispatcher;
@@ -638,7 +637,7 @@ public class Sensor {


    public void onBinderDied() {
    public void onBinderDied() {
        final BaseClientMonitor client = mScheduler.getCurrentClient();
        final BaseClientMonitor client = mScheduler.getCurrentClient();
        if (client instanceof Interruptable) {
        if (client.isInterruptable()) {
            Slog.e(mTag, "Sending ERROR_HW_UNAVAILABLE for client: " + client);
            Slog.e(mTag, "Sending ERROR_HW_UNAVAILABLE for client: " + client);
            final ErrorConsumer errorConsumer = (ErrorConsumer) client;
            final ErrorConsumer errorConsumer = (ErrorConsumer) client;
            errorConsumer.onError(FaceManager.FACE_ERROR_HW_UNAVAILABLE,
            errorConsumer.onError(FaceManager.FACE_ERROR_HW_UNAVAILABLE,
Loading