Skip to content

Add in-app update: new-version announcement, in-app download and install - #6455

Open
rasa68 wants to merge 1 commit into
2dust:masterfrom
rasa68:pr/in-app-update
Open

rasa68 wants to merge 1 commit into
2dust:masterfrom
rasa68:pr/in-app-update

Conversation

@rasa68

@rasa68 rasa68 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

What

v2rayNG is released on GitHub (and F-Droid), so many users stay on an old version without noticing new ones, and "Check for update" makes them leave the app to download and install. This PR adds in-app updating:

  • Announcement: when the app starts, a bottom sheet announces a newer release with its notes and two actions, Update now and Later. The check is rate limited (at most once every 3 hours), silent when offline, and respects the existing pre-release switch of the "Check for update" screen: pre-releases are announced only when that switch is on, otherwise only the latest stable release. After Later (or swiping the sheet away) the same version is not announced again; a newer release is.
  • In-app download: Update now downloads the APK inside the app with a progress bar (downloaded / total size, percent) and a Cancel button. It tries a direct connection first and then the local proxy, the same order the update check already uses.
  • Install: after the download the system installer is started. If the app is not allowed to install apps yet, the system screen for that permission opens first. If the user does not allow it, a message says the new version was saved in the Downloads folder so they can install it manually (a copy is stored in the public Downloads folder through MediaStore on Android 10+, and in the app's own Downloads folder on older versions, which would otherwise need a storage permission).
  • The "Check for update" screen uses the same sheet instead of opening the browser, so the manual path also downloads and installs in-app.

Implementation notes

  • UpdateAnnouncementPolicy (pure, no Android types): version comparison (non-numeric parts count as 0 instead of throwing), the "postponed version" rule and the check interval. Covered by JUnit tests.
  • AppUpdateManager: the announcement check, download, copy to Downloads and the install intents. HttpUtil.downloadToFile gains optional progress and cancellation parameters (existing callers unchanged). GitHubRelease.Asset now reads size, and CheckUpdateResult carries the asset name and size.
  • ui/update: AppUpdateController (state machine shared by both screens), AppUpdateSheetHost (Compose; the parts needing an Activity: permission screen and installer), AppUpdateViewModel (startup announcement). The APK goes through the existing ${applicationId}.cache FileProvider.
  • New preferences: the postponed version and the time of the last check. New permission: REQUEST_INSTALL_PACKAGES. Four new strings (translated for all locales in localeFilters; the non-English translations are mine and need native review).

Open question

The F-Droid flavor already finds its own asset in the update check, but F-Droid generally prefers that apps do not install updates themselves. I left the behavior identical for both flavors; if you prefer, I can restrict the download/install (and the permission) to the non-F-Droid flavor and keep the old "open in browser" behavior there.

Verification

  • Verified: the 6 JUnit tests of UpdateAnnouncementPolicy (run with kotlinc outside Gradle, all passed). :app:assembleRelease succeeded in a GitHub Actions build of this exact branch on my fork (compiles and packages).
  • Not run: ./gradlew :app:testPlaystoreDebugUnitTest :app:compilePlaystoreDebugKotlin :app:assemblePlaystoreDebug (no local Gradle run).
  • Not run: checks on a device across Android versions: the announcement sheet (dark theme, RTL), progress and cancel, the install-permission round trip (allowed and denied), installing over the previous version, the Downloads copy on Android 10+ and older, the F-Droid flavor, and behavior without network access to GitHub.

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