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

Commit 9524cd8e authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge changes from topic "am-a61e8e22eb2f453a8f5133dd1c990448" into udc-qpr-dev-plus-aosp

* changes:
  Merge changes from topic "caitlinshk-cs-wakeupfromtouch" into udc-qpr-dev am: 31e69820
  [Central Surfaces] Make KeyguardRepository.wakefulness a StateFlow. am: 0ade739a
parents fd52fee5 e12ad235
Loading
Loading
Loading
Loading
+43 −37
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLoggin
import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow
import com.android.systemui.common.shared.model.Position
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.doze.DozeMachine
import com.android.systemui.doze.DozeTransitionCallback
@@ -44,13 +45,16 @@ import com.android.systemui.statusbar.phone.DozeParameters
import com.android.systemui.statusbar.policy.KeyguardStateController
import javax.inject.Inject
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.stateIn

/** Defines interface for classes that encapsulate application state for the keyguard. */
interface KeyguardRepository {
@@ -138,7 +142,7 @@ interface KeyguardRepository {
    val statusBarState: Flow<StatusBarState>

    /** Observable for device wake/sleep state */
    val wakefulness: Flow<WakefulnessModel>
    val wakefulness: StateFlow<WakefulnessModel>

    /** Observable for biometric unlock modes */
    val biometricUnlockState: Flow<BiometricUnlockModel>
@@ -202,7 +206,8 @@ constructor(
    private val dozeParameters: DozeParameters,
    private val authController: AuthController,
    private val dreamOverlayCallbackController: DreamOverlayCallbackController,
    @Main private val mainDispatcher: CoroutineDispatcher
    @Main private val mainDispatcher: CoroutineDispatcher,
    @Application private val scope: CoroutineScope,
) : KeyguardRepository {
    private val _animateBottomAreaDozingTransitions = MutableStateFlow(false)
    override val animateBottomAreaDozingTransitions =
@@ -486,7 +491,8 @@ constructor(
        awaitClose { biometricUnlockController.removeListener(callback) }
    }

    override val wakefulness: Flow<WakefulnessModel> = conflatedCallbackFlow {
    override val wakefulness: StateFlow<WakefulnessModel> =
        conflatedCallbackFlow {
                val observer =
                    object : WakefulnessLifecycle.Observer {
                        override fun onStartedWakingUp() {
@@ -513,20 +519,20 @@ constructor(
                            trySendWithFailureLogging(
                                WakefulnessModel.fromWakefulnessLifecycle(wakefulnessLifecycle),
                                TAG,
                        "updated wakefulness state"
                                "updated wakefulness state",
                            )
                        }
                    }

                wakefulnessLifecycle.addObserver(observer)
        trySendWithFailureLogging(
            WakefulnessModel.fromWakefulnessLifecycle(wakefulnessLifecycle),
            TAG,
            "initial wakefulness state"
        )

                awaitClose { wakefulnessLifecycle.removeObserver(observer) }
            }
            .stateIn(
                scope,
                // Use Eagerly so that we're always listening and never miss an event.
                SharingStarted.Eagerly,
                initialValue = WakefulnessModel.fromWakefulnessLifecycle(wakefulnessLifecycle),
            )

    override val fingerprintSensorLocation: Flow<Point?> = conflatedCallbackFlow {
        fun sendFpLocation() {
+2 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import javax.inject.Inject
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filter
@@ -99,7 +100,7 @@ constructor(
    }

    /** The device wake/sleep state */
    val wakefulnessModel: Flow<WakefulnessModel> = repository.wakefulness
    val wakefulnessModel: StateFlow<WakefulnessModel> = repository.wakefulness

    /**
     * Dozing and dreaming have overlapping events. If the doze state remains in FINISH, it means
+5 −1
Original line number Diff line number Diff line
@@ -23,9 +23,12 @@ enum class WakeSleepReason {
    /** The physical power button was pressed to wake up or sleep the device. */
    POWER_BUTTON,

    /** The user has taped or double tapped to wake the screen */
    /** The user has tapped or double tapped to wake the screen. */
    TAP,

    /** The user performed some sort of gesture to wake the screen. */
    GESTURE,

    /** Something else happened to wake up or sleep the device. */
    OTHER;

@@ -34,6 +37,7 @@ enum class WakeSleepReason {
            return when (reason) {
                PowerManager.WAKE_REASON_POWER_BUTTON -> POWER_BUTTON
                PowerManager.WAKE_REASON_TAP -> TAP
                PowerManager.WAKE_REASON_GESTURE -> GESTURE
                else -> OTHER
            }
        }
+10 −1
Original line number Diff line number Diff line
@@ -27,7 +27,11 @@ data class WakefulnessModel(

    fun isStartingToSleep() = state == WakefulnessState.STARTING_TO_SLEEP

    fun isStartingToSleepOrAsleep() = isStartingToSleep() || state == WakefulnessState.ASLEEP
    private fun isAsleep() = state == WakefulnessState.ASLEEP

    fun isStartingToSleepOrAsleep() = isStartingToSleep() || isAsleep()

    fun isDeviceInteractive() = !isAsleep()

    fun isStartingToSleepFromPowerButton() =
        isStartingToSleep() && lastWakeReason == WakeSleepReason.POWER_BUTTON
@@ -41,6 +45,11 @@ data class WakefulnessModel(
    fun isAwakeFromTap() =
        state == WakefulnessState.STARTING_TO_WAKE && lastWakeReason == WakeSleepReason.TAP

    fun isDeviceInteractiveFromTapOrGesture(): Boolean {
        return isDeviceInteractive() &&
            (lastWakeReason == WakeSleepReason.TAP || lastWakeReason == WakeSleepReason.GESTURE)
    }

    companion object {
        fun fromWakefulnessLifecycle(wakefulnessLifecycle: WakefulnessLifecycle): WakefulnessModel {
            return WakefulnessModel(
+10 −3
Original line number Diff line number Diff line
@@ -134,6 +134,7 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInterac
import com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants;
import com.android.systemui.keyguard.shared.model.TransitionState;
import com.android.systemui.keyguard.shared.model.TransitionStep;
import com.android.systemui.keyguard.shared.model.WakefulnessModel;
import com.android.systemui.keyguard.ui.binder.KeyguardLongPressViewBinder;
import com.android.systemui.keyguard.ui.viewmodel.DreamingToLockscreenTransitionViewModel;
import com.android.systemui.keyguard.ui.viewmodel.GoneToDreamingTransitionViewModel;
@@ -2150,10 +2151,14 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
    }

    int getFalsingThreshold() {
        float factor = mCentralSurfaces.isWakeUpComingFromTouch() ? 1.5f : 1.0f;
        float factor = ShadeViewController.getFalsingThresholdFactor(getWakefulness());
        return (int) (mQsController.getFalsingThreshold() * factor);
    }

    private WakefulnessModel getWakefulness() {
        return mKeyguardInteractor.getWakefulnessModel().getValue();
    }

    private void maybeAnimateBottomAreaAlpha() {
        mBottomAreaShadeAlphaAnimator.cancel();
        if (mBarState == StatusBarState.SHADE_LOCKED) {
@@ -3587,8 +3592,10 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
                expand = flingExpands(vel, vectorVel, x, y);
            }

            mDozeLog.traceFling(expand, mTouchAboveFalsingThreshold,
                    mCentralSurfaces.isWakeUpComingFromTouch());
            mDozeLog.traceFling(
                    expand,
                    mTouchAboveFalsingThreshold,
                    /* screenOnFromTouch=*/ getWakefulness().isDeviceInteractiveFromTapOrGesture());
            // Log collapse gesture if on lock screen.
            if (!expand && onKeyguard) {
                float displayDensity = mCentralSurfaces.getDisplayDensity();
Loading