Skip to content

magisk模块添加abl分区备份与恢复功能 - #35

Closed
liujixings wants to merge 1 commit into
SuperTurtleDev:mainfrom
liujixings:main
Closed

magisk模块添加abl分区备份与恢复功能#35
liujixings wants to merge 1 commit into
SuperTurtleDev:mainfrom
liujixings:main

Conversation

@liujixings

Copy link
Copy Markdown
Contributor

为了方便增量OTA更新(主要某厂家有时候不提供完整包),添加abl分区的备份与恢复功能:
1、在执行刷写到另一槽位时自动备份abl分区
2、添加恢复abl按钮,恢复abl时将当前槽位abl保存到临时文件
3、执行刷写到另一槽位时存在临时文件将会使用临时文件

在小米17上测试通过

Copilot AI review requested due to automatic review settings April 26, 2026 17:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

该 PR 为了支持增量 OTA 场景下的引导分区处理,新增了 abl 分区的自动备份手动恢复当前槽位 ABL 能力,并将备份/临时保存状态反馈到 WebUI。

Changes:

  • WebUI 增加“恢复当前槽位 ABL”入口,并根据备份/临时文件状态调整映射表展示与确认流程。
  • bl_flasher.sh 增加 abl 备份目录管理、备份/恢复流程、哈希校验,以及状态输出(HAS_BACKUP/LATEST_BACKUP/HAS_SAVED/LATEST_SAVED)。
  • 刷写到另一槽位时自动备份当前槽位 abl;如存在 saved 临时文件则优先使用并在成功后清理。

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
magisk_module/webroot/index.html 增加“恢复当前槽位 ABL”按钮入口
magisk_module/webroot/app.js 新增 restore 动作确认流程、重复刷写提示、并在映射表中体现 saved 镜像来源
magisk_module/bin/bl_flasher.sh 新增备份目录、备份/恢复逻辑、哈希校验与状态字段输出

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

elements.confirmText.textContent = state.confirmAction === "restore"
? "第二次确认: 恢复将覆盖当前槽位 abl,错误镜像可能导致设备无法启动。确认后将立即开始恢复。"
: "第二次确认: 这是高风险写入操作,错误操作可能导致目标槽位无法启动。确认后将立即开始刷写。";
elements.nextConfirmButton.textContent = "确认刷写";

Copilot AI Apr 26, 2026

Copy link

Choose a reason for hiding this comment

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

这里第二次确认后把 nextConfirmButton 固定设置为“确认刷写”,即使当前动作是 restore 也一样(会导致恢复流程的最终按钮文案不正确)。建议根据 state.confirmAction 分支设置按钮文本,例如 restore 时显示“确认恢复”。

Suggested change
elements.nextConfirmButton.textContent = "确认刷写";
elements.nextConfirmButton.textContent = state.confirmAction === "restore" ? "确认恢复" : "确认刷写";

Copilot uses AI. Check for mistakes.
Comment on lines +248 to +252
if (action === "restore") {
elements.confirmText.textContent =
"第一次确认: 将把 /data/adb/abl_backup 中最近的 abl 备份恢复到当前槽位,同时先保存当前槽位 abl。";
elements.nextConfirmButton.textContent = "继续确认";
} else {

Copilot AI Apr 26, 2026

Copy link

Choose a reason for hiding this comment

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

恢复流程的确认弹窗文案没有和“刷写”区分:openConfirmModal("restore") 只改了 confirmText,但弹窗标题(#confirmTitle)仍是“确认刷写”,且后续步骤的按钮文案也会被覆盖成“确认刷写”。建议把 confirmTitle 节点加入 elements,并在 openConfirmModal / handleConfirmProgress 中根据 action 分别设置标题与按钮文案(例如“确认恢复”),避免误导用户。

Copilot uses AI. Check for mistakes.
@liujixings liujixings changed the title 添加abl分区备份与恢复功能 magisk模块添加abl分区备份与恢复功能 Apr 27, 2026
@superturtlee

Copy link
Copy Markdown
Collaborator

当前采取方案是检测新abl分区是否存在漏洞,如果否,则拷贝当前槽位abl分区到新槽,而当前槽位必然存在gbl漏洞,所以不必备份abl img 只要分区拷贝就行

@liujixings

Copy link
Copy Markdown
Contributor Author

当前采取的方案是检测新abl分区是否存在缺陷,如果否,则拷贝当前槽位abl分区到新槽,而当前槽位必然存在gbl缺陷,所以不需要备份abl img分区分区就行

主要目的是方便进行增量更新,abl分区被修改后增量更新不一定能进行,通过刷入之前备份的abl就可以增量ota,并且部分厂家(主要是努比亚)有时候不给推送完整更新包

@superturtlee

Copy link
Copy Markdown
Collaborator

增量更新abl会被拷贝到第二槽位

@liujixings

Copy link
Copy Markdown
Contributor Author

增量更新abl会被拷贝到第二槽位

不是拷贝abl的问题,增量更新时一是会校验分区完整性;二是如果此次更新内容包括abl会通过当前的abl与更新包生成新abl,如果abl被修改更新会报错失败

@liujixings

Copy link
Copy Markdown
Contributor Author

增量更新abl会被拷贝到第二槽位

增量更新就是对原有的分区patch生成新的,如果原分区被修改就会更新失败,所以如果要增量更新就得将修改还原,所以有这个abl备份与恢复,虽然也可以通过完整包更新,但是增量更新体积更小并且有时候会没有完整包

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.

3 participants