You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(android): add alwaysFetchScreenInfo option to control screen info caching (#1315)
* feat(android): add alwaysFetchScreenInfo option to control screen info caching
Add a new optional parameter `alwaysFetchScreenInfo` to `AndroidDeviceOpt` that allows
users to control whether screen size and orientation information should be fetched on
every call or cached after the first fetch.
- Add `alwaysFetchScreenInfo` parameter to `AndroidDeviceOpt` (defaults to false)
- Add cache fields `cachedScreenSize` and `cachedOrientation` to `AndroidDevice` class
- Update `getScreenSize()` to check and use cache when `alwaysFetchScreenInfo` is false
- Update `getDisplayOrientation()` to use cache when `alwaysFetchScreenInfo` is false
- Update documentation (both English and Chinese) to describe the new parameter
By default, screen info is cached to reduce ADB calls and improve performance. Users can
set `alwaysFetchScreenInfo: true` if they need real-time screen information (e.g., device
rotation scenarios).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix(android): pass alwaysFetchScreenInfo option to AndroidDevice
The alwaysFetchScreenInfo parameter was not being passed from agentFromAdbDevice to
AndroidDevice constructor, causing the option to be ignored when creating agents.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: apps/site/docs/en/mcp-android.mdx
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -76,6 +76,7 @@ Midscene MCP provides the following Android device automation tools:
76
76
Parameters:
77
77
- deviceId: (Optional) Device ID to connect to. If not provided, uses the first available device.
78
78
- displayId: (Optional) Display ID for multi-display Android devices (e.g., 0, 1, 2). When specified, all ADB input operations will target this specific display.
79
+
- alwaysFetchScreenInfo: (Optional) Whether to always fetch screen size and orientation from the device on each call. Defaults to false (uses cache for better performance). Set to true if the device may rotate or you need real-time screen information.
Copy file name to clipboardExpand all lines: packages/android/src/device.ts
+48-3Lines changed: 48 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -69,6 +69,7 @@ export type AndroidDeviceOpt = {
69
69
usePhysicalDisplayIdForDisplayLookup?: boolean;
70
70
customActions?: DeviceAction<any>[];
71
71
screenshotResizeScale?: number;
72
+
alwaysFetchScreenInfo?: boolean;// If true, always fetch screen size and orientation from device on each call; if false (default), cache the first result
0 commit comments