Skip to content

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

Merge PR #407: launcher: Fire OS routes standard settings intents to a CTS stub; fall back to MainSetting

Gathin238007d0307843
diff --cc launcher/app/src/main/AndroidManifest.xml
index 9b5cdaa5c,fe55de630..4bd7ba955
--- a/launcher/app/src/main/AndroidManifest.xml
+++ b/launcher/app/src/main/AndroidManifest.xml
@@@ -21,6 -18,19 +21,19 @@@
<!-- Android 11+ package visibility: lets the launcher list the TV apps it shows as tiles, and the
apps that declare a module card (docs/specs/card.md). -->
<queries>
- <!-- 查询标准设置处理程序,避免包可见性限制导致误用厂商回退入口。 -->
++ <!-- The standard settings handlers, so package visibility doesn't hide them and send the pills to a vendor fallback by mistake. -->
+ <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" />
@@@ -33,16 -43,11 +46,19 @@@
<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. -->
+ <!-- China-market MIUI TV firmware: the Settings and Wi-Fi pills fall back to Xiaomi's settings app.
+ Fire TV: the real settings menu lives in the stock launcher (see settings_fallback_components). -->
<package android:name="com.xiaomi.mitv.settings" />
+ <package android:name="com.tcl.settings" />
+ <package android:name="com.amazon.tv.launcher" />
+ <!-- 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 --cc launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java
index 534a6a0a4,9a566ae62..8a9a32c4d
--- a/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java
@@@ -1,21 -1,15 +1,23 @@@
package com.gathin.tvhome;
import android.accessibilityservice.AccessibilityService;
+ import android.content.ActivityNotFoundException;
+import android.content.BroadcastReceiver;
+import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.UserManager;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.provider.Settings;
import android.view.KeyEvent;
import android.view.accessibility.AccessibilityEvent;
+ import android.widget.Toast;
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
diff --cc launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
index 01c26d9e6,fb1a484a0..49f7864fe
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@@ -2204,18 -1684,9 +2204,9 @@@ public class MainActivity extends Activ
}
- /**
- * 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 与厂商回退策略。 */
++ /** Every settings entry shares the standard intent and the vendor fallback (SystemSettings). */
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. */
diff --cc launcher/app/src/main/java/com/gathin/tvhome/SystemSettings.java
index 000000000,ae8731763..4b5fb5373
mode 000000,100644..100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/SystemSettings.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/SystemSettings.java
@@@ -1,0 -1,34 +1,35 @@@
+ package com.gathin.tvhome;
+
+ import android.content.ComponentName;
+ import android.content.Context;
+ import android.content.Intent;
+ import android.content.pm.PackageManager;
+ import android.content.pm.ResolveInfo;
+
-/** 标准设置入口不可用时,尝试配置中声明的厂商设置入口。 */
++/** The standard settings intent, or, when nothing usable answers it, the first vendor settings entry
++ * from settings_fallback_components that is installed (Xiaomi China, TCL / FFALCON, Fire OS). */
+ final class SystemSettings {
+ private SystemSettings() {}
+
+ static Intent intent(Context context, String action) {
+ PackageManager pm = context.getPackageManager();
+ Intent standard = new Intent(action);
+ ResolveInfo resolved = pm.resolveActivity(standard, PackageManager.MATCH_DEFAULT_ONLY);
+ // Fire OS resolves the standard actions to a CTS compliance stub that opens nothing;
+ // treat it as missing so the vendor fallback runs.
+ if (resolved != null && !resolved.activityInfo.name.contains("CTSDummy")) return standard;
+
+ for (String value : context.getResources().getStringArray(R.array.settings_fallback_components)) {
+ ComponentName component = ComponentName.unflattenFromString(value);
+ if (component == null) continue;
+ // Explicit resolveActivity() always succeeds, so check the package exists instead.
+ try {
+ pm.getPackageInfo(component.getPackageName(), 0);
+ } catch (PackageManager.NameNotFoundException e) {
+ continue;
+ }
+ return new Intent().setComponent(component);
+ }
+ return standard;
+ }
+ }
diff --cc launcher/app/src/main/res/values/config.xml
index 4e50cf07e,32be92f5d..9c58f4112
--- a/launcher/app/src/main/res/values/config.xml
+++ b/launcher/app/src/main/res/values/config.xml
@@@ -7,6 -7,13 +7,14 @@@
-->
<resources>
- <!-- 标准设置入口不可用时依次尝试;对应包也须在 Manifest 的 queries 中可见。 -->
++ <!-- Tried in order when no standard settings handler is usable; each package must also be visible
++ through <queries> in the manifest. -->
+ <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>
+ <item>com.amazon.tv.launcher/com.amazon.tv.launcher.ui.MainSettingsActivity</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>