Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.
Python adbadblockandroid-tvandroid-tv-launcherapple-tvbloatware-removalclaude-codedebloatfire-tvgoogle-tvlauncherprivacysmart-tvsony-braviatclvibe-codingxiaomi
Launcher: game_day, read each team's next game from an add-on (off by default)
Justin Newman429cdd2a8a61
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/Config.java b/launcher/app/src/main/java/com/gathin/tvhome/Config.javaindex 5d4b78fbd..1b84b546e 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java@@ -139,6 +139,8 @@ final class Config {final boolean showHomeSettingsShortcut;/** One line under the clock: CPU, free memory, free storage. Off unless config or a theme turns it on. */final boolean showStats;+ /** game_day: the package of an add-on that publishes each team's next game (GameDay); empty = off. */+ final String gameDay;/** App library pill after the last Home row (config.xml app_library). */final boolean appLibrary;/** OK directly toggles Home membership in the library (app_library_selection). */@@ -265,7 +267,7 @@ final class Config {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,+ boolean showHomeSettingsShortcut, boolean showStats, String gameDay, boolean appLibrary, boolean appLibrarySelection, boolean libraryOkOpens, boolean uniformTiles, int backgroundColor, int skyIntensity,int[] settingsKeycodes, boolean settingsKeyPanel, boolean restoreKeyServices, boolean wallpaperEnabled, File wallpaper, List<File> wallpapers,int wallpaperRotationMinutes, int wallpaperDim, int dockOpacity, String wallpaperOrder, boolean overlayApplied,Festival festival, int[] inputKeycodes, List<String> appKeys, String stockHomeRedirect,@@ -329,6 +331,7 @@ final class Config {this.vpnApp = vpnApp;this.showHomeSettingsShortcut = showHomeSettingsShortcut;this.showStats = showStats;+ this.gameDay = gameDay;this.appLibrary = appLibrary;this.appLibrarySelection = appLibrarySelection;this.libraryOkOpens = libraryOkOpens;@@ -451,6 +454,7 @@ final class Config {String vpn = res.getString(R.string.vpn_app).trim();boolean homeSettings = res.getBoolean(R.bool.show_home_settings_shortcut);boolean showStats = res.getBoolean(R.bool.show_stats);+ String gameDay = res.getString(R.string.game_day).trim();boolean library = res.getBoolean(R.bool.app_library);boolean librarySelection = res.getBoolean(R.bool.app_library_selection);boolean libraryOkOpens = res.getBoolean(R.bool.library_ok_opens);@@ -556,6 +560,7 @@ final class Config {vpn = string(json, "vpn_app", vpn);homeSettings = bool(json, "show_home_settings_shortcut", homeSettings);showStats = bool(json, "show_stats", showStats);+ gameDay = string(json, "game_day", gameDay);library = bool(json, "app_library", library);librarySelection = bool(json, "app_library_selection", librarySelection);libraryOkOpens = bool(json, "library_ok_opens", libraryOkOpens);@@ -657,7 +662,7 @@ final class Config {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,- vpn, homeSettings, showStats, library, librarySelection, libraryOkOpens, uniformTiles, background,+ vpn, homeSettings, showStats, gameDay, library, librarySelection, libraryOkOpens, uniformTiles, background,Math.max(0, Math.min(100, skyIntensity)), settingsKeycodes, settingsKeyPanel, restoreKeyServices, wallpaperEnabled, wallpaper,wallpapers, rotationMinutes, wallpaperDim, dockOpacity, wallpaperOrder, applied, festival, inputKeycodes, appKeys, stockHomeRedirect,json == null ? Collections.emptyList() : raceCalendar(json), cinematic, ambientGlow, appGlow, fadeRows,diff --git a/launcher/app/src/main/java/com/gathin/tvhome/GameDay.java b/launcher/app/src/main/java/com/gathin/tvhome/GameDay.javaindex dbb2a1331..3f55f6ea9 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/GameDay.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/GameDay.java@@ -1,10 +1,23 @@package com.gathin.tvhome;+import android.content.ContentResolver;+import android.content.Context;+import android.content.pm.ApplicationInfo;+import android.content.pm.PackageManager;+import android.content.pm.ProviderInfo;+import android.database.ContentObserver;+import android.database.Cursor;+import android.net.Uri;+import android.os.Handler;+import java.time.Duration;import java.util.ArrayList;import java.util.Collections;import java.util.Comparator;import java.util.List;+import java.util.concurrent.ExecutorService;+import java.util.concurrent.Executors;+import java.util.concurrent.RejectedExecutionException;/*** game_day (config.xml or a theme): each team's next game in the race panel's place, from an add-on such as@@ -12,6 +25,134 @@ import java.util.List;* offline. Contract: docs/modules.md.*/final class GameDay {+ static final String META = "com.gathin.tvhome.games";+ static final int TURN_DEFAULT = 30;+ private static final String[] COLUMNS = {"top_line", "word", "start_ms", "end_ms", "colour", "calendar", "turn_seconds"};++ private final Context ctx;+ private final Uri uri;+ private final Handler main;+ private final Runnable onChange;+ private final ExecutorService io = Executors.newSingleThreadExecutor();+ private final ContentObserver observer;+ private boolean watching;+ private List<Turn> turns = Collections.emptyList();+ private int turnSeconds = TURN_DEFAULT;++ private GameDay(Context ctx, Uri uri, Handler main, Runnable onChange) {+ this.ctx = ctx;+ this.uri = uri;+ this.main = main;+ this.onChange = onChange;+ observer = new ContentObserver(main) {+ @Override+ public void onChange(boolean selfChange) {+ read();+ }+ };+ }++ /**+ * Null when the key is empty, the package is not installed, or it names no provider of its own in a+ * {@value #META} meta-data. Naming the package is the owner's opt-in.+ */+ static GameDay create(Context ctx, String pkg, Handler main, Runnable onChange) {+ if (pkg == null || pkg.trim().isEmpty()) return null;+ try {+ PackageManager pm = ctx.getPackageManager();+ ApplicationInfo info = pm.getApplicationInfo(pkg.trim(), PackageManager.GET_META_DATA);+ String authority = info.metaData == null ? null : info.metaData.getString(META);+ if (authority == null || authority.trim().isEmpty()) return null;+ // The provider must be the named package's own, not another app's that claims the authority.+ ProviderInfo provider = pm.resolveContentProvider(authority.trim(), 0);+ if (provider == null || !pkg.trim().equals(provider.packageName)) return null;+ Uri uri = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(authority.trim()).appendPath("turns").build();+ return new GameDay(ctx, uri, main, onChange);+ } catch (PackageManager.NameNotFoundException e) {+ return null;+ }+ }++ /** Home is on screen: read now and watch for changes. */+ void start() {+ if (!watching) {+ try {+ ctx.getContentResolver().registerContentObserver(uri, false, observer);+ watching = true;+ } catch (SecurityException e) {+ // The add-on's provider went away; the panel keeps what it had.+ }+ }+ read();+ }++ /** Home is off screen: nothing runs until it is back. */+ void stop() {+ if (watching) ctx.getContentResolver().unregisterContentObserver(observer);+ watching = false;+ }++ void shutdown() {+ stop();+ io.shutdownNow();+ }++ /** One query off the main thread (the provider lives in the add-on's process), then onChange on the main thread. */+ void read() {+ try {+ io.execute(() -> {+ List<Object[]> rows = new ArrayList<>();+ try (Cursor c = ctx.getContentResolver().query(uri, COLUMNS, null, null, null)) {+ while (c != null && c.moveToNext()) {+ rows.add(new Object[] {c.getString(0), c.getString(1), c.getLong(2), c.getLong(3), c.getInt(4),+ c.getString(5), c.getInt(6)});+ }+ } catch (RuntimeException gone) {+ // Uninstalled or crashed mid-query: keep what is on screen.+ return;+ }+ List<Turn> parsed = fromRows(rows);+ int seconds = turnSeconds(rows);+ main.post(() -> {+ turns = parsed;+ turnSeconds = seconds;+ onChange.run();+ });+ });+ } catch (RejectedExecutionException shutDown) {+ // Home is being destroyed.+ }+ }++ List<Turn> turns() {+ return turns;+ }++ int turnSeconds() {+ return turnSeconds;+ }++ /** The add-on's rows as turns; a row without a top line or with impossible times is skipped. */+ static List<Turn> fromRows(List<Object[]> rows) {+ List<Turn> out = new ArrayList<>();+ for (Object[] r : rows) {+ if (!(r[0] instanceof String) || ((String) r[0]).isEmpty()) continue;+ long start = r[2] instanceof Number ? ((Number) r[2]).longValue() : -1;+ long end = r[3] instanceof Number ? ((Number) r[3]).longValue() : -1;+ if (start < 0 || end <= start) continue;+ String word = r[1] instanceof String ? (String) r[1] : "";+ int colour = r[4] instanceof Number ? ((Number) r[4]).intValue() : 0xFFFFFFFF;+ out.add(new Turn((String) r[0], word, start, end, colour));+ }+ return out;+ }++ /** 10 to 120 seconds per turn, as the add-on's settings allow; anything else is the default. */+ static int turnSeconds(List<Object[]> rows) {+ if (rows.isEmpty() || !(rows.get(0)[6] instanceof Number)) return TURN_DEFAULT;+ int s = ((Number) rows.get(0)[6]).intValue();+ return s >= 10 && s <= 120 ? s : TURN_DEFAULT;+ }/** One turn in the rotation: a game from the add-on, or the theme's F1 weekend ({@link #f1}). */static final class Turn {diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xmlindex c963338f1..5d96501c7 100644--- a/launcher/app/src/main/res/values/config.xml+++ b/launcher/app/src/main/res/values/config.xml@@ -412,6 +412,12 @@"show_stats": true. Nothing is read, and the clock does not move, while this is false. --><bool name="show_stats">false</bool>+ <!-- Each team's next game in the F1 panel's place under the clock, rotating with the theme's F1 weekend: the package+ of an add-on that publishes them (addons/game-day: io.github.justinnewman.gameday; contract in docs/modules.md).+ Empty = off: nothing is read or watched. The launcher only reads what the add-on publishes and never goes+ online. A theme can set "game_day". -->+ <string name="game_day" translatable="false"></string>+<!-- Time-of-day backdrop behind everything: a dark gradient that follows the clock, with a warmhorizon glow around sunrise and sunset. 0 keeps the plain background (the default); 1 to 100sets its opacity. Around 60 reads clearly without hiding a wallpaper. Can also be set withdiff --git a/launcher/app/src/test/java/com/gathin/tvhome/GameDayTest.java b/launcher/app/src/test/java/com/gathin/tvhome/GameDayTest.javaindex 4d22d0858..b5ad76941 100644--- a/launcher/app/src/test/java/com/gathin/tvhome/GameDayTest.java+++ b/launcher/app/src/test/java/com/gathin/tvhome/GameDayTest.java@@ -83,6 +83,30 @@ public class GameDayTest {assertFalse(GameDay.live(t, t.endMs));}+ @Test public void rowsAreParsedAndBadOnesSkipped() {+ List<Object[]> rows = Arrays.asList(+ new Object[] {"Minnesota Wild at Dallas Stars", "Puck drop", 1000L, 5000L, 0xFF2E7D32, "Minnesota Wild", 45},+ new Object[] {null, "Puck drop", 1000L, 5000L, 0, "x", 45},+ new Object[] {"Bad start", "Kickoff", -1L, 5000L, 0, "x", 45},+ new Object[] {"Ends first", "Kickoff", 5000L, 5000L, 0, "x", 45},+ new Object[] {"No word", null, 2000L, 6000L, 0xFF1565C0, "x", 45});+ List<GameDay.Turn> t = GameDay.fromRows(rows);+ assertEquals(2, t.size());+ assertEquals("Minnesota Wild at Dallas Stars", t.get(0).topLine);+ assertEquals("Puck drop", t.get(0).word);+ assertEquals(1000L, t.get(0).startMs);+ assertEquals(5000L, t.get(0).endMs);+ assertEquals(0xFF2E7D32, t.get(0).colour);+ assertEquals("", t.get(1).word);+ assertEquals(45, GameDay.turnSeconds(rows));+ }++ @Test public void turnSecondsOutOfRangeBecomesThirty() {+ assertEquals(30, GameDay.turnSeconds(Collections.singletonList(new Object[] {"a", "b", 1L, 2L, 0, "c", 500})));+ assertEquals(30, GameDay.turnSeconds(Collections.singletonList(new Object[] {"a", "b", 1L, 2L, 0, "c", 3})));+ assertEquals(30, GameDay.turnSeconds(Collections.emptyList()));+ }+@Test public void durationHelperMatchesTheCountdown() {assertEquals(Duration.ofMinutes(125), GameDay.until(game("Game", 125 * 60_000L, HOUR), NOW.toEpochMilli()));}diff --git a/themes/README.md b/themes/README.mdindex 9fe471a6e..f94c4a190 100644--- a/themes/README.md+++ b/themes/README.md@@ -101,6 +101,7 @@ A new key needs one there in the same pull request.| `advanced_effects` | bool | Optional lifted tile, icon zoom, smooth ambient colour and app opening effects; false by default || `show_home_settings_shortcut` | bool | Keep the optional Default-home tile visible when the TV has a home picker; false by default || `show_stats` | bool | One line under the clock with CPU, free memory and free storage. Off unless set |+| `game_day` | string | Each team's next game in the F1 panel's place under the clock ("Minnesota Wild at Dallas Stars", "Puck drop in 2h 18m", "Live now"), rotating every few seconds with the F1 weekend when `race_calendar` is on: the package of an add-on that publishes them, such as [Game Day](../addons/game-day/) (`io.github.justinnewman.gameday`). The launcher only reads it and stays offline. Off (empty) unless set || `handle_view_inputs` | bool | Answer the system input switcher (`VIEW_INPUTS`, what the remote's Input button becomes) with the Inputs menu, for sets whose stock launcher was its only handler (Hisense huangshan); `false` by default so a TV with its own input picker never gets a chooser || `background_color` | `#RRGGBB` | Colour behind everything; black by default || `sky_intensity` | 0 to 100 | Time-of-day backdrop: a dark gradient that follows the clock, 0 hides it (default) |