Skip to content

feat(android): Android 应用内自动更新与 release JNI 修复(基于 beta 重迁)#704

Open
HKLHaoBin wants to merge 2 commits into
Open-Less:betafrom
HKLHaoBin:feat/android-auto-update-to-beta
Open

feat(android): Android 应用内自动更新与 release JNI 修复(基于 beta 重迁)#704
HKLHaoBin wants to merge 2 commits into
Open-Less:betafrom
HKLHaoBin:feat/android-auto-update-to-beta

Conversation

@HKLHaoBin

@HKLHaoBin HKLHaoBin commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

User description

摘要

Fixes #677

feat/android-auto-update 的能力以 squash 方式重迁到当前 beta1.3.10-3),保留 beta 侧 IPC 拆分、overlay destroy 通知、Android context 空指针保护、APK 200 MB 下载上限、剪贴板还原辅助函数等修复;并修复多 useAutoUpdate() 实例共享 android-update:progress 导致非发起方误入下载/安装 UI 的问题。

本 PR 取代 #664(旧分支基于过时 beta,无法快进合并)及 #666 中捆绑的 Android 更新部分;#653 历史润色将单独开 PR。

修复 / 新增 / 改进

  • 自动更新updateChannelAutoUpdateGate 对齐;高级页 Beta 开关 + 自动更新开关;关于页 / 高级页分别手动查 Stable / Beta;Android 检查到新版本后可自动下载并打开系统安装器。
  • Rust 更新器:抽取 updater_logic.rs(manifest URL、版本比较、单测);Android updater.rs 拉取 GitHub Release manifest、minisign 校验、系统安装器安装;保留 APK 200 MB 下载上限。
  • 公钥与安装器UPDATER_PUBKEY_B64tauri.conf.json 同步;installApk 返回 false 时向前端报错;新增 check-android-updater-pubkey.mjs 与 CI 检查。
  • 真机崩溃修复Build.SUPPORTED_ABIS 改读 static field;无障碍状态改 JNI 直读 Settings.Secure;release APK 为 JNI 入口加 @Keep / @JvmStatic;overlay 仅 START_RECORDING 在 API 26+ 使用 startForegroundService,前台失败则取消录音;保留 onDestroynativeNotifyOverlayDestroyed()
  • UI:高级页 Beta 区块与自动更新开关;Beta Toggle 独立 SettingRowuseAutoUpdate 实例级 androidDownloadActiveRef 隔离进度事件,避免 Gate / 手动按钮串扰。
  • CIworkflow_dispatch 在 keystore secrets 齐全时构建 signed release APK;否则回退 unsigned debug 并写 job summary。

兼容

  • 不包含:桌面 updater 行为变更(仍走 plugin-updater);[area:style] 润色结果偶发与原文完全一致,缺少重试提示 #653 历史润色重新润色;Kotlin 安装流程重写;minisign 密钥轮换。
  • 对现有用户 / 本地环境 / 构建流程的影响:
    • Android 用户需授予「安装未知应用」权限才能完成 in-app 更新;无权限时会跳转设置且 UI 显示错误、可重试。
    • 手动 dispatch CI 在 secrets 齐全时产出 release 签名 APK,与 debug 签名不同,跨签名升级需先卸载(与既有 release 行为一致)。
    • 新增 CI 步骤 npm run check:android-updater-pubkey,公钥与 tauri.conf.json 不一致时构建失败。

测试计划

  • 命令:npm run build
  • 结果:通过
  • 证据路径:本地构建
  • 命令:npm run check:android-updater-pubkey
  • 结果:通过
  • 证据路径:本地脚本
  • 命令:cargo metadata --manifest-path openless-all/app/src-tauri/Cargo.toml --filter-platform aarch64-linux-android --format-version 1 --no-deps --locked
  • 结果:通过
  • 证据路径:本地
  • 命令:git diff --check
  • 结果:通过
  • 证据路径:本地
  • 命令:真机 adb install -r + Stable/Beta 手动检查 + 后台 Gate 进度弹窗隔离
  • 结果:待 reviewer 真机复测
  • 证据路径:—

PR Type

Enhancement, Bug fix


Description

  • Port Android auto-update to beta

  • Fix JNI crashes and overlay service issues

  • Add CI signed release APK support


File Walkthrough

