mobile-mcp-ai 2.5.8__py3-none-any.whl → 2.6.5__py3-none-any.whl
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.
- mobile_mcp/config.py +32 -0
- mobile_mcp/core/basic_tools_lite.py +1669 -667
- mobile_mcp/core/mobile_client.py +23 -2
- mobile_mcp/mcp_tools/mcp_server.py +298 -278
- {mobile_mcp_ai-2.5.8.dist-info → mobile_mcp_ai-2.6.5.dist-info}/METADATA +1 -1
- {mobile_mcp_ai-2.5.8.dist-info → mobile_mcp_ai-2.6.5.dist-info}/RECORD +10 -10
- {mobile_mcp_ai-2.5.8.dist-info → mobile_mcp_ai-2.6.5.dist-info}/WHEEL +0 -0
- {mobile_mcp_ai-2.5.8.dist-info → mobile_mcp_ai-2.6.5.dist-info}/entry_points.txt +0 -0
- {mobile_mcp_ai-2.5.8.dist-info → mobile_mcp_ai-2.6.5.dist-info}/licenses/LICENSE +0 -0
- {mobile_mcp_ai-2.5.8.dist-info → mobile_mcp_ai-2.6.5.dist-info}/top_level.txt +0 -0
mobile_mcp/core/mobile_client.py
CHANGED
|
@@ -189,8 +189,29 @@ class MobileClient:
|
|
|
189
189
|
return xml_string
|
|
190
190
|
|
|
191
191
|
# Android平台
|
|
192
|
-
# 获取XML
|
|
193
|
-
xml_string =
|
|
192
|
+
# 获取XML - 优先使用 ADB 直接 dump(更完整,包含 NAF 元素)
|
|
193
|
+
xml_string = None
|
|
194
|
+
try:
|
|
195
|
+
# 方法1: 使用 ADB 直接 dump(获取最完整的 UI 树,包括 NAF 元素)
|
|
196
|
+
import subprocess
|
|
197
|
+
import tempfile
|
|
198
|
+
import os
|
|
199
|
+
|
|
200
|
+
# 在设备上执行 dump
|
|
201
|
+
self.u2.shell('uiautomator dump /sdcard/ui_dump.xml')
|
|
202
|
+
|
|
203
|
+
# 读取文件内容
|
|
204
|
+
result = self.u2.shell('cat /sdcard/ui_dump.xml')
|
|
205
|
+
if result and isinstance(result, str) and result.strip().startswith('<?xml'):
|
|
206
|
+
xml_string = result.strip()
|
|
207
|
+
# 清理临时文件
|
|
208
|
+
self.u2.shell('rm /sdcard/ui_dump.xml')
|
|
209
|
+
except Exception as e:
|
|
210
|
+
print(f" ⚠️ ADB dump 失败,使用 uiautomator2: {e}", file=sys.stderr)
|
|
211
|
+
|
|
212
|
+
# 方法2: 回退到 uiautomator2 的 dump_hierarchy
|
|
213
|
+
if not xml_string:
|
|
214
|
+
xml_string = self.u2.dump_hierarchy(compressed=False)
|
|
194
215
|
|
|
195
216
|
# 确保xml_string是字符串类型
|
|
196
217
|
if not isinstance(xml_string, str):
|