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.