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

Commit 781cb9ae authored by Vincent Wang's avatar Vincent Wang Committed by Android (Google) Code Review
Browse files

Merge "Pass extra information to face HAL" into main

parents e7d9f63e f1e0ab64
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ filegroup {
        ":platform-compat-native-aidl",

        // AIDL sources from external directories
        ":android.hardware.biometrics.common-V3-java-source",
        ":android.hardware.biometrics.common-V4-java-source",
        ":android.hardware.biometrics.fingerprint-V3-java-source",
        ":android.hardware.gnss-V2-java-source",
        ":android.hardware.graphics.common-V3-java-source",
+6 −3
Original line number Diff line number Diff line
@@ -116,8 +116,10 @@ public final class BiometricContextProvider implements BiometricContext {
            service.setBiometicContextListener(new IBiometricContextListener.Stub() {
                @Override
                public void onFoldChanged(int foldState) {
                    if (mFoldState != foldState) {
                        mFoldState = foldState;
                    // no need to notify, not sent to HAL
                        notifyChanged();
                    }
                }

                @Override
@@ -254,6 +256,7 @@ public final class BiometricContextProvider implements BiometricContext {
                + "isAwake: " + isAwake() +  ", "
                + "isDisplayOn: " + isDisplayOn() +  ", "
                + "dock: " + getDockedState() + ", "
                + "rotation: " + getCurrentRotation() + "]";
                + "rotation: " + getCurrentRotation() + ", "
                + "foldState: " + mFoldState + "]";
    }
}
+15 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.hardware.biometrics.AuthenticateOptions;
import android.hardware.biometrics.IBiometricContextListener;
import android.hardware.biometrics.common.AuthenticateReason;
import android.hardware.biometrics.common.DisplayState;
import android.hardware.biometrics.common.FoldState;
import android.hardware.biometrics.common.OperationContext;
import android.hardware.biometrics.common.OperationReason;
import android.hardware.biometrics.common.WakeReason;
@@ -250,6 +251,7 @@ public class OperationContextExt {
    OperationContextExt update(@NonNull BiometricContext biometricContext, boolean isCrypto) {
        mAidlContext.isAod = biometricContext.isAod();
        mAidlContext.displayState = toAidlDisplayState(biometricContext.getDisplayState());
        mAidlContext.foldState = toAidlFoldState(biometricContext.getFoldState());
        mAidlContext.isCrypto = isCrypto;
        setFirstSessionId(biometricContext);

@@ -276,6 +278,19 @@ public class OperationContextExt {
        return DisplayState.UNKNOWN;
    }

    @FoldState
    private static int toAidlFoldState(@IBiometricContextListener.FoldState int state) {
        switch (state) {
            case IBiometricContextListener.FoldState.FULLY_CLOSED:
                return FoldState.FULLY_CLOSED;
            case IBiometricContextListener.FoldState.FULLY_OPENED:
                return FoldState.FULLY_OPENED;
            case IBiometricContextListener.FoldState.HALF_OPENED:
                return FoldState.HALF_OPENED;
        }
        return FoldState.UNKNOWN;
    }

    private void setFirstSessionId(@NonNull BiometricContext biometricContext) {
        if (mIsBP) {
            mSessionInfo = biometricContext.getBiometricPromptSessionInfo();
+23 −0
Original line number Diff line number Diff line
@@ -178,6 +178,29 @@ public class BiometricContextProviderTest {
        }
    }

    @Test
    public void testSubscribesToFoldState() throws RemoteException {
        final List<Integer> actual = new ArrayList<>();
        final List<Integer> expected = List.of(FoldState.FULLY_CLOSED, FoldState.FULLY_OPENED,
                FoldState.UNKNOWN, FoldState.HALF_OPENED);
        mProvider.subscribe(mOpContext, ctx -> {
            assertThat(ctx).isSameInstanceAs(mOpContext.toAidlContext());
            assertThat(mProvider.getFoldState()).isEqualTo(ctx.foldState);
            actual.add(ctx.foldState);
        });

        for (int v : expected) {
            mListener.onFoldChanged(v);
        }

        assertThat(actual).containsExactly(
                FoldState.FULLY_CLOSED,
                FoldState.FULLY_OPENED,
                FoldState.UNKNOWN,
                FoldState.HALF_OPENED
        ).inOrder();
    }

    @Test
    public void testSubscribesToDisplayState() throws RemoteException {
        final List<Integer> actual = new ArrayList<>();