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

Commit 75fe9ce1 authored by Yong Zhang's avatar Yong Zhang Committed by Automerger Merge Worker
Browse files

Merge "Fix biometric context update problem." into udc-dev am: 656f5d51 am: 9fee241b

parents 55517bae 9fee241b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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
+11 −0
Original line number Diff line number Diff line
@@ -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);