Skip to content

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

app_keys: an entry can name an activity (package/.Activity)

NewPlayer0213a16993d4aac5
diff --git a/README.md b/README.md
index e84c36dbc..15cdfc91f 100644
--- a/README.md
+++ b/README.md
@@ -596,7 +596,8 @@ tools/tv.py 'settings put secure screensaver_components com.gathin.tvhome/.Clock
- It can bring back other buttons only the stock launcher answered, such as the **YouTube** button
(`app_keys` and `input_key_keycodes`, in config.xml or a theme; `HOME_KEY_SERVICE=1` reads `app_keys` too).
- A `hold:` prefix on an `app_keys` entry gives that button a second app: a normal press opens the
- unprefixed app, holding for half a second opens the hold one (by keycode or `hold:scan:...`).
+ unprefixed app, holding for half a second opens the hold one (by keycode or `hold:scan:...`). An entry can
+ name an activity (`package/.Activity`), such as an add-on's quick bar, instead of the app's launcher entry.
- `HOME_KEY_SERVICE=1` also fixes sticks whose Home key sends ALL_APPS, and opens Settings from the remote's
**gear** button, even one Android does not map (scancodes or keycodes in config.xml).
- With `settings_key_panel` the gear opens a [small quick settings panel](docs/quick-settings-panel.jpg)
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 5316e822a..fa4fc585f 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/RemoteKeys.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/RemoteKeys.java
@@ -3,6 +3,7 @@ package com.gathin.tvhome;
import android.accessibilityservice.AccessibilityService;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.content.ActivityNotFoundException;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.media.tv.TvContract;
@@ -25,7 +26,8 @@ import java.util.function.ToIntFunction;
* that button is held for HOLD_MS, while the unprefixed entry still opens on a tap; "hold:scan:490:..." does
* the same for a scancode. One set of maps for both services; Android hands a key to every service that filters,
* 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 "input:<input id>" switches to that TV input (an HDMI port) instead of opening an app, and one of
+ * "package/.Activity" opens that activity rather than the app's launcher entry (an add-on's quick bar, say).
*/
final class RemoteKeys {
@@ -185,9 +187,17 @@ final class RemoteKeys {
}
/** Opens an app from a remote button: its TV entry if it has one, else its phone entry. An "input:<id>" target
- * switches to that TV input (an HDMI port) instead. */
+ * switches to that TV input (an HDMI port) instead; a "package/.Activity" target opens that activity. */
static void launch(Context ctx, String pkg) {
if (pkg == null) return;
+ ComponentName activity = pkg.indexOf('/') > 0 ? ComponentName.unflattenFromString(pkg) : null;
+ if (activity != null) {
+ try {
+ ctx.startActivity(new Intent().setComponent(activity).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
+ } catch (ActivityNotFoundException | SecurityException ignored) {
+ }
+ return;
+ }
String inputId = inputId(pkg);
if (inputId != null) {
// The same passthrough URI the Inputs menu opens, which the Live TV app handles.
diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xml
index f600b7d60..60319b282 100644
--- a/launcher/app/src/main/res/values/config.xml
+++ b/launcher/app/src/main/res/values/config.xml
@@ -169,7 +169,8 @@
EV_KEY code, in hex). A scancode entry wins over a keycode. In place of a package, "input:<input id>"
switches to that TV input, e.g. scan:227:input:com.tcl.tvinput/.passthroughinput.TvPassThroughService/HW1413744640
for HDMI 3 on a TCL Smart TV Pro; the ids are in `tools/tv.py 'dumpsys tv_input'` (hdmi_port=N under
- TvInputHardwareInfo). Prefix an entry with "hold:" for the same button's long press:
+ TvInputHardwareInfo). "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 entry with "hold:" for the same button's long press:
"hold:KEYCODE_BUTTON_8:org.xbmc.kodi" opens Kodi when held for half a second, while the unprefixed entry
still opens on a tap; "hold:scan:490:..." works for scancodes. A key with only a hold entry does nothing
on a tap. A listed app that is not installed leaves the button doing nothing. Leave empty to omit. -->