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

Commit d965a6ef authored by Darrell Shi's avatar Darrell Shi
Browse files

Ignore custom glanceable hub touch on lockscreen

This change ignores custom touch handling to enter the Glanceable Hub by
swiping on the lock screen for Glanceable Hub V2.

Test: atest GlanceableHubContainerControllerTest
Test: verified from GlanceableHubContainer logs that touches on the lock
      screen are ignored
Fix: 378173758
Flag: com.android.systemui.communal_hub_on_mobile
Change-Id: Ic05337ce123a61be884b14fe3e4414a5349cf212
parent 923f969d
Loading
Loading
Loading
Loading
+9 −3
Original line number Original line Diff line number Diff line
@@ -37,9 +37,11 @@ import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LifecycleRegistry
import androidx.lifecycle.LifecycleRegistry
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.app.tracing.coroutines.launchTraced as launch
import com.android.compose.theme.PlatformTheme
import com.android.compose.theme.PlatformTheme
import com.android.internal.annotations.VisibleForTesting
import com.android.internal.annotations.VisibleForTesting
import com.android.systemui.Flags
import com.android.systemui.Flags
import com.android.systemui.Flags.communalHubOnMobile
import com.android.systemui.ambient.touch.TouchMonitor
import com.android.systemui.ambient.touch.TouchMonitor
import com.android.systemui.ambient.touch.dagger.AmbientTouchComponent
import com.android.systemui.ambient.touch.dagger.AmbientTouchComponent
import com.android.systemui.communal.dagger.Communal
import com.android.systemui.communal.dagger.Communal
@@ -70,7 +72,6 @@ import java.util.function.Consumer
import javax.inject.Inject
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.combine
import com.android.app.tracing.coroutines.launchTraced as launch


/**
/**
 * Controller that's responsible for the glanceable hub container view and its touch handling.
 * Controller that's responsible for the glanceable hub container view and its touch handling.
@@ -513,14 +514,19 @@ constructor(
        val touchOnUmo = keyguardMediaController.isWithinMediaViewBounds(ev.x.toInt(), ev.y.toInt())
        val touchOnUmo = keyguardMediaController.isWithinMediaViewBounds(ev.x.toInt(), ev.y.toInt())
        val touchOnSmartspace =
        val touchOnSmartspace =
            lockscreenSmartspaceController.isWithinSmartspaceBounds(ev.x.toInt(), ev.y.toInt())
            lockscreenSmartspaceController.isWithinSmartspaceBounds(ev.x.toInt(), ev.y.toInt())
        if (!hubShowing && (touchOnNotifications || touchOnUmo || touchOnSmartspace)) {
        val glanceableHubV2 = communalHubOnMobile()
        if (
            !hubShowing &&
                (touchOnNotifications || touchOnUmo || touchOnSmartspace || glanceableHubV2)
        ) {
            logger.d({
            logger.d({
                "Lockscreen touch ignored: touchOnNotifications: $bool1, touchOnUmo: $bool2, " +
                "Lockscreen touch ignored: touchOnNotifications: $bool1, touchOnUmo: $bool2, " +
                    "touchOnSmartspace: $bool3"
                    "touchOnSmartspace: $bool3, glanceableHubV2: $bool4"
            }) {
            }) {
                bool1 = touchOnNotifications
                bool1 = touchOnNotifications
                bool2 = touchOnUmo
                bool2 = touchOnUmo
                bool3 = touchOnSmartspace
                bool3 = touchOnSmartspace
                bool4 = glanceableHubV2
            }
            }
            return false
            return false
        }
        }
+16 −0
Original line number Original line Diff line number Diff line
@@ -33,6 +33,7 @@ import androidx.lifecycle.LifecycleOwner
import androidx.test.filters.SmallTest
import androidx.test.filters.SmallTest
import com.android.compose.animation.scene.SceneKey
import com.android.compose.animation.scene.SceneKey
import com.android.systemui.Flags
import com.android.systemui.Flags
import com.android.systemui.Flags.FLAG_COMMUNAL_HUB_ON_MOBILE
import com.android.systemui.Flags.FLAG_HUBMODE_FULLSCREEN_VERTICAL_SWIPE_FIX
import com.android.systemui.Flags.FLAG_HUBMODE_FULLSCREEN_VERTICAL_SWIPE_FIX
import com.android.systemui.SysuiTestCase
import com.android.systemui.SysuiTestCase
import com.android.systemui.ambient.touch.TouchHandler
import com.android.systemui.ambient.touch.TouchHandler
@@ -630,6 +631,7 @@ class GlanceableHubContainerControllerTest : SysuiTestCase() {
            }
            }
        }
        }


    @DisableFlags(FLAG_COMMUNAL_HUB_ON_MOBILE)
    @Test
    @Test
    fun onTouchEvent_shadeInteracting_movesNotDispatched() =
    fun onTouchEvent_shadeInteracting_movesNotDispatched() =
        with(kosmos) {
        with(kosmos) {
@@ -686,6 +688,7 @@ class GlanceableHubContainerControllerTest : SysuiTestCase() {
            }
            }
        }
        }


    @DisableFlags(FLAG_COMMUNAL_HUB_ON_MOBILE)
    @Test
    @Test
    fun onTouchEvent_bouncerInteracting_movesNotDispatched() =
    fun onTouchEvent_bouncerInteracting_movesNotDispatched() =
        with(kosmos) {
        with(kosmos) {
@@ -718,6 +721,19 @@ class GlanceableHubContainerControllerTest : SysuiTestCase() {
            }
            }
        }
        }


    @EnableFlags(FLAG_COMMUNAL_HUB_ON_MOBILE)
    @Test
    fun onTouchEvent_onLockscreenAndGlanceableHubV2_touchIgnored() =
        with(kosmos) {
            testScope.runTest {
                // On lockscreen.
                goToScene(CommunalScenes.Blank)

                assertThat(underTest.onTouchEvent(DOWN_EVENT)).isFalse()
                verify(containerView, never()).onTouchEvent(DOWN_EVENT)
            }
        }

    @Test
    @Test
    fun disposeView_destroysTouchMonitor() {
    fun disposeView_destroysTouchMonitor() {
        clearInvocations(touchMonitor)
        clearInvocations(touchMonitor)