Merge "Fix biometric context update problem." into udc-dev
This commit is contained in:
@@ -216,6 +216,10 @@ public final class BiometricContextProvider implements BiometricContext {
|
||||
public void subscribe(@NonNull OperationContextExt context,
|
||||
@NonNull Consumer<OperationContext> consumer) {
|
||||
mSubscribers.put(context, consumer);
|
||||
// TODO(b/294161627) Combine the getContext/subscribe APIs to avoid race
|
||||
if (context.getDisplayState() != getDisplayState()) {
|
||||
consumer.accept(context.update(this, context.isCrypto()).toAidlContext());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -251,6 +251,14 @@ public class BiometricContextProviderTest {
|
||||
assertThat(actual).containsExactly(true, false, true, true, false, false).inOrder();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubscribesWithDifferentState() throws RemoteException {
|
||||
final Consumer<OperationContext> nonEmptyConsumer = mock(Consumer.class);
|
||||
mListener.onDisplayStateChanged(AuthenticateOptions.DISPLAY_STATE_AOD);
|
||||
mProvider.subscribe(mOpContext, nonEmptyConsumer);
|
||||
verify(nonEmptyConsumer).accept(same(mOpContext.toAidlContext()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnsubscribes() throws RemoteException {
|
||||
final Consumer<OperationContext> emptyConsumer = mock(Consumer.class);
|
||||
@@ -259,6 +267,9 @@ public class BiometricContextProviderTest {
|
||||
|
||||
mListener.onDisplayStateChanged(AuthenticateOptions.DISPLAY_STATE_AOD);
|
||||
|
||||
//reset to unknown to avoid trigger accept when subscribe
|
||||
mListener.onDisplayStateChanged(AuthenticateOptions.DISPLAY_STATE_UNKNOWN);
|
||||
|
||||
final Consumer<OperationContext> nonEmptyConsumer = mock(Consumer.class);
|
||||
mProvider.subscribe(mOpContext, nonEmptyConsumer);
|
||||
mListener.onDisplayStateChanged(AuthenticateOptions.DISPLAY_STATE_LOCKSCREEN);
|
||||
|
||||
Reference in New Issue
Block a user