Skip to content

feat: 支持腾讯应用宝5.10.56.xx+#540

Open
srdr0p wants to merge 4 commits into
MaaAssistantArknights:mainfrom
srdr0p:main
Open

feat: 支持腾讯应用宝5.10.56.xx+#540
srdr0p wants to merge 4 commits into
MaaAssistantArknights:mainfrom
srdr0p:main

Conversation

@srdr0p
Copy link
Copy Markdown

@srdr0p srdr0p commented May 1, 2026

Summary by Sourcery

在 maa-cli 中新增对腾讯 Androws(应用宝)安卓模拟器预设和客户端类型处理的支持。

新功能:

  • 引入新的 Androws 连接预设,包含默认 adb 路径、地址以及配置解析,并支持通过 Windows 注册表自动发现 adb。
  • 在 Windows 上新增 Androws 外部应用集成,在连接前会验证模拟器是否已运行。
  • 新增可配置的 ClientType 实例选项,用于在连接时选择游戏渠道。

增强:

  • 优化连接参数处理,通过 Cow 使用“自有或借用”的 adb 路径值,以更好地支持基于预设的路径计算。
  • 扩展助手运行流程,在 Assistant 实例上设置客户端类型,并改进与客户端配置相关的调试日志。

构建:

  • 新增仅在 Windows 下启用的依赖 windows-sys,用于支持通过注册表访问来检测 Androws 的 adb 路径。

测试:

  • 扩展预设反序列化与连接参数测试,以覆盖新的 Androws 预设及其默认值。
  • 为新的 Androws 外部应用构造函数添加单元测试。
Original summary in English

Summary by Sourcery

Add support for the Tencent Androws (应用宝) Android emulator preset and client type handling in maa-cli.

New Features:

  • Introduce a new Androws connection preset with default adb path, address, and config resolution, including Windows registry-based adb discovery.
  • Add an Androws external app integration on Windows that verifies the emulator is running before connecting.
  • Expose a new ClientType instance option to allow selecting the game channel when connecting.

Enhancements:

  • Refine connection argument handling to use owned-or-borrowed adb path values via Cow for better preset-specific path computation.
  • Extend the assistant run flow to set the client type on the Assistant instance and improve debug logging around client configuration.

Build:

  • Add windows-sys as a Windows-only dependency to support registry access for Androws adb path detection.

Tests:

  • Expand preset deserialization and connection argument tests to cover the new Androws preset and its defaults.
  • Add unit tests for the new Androws external app constructor.

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我发现了 1 个问题,并给出了一些整体性的反馈:

  • get_androws_adb_path 中对 Windows 注册表的处理可以更健壮一些:比如同时接受 REG_EXPAND_SZ 类型的值(安装路径常见为该类型),并将 HKEY 句柄封装进一个小的 RAII 帮助器中,以保证在所有提前返回路径上都调用 RegCloseKey,而不是在多处手动关闭。
  • AndrowsApp::open 中,start_if_needed 标志被忽略了;建议要么在 Androws 未运行时使用这个标志尝试启动它,要么明确记录日志说明该标志是被有意忽略的,以免调用方误解其行为。
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- `get_androws_adb_path` 中对 Windows 注册表的处理可以更健壮一些:比如同时接受 `REG_EXPAND_SZ` 类型的值(安装路径常见为该类型),并将 `HKEY` 句柄封装进一个小的 RAII 帮助器中,以保证在所有提前返回路径上都调用 `RegCloseKey`,而不是在多处手动关闭。
-`AndrowsApp::open` 中,`start_if_needed` 标志被忽略了;建议要么在 Androws 未运行时使用这个标志尝试启动它,要么明确记录日志说明该标志是被有意忽略的,以免调用方误解其行为。

## Individual Comments

