fix: 补齐 Android 升级闭环并重构可靠性与集成接口 - #21
Conversation
Track installation outcomes across restarts, normalize cancellation and retries, manage HTTP ownership, and extract injectable package and persistence services. Simplify the sample with a testable view model and preparation/reset APIs. Refs #20 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
@copilot 初始化的地方加一个中英文的配置选项,让用户决定当前组件中的提示内容显示中文还是英文。 |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Global authentication can leak to untrusted download origins, and custom source timeouts can escape the result-based API.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Completes Android’s update lifecycle with durable installation confirmation, resilient downloads, injectable services, and a testable sample architecture.
Changes:
- Adds installation journaling, reconciliation, reset, and preparation APIs.
- Improves HTTP retries, timeout handling, ownership, and disposal.
- Refactors the sample and expands tests, documentation, and CI.
| File | Description |
|---|---|
tests/.../UpdateViewModelTests.cs |
Tests sample lifecycle and recovery. |
tests/.../UpdateTestDoubles.cs |
Adds reusable test doubles. |
tests/.../UpdatePreparationTests.cs |
Tests preparation, disposal, and reset. |
tests/.../UpdateFlowEndToEndTests.cs |
Extends end-to-end restart coverage. |
tests/.../InstallationTrackingTests.cs |
Tests durable installation tracking. |
tests/.../GeneralUpdate.Avalonia.Android.Tests.csproj |
Links new production and sample sources. |
tests/.../DownloadReliabilityTests.cs |
Tests retries, timeouts, and ownership. |
src/.../Services/UpdateHttpClientFactory.cs |
Centralizes HTTP-client construction. |
src/.../Services/JsonFileInstallationStore.cs |
Implements durable JSON journaling. |
src/.../Services/HttpUpdatePackageClient.cs |
Implements injectable package discovery. |
src/.../Services/HttpResumableApkDownloader.cs |
Adds retry and resume reliability. |
src/.../Services/AndroidBootstrap.cs |
Orchestrates preparation and reconciliation. |
src/.../README.zh-CN.md |
Updates Chinese package guidance. |
src/.../README.md |
Updates package documentation. |
src/.../README.en.md |
Updates English package guidance. |
src/.../Models/UpdatePreparationResult.cs |
Adds preparation result model. |
src/.../Models/InstallationRecord.cs |
Defines durable installation records. |
src/.../Models/InstallationCheckResult.cs |
Defines reconciliation results. |
src/.../Models/HttpDownloadOptions.cs |
Documents and validates transport policies. |
src/.../Models/AndroidUpdateOptions.cs |
Adds journal path configuration. |
src/.../GeneralUpdateBootstrap.cs |
Wires new default dependencies. |
src/.../Events/UpdateCompletedEventArgs.cs |
Clarifies event semantics. |
src/.../Events/InstallationConfirmedEventArgs.cs |
Adds confirmation event data. |
src/.../Enums/UpdateState.cs |
Adds installation states. |
src/.../Abstractions/IUpdatePackageSource.cs |
Introduces package-source abstraction. |
src/.../Abstractions/IInstallationStore.cs |
Introduces journal-store abstraction. |
src/.../Abstractions/IAndroidBootstrap.cs |
Exposes new lifecycle APIs. |
samples/.../Views/MainView.axaml.cs |
Reduces view code-behind responsibilities. |
samples/.../Views/MainView.axaml |
Adds compiled ViewModel bindings. |
samples/.../ViewModels/UpdateViewModel.cs |
Implements sample update orchestration. |
samples/.../README.md |
Documents sample integration and validation. |
samples/.../Infrastructure/IUpdateHost.cs |
Abstracts platform integration. |
samples/.../Infrastructure/AndroidUpdateHost.cs |
Implements Android platform services. |
samples/.../GeneralUpdate.Avalonia.Android.Sample.csproj |
Adjusts Android publish RID behavior. |
README.md |
Documents the complete Chinese workflow. |
README-EN.md |
Documents the complete English workflow. |
.github/workflows/ci-cd.yml |
Builds the Android sample in CI. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| _globalAuthProvider = null; | ||
| _ownsClient = false; | ||
| _httpOptions = httpOptions; | ||
| _globalAuthProvider = httpOptions?.AuthProvider; |
|
|
||
| if (compare > 0) | ||
| cancellationToken.ThrowIfCancellationRequested(); | ||
| packageInfo = await _packageSource.GetLatestAsync(currentVersion, cancellationToken).ConfigureAwait(false); |
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
Added an |
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
Localized the sample’s UI prompts, input-validation and Android platform exceptions, and added a persisted language selector that configures the updater during initialization. 114 tests pass. Commit: |
|
@copilot 修复当前会话中copilot提出的修复建议 |
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
Addressed the two review findings: global download auth is restricted to the configured HTTPS verification origin and HTTP downloads require an explicit opt-out; package-source timeouts now return a network failure result/event. 120 tests pass. Commit: |


关联问题
Closes #20
变更内容
CheckInstallationAsync和首次持久化确认事件,支持跨进程恢复;损坏记录通过显式ResetInstallationAsync恢复。IUpdatePackageSource、IInstallationStore;新增PrepareUpdateAsync在一个操作锁内完成查询、比较、pre-check、下载和校验,不自动打开 UI。兼容性与行为说明
AddListenerUpdateCompleted仍表示ReadyToInstall/Installing阶段完成,不表示安装成功。LocalApplicationData/update/installation.json,不再隐式关闭跟踪;依赖注入构造函数要求提供安装存储。CreateDefault默认查询/HEAD 超时 30 秒、总下载超时 10 分钟、最多 3 次下载尝试;元数据查询不重试。超时报告网络失败,主动取消报告取消。OperationCanceledException。建议取消并等待活动操作结束后再 Dispose。验证
dotnet test tests/GeneralUpdate.Avalonia.Android.Tests/GeneralUpdate.Avalonia.Android.Tests.csproj -c Release --no-restore:106 个测试通过。git diff --check通过。尚需真机验收
未连接 Android 设备,尚未验证真实 APK 覆盖安装。端到端自动化中的安装器为模拟实现,不能替代真机验收。用户仍需确认系统安装并重新打开应用;不提供静默安装、自动重启、健康检查或回滚。APK 必须同包名、兼容签名且 versionCode 递增。