Repository navigation
Fix updater stuck on 'Downloading…' — complete download → verify → installer flow - #20
Merged
Merged
Conversation
…taller flow Root cause: after the APK finished downloading, three defects prevented the installer from ever opening and left the JS button on 'Downloading…' forever: 1. REQUEST_INSTALL_PACKAGES was missing from the manifest — Android 8+ cannot resolve the package installer for ACTION_VIEW apk:// intents without it; 2. the plugin caught only Exception (an Error/Throwable after download left the Capacitor PluginCall unanswered forever); 3. JS had no success/error state handling after the call. Fixes (updater only — detection, Worker, releases untouched): - DsmnruAppPlugin.downloadAndInstall: phased download → verify → install with real byte progress events (updateDownloadProgress), .part→.apk promotion only after verification (exists/size/ZIP magic/PackageManager parse/expected versionCode), manual per-hop redirect re-validation via new UpdateUrlPolicy (HTTPS github.com/objects.githubusercontent.com + *.githubusercontent.com CDN only), 15s/30s timeouts, proper stream/connection close, single-flight guard, partial-file cleanup, verified-APK reuse for instant retry, unknown app-sources settings hand-off (UPDATE_INSTALL_PERMISSION_REQUIRED), and the call answered EXACTLY ONCE on every terminal path (catch Throwable). - Manifest: + REQUEST_INSTALL_PACKAGES (sideload installer requirement). - update.js: same dialog; real MB progress, Verifying/Starting installer states, retry + toast on every failure, 90s watchdog, 'Open installer' success state, Later/mandatory behavior preserved. - native.js: onUpdateProgress subscription, expectedVersionCode passthrough, re-resolve injected bridge on each probe. - build.gradle: pinned back to 1.4.1 / 12 (local test build) so the existing GitHub v1.4.2 (code 13) is the update target. - Tests: UpdateUrlPolicyTest (JUnit, plain JVM) + test/update-install.test.mjs (policy contract, FileProvider/Intent contract, jsdom UI state machine: success, download failure, post-download installer failure, permission guidance, watchdog, retry, Later/mandatory, no version bump). Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 37209929 | Triggered | Generic Password | ff0ef91 | android-app/android/app/src/test/java/com/dsmnru/pyq/UpdateUrlPolicyTest.java | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
…ect.opt JSONObject.get(String) throws the checked JSONException, so downloadAndInstall failed 'assembleRelease' with 'unreported exception JSONException' at the expectedVersionCode read. Switch to opt(String), which returns null when absent and never throws — behavior identical: JS/native.js still passes the Worker-reported versionCode, and verifyApk still rejects any package whose versionCode differs. Adds a source regression test locking the accessor choice. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…sion pins Reproduced the 'App logic + Worker API tests' failure with versionName 1.4.2 / versionCode 13. Exactly two tests failed, both stale hard-coded version pins (no production bug, no Worker coupling — worker tests are pure fixtures and build.gradle is never read there): 1. test/fcm.test.mjs (pre-existing, predates PR #20): asserted 'versionCode 12' / versionName "1.4.1" inside a Firebase-wiring test. Written before the repo's own bump commit d99c212, which never updated it — incidental coupling that breaks on every legitimate bump. Now asserts well-formed metadata (integer versionCode, semver versionName) while keeping every Firebase/identity/signing assertion. 2. test/update-install.test.mjs: 'NO version bump' pinned 1.4.1/12 for the temporary local-device updater test against the published v1.4.2 release. Replaced with a well-formedness invariant; the updater logic tests remain fixture-driven (local 1.4.1/12 vs remote v1.4.2/13 as pure data, independent of build.gradle). build.gradle is restored to the production versionCode 13 / versionName "1.4.2" with a comment stating the release flow owns the values. No Worker changes, no release automation changes, existing GitHub releases untouched. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.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
Fixes the in-app updater bug where the v1.4.2 APK downloaded fully ("5.70 MB / 5.70 MB") but the system installer never appeared and the button stayed on "Downloading…" forever. Updater scope only — update detection, the Worker
/api/app-updateendpoint, releases, and all other app features are untouched.Root cause (3 compounding post-download defects)
REQUEST_INSTALL_PACKAGESmissing from the manifest — on Android 8+ the system package installer cannot resolveACTION_VIEWintents forapplication/vnd.android.package-archiveat all without it. The download finished, the installer launch failed silently.catch (Exception)only indownloadAndInstall— anyThrowableafter download left the CapacitorPluginCallunanswered, so the JSawaitnever settled.What changed
DsmnruAppPlugin.java—downloadAndInstallrewritten as a phased pipeline: download (.partfile, real byte-progress events, manual per-hop redirect re-validation, timeouts, UA, streams/connections closed) → verify (exists → plausible/exact size → ZIP magic →PackageManager.getPackageArchiveInfoparse → exactexpectedVersionCode) → atomic.part → .apkrename → install (FileProvidercontent://URI +FLAG_GRANT_READ_URI_PERMISSION, launched on the main thread with a latch so the real outcome is known) → plugin call resolved/rejected exactly once on every terminal path (AtomicBoolean+catch (Throwable)). Invalid/partial files are deleted; a verified APK is kept so retry after granting the install permission skips straight to the installer. Unknown-app-sources is detected viacanRequestPackageInstalls()and the exact settings screen is opened (UPDATE_INSTALL_PERMISSION_REQUIRED) instead of failing opaquely.UpdateUrlPolicy.java(new) — pure-JDK security policy: HTTPS-onlygithub.com/objects.githubusercontent.cominitial URLs,*.githubusercontent.comredirect targets only, no embedded credentials, bounded redirects, APK size floor/ceiling,.apkfilename sanitizing, ZIP-magic sniff. Noandroid.*imports → unit-testable on the JVM.AndroidManifest.xml— addsREQUEST_INSTALL_PACKAGES(required for sideload installs; per-user "Install unknown apps" toggle still fully in the user's control).www/js/update.js— same dialog design; real MB progress, "Verifying…", "Starting installer…", retry + toast on every failure (download and post-download), 90 s watchdog, "Open installer" success state; Later/mandatory behavior preserved.www/js/native.js—onUpdateProgress()subscription,expectedVersionCodepassthrough, bridge re-resolution on each probe.build.gradle— pinned back to 1.4.1 / versionCode 12 (the merged baseline was 13/1.4.2) so the existing GitHub Release v1.4.2 (code 13) remains the update target for the on-device test.Tests
android-app: 91/91 pass, including the newtest/update-install.test.mjs(15 cases: trusted/untrusted URLs, redirect policy, phase separation,.part/rename/cleanup, FileProvider + Intent contract, install-permission guidance, jsdom UI state machine — success / download failure / post-download installer failure / permission / watchdog / retry / Later / mandatory, 1.4.1→v1.4.2 detection, no version bump) and new JUnitUpdateUrlPolicyTest(plain JVM).worker: 139/139 pass — update detection untouched.Version / release safety
versionName "1.4.1",versionCode 12(test-enforced)