Repository navigation
In-app update check, Play-safe by design - #24
Merged
Merged
Conversation
Settings > About now has a real "Check for updates" row.
- UpdateChecker reads the GitHub releases feed and compares dotted versions numerically
(1.0.99 < 1.0.100), so the check works without any account or API key
- The action depends on the install source, which is the only compliant design:
* installed from Google Play -> opens the Play listing, no APK is downloaded
(Play's Device and Network Abuse policy forbids self-updating a Play-distributed app)
* sideloaded -> downloads the release APK and installs it
- The sideload path verifies before it trusts anything: signing certificate must match the
running app, versionCode must be newer, and a published .apk.sha256 is checked when present.
A file that fails any check is deleted, never offered to the installer
- Unknown-sources permission is requested through the proper per-app settings screen
- The About screen now shows the real version name instead of the hardcoded 1.0.0
- 5 unit tests for the version comparison
|
Caution Review failedThe pull request is closed. Walkthrough
Change: Feature
|
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.
Settings > About now has a working Check for updates row.
The policy constraint drives the design
Google Play's Device and Network Abuse policy: "An app distributed via Google Play may not modify, replace, or update itself using any method other than Google Play's update mechanism."
So the row does one of two things, decided at runtime by the install source:
com.android.vending)No build flavour is needed: a Play install can never reach the self-install path, so the Play-distributed build cannot violate the policy.
The sideload path trusts nothing
UpdateInstaller.verifySignature). A mismatch deletes the file and reports it..apk.sha256asset, the download is verified against it.A file that fails any check is deleted, never handed to the installer.
Also in here
UpdateCheckerreads the GitHub releases feed; dotted versions compare numerically, so1.0.99is correctly older than1.0.100(5 unit tests).ACTION_MANAGE_UNKNOWN_APP_SOURCES).1.0.0before.REQUEST_INSTALL_PACKAGESis declared, with a comment explaining it exists only for the sideload path.Honest limits
versionCodethan the Play build, Play cannot update it until Play's version code catches up. Keep the Play version ahead.Summary by CodeRabbit