feat: Home button on Google TV without ADB (accessibility service) #34

Merged
namillis merged 1 commit from feat/accessibility-home into main 2026-11-24 21:13:26 +00:00
Owner

Adds an optional way for Google TV users to open Glass Launcher with the remote's Home button, without the one-time ADB setup. It follows the design in issue #45 on GitHub, with one change. That design filtered every key press, which on TVs stops a held volume key from repeating. This PR pauses the filtering after each volume change (see What changed). Gabriel (the repo owner) tried the debug build on his TV and asked for this PR to be opened and merged.

One commit: e44d2be, on top of current main 8868bcc (the merge of #33, 5/6/7 icons per row). Gabriel tried a build of 054ab85. That commit has exactly the same files as e44d2be (same git tree, abe6ab0). It was only re-authored to the repo's noreply email before pushing.

Terms used below:

  • Google TV / Android TV: Google's TV operating system. On Google TV the Home button always opens Google's own launcher, even when another app is chosen as Home.
  • Stock launcher packages: com.google.android.apps.tv.launcherx (Google TV's home screen), com.google.android.tvlauncher (older Android TV's home screen) and com.google.android.tungsten.setupwraith (Google TV's setup app, which can also take Home).
  • Default Home: the app Android opens for Home. The existing ADB setup (Settings > Default home & backup > Default home) makes Glass the default Home by turning the stock launcher off over the TV's own debugging connection.
  • Accessibility service: a background helper the user switches on in Android's Accessibility settings. It can see key presses before apps do, and which app comes to the front. An app can't switch its own service on or off; only the user can, in that screen.
  • Key filtering: the accessibility-service mode that sends every key press to the service first.
  • Recents: Android's recent-apps screen.

What changed

  • The service (HomeButtonService.java, res/xml/home_button_service.xml, AndroidManifest.xml). When the service is on and Glass is not the default Home, a short Home press is swallowed and brings Glass to the front. It is also meant to bring Glass back when a stock launcher window comes to the front anyway (after boot, waking from standby, or an app opening Home). When Glass is already the default Home, for example after the ADB setup, the service does nothing, so the two never fight. Every key other than Home goes straight back to Android. The config asks for no screen content (canRetrieveWindowContent=false), only window changes from the three stock launcher packages.
  • Volume hold. With key filtering on, many Android TVs apply each volume press but drop the key repeat, so a held key moves one step. The service listens for android.media.VOLUME_CHANGED_ACTION (a stable but unpublished Android broadcast) and turns key filtering off for 4 seconds after each volume change, so a hold ramps. If a TV never sends that broadcast, only the hold fix is lost. During those 4 seconds a Home press goes to the stock launcher first.
  • Long-press Home (held 500 ms or more) opens Recents, or Glass if the TV has no Recents screen. A swallowed press can't be handed back to Android, so the stock launcher's own long-press action can't be reproduced.
  • Decision logic (HomeOverridePlan.java, HomeOverridePlanTest.java). The rules live in a pure Java class with 20 unit tests: which keys pass, the short/long split, not bringing Glass back within 1.5 s of the service's own launch of Glass or of a long press (so its own transition and Recents aren't undone), reading Android's enabled-services setting, and the On / Off / Not needed status. It copies the pattern of GoogleTvSetupPlan, the ADB setup's tested rule class.
  • Settings (LauncherActivity.java, strings.xml). Default home & backup gets a Home button row showing On, Off or Not needed (Glass is already the default Home). Its page has the status and a Turn on Home button or Turn off Home button row; both open Android's Accessibility settings, where the user flips the switch. Two notes say Google TV Home keeps running, and that the system wallpaper and pinned shortcuts don't apply while Glass isn't the default Home. Turn on first shows a consent screen: the service reads only the Home key and which launcher is in front, never screen content. Continue asks for Glass's own toggle screen, and opens the Accessibility list on TVs without it.
  • Docs (README.md, CHANGELOG.md). README has a "Home button without ADB (Google TV)" section with the steps, trade-offs and the Android 13+ restricted-settings note. CHANGELOG has an Unreleased entry.

No new permissions. minSdk stays 26 (Android 8). Glass's own Back up settings file gets nothing new, because Android stores whether the service is on.

Screenshots

Glass Launcher on the emulator (Android TV 14, API 34, 1080p), set up like a TV without the ADB setup: the stock launcher is the default Home.

Default home & backup, service on Home button page, service on
device page home button on
Home button page, service off Consent screen after Turn on
home button off consent

How it was checked

  • On the head, each as its own Gradle run: 308 unit tests pass (20 new), 0 failed. Lint has 0 errors and 9 warnings; main has 8. The new one says isAccessibilityTool is read only on Android 12 and newer, where it tells Android this is not an assistive tool; older versions ignore it and lose nothing. assembleDebug and assembleDebugAndroidTest build. No instrumented tests were added; the existing ones were compiled, not run.
  • Emulator (Android TV 14) with the stock launcher as default Home: with the service on, opening the stock launcher put Glass back in front; with it off, the stock launcher stayed. That is the bring-back path. The settings screens show On and Off as above, and Continue opened Android's Accessibility list.
  • Gabriel's TV (hometv: Google TV, Android 11, real remote): release Glass is its default Home through the ADB setup, so Google TV Home is turned off there. He installed the 054ab85 debug build next to it and said it works. Which behaviors he tried wasn't recorded, nothing was measured, and the service is off on the TV now.
  • Size: the debug APK grows by 9,949 bytes (2,014,879 to 2,024,828).

Not covered yet

  • A Google TV where launcherx is still on (no ADB setup), with a real remote. That is the main target, and the bring-back path has only run on the emulator.
  • A recorded check of the Home-key path, volume hold, the 4-second Home behavior and long-press Home on a remote. The emulator's injected keys skip key filtering, so only a real remote can show these.
  • Boot and standby wake on a device, and the service staying on after a reboot.
  • The direct Glass toggle screen after Continue, and the Not needed state on a screen (unit tests only).
  • Android 8 to 10, and Android 13+ sideloads, where the toggle can stay greyed out until "Allow restricted settings" is turned on.

Glass is sideload-only, so Google Play's accessibility declaration doesn't apply.

Trying it

Debug APK: GlassLauncher-accessibility-home-054ab85-debug.apk, sha256 9c7701c1e180947ad233478af9b7882714df0f9704617aa7168d32d4ca84471d, built from the same files as the head. Install it with adb install -r. Open Settings > Default home & backup > Home button > Turn on Home button, choose Continue, and switch on "Glass Launcher – Home button". If a release build is also installed and is the default Home, Home opens the debug build while its service is on.

Adds an optional way for Google TV users to open Glass Launcher with the remote's Home button, without the one-time ADB setup. It follows the design in [issue #45](https://github.com/namillis/GlassLauncherTV/issues/45) on GitHub, with one change. That design filtered every key press, which on TVs stops a held volume key from repeating. This PR pauses the filtering after each volume change (see What changed). Gabriel (the repo owner) tried the debug build on his TV and asked for this PR to be opened and merged. **One commit:** `e44d2be`, on top of current main `8868bcc` (the merge of #33, 5/6/7 icons per row). Gabriel tried a build of `054ab85`. That commit has exactly the same files as `e44d2be` (same git tree, `abe6ab0`). It was only re-authored to the repo's noreply email before pushing. Terms used below: - **Google TV / Android TV:** Google's TV operating system. On Google TV the Home button always opens Google's own launcher, even when another app is chosen as Home. - **Stock launcher packages:** `com.google.android.apps.tv.launcherx` (Google TV's home screen), `com.google.android.tvlauncher` (older Android TV's home screen) and `com.google.android.tungsten.setupwraith` (Google TV's setup app, which can also take Home). - **Default Home:** the app Android opens for Home. The existing **ADB setup** (Settings > Default home & backup > Default home) makes Glass the default Home by turning the stock launcher off over the TV's own debugging connection. - **Accessibility service:** a background helper the user switches on in Android's Accessibility settings. It can see key presses before apps do, and which app comes to the front. An app can't switch its own service on or off; only the user can, in that screen. - **Key filtering:** the accessibility-service mode that sends every key press to the service first. - **Recents:** Android's recent-apps screen. ## What changed - **The service (`HomeButtonService.java`, `res/xml/home_button_service.xml`, `AndroidManifest.xml`).** When the service is on and Glass is not the default Home, a short Home press is swallowed and brings Glass to the front. It is also meant to bring Glass back when a stock launcher window comes to the front anyway (after boot, waking from standby, or an app opening Home). When Glass is already the default Home, for example after the ADB setup, the service does nothing, so the two never fight. Every key other than Home goes straight back to Android. The config asks for no screen content (`canRetrieveWindowContent=false`), only window changes from the three stock launcher packages. - **Volume hold.** With key filtering on, many Android TVs apply each volume press but drop the key repeat, so a held key moves one step. The service listens for `android.media.VOLUME_CHANGED_ACTION` (a stable but unpublished Android broadcast) and turns key filtering off for 4 seconds after each volume change, so a hold ramps. If a TV never sends that broadcast, only the hold fix is lost. During those 4 seconds a Home press goes to the stock launcher first. - **Long-press Home** (held 500 ms or more) opens Recents, or Glass if the TV has no Recents screen. A swallowed press can't be handed back to Android, so the stock launcher's own long-press action can't be reproduced. - **Decision logic (`HomeOverridePlan.java`, `HomeOverridePlanTest.java`).** The rules live in a pure Java class with 20 unit tests: which keys pass, the short/long split, not bringing Glass back within 1.5 s of the service's own launch of Glass or of a long press (so its own transition and Recents aren't undone), reading Android's enabled-services setting, and the On / Off / Not needed status. It copies the pattern of `GoogleTvSetupPlan`, the ADB setup's tested rule class. - **Settings (`LauncherActivity.java`, `strings.xml`).** Default home & backup gets a **Home button** row showing On, Off or Not needed (Glass is already the default Home). Its page has the status and a **Turn on Home button** or **Turn off Home button** row; both open Android's Accessibility settings, where the user flips the switch. Two notes say Google TV Home keeps running, and that the system wallpaper and pinned shortcuts don't apply while Glass isn't the default Home. Turn on first shows a consent screen: the service reads only the Home key and which launcher is in front, never screen content. Continue asks for Glass's own toggle screen, and opens the Accessibility list on TVs without it. - **Docs (`README.md`, `CHANGELOG.md`).** README has a "Home button without ADB (Google TV)" section with the steps, trade-offs and the Android 13+ restricted-settings note. CHANGELOG has an Unreleased entry. No new permissions. minSdk stays 26 (Android 8). Glass's own Back up settings file gets nothing new, because Android stores whether the service is on. ## Screenshots Glass Launcher on the emulator (Android TV 14, API 34, 1080p), set up like a TV without the ADB setup: the stock launcher is the default Home. | | | |---|---| | Default home & backup, service on | Home button page, service on | | ![device page](https://git.namillis.me/attachments/629dcd4a-a827-4933-a727-dda776606b2d) | ![home button on](https://git.namillis.me/attachments/c4beb59c-b7fb-4d46-bb89-4c4f8a9928ff) | | Home button page, service off | Consent screen after Turn on | | ![home button off](https://git.namillis.me/attachments/a4c1c9f4-0d85-4826-a68f-c5160d6a6298) | ![consent](https://git.namillis.me/attachments/0537c809-4ae4-4de9-8fb8-d9474818aaf0) | ## How it was checked - **On the head, each as its own Gradle run:** 308 unit tests pass (20 new), 0 failed. Lint has 0 errors and 9 warnings; main has 8. The new one says `isAccessibilityTool` is read only on Android 12 and newer, where it tells Android this is not an assistive tool; older versions ignore it and lose nothing. `assembleDebug` and `assembleDebugAndroidTest` build. No instrumented tests were added; the existing ones were compiled, not run. - **Emulator (Android TV 14) with the stock launcher as default Home:** with the service on, opening the stock launcher put Glass back in front; with it off, the stock launcher stayed. That is the bring-back path. The settings screens show On and Off as above, and Continue opened Android's Accessibility list. - **Gabriel's TV (hometv: Google TV, Android 11, real remote):** release Glass is its default Home through the ADB setup, so Google TV Home is turned off there. He installed the `054ab85` debug build next to it and said it works. Which behaviors he tried wasn't recorded, nothing was measured, and the service is off on the TV now. - **Size:** the debug APK grows by 9,949 bytes (2,014,879 to 2,024,828). ## Not covered yet - A Google TV where `launcherx` is still on (no ADB setup), with a real remote. That is the main target, and the bring-back path has only run on the emulator. - A recorded check of the Home-key path, volume hold, the 4-second Home behavior and long-press Home on a remote. The emulator's injected keys skip key filtering, so only a real remote can show these. - Boot and standby wake on a device, and the service staying on after a reboot. - The direct Glass toggle screen after Continue, and the Not needed state on a screen (unit tests only). - Android 8 to 10, and Android 13+ sideloads, where the toggle can stay greyed out until "Allow restricted settings" is turned on. Glass is sideload-only, so Google Play's accessibility declaration doesn't apply. ## Trying it Debug APK: `GlassLauncher-accessibility-home-054ab85-debug.apk`, sha256 `9c7701c1e180947ad233478af9b7882714df0f9704617aa7168d32d4ca84471d`, built from the same files as the head. Install it with `adb install -r`. Open Settings > Default home & backup > Home button > Turn on Home button, choose Continue, and switch on "Glass Launcher – Home button". If a release build is also installed and is the default Home, Home opens the debug build while its service is on.
Add an optional AccessibilityService (HomeButtonService) that filters the
remote's Home key and brings Glass to the front, so Google TV users can
switch launchers without the one-time ADB setup. A window-state reclaim
handles boot, wake and HOME intents. It is a no-op when Glass is already the
default Home, so it never fights the ADB setup.

Volume long-press keeps working: a VOLUME_CHANGED broadcast pauses key
filtering for a few seconds so a hold repeats. No screen content is read
(canRetrieveWindowContent=false, isAccessibilityTool=false).

Decision logic lives in a pure, unit-tested class (HomeOverridePlan, 20
tests), the GoogleTvSetupPlan pattern. Settings gains a Home button page
under Device with a status row, a consent screen (Play disclosure) and the
trade-off notes. README and CHANGELOG updated.
Author
Owner

Intent. Give Google TV users a way to open Glass with the remote's Home button without the one-time ADB setup, through an optional accessibility service they switch on themselves. It reads only the Home key and which launcher is in front. It does nothing when Glass is already the default Home, and it keeps volume holds working by pausing key filtering after each volume change. This is issue #45's design on GitHub, with the volume change added.

Not goals:

  • replacing or changing the ADB setup, which stays the full-replacement option;
  • reading screen content, or remapping any key other than Home;
  • reproducing the stock launcher's own long-press Home action;
  • stopping the brief Google TV flash on boot or wake, or freeing the memory Google TV Home uses;
  • a Google Play listing or its accessibility declaration (Glass is sideload-only);
  • a release.
**Intent.** Give Google TV users a way to open Glass with the remote's Home button without the one-time ADB setup, through an optional accessibility service they switch on themselves. It reads only the Home key and which launcher is in front. It does nothing when Glass is already the default Home, and it keeps volume holds working by pausing key filtering after each volume change. This is issue #45's design on GitHub, with the volume change added. **Not goals:** - replacing or changing the ADB setup, which stays the full-replacement option; - reading screen content, or remapping any key other than Home; - reproducing the stock launcher's own long-press Home action; - stopping the brief Google TV flash on boot or wake, or freeing the memory Google TV Home uses; - a Google Play listing or its accessibility declaration (Glass is sideload-only); - a release.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
namillis/GlassLauncherTV!34
No description provided.