summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2025-01-15 10:20:55 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2025-01-15 10:20:55 -0800
commita53292bb689b3dbfe335378282b2de06ec807397 (patch)
treeb0f982216bc3cd29a9916fbc4eafe21b9e6963d7
parentbfd7b2dea7e85c3233559aef0ad366cfab13400c (diff)
parentb5fe24b7346d2daa18a1c52af4872dd00f6cae27 (diff)
Merge "Add debug command to set device postured state" into main
-rw-r--r--packages/SystemUI/src/com/android/systemui/communal/DevicePosturingCommandListener.kt66
-rw-r--r--packages/SystemUI/src/com/android/systemui/communal/dagger/CommunalStartableModule.kt6
2 files changed, 72 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/communal/DevicePosturingCommandListener.kt b/packages/SystemUI/src/com/android/systemui/communal/DevicePosturingCommandListener.kt
new file mode 100644
index 000000000000..c7b7050340a0
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/communal/DevicePosturingCommandListener.kt
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2025 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.communal
+
+import android.annotation.SuppressLint
+import android.app.DreamManager
+import com.android.systemui.CoreStartable
+import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.statusbar.commandline.Command
+import com.android.systemui.statusbar.commandline.CommandRegistry
+import java.io.PrintWriter
+import javax.inject.Inject
+
+@SysUISingleton
+class DevicePosturingCommandListener
+@Inject
+constructor(private val commandRegistry: CommandRegistry, private val dreamManager: DreamManager) :
+ CoreStartable {
+ private val command = DevicePosturingCommand()
+
+ override fun start() {
+ commandRegistry.registerCommand(COMMAND_ROOT) { command }
+ }
+
+ internal inner class DevicePosturingCommand : Command {
+ @SuppressLint("MissingPermission")
+ override fun execute(pw: PrintWriter, args: List<String>) {
+ val arg = args.getOrNull(0)
+ if (arg == null || arg.lowercase() == "help") {
+ help(pw)
+ return
+ }
+
+ when (arg.lowercase()) {
+ "true" -> dreamManager.setDevicePostured(true)
+ "false" -> dreamManager.setDevicePostured(false)
+ else -> {
+ pw.println("Invalid argument!")
+ help(pw)
+ }
+ }
+ }
+
+ override fun help(pw: PrintWriter) {
+ pw.println("Usage: $ adb shell cmd statusbar device-postured <true|false>")
+ }
+ }
+
+ private companion object {
+ const val COMMAND_ROOT = "device-postured"
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/communal/dagger/CommunalStartableModule.kt b/packages/SystemUI/src/com/android/systemui/communal/dagger/CommunalStartableModule.kt
index 2d19b026489c..e3443227685f 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/dagger/CommunalStartableModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/dagger/CommunalStartableModule.kt
@@ -22,6 +22,7 @@ import com.android.systemui.communal.CommunalDreamStartable
import com.android.systemui.communal.CommunalMetricsStartable
import com.android.systemui.communal.CommunalOngoingContentStartable
import com.android.systemui.communal.CommunalSceneStartable
+import com.android.systemui.communal.DevicePosturingCommandListener
import com.android.systemui.communal.log.CommunalLoggerStartable
import com.android.systemui.communal.widgets.CommunalAppWidgetHostStartable
import com.android.systemui.dagger.qualifiers.PerUser
@@ -67,4 +68,9 @@ interface CommunalStartableModule {
@IntoMap
@ClassKey(CommunalMetricsStartable::class)
fun bindCommunalMetricsStartable(impl: CommunalMetricsStartable): CoreStartable
+
+ @Binds
+ @IntoMap
+ @ClassKey(DevicePosturingCommandListener::class)
+ fun bindDevicePosturingCommandListener(impl: DevicePosturingCommandListener): CoreStartable
}