Skip to content

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

Launcher: route Xiaomi MiTV-MTEQ0 HDMI inputs

Haoran Chencb8ebae2e2b1
diff --git a/docs/devices/xiaomi-mitv-mteq0-baymax.md b/docs/devices/xiaomi-mitv-mteq0-baymax.md
index 444c217fa..7a80138db 100644
--- a/docs/devices/xiaomi-mitv-mteq0-baymax.md
+++ b/docs/devices/xiaomi-mitv-mteq0-baymax.md
@@ -63,10 +63,15 @@ The passthrough channel URI the launcher sends is accepted but does not switch t
and an integer extra `input` does, with the same numbering as the MiTV-MFTR0
([`xiaomi-mitv-mftr0-freeguy.txt`](xiaomi-mitv-mftr0-freeguy.txt)):
+The ready-to-push overlay is [`examples/xiaomi-mitv-mteq0/config.json`](../../examples/xiaomi-mitv-mteq0/config.json):
+push it with `TV_HOST=<tv ip> tools/theme.sh examples/xiaomi-mitv-mteq0` after installing the launcher.
+It keeps the shared launcher defaults unchanged and applies this route only when this device profile is pushed.
+
| Input | TvInputInfo ID | `input` |
|---|---|---|
| HDMI 1 | `com.mediatek.tvinput/.hdmi.HDMIInputService/HW5` | 23 |
| HDMI 2 | `com.mediatek.tvinput/.hdmi.HDMIInputService/HW6` | 24 |
+| HDMI 3 | `com.mediatek.tvinput/.hdmi.HDMIInputService/HW7` | 25 |
| AV | `com.mediatek.tvinput/.composite.CompositeInputService/HW2` | 2 |
An HDMI-CEC device appears as an extra input (`.../HDMI200008`) whose parent is the port it is on.
diff --git a/examples/xiaomi-mitv-mteq0/config.json b/examples/xiaomi-mitv-mteq0/config.json
new file mode 100644
index 000000000..f570f7e33
--- /dev/null
+++ b/examples/xiaomi-mitv-mteq0/config.json
@@ -0,0 +1,9 @@
+{
+ "input_action": "com.xiaomi.mitv.tvplayer.EXTSRC_PLAY",
+ "input_sources": [
+ "HW5=23",
+ "HW6=24",
+ "HW7=25",
+ "HW2=2"
+ ]
+}
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/Config.java b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
index be67171ae..5e1f2c0d1 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
@@ -78,7 +78,9 @@ final class Config {
/** List Coocaa OS sources from com.skyworth.tv in the Inputs menu (config.xml coocaa_sources). */
final boolean coocaaSources;
final String inputAction;
- /** Scheme an Inputs row's passthrough URI is sent with instead of content:// (config.xml input_uri_scheme). */
+ /** Vendor source numbers for passthrough inputs (config.xml or theme input_sources). */
+ final List<String> inputSources;
+ /** Scheme an Inputs row's passthrough URI is sent with instead of content:// (config.xml or theme input_uri_scheme). */
final String inputUriScheme;
final int columns;
final boolean animations;
@@ -250,7 +252,7 @@ final class Config {
private Config(List<String> dockApps, boolean fillDock, List<String> hiddenApps, List<String> libraryApps, String liveTvPackage,
String liveTvAction, String liveTvInputId, Map<String, String> launchActions, Map<String, String> appLabels,
Map<String, String> appBanners, String sourcePanelService, String sourcePanelAction,
- String sourcePanelExtra, boolean coocaaSources, String inputAction,
+ String sourcePanelExtra, boolean coocaaSources, String inputAction, List<String> inputSources,
String inputUriScheme, int columns, int rowsBelowDock, boolean animations, boolean advancedEffects,
boolean shamsiDate, String greetingName, boolean moduleCards, boolean reducedMotion, boolean bootToLiveTv, boolean openOnStartChoice, boolean dockTitle, boolean dockRow, boolean topMenu, boolean launcherSettingsButton, boolean reorderButton, boolean showNetworkPill, boolean showInputsPill, boolean iconOnlyButtons, boolean iconOnlyInputs, boolean libraryButton, boolean showLibraryPill, int wifiLabelWidth, boolean alwaysShowNames, boolean wallpaperTrueColor, boolean focusOvershoot, String vpnApp,
boolean showHomeSettingsShortcut, boolean showStats, boolean appLibrary, boolean appLibrarySelection, boolean libraryOkOpens, boolean uniformTiles, int backgroundColor, int skyIntensity,
@@ -282,6 +284,7 @@ final class Config {
this.sourcePanelExtra = sourcePanelExtra;
this.coocaaSources = coocaaSources;
this.inputAction = inputAction;
+ this.inputSources = Collections.unmodifiableList(inputSources);
this.inputUriScheme = inputUriScheme;
this.columns = columns;
this.rowsBelowDock = rowsBelowDock;
@@ -399,6 +402,7 @@ final class Config {
String panelExtra = res.getString(R.string.source_panel_extra).trim();
boolean coocaaSources = res.getBoolean(R.bool.coocaa_sources);
String inputAction = res.getString(R.string.input_action).trim();
+ List<String> inputSources = new ArrayList<>(Arrays.asList(res.getStringArray(R.array.input_sources)));
String inputUriScheme = res.getString(R.string.input_uri_scheme).trim();
int columns = res.getInteger(R.integer.columns);
int rowsBelow = res.getInteger(R.integer.rows_below_dock);
@@ -498,6 +502,7 @@ final class Config {
panelExtra = string(json, "source_panel_extra", panelExtra).trim();
coocaaSources = bool(json, "coocaa_sources", coocaaSources);
inputAction = string(json, "input_action", inputAction);
+ inputSources = stringList(json, "input_sources", inputSources);
inputUriScheme = string(json, "input_uri_scheme", inputUriScheme).trim();
columns = integer(json, "columns", columns, 1, 8);
rowsBelow = integer(json, "rows_below_dock", rowsBelow, 0, 3);
@@ -623,7 +628,7 @@ final class Config {
string(json, "festival_until", ""), string(json, "greeting", ""), string(json, "accent_color", ""));
return new Config(dock, fillDock, hidden, libraryApps, liveTv, liveTvAction, liveTvInputId, packageMap(launchActions), packageMap(appLabels),
- packageMap(appBanners), panelService, panelAction, panelExtra, coocaaSources, inputAction, inputUriScheme, Math.max(1, columns),
+ packageMap(appBanners), panelService, panelAction, panelExtra, coocaaSources, inputAction, inputSources, inputUriScheme, Math.max(1, columns),
Math.max(0, rowsBelow), animations, advancedEffects, shamsi, greetingName, moduleCards, reducedMotion, bootToLiveTv,
openOnStartChoice, dockTitle, dockRow, topMenu, launcherSettingsButton, reorderButton, showNetworkPill, showInputsPill,
iconOnlyButtons, iconOnlyInputs, libraryButton, showLibraryPill, wifiLabelWidth, alwaysShowNames, wallpaperTrueColor, focusOvershoot,
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/InputSources.java b/launcher/app/src/main/java/com/gathin/tvhome/InputSources.java
new file mode 100644
index 000000000..ac1604f37
--- /dev/null
+++ b/launcher/app/src/main/java/com/gathin/tvhome/InputSources.java
@@ -0,0 +1,28 @@
+package com.gathin.tvhome;
+
+import java.util.List;
+
+/** Vendor source numbers for passthrough inputs, such as Xiaomi's EXTSRC_PLAY route. */
+final class InputSources {
+ private InputSources() {
+ }
+
+ /** Returns the mapped source, -1 for a hidden input, or null when the input is not mapped. */
+ static Integer mapped(List<String> mappings, String inputId) {
+ if (inputId == null || mappings == null) return null;
+ String input = inputId.substring(inputId.lastIndexOf('/') + 1);
+ for (String mapping : mappings) {
+ if (mapping == null) continue;
+ int equals = mapping.indexOf('=');
+ if (equals <= 0 || !mapping.substring(0, equals).trim().equals(input)) continue;
+ String value = mapping.substring(equals + 1).trim();
+ if (value.equals("-")) return -1;
+ try {
+ return Integer.parseInt(value);
+ } catch (NumberFormatException ignored) {
+ return null;
+ }
+ }
+ return null;
+ }
+}
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 880d15fcc..2d4dba492 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@ -124,6 +124,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
/** The same opt-in menu is available from either hold-OK or the remote's Menu key. */
private boolean tileMenuEnabled;
private String inputAction;
+ private List<String> inputSources;
private String inputUriScheme;
private String sourcePanelService;
private String sourcePanelAction;
@@ -404,6 +405,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
appLibraryEnabled = cfg.appLibrary;
tileMenuEnabled = cfg.tileMenu;
inputAction = cfg.inputAction;
+ inputSources = cfg.inputSources;
inputUriScheme = cfg.inputUriScheme;
sourcePanelService = cfg.sourcePanelService;
sourcePanelAction = cfg.sourcePanelAction;
@@ -2831,20 +2833,11 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
}
}
- /** `input_sources` in config.xml: "HW5=23" maps the framework input whose id ends in /HW5 to a vendor
+ /** `input_sources` in config.xml or a theme: "HW5=23" maps the framework input whose id ends in /HW5 to a vendor
* source number; "HW8=-" leaves that input out of the Inputs menu (a port the board reports but the set
* does not have). Returns the number, -1 for a left-out input, or null when the input is not listed. */
private Integer mappedSource(String inputId) {
- if (inputId == null) return null;
- String hw = inputId.substring(inputId.lastIndexOf('/') + 1);
- for (String m : getResources().getStringArray(R.array.input_sources)) {
- int eq = m.indexOf('=');
- if (eq <= 0 || !m.substring(0, eq).trim().equals(hw)) continue;
- String v = m.substring(eq + 1).trim();
- if (v.equals("-")) return -1;
- try { return Integer.parseInt(v); } catch (NumberFormatException e) { return null; }
- }
- return null;
+ return InputSources.mapped(inputSources, inputId);
}
/** Switches to a passthrough input (HDMI, AV). An input mapped in `input_sources` is opened by sending
diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xml
index 580e748f8..d4eeee3f6 100644
--- a/launcher/app/src/main/res/values/config.xml
+++ b/launcher/app/src/main/res/values/config.xml
@@ -124,7 +124,7 @@
<!-- Vendor source numbers for the Inputs menu, "HW<n>=<number>" by the framework input id's last part
(`tools/tv.py 'dumpsys tv_input'` lists them). A mapped input opens by sending input_action with the
number as the int extra "input"; "HW<n>=-" leaves a port the board reports but the set does not have
- out of the menu. Xiaomi/Redmi China firmware (MiTV-MFTP0) needs input_action
+ out of the menu. A theme can set the same list. Xiaomi/Redmi China firmware (MiTV-MFTP0) needs input_action
com.xiaomi.mitv.tvplayer.EXTSRC_PLAY and MStar numbers: HW5=23, HW6=24, HW7=25, HW8=-, HW2=2,
HW3=-, HW4=- (see examples/redmi-mitv-mftp0). Leave empty to omit. -->
<string-array name="input_sources" translatable="false">
diff --git a/launcher/app/src/test/java/com/gathin/tvhome/InputSourcesTest.java b/launcher/app/src/test/java/com/gathin/tvhome/InputSourcesTest.java
new file mode 100644
index 000000000..2f4ab267d
--- /dev/null
+++ b/launcher/app/src/test/java/com/gathin/tvhome/InputSourcesTest.java
@@ -0,0 +1,32 @@
+package com.gathin.tvhome;
+
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class InputSourcesTest {
+ @Test public void mapsTheLastInputComponent() {
+ assertEquals(Integer.valueOf(25), InputSources.mapped(
+ Collections.singletonList("HW7=25"), "service/.Hdmi/HW7"));
+ }
+
+ @Test public void trimsMappingWhitespace() {
+ assertEquals(Integer.valueOf(25), InputSources.mapped(
+ Collections.singletonList(" HW7 = 25 "), "service/.Hdmi/HW7"));
+ }
+
+ @Test public void aDashHidesAnInput() {
+ assertEquals(Integer.valueOf(-1), InputSources.mapped(
+ Collections.singletonList("HW8=-"), "service/.Hdmi/HW8"));
+ }
+
+ @Test public void anUnknownOrMalformedInputIsNotMapped() {
+ assertNull(InputSources.mapped(Arrays.asList("HW5=23", "HW7=nope"), "service/.Hdmi/HW6"));
+ assertNull(InputSources.mapped(Collections.singletonList("HW7=nope"), "service/.Hdmi/HW7"));
+ assertNull(InputSources.mapped(null, "service/.Hdmi/HW7"));
+ }
+}
diff --git a/tests/test_theme_keys_config.py b/tests/test_theme_keys_config.py
index 79f9c34c9..35bb9a4ee 100644
--- a/tests/test_theme_keys_config.py
+++ b/tests/test_theme_keys_config.py
@@ -3,12 +3,12 @@
The switch recipe in AGENTS.md asks for a row in that table for every key it adds, because the table
is what a theme author reads and the launcher itself says nothing: an unknown key is ignored, so a
reader who sets one the table never names has no way to tell a typo from a key that does not exist.
-`input_sources` is in the table marked "config.xml only", so the table is meant to cover those too -
-and `settings_fallback_components`, the list SystemSettings.java walks when nothing usable answers the
-standard Settings action, was the one entry missing. A reader whose Settings action opens nothing had
-nothing to look up, and the row now says why: the three vendor screens it ships with, the `CTSDummy`
-stub Fire OS resolves the action to, and that a package named here also has to be in the launcher's
-`<queries>`, so a fourth set needs a build rather than a theme push.
+`settings_fallback_components`, the list SystemSettings.java walks when nothing usable answers the
+standard Settings action, is config.xml-only. A reader whose Settings action opens nothing had nothing
+to look up, and the row now says why: the three vendor screens it ships with, the `CTSDummy` stub Fire
+OS resolves the action to, and that a package named here also has to be in the launcher's `<queries>`,
+so a fourth set needs a build rather than a theme push. Input source mappings are also accepted from a
+theme now, so a model-specific example can carry its vendor HDMI route without changing shared defaults.
The check runs one way only, the way the table is written: every key the launcher reads from
config.xml has a row. It does not ask the table to stop carrying theme-only keys such as `race_calendar`
@@ -183,7 +183,7 @@ class KeysTableCoversConfigXmlTest(unittest.TestCase):
from_theme = set(FROM_THEME.findall(CONFIG_JAVA.read_text(encoding="utf-8")))
config_only = [key for key, row in table_keys(self.text).items()
if "`config.xml` only" in type_cell(row)]
- self.assertGreaterEqual(len(config_only), 2,
+ self.assertGreaterEqual(len(config_only), 1,
"no row says config.xml only any more: is the wording still the same?")
for key in config_only:
with self.subTest(key=key):
diff --git a/themes/README.md b/themes/README.md
index d080af63c..45c2c7acb 100644
--- a/themes/README.md
+++ b/themes/README.md
@@ -54,7 +54,7 @@ A new key needs one there in the same pull request.
| `app_banners` | list of `"package=banner_name"` | A tile's artwork from a `banner_*` drawable bundled with the launcher (`banner_tv`: magenta with the Live TV glyph) |
| `input_action` | string | Action sent with an HDMI/AV row's channel URI when nothing handles the standard `VIEW` (XGIMI: `com.xgimi.action.hdmiPlayer`). Only a handler-less set gets here; any app that claims the channel MIME type takes the row instead, so check with `query-activities` ([#805](https://github.com/Gathin23/cleanyourtv/issues/805)) |
| `input_uri_scheme` | string | Scheme an HDMI/AV row's passthrough URI is sent with instead of `content://`, with no MIME type (YaOS: `live-tv`, which its source player answers) |
-| `input_sources` | list, `config.xml` only | Vendor source numbers for the Inputs menu, `HW<n>=<number>` by the input id's last part; a mapped input opens by sending `input_action` with the number as the int extra `input`, and `HW<n>=-` leaves a port the set doesn't have out of the menu. Xiaomi/Redmi China firmware: [redmi-mitv-mftp0](../examples/redmi-mitv-mftp0/). Not read from a theme |
+| `input_sources` | list | Vendor source numbers for the Inputs menu, `HW<n>=<number>` by the input id's last part; a mapped input opens by sending `input_action` with the number as the int extra `input`, and `HW<n>=-` leaves a port the set doesn't have out of the menu. Xiaomi/Redmi China firmware: [redmi-mitv-mftp0](../examples/redmi-mitv-mftp0/) |
| `columns` | 1 to 8 | Tiles per row; tiles shrink to fit from 5 up |
| `rows_below_dock` | 0 to 3 | Grid rows left visible under the dock; tiles shrink if the dock, its title and that many rows would not fit the screen height |
| `dock_title` | bool | The focused dock app's name in large type above the dock (`true`); `false` keeps only the glow |