Skip to content

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

Launcher: input_action may name an activity, for Redmi X65's ExternalSourceActivity (#2558)

10k1122e5884ffa02
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/InputSources.java b/launcher/app/src/main/java/com/gathin/tvhome/InputSources.java
index ac1604f37..0ee9e28be 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/InputSources.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/InputSources.java
@@ -25,4 +25,12 @@ final class InputSources {
}
return null;
}
+
+ /** True when `input_action` names an activity ("package/.Activity", "package/package.Activity") rather than an
+ * intent action. Actions never contain a slash, so the two forms cannot be confused. */
+ static boolean isComponent(String inputAction) {
+ if (inputAction == null) return false;
+ int slash = inputAction.indexOf('/');
+ return slash > 0 && slash < inputAction.length() - 1 && inputAction.indexOf('/', slash + 1) < 0;
+ }
}
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 a68495feb..f734f6a69 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@ -3156,7 +3156,9 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
* answers com.xiaomi.mitv.tvplayer.EXTSRC_PLAY and nothing else). Otherwise the standard way is
* ACTION_VIEW on its channel URI, which the Live TV app handles; where nothing takes that, the
* configured `input_action` is sent with the same URI instead (XGIMI's HDMI player only answers
- * com.xgimi.action.hdmiPlayer). With `input_uri_scheme` set (YaOS: live-tv) the same URI goes out
+ * com.xgimi.action.hdmiPlayer). An `input_action` written as "package/.Activity" starts that activity
+ * itself, ahead of the standard way, for firmware that answers the channel URI with "unsupported"
+ * (Redmi X65, MiTV-NSOP0: com.xiaomi.mitv.tvplayer/.ExternalSourceActivity). With `input_uri_scheme` set (YaOS: live-tv) the same URI goes out
* with that scheme and no MIME type. A player guarded by a permission this build does not declare
* throws SecurityException, which used to take Home down with it (YaOS before the manifest asked
* for ACCESS_TV_SOURCE). */
@@ -3175,12 +3177,22 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
Integer source = mappedSource(sourceId);
if (source != null && source >= 0 && !inputAction.isEmpty()) {
try {
- startActivity(new Intent(inputAction).putExtra("input", source.intValue())
+ startActivity(inputActionIntent().putExtra("input", source.intValue())
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
return;
} catch (ActivityNotFoundException | SecurityException e) {
// fall through to the standard way
}
+ } else if (source == null && InputSources.isComponent(inputAction)) {
+ // An activity named in input_action is the vendor's own source picker (Xiaomi: tvplayer's
+ // ExternalSourceActivity). Its firmware answers the standard channel URI with "unsupported", so the
+ // row goes straight there; the picker is the overlay the remote's Source button opens.
+ try {
+ startActivity(inputActionIntent().addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
+ return;
+ } catch (ActivityNotFoundException | SecurityException e) {
+ // fall through to the standard way
+ }
}
Uri uri = TvContract.buildChannelUriForPassthroughInput(inputId);
Intent view = (inputUriScheme.isEmpty()
@@ -3205,7 +3217,14 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
return;
}
}
- open(new Intent(inputAction).setDataAndType(uri, "vnd.android.cursor.item/channel"));
+ open(inputActionIntent().setDataAndType(uri, "vnd.android.cursor.item/channel"));
+ }
+
+ /** `input_action` as an intent: an explicit component when it reads "package/.Activity", else an action. */
+ private Intent inputActionIntent() {
+ ComponentName component = InputSources.isComponent(inputAction)
+ ? ComponentName.unflattenFromString(inputAction) : null;
+ return component != null ? new Intent().setComponent(component) : new Intent(inputAction);
}
/** Dropdown menu under the Inputs pill: HDMI ports (with connection state), AV and Live TV. */
diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xml
index 14e30b9d8..81c48fbb8 100644
--- a/launcher/app/src/main/res/values/config.xml
+++ b/launcher/app/src/main/res/values/config.xml
@@ -108,7 +108,10 @@
<!-- Inputs menu: HDMI and AV rows normally open with ACTION_VIEW on the input's channel URI, which the
Live TV app handles. Where nothing answers that, this action is sent with the same URI instead
- (XGIMI projectors: com.xgimi.action.hdmiPlayer). Leave empty to omit. -->
+ (XGIMI projectors: com.xgimi.action.hdmiPlayer). Written as "package/.Activity" it names the vendor's
+ own source picker instead, started by itself for every row, ahead of the standard way: for firmware that
+ answers the channel URI with "unsupported" (Redmi X65, MiTV-NSOP0:
+ com.xiaomi.mitv.tvplayer/.ExternalSourceActivity opens its HDMI 1 / HDMI 2 / AV overlay). Leave empty to omit. -->
<string name="input_action" translatable="false"></string>
<!-- Inputs menu: a scheme to send the input's passthrough URI with instead of content:// (and no channel MIME
type). YaOS: live-tv. Its source player answers live-tv://android.media.tv/passthrough/<input>, while the
diff --git a/launcher/app/src/test/java/com/gathin/tvhome/InputSourcesTest.java b/launcher/app/src/test/java/com/gathin/tvhome/InputSourcesTest.java
index 2f4ab267d..3678132f7 100644
--- a/launcher/app/src/test/java/com/gathin/tvhome/InputSourcesTest.java
+++ b/launcher/app/src/test/java/com/gathin/tvhome/InputSourcesTest.java
@@ -6,7 +6,9 @@ import java.util.Arrays;
import java.util.Collections;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
public class InputSourcesTest {
@Test public void mapsTheLastInputComponent() {
@@ -29,4 +31,16 @@ public class InputSourcesTest {
assertNull(InputSources.mapped(Collections.singletonList("HW7=nope"), "service/.Hdmi/HW7"));
assertNull(InputSources.mapped(null, "service/.Hdmi/HW7"));
}
+
+ @Test public void anActivityIsAComponentAndAnActionIsNot() {
+ assertTrue(InputSources.isComponent("com.xiaomi.mitv.tvplayer/.ExternalSourceActivity"));
+ assertTrue(InputSources.isComponent("com.xiaomi.mitv.tvplayer/com.xiaomi.mitv.tvplayer.ExternalSourceActivity"));
+ assertFalse(InputSources.isComponent("com.xgimi.action.hdmiPlayer"));
+ assertFalse(InputSources.isComponent("com.xiaomi.mitv.tvplayer.EXTSRC_PLAY"));
+ assertFalse(InputSources.isComponent(""));
+ assertFalse(InputSources.isComponent(null));
+ assertFalse(InputSources.isComponent("/.Activity"));
+ assertFalse(InputSources.isComponent("com.example/"));
+ assertFalse(InputSources.isComponent("a/b/c"));
+ }
}
diff --git a/themes/README.md b/themes/README.md
index 8bed449ed..964ae5e58 100644
--- a/themes/README.md
+++ b/themes/README.md
@@ -56,7 +56,7 @@ A new key needs one there in the same pull request.
| `launch_actions` | list of `"package=action"` | Tiles and `top_bar_apps` buttons that open a screen of the app instead of its start screen; an action that no longer resolves opens the app normally (MagentaTV's guide: `com.telekom.onetv.tv.pl=com.telekom.onetv.tv.pl.action.PROGRAM_GUIDE`); `"package=input:<input id>"` makes a tile switch to that TV input instead (ids from `dumpsys tv_input`), e.g. `com.mediatek.wwtv.tvcenter=input:com.mediatek.tvinput/.hdmi.HDMIInputService/HW5`; `"package=view:uri"` opens that URI in the package instead (Bbox TV's live channels: `fr.bouyguestelecom.tv.bbui=view:bbox://live`) |
| `app_labels` | list of `"package=Name"` | A tile's name instead of the app's own (MagentaTV as `com.telekom.onetv.tv.pl=TV`) |
| `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_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)). Written as `package/.Activity` it names the vendor's own source picker, which every row starts first (Redmi X65, MiTV-NSOP0: `com.xiaomi.mitv.tvplayer/.ExternalSourceActivity`) |
| `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 | 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 |