### Comment 1
<location path="crates/maa-cli/src/config/asst.rs" line_range="324-326" />
<code_context>
+    }
+
+    /// Open a registry subkey under HKLM with KEY_READ access.
+    unsafe fn open_hklm_key(subkey: &str) -> Option<HKEY> {
+        let subkey_wide: Vec<u16> = subkey.encode_utf16().chain(std::iter::once(0)).collect();
+        let mut hkey: HKEY = std::ptr::null_mut();
+        let rc = unsafe {
+            RegOpenKeyExW(
</code_context>
<issue_to_address>
**issue (bug_risk):** `windows-sys` 中的 HKEY 不是指针类型;使用 `null_mut()` 初始化很可能会导致类型错误。

在 `windows-sys` 中,`HKEY` 是一个整数句柄(`isize`),因此将 `std::ptr::null_mut()` 赋值给它是类型错误,也与 API 不匹配。应将其初始化为整数,例如 `let mut hkey: HKEY = 0;``HKEY::default()`,并继续将 `&mut hkey` 传给 `RegOpenKeyExW`。
</issue_to_address>

Sourcery 对开源项目是免费的——如果你觉得这些评审有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据反馈改进后续的评审。
Original comment in English

Hey - I've found 1 issue, and left some high level feedback:

  • The Windows registry handling in get_androws_adb_path could be made more robust by also accepting REG_EXPAND_SZ values (common for install paths) and by wrapping the HKEY handle in a small RAII helper to guarantee RegCloseKey on all early-return paths rather than manually closing in multiple places.
  • In AndrowsApp::open, the start_if_needed flag is ignored; consider either using it to attempt to launch Androws when it's not running or logging explicitly that the flag is intentionally ignored so callers are not misled about the behavior.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The Windows registry handling in `get_androws_adb_path` could be made more robust by also accepting `REG_EXPAND_SZ` values (common for install paths) and by wrapping the `HKEY` handle in a small RAII helper to guarantee `RegCloseKey` on all early-return paths rather than manually closing in multiple places.
- In `AndrowsApp::open`, the `start_if_needed` flag is ignored; consider either using it to attempt to launch Androws when it's not running or logging explicitly that the flag is intentionally ignored so callers are not misled about the behavior.

## Individual Comments

### Comment 1
<location path="crates/maa-cli/src/config/asst.rs" line_range="324-326" />
<code_context>
+    }
+
+    /// Open a registry subkey under HKLM with KEY_READ access.
+    unsafe fn open_hklm_key(subkey: &str) -> Option<HKEY> {
+        let subkey_wide: Vec<u16> = subkey.encode_utf16().chain(std::iter::once(0)).collect();
+        let mut hkey: HKEY = std::ptr::null_mut();
+        let rc = unsafe {
+            RegOpenKeyExW(
</code_context>
<issue_to_address>
**issue (bug_risk):** HKEY is not a pointer type in `windows-sys`; initializing it with `null_mut()` is likely a type error.

`HKEY` in `windows-sys` is an integer handle (`isize`), so assigning `std::ptr::null_mut()` is a type error and doesn’t match the API. Initialize it as an integer instead, e.g. `let mut hkey: HKEY = 0;` or `HKEY::default()`, and continue passing `&mut hkey` to `RegOpenKeyExW`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread crates/maa-cli/src/config/asst.rs
@srdr0p
Copy link
Copy Markdown
Author

srdr0p commented May 11, 2026

@wangl-cc 麻烦看看

@wangl-cc
Copy link
Copy Markdown
Member

感谢贡献!不好意思,我最近一段时间都比较忙,我今天晚点看一下。

@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 22.18%. Comparing base (7557252) to head (5a3f186).
⚠️ Report is 6 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (7557252) and HEAD (5a3f186). Click for more details.

HEAD has 3 uploads less than BASE
Flag BASE (7557252) HEAD (5a3f186)
4 1
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #540       +/-   ##
===========================================
- Coverage   71.86%   22.18%   -49.69%     
===========================================
  Files          69        6       -63     
  Lines        6412      284     -6128     
  Branches     6412      284     -6128     
===========================================
- Hits         4608       63     -4545     
+ Misses       1477      220     -1257     
+ Partials      327        1      -326     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@srdr0p
Copy link
Copy Markdown
Author

srdr0p commented May 12, 2026

@wangl-cc 修了下build错误

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants