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

Commit 79d52d2a authored by Beverly Tai's avatar Beverly Tai Committed by Automerger Merge Worker
Browse files

Merge "Send display changes to framework" into udc-dev am: ff1d5189

parents d11cd2c7 ff1d5189
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -23,10 +23,10 @@ package android.hardware.biometrics;
 * @hide
 */
oneway interface IBiometricContextListener {
    // Called when doze or awake (screen on) status changes.
    // 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 isDozing, boolean isAwake);
    void onDozeChanged(boolean isAod, boolean isAwake);

    @VintfStability
    @Backing(type="int")
@@ -39,4 +39,8 @@ oneway interface IBiometricContextListener {

    // Called when the fold state of the device changes.
    void onFoldChanged(FoldState FoldState);

    // Called when the display state of the device changes.
    // Where `displayState` is defined in AuthenticateOptions.DisplayState
    void onDisplayStateChanged(int displayState);
}
+7 −3
Original line number Diff line number Diff line
@@ -3036,10 +3036,14 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                                .setUserId(userId)
                                .build());
            } else {
                mLogger.v("startListeningForFingerprint - authenticate");
                mLogger.v("startListeningForFingerprint");
                mFpm.authenticate(null /* crypto */, mFingerprintCancelSignal,
                        mFingerprintAuthenticationCallback, null /* handler */,
                        FingerprintManager.SENSOR_ID_ANY, userId, 0 /* flags */);
                        mFingerprintAuthenticationCallback,
                        null /* handler */,
                        new FingerprintAuthenticateOptions.Builder()
                                .setUserId(userId)
                                .build()
                );
            }
            setFingerprintRunningState(BIOMETRIC_STATE_RUNNING);
        }
+42 −35
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.biometrics.domain.interactor

import android.hardware.biometrics.AuthenticateOptions
import android.hardware.biometrics.IBiometricContextListener
import android.util.Log
import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLogging
@@ -23,7 +24,8 @@ import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCall
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.keyguard.WakefulnessLifecycle
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.unfold.updates.FOLD_UPDATE_FINISH_CLOSED
import com.android.systemui.unfold.updates.FOLD_UPDATE_FINISH_FULL_OPEN
import com.android.systemui.unfold.updates.FOLD_UPDATE_FINISH_HALF_OPEN
@@ -39,6 +41,7 @@ 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
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.shareIn
import kotlinx.coroutines.launch
@@ -49,8 +52,8 @@ import kotlinx.coroutines.launch
 */
interface LogContextInteractor {

    /** If the device is dozing. */
    val isDozing: Flow<Boolean>
    /** If the device is showing aod. */
    val isAod: Flow<Boolean>

