Skip to content

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

Launcher: launch_actions takes "package=view:uri" to open a URI in the app

Arnoulf4c0e07239403
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java b/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java
index 5e2ab51c0..25b956672 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java
@@ -539,7 +539,7 @@ public class AppAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
if (action != null) {
// NEW_TASK only: with RESET_TASK_IF_NEEDED, Android just brings a running task of the app to the front
// ("Activity not started"), so the screen never opens while the app is up, e.g. MagentaTV's boot-time task.
- Intent byAction = new Intent(action).setPackage(e.pkg).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ Intent byAction = LaunchActions.intent(e.pkg, action).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (ctx.getPackageManager().resolveActivity(byAction, 0) != null) i = byAction;
}
try {
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/LaunchActions.java b/launcher/app/src/main/java/com/gathin/tvhome/LaunchActions.java
index 3fb4f455b..8a7f255ef 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/LaunchActions.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/LaunchActions.java
@@ -1,10 +1,15 @@
package com.gathin.tvhome;
+import android.content.Intent;
+import android.net.Uri;
import java.util.Map;
import java.util.function.BiFunction;
/** Selects a configured, package-scoped action only when it resolves; otherwise keeps the normal launch. */
final class LaunchActions {
+ /** A launch_actions value "view:<uri>" opens that URI in the package instead of sending an action. */
+ static final String VIEW_PREFIX = "view:";
+
private LaunchActions() {}
static <T> T select(String pkg, Map<String, String> actions, T fallback,
@@ -14,4 +19,18 @@ final class LaunchActions {
T custom = resolver.apply(pkg, action);
return custom != null ? custom : fallback;
}
+
+ /** The URI of a "view:<uri>" value, or null for a plain action. */
+ static String viewUri(String value) {
+ if (value == null || !value.startsWith(VIEW_PREFIX)) return null;
+ String uri = value.substring(VIEW_PREFIX.length()).trim();
+ return uri.isEmpty() ? null : uri;
+ }
+
+ /** The intent for a launch_actions value, limited to its package: ACTION_VIEW on the URI, or the action. */
+ static Intent intent(String pkg, String value) {
+ String uri = viewUri(value);
+ Intent i = uri != null ? new Intent(Intent.ACTION_VIEW, Uri.parse(uri)) : new Intent(value);
+ return i.setPackage(pkg);
+ }
}
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 179614434..6e2379a86 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@ -2347,7 +2347,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
if (launch == null) continue; // not installed, or disabled
// Use the same configured launch_actions as tiles; retain the normal entry if unavailable.
launch = LaunchActions.select(pkg, launchActions, launch, (targetPackage, action) -> {
- Intent custom = new Intent(action).setPackage(targetPackage);
+ Intent custom = LaunchActions.intent(targetPackage, action);
return pm.resolveActivity(custom, 0) != null ? custom : null;
});
Drawable logo;
diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xml
index c963338f1..7a293556a 100644
--- a/launcher/app/src/main/res/values/config.xml
+++ b/launcher/app/src/main/res/values/config.xml
@@ -63,7 +63,8 @@
<!-- Tiles that open a screen of the app instead of its start screen: "package=action", sent to that package.
A tile whose action no longer resolves opens the app normally. MagentaTV's program guide:
- com.telekom.onetv.tv.pl=com.telekom.onetv.tv.pl.action.PROGRAM_GUIDE. -->
+ com.telekom.onetv.tv.pl=com.telekom.onetv.tv.pl.action.PROGRAM_GUIDE. "package=view:uri" opens that URI
+ in the package instead (ACTION_VIEW): Bbox TV's live channels are fr.bouyguestelecom.tv.bbui=view:bbox://live. -->
<string-array name="launch_actions">
</string-array>
diff --git a/launcher/app/src/test/java/com/gathin/tvhome/LaunchActionsTest.java b/launcher/app/src/test/java/com/gathin/tvhome/LaunchActionsTest.java
index b7d24321f..e86f49506 100644
--- a/launcher/app/src/test/java/com/gathin/tvhome/LaunchActionsTest.java
+++ b/launcher/app/src/test/java/com/gathin/tvhome/LaunchActionsTest.java
@@ -28,6 +28,17 @@ public class LaunchActionsTest {
(pkg, action) -> { throw new AssertionError("No action configured for this package"); }));
}
+ @Test public void viewPrefixGivesTheUri() {
+ assertEquals("bbox://live", LaunchActions.viewUri("view:bbox://live"));
+ assertEquals("bbox://live?a=b", LaunchActions.viewUri("view: bbox://live?a=b "));
+ }
+
+ @Test public void plainActionOrEmptyViewHasNoUri() {
+ assertNull(LaunchActions.viewUri("com.telekom.onetv.tv.pl.action.PROGRAM_GUIDE"));
+ assertNull(LaunchActions.viewUri("view:"));
+ assertNull(LaunchActions.viewUri(null));
+ }
+
@Test public void emptyConfigurationRetainsNormalEntryWithoutResolving() {
Object normal = new Object();
assertSame(normal, LaunchActions.select("store", Map.of(), normal,
diff --git a/tests/test_top_bar_launch_actions.py b/tests/test_top_bar_launch_actions.py
index 16b50b1d9..46db11420 100644
--- a/tests/test_top_bar_launch_actions.py
+++ b/tests/test_top_bar_launch_actions.py
@@ -18,7 +18,9 @@ class TopBarLaunchActionsTest(unittest.TestCase):
self.assertIn('button.setOnClickListener(v -> open(new Intent(target)))', self.method)
def test_action_is_package_scoped_resolved_and_does_not_replace_missing_apps(self):
- self.assertIn('new Intent(action).setPackage(targetPackage)', self.method)
+ self.assertIn('LaunchActions.intent(targetPackage, action)', self.method)
+ helper = (JAVA / 'LaunchActions.java').read_text()
+ self.assertIn('return i.setPackage(pkg);', helper)
self.assertIn('pm.resolveActivity(custom, 0) != null ? custom : null', self.method)
self.assertLess(self.method.index('if (launch == null) continue'),
self.method.index('LaunchActions.select'))
diff --git a/themes/README.md b/themes/README.md
index 9fe471a6e..077058fa3 100644
--- a/themes/README.md
+++ b/themes/README.md
@@ -51,7 +51,7 @@ A new key needs one there in the same pull request.
| `source_panel_service`, `source_panel_action` | string | The TV's own source panel, for sets with no TvInputManager: a service, or an activity (BYINTEK U4). Without a Live TV app, the Inputs pill opens it directly |
| `source_panel_extra` | `"name=value"` | One int extra sent with the source panel (Coocaa OS: `control_center_command=100`) |
| `coocaa_sources` | bool | Coocaa OS (Skyworth, China): list the sources from `com.skyworth.tv` in the Inputs menu, ahead of the source panel |
-| `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`) |
+| `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=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)) |