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

Commit e1b6f7e4 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:...

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

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24284551



Change-Id: Iaeffe9ac8d3a325eabf701b8162a3e0dbd07921e
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 2f1dc224 75fe9ce1
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);