Skip to content

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

launcher: Coocaa OS inputs (coocaa_sources, source_panel_extra)

VincentYe12337e71705e5bd
diff --git a/launcher/app/src/main/AndroidManifest.xml b/launcher/app/src/main/AndroidManifest.xml
index 7dc9ee681..d0e3a31ac 100644
--- a/launcher/app/src/main/AndroidManifest.xml
+++ b/launcher/app/src/main/AndroidManifest.xml
@@ -32,6 +32,9 @@
</intent>
<!-- China-market MIUI TV firmware: the Settings and Wi-Fi pills fall back to Xiaomi's settings app. -->
<package android:name="com.xiaomi.mitv.settings" />
+ <!-- Coocaa OS sources for the Inputs menu (coocaa_sources); see CoocaaSources. -->
+ <provider android:authorities="com.skyworth.tv.provider" />
+ <provider android:authorities="com.skyworth.tv.sdk.provider" />
</queries>
<application
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 b55b5a100..2e8b8df06 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
@@ -56,6 +56,10 @@ final class Config {
final Map<String, String> appBanners;
final String sourcePanelService;
final String sourcePanelAction;
+ /** One int extra for the source panel, "name=value" (config.xml source_panel_extra); empty for none. */
+ final String sourcePanelExtra;
+ /** List Coocaa OS sources from com.skyworth.tv in the Inputs menu (config.xml coocaa_sources). */
+ final boolean coocaaSources;
final String inputAction;
final int columns;
final boolean animations;
@@ -131,7 +135,8 @@ final class Config {
private Config(List<String> dockApps, boolean fillDock, List<String> hiddenApps, String liveTvPackage,
String liveTvAction, Map<String, String> launchActions, Map<String, String> appLabels,
- Map<String, String> appBanners, String sourcePanelService, String sourcePanelAction, String inputAction,
+ Map<String, String> appBanners, String sourcePanelService, String sourcePanelAction,
+ String sourcePanelExtra, boolean coocaaSources, String inputAction,
int columns, int rowsBelowDock, boolean animations, boolean advancedEffects,
boolean shamsiDate, String greetingName, boolean moduleCards, boolean reducedMotion, boolean dockTitle, boolean dockRow, boolean reorderButton, boolean showNetworkPill, boolean iconOnlyButtons, boolean libraryButton, int wifiLabelWidth, boolean alwaysShowNames, boolean wallpaperTrueColor, String vpnApp,
boolean showHomeSettingsShortcut, boolean showStats, boolean appLibrary, int backgroundColor, int skyIntensity,
@@ -151,6 +156,8 @@ final class Config {
this.appBanners = Collections.unmodifiableMap(appBanners);
this.sourcePanelService = sourcePanelService;
this.sourcePanelAction = sourcePanelAction;
+ this.sourcePanelExtra = sourcePanelExtra;
+ this.coocaaSources = coocaaSources;
this.inputAction = inputAction;
this.columns = columns;
this.rowsBelowDock = rowsBelowDock;
@@ -208,6 +215,8 @@ final class Config {
List<String> appBanners = new ArrayList<>(Arrays.asList(res.getStringArray(R.array.app_banners)));
String panelService = res.getString(R.string.source_panel_service).trim();
String panelAction = res.getString(R.string.source_panel_action).trim();
+ 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();
int columns = res.getInteger(R.integer.columns);
int rowsBelow = res.getInteger(R.integer.rows_below_dock);
@@ -257,6 +266,8 @@ final class Config {
appBanners = stringList(json, "app_banners", appBanners);
panelService = string(json, "source_panel_service", panelService);
panelAction = string(json, "source_panel_action", panelAction);
+ panelExtra = string(json, "source_panel_extra", panelExtra).trim();
+ coocaaSources = bool(json, "coocaa_sources", coocaaSources);
inputAction = string(json, "input_action", inputAction);
columns = integer(json, "columns", columns, 1, 8);
rowsBelow = integer(json, "rows_below_dock", rowsBelow, 0, 3);
@@ -341,7 +352,7 @@ final class Config {
return new Config(dock, fillDock, hidden, liveTv, liveTvAction, packageMap(launchActions), packageMap(appLabels),
packageMap(appBanners), panelService,
- panelAction, inputAction,
+ panelAction, panelExtra, coocaaSources, inputAction,
Math.max(1, columns), Math.max(0, rowsBelow), animations, advancedEffects,
shamsi, greetingName, moduleCards, reducedMotion, dockTitle, dockRow, reorderButton, showNetworkPill, iconOnlyButtons, libraryButton, wifiLabelWidth, alwaysShowNames, wallpaperTrueColor, vpn, homeSettings, showStats, library, background,
Math.max(0, Math.min(100, skyIntensity)), settingsKeycodes, settingsKeyPanel, wallpaperEnabled, wallpaper,
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/CoocaaSources.java b/launcher/app/src/main/java/com/gathin/tvhome/CoocaaSources.java
new file mode 100644
index 000000000..76014e187
--- /dev/null
+++ b/launcher/app/src/main/java/com/gathin/tvhome/CoocaaSources.java
@@ -0,0 +1,77 @@
+package com.gathin.tvhome;
+
+import android.content.Context;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Bundle;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Inputs on Coocaa OS (Skyworth) TVs, which register nothing with TvInputManager. com.skyworth.tv lists
+ * the sources its own Source panel shows (HDMI 1, HDMI 2, RF, AV), and switches to one and brings up its
+ * player, as picking it in that panel does.
+ */
+final class CoocaaSources {
+
+ private static final Uri LIST = Uri.parse("content://com.skyworth.tv.provider/system/source_list");
+ private static final Uri METHOD = Uri.parse("content://com.skyworth.tv.sdk.provider/method");
+ private static final String[] COLUMNS = {"sourceName", "sourceIndex", "displayName"};
+
+ static final class Source {
+ /** HDMI, AV, VOD (the RF tuner), ... */
+ final String name;
+ final int index;
+ final String label;
+
+ Source(String name, int index, String label) {
+ this.name = name;
+ this.index = index;
+ this.label = label;
+ }
+ }
+
+ private CoocaaSources() {
+ }
+
+ /** HDMI ports in port order, then AV, then the tuner; empty where the provider is missing. */
+ static List<Source> list(Context ctx) {
+ List<Source> out = new ArrayList<>();
+ try (Cursor c = ctx.getContentResolver().query(LIST, COLUMNS, null, null, null)) {
+ while (c != null && c.moveToNext()) {
+ String name = c.getString(0);
+ String label = c.getString(2);
+ if (name == null) continue;
+ out.add(new Source(name, c.getInt(1), label == null || label.isEmpty() ? name : label));
+ }
+ } catch (RuntimeException e) {
+ return Collections.emptyList();
+ }
+ Collections.sort(out, (a, b) -> a.name.equals(b.name) ? Integer.compare(a.index, b.index)
+ : Integer.compare(rank(a.name), rank(b.name)));
+ return out;
+ }
+
+ private static int rank(String name) {
+ switch (name) {
+ case "HDMI": return 0;
+ case "AV": return 1;
+ case "VOD": return 3;
+ default: return 2;
+ }
+ }
+
+ static boolean open(Context ctx, Source source) {
+ Bundle extras = new Bundle();
+ extras.putString("name", source.name);
+ extras.putInt("index", source.index);
+ try {
+ Bundle ret = ctx.getContentResolver().call(METHOD, "METHOD_GOTO_SOURCE", null, extras);
+ return ret != null && ret.getBoolean("ret");
+ } catch (RuntimeException e) {
+ return false;
+ }
+ }
+}
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 e89977e15..90a54e87f 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@ -111,6 +111,8 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
private String inputAction;
private String sourcePanelService;
private String sourcePanelAction;
+ private String sourcePanelExtra;
+ private boolean coocaaSources;
private AppAdapter adapter;
private RecyclerView grid;
@@ -320,6 +322,8 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
inputAction = cfg.inputAction;
sourcePanelService = cfg.sourcePanelService;
sourcePanelAction = cfg.sourcePanelAction;
+ sourcePanelExtra = cfg.sourcePanelExtra;
+ coocaaSources = cfg.coocaaSources;
root = findViewById(R.id.root);
root.setBackgroundColor(cfg.backgroundColor);
@@ -2183,7 +2187,8 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
/** Hides the Inputs pill when it would have nothing to list: streaming boxes have no HDMI-in, AV or tuner. */
private void updateInputsButton() {
- boolean any = liveTvIntent() != null || !sourcePanelService.isEmpty();
+ boolean any = liveTvIntent() != null || !sourcePanelService.isEmpty()
+ || (coocaaSources && !CoocaaSources.list(this).isEmpty());
TvInputManager tim = (TvInputManager) getSystemService(TV_INPUT_SERVICE);
if (!any && tim != null) {
for (TvInputInfo info : tim.getTvInputList()) {
@@ -2212,6 +2217,14 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
Intent i = new Intent(sourcePanelAction);
ComponentName c = ComponentName.unflattenFromString(sourcePanelService);
if (c != null) i.setComponent(c);
+ int eq = sourcePanelExtra.indexOf('=');
+ if (eq > 0) {
+ try {
+ i.putExtra(sourcePanelExtra.substring(0, eq).trim(),
+ Integer.parseInt(sourcePanelExtra.substring(eq + 1).trim()));
+ } catch (NumberFormatException ignored) {
+ }
+ }
try {
if (getPackageManager().resolveActivity(i, 0) != null) {
startActivity(i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
@@ -2255,7 +2268,8 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
private void showInputs() {
// A configured source panel and no Live TV row to offer next to it: the panel is the whole menu.
// The BYINTEK U4 needs this, as its TvInputManager lists three HDMI ports and an AV input it doesn't have.
- if (!sourcePanelService.isEmpty() && liveTvIntent() == null) {
+ List<CoocaaSources.Source> coocaa = coocaaSources ? CoocaaSources.list(this) : Collections.emptyList();
+ if (coocaa.isEmpty() && !sourcePanelService.isEmpty() && liveTvIntent() == null) {
openSourcePanel();
return;
}
@@ -2363,6 +2377,18 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
() -> openInput(id));
}
}
+ // Coocaa OS registers nothing with TvInputManager; com.skyworth.tv lists its sources instead.
+ if (rows.getChildCount() == 0) {
+ for (CoocaaSources.Source s : coocaa) {
+ int icon = "HDMI".equals(s.name) ? R.drawable.ic_input
+ : "VOD".equals(s.name) ? R.drawable.ic_livetv : R.drawable.ic_av;
+ addInputRow(rows, popup, icon, s.label, -1, () -> {
+ if (!CoocaaSources.open(this, s)) {
+ Toast.makeText(this, R.string.not_available, Toast.LENGTH_SHORT).show();
+ }
+ });
+ }
+ }
// Nothing to list where there is no TvInputManager: the TV's own source panel switches inputs.
if (rows.getChildCount() == 0 && !sourcePanelService.isEmpty()) {
addInputRow(rows, popup, R.drawable.ic_input, getString(R.string.inputs), -1, this::openSourcePanel);
diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xml
index 4ca1b963c..8764940f6 100644
--- a/launcher/app/src/main/res/values/config.xml
+++ b/launcher/app/src/main/res/values/config.xml
@@ -54,6 +54,16 @@
opens the panel directly instead of a menu. Leave empty to omit. -->
<string name="source_panel_service" translatable="false"></string>
<string name="source_panel_action" translatable="false"></string>
+ <!-- One int extra sent with the source panel intent, "name=value". Coocaa OS (Skyworth, China) needs
+ control_center_command=100 for its control center to open on the source row, as the remote's
+ Source button does. Leave empty to omit. -->
+ <string name="source_panel_extra" translatable="false"></string>
+
+ <!-- Coocaa OS (Skyworth, China) registers no inputs with TvInputManager; com.skyworth.tv lists its
+ sources (HDMI 1, HDMI 2, AV, the tuner) through its own provider instead. true: show those in the
+ Inputs menu and switch with com.skyworth.tv, ahead of the source panel above, which stays as the
+ fallback. See CoocaaSources and examples/skyworth-7s60-a5. -->
+ <bool name="coocaa_sources">false</bool>
<!-- 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
diff --git a/themes/README.md b/themes/README.md
index e9ae32cfe..d79f31546 100644
--- a/themes/README.md
+++ b/themes/README.md
@@ -32,6 +32,8 @@ is ignored, and a file that doesn't parse is ignored as a whole, so a theme can
| `hidden_apps` | list of package names | Never shown as tiles |
| `live_tv_package`, `live_tv_action` | string | The Live TV app and, if it has no leanback entry, the action to start it with |
| `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 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`) |
| `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) |