hex/android/app/src
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Ryan Vogel 5da0e4c28e
Android: a dropped connection fails Hex Preview's update check instead of crashing it (#2618)
* Android: a dropped connection fails Hex Preview's update check instead of crashing it

Why: Channel.latest() read latest.json's body (http.inputStream, readLimited) outside open()'s
try, and open() calls openConnection() before its try. An IOException there, such as a
connection dropped after the 200, was not a Channel.Failure, and Updates.check catches only
Channel.Failure on its "Hex Preview updates" worker thread, so it was uncaught and ended the
process: the app and, during the keyboard's daily check, the keyboard with it. This is an old
gap, present since the updater was added (f1d965ae5, #2531) and in build 2332.

What changed: latest() catches IOException around the whole fetch (open and body read) as
Problem.Connection, which the check already handles: the automatic check stays quiet and
Check now says "Couldn't check". Failure itself is not an IOException, so Server failures pass
through unchanged. No behaviour is removed.

Checked for other ways an update check could throw in the keyboard's process (none needed a
change):
- latest.json parsing: Release.parse and the release-file rule run inside runCatching.
- Date formatting: runCatching, and only on the app's Home card.
- startActivity: Update's ACTION_VIEW catches ActivityNotFoundException and runs only in the
  app; the strip notice opens Hex Preview's own MainActivity.
- Prefs: the keys keep the types every earlier build wrote (automatic Boolean, checked and
  stripDismissed Long, release String), so no ClassCastException; the cache cleanup's
  deleteRecursively doesn't throw.
- getPackageInfo of Hex Preview itself, and the main-thread handling of the result, can't fail
  for a check's outcome.

Verified: ./gradlew :app:testDebugUnitTest :app:testPreviewUnitTest (136 tests each, 0
failures) and :app:assemblePreview green. Not run on a device (no emulator touched); the four
crashes the Play Protect helper saw came from a throwaway 0.2.2-preview.1 test build whose
local-server fetch line skipped open()'s handling, the same class of gap.

* Android README: Hex Preview's Play Protect check before and after publishing

Why: Play Protect blocked build 2332 as harmful, and the fix depended on a test only today's
history describes. Someone publishing the preview later needs the check and the rule in the
README, beside the release script.

What changed: one paragraph in android/README.md's Hex Preview section.
- Before publishing: the dry run's APK gets a Play Protect scan on the Google Play image
  (system-images;android-36;google_apis_playstore;arm64-v8a, AVD hex-playprotect-vogel), signed
  out, installed through the emulator's Chrome from a local http.server on 10.0.2.2, with Scan app
  accepted; it passes on "This app looks safe" (VerifyApps verdict SAFE in logcat). The commands
  are given.
- After publishing: a fresh install of the published file from anoma.ly/hex/android, accepting a
  scan, so Google holds a verdict; a second fresh install shows nothing (logcat response=15).
- The rule: the preview never again declares REQUEST_INSTALL_PACKAGES or
  UPDATE_PACKAGES_WITHOUT_USER_ACTION. Of nine test builds, every one requesting it was judged
  POTENTIALLY_UNWANTED / generic_malware, even with no updater code, and every one without it
  was SAFE; that is why updates go through the browser.

Verified: documentation only; the paths and options match scripts/preview-release.sh's dry run
(android/build/preview/<build>) and the AVD used for the scans. No code changed.
2026-11-24 09:06:35 -05:00
..
main android: Gboard's ?123 and =< symbol pages (#2678) 2026-11-24 06:42:07 -05:00
play/java/ly/anoma/hex/updates Android: Hex Preview, an APK outside Google Play that updates itself (#2531) 2026-11-23 11:37:51 -05:00
preview Android: a dropped connection fails Hex Preview's update check instead of crashing it (#2618) 2026-11-24 09:06:35 -05:00
release Hex for Android: on-device dictation keyboard (#2074) 2026-11-20 17:27:17 +00:00
test/java/ly/anoma/hex android: Gboard's ?123 and =< symbol pages (#2678) 2026-11-24 06:42:07 -05:00