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: one LEANBACK query per rebuild, card records read only when an app declares a card
Riku Pirttinokkafb3da06d5b52
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java b/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.javaindex 11693851d..5a5356f7f 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java@@ -226,10 +226,11 @@ public class AppAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {* Rebuilds the tiles. A shown module card stands in for every tile of its package (same component,* so focus follows it); hidden_apps wins over a card, and a card's package in dock_apps takes that slot.*/- void reload(List<Cards.Card> cards) {+ void reload(List<Cards.Card> cards, List<ResolveInfo> leanback) {PackageManager pm = ctx.getPackageManager();- Intent probe = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LEANBACK_LAUNCHER);- List<ResolveInfo> found = new ArrayList<>(pm.queryIntentActivities(probe, 0));+ // The LEANBACK query is shared with the module-card check (MainActivity); copy it before adding+ // library apps so the caller's list stays as it was.+ List<ResolveInfo> found = new ArrayList<>(leanback);Set<String> tvPackages = new HashSet<>();for (ResolveInfo ri : found) if (ri.activityInfo != null) tvPackages.add(ri.activityInfo.packageName);leanbackPackages = tvPackages;diff --git a/launcher/app/src/main/java/com/gathin/tvhome/Cards.java b/launcher/app/src/main/java/com/gathin/tvhome/Cards.javaindex 4db7bfefe..303a8f68f 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/Cards.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/Cards.java@@ -32,6 +32,7 @@ import java.util.List;import java.util.Map;import java.util.Set;import java.util.TreeMap;+import java.util.function.Supplier;/*** Module cards (docs/specs/card.md): an installed app can declare a card for its tile, with its own@@ -179,8 +180,11 @@ final class Cards {* Every valid card installed on this TV, with its state under the given records. One cheap* PackageManager query when no app declares a card; the app list is only walked when one does.* hidden is the launcher's hidden_apps as in force (config.xml or a theme overlay): no card for those.+ * The decision records are only read when some app declares a card, and leanback is the launcher's+ * own LEANBACK_LAUNCHER query, so the app list isn't queried twice.*/- static List<Card> discover(Context ctx, Set<String> hidden, Map<String, Record> records) {+ static List<Card> discover(Context ctx, Set<String> hidden, Supplier<Map<String, Record>> recordSource,+ List<ResolveInfo> leanback) {if ((ctx.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) selfCheck();List<Card> out = new ArrayList<>();PackageManager pm = ctx.getPackageManager();@@ -193,12 +197,12 @@ final class Cards {return out;}if (declared.isEmpty()) return out;+ Map<String, Record> records = recordSource.get();// What the card must agree with: the activities shown as tiles, and the names already on screen.Set<String> tiles = new HashSet<>();Map<String, Set<String>> names = new HashMap<>();- for (ResolveInfo ri : pm.queryIntentActivities(- new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LEANBACK_LAUNCHER), 0)) {+ for (ResolveInfo ri : leanback) {if (ri.activityInfo == null) continue;String pkg = ri.activityInfo.packageName;tiles.add(new ComponentName(pkg, ri.activityInfo.name).flattenToString());diff --git a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.javaindex 7597e0e60..57303a568 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java@@ -11,6 +11,7 @@ import android.content.Context;import android.content.Intent;import android.content.IntentFilter;import android.content.pm.ApplicationInfo;+import android.content.pm.ResolveInfo;import android.graphics.Bitmap;import android.graphics.Canvas;import android.graphics.Color;@@ -689,8 +690,12 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {// An updated app may bring new artwork; the backdrop is cheap to make again.heroArtCache.clear();heroArtKey = null;- cards = moduleCards ? CardFeature.run(() -> Cards.discover(this, hiddenApps, Cards.load(Cards.storeFile(this))), none) : none;- adapter.reload(cards.isEmpty() ? none : CardFeature.run(() -> Cards.shown(cards), none));+ // One LEANBACK query for both the tiles and the card checks.+ final List<ResolveInfo> leanback = getPackageManager().queryIntentActivities(+ new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LEANBACK_LAUNCHER), 0);+ cards = moduleCards ? CardFeature.run(() -> Cards.discover(this, hiddenApps,+ () -> Cards.load(Cards.storeFile(this)), leanback), none) : none;+ adapter.reload(cards.isEmpty() ? none : CardFeature.run(() -> Cards.shown(cards), none), leanback);lastFocusedKey = returnKey;lastFocused = returnSlot;}