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

Commit 69ccc074 authored by Alejandro Nijamkin's avatar Alejandro Nijamkin
Browse files

[flexiglass] Wake up from AOD when lockscreen tapped.

During the first ~4 seconds after entering AOD, tapping the lockscreen
should wake up the device and exit AOD. This wasn't happening in
Flexiglass. This CL makes it work.

The PulsingGestureListener is responsible for translating taps and
double taps into the proper wakefulness state changes. This CL hooks it
up to the pre-existing LockscreenLongPress (which is renamed to a more
generic name in the follow-up CL).

Bug: 344879669
Test: manually verified that tapping or double tapping on the AOD
lockscreen during the first 4 seconds properly wakes up the device and
exits AOD.
Flag: com.android.systemui.scene_container

Change-Id: I44352c788e841a475f5b31a460c69cdcda91685f
parent 6656e1db
Loading
Loading
Loading
Loading
+18 −10
Original line number Diff line number Diff line
@@ -19,9 +19,10 @@
package com.android.systemui.keyguard.ui.composable

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.gestures.awaitEachGesture
import androidx.compose.foundation.gestures.awaitFirstDown
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.indication
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
@@ -33,10 +34,12 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.input.pointer.pointerInput
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.android.systemui.communal.ui.compose.extensions.detectLongPressGesture
import com.android.systemui.keyguard.ui.viewmodel.KeyguardLongPressViewModel

/** Container for lockscreen content that handles long-press to bring up the settings menu. */
@Composable
// TODO(b/344879669): now that it's more generic than long-press, rename it.
fun LockscreenLongPress(
    viewModel: KeyguardLongPressViewModel,
    modifier: Modifier = Modifier,
@@ -50,14 +53,17 @@ fun LockscreenLongPress(
    Box(
        modifier =
            modifier
                .combinedClickable(
                    enabled = isEnabled,
                    onLongClick = viewModel::onLongPress,
                    onClick = {},
                    interactionSource = interactionSource,
                    // Passing null for the indication removes the ripple effect.
                    indication = null,
                .pointerInput(isEnabled) {
                    if (isEnabled) {
                        detectLongPressGesture { viewModel.onLongPress() }
                    }
                }
                .pointerInput(Unit) {
                    detectTapGestures(
                        onTap = { viewModel.onClick(it.x, it.y) },
                        onDoubleTap = { viewModel.onDoubleClick() },
                    )
                }
                .pointerInput(settingsMenuBounds) {
                    awaitEachGesture {
                        val pointerInputChange = awaitFirstDown()
@@ -65,7 +71,9 @@ fun LockscreenLongPress(
                            viewModel.onTouchedOutside()
                        }
                    }
                },
                }
                // Passing null for the indication removes the ripple effect.
                .indication(interactionSource, null)
    ) {
        content(setSettingsMenuBounds)
    }
+3 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepos
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.kosmos.testScope
import com.android.systemui.res.R
import com.android.systemui.shade.pulsingGestureListener
import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper
import com.android.systemui.testKosmos
import com.android.systemui.util.mockito.mock
@@ -300,7 +301,8 @@ class KeyguardLongPressInteractorTest : SysuiTestCase() {
                        set(Flags.LOCK_SCREEN_LONG_PRESS_DIRECT_TO_WPP, isOpenWppDirectlyEnabled)
                    },
                broadcastDispatcher = fakeBroadcastDispatcher,
                accessibilityManager = kosmos.accessibilityManagerWrapper
                accessibilityManager = kosmos.accessibilityManagerWrapper,
                pulsingGestureListener = kosmos.pulsingGestureListener,
            )
        setUpState()
    }
+13 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.systemui.flags.Flags
import com.android.systemui.keyguard.data.repository.KeyguardRepository
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.res.R
import com.android.systemui.shade.PulsingGestureListener
import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
@@ -54,6 +55,7 @@ import kotlinx.coroutines.launch
/** Business logic for use-cases related to the keyguard long-press feature. */
@OptIn(ExperimentalCoroutinesApi::class)
@SysUISingleton
// TODO(b/344879669): now that it's more generic than long-press, rename it.
class KeyguardLongPressInteractor
@Inject
constructor(
@@ -65,6 +67,7 @@ constructor(
    private val featureFlags: FeatureFlags,
    broadcastDispatcher: BroadcastDispatcher,
    private val accessibilityManager: AccessibilityManagerWrapper,
    private val pulsingGestureListener: PulsingGestureListener,
) {
    /** Whether the long-press handling feature should be enabled. */
    val isLongPressHandlingEnabled: StateFlow<Boolean> =
@@ -166,6 +169,16 @@ constructor(
        _shouldOpenSettings.value = false
    }

    /** Notifies that the lockscreen has been clicked at position [x], [y]. */
    fun onClick(x: Float, y: Float) {
        pulsingGestureListener.onSingleTapUp(x, y)
    }

    /** Notifies that the lockscreen has been double clicked. */
    fun onDoubleClick() {
        pulsingGestureListener.onDoubleTapEvent()
    }

    private fun showSettings() {
        _shouldOpenSettings.value = true
    }
+11 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import kotlinx.coroutines.flow.Flow

/** Models UI state to support the lock screen long-press feature. */
@SysUISingleton
// TODO(b/344879669): now that it's more generic than long-press, rename it.
class KeyguardLongPressViewModel
@Inject
constructor(
@@ -45,4 +46,14 @@ constructor(
    fun onTouchedOutside() {
        interactor.onTouchedOutside()
    }

    /** Notifies that the lockscreen has been clicked at position [x], [y]. */
    fun onClick(x: Float, y: Float) {
        interactor.onClick(x, y)
    }

    /** Notifies that the lockscreen has been double clicked. */
    fun onDoubleClick() {
        interactor.onDoubleClick()
    }
}
+3 −1
Original line number Diff line number Diff line
@@ -369,7 +369,9 @@ public class NotificationShadeWindowViewController implements Dumpable {
                }

                mFalsingCollector.onTouchEvent(ev);
                if (!SceneContainerFlag.isEnabled()) {
                    mPulsingWakeupGestureHandler.onTouchEvent(ev);
                }

                if (!SceneContainerFlag.isEnabled()
                        && mGlanceableHubContainerController.onTouchEvent(ev)) {
Loading