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

Commit 340d9729 authored by Joe Bolinger's avatar Joe Bolinger Committed by Android (Google) Code Review
Browse files

Merge "Propogate SysUI's display state changes to face & fingerprint HAL." into udc-dev

parents 0ef2ab3b d72fb2fe
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -23,11 +23,6 @@ package android.hardware.biometrics;
 * @hide
 */
oneway interface IBiometricContextListener {
    // Called when aod or awake (screen on) status changes.
    // These may be called while the device is still transitioning to the new state
    // (i.e. about to become awake or enter doze)
    void onDozeChanged(boolean isAod, boolean isAwake);

    @VintfStability
    @Backing(type="int")
    enum FoldState {
+0 −6
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
@@ -147,11 +146,6 @@ constructor(

    override fun addBiometricContextListener(listener: IBiometricContextListener): Job {
        return applicationScope.launch {
            combine(isAod, isAwake) { doze, awake -> doze to awake }
                .onEach { (aod, awake) -> listener.onDozeChanged(aod, awake) }
                .catch { t -> Log.w(TAG, "failed to notify new doze state", t) }
                .launchIn(this)

            foldState
                .onEach { state -> listener.onFoldChanged(state) }
                .catch { t -> Log.w(TAG, "failed to notify new fold state", t) }
+0 −13
Original line number Diff line number Diff line
@@ -191,18 +191,11 @@ class LogContextInteractorImplTest : SysuiTestCase() {
            foldListener.onFoldUpdate(FOLD_UPDATE_FINISH_CLOSED)
            keyguardTransitionRepository.startTransitionTo(KeyguardState.AOD)

            var aod: Boolean? = null
            var awake: Boolean? = null
            var folded: Int? = null
            var displayState: Int? = null
            val job =
                interactor.addBiometricContextListener(
                    object : IBiometricContextListener.Stub() {
                        override fun onDozeChanged(isAod: Boolean, isAwake: Boolean) {
                            aod = isAod
                            awake = isAwake
                        }

                        override fun onFoldChanged(foldState: Int) {
                            folded = foldState
                        }
@@ -214,8 +207,6 @@ class LogContextInteractorImplTest : SysuiTestCase() {
                )
            runCurrent()

            assertThat(aod).isTrue()
            assertThat(awake).isFalse()
            assertThat(folded).isEqualTo(FoldState.FULLY_CLOSED)
            assertThat(displayState).isEqualTo(AuthenticateOptions.DISPLAY_STATE_AOD)

@@ -224,8 +215,6 @@ class LogContextInteractorImplTest : SysuiTestCase() {
            keyguardTransitionRepository.startTransitionTo(KeyguardState.LOCKSCREEN)
            runCurrent()

            assertThat(aod).isFalse()
            assertThat(awake).isTrue()
            assertThat(folded).isEqualTo(FoldState.HALF_OPENED)
            assertThat(displayState).isEqualTo(AuthenticateOptions.DISPLAY_STATE_LOCKSCREEN)

@@ -236,8 +225,6 @@ class LogContextInteractorImplTest : SysuiTestCase() {
            keyguardTransitionRepository.startTransitionTo(KeyguardState.AOD)
            runCurrent()

            assertThat(aod).isFalse()
            assertThat(awake).isTrue()
            assertThat(folded).isEqualTo(FoldState.HALF_OPENED)
            assertThat(displayState).isEqualTo(AuthenticateOptions.DISPLAY_STATE_LOCKSCREEN)
        }
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.hardware.biometrics.AuthenticateOptions;
import android.hardware.biometrics.IBiometricContextListener;
import android.hardware.biometrics.common.OperationContext;
import android.view.Surface;

@@ -65,6 +66,7 @@ public interface BiometricContext {
     * Current fold state from
     * {@link android.hardware.biometrics.IBiometricContextListener.FoldState}.
     */
    @IBiometricContextListener.FoldState
    int getFoldState();

    /** Current device display rotation. */
+9 −15
Original line number Diff line number Diff line
@@ -84,8 +84,6 @@ public final class BiometricContextProvider implements BiometricContext {
    private final AuthSessionCoordinator mAuthSessionCoordinator;
    private final WindowManager mWindowManager;
    @Nullable private final Handler mHandler;
    private boolean mIsAod = false;
    private boolean mIsAwake = false;
    private int mDockState = Intent.EXTRA_DOCK_STATE_UNDOCKED;
    private int mFoldState = IBiometricContextListener.FoldState.UNKNOWN;

@@ -116,16 +114,6 @@ public final class BiometricContextProvider implements BiometricContext {
    private void subscribeBiometricContextListener(@NonNull IStatusBarService service) {
        try {
            service.setBiometicContextListener(new IBiometricContextListener.Stub() {
                @Override
                public void onDozeChanged(boolean isAod, boolean isAwake) {
                    final boolean changed = (mIsAod != isAod) || (mIsAwake != isAwake);
                    if (changed) {
                        mIsAod = isAod;
                        mIsAwake = isAwake;
                        notifyChanged();
                    }
                }

                @Override
                public void onFoldChanged(int foldState) {
                    mFoldState = foldState;
@@ -185,12 +173,18 @@ public final class BiometricContextProvider implements BiometricContext {

    @Override
    public boolean isAod() {
        return mIsAod;
        return mDisplayState == AuthenticateOptions.DISPLAY_STATE_AOD;
    }

    @Override
    public boolean isAwake() {
        return mIsAwake;
        switch (mDisplayState) {
            case AuthenticateOptions.DISPLAY_STATE_LOCKSCREEN:
            case AuthenticateOptions.DISPLAY_STATE_SCREENSAVER:
            case AuthenticateOptions.DISPLAY_STATE_UNKNOWN:
                return true;
        }
        return false;
    }

    @Override
@@ -252,7 +246,7 @@ public final class BiometricContextProvider implements BiometricContext {
    public String toString() {
        return "[keyguard session: " + getKeyguardEntrySessionInfo() + ", "
                + "bp session: " + getBiometricPromptSessionInfo() + ", "
                + "isAod: " + isAod() + ", "
                + "displayState: " + getDisplayState() + ", "
                + "isAwake: " + isAwake() +  ", "
                + "isDisplayOn: " + isDisplayOn() +  ", "
                + "dock: " + getDockedState() + ", "
Loading