@mobilenext/mobile-mcp 0.0.22 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/android.js +14 -1
  2. package/package.json +1 -1
package/lib/android.js CHANGED
@@ -73,6 +73,11 @@ class AndroidRobot {
73
73
  timeout: TIMEOUT,
74
74
  });
75
75
  }
76
+ getFirstDisplayId() {
77
+ const output = this.adb("shell", "dumpsys", "SurfaceFlinger", "--display-id").toString();
78
+ const match = output.match(/Display (\d+) \(/);
79
+ return match ? match[1] : null;
80
+ }
76
81
  getSystemFeatures() {
77
82
  return this.adb("shell", "pm", "list", "features")
78
83
  .toString()
@@ -191,7 +196,15 @@ class AndroidRobot {
191
196
  this.adb("shell", "input", "swipe", `${x0}`, `${y0}`, `${x1}`, `${y1}`, "1000");
192
197
  }
193
198
  async getScreenshot() {
194
- return this.adb("exec-out", "screencap", "-p");
199
+ const displayId = this.getFirstDisplayId();
200
+ if (displayId !== null) {
201
+ // always good to provide displayId. required for multi-display devices such as fold
202
+ return this.adb("exec-out", "screencap", "-p", "-d", displayId);
203
+ }
204
+ else {
205
+ // backward compatibility for android 10 and below
206
+ return this.adb("exec-out", "screencap", "-p");
207
+ }
195
208
  }
196
209
  collectElements(node) {
197
210
  const elements = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mobilenext/mobile-mcp",
3
- "version": "0.0.22",
3
+ "version": "0.0.23",
4
4
  "description": "Mobile MCP",
5
5
  "repository": {
6
6
  "type": "git",