feat: add Android APK update sample with GeneralUpdate.Avalonia#118
Merged
Conversation
- Remove UpgradeMode from VerifyDTO and VerificationResultDTO - Remove UpgradeMode-based filtering and logging in Program.cs Co-Authored-By: Claude <noreply@anthropic.com>
- Add UI/AndroidUpdate/ sample project (net10.0-android) - Avalonia UI with MVVM pattern (CommunityToolkit.Mvvm) - Confirmation dialogs for check and download actions - Real-time progress bar with percentage display - App version read from PackageManager (not hardcoded) - Permission check for Android 8+ unknown app sources - Reference GeneralUpdate.Avalonia.Android via compiled DLL (libs/GeneralUpdate.Avalonia.Android.dll) - Modify Server/Program.cs to support .apk format downloads - Use Format field from versions.json for file extension - Search both .zip and .apk in hash lookup - Support non-.zip file extensions in hash computation - Add Android platform entry (Platform=4) to versions.json - Add BaseUrl and Urls config to Server appsettings.json Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a new Avalonia-based Android sample app that demonstrates APK self-update using GeneralUpdate.Avalonia.Android, and extends the sample server to serve non-.zip package formats (notably .apk) via the existing download-by-hash endpoint.
Changes:
- Added
UI/AndroidUpdate/Android APK auto-update sample (UI, MVVM, handler abstraction + Android implementation). - Updated sample Server download logic to honor package
Format/extensions and search.apkpackages. - Updated server configuration (
Urls,BaseUrl) and package metadata (versions.json) to include an Android platform entry.
Reviewed changes
Copilot reviewed 27 out of 29 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| UI/AndroidUpdate/src/AndroidUpdate.Android/Views/MainView.axaml.cs | Adds code-behind for the Android sample’s main view. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Views/MainView.axaml | Implements the update/check/download UI and dialog overlay. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/ViewModels/ViewModelBase.cs | Introduces MVVM base type using CommunityToolkit. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/ViewModels/UpdatePackageInfo.cs | Adds DTO representing server verification response package metadata. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/ViewModels/MainViewViewModel.cs | Implements update flow: verify → download/verify → install. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/ViewModels/IAndroidUpdateHandler.cs | Defines abstraction for platform-specific download/install handler. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/ViewLocator.cs | Adds Avalonia ViewLocator for VM→View mapping. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Services/AndroidUpdateHandler.cs | Android implementation using GeneralUpdate.Avalonia.Android bootstrap APIs. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Resources/xml/network_security_config.xml | Adds dev cleartext network policy for local server access. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Resources/xml/file_paths.xml | Configures FileProvider paths for sharing the downloaded APK. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Resources/values/styles.xml | Adds theme/splash-related styles for Android. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Resources/values/colors.xml | Adds splash background color (light). |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Resources/values-v31/styles.xml | Adds Android 12+ splash screen styling. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Resources/values-night/colors.xml | Adds splash background color (night). |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Resources/drawable/splash_screen.xml | Adds splash screen drawable layer-list. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Resources/drawable-v31/avalonia_anim.xml | Adds animated vector drawable for splash (v31). |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Resources/drawable-night-v31/avalonia_anim.xml | Adds night variant of animated vector drawable (v31). |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Properties/AndroidManifest.xml | Declares permissions + FileProvider for APK installation. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/MainActivity.cs | Adds Avalonia Android main activity. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/App.axaml.cs | Wires up DI-ish creation of VM + handler factory hook. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/App.axaml | Adds Fluent theme + ViewLocator template registration. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/AndroidUpdate.Android.csproj | Adds Android project config + package refs + GeneralUpdate DLL reference. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/AndroidApp.cs | Initializes handler factory and reads device version via PackageManager. |
| UI/AndroidUpdate/AndroidUpdate.slnx | Adds solution for the new Android sample project. |
| src/Server/wwwroot/packages/versions.json | Adds Android platform entry and .apk format metadata. |
| src/Server/Program.cs | Extends download and package size/hash discovery logic to use Format/.apk. |
| src/Server/appsettings.json | Adds Urls and BaseUrl configuration values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+204
to
+223
| if (success) | ||
| { | ||
| CurrentVersion = _pendingUpdate.Version; | ||
| StatusText = $"Updated to v{CurrentVersion}!"; | ||
| DownloadProgress = 100; | ||
| ProgressText = "Done"; | ||
| } | ||
| } | ||
| catch (OperationCanceledException) | ||
| { | ||
| StatusText = "Cancelled."; | ||
| } | ||
| finally | ||
| { | ||
| IsDownloading = false; | ||
| _cts?.Dispose(); | ||
| _cts = null; | ||
| _currentHandler?.Dispose(); | ||
| _currentHandler = null; | ||
| } |
| ); | ||
| } | ||
|
|
||
| private static string ServerBaseUrl => "http://192.168.50.204:5000"; |
Comment on lines
+4
to
+6
| <cache-path name="cache" path="update/" /> | ||
| <cache-path name="cache_root" path="/" /> | ||
| <files-path name="files" path="update/" /> |
Comment on lines
+6
to
+12
| public sealed record PackageInfo( | ||
| string Version, | ||
| string DownloadUrl, | ||
| string Sha256, | ||
| long FileSize, | ||
| string? Description, | ||
| bool IsForced); |
- Rename PackageInfo to UpdatePackageDto to avoid collision with Android SDK type - Use TaskCreationOptions.RunContinuationsAsynchronously for dialog TCS - Restore HasUpdate on download failure so retry is possible - Reset _pendingUpdate only after successful update - Replace global cleartext flag with targeted network_security_config - Tighten FileProvider paths to dedicated update/ subfolder only - Change BaseUrl to localhost (LAN IP was environment-specific) - Make ServerBaseUrl configurable via ANDROID_UPDATE_SERVER_URL env var Co-Authored-By: Claude <noreply@anthropic.com>
Collaborator
Author
|
All 7 review comments have been addressed in commit a160a2b:
|
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.
Closes #117
Summary
Adds a new Android APK auto-update sample project at
UI/AndroidUpdate/and modifies the Server to support.apkformat downloads.Key files
UI/AndroidUpdate/AndroidUpdate.slnxUI/AndroidUpdate/src/AndroidUpdate.Android/AndroidUpdate.Android.csprojsrc/Server/Program.cssrc/Server/wwwroot/packages/versions.jsonVerification
/File/Download/{hash}