From d965a6ef90e7d7bb036997eefdd4ce1a6cc274f0 Mon Sep 17 00:00:00 2001 From: Darrell Shi Date: Fri, 22 Nov 2024 09:54:26 -0500 Subject: 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 --- .../systemui/shade/GlanceableHubContainerController.kt | 12 +++++++++--- .../shade/GlanceableHubContainerControllerTest.kt | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/shade/GlanceableHubContainerController.kt b/packages/SystemUI/src/com/android/systemui/shade/GlanceableHubContainerController.kt index 49ceba834dd4..31780a56f7f0 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/GlanceableHubContainerController.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/GlanceableHubContainerController.kt @@ -37,9 +37,11 @@ import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LifecycleRegistry import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle +import com.android.app.tracing.coroutines.launchTraced as launch import com.android.compose.theme.PlatformTheme import com.android.internal.annotations.VisibleForTesting import com.android.systemui.Flags +import com.android.systemui.Flags.communalHubOnMobile import com.android.systemui.ambient.touch.TouchMonitor import com.android.systemui.ambient.touch.dagger.AmbientTouchComponent import com.android.systemui.communal.dagger.Communal @@ -70,7 +72,6 @@ import java.util.function.Consumer import javax.inject.Inject import kotlinx.coroutines.flow.Flow 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. @@ -513,14 +514,19 @@ constructor( val touchOnUmo = keyguardMediaController.isWithinMediaViewBounds(ev.x.toInt(), ev.y.toInt()) val touchOnSmartspace = lockscreenSmartspaceController.isWithinSmartspaceBounds(ev.x.toInt(), ev.y.toInt()) - if (!hubShowing && (touchOnNotifications || touchOnUmo || touchOnSmartspace)) { + val glanceableHubV2 = communalHubOnMobile() + if ( + !hubShowing && + (touchOnNotifications || touchOnUmo || touchOnSmartspace || glanceableHubV2) + ) { logger.d({ "Lockscreen touch ignored: touchOnNotifications: $bool1, touchOnUmo: $bool2, " + - "touchOnSmartspace: $bool3" + "touchOnSmartspace: $bool3, glanceableHubV2: $bool4" }) { bool1 = touchOnNotifications bool2 = touchOnUmo bool3 = touchOnSmartspace + bool4 = glanceableHubV2 } return false } diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/GlanceableHubContainerControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/GlanceableHubContainerControllerTest.kt index 859f84edda39..e7fb470cfa76 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/GlanceableHubContainerControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/GlanceableHubContainerControllerTest.kt @@ -33,6 +33,7 @@ import androidx.lifecycle.LifecycleOwner import androidx.test.filters.SmallTest import com.android.compose.animation.scene.SceneKey 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.SysuiTestCase import com.android.systemui.ambient.touch.TouchHandler @@ -630,6 +631,7 @@ class GlanceableHubContainerControllerTest : SysuiTestCase() { } } + @DisableFlags(FLAG_COMMUNAL_HUB_ON_MOBILE) @Test fun onTouchEvent_shadeInteracting_movesNotDispatched() = with(kosmos) { @@ -686,6 +688,7 @@ class GlanceableHubContainerControllerTest : SysuiTestCase() { } } + @DisableFlags(FLAG_COMMUNAL_HUB_ON_MOBILE) @Test fun onTouchEvent_bouncerInteracting_movesNotDispatched() = 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 fun disposeView_destroysTouchMonitor() { clearInvocations(touchMonitor) -- cgit v1.2.3-59-g8ed1b