feat: add MAUI Android update sample#119
Merged
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>
- 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>
Adds a complete .NET MAUI Android sample demonstrating auto-update integration with GeneralUpdate.Maui.Android library. Includes: - MauiUpdate.Android client app with MVVM pattern (CommunityToolkit.Mvvm) - Update server (ASP.NET Minimal API) for version check and APK delivery - Full update flow: check → download → verify SHA256 → install - Platform config: AndroidManifest, FileProvider, network security - Real device version detection via PackageManager - Support for 'Install unknown apps' permission flow on Android 8+ The sample mirrors the pattern from UI/SemiUrsa (Avalonia) and UI/AndroidUpdate (Avalonia.Android) samples. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: JusterChu <juster.chu@foxmail.com>
Adds a .slnx solution file referencing the client and server projects for easier management in IDEs. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a new .NET MAUI Android sample app plus a small companion update server to demonstrate the GeneralUpdate.Maui.Android update flow (check → download → verify → install), and adjusts existing Android/Avalonia sample assets + the main sample server to better support Android APK-style packages.
Changes:
- Introduces
UI/MauiUpdate(MAUI Android client + minimal API server) implementing an end-to-end update workflow. - Adds/updates
UI/AndroidUpdate(Avalonia Android) UI + handler plumbing and Android resources (manifest/FileProvider/network security). - Updates the main sample server to support variable package extensions (e.g.,
.apkas well as.zip) and adds related configuration.
Reviewed changes
Copilot reviewed 47 out of 51 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| UI/MauiUpdate/src/MauiUpdate.Android/Views/MainPage.xaml.cs | MAUI page code-behind wiring DI-provided ViewModel. |
| UI/MauiUpdate/src/MauiUpdate.Android/Views/MainPage.xaml | MAUI UI layout for version/status/progress/actions. |
| UI/MauiUpdate/src/MauiUpdate.Android/ViewModels/MainViewModel.cs | MVVM logic for verification request + download/install workflow. |
| UI/MauiUpdate/src/MauiUpdate.Android/Services/MauiUpdateHandler.cs | Wrapper around GeneralUpdate.Maui.Android bootstrap + events/options mapping. |
| UI/MauiUpdate/src/MauiUpdate.Android/Resources/Styles/Styles.xaml | Shared MAUI styles (Page/Label/Button). |
| UI/MauiUpdate/src/MauiUpdate.Android/Resources/Styles/Colors.xaml | Shared MAUI color resources. |
| UI/MauiUpdate/src/MauiUpdate.Android/Resources/Splash/splash.svg | MAUI splash asset. |
| UI/MauiUpdate/src/MauiUpdate.Android/Resources/AppIcon/appicon.svg | MAUI app icon asset. |
| UI/MauiUpdate/src/MauiUpdate.Android/Platforms/Android/Resources/xml/network_security_config.xml | Android network security config for dev hosts/cleartext. |
| UI/MauiUpdate/src/MauiUpdate.Android/Platforms/Android/Resources/xml/file_paths.xml | FileProvider paths for update artifacts. |
| UI/MauiUpdate/src/MauiUpdate.Android/Platforms/Android/MainApplication.cs | MAUI Android Application entry. |
| UI/MauiUpdate/src/MauiUpdate.Android/Platforms/Android/MainActivity.cs | MAUI Android Activity entry. |
| UI/MauiUpdate/src/MauiUpdate.Android/Platforms/Android/AndroidManifest.xml | Android manifest (permissions, network security config, FileProvider). |
| UI/MauiUpdate/src/MauiUpdate.Android/Models/UpdatePackageDto.cs | DTO for server response + auth fields for downloads. |
| UI/MauiUpdate/src/MauiUpdate.Android/MauiUpdate.Android.csproj | MAUI Android project definition + package references/resources. |
| UI/MauiUpdate/src/MauiUpdate.Android/MauiProgram.cs | MAUI DI registrations (HttpClient, handler, VM, page). |
| UI/MauiUpdate/src/MauiUpdate.Android/App.xaml.cs | MAUI Application + window creation. |
| UI/MauiUpdate/src/MauiUpdate.Android/App.xaml | App resource dictionary merges (colors/styles). |
| UI/MauiUpdate/server/Server.csproj | Minimal API server project for the MAUI sample. |
| UI/MauiUpdate/server/Program.cs | Minimal API endpoints for verification/report and serving APKs. |
| UI/MauiUpdate/nuget.config | Adds local NuGet feed configuration for the MAUI sample. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Views/MainView.axaml.cs | Avalonia UserControl code-behind initialization. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Views/MainView.axaml | Avalonia UI for checking/downloading/installing updates + dialog overlay. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/ViewModels/ViewModelBase.cs | Base VM type (ObservableObject). |
| UI/AndroidUpdate/src/AndroidUpdate.Android/ViewModels/UpdatePackageDto.cs | Update package record used by Avalonia Android sample. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/ViewModels/MainViewViewModel.cs | Avalonia Android sample MVVM workflow and dialog orchestration. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/ViewModels/IAndroidUpdateHandler.cs | Abstraction for platform update handler used by the VM. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/ViewLocator.cs | Avalonia view locator for VM→View mapping. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Services/AndroidUpdateHandler.cs | GeneralUpdate.Avalonia.Android integration for download/verify/install. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Resources/xml/network_security_config.xml | Android network security config for Avalonia Android sample. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Resources/xml/file_paths.xml | FileProvider paths for the Avalonia Android sample. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Resources/values/styles.xml | Android styles for splash/theme. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Resources/values/colors.xml | Android colors for splash background (light). |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Resources/values-v31/styles.xml | Android 12+ splash screen styles. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Resources/values-night/colors.xml | Android colors for splash background (dark). |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Resources/drawable/splash_screen.xml | Drawable splash screen composition. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Resources/drawable-v31/avalonia_anim.xml | Android 12+ animated vector splash (light). |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Resources/drawable-night-v31/avalonia_anim.xml | Android 12+ animated vector splash (dark). |
| UI/AndroidUpdate/src/AndroidUpdate.Android/Properties/AndroidManifest.xml | Avalonia Android manifest (permissions, FileProvider, net sec config). |
| UI/AndroidUpdate/src/AndroidUpdate.Android/MainActivity.cs | Avalonia Android activity entry. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/App.axaml.cs | Avalonia app startup + DI-ish wiring for handler factory. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/App.axaml | Avalonia app styles + data templates. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/AndroidUpdate.Android.csproj | Avalonia Android project definition + references/resources. |
| UI/AndroidUpdate/src/AndroidUpdate.Android/AndroidApp.cs | Avalonia Android Application bootstrapping + version detection + handler factory. |
| UI/AndroidUpdate/AndroidUpdate.slnx | Solution file for the AndroidUpdate sample. |
| src/Server/wwwroot/packages/versions.json | Adds/adjusts package entries (incl. APK-style entry) and formatting. |
| src/Server/Program.cs | Extends download handling to support non-.zip formats via Format. |
| src/Server/appsettings.json | Adds Urls/BaseUrl configuration keys for server binding + link generation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+3
to
+7
| <packageSources> | ||
| <clear /> | ||
| <add key="local-packages" value="C:\github code\GeneralUpdate-Samples\UI\local-packages" /> | ||
| <add key="nuget.org" value="https://api.nuget.org/v3/index.json" /> | ||
| </packageSources> |
Comment on lines
+24
to
+26
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" /> | ||
| <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" /> |
Comment on lines
+118
to
+120
| var latest = packages[0]; | ||
| latest.DownloadUrl = $"{_serverUrl}/packages/{latest.PacketName}.apk"; | ||
|
|
Comment on lines
+189
to
+191
| Format = _pendingUpdate.Format, | ||
| Size = _pendingUpdate.Size, | ||
| DownloadUrl = $"{_serverUrl}/packages/{_pendingUpdate.PacketName}.apk" |
Comment on lines
+9
to
+13
| <!-- Also trust user-installed CAs for debugging --> | ||
| <trust-anchors> | ||
| <certificates src="user" /> | ||
| <certificates src="system" /> | ||
| </trust-anchors> |
Comment on lines
+20
to
+34
| app.MapGet("/packages/{filename}", async (string filename, HttpContext context) => | ||
| { | ||
| // Sanitize filename to prevent path traversal | ||
| var sanitized = Path.GetFileName(filename); | ||
| var filePath = Path.Combine(packagesDir, sanitized); | ||
| if (!File.Exists(filePath)) | ||
| { | ||
| return Results.NotFound(new { error = "Package not found.", filename = sanitized }); | ||
| } | ||
|
|
||
| var fileInfo = new FileInfo(filePath); | ||
| context.Response.Headers.Append("Content-Disposition", $"attachment; filename=\"{sanitized}\""); | ||
| context.Response.Headers.Append("Accept-Ranges", "bytes"); | ||
| return Results.File(filePath, "application/vnd.android.package-archive", sanitized); | ||
| }); |
Comment on lines
+3
to
+6
| <domain-config cleartextTrafficPermitted="true"> | ||
| <domain includeSubdomains="true">192.168.50.204</domain> | ||
| <domain includeSubdomains="true">localhost</domain> | ||
| </domain-config> |
- Fix nuget.config: use relative path for local feed, keep nuget.org - Fix .csproj: use explicit MAUI version instead of unset - Fix network_security_config: remove hardcoded LAN IP, remove user CAs - Fix MainViewModel: use generic localhost default, use Format extension - Fix server endpoint: enable range processing, remove unused variable Co-Authored-By: Claude <noreply@anthropic.com>
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
Adds a complete .NET MAUI Android sample demonstrating auto-update integration with GeneralUpdate.Maui.Android, following the same architecture as the existing Avalonia (UI/SemiUrsa) and Avalonia.Android (UI/AndroidUpdate) samples.
Structure
Features
AppInfo.VersionStringfrom installed packageVerification
Co-Authored-By: Claude noreply@anthropic.com