Consider smartspace and umo for fullscreen swipe gesture.
This changelist checks to make sure swipe gestures are not within
smartspace and umo on the lockscreen before consuming the touch and
initiating fullscreen swipe to glanceable hub.
Test: atest GlanceableHubContainerControllerTest#fullScreenSwipeGesture_doNotProcessTouchesInSmartspace
Test: atest GlanceableHubContainerControllerTest#fullScreenSwipeGesture_doNotProcessTouchesInUmo
Fixes: 357798999
Flag: EXEMPT bugfix
Change-Id: Iab2465c7ab05b0d92a8247e865d9fc9bb0f95e25
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/KeyguardMediaController.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/KeyguardMediaController.kt
index e17c0bb..9bea6e9 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/KeyguardMediaController.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/controller/KeyguardMediaController.kt
@@ -18,6 +18,7 @@
import android.content.Context
import android.content.res.Configuration
+import android.graphics.Rect
import android.view.View
import android.view.ViewGroup
import androidx.annotation.VisibleForTesting
@@ -125,6 +126,7 @@
/** single pane media container placed at the top of the notifications list */
var singlePaneContainer: MediaContainerView? = null
private set
+
private var splitShadeContainer: ViewGroup? = null
/**
@@ -185,6 +187,13 @@
}
}
+ fun isWithinMediaViewBounds(x: Int, y: Int): Boolean {
+ val bounds = Rect()
+ mediaHost.hostView.getBoundsOnScreen(bounds)
+
+ return bounds.contains(x, y)
+ }
+
fun refreshMediaPosition(reason: String) {
val currentState = statusBarStateController.state
diff --git a/packages/SystemUI/src/com/android/systemui/shade/GlanceableHubContainerController.kt b/packages/SystemUI/src/com/android/systemui/shade/GlanceableHubContainerController.kt
index 15bbef0..22f62fc 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/GlanceableHubContainerController.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/GlanceableHubContainerController.kt
@@ -55,10 +55,12 @@
import com.android.systemui.keyguard.shared.model.Edge
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.lifecycle.repeatWhenAttached
+import com.android.systemui.media.controls.ui.controller.KeyguardMediaController
import com.android.systemui.res.R
import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.scene.shared.model.SceneDataSourceDelegator
import com.android.systemui.shade.domain.interactor.ShadeInteractor
+import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
import com.android.systemui.util.kotlin.BooleanFlowOperators.anyOf
import com.android.systemui.util.kotlin.collectFlow
@@ -88,6 +90,8 @@
private val communalContent: CommunalContent,
@Communal private val dataSourceDelegator: SceneDataSourceDelegator,
private val notificationStackScrollLayoutController: NotificationStackScrollLayoutController,
+ private val keyguardMediaController: KeyguardMediaController,
+ private val lockscreenSmartspaceController: LockscreenSmartspaceController
) : LifecycleOwner {
private class CommunalWrapper(context: Context) : FrameLayout(context) {
@@ -445,7 +449,12 @@
// the touch.
if (
!hubShowing &&
- !notificationStackScrollLayoutController.isBelowLastNotification(ev.x, ev.y)
+ (!notificationStackScrollLayoutController.isBelowLastNotification(ev.x, ev.y) ||
+ keyguardMediaController.isWithinMediaViewBounds(ev.x.toInt(), ev.y.toInt()) ||
+ lockscreenSmartspaceController.isWithinSmartspaceBounds(
+ ev.x.toInt(),
+ ev.y.toInt()
+ ))
) {
return false
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt
index ef4dffad..97add30 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt
@@ -26,6 +26,7 @@
import android.content.Context
import android.content.Intent
import android.database.ContentObserver
+import android.graphics.Rect
import android.net.Uri
import android.os.Handler
import android.os.UserHandle
@@ -570,6 +571,20 @@
plugin?.unregisterListener(listener)
}
+ fun isWithinSmartspaceBounds(x: Int, y: Int): Boolean {
+ smartspaceViews.forEach {
+ val bounds = Rect()
+ with(it as View) {
+ this.getBoundsOnScreen(bounds)
+ if (bounds.contains(x, y)) {
+ return true
+ }
+ }
+ }
+
+ return false
+ }
+
private fun filterSmartspaceTarget(t: SmartspaceTarget): Boolean {
if (isDateWeatherDecoupled && t.featureType == SmartspaceTarget.FEATURE_WEATHER) {
return false
@@ -587,7 +602,7 @@
// Only the primary user can have an associated managed profile, so only show
// content for the managed profile if the primary user is active
userTracker.userHandle.identifier == UserHandle.USER_SYSTEM &&
- (!t.isSensitive || showSensitiveContentForManagedUser)
+ (!t.isSensitive || showSensitiveContentForManagedUser)
}
else -> {
false
@@ -705,4 +720,3 @@
}
}
}
-
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 5de31d8..1fa78b4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/shade/GlanceableHubContainerControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/shade/GlanceableHubContainerControllerTest.kt
@@ -57,9 +57,11 @@
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.testDispatcher
import com.android.systemui.kosmos.testScope
+import com.android.systemui.media.controls.controller.keyguardMediaController
import com.android.systemui.res.R
import com.android.systemui.scene.shared.model.sceneDataSourceDelegator
import com.android.systemui.shade.domain.interactor.shadeInteractor
+import com.android.systemui.statusbar.lockscreen.lockscreenSmartspaceController
import com.android.systemui.statusbar.notification.stack.notificationStackScrollLayoutController
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
@@ -134,7 +136,9 @@
ambientTouchComponentFactory,
communalContent,
kosmos.sceneDataSourceDelegator,
- kosmos.notificationStackScrollLayoutController
+ kosmos.notificationStackScrollLayoutController,
+ kosmos.keyguardMediaController,
+ kosmos.lockscreenSmartspaceController
)
}
testableLooper = TestableLooper.get(this)
@@ -178,7 +182,9 @@
ambientTouchComponentFactory,
communalContent,
kosmos.sceneDataSourceDelegator,
- kosmos.notificationStackScrollLayoutController
+ kosmos.notificationStackScrollLayoutController,
+ kosmos.keyguardMediaController,
+ kosmos.lockscreenSmartspaceController
)
// First call succeeds.
@@ -205,6 +211,8 @@
communalContent,
kosmos.sceneDataSourceDelegator,
kosmos.notificationStackScrollLayoutController,
+ kosmos.keyguardMediaController,
+ kosmos.lockscreenSmartspaceController
)
assertThat(underTest.lifecycle.currentState).isEqualTo(Lifecycle.State.INITIALIZED)
@@ -226,6 +234,8 @@
communalContent,
kosmos.sceneDataSourceDelegator,
kosmos.notificationStackScrollLayoutController,
+ kosmos.keyguardMediaController,
+ kosmos.lockscreenSmartspaceController
)
// Only initView without attaching a view as we don't want the flows to start collecting
@@ -599,6 +609,30 @@
}
@Test
+ fun fullScreenSwipeGesture_doNotProcessTouchesInUmo() =
+ with(kosmos) {
+ testScope.runTest {
+ // Communal is closed.
+ goToScene(CommunalScenes.Blank)
+ whenever(keyguardMediaController.isWithinMediaViewBounds(any(), any()))
+ .thenReturn(true)
+ assertThat(underTest.onTouchEvent(DOWN_EVENT)).isFalse()
+ }
+ }
+
+ @Test
+ fun fullScreenSwipeGesture_doNotProcessTouchesInSmartspace() =
+ with(kosmos) {
+ testScope.runTest {
+ // Communal is closed.
+ goToScene(CommunalScenes.Blank)
+ whenever(lockscreenSmartspaceController.isWithinSmartspaceBounds(any(), any()))
+ .thenReturn(true)
+ assertThat(underTest.onTouchEvent(DOWN_EVENT)).isFalse()
+ }
+ }
+
+ @Test
fun onTouchEvent_hubOpen_touchesDispatched() =
with(kosmos) {
testScope.runTest {
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/media/controls/controller/KeyguardMediaController.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/media/controls/controller/KeyguardMediaController.kt
new file mode 100644
index 0000000..aed320c
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/media/controls/controller/KeyguardMediaController.kt
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.media.controls.controller
+
+import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.media.controls.ui.controller.KeyguardMediaController
+import com.android.systemui.util.mockito.mock
+
+val Kosmos.keyguardMediaController by Kosmos.Fixture { mock<KeyguardMediaController>() }
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt
new file mode 100644
index 0000000..2a522ce
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.statusbar.lockscreen
+
+import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.util.mockito.mock
+
+val Kosmos.lockscreenSmartspaceController by
+ Kosmos.Fixture { mock<LockscreenSmartspaceController>() }