Skip to content

Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.

Launcher: app_keys action word "library" opens the App library from a remote button

Mykola Dementiev8e8aed0c6776
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
index ad32dfaf3..049a8cbea 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@ -104,6 +104,8 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
private static final int LAUNCHER_SETTINGS_REQUEST = 42;
/** Sent by QuickSettingsActivity: open Launcher settings from here so Home rebuilds when they close. */
static final String ACTION_LAUNCHER_SETTINGS = "com.gathin.tvhome.action.LAUNCHER_SETTINGS";
+ /** Sent by the "library" action word of app_keys: open the App library over Home (needs app_library). */
+ static final String ACTION_APP_LIBRARY = "com.gathin.tvhome.action.APP_LIBRARY";
/** The system input switcher, forwarded here by InputsRequestActivity while handle_view_inputs is on. */
static final String ACTION_VIEW_INPUTS = "com.android.tv.action.VIEW_INPUTS";
/** Tiles per row and dock slots (res/values/config.xml, columns). Set in onCreate. */
@@ -928,7 +930,9 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
.build(), vpnCallback);
}
// Not after recreate(): the launch intent survives it and would open the settings again.
- if (savedInstanceState == null && !openLauncherSettingsIfAsked(getIntent())) openInputsIfAsked(getIntent());
+ if (savedInstanceState == null && !openLauncherSettingsIfAsked(getIntent()) && !openLibraryIfAsked(getIntent())) {
+ openInputsIfAsked(getIntent());
+ }
}
/**
@@ -981,6 +985,21 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
return true;
}
+ /**
+ * ACTION_APP_LIBRARY, sent by the "library" action word: open the App library once Home is on screen. The intent
+ * is replaced so a later recreate() does not open it again. With app_library off there is no library, so the
+ * press only brings Home forward.
+ */
+ private boolean openLibraryIfAsked(Intent intent) {
+ if (intent == null || !ACTION_APP_LIBRARY.equals(intent.getAction())) return false;
+ setIntent(new Intent(Intent.ACTION_MAIN));
+ if (!appLibraryEnabled) return true;
+ getWindow().getDecorView().post(() -> {
+ if (!isFinishing()) onLibraryRequested();
+ });
+ return true;
+ }
+
private boolean openLauncherSettingsIfAsked(Intent intent) {
if (intent == null || !ACTION_LAUNCHER_SETTINGS.equals(intent.getAction())) return false;
setIntent(new Intent(Intent.ACTION_MAIN));
@@ -997,6 +1016,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (openLauncherSettingsIfAsked(intent)) return;
+ if (openLibraryIfAsked(intent)) return;
if (openInputsIfAsked(intent)) return;
if (intent == null || !intent.hasCategory(Intent.CATEGORY_HOME)) return;
if (gameDay != null && !stopped) gameDay.read();
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/RemoteKeys.java b/launcher/app/src/main/java/com/gathin/tvhome/RemoteKeys.java
index 6137c6a7a..7cd9e4dbf 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/RemoteKeys.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/RemoteKeys.java
@@ -34,7 +34,7 @@ import java.util.regex.Pattern;
* so both may call handle() for one event, and it answers each press once.
* A target of "input:<input id>" switches to that TV input (an HDMI port) instead of opening an app, a target
* of "inputs" opens the input switcher, for a remote whose source button sends a key Android does not map,
- * one of the action words (back, home, recents, mute, sleep, screensaver, settings, wifi) does that action, and
+ * one of the action words (back, home, recents, mute, sleep, screensaver, settings, wifi, library) does that action, and
* "package/.Activity" opens that activity rather than the app's launcher entry (an add-on's quick bar, say).
*/
final class RemoteKeys {
@@ -343,7 +343,7 @@ final class RemoteKeys {
static boolean isAction(String target) {
switch (target) {
case "back": case "home": case "recents": case "mute": case "sleep":
- case "screensaver": case "settings": case "wifi": case "ignore":
+ case "screensaver": case "settings": case "wifi": case "library": case "ignore":
return true;
default:
return false;
@@ -379,6 +379,10 @@ final class RemoteKeys {
case "wifi":
start(ctx, SystemSettings.intent(ctx, Settings.ACTION_WIFI_SETTINGS));
break;
+ case "library":
+ // Home with the App library open on top; Home does nothing when app_library is off.
+ start(ctx, new Intent(ctx, MainActivity.class).setAction(MainActivity.ACTION_APP_LIBRARY));
+ break;
default:
break; // "ignore", or "sleep" below Android 9: consumed, nothing to do
}
diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xml
index 42b73d75f..c966c5fbf 100644
--- a/launcher/app/src/main/res/values/config.xml
+++ b/launcher/app/src/main/res/values/config.xml
@@ -200,7 +200,9 @@
for HDMI 3 on a TCL Smart TV Pro; the ids are in `tools/tv.py 'dumpsys tv_input'` (hdmi_port=N under
TvInputHardwareInfo). An action word in place of a package runs that action instead: back, home, recents,
mute (toggles the sound, with the TV's volume bar), sleep (standby, Android 9 and later), screensaver (the
- one chosen in the TV's settings, or the launcher's clock), settings, wifi or ignore (swallows the button: it
+ one chosen in the TV's settings, or the launcher's clock), settings, wifi, library (Home with the App
+ library open; with app_library off it only brings Home forward, so a remote's Apps button, which sends
+ 284 KEYCODE_ALL_APPS, can open it: 284:library) or ignore (swallows the button: it
does nothing, for a shortcut pressed by accident; find its scancode with `tools/tv.py 'getevent -t'`);
e.g. KEYCODE_PROG_YELLOW:mute, scan:586:ignore and hold:KEYCODE_PROG_YELLOW:sleep. "package/.Activity" opens that activity instead of the app's launcher
entry, e.g. hold:191:io.github.maxhayim.brightness/.QuickActivity for an add-on's quick bar. Prefix an
diff --git a/launcher/app/src/test/java/com/gathin/tvhome/RemoteKeysTest.java b/launcher/app/src/test/java/com/gathin/tvhome/RemoteKeysTest.java
index bf62d15f9..adf081de4 100644
--- a/launcher/app/src/test/java/com/gathin/tvhome/RemoteKeysTest.java
+++ b/launcher/app/src/test/java/com/gathin/tvhome/RemoteKeysTest.java
@@ -136,7 +136,7 @@ public class RemoteKeysTest {
assertEquals("mute", keys.get(190));
assertEquals("screensaver", keys.get(195));
assertEquals("sleep", parseHold("hold:190:sleep").get(190));
- for (String word : new String[] {"back", "home", "recents", "mute", "sleep", "screensaver", "settings", "wifi", "ignore"}) {
+ for (String word : new String[] {"back", "home", "recents", "mute", "sleep", "screensaver", "settings", "wifi", "library", "ignore"}) {
assertTrue(word, RemoteKeys.isAction(word));
}
assertFalse(RemoteKeys.isAction("com.netflix.ninja"));
diff --git a/themes/README.md b/themes/README.md
index fcb17197f..8575ea756 100644
--- a/themes/README.md
+++ b/themes/README.md
@@ -155,7 +155,7 @@ A new key needs one there in the same pull request.
| `settings_fallback_components` | list, `config.xml` only | Vendor screens tried in order when nothing usable answers the standard Settings action (Xiaomi China, TCL/FFALCON, and Fire OS, where the real menu lives in its launcher), each as `package/activity`; the first one whose package is installed wins, and when none is, the standard intent is sent anyway and may open nothing. Fire OS answers that intent with a `CTSDummy` stub, which counts as missing so the fallback runs. A package named here also has to be listed in the launcher's `<queries>` (Android 11 package visibility), so a set whose settings app is neither of these needs a build, not a theme push. Not read from a theme |
| `restore_key_services` | bool | After a force stop of the launcher, Home puts the remote's accessibility helpers (`HomeKeyService`, `InputKeyService`) back on the enabled list; needs `RESTORE_KEY_SERVICES=1` at install. Off by default |
| `input_key_keycodes` | list of keycodes | More remote buttons that open the input switcher, for `InputKeyService` (`KEYCODE_TV` and `KEYCODE_TV_INPUT` always do) |
-| `app_keys` | list of strings | Remote buttons that open an app, as `"190:com.google.android.youtube.tv"` or `"KEYCODE_BUTTON_3:com.google.android.youtube.tv"`, or by scancode as `"scan:490:com.wbd.hbomax"` for remotes that share one keycode between app buttons (Sony BRAVIA), for `InputKeyService` or `HomeKeyService`. `"input:<input id>"` in place of the package switches to a TV input instead, e.g. `"scan:227:input:com.tcl.tvinput/.passthroughinput.TvPassThroughService/HW1413744640"` for an HDMI port (ids from `dumpsys tv_input`). `"inputs"` in place of the package opens the Inputs menu, for a remote whose source button sends a key Android does not map, e.g. `"scan:365:inputs"` (TCL 65C745). An action word in place of the package runs that action: `back`, `home`, `recents`, `mute`, `sleep` (standby, Android 9 and later), `screensaver`, `settings`, `wifi` or `ignore` (swallows the button so it does nothing, for a shortcut pressed by accident), e.g. `"KEYCODE_PROG_YELLOW:mute"` or `"scan:586:ignore"`. Prefix an entry with `hold:` to make it the long-press action, e.g. `"hold:190:com.netflix.ninja"`, while the unprefixed entry still opens on a tap. Prefix it with `front:` for what a tap does while the button's own app is already in front (`HomeKeyService` only), and use `"guide:<package>"` as a target to open that Live TV app's program guide: `"172:com.vt.tv.tvcenter"` with `"front:172:guide:com.vt.tv.tvcenter"` opens Live TV, then its guide, on a Hisense hengshan set whose firmware sends the Live TV button (`KEYCODE_GUIDE`) only to the stock launcher |
+| `app_keys` | list of strings | Remote buttons that open an app, as `"190:com.google.android.youtube.tv"` or `"KEYCODE_BUTTON_3:com.google.android.youtube.tv"`, or by scancode as `"scan:490:com.wbd.hbomax"` for remotes that share one keycode between app buttons (Sony BRAVIA), for `InputKeyService` or `HomeKeyService`. `"input:<input id>"` in place of the package switches to a TV input instead, e.g. `"scan:227:input:com.tcl.tvinput/.passthroughinput.TvPassThroughService/HW1413744640"` for an HDMI port (ids from `dumpsys tv_input`). `"inputs"` in place of the package opens the Inputs menu, for a remote whose source button sends a key Android does not map, e.g. `"scan:365:inputs"` (TCL 65C745). An action word in place of the package runs that action: `back`, `home`, `recents`, `mute`, `sleep` (standby, Android 9 and later), `screensaver`, `settings`, `wifi`, `library` (Home with the App library open, for a remote's Apps button, `"284:library"`; needs `app_library`) or `ignore` (swallows the button so it does nothing, for a shortcut pressed by accident), e.g. `"KEYCODE_PROG_YELLOW:mute"` or `"scan:586:ignore"`. Prefix an entry with `hold:` to make it the long-press action, e.g. `"hold:190:com.netflix.ninja"`, while the unprefixed entry still opens on a tap. Prefix it with `front:` for what a tap does while the button's own app is already in front (`HomeKeyService` only), and use `"guide:<package>"` as a target to open that Live TV app's program guide: `"172:com.vt.tv.tvcenter"` with `"front:172:guide:com.vt.tv.tvcenter"` opens Live TV, then its guide, on a Hisense hengshan set whose firmware sends the Live TV button (`KEYCODE_GUIDE`) only to the stock launcher |
| `key_filter` | bool | `false` makes the key helpers stop filtering keys while staying enabled. Use it on firmware where any key-filtering accessibility service breaks long-press repeat (TCL Google TV on Android 12): the remote buttons above stop working, and volume repeat comes back |
| `gamepad_passthrough` | bool | `true` makes the key helpers stop filtering keys while a game controller is connected, so games see its buttons (Steam Link with an Xbox controller, Moonlight with two controllers); the remote buttons above do nothing until it disconnects. Needs `key_filter` on. A voice remote that reports a joystick does not count. Off by default |
| `consume_volume_keys` | bool | `true` makes the key helpers swallow Volume Up/Down and repeat a held one themselves (after 500 ms, every 60 ms). Use it on firmware that applies a volume key both before the helper and when the helper hands it back, so one tap moves two steps (TCL G03 / BeyondTV4, Android 11, #1100). Needs `key_filter` on. Off by default |