Skip to content

feat(android): the app updates itself - #551

Open
vaakx-dev wants to merge 1 commit into
mainfrom
sand/android-in-app-updater
Open

vaakx-dev wants to merge 1 commit into
mainfrom
sand/android-in-app-updater

Conversation

@vaakx-dev

@vaakx-dev vaakx-dev commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

The Android app finds a newer sand.apk on the release its PC follows, downloads it and opens Android's installer.

What

  • Release stamps (sand-build.json) now record committedAt, the HEAD commit time. The Android build already uses that time in seconds as its versionCode.
  • updates reads the sand.apk asset of the release it found for the PC's channel and puts android: { url, sha256, versionCode } on ReleaseInfo. No new GitHub lookups and no second channel setting: the app follows the same release and channel as PC updates.
  • The app passes its versionCode to the page in sandAppStart. Inside the app, Settings › Updates gets a This app section. It offers Update app only when the release's APK has a higher version code, so it never offers a downgrade Android would refuse. The Updates dot lights up for it too.
  • Tapping Update app sends an install message to the app. The app:
    • checks canRequestPackageInstalls() and opens ACTION_MANAGE_UNKNOWN_APP_SOURCES for sand if installs aren't allowed yet, then carries on once they are;
    • downloads the APK on one worker thread to cache/update/sand.apk, sending progress by whole percent;
    • checks the GitHub SHA-256 digest and deletes a download that doesn't match;
    • opens the installer with a FileProvider content:// URI (REQUEST_INSTALL_PACKAGES is now in the manifest).
  • Failures show under the row as plain sentences. The push reply listener now ignores install replies.

Why

  • Updating the app used to mean finding the APK on GitHub by hand.
  • Reusing the PC's update check keeps the channel and release choice in one place.

Verification

  • ./gradlew testDebugUnitTest: new Robolectric tests for the download (bytes, progress up to 100%, bad checksum thrown away), the install-permission intent and the installer intent. On Windows, the installer-intent test fails inside androidx FileProvider, which only matches / path separators. It passes on Linux CI.
  • ./gradlew assembleDebug assembleRelease built both APKs. aapt2 dump shows REQUEST_INSTALL_PACKAGES and the dev.vaakx.sand.files provider in the release manifest. lintDebug reports nothing new; its one error is the existing one in Push.kt.
  • bunx tsc, vrui-check, scripts/deps.ts, scripts/comments.ts, plus bun test on updates, update-banner, devices, release and util: all pass. New tests cover APK asset selection in findRelease and the version comparison.
  • Ran buildHistory on this checkout. committedAt matches git log -1 --format=%ct × 1000.
  • Not yet tried on a phone. No published release has committedAt yet, so the first release after this merges is the first one the app can update to.

- Release stamps record their commit time, which is also the APK's versionCode, so a release offers its sand.apk with the version code it carries.
- Updates in Settings shows a This app row inside the Android app; Update app downloads the APK, checks its SHA-256, asks to allow installs if needed, and opens Android's installer.
@github-actions

Copy link
Copy Markdown

Performance: ✅ every row is within its limit

Main 932d802 against this PR a1bca5a, both measured in the same job, medians of 5 runs. Times, memory and CPU fail when the PR is more than 15% worse, bytes when they grow more than 5%; changes under 20 ms or 2 KB never fail. Logs

main PR change
Phone (4× slower CPU, 150 ms, 9 Mbit/s link)
open a chat: shows 294 ms 288 ms -2.0% ✅
open a chat: usable 303 ms 299 ms -1.3% ✅
first visit with an empty cache: usable 1.89 s 1.87 s -0.9% ✅
open a long chat: usable 297 ms 292 ms -1.9% ✅
send: your message shows 61 ms 57 ms -7.4% ✅
send: first reply text shows 326 ms 328 ms +0.6% ✅
main thread blocked over these steps 547 ms 553 ms +1.1% ✅
data on first visit 931.9 KB 931.8 KB -0.0% ✅
data per chat opened 49.5 KB 49.5 KB 0% ✅
data while idle for 20 s 220 B 220 B 0% ✅
app code a phone downloads 1.6 MB 1.6 MB +0.1% ✅
Main pages (same phone and link)
Settings: time to open 63 ms 59 ms -5.9% ✅
Settings: data to open 100 B 100 B 0% ✅
Settings: data per minute left open 600 B 600 B 0% ✅
Add-ons: time to open 82 ms 87 ms +6.5% ✅
Add-ons: data to open 0 B 0 B 0% ✅
Add-ons: data per minute left open 600 B 600 B 0% ✅
Usage: time to open 62 ms 64 ms +3.2% ✅
Usage: data to open 14.6 KB 14.6 KB 0% ✅
Usage: data per minute left open 600 B 600 B 0% ✅
Search: time to open 76 ms 82 ms +7.9% ✅
Search: data to open 0 B 0 B 0% ✅
Search: data per minute left open 600 B 600 B 0% ✅
Performance: time to open 442 ms 443 ms +0.2% ✅
Performance: data to open 822 B 865 B +5.2% ✅
Performance: data per minute left open 2.1 KB 1.8 KB -12.0% ✅
PC side
start-up until ready 4.03 s 4.03 s -0.0% ✅
memory while idle 237.4 MB 236.6 MB -0.3% ✅
CPU used over 60 s idle 340 ms 320 ms -5.9% ✅
memory after 100 scripted chat turns 273.2 MB 273.3 MB +0.0% ✅
CPU for one reply 49 ms 49 ms 0% ✅
search time on 100k messages 104 ms 107 ms +2.5% ✅
database size per 10k messages 19.8 MB 19.8 MB 0% ✅
worktree list with sizes on 40 worktrees 784 ms 790 ms +0.9% ✅
slowest other reply during a worktree list 43 ms 58 ms +35.7% ✅

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant