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: stock_home_redirect, for firmware that turns the stock launcher back on
Takrim2c873c727500
diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.mdindex aec219597..6b7c16c7d 100644--- a/docs/TROUBLESHOOTING.md+++ b/docs/TROUBLESHOOTING.md@@ -130,6 +130,16 @@ Things that bit us or contributors, so they don't bite you. Commands use `tools/`/data/local/tmp` and, when copying them in is refused, writes them through the launcher's`ThemeProvider` instead. A launcher installed before that provider existed doesn't have it: run`launcher/build-and-install.sh` once, then push the theme again.+- **Google TV comes back after a few remote presses**, seen on XGIMI (MoGo 3 Pro, Google TV 14). The+ remote's app buttons (YouTube, Netflix, Prime Video), the programmable button, the profile button and power+ all send F keys that the system hands to `com.xgimi.xrmservice/.XgimiGlobalKeyBroadcast` as global keys+ (`tools/tv.py 'dumpsys window' | grep -A40 mKeyMapping` lists them). That receiver runs+ `pm enable com.google.android.apps.tv.launcherx` on every one of them, so the stock launcher takes Home back.+ Keys listed in `app_keys` are taken by the key services before global key dispatch, so XGIMI's receiver never+ sees them: `examples/xgimi-mogo-3-pro` lists the app buttons. Power (F11) can't be taken over, because its+ sleep and power-menu handling needs system permissions. For that one, run with `HOME_KEY_SERVICE=1` and set+ `stock_home_redirect` to `com.google.android.apps.tv.launcherx`: if it comes back, its home screen is sent+ straight back here, and `tools/disable.sh` with the list disables it again.- **No on-screen keyboard** after switching launchers, seen on Xiaomi: the default input methodpointed at a Baidu keyboard that isn't installed. Fix:`tools/tv.py 'ime set com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME'`diff --git a/launcher/app/src/main/AndroidManifest.xml b/launcher/app/src/main/AndroidManifest.xmlindex 1f96dd066..3bd6fd4d5 100644--- a/launcher/app/src/main/AndroidManifest.xml+++ b/launcher/app/src/main/AndroidManifest.xml@@ -30,6 +30,11 @@<action android:name="android.intent.action.MAIN" /><category android:name="com.gathin.tvhome.category.DOCK_CARD" /></intent>+ <!-- stock_home_redirect: HomeKeyService looks up the stock launcher's HOME activity. -->+ <intent>+ <action android:name="android.intent.action.MAIN" />+ <category android:name="android.intent.category.HOME" />+ </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" /></queries>diff --git a/launcher/app/src/main/java/com/gathin/tvhome/Config.java b/launcher/app/src/main/java/com/gathin/tvhome/Config.javaindex 8f41173e3..fbb82a302 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java@@ -86,6 +86,8 @@ final class Config {final int[] inputKeycodes;/** Remote buttons that open an app, "keycode:package" or "KEYCODE_NAME:package" (config.xml app_keys). */final List<String> appKeys;+ /** Stock launcher whose home screen is sent back here if the firmware revives it (config.xml stock_home_redirect). */+ final String stockHomeRedirect;/** The Settings button opens the quick settings panel instead of the TV's Settings (settings_key_panel). */final boolean settingsKeyPanel;/** Whether themes may show a wallpaper (config.json, wallpaper). */@@ -113,10 +115,11 @@ final class Config {boolean showHomeSettingsShortcut, boolean showStats, boolean appLibrary, int backgroundColor, int skyIntensity,int[] settingsKeycodes, boolean settingsKeyPanel, boolean wallpaperEnabled, File wallpaper, List<File> wallpapers,int wallpaperRotationMinutes, int wallpaperDim, boolean overlayApplied,- Festival festival, int[] inputKeycodes, List<String> appKeys,+ Festival festival, int[] inputKeycodes, List<String> appKeys, String stockHomeRedirect,List<RaceWeekend.Race> raceCalendar, boolean cinematicHome) {this.inputKeycodes = inputKeycodes;this.appKeys = Collections.unmodifiableList(appKeys);+ this.stockHomeRedirect = stockHomeRedirect;this.dockApps = Collections.unmodifiableList(dockApps);this.fillDock = fillDock;this.hiddenApps = Collections.unmodifiableList(hiddenApps);@@ -197,6 +200,7 @@ final class Config {boolean settingsKeyPanel = res.getBoolean(R.bool.settings_key_panel);int[] inputKeycodes = res.getIntArray(R.array.input_key_keycodes);List<String> appKeys = new ArrayList<>(Arrays.asList(res.getStringArray(R.array.app_keys)));+ String stockHomeRedirect = res.getString(R.string.stock_home_redirect).trim();boolean cinematic = res.getBoolean(R.bool.cinematic_home);boolean applied = false;@@ -237,6 +241,7 @@ final class Config {settingsKeyPanel = bool(json, "settings_key_panel", settingsKeyPanel);inputKeycodes = intArray(json, "input_key_keycodes", inputKeycodes);appKeys = stringList(json, "app_keys", appKeys);+ stockHomeRedirect = string(json, "stock_home_redirect", stockHomeRedirect);cinematic = bool(json, "cinematic_home", cinematic);}// A theme push or reset invalidates choices made on the TV. On first use, remember the@@ -291,7 +296,7 @@ final class Config {shamsi, greetingName, moduleCards, reducedMotion, dockTitle, dockRow, reorderButton, vpn, homeSettings, showStats, library, background,Math.max(0, Math.min(100, skyIntensity)), settingsKeycodes, settingsKeyPanel, wallpaperEnabled, wallpaper,wallpapers, rotationMinutes, wallpaperDim, applied,- festival, inputKeycodes, appKeys, json == null ? Collections.emptyList() : raceCalendar(json), cinematic);+ festival, inputKeycodes, appKeys, stockHomeRedirect, json == null ? Collections.emptyList() : raceCalendar(json), cinematic);}/**diff --git a/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java b/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.javaindex 2cc4aa27d..4ad416501 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java@@ -2,18 +2,25 @@ package com.gathin.tvhome;import android.accessibilityservice.AccessibilityService;import android.content.Intent;+import android.content.pm.PackageManager;+import android.content.pm.ResolveInfo;import android.provider.Settings;import android.view.KeyEvent;import android.view.accessibility.AccessibilityEvent;import java.util.Collections;+import java.util.HashSet;import java.util.Map;+import java.util.Set;/*** Sends the remote's Home button to this launcher on remotes that emit KEYCODE_ALL_APPS for Home* (Xiaomi sticks and boxes). Android TV 9 routes that key only to the system-image launcher, so once* the stock launcher is disabled the button does nothing. Every other key passes through untouched.*+ * With stock_home_redirect set, it also sends the stock launcher's home screen back here, for firmware that turns+ * that launcher on again after it was disabled (XGIMI's xrmservice does, on its own remote keys).+ ** Enable over adb:* settings put secure enabled_accessibility_services com.gathin.tvhome/.HomeKeyService* settings put secure accessibility_enabled 1@@ -26,6 +33,8 @@ public class HomeKeyService extends AccessibilityService {private boolean settingsPanel;/** app_keys, the same map InputKeyService reads, for setups that run only this service. */private Map<Integer, String> appKeys = Collections.emptyMap();+ /** The stock launcher's HOME activities (stock_home_redirect), disabled ones included. */+ private final Set<String> stockHome = new HashSet<>();@Overrideprotected void onServiceConnected() {@@ -36,6 +45,13 @@ public class HomeKeyService extends AccessibilityService {settingsKeycodes = config.settingsKeycodes;settingsPanel = config.settingsKeyPanel;appKeys = RemoteKeys.parseAppKeys(config.appKeys);+ stockHome.clear();+ if (!config.stockHomeRedirect.isEmpty()) {+ Intent home = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME).setPackage(config.stockHomeRedirect);+ for (ResolveInfo ri : getPackageManager().queryIntentActivities(home, PackageManager.MATCH_DISABLED_COMPONENTS)) {+ stockHome.add(ri.activityInfo.name);+ }+ }}private boolean isSettingsKey(KeyEvent event) {@@ -74,6 +90,13 @@ public class HomeKeyService extends AccessibilityService {@Overridepublic void onAccessibilityEvent(AccessibilityEvent event) {+ // stock_home_redirect: the firmware turned the stock launcher back on and its home screen came up.+ if (stockHome.isEmpty() || event.getEventType() != AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) return;+ CharSequence cls = event.getClassName();+ if (cls != null && stockHome.contains(cls.toString())) {+ startActivity(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME).setPackage(getPackageName())+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED));+ }}@Overridediff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xmlindex 3deebbea4..0ad493e29 100644--- a/launcher/app/src/main/res/values/config.xml+++ b/launcher/app/src/main/res/values/config.xml@@ -93,6 +93,12 @@<string-array name="app_keys" translatable="false"></string-array>+ <!-- Package of the stock launcher, for TVs whose firmware turns it back on after it was disabled. XGIMI's+ com.xgimi.xrmservice does, on every one of its remote keys, power included (docs/TROUBLESHOOTING.md).+ Whenever that launcher's home screen comes up anyway, HomeKeyService (HOME_KEY_SERVICE=1) sends the TV+ straight back here. A theme's config.json can set it too. Leave empty to omit. -->+ <string name="stock_home_redirect" translatable="false"></string>+<!-- Show the Solar Hijri (Shamsi) date used in Iran and Afghanistan, e.g. "27 Mehr 1405", above theGregorian date. --><bool name="shamsi_date">false</bool>diff --git a/themes/README.md b/themes/README.mdindex d08c19670..cd10fac94 100644--- a/themes/README.md+++ b/themes/README.md@@ -63,6 +63,7 @@ is ignored, and a file that doesn't parse is ignored as a whole, so a theme can| `settings_key_panel` | bool | Those buttons open a small quick settings panel (TV settings, Display, Network, Apps, Launcher settings) instead of the TV's Settings || `input_key_keycodes` | list of keycodes | More remote buttons that open the input switcher, for `InputKeyService` (`KEYCODE_TV` and `KEYCODE_TV_INPUT` always do) || `app_keys` | list of strings | Remote buttons that open an app, as `"190:com.google.android.youtube.tv"` or `"KEYCODE_BUTTON_3:com.google.android.youtube.tv"`, for `InputKeyService` or `HomeKeyService` |+| `stock_home_redirect` | string | Stock launcher package; if the firmware turns it back on (XGIMI), its home screen is sent straight back here (`HOME_KEY_SERVICE=1`) || `race_calendar` | list of races | F1 race-weekend mode: from 12 hours before a weekend's first session until 4 hours after the race starts, a panel under the clock shows the next session with a countdown (or the live one) and the weekend's session times in the TV's time zone. Write it with `tools/race_calendar.py <theme folder>`, which fetches the season from the free Jolpica API; the launcher itself never goes online || `cinematic_home` | bool | Cinematic top shelf: the focused dock app's artwork, softened, fills the top of the screen in its colour, with a larger name, "Last opened" (apps opened from Home), dock position dots, a focus glow in the app's colour and a translucent dock band; off by default |