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
fix: 统一设置入口回退并支持 TCL 与 FFALCON 电视
lin020c7273fca8
diff --git a/docs/tcl-settings-native.png b/docs/tcl-settings-native.pngnew file mode 100644index 000000000..8e433f409Binary files /dev/null and b/docs/tcl-settings-native.png differdiff --git a/launcher/app/src/main/AndroidManifest.xml b/launcher/app/src/main/AndroidManifest.xmlindex f56e008ea..c23b68638 100644--- a/launcher/app/src/main/AndroidManifest.xml+++ b/launcher/app/src/main/AndroidManifest.xml@@ -18,6 +18,19 @@<!-- Android 11+ package visibility: lets the launcher list the TV apps it shows as tiles, and theapps that declare a module card (docs/specs/card.md). --><queries>+ <!-- 查询标准设置处理程序,避免包可见性限制导致误用厂商回退入口。 -->+ <intent>+ <action android:name="android.settings.SETTINGS" />+ </intent>+ <intent>+ <action android:name="android.settings.WIFI_SETTINGS" />+ </intent>+ <intent>+ <action android:name="android.settings.DISPLAY_SETTINGS" />+ </intent>+ <intent>+ <action android:name="android.settings.MANAGE_APPLICATIONS_SETTINGS" />+ </intent><intent><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" />@@ -32,6 +45,7 @@</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" />+ <package android:name="com.tcl.settings" /></queries><applicationdiff --git a/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java b/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.javaindex 2cc4aa27d..9a566ae62 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java@@ -1,10 +1,12 @@package com.gathin.tvhome;import android.accessibilityservice.AccessibilityService;+import android.content.ActivityNotFoundException;import android.content.Intent;import android.provider.Settings;import android.view.KeyEvent;import android.view.accessibility.AccessibilityEvent;+import android.widget.Toast;import java.util.Collections;import java.util.Map;@@ -51,8 +53,12 @@ public class HomeKeyService extends AccessibilityService {if (isSettingsKey(event)) {if (event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled()) {Intent open = settingsPanel ? new Intent(this, QuickSettingsActivity.class)- : new Intent(Settings.ACTION_SETTINGS);- startActivity(open.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));+ : SystemSettings.intent(this, Settings.ACTION_SETTINGS);+ try {+ startActivity(open.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));+ } catch (ActivityNotFoundException | SecurityException unavailable) {+ Toast.makeText(this, R.string.not_available, Toast.LENGTH_SHORT).show();+ }}return true;}diff --git a/launcher/app/src/main/java/com/gathin/tvhome/LauncherSettingsActivity.java b/launcher/app/src/main/java/com/gathin/tvhome/LauncherSettingsActivity.javaindex fe5b5e504..ff6da6908 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/LauncherSettingsActivity.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/LauncherSettingsActivity.java@@ -89,7 +89,7 @@ public final class LauncherSettingsActivity extends Activity {open(new Intent(Settings.ACTION_HOME_SETTINGS));});findViewById(R.id.tvSettingsChoice).setOnClickListener(v ->- open(new Intent(Settings.ACTION_SETTINGS)));+ open(SystemSettings.intent(this, Settings.ACTION_SETTINGS)));refresh();columnChoices[Math.max(0, Math.min(columns - 4, 3))].requestFocus();}diff --git a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.javaindex 28a35f331..fb1a484a0 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java@@ -1684,18 +1684,9 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {}- /**- * China-market MIUI TV firmware answers no standard Settings intents at all; open Xiaomi's own- * settings app (com.xiaomi.mitv.settings) there, so the Settings and Wi-Fi pills keep working.- * On firmware with a standard settings handler the behaviour is unchanged.- */+ /** 所有设置入口共用标准 Intent 与厂商回退策略。 */private Intent systemIntent(String standardAction) {- Intent i = new Intent(standardAction);- if (i.resolveActivity(getPackageManager()) != null) return i;- i = new Intent().setComponent(new ComponentName(- "com.xiaomi.mitv.settings", "com.xiaomi.mitv.settings.entry.MainActivity"));- if (i.resolveActivity(getPackageManager()) != null) return i;- return new Intent(standardAction); // nothing found: let open() show the can't-open toast+ return SystemSettings.intent(this, standardAction);}/** Hides the Inputs pill when it would have nothing to list: streaming boxes have no HDMI-in, AV or tuner. */@@ -1739,7 +1730,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);try {startActivity(i);- } catch (ActivityNotFoundException e) {+ } catch (ActivityNotFoundException | SecurityException e) {Toast.makeText(this, R.string.not_available, Toast.LENGTH_SHORT).show();}}diff --git a/launcher/app/src/main/java/com/gathin/tvhome/QuickSettingsActivity.java b/launcher/app/src/main/java/com/gathin/tvhome/QuickSettingsActivity.javaindex 36ff5030c..8f5a1aa8b 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/QuickSettingsActivity.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/QuickSettingsActivity.java@@ -25,11 +25,11 @@ public final class QuickSettingsActivity extends Activity {setContentView(R.layout.activity_quick_settings);findViewById(R.id.scrim).setOnClickListener(v -> finish());LinearLayout rows = findViewById(R.id.rows);- addRow(rows, R.drawable.ic_settings, R.string.tv_settings, 0, new Intent(Settings.ACTION_SETTINGS));- addRow(rows, R.drawable.ic_picture, R.string.quick_picture, 0, new Intent(Settings.ACTION_DISPLAY_SETTINGS));- addRow(rows, R.drawable.ic_wifi, R.string.quick_network, 0, new Intent(Settings.ACTION_WIFI_SETTINGS));+ addRow(rows, R.drawable.ic_settings, R.string.tv_settings, 0, SystemSettings.intent(this, Settings.ACTION_SETTINGS));+ addRow(rows, R.drawable.ic_picture, R.string.quick_picture, 0, SystemSettings.intent(this, Settings.ACTION_DISPLAY_SETTINGS));+ addRow(rows, R.drawable.ic_wifi, R.string.quick_network, 0, SystemSettings.intent(this, Settings.ACTION_WIFI_SETTINGS));addRow(rows, R.drawable.ic_apps, R.string.quick_apps, R.string.quick_apps_hint,- new Intent(Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS));+ SystemSettings.intent(this, Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS));// Through Home, so it rebuilds with the new choices when Launcher settings closes.addRow(rows, R.drawable.ic_home_settings, R.string.launcher_settings, 0,new Intent(this, MainActivity.class).setAction(MainActivity.ACTION_LAUNCHER_SETTINGS));@@ -62,7 +62,7 @@ public final class QuickSettingsActivity extends Activity {row.setOnClickListener(v -> {try {startActivity(target.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));- } catch (ActivityNotFoundException e) {+ } catch (ActivityNotFoundException | SecurityException e) {Toast.makeText(this, R.string.not_available, Toast.LENGTH_SHORT).show();}finish();diff --git a/launcher/app/src/main/java/com/gathin/tvhome/SystemSettings.java b/launcher/app/src/main/java/com/gathin/tvhome/SystemSettings.javanew file mode 100644index 000000000..464dc9a4b--- /dev/null+++ b/launcher/app/src/main/java/com/gathin/tvhome/SystemSettings.java@@ -0,0 +1,26 @@+package com.gathin.tvhome;++import android.content.ComponentName;+import android.content.Context;+import android.content.Intent;+import android.content.pm.PackageManager;++/** 标准设置入口不可用时,尝试配置中声明的厂商设置入口。 */+final class SystemSettings {+ private SystemSettings() {}++ static Intent intent(Context context, String action) {+ PackageManager pm = context.getPackageManager();+ Intent standard = new Intent(action);+ if (pm.resolveActivity(standard, PackageManager.MATCH_DEFAULT_ONLY) != null) return standard;++ for (String value : context.getResources().getStringArray(R.array.settings_fallback_components)) {+ ComponentName component = ComponentName.unflattenFromString(value);+ if (component == null) continue;+ Intent fallback = new Intent().setComponent(component);+ // 显式 Intent 的 resolveActivity() 会直接返回指定组件,不能用它判断是否已安装。+ if (pm.resolveActivity(fallback, 0) != null) return fallback;+ }+ return standard;+ }+}diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xmlindex d415e695b..5c62ae1ad 100644--- a/launcher/app/src/main/res/values/config.xml+++ b/launcher/app/src/main/res/values/config.xml@@ -7,6 +7,12 @@--><resources>+ <!-- 标准设置入口不可用时依次尝试;对应包也须在 Manifest 的 queries 中可见。 -->+ <string-array name="settings_fallback_components" translatable="false">+ <item>com.xiaomi.mitv.settings/com.xiaomi.mitv.settings.entry.MainActivity</item>+ <item>com.tcl.settings/com.tcl.settings.ui.MainActivity</item>+ </string-array>+<!-- Apps pinned to the dock row at the bottom, in this order. Missing apps are skipped. --><string-array name="dock_apps"><item>com.netflix.ninja</item>