【Android】【多屏】多屏异显异触调试技巧总结

这里写目录标题

如何获取多屏IDs

bash 复制代码
dumpsys display | grep mDisplayId

trinket:/ # dumpsys display | grep mDisplayId
    mDisplayId=0
    mDisplayId=2
trinket:/ #

获取多屏的size/density

bash 复制代码
trinket:/ # wm
Window manager (window) commands:
  help
      Print this help text.
  size [reset|WxH|WdpxHdp] [-d DISPLAY_ID]
    Return or override display size.
    width and height in pixels unless suffixed with 'dp'.
  density [reset|DENSITY] [-d DISPLAY_ID]
    Return or override display density.
  folded-area [reset|LEFT,TOP,RIGHT,BOTTOM]
    Return or override folded area.
  overscan [reset|LEFT,TOP,RIGHT,BOTTOM] [-d DISPLAY ID]
    Set overscan area for display.
  scaling [off|auto] [-d DISPLAY_ID]
    Set display scaling mode.
  dismiss-keyguard
    Dismiss the keyguard, prompting user for auth if necessary.
  set-user-rotation [free|lock] [-d DISPLAY_ID] [rotation]
    Set user rotation mode and user rotation.
  set-fix-to-user-rotation [-d DISPLAY_ID] [enabled|disabled]
    Enable or disable rotating display for app requested orientation.
  tracing (start | stop)
    Start or stop window tracing.

通过指令 wm size -d xxx; // xxx 代表ID

bash 复制代码
trinket:/ # wm size -d 0
Physical size: 1080x1920
trinket:/ # wm size -d 2
Physical size: 1280x720
trinket:/ #

通过指令 wm density -d xxx; // xxx 代表ID

bash 复制代码
trinket:/ # wm density -d 0
Physical density: 320
Override density: 240
trinket:/ # wm density -d 2
Physical density: 213

如何启动应用到指定DisplayId

bash 复制代码
am start -n com.android.settings/.Settings --display 2

多屏截屏/录屏

screencap
bash 复制代码
trinket:/ # screencap  -h
usage: screencap [-hp] [-d display-id] [FILENAME]
   -h: this message
   -p: save the file as a png.
   -d: specify the physical display ID to capture (default: 19260879647709569)
       see "dumpsys SurfaceFlinger --display-id" for valid display IDs.
If FILENAME ends with .png it will be saved as a png.
If FILENAME is not given, the results will be printed to stdout.

指令如下:

bash 复制代码
//display id 0,界面截屏
screencap -p -d 0 sdcard/0.png
//display id 2,界面截屏
screencap -p -d 2 sdcard/2.png
screenrecord

当前android平台没有指令支持。

发送按键到指定DisplayId
bash 复制代码
//发送 back 按键到display id 2
input -d 2 keyevent 4

//发送屏幕点击事件
input -d 2 tap 200 200 

//发送屏幕滑动事件
//swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)
input -d 2 siwpe 200 200 200 500 40
相关推荐
法欧特斯卡雷特8 小时前
Kotlin 2.4.20 现已发布,新特性多不多?
android·开源·全栈
摇滚侠8 小时前
《SpringBoot 3:入门与应用实战》第 12 章 JDBC 与事务 使用 JdbcTemplate 阅读笔记 31
android·spring boot·笔记
Zeaon9 小时前
别再手写筛选栏了:一个可组合的 Flutter 选择组件(5 入口 × 7 委托)
android·flutter
Michaelwubo9 小时前
mysql8 主从 HA切换
android·adb
墨狂之逸才9 小时前
Android 工业手持机蓝牙扫描失败:为什么同时需要蓝牙和定位权限
android
Android打工仔10 小时前
Kotlin 协程源码解析(七)`delay()` 到底是如何在 `Dispatchers.Main` 上恢复的?
android·kotlin
律宏阔10 小时前
Android 红外功能实现与红外协议开发笔记:ConsumerIrManager、NEC、PWM、曼彻斯特编码
android
mmsx11 小时前
MapLibre 统一图层模型:sealed class + 声明式图层 + XML 持久化
android·源码·地图·maplibre
YUJIANYUE11 小时前
查立得万用查分安卓版(web环境+查询系统免安装单文件一键运行包)
android·前端
天空之城--12 小时前
Android Launcher 性能优化完全指南:从启动到滑动,构建极致流畅的桌面体验
android·性能优化