Merge "Cancel acquisition client in scheduler" into udc-d1-dev am: aef8ccbfdc
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23680826 Change-Id: I5f4dfbb628ad8fd27958bdb72c80ec6e9990f8a9 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -210,4 +210,8 @@ public abstract class AcquisitionClient<T> extends HalClientMonitor<T> implement
|
|||||||
public boolean isInterruptable() {
|
public boolean isInterruptable() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAlreadyCancelled() {
|
||||||
|
return mAlreadyCancelled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -268,6 +268,14 @@ public class BiometricScheduler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mCurrentOperation.isAcquisitionOperation()) {
|
||||||
|
AcquisitionClient client = (AcquisitionClient) mCurrentOperation.getClientMonitor();
|
||||||
|
if (client.isAlreadyCancelled()) {
|
||||||
|
mCurrentOperation.cancel(mHandler, mInternalCallback);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mGestureAvailabilityDispatcher != null && mCurrentOperation.isAcquisitionOperation()) {
|
if (mGestureAvailabilityDispatcher != null && mCurrentOperation.isAcquisitionOperation()) {
|
||||||
mGestureAvailabilityDispatcher.markSensorActive(
|
mGestureAvailabilityDispatcher.markSensorActive(
|
||||||
mCurrentOperation.getSensorId(), true /* active */);
|
mCurrentOperation.getSensorId(), true /* active */);
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ package com.android.server.biometrics.sensors;
|
|||||||
import static android.hardware.biometrics.BiometricConstants.BIOMETRIC_ERROR_CANCELED;
|
import static android.hardware.biometrics.BiometricConstants.BIOMETRIC_ERROR_CANCELED;
|
||||||
import static android.hardware.biometrics.BiometricConstants.BIOMETRIC_SUCCESS;
|
import static android.hardware.biometrics.BiometricConstants.BIOMETRIC_SUCCESS;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertTrue;
|
import static junit.framework.Assert.assertTrue;
|
||||||
import static junit.framework.Assert.fail;
|
import static junit.framework.Assert.fail;
|
||||||
|
|
||||||
@@ -405,6 +407,59 @@ public class BiometricSchedulerTest {
|
|||||||
testCancelsEnrollWhenRequestId(10L, 20, false /* started */);
|
testCancelsEnrollWhenRequestId(10L, 20, false /* started */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCancelAuthenticationClientWithoutStarting() {
|
||||||
|
final Supplier<Object> lazyDaemon = () -> mock(Object.class);
|
||||||
|
final TestHalClientMonitor client1 = new TestHalClientMonitor(mContext, mToken, lazyDaemon);
|
||||||
|
final ClientMonitorCallbackConverter callback = mock(ClientMonitorCallbackConverter.class);
|
||||||
|
final TestAuthenticationClient client2 = new TestAuthenticationClient(mContext, lazyDaemon,
|
||||||
|
mToken, callback, mBiometricContext);
|
||||||
|
|
||||||
|
//Schedule authentication client to the pending queue
|
||||||
|
mScheduler.scheduleClientMonitor(client1);
|
||||||
|
mScheduler.scheduleClientMonitor(client2);
|
||||||
|
waitForIdle();
|
||||||
|
|
||||||
|
assertThat(mScheduler.getCurrentClient()).isEqualTo(client1);
|
||||||
|
|
||||||
|
client2.cancel();
|
||||||
|
waitForIdle();
|
||||||
|
|
||||||
|
assertThat(client2.isAlreadyCancelled()).isTrue();
|
||||||
|
|
||||||
|
client1.getCallback().onClientFinished(client1, false);
|
||||||
|
waitForIdle();
|
||||||
|
|
||||||
|
assertThat(mScheduler.getCurrentClient()).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCancelAuthenticationClientWithoutStarting_whenAppCrashes() {
|
||||||
|
final Supplier<Object> lazyDaemon = () -> mock(Object.class);
|
||||||
|
final TestHalClientMonitor client1 = new TestHalClientMonitor(mContext, mToken, lazyDaemon);
|
||||||
|
final ClientMonitorCallbackConverter callback = mock(ClientMonitorCallbackConverter.class);
|
||||||
|
final TestAuthenticationClient client2 = new TestAuthenticationClient(mContext, lazyDaemon,
|
||||||
|
mToken, callback, mBiometricContext);
|
||||||
|
|
||||||
|
//Schedule authentication client to the pending queue
|
||||||
|
mScheduler.scheduleClientMonitor(client1);
|
||||||
|
mScheduler.scheduleClientMonitor(client2);
|
||||||
|
waitForIdle();
|
||||||
|
|
||||||
|
assertThat(mScheduler.getCurrentClient()).isEqualTo(client1);
|
||||||
|
|
||||||
|
//App crashes
|
||||||
|
client2.binderDied();
|
||||||
|
waitForIdle();
|
||||||
|
|
||||||
|
assertThat(client2.isAlreadyCancelled()).isTrue();
|
||||||
|
|
||||||
|
client1.getCallback().onClientFinished(client1, false);
|
||||||
|
waitForIdle();
|
||||||
|
|
||||||
|
assertThat(mScheduler.getCurrentClient()).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
private void testCancelsEnrollWhenRequestId(@Nullable Long requestId, long cancelRequestId,
|
private void testCancelsEnrollWhenRequestId(@Nullable Long requestId, long cancelRequestId,
|
||||||
boolean started) {
|
boolean started) {
|
||||||
final Supplier<Object> lazyDaemon = () -> mock(Object.class);
|
final Supplier<Object> lazyDaemon = () -> mock(Object.class);
|
||||||
|
|||||||
Reference in New Issue
Block a user