Add additional Dual Shade support functions to Root
Bug: 419192993
Test: Ran tests
Flag: com.android.systemui.scene_container
Change-Id: I9e8a24b6654610da9a160955385840d27ff7e671
diff --git a/libraries/systemui-tapl/src/android/platform/systemui_tapl/ui/Root.kt b/libraries/systemui-tapl/src/android/platform/systemui_tapl/ui/Root.kt
index 6fefe2a..989387e 100644
--- a/libraries/systemui-tapl/src/android/platform/systemui_tapl/ui/Root.kt
+++ b/libraries/systemui-tapl/src/android/platform/systemui_tapl/ui/Root.kt
@@ -21,9 +21,11 @@
import android.graphics.Rect
import android.os.RemoteException
import android.os.SystemClock
+import android.platform.helpers.CommonUtils
import android.platform.systemui_tapl.controller.LockscreenController
import android.platform.systemui_tapl.controller.NotificationIdentity
import android.platform.systemui_tapl.ui.ExpandedBubbleStack.Companion.BUBBLE_EXPANDED_VIEW
+import android.platform.systemui_tapl.ui.NotificationShade.Companion.waitForShadeToClose
import android.platform.systemui_tapl.utils.DeviceUtils.LONG_WAIT
import android.platform.systemui_tapl.utils.DeviceUtils.sysuiResSelector
import android.platform.systemui_tapl.utils.LAUNCHER_PACKAGE
@@ -200,6 +202,9 @@
private val notificationSwipeX: Float
get() = uiDevice.getDisplayWidth(displayId) / 4f
+ private val qsSwipeX: Float
+ get() = 3 * uiDevice.getDisplayWidth(displayId) / 4f
+
/**
* Finds a HUN by its identity. Fails if the notification can't be found.
*
@@ -257,7 +262,22 @@
} else {
uiDevice.executeShellCommand("cmd statusbar expand-settings")
}
- waitForObj(sysuiResSelector("quick_settings_panel", displayId))
+ waitForQuickSettingsToOpen()
+ return QuickSettings(displayId)
+ }
+
+ /** Opens quick settings with a swipe gesture that depends on form factor. */
+ fun openQuickSettingsWithSwipe(): QuickSettings {
+ if (Flags.sceneContainer() && CommonUtils.isDualShade()) {
+ BetterSwipe.swipe(
+ PointF(qsSwipeX, 1f),
+ PointF(qsSwipeX, uiDevice.getDisplayHeight(displayId).toFloat() - 2f),
+ displayId = displayId,
+ )
+ } else {
+ openNotificationShadeViaTwoFingersSwipe()
+ }
+ waitForQuickSettingsToOpen()
return QuickSettings(displayId)
}
@@ -275,6 +295,16 @@
return QuickSettings(displayId)
}
+ /** Collapses any open shade, i.e. either Notifications or QS. */
+ fun collapseAnyShade() {
+ if (Flags.sceneContainer()) {
+ uiDevice.executeShellCommand("cmd statusbar collapse-instant")
+ } else {
+ uiDevice.executeShellCommand("cmd statusbar collapse")
+ }
+ waitForShadeToClose(displayId)
+ }
+
/** Gets status bar. */
val statusBar: StatusBar
get() = StatusBar(displayId)
@@ -509,6 +539,10 @@
}
}
+ private fun waitForQuickSettingsToOpen() {
+ waitForObj(sysuiResSelector("quick_settings_panel", displayId))
+ }
+
fun pressBackOnDisplay() {
if (displayId == DEFAULT_DISPLAY) {
LauncherInstrumentation().pressBack()