    /** If the device is currently awake with the screen on. */
    val isAwake: Flow<Boolean>
@@ -58,6 +61,9 @@ interface LogContextInteractor {
    /** Current device fold state, defined as [IBiometricContextListener.FoldState]. */
    val foldState: Flow<Int>

    /** Current display state, defined as [AuthenticateOptions.DisplayState] */
    val displayState: Flow<Int>

    /**
     * Add a permanent context listener.
     *
@@ -72,46 +78,41 @@ class LogContextInteractorImpl
@Inject
constructor(
    @Application private val applicationScope: CoroutineScope,
    private val statusBarStateController: StatusBarStateController,
    private val wakefulnessLifecycle: WakefulnessLifecycle,
    private val foldProvider: FoldStateProvider,
    keyguardTransitionInteractor: KeyguardTransitionInteractor,
) : LogContextInteractor {

    init {
        foldProvider.start()
    }

    override val isDozing =
        conflatedCallbackFlow {
                val callback =
                    object : StatusBarStateController.StateListener {
                        override fun onDozingChanged(isDozing: Boolean) {
                            trySendWithFailureLogging(isDozing, TAG)
    override val displayState =
        keyguardTransitionInteractor.startedKeyguardTransitionStep.map {
            when (it.to) {
                KeyguardState.LOCKSCREEN,
                KeyguardState.OCCLUDED,
                KeyguardState.ALTERNATE_BOUNCER,
                KeyguardState.PRIMARY_BOUNCER -> AuthenticateOptions.DISPLAY_STATE_LOCKSCREEN
                KeyguardState.AOD -> AuthenticateOptions.DISPLAY_STATE_AOD
                KeyguardState.OFF,
                KeyguardState.DOZING -> AuthenticateOptions.DISPLAY_STATE_NO_UI
                KeyguardState.DREAMING -> AuthenticateOptions.DISPLAY_STATE_SCREENSAVER
                else -> AuthenticateOptions.DISPLAY_STATE_UNKNOWN
            }
        }

                statusBarStateController.addCallback(callback)
                trySendWithFailureLogging(statusBarStateController.isDozing, TAG)
                awaitClose { statusBarStateController.removeCallback(callback) }
            }
            .distinctUntilChanged()
    override val isAod =
        displayState.map { it == AuthenticateOptions.DISPLAY_STATE_AOD }.distinctUntilChanged()

    override val isAwake =
        conflatedCallbackFlow {
                val callback =
                    object : WakefulnessLifecycle.Observer {
                        override fun onFinishedWakingUp() {
                            trySendWithFailureLogging(true, TAG)
        displayState
            .map {
                when (it) {
                    AuthenticateOptions.DISPLAY_STATE_LOCKSCREEN,
                    AuthenticateOptions.DISPLAY_STATE_SCREENSAVER,
                    AuthenticateOptions.DISPLAY_STATE_UNKNOWN -> true
                    else -> false
                }

                        override fun onStartedGoingToSleep() {
                            trySendWithFailureLogging(false, TAG)
                        }
                    }

                wakefulnessLifecycle.addObserver(callback)
                trySendWithFailureLogging(wakefulnessLifecycle.isAwake, TAG)
                awaitClose { wakefulnessLifecycle.removeObserver(callback) }
            }
            .distinctUntilChanged()

@@ -146,8 +147,8 @@ constructor(

    override fun addBiometricContextListener(listener: IBiometricContextListener): Job {
        return applicationScope.launch {
            combine(isDozing, isAwake) { doze, awake -> doze to awake }
                .onEach { (doze, awake) -> listener.onDozeChanged(doze, awake) }
            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)

@@ -156,6 +157,12 @@ constructor(
                .catch { t -> Log.w(TAG, "failed to notify new fold state", t) }
                .launchIn(this)

            displayState
                .distinctUntilChanged()
                .onEach { state -> listener.onDisplayStateChanged(state) }
                .catch { t -> Log.w(TAG, "failed to notify new display state", t) }
                .launchIn(this)

            listener.asBinder().linkToDeath({ cancel() }, 0)
        }
    }
+4 −5
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ import android.hardware.face.FaceAuthenticateOptions.AuthenticateReason
import android.os.PowerManager
import android.os.PowerManager.WAKE_REASON_UNKNOWN
import android.util.Log
import com.android.internal.logging.UiEvent
import com.android.internal.logging.UiEventLogger
import com.android.keyguard.FaceAuthUiEvent

@@ -44,7 +43,7 @@ data class SysUiFaceAuthenticateOptions(
    private val faceAuthUiEvent: UiEventLogger.UiEventEnum,
    @PowerManager.WakeReason val wakeReason: Int = WAKE_REASON_UNKNOWN
) {
    val authenticateReason = setAuthenticateReason(faceAuthUiEvent)
    private val authenticateReason = setAuthenticateReason(faceAuthUiEvent)

    /**
     * The [FaceAuthUiEvent] for this operation. This method converts the UiEvent to the framework
+2 −4
Original line number Diff line number Diff line
@@ -2159,8 +2159,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
        keyguardIsVisible();

        verifyFaceAuthenticateCall();
        verify(mFingerprintManager).authenticate(any(), any(), any(), any(), anyInt(), anyInt(),
                anyInt());
        verifyFingerprintAuthenticateCall();

        final CancellationSignal faceCancel = spy(mKeyguardUpdateMonitor.mFaceCancelSignal);
        final CancellationSignal fpCancel = spy(mKeyguardUpdateMonitor.mFingerprintCancelSignal);
@@ -2627,8 +2626,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
    }

    private void verifyFingerprintAuthenticateCall() {
        verify(mFingerprintManager).authenticate(any(), any(), any(), any(), anyInt(), anyInt(),
                anyInt());
        verify(mFingerprintManager).authenticate(any(), any(), any(), any(), any());
    }

    private void verifyFingerprintDetectNeverCalled() {
Loading