feat: 支持腾讯应用宝5.10.56.xx+#540
Open
srdr0p wants to merge 4 commits into
Open
Conversation
There was a problem hiding this comment.
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>帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据反馈改进后续的评审。
Original comment in English
Hey - I've found 1 issue, and left some high level feedback:
- The Windows registry handling in
get_androws_adb_pathcould be made more robust by also acceptingREG_EXPAND_SZvalues (common for install paths) and by wrapping theHKEYhandle in a small RAII helper to guaranteeRegCloseKeyon all early-return paths rather than manually closing in multiple places. - In
AndrowsApp::open, thestart_if_neededflag 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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Author
|
@wangl-cc 麻烦看看 |
Member
|
感谢贡献!不好意思,我最近一段时间都比较忙,我今天晚点看一下。 |
Codecov Report✅ All modified and coverable lines are covered by tests.
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. 🚀 New features to boost your workflow:
|
Author
|
@wangl-cc 修了下build错误 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
在 maa-cli 中新增对腾讯 Androws(应用宝)安卓模拟器预设和客户端类型处理的支持。
新功能:
ClientType实例选项,用于在连接时选择游戏渠道。增强:
Cow使用“自有或借用”的 adb 路径值,以更好地支持基于预设的路径计算。Assistant实例上设置客户端类型,并改进与客户端配置相关的调试日志。构建:
windows-sys,用于支持通过注册表访问来检测 Androws 的 adb 路径。测试:
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:
Enhancements:
Build:
Tests: