feat(MAA): 支持按服务器在队列前后管理明日方舟安装 - #330
Open
Taimer0721 wants to merge 1 commit into
Open
Conversation
Reviewer's Guide为每个已启用的服务器和模拟器实例新增可配置的队列前/后自动化流程,用于卸载/安装明日方舟(Arknights),包括一个新的 ArknightsPackage 服务,用于管理基于服务器的包映射、下载以及基于 ADB 的安装/卸载,并配套相应的后端配置与前端选项接线。 基于队列的明日方舟卸载/安装自动化时序图sequenceDiagram
participant TaskRunner as TaskExecuteBase_main_task
participant Config as Config
participant EmulatorManager as EmulatorManager
participant ArknightsPackage as ArknightsPackage
participant Emulator as DeviceBase
TaskRunner->>TaskRunner: prepare()
TaskRunner->>TaskRunner: _collect_arknights_package_automations()
TaskRunner->>TaskRunner: _run_arknights_package_action(uninstall)
loop per automation
TaskRunner->>EmulatorManager: get_emulator_instance(emulator_id)
EmulatorsManager-->>TaskRunner: emulator
TaskRunner->>Config: EmulatorConfig[emulator_uid]
TaskRunner->>ArknightsPackage: get_resource(server)
TaskRunner->>ArknightsPackage: uninstall(emulator, server, emulator_type, emulator_path, emulator_index)
ArknightsPackage->>ArknightsPackage: _prepare_device(emulator, emulator_type, emulator_path, emulator_index)
ArknightsPackage->>Emulator: getStatus(emulator_index)
alt [emulator offline]
ArknightsPackage->>Emulator: open(emulator_index)
end
ArknightsPackage->>ArknightsPackage: _ensure_connected(adb_path, serial)
ArknightsPackage->>ProcessRunner: run_process(adb_path, -s, serial, uninstall, package_name)
ProcessRunner-->>ArknightsPackage: result
ArknightsPackage-->>TaskRunner: uninstall completed
end
TaskRunner->>TaskRunner: run scripts in queue
TaskRunner->>TaskRunner: final_task()
TaskRunner->>TaskRunner: _run_arknights_package_action(install)
loop per automation
TaskRunner->>ArknightsPackage: get_resource(server)
TaskRunner->>ArknightsPackage: install(emulator, server, emulator_type, emulator_path, emulator_index, proxy)
ArknightsPackage->>ArknightsPackage: _prepare_device(emulator, emulator_type, emulator_path, emulator_index)
ArknightsPackage->>ArknightsPackage: _download_package(resource, proxy)
alt [package_format == apk]
ArknightsPackage->>ArknightsPackage: _install_apks(adb_path, serial, [apk])
else [package_format == xapk]
ArknightsPackage->>ArknightsPackage: _install_xapk(adb_path, serial, resource, xapk_path)
end
ArknightsPackage-->>TaskRunner: install completed
end
文件级变更
Tips and commandsInteracting with Sourcery
自定义你的体验访问你的 dashboard 以:
获取帮助Original review guide in EnglishReviewer's GuideAdds configurable pre/post queue automation to uninstall/install Arknights per enabled server and emulator instance, including a new ArknightsPackage service that manages server-specific package mapping, download, and ADB-based install/uninstall, with corresponding backend config and frontend options wiring. Sequence diagram for queue-based Arknights uninstall/install automationsequenceDiagram
participant TaskRunner as TaskExecuteBase_main_task
participant Config as Config
participant EmulatorManager as EmulatorManager
participant ArknightsPackage as ArknightsPackage
participant Emulator as DeviceBase
TaskRunner->>TaskRunner: prepare()
TaskRunner->>TaskRunner: _collect_arknights_package_automations()
TaskRunner->>TaskRunner: _run_arknights_package_action(uninstall)
loop per automation
TaskRunner->>EmulatorManager: get_emulator_instance(emulator_id)
EmulatorsManager-->>TaskRunner: emulator
TaskRunner->>Config: EmulatorConfig[emulator_uid]
TaskRunner->>ArknightsPackage: get_resource(server)
TaskRunner->>ArknightsPackage: uninstall(emulator, server, emulator_type, emulator_path, emulator_index)
ArknightsPackage->>ArknightsPackage: _prepare_device(emulator, emulator_type, emulator_path, emulator_index)
ArknightsPackage->>Emulator: getStatus(emulator_index)
alt [emulator offline]
ArknightsPackage->>Emulator: open(emulator_index)
end
ArknightsPackage->>ArknightsPackage: _ensure_connected(adb_path, serial)
ArknightsPackage->>ProcessRunner: run_process(adb_path, -s, serial, uninstall, package_name)
ProcessRunner-->>ArknightsPackage: result
ArknightsPackage-->>TaskRunner: uninstall completed
end
TaskRunner->>TaskRunner: run scripts in queue
TaskRunner->>TaskRunner: final_task()
TaskRunner->>TaskRunner: _run_arknights_package_action(install)
loop per automation
TaskRunner->>ArknightsPackage: get_resource(server)
TaskRunner->>ArknightsPackage: install(emulator, server, emulator_type, emulator_path, emulator_index, proxy)
ArknightsPackage->>ArknightsPackage: _prepare_device(emulator, emulator_type, emulator_path, emulator_index)
ArknightsPackage->>ArknightsPackage: _download_package(resource, proxy)
alt [package_format == apk]
ArknightsPackage->>ArknightsPackage: _install_apks(adb_path, serial, [apk])
else [package_format == xapk]
ArknightsPackage->>ArknightsPackage: _install_xapk(adb_path, serial, resource, xapk_path)
end
ArknightsPackage-->>TaskRunner: install completed
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - 我留下了一些整体性的反馈:
- 在
_resolve_adb_path中你将adb.exe写死了,这在非 Windows 平台上会失败;建议使用与平台无关的方式解析adb,或者同时检查adb和adb.exe,以保证该功能在不同平台上都能正常工作。 _download_package方法在_PACKAGE_DIR中已有缓存文件的情况下仍然会重新下载 APK/XAPK;如果这些文件比较大,你可能需要在已经存在有效文件时提前返回,或者增加一个简单的版本/修改时间检查,以避免不必要的重复下载。
给 AI Agent 的提示
请根据这次代码评审中的评论进行修改:
## 整体评论
- 在 `_resolve_adb_path` 中你将 `adb.exe` 写死了,这在非 Windows 平台上会失败;建议使用与平台无关的方式解析 `adb`,或者同时检查 `adb` 和 `adb.exe`,以保证该功能在不同平台上都能正常工作。
- `_download_package` 方法在 `_PACKAGE_DIR` 中已有缓存文件的情况下仍然会重新下载 APK/XAPK;如果这些文件比较大,你可能需要在已经存在有效文件时提前返回,或者增加一个简单的版本/修改时间检查,以避免不必要的重复下载。帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈来改进后续的评审。
Original comment in English
Hey - I've left some high level feedback:
- In
_resolve_adb_pathyou hardcodeadb.exe, which will fail on non‑Windows platforms; consider resolvingadbwith a platform‑agnostic name or checking bothadbandadb.exeto keep this feature working cross‑platform. - The
_download_packagemethod always re-downloads the APK/XAPK even if a cached file already exists in_PACKAGE_DIR; if these files are large, you might want to short‑circuit when a valid existing file is present or add a simple versioning/mtime check to avoid unnecessary downloads.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `_resolve_adb_path` you hardcode `adb.exe`, which will fail on non‑Windows platforms; consider resolving `adb` with a platform‑agnostic name or checking both `adb` and `adb.exe` to keep this feature working cross‑platform.
- The `_download_package` method always re-downloads the APK/XAPK even if a cached file already exists in `_PACKAGE_DIR`; if these files are large, you might want to short‑circuit when a valid existing file is present or add a simple versioning/mtime check to avoid unnecessary downloads.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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 脚本队列的每个服务器添加明日方舟的队列级自动卸载和重装功能。
New Features:
Enhancements:
Original summary in English
Summary by Sourcery
Add queue-level automation for uninstalling and reinstalling Arknights per server around MAA script queues.
New Features:
Enhancements: