Repository navigation
Android: Hex Preview's update download survives leaving the app; setup says Hex Preview - #2552
Merged
Merged
Conversation
Hex Preview's first run said "Set up Hex", "choose Hex as your keyboard", a
"Hex keyboard" row with "Turn on Hex in Settings" / "Choose Hex in the list",
and "Choose Hex keyboard", while Android's keyboard list, keyboard picker and
microphone prompt say "Hex Preview" (and list both "Hex" and "Hex Preview"
for anyone who also has the Play app), so a person could turn on or pick the
wrong keyboard. Its welcome also said Hex uses the internet only for the
speech model, which isn't true for Hex Preview: it also asks GitHub for
updates.
What changed (preview build type only, src/preview/res, English and Simplified
Chinese; src/main and the Play builds are unchanged):
- setup_title, setup_detail, setup_microphone_detail, setup_keyboard,
setup_keyboard_enabled, setup_keyboard_off, setup_choose_hex now name
"Hex Preview".
- keyboard_hint_microphone ("Allow the microphone in Hex Preview"): the
keyboard's hint tells the person which app to open; MicCapture's sentinel
sentence still maps to this resource, so no code changed.
- setup_welcome_detail: "Hex Preview uses the internet only to download its
speech model (190 MB) and to check GitHub for updates. Your voice and words
stay on this device."
"The Hex key", "Hex menu", "Hex dictation" and the keyboard's TalkBack pane
name stay as they are: they name the key and the keyboard's own parts, not
something to find in Android's lists.
Verified on the Mac Studio (with the next commit): :app:testDebugUnitTest
passes; :app:assemblePreview -PhexPreviewBuild=2300 builds, and aapt2 dump
strings shows the new English and Chinese strings in app-preview.apk.
…aves the app
On Android 16 (API 36) the update download, a plain HTTPS read on the
updater's own thread, was cut off about 5 s after the person left Hex
Preview, and the Home card then said "The download stopped..." with Try
again. API 31 was unaffected.
What changed (src/preview only; the Play builds and src/main are unchanged):
- Android 14+ (API 34): the tap on Update (or Download after the mobile-data
note, or Try again) schedules a user-initiated data transfer job
(UpdateJob: setUserInitiated, NETWORK_TYPE_ANY, the APK's size as its
estimated bytes, the release in its extras). The job posts its
notification first thing, then runs the same download and checks as
before on the updater's worker (Channel.download's host allow-list, size
and SHA-256, then Channel.verify's package, build and signing-key checks,
untouched), updating the Home card and the notification's progress.
onStopJob ends the download at its next read, which deletes the partial
file and shows the same "download stopped" card; it is not rescheduled.
With no network at all, or if Android refuses the job, the download runs
in-process as before.
- When the job's download is checked: if Hex Preview's window shows, it
installs exactly as before. If not, nothing installs from the background:
the verified file stays, a notification says "Hex Preview <version> is
downloaded" / "Open Hex Preview to install it.", and the Home card shows
Install (kept across a restart of the process while the file is still
there). Install checks the file's size, SHA-256 and signing key again
before the installer session; if Android cleared it from the cache, it
downloads again (asking first on mobile data). Nothing installs without
the person's tap.
- Below Android 14 the in-process download is unchanged (the same code,
moved into Updates.fetch, which both paths share).
New permission (preview manifest only): android.permission.RUN_USER_INITIATED_JOBS,
plus the UpdateJob service guarded by BIND_JOB_SERVICE (not exported). No
POST_NOTIFICATIONS is declared or asked for, so there is no new prompt.
What the person sees: the Home card's progress as before, and Android's
running-apps list (Task Manager) shows Hex Preview while the job runs. The
notification ("Downloading Hex Preview <version>" with progress, in a
low-importance "Updates" channel; tapping opens Hex Preview) appears in the
notification shade only where Hex Preview may post notifications, which by
default it can't on Android 13+.
Verified on the Mac Studio: :app:testDebugUnitTest passes;
:app:assemblePreview -PhexPreviewBuild=2300 builds (lintVital included);
aapt2 dump badging shows ly.anoma.hex.preview, versionCode 2300, label
"Hex Preview"; aapt2 dump permissions lists RUN_USER_INITIATED_JOBS; the
manifest has the UpdateJob service with BIND_JOB_SERVICE; apksigner verify
passes with certificate SHA-256 133568f6...35d98e. Not yet run on a phone
or emulator.
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.
Two commits, both under
android/app/src/preview/only (Play builds andsrc/mainunchanged). Not for merge by the author. Both reach people as Hex Preview's first update through the app.1. f84143a: setup names "Hex Preview", as Android's lists do. Found on a first run of published build 2305 from the real link: Hex Preview's setup said "Set up Hex", "choose Hex as your keyboard", "Turn on Hex in Settings", "Choose Hex in the list", while Android's Turn on list, keyboard picker and microphone prompt say "Hex Preview" (and, with the Play app installed, the picker offers both "Hex" and "Hex Preview"). Preview-only overrides (English and Simplified Chinese) of
setup_title,setup_detail,setup_microphone_detail,setup_keyboard,setup_keyboard_enabled,setup_keyboard_off,setup_choose_hex,keyboard_hint_microphone, andsetup_welcome_detail, which also stops claiming the internet is used only for the speech model (it now names the GitHub update check). "The Hex key" stays.2. 4e90199: the update download keeps going when the person leaves the app (Android 14+). On Android 16 the in-process download was cut off about 5 s after leaving Hex Preview. The tap on Update now schedules a user-initiated data transfer job (
UpdateJob) running the unchangedChannel.downloadandChannel.verify. If the app is in front when it finishes, it installs as before; if not, nothing installs from the background: the verified file stays and the Home card shows Install, which re-checks size, SHA-256 and signing key before the installer runs. Below Android 14 nothing changes.android.permission.RUN_USER_INITIATED_JOBSand theUpdateJobservice (BIND_JOB_SERVICE, not exported). NoPOST_NOTIFICATIONS.POST_NOTIFICATIONSdeclared, Android's settings say "This app does not send notifications" and can't turn it on.Verified on an Android 16 emulator with this branch built as build 2300 (preview key), updating to the real channel's published 2305 (nothing published, test fork untouched):
cmd jobscheduler timeout): partial file deleted, card says "The download stopped…" with Try again, which then completed;./gradlew :app:testDebugUnitTestpasses; APK signed with the preview certificate, badging and permissions checked.Not verified: a slow connection long enough to exceed the old cut-off by minutes (the emulator's network couldn't be throttled; the background run was ~8 s against the observed ~5 s cut-off), Android 14/15, and real phones.