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: preserve banner detail on low-density TV UIs
Roman Linevab75d36f2b65
diff --git a/README.md b/README.mdindex 4fb0d03e3..c7f316494 100644--- a/README.md+++ b/README.md@@ -175,6 +175,7 @@ network, no background services. It needs JDK 17 and Android SDK platform 34 to`tools/tv.py 'settings put secure screensaver_components com.gathin.tvhome/.ClockDream; settings put secure screensaver_enabled 1'`- **Remote keys**: an optional accessibility service keeps the remote's Input button working on Google TV (`INPUT_KEY_SERVICE=1` at install), another fixes sticks whose Home key sends ALL_APPS (`HOME_KEY_SERVICE=1`).- **Navigation** is deliberate: Up and Down move one row, the top buttons never fall through to tiles, the last focused app is remembered, and installing or removing an app refreshes the tiles while Home is open.+- **Artwork** loads each app's banner at at least xhdpi (320 dpi), avoiding unnecessary downsampling on low-density TV interfaces before the focus zoom. Activity banners retain priority over application banners, vectors stay vectors, and resource failures use the normal package-manager fallback. No downloaded artwork, extra permission or display-resolution override.## Restoring your TVdiff --git a/launcher/app/build.gradle b/launcher/app/build.gradleindex 5045f80d4..e8b8d932e 100644--- a/launcher/app/build.gradle+++ b/launcher/app/build.gradle@@ -12,6 +12,7 @@ android {targetSdk 34versionCode 2versionName '2.0'+ testInstrumentationRunner 'com.gathin.tvhome.BannerLoadingTest'}buildTypes {diff --git a/launcher/app/src/androidTest/AndroidManifest.xml b/launcher/app/src/androidTest/AndroidManifest.xmlnew file mode 100644index 000000000..8fff10ddd--- /dev/null+++ b/launcher/app/src/androidTest/AndroidManifest.xml@@ -0,0 +1,21 @@+<?xml version="1.0" encoding="utf-8"?>+<manifest xmlns:android="http://schemas.android.com/apk/res/android">+ <uses-feature android:name="android.hardware.touchscreen" android:required="false" />+ <application android:banner="@drawable/test_raster_banner">+ <activity android:name="com.gathin.tvhome.BannerLoadingTest$RasterActivity"+ android:label="Banner bitmap fixture" android:exported="true">+ <intent-filter>+ <action android:name="android.intent.action.MAIN" />+ <category android:name="android.intent.category.LEANBACK_LAUNCHER" />+ </intent-filter>+ </activity>+ <activity android:name="com.gathin.tvhome.BannerLoadingTest$VectorActivity"+ android:label="Banner vector fixture" android:banner="@drawable/test_vector_banner"+ android:exported="true">+ <intent-filter>+ <action android:name="android.intent.action.MAIN" />+ <category android:name="android.intent.category.LEANBACK_LAUNCHER" />+ </intent-filter>+ </activity>+ </application>+</manifest>diff --git a/launcher/app/src/androidTest/java/com/gathin/tvhome/BannerLoadingTest.java b/launcher/app/src/androidTest/java/com/gathin/tvhome/BannerLoadingTest.javanew file mode 100644index 000000000..4885e53a3--- /dev/null+++ b/launcher/app/src/androidTest/java/com/gathin/tvhome/BannerLoadingTest.java@@ -0,0 +1,80 @@+package com.gathin.tvhome;++import android.app.Activity;+import android.app.Instrumentation;+import android.content.ComponentName;+import android.content.Context;+import android.content.res.Configuration;+import android.graphics.Bitmap;+import android.graphics.drawable.BitmapDrawable;+import android.graphics.drawable.Drawable;+import android.graphics.drawable.VectorDrawable;+import android.os.Bundle;+import android.util.Log;+import android.widget.FrameLayout;++import java.util.Collections;++/** Run with connectedDebugAndroidTest; uses real package resources, without test dependencies. */+public final class BannerLoadingTest extends Instrumentation {+ public static final class RasterActivity extends Activity {}+ public static final class VectorActivity extends Activity {}++ @Override+ public void onCreate(Bundle arguments) {+ super.onCreate(arguments);+ start();+ }++ @Override+ public void onStart() {+ Bundle result = new Bundle();+ result.putString("class", getClass().getName());+ result.putString("test", "preservesBannerDetailAndPrecedence");+ result.putInt("numtests", 1);+ result.putInt("current", 1);+ sendStatus(1, result);+ try {+ Throwable[] problem = {null};+ runOnMainSync(() -> {+ try {+ Configuration config = new Configuration(getTargetContext().getResources().getConfiguration());+ config.densityDpi = 213;+ Context context = getTargetContext().createConfigurationContext(config);+ AppAdapter adapter = new AppAdapter(context, null, 4, Config.load(context));+ adapter.reload(Collections.emptyList());+ Drawable raster = bannerFor(adapter, context, RasterActivity.class);+ if (!(raster instanceof BitmapDrawable)) throw new AssertionError("Missing application banner");+ Bitmap bitmap = ((BitmapDrawable) raster).getBitmap();+ // A focused 240 x 135 tile must not stretch a downsampled 213 x 120 bitmap.+ if (bitmap.getWidth() < 264 || bitmap.getHeight() < 149) {+ throw new AssertionError("Banner loses source detail: " + bitmap.getWidth() + "x" + bitmap.getHeight());+ }+ if (!(bannerFor(adapter, context, VectorActivity.class) instanceof VectorDrawable)) {+ throw new AssertionError("Activity vector banner must override the application bitmap");+ }+ } catch (Throwable failure) {+ problem[0] = failure;+ }+ });+ if (problem[0] != null) throw problem[0];+ sendStatus(0, result);+ result.putString("stream", "\nPASS: focused banner detail, application fallback, activity vector precedence\n");+ finish(Activity.RESULT_OK, result);+ } catch (Throwable failure) {+ result.putString("stack", Log.getStackTraceString(failure));+ sendStatus(-2, result);+ result.putString("stream", "\nFAIL: " + Log.getStackTraceString(failure));+ finish(Activity.RESULT_OK, result);+ }+ }++ private Drawable bannerFor(AppAdapter adapter, Context context, Class<?> activity) {+ String key = new ComponentName(getContext().getPackageName(), activity.getName()).flattenToShortString();+ int position = adapter.positionOf(key);+ if (position < 0) throw new AssertionError("Missing fixture tile: " + key);+ AppAdapter.Holder holder = adapter.onCreateViewHolder(new FrameLayout(context), 0);+ adapter.onBindViewHolder(holder, position);+ return holder.banner.getDrawable();+ }+}diff --git a/launcher/app/src/androidTest/res/drawable-xhdpi/test_raster_banner.png b/launcher/app/src/androidTest/res/drawable-xhdpi/test_raster_banner.pngnew file mode 100644index 000000000..12c9d8128Binary files /dev/null and b/launcher/app/src/androidTest/res/drawable-xhdpi/test_raster_banner.png differdiff --git a/launcher/app/src/androidTest/res/drawable/test_vector_banner.xml b/launcher/app/src/androidTest/res/drawable/test_vector_banner.xmlnew file mode 100644index 000000000..47a74d434--- /dev/null+++ b/launcher/app/src/androidTest/res/drawable/test_vector_banner.xml@@ -0,0 +1,6 @@+<?xml version="1.0" encoding="utf-8"?>+<vector xmlns:android="http://schemas.android.com/apk/res/android"+ android:width="160dp" android:height="90dp"+ android:viewportWidth="320" android:viewportHeight="180">+ <path android:fillColor="#00AA00" android:pathData="M0,0h320v180h-320z" />+</vector>diff --git a/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java b/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.javaindex 489e74250..77c581e8b 100644--- a/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java+++ b/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java@@ -6,6 +6,7 @@ import android.content.Context;import android.content.Intent;import android.content.pm.PackageManager;import android.content.pm.ResolveInfo;+import android.content.res.Resources;import android.graphics.Bitmap;import android.graphics.Canvas;import android.graphics.Color;@@ -14,6 +15,7 @@ import android.graphics.Rect;import android.graphics.drawable.Drawable;import android.net.Uri;import android.provider.Settings;+import android.util.DisplayMetrics;import android.view.KeyEvent;import android.view.LayoutInflater;import android.view.View;@@ -144,8 +146,7 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {ComponentName component = new ComponentName(pkg, ri.activityInfo.name);Cards.Card card = cardByPkg.get(pkg);if (card != null && !card.component.equals(component)) continue; // the card stands in for this tile- Drawable banner = ri.activityInfo.loadBanner(pm);- if (banner == null) banner = ri.activityInfo.applicationInfo.loadBanner(pm);+ Drawable banner = loadBanner(pm, ri);Drawable icon = ri.loadIcon(pm);if (card != null) {fresh.add(new Entry(Entry.CARD, card.label, component, banner, icon, card.caption, card.accent));@@ -177,6 +178,21 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.Holder> {notifyDataSetChanged();}+ private Drawable loadBanner(PackageManager pm, ResolveInfo ri) {+ int id = ri.activityInfo.banner;+ if (id == 0) id = ri.activityInfo.applicationInfo.banner;+ if (id != 0) {+ try {+ Resources resources = pm.getResourcesForApplication(ri.activityInfo.applicationInfo);+ // Keep at least xhdpi detail rather than downsampling artwork before the focus zoom.+ int density = Math.max(DisplayMetrics.DENSITY_XHIGH, ctx.getResources().getDisplayMetrics().densityDpi);+ return resources.getDrawableForDensity(id, density, null);+ } catch (PackageManager.NameNotFoundException | Resources.NotFoundException ignored) {+ }+ }+ return ri.activityInfo.loadBanner(pm);+ }+@NonNull@Overridepublic Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {