fix: Home button service filters keys only while Glass isn't Home #35
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/a11y-key-filtering"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes two bugs in the Home button service that #34 added. When Glass is already the default Home, the service now leaves other apps' keys alone, as if it were off. And in the 4 seconds after a volume change, Google TV Home showing up is sent back to Glass again. Gabriel (the repo owner) asked for this PR to be opened and merged without further review.
One commit:
0d5d21a, on top of current main920db0d(the #34 merge).Terms used below:
com.google.android.apps.tv.launcherxon Google TV,com.google.android.tvlauncheron older Android TV).What changed
HomeButtonService.java,res/xml/home_button_service.xml). In #34 the service's config turned key filtering on, and the service turned it on again every time it started, even when Glass was already the default Home. Then the service could do nothing with Home, but every key still went through it, with the volume-hold problem above. Now the config leaves filtering off. The service turns it on only while Glass is not the default Home and no volume pause is running, and calls Android'ssetServiceInfoonly when that answer changes.HomeButtonService.java,LauncherActivity.java). The service checks the default Home when it starts, when a stock launcher window appears, and after each Home press it handles. That last check also covers a Home app chosen in Android's own settings. It also checks when the ADB setup or restore finishes and when Glass's settings open, through a newHomeButtonService.refreshIfRunning().HomeButtonService.java). In #34 the pause also switched off the part that sends a stock launcher window back to Glass. A Home press during the pause reaches Google TV Home, because filtering is off then. So in those 4 seconds Google TV Home stayed on screen. That part now depends only on Glass not being the default Home.HomeOverridePlan.java,HomeOverridePlanTest.java). The rule is the newHomeOverridePlan.wantsKeyFiltering(glassIsHome, volumePaused): on only when Glass is not Home and there is no pause. Four new tests cover it, one of them checking thatHomeOverridePlan.shouldReclaimstill sends Google TV Home back to Glass during a pause.CHANGELOG.md). The Unreleased Home button entry says filtering stays off when Glass is Home, and that Home during the pause comes back to Glass.No settings, screens or permissions change, so there are no screenshots.
How it was checked
On the head, each as its own Gradle run: 312 unit tests pass (4 new), 0 failed. Lint has 0 errors and 9 warnings, the same 9 as main.
assembleDebugbuilds.Emulator (Android TV 14, API 34). "Filtering on" means
dumpsys accessibilitylists Android's key filter (KeyboardInterceptor). The stock launcher was opened witham start, the same path an app's Home request or a Home press during the pause takes:The #34 build: these checks ran on
054ab85, which has the same files as main's #34 code. With Glass as Home, filtering was on, and opening the stock launcher during the volume pause left it in front.Not covered yet
pm disable-userandpm enable, and the re-check was triggered by opening settings.launcherxis the stock launcher.Pattern harvest
Rule candidate: a mode that costs every other app something (here, key filtering) should be requested at runtime from one rule that says when it is needed, with every state the rule depends on re-checked when it can change. It shouldn't be declared always-on in a config file.
Trying it
Debug APK in Gabriel's Downloads:
GlassLauncher-a11y-key-filtering-0d5d21a-debug.apk, sha256b92188339f1c895488bb26b31f07e4008cc30be0e83ce6b423965404c492b36a, built from the head. On a TV where Glass is the default Home, turn the service on and hold volume in a video app: it should ramp the same as with the service off.Intent. Make the Home button service from #34 cost other apps nothing when it has nothing to do. When Glass is already the default Home, key filtering stays off, so holding volume works as if the service were off. Also, Google TV Home appearing during the 4-second volume pause is sent back to Glass again, as #34 meant it to be.
Not goals: