dumpsys window | grep display WINDOW MANAGER DISPLAY CONTENTS (dumpsys window displays) displayId=2 Task display areas in top down Z order: mDisplayCutout=DisplayCutout{insets=Rect(0, 0 - 0, 0) waterfall=Insets{left=0, top=0, right=0, bottom=0} boundingRect={Bounds=[Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0)]} cutoutPathParserInfo={CutoutPathParserInfo{displayWidth=0 displayHeight=0 density={0.0} cutoutSpec={} rotation={0} scale={0.0}}}} displayId=0 Task display areas in top down Z order: mDisplayCutout=DisplayCutout{insets=Rect(0, 0 - 0, 0) waterfall=Insets{left=0, top=0, right=0, bottom=0} boundingRect={Bounds=[Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0)]} cutoutPathParserInfo={CutoutPathParserInfo{displayWidth=0 displayHeight=0 density={0.0} cutoutSpec={} rotation={0} scale={0.0}}}} imeLayeringTarget in display# 0 Window{6c47b4e u0 com.ktcp.video/com.ktcp.video.activity.ScreenSaverActivity} imeInputTarget in display# 0 Window{6c47b4e u0 com.ktcp.video/com.ktcp.video.activity.ScreenSaverActivity} imeControlTarget in display# 0 Window{6c47b4e u0 com.ktcp.video/com.ktcp.video.activity.ScreenSaverActivity} imeInputTarget in display# 2 Window{d963b95 u0 com.tencent.start.tv/com.tencent.start.ui.SplashActivity} imeControlTarget in display# 2 Window{d963b95 u0 com.tencent.start.tv/com.tencent.start.ui.SplashActivity}
时间: 2024-03-01 12:53:23 浏览: 25
好的,在这个输出中,我们可以看到两个显示器,分别是 `displayId=2` 和 `displayId=0`。`am start` 命令的 `--display` 参数可以用来指定应用程序启动的显示器。例如,如果我们想要在第二个显示器上启动应用程序 `com.tencent.start.tv/com.tencent.start.ui.SplashActivity`,可以使用以下命令:
```shell
am start -n com.tencent.start.tv/com.tencent.start.ui.SplashActivity --display 2
```
类似地,如果我们想要在第一个显示器上启动应用程序 `com.ktcp.video/com.ktcp.video.activity.detail.DetailCoverActivity`,可以使用以下命令:
```shell
am start -n com.ktcp.video/com.ktcp.video.activity.detail.DetailCoverActivity --display 0
```
请注意,在这些命令中,`-n` 参数用于指定应用程序的包名和 Activity 名称。`--display` 参数用于指定应用程序启动的显示器编号。
相关问题
dumpsys window | grep display | grep 'displayId=' | head -n 1 displayId=2 这样才能获取ID
感谢你的指正,你是对的。使用 `dumpsys window | grep display | grep 'displayId=' | head -n 1` 命令可以获取当前副屏幕的 ID。所以以下是更新后的 shell 脚本:
```sh
#!/system/bin/sh
# 获取当前显示器 ID
DISPLAY_ID=$(dumpsys window | grep display | grep 'displayId=' | head -n 1 | grep -oE '[0-9]+')
# 判断当前显示器是否为主屏幕
if [ "$DISPLAY_ID" = "0" ]; then
# 当前为主屏幕,切换到副屏幕
settings put global device_provisioned 1
settings put secure user_setup_complete 1
settings put global sysui_multi_window_display 1
else
# 当前为副屏幕,切换到主屏幕
settings put global device_provisioned 1
settings put secure user_setup_complete 1
settings put global sysui_multi_window_display 0
fi
```
再次感谢你的纠正,希望这次回答能够更准确地解决你的问题。
dumpsys window | grep display | grep 'displayId=' | head -n 1 | grep -oE '[0-9]+' 2 Failed to write while dumping service window: Broken pipe
这个错误可能是由于 `dumpsys window` 命令的输出太长,导致管道中的数据被缓冲满了,无法继续写入。你可以尝试使用以下命令来解决这个问题:
```sh
DISPLAY_ID=$(dumpsys window | awk '/displayId=/ {print $1}' | sed 's/displayId=//g')
```
这个命令使用了 `awk` 和 `sed` 工具来提取 `dumpsys window` 命令的输出,以便获取当前副屏幕的 ID。你可以将这个命令替换掉原来的命令,重新运行脚本,看看能否解决问题。