Merge "Destroy() client after onClientFinished." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f5704ec276
@@ -206,7 +206,6 @@ public abstract class BaseClientMonitor extends LoggableMonitor
|
|||||||
}
|
}
|
||||||
mToken = null;
|
mToken = null;
|
||||||
}
|
}
|
||||||
mListener = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -295,6 +295,7 @@ public class BiometricScheduler {
|
|||||||
@Override
|
@Override
|
||||||
public void onClientFinished(@NonNull BaseClientMonitor clientMonitor, boolean success) {
|
public void onClientFinished(@NonNull BaseClientMonitor clientMonitor, boolean success) {
|
||||||
mHandler.post(() -> {
|
mHandler.post(() -> {
|
||||||
|
clientMonitor.destroy();
|
||||||
if (mCurrentOperation == null) {
|
if (mCurrentOperation == null) {
|
||||||
Slog.e(getTag(), "[Finishing] " + clientMonitor
|
Slog.e(getTag(), "[Finishing] " + clientMonitor
|
||||||
+ " but current operation is null, success: " + success
|
+ " but current operation is null, success: " + success
|
||||||
|
|||||||
@@ -348,6 +348,17 @@ public class BiometricSchedulerTest {
|
|||||||
verify((Interruptable) interruptableMonitor, never()).cancel();
|
verify((Interruptable) interruptableMonitor, never()).cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testClientDestroyed_afterFinish() {
|
||||||
|
final HalClientMonitor.LazyDaemon<Object> nonNullDaemon = () -> mock(Object.class);
|
||||||
|
final TestClientMonitor client =
|
||||||
|
new TestClientMonitor(mContext, mToken, nonNullDaemon);
|
||||||
|
mScheduler.scheduleClientMonitor(client);
|
||||||
|
client.mCallback.onClientFinished(client, true /* success */);
|
||||||
|
waitForIdle();
|
||||||
|
assertTrue(client.wasDestroyed());
|
||||||
|
}
|
||||||
|
|
||||||
private BiometricSchedulerProto getDump(boolean clearSchedulerBuffer) throws Exception {
|
private BiometricSchedulerProto getDump(boolean clearSchedulerBuffer) throws Exception {
|
||||||
return BiometricSchedulerProto.parseFrom(mScheduler.dumpProtoState(clearSchedulerBuffer));
|
return BiometricSchedulerProto.parseFrom(mScheduler.dumpProtoState(clearSchedulerBuffer));
|
||||||
}
|
}
|
||||||
@@ -437,6 +448,7 @@ public class BiometricSchedulerTest {
|
|||||||
private static class TestClientMonitor extends HalClientMonitor<Object> {
|
private static class TestClientMonitor extends HalClientMonitor<Object> {
|
||||||
private boolean mUnableToStart;
|
private boolean mUnableToStart;
|
||||||
private boolean mStarted;
|
private boolean mStarted;
|
||||||
|
private boolean mDestroyed;
|
||||||
|
|
||||||
public TestClientMonitor(@NonNull Context context, @NonNull IBinder token,
|
public TestClientMonitor(@NonNull Context context, @NonNull IBinder token,
|
||||||
@NonNull LazyDaemon<Object> lazyDaemon) {
|
@NonNull LazyDaemon<Object> lazyDaemon) {
|
||||||
@@ -475,6 +487,11 @@ public class BiometricSchedulerTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
mDestroyed = true;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean wasUnableToStart() {
|
public boolean wasUnableToStart() {
|
||||||
return mUnableToStart;
|
return mUnableToStart;
|
||||||
}
|
}
|
||||||
@@ -482,6 +499,11 @@ public class BiometricSchedulerTest {
|
|||||||
public boolean hasStarted() {
|
public boolean hasStarted() {
|
||||||
return mStarted;
|
return mStarted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean wasDestroyed() {
|
||||||
|
return mDestroyed;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void waitForIdle() {
|
private static void waitForIdle() {
|
||||||
|
|||||||
Reference in New Issue
Block a user