Relevant files
Bug fix
6 files
jni.rs
Fix overlay foreground service selection and accessibility JNI
+131/-26
OpenLessAccessibilityService.kt
Add @Keep annotations for JNI methods                                       
+3/-0     
OpenLessOverlayBridge.kt
Add @Keep annotations for JNI object                                         
+4/-0     
OpenLessOverlayService.kt
Fix foreground service failure handling                                   
+37/-18 
OpenLessPermissionBridge.kt
Add @Keep annotation                                                                         
+3/-0     
OpenLessUpdateInstaller.kt
Add @Keep and @JvmStatic annotations                                         
+4/-0     
Enhancement
15 files
mod.rs
Add updater_logic module declaration                                         
+1/-0     
updater.rs
Refactor updater to use shared helpers                                     
+20/-65 
updater_logic.rs
Add pure updater helpers with tests                                           
+123/-0 
AutoUpdate.tsx
Add autoInstallAndroid option and isolate progress             
+86/-54 
AutoUpdateGate.tsx
Enable Android auto-install in background checks                 
+6/-9     
en.ts
Add Android auto-update and beta toggle i18n                         
+12/-1   
ja.ts
Add Android auto-update and beta toggle i18n                         
+12/-1   
ko.ts
Add Android auto-update and beta toggle i18n                         
+12/-1   
zh-CN.ts
Add Android auto-update and beta toggle i18n                         
+12/-1   
zh-TW.ts
Add Android auto-update and beta toggle i18n                         
+12/-1   
AutoUpdateSection.tsx
Add Android auto-update toggle section                                     
+36/-0   
BetaChannelSection.tsx
Restructure Beta toggle with separate row                               
+12/-15 
CheckUpdateButton.tsx
Use explicit channel labels for manual checks                       
+5/-9     
tabs.tsx
Include AutoUpdateSection in Advanced tab                               
+2/-0     
check-android-updater-pubkey.mjs
Add script to validate pubkey consistency                               
+37/-0   
Documentation
4 files
types.rs
Update UpdateChannel and autoUpdateCheck docs                       
+9/-11   
types.ts
Update UpdateChannel and autoUpdateCheck docs                       
+8/-6     
android-mobile-apk-overlay-plan.md
Document in-app updater behavior                                                 
+26/-2   
README.md
Add updater module docs                                                                   
+2/-0     
Configuration changes
3 files
android-apk.yml
Support signed release builds on workflow_dispatch             
+64/-10 
ci.yml
Add Android updater pubkey check step                                       
+3/-0     
package.json
Add check:android-updater-pubkey script                                   
+2/-1     

HKLHaoBin and others added 2 commits June 17, 2026 22:59
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

664 - Partially compliant

Compliant requirements:

  • Android 应用内自动更新(Stable / Beta 渠道、后台检查、手动检查、自动下载安装)
  • 修复 release 构建下 JNI 桥接被 R8 裁剪问题(添加 @keep / @JvmStatic 注解)
  • 修复更新签名校验不一致问题(公钥与 tauri.conf.json 同步)
  • 修复 overlay 前台服务误启动问题(仅 START_RECORDING 使用 startForegroundService,前台失败时取消录音并 stopSelf)
  • 修复无障碍状态 JNI 直读 Settings.Secure
  • 修复 Build.SUPPORTED_ABIS 读 static field
  • 抽取 updater_logic.rs(manifest URL、版本比较、单测)
  • 新增 check-android-updater-pubkey.mjs 与 CI 检查
  • 真机崩溃修复(NoSuchMethodError、ForegroundServiceDidNotStartInTimeException 等)
  • 高级页 Beta 开关 + 自动更新开关;关于页 / 高级页分别手动查 Stable / Beta
  • 新增 Android 自动更新开关(autoUpdateCheck)
  • i18n 翻译(en / zh-CN / zh-TW / ja / ko)
  • 自动安装:发现新版本后自动下载并打开系统安装器

Non-compliant requirements:

  • (无)

Requires further human verification:

  • (无)

666 - Partially compliant

Compliant requirements:

  • (无)

Non-compliant requirements:

  • 检测润色结果与原文是否一致
  • 在 end_session 中写入 errorCode = polishUnchanged
  • 历史重新润色
  • 前端 History 列表 tag、详情 banner、「重新润色」按钮
  • DataStorageSection 全局开关
  • i18n 翻译(润色相关)
  • 单元测试(polish 相关)

Requires further human verification:

  • (无)

653 - Partially compliant

Compliant requirements:

  • (无)

Non-compliant requirements:

  • 识别润色未变化
  • 向用户提供反馈和重试入口
  • 历史记录标识

Requires further human verification:

  • (无)
⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@HKLHaoBin

Copy link
Copy Markdown
Contributor Author

Codex 审查结论:

我已按完整实现链路审查 #704。基于当前 HEAD a8aa8138252f716218ab2d9f9c1bf893766dd925,我认为该 PR 在源码实现和已运行验证范围内可以合入 beta

审查覆盖:

  • Android 自动更新主链路:manifest 生成、Rust 检查/下载/验签/安装、JNI installer 桥接、前端 AutoUpdateGate 自动检查与设置页手动检查。
  • beta channel 行为:latest-android-{arch}-beta.json 路径、设置页开关、手动检查按钮与 manifest channel 对齐。
  • release/JNI 修复:Kotlin bridge/installer 的保留与调用入口,Rust Android 模块拆分后调用关系仍闭合。
  • 前端状态机:多个 useAutoUpdate() 实例共存时,android-update:progress 事件已通过实例级 androidDownloadActiveRef 收口,避免后台自动下载进度串到手动检查按钮或其它 dialog。

已验证:

  • git diff --check beta...HEAD:通过。
  • npm run build:通过;构建仍输出既有 Rollup IPC barrel chunk 警告,未指向本 PR 新增的自动更新链路。
  • npm run check:android-updater-pubkey:通过。
  • cargo metadata --manifest-path openless-all/app/src-tauri/Cargo.toml --filter-platform aarch64-linux-android --format-version 1 --no-deps --locked:通过。
  • PR 当前检查:Android cargo checkLinux checksmacOS checkspr_agent_job 已通过;我评论时 Windows checks 仍在 pending。

边界:

  • 本地未完成 Android APK 实际打包、dex/Keep 保留验证、真机安装与 logcat 验证。
  • Rust 单测此前受本机缺少 MSVC link.exe 影响,未作为本次通过项声明。

担保结论:

  • 未发现需要阻断合并的遗漏。
  • Codex 为本次代码审查范围内的合入结论背书;等待 Windows checks 结束后,可按项目合并策略处理。

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 安卓新版本闪退

1 participant