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 Original line Diff line number Diff line
@@ -19,9 +19,10 @@
package com.android.systemui.keyguard.ui.composable
package com.android.systemui.keyguard.ui.composable


import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.gestures.awaitEachGesture
import androidx.compose.foundation.gestures.awaitEachGesture
import androidx.compose.foundation.gestures.awaitFirstDown
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.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
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.geometry.Rect
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.input.pointer.pointerInput
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.android.systemui.communal.ui.compose.extensions.detectLongPressGesture
import com.android.systemui.keyguard.ui.viewmodel.KeyguardLongPressViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardLongPressViewModel


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


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


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