Declutter and Customize Your Android TV (and Put Your Home Assistant Dashboard on It)

Share
A de-bloated Android TV showing a custom Home Assistant dashboard

Most smart TVs ship with a home screen full of adverts, "recommended" rows, tracking services and a dozen pre-installed apps you will never open. On a TV with only 2 GB of RAM that clutter is not just ugly, it makes the whole thing slow.

This is a step-by-step account of how I cleaned up an Android TV (a TCL Smart TV Pro running Android TV 14, 1.9 GB RAM), made it noticeably quicker, replaced the home screen with my own launcher, and put a live Home Assistant dashboard on it: camera feeds, solar and battery, weather, a swim spa, a 10-day forecast, world clocks and a news ticker. Everything below is reversible, nothing was uninstalled, and nothing needs root.

Finished dashboard on the TV (sample data and placeholder cameras, in the Wave theme)

The finished result. Screenshots in this article use sample data and generated placeholder camera images, never real footage.

The same approach works on most Android TV / Google TV sets (Sony, Philips, Hisense, Xiaomi, TCL, Chromecast with Google TV). Menus and package names differ by brand, so treat the package names as examples of the kind of thing to look for.

What you will need

  • An Android TV or Google TV on the same network as your computer.
  • A computer with the Android platform-tools (adb). I used Windows; the commands are the same elsewhere.
  • About an hour for the clean-up, and an evening if you also want to build your own home screen.
  • For the dashboard part: a Home Assistant server you can reach from the TV.

The ground rules I followed (they are why nothing went wrong):

  1. Disable, never uninstall. pm disable-user can be undone in one command; an uninstall of a system app cannot.
  2. Back up first. Save the full package list and the current home app before touching anything.
  3. Change one thing at a time and check the TV is still healthy after each.
  4. Keep an escape route. Know how to re-enable everything from the TV's own menus if you lose your computer connection.
  5. Do not touch the things the TV needs: the Settings app, the Play Store and Play Services, the remote and Bluetooth services, the TV input / HDMI stack, the keyboard and the firmware updater.

Warning: you are changing a device you own, and a firmware update can re-enable some things you disabled. Disabling system apps may affect your warranty position with some manufacturers. Do this at your own risk, and read the "Undo everything" section before you start.

Step 1: Turn on Developer options and wireless debugging

  1. Go to Settings > System > About and press OK on Android TV OS build (on some sets "Build number") seven times. You will see a message that developer mode is on.
  2. Open Settings > System > Developer options and turn on Wireless debugging (Android 11 and later). On older TVs use Network debugging / USB debugging instead.
  3. Choose Pair device with pairing code. The TV shows a six-digit code and an IP:port for pairing.

On the computer:

# one-time pairing (use the pairing port and code shown on the TV)
adb pair 192.168.1.50:36189 123456

# then connect using the *other* port shown on the main Wireless debugging screen
adb connect 192.168.1.50:43491
adb devices

Two things that cost me time:

  • The connect port is different from the pairing port, and it changes every time the TV reboots or sleeps for a while. After a reboot you usually have to pair again with a fresh code.
  • If the connect port is not shown or mDNS discovery does not find it, scan for it. The wireless debugging port is in the 30000 to 46000 range:
// find-port.js: lists open TCP ports on the TV in the usual wireless-debugging range
const net = require('net');
const host = '192.168.1.50', open = [];
let pending = 0, next = 30000;
function one() {
  if (next > 46000) { if (!pending) console.log('open:', open.join(',')); return; }
  const p = next++; pending++;
  const s = net.connect({ host, port: p, timeout: 700 });
  s.on('connect', () => { open.push(p); s.destroy(); });
  s.on('timeout', () => s.destroy());
  s.on('error', () => {});
  s.on('close', () => { pending--; one(); });
}
for (let i = 0; i < 400; i++) one();

The pairing port will be in the list too; try the other ones with adb connect.

If you use Git Bash on Windows, remember that it rewrites anything that looks like a Unix path, so adb shell ls /sdcard can turn into C:/Program Files/Git/sdcard. Prefix those commands with MSYS_NO_PATHCONV=1.

Step 2: Take a backup before changing anything

mkdir backup && cd backup
adb shell getprop ro.product.model        > device.txt
adb shell getprop ro.build.version.release >> device.txt
adb shell pm list packages -f -s > system-packages.txt   # system apps
adb shell pm list packages -f -3 > user-packages.txt     # apps you installed
adb shell pm list packages -d    > already-disabled.txt  # what is disabled today
adb shell cmd package resolve-activity -a android.intent.action.MAIN \
   -c android.intent.category.HOME > home-app.txt        # which app is your home screen
adb shell dumpsys usagestats > usagestats.txt

On my TV that was 171 system packages and 85 apps I (or the previous owner) had installed. The usage stats were disappointing: Android TV only keeps a day or two of events, so you cannot reliably tell "never used" from "not used this week". Decide from what each package is, not from the usage log.

Step 3: Decide what is junk

I sorted everything into four buckets.

Bucket Examples (package names are from my TCL) What I did
Tracking and ads Samba TV viewing-data service tv.samba.ssm.ui, TCL Channel+ (com.tcl.channelplus), TCL's promoted-content hub (com.tcl.waterfall.overseas), the on-screen message box Disabled
Retail and hotel leftovers store demo mode (com.tcl.exhibit), hotel menu, e-sticker price tag Disabled
Duplicate or sketchy user apps several browsers, two file managers, APK installers and "downloader" apps, a free VPN, ten screen-mirroring receivers doing the same job, "free movies" apps Disabled (kept one of each that I actually use)
Google extras I do not use YouTube Music, Play Games, feedback services, the print spooler, the HTML viewer, partner auto-installer Disabled
Must keep Settings, Play Store/Services, remote and Bluetooth services, TV input and HDMI stack, keyboard, updater, WebView, the streaming apps you use, one mirroring app, Chromecast built-in Untouched

Two tips for unknown packages:

adb shell dumpsys package com.vendor.mystery | head -40     # who is it, when installed, what does it declare?
adb shell dumpsys package com.vendor.mystery | grep -E "LEANBACK_LAUNCHER|BOOT_COMPLETED|HOME"

A package that has a launcher icon, starts at boot and has a vendor name is a good candidate. A package named *overlay*, *resoverlay* or *frameworkres* is part of the system theme: leave it alone.

For screen mirroring I kept one app (AirScreen, which receives AirPlay, Google Cast and Miracast) plus the TV's built-in Chromecast, and disabled the other nine receivers. Phone mirroring and casting from YouTube both still work.

Step 4: Disable, one at a time, with a safety net

Here is the little script I used. It disables packages one at a time, logs each one to a file, checks that adb is still connected after each one, and stops at the first failure. A second script re-enables everything from the log.

#!/bin/bash
# disable.sh <label> pkg1 pkg2 ...
TV="192.168.1.50:43491"; A="adb -s $TV"; L=$1; shift
for p in "$@"; do
  if ! $A shell pm path "$p" 2>/dev/null | grep -q package; then echo "skip (not installed): $p"; continue; fi
  r=$($A shell pm disable-user --user 0 "$p" 2>&1 | tr -d '\r' | head -1); echo "$r"
  if echo "$r" | grep -q "disabled-user"; then echo "$p" >> disabled-packages.txt
  else echo "FAILED on $p - stopping"; exit 1; fi
  $A devices | grep -q "$TV.*device" || { echo "ADB LOST after $p - stopping"; exit 1; }
done
#!/bin/bash
# restore-all.sh <ip:port>  re-enables every package listed in disabled-packages.txt
while read p; do [ -n "$p" ] && adb -s "$1" shell pm enable "$p"; done < disabled-packages.txt

You can also undo any single one from the TV itself with no computer: Settings > Apps > See all apps > Show system apps, pick the app and choose Enable.

In total I disabled about 100 packages (the first 7 tracking/retail items, 29 junk user apps, 17 system extras, then everything else I did not use). After each batch I checked that the streaming apps I care about were still enabled. A word of warning if you script that check: grep -q "com.google.android.youtube.tv" also matches com.google.android.youtube.tvmusic. I briefly thought I had disabled YouTube; use grep -x "package:..." for exact matches.

Step 5: Make it faster

The biggest speed-up is simply not running a hundred background services on 1.9 GB of RAM. Two extra tweaks:

adb shell "settings put global window_animation_scale 0.5; settings put global transition_animation_scale 0.5; settings put global animator_duration_scale 0.5"
adb shell pm trim-caches 4G
adb shell "grep MemAvailable /proc/meminfo"

Available memory went from about 705 MB to 850 to 960 MB and menus feel noticeably snappier with half-length animations (use 0 to switch them off entirely).

Step 6: Replace the home screen (the hard part)

On Google TV the home screen is com.google.android.apps.tv.launcherx, full of promoted content. I wanted to replace it with my own launcher, and this is where the "simple" guides stop. What I learned:

Attempt Result
Install my launcher and run cmd package set-home-activity my.package/.MainActivity Reported success, no effect. The Home key still opened the stock launcher.
Make it the HOME role holder (cmd role add-role-holder --user 0 android.app.role.HOME my.package) Same: it was already the holder and the Home key ignored it.
Disable the stock launcher Home key now opened Google's setup-recovery screen, not my app.
Disable that single recovery component Refused: SecurityException: Shell cannot change component state.

The reason is the priority of the HOME handlers. This is what the TV listed:

adb shell cmd package query-activities --brief -a android.intent.action.MAIN -c android.intent.category.HOME
Handler Priority
Stock launcher (launcherx) 2
Setup wizard recovery activity (setupwraith/.RecoveryActivity) 1
My launcher 0
Settings FallbackHome -1000

A normal app cannot raise its own filter priority, so mine could only win if both handlers above it were disabled. The only way to switch off the recovery activity from the shell is to disable the whole setup wizard package.

That sounded risky (some guides warn it can drop saved Wi-Fi), so I checked first that the TV counted as fully set up and, importantly, kept the safety net: the Settings FallbackHome activity, which the system uses if nothing else can handle Home.

adb shell "settings get global device_provisioned; settings get secure user_setup_complete"   # both should be 1
adb shell pm disable-user --user 0 com.google.android.apps.tv.launcherx
adb shell pm disable-user --user 0 com.google.android.tungsten.setupwraith
adb shell input keyevent KEYCODE_HOME      # should now open YOUR launcher

It worked, Wi-Fi stayed connected, and (the real test) I rebooted the TV: it came up on my launcher with everything still disabled. If you try this, do the reboot test before you declare victory.

Recovery if it ever goes wrong: the TV falls back to its own Settings screen. Go to Settings > Apps > Show system apps and enable "Android TV Launcher" and "Setup Wizard", or run restore-all.sh.

Step 7: Build your own launcher without Android Studio

A launcher is just an app whose activity declares the HOME category. Mine is a single activity: a row of shortcuts across the top and a full-screen WebView underneath that shows a page I wrote. No libraries, no Gradle: the Android command-line tools are enough.

Tools (JDK 17 plus the SDK command-line tools):

# after installing a JDK 17 and unpacking the command-line tools:
sdkmanager --sdk_root=$ANDROID_HOME "platforms;android-34" "build-tools;34.0.0"
yes | sdkmanager --sdk_root=$ANDROID_HOME --licenses

(Piping y once at a time did not work for me; yes | did.)

Manifest — the two intent filters are the important part: one makes it appear in the app row, the other makes it a home screen:

<activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTask">
  <intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
  </intent-filter>
  <intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.HOME"/>
    <category android:name="android.intent.category.DEFAULT"/>
  </intent-filter>
</activity>

Restrict cleartext traffic to your Home Assistant host only. Home Assistant is usually plain HTTP on the LAN; do not let the whole app speak HTTP:

<!-- res/xml/nsc.xml (referenced by android:networkSecurityConfig) -->
<network-security-config>
  <base-config cleartextTrafficPermitted="false"/>
  <domain-config cleartextTrafficPermitted="true">
    <domain includeSubdomains="false">192.168.1.20</domain>
  </domain-config>
</network-security-config>

The activity loads a page bundled in the APK, with the Home Assistant URL and token substituted in memory at runtime. The token is never baked into the APK; it is pushed to the TV as a small config file:

web.getSettings().setJavaScriptEnabled(true);
web.getSettings().setDomStorageEnabled(true);
web.getSettings().setMediaPlaybackRequiresUserGesture(false);
web.getSettings().setAllowFileAccess(false);
web.setFocusable(false);                       // D-pad stays on the shortcut buttons
web.setWebViewClient(new WebViewClient() {     // never navigate away from the HA origin
  @Override public boolean shouldOverrideUrlLoading(WebView v, WebResourceRequest r) {
    return !r.getUrl().toString().startsWith(base);
  }});

String html = readAsset("tv.html")
    .replace("__HA_BASE__", base).replace("__HA_TOKEN__", token);
web.loadDataWithBaseURL(base + "/", html, "text/html", "utf-8", null);  // same origin as HA, so fetch() needs no CORS

Using loadDataWithBaseURL with the Home Assistant origin means the page can call /api/... on that host without CORS headaches.

Other details worth stealing:

  • Shortcut buttons use the real app logos, taken from the apps already on the TV, so they always match:
    PackageManager.getApplicationBanner(pkg) (falling back to getApplicationIcon). Add a <queries> entry for each package or Android 11+ package visibility will hide them.
  • Pause the page when another app is in front (web.onPause(); web.pauseTimers();) so camera streams are not running behind a movie.
  • Ignore the Back key (this is Home).

Build script (Windows PowerShell, condensed). It uses only tools from the SDK:

$bt  = "$env:ANDROID_HOME\build-tools\34.0.0"; $jar = "$env:ANDROID_HOME\platforms\android-34\android.jar"
& "$bt\aapt2.exe" compile --dir res -o build\res.zip
& "$bt\aapt2.exe" link -o build\base.apk -I $jar --manifest AndroidManifest.xml `
    --min-sdk-version 26 --target-sdk-version 34 -A assets build\res.zip
javac --release 8 -cp $jar -d build\classes (Get-ChildItem src -Recurse -Filter *.java).FullName
& "$bt\d8.bat" --lib $jar --min-api 26 --output build\dex (Get-ChildItem build\classes -Recurse -Filter *.class).FullName
Copy-Item build\base.apk build\unsigned.apk; Push-Location build\dex; jar uf ..\unsigned.apk classes.dex; Pop-Location
& "$bt\zipalign.exe" -f 4 build\unsigned.apk build\aligned.apk
# one-time: keytool -genkeypair -keystore launcher.jks -alias launcher -keyalg RSA -keysize 2048 -validity 9000
& "$bt\apksigner.bat" sign --ks launcher.jks --ks-key-alias launcher --out launcher.apk build\aligned.apk

The whole APK is about 33 KB. Install it and push its config:

adb install -r launcher.apk
adb shell mkdir -p /sdcard/Android/data/my.package/files
adb push ha.cfg /sdcard/Android/data/my.package/files/ha.cfg   # url=...  token=...
adb shell am start -n my.package/.MainActivity

A PowerShell gotcha: keytool writes its progress to stderr, and with $ErrorActionPreference = 'Stop' that aborts the script. Wrap the call so stderr is not treated as an error.

Step 8: Connect Home Assistant, safely

My first instinct was to put the normal Home Assistant dashboard in the WebView. It works, but a standard Lovelace dashboard blown up on a 4K TV overflows the screen, needs a login with the remote, and looks like a web page. I wrote a purpose-built page instead, which talks to Home Assistant's REST API. That needs a token, and the token on the TV should never be your admin token.

I created a dedicated Home Assistant user for the TV: non-admin and local-only (it can only log in from your LAN), with its own 10-year long-lived token. If the TV is ever lost or compromised you delete that one user and nothing else is affected.

// create-tv-user.js (Node 20+). ADMIN_TOKEN comes from a file, never a command line.
const ha = 'http://192.168.1.20:8123';
const ws = new WebSocket(ha.replace('http', 'ws') + '/api/websocket');
// ... authenticate with the admin token, then:
await call({ type: 'config/auth/create', name: 'TV', group_ids: ['system-users'], local_only: true });   // non-admin, LAN-only
await call({ type: 'config/auth_provider/homeassistant/create', user_id, username: 'tv', password: randomPassword });
// log in as that user via the normal login flow to get an access token, then mint the long-lived one:
await asTv.call({ type: 'auth/long_lived_access_token', client_name: 'TV launcher', lifespan: 3650 });

One gotcha: do not send client_icon: null with that last call. It is rejected with expected str at 'client_icon'; just omit the field.

Keep in mind that a non-admin user can still operate whatever entities its dashboard exposes, so the TV page is read-only on purpose.

Cameras: snapshots beat video on a weak TV

I tried live HLS video for the four cameras first. This TV's decoder handled two of the four streams and left the others black or showing the browser's placeholder play icon. A snapshot every 1.5 seconds, fetched with the token and cross-faded, was far more reliable and far lighter:

function snap(id){
  var k = cams[id];
  (function loop(){
    fetch(B + '/api/camera_proxy/' + id + '?_=' + Date.now(), { headers: { Authorization: 'Bearer ' + T } })
      .then(function(r){ if(!r.ok) throw 0; return r.blob(); })
      .then(function(b){
        var im = [k.img, k.img2], nx = im[1 - k.cur], pv = im[k.cur], u = URL.createObjectURL(b);
        nx.onload = function(){ nx.style.opacity = 1; pv.style.opacity = 0; k.cur = 1 - k.cur; };  // CSS: img{transition:opacity .5s}
        nx.src = u; setTimeout(loop, 1500);
      })
      .catch(function(){ setTimeout(loop, 3000); });
  })();
}

The first snapshot after the cameras have been idle can take a few seconds; after that each one is a fraction of a second. Two stacked <img> elements that cross-fade remove the flicker you get when you replace the source directly.

Everything else is a tiny poll

Entity values come from GET /api/states/<entity_id> every five seconds (about twenty small requests) which is far lighter than parsing the full states list on a weak CPU. The page shows: solar, house load, battery and grid, today's yield, the weather, indoor temperature, who is home, and the spa.

Step 9: The extras

How the pieces connect

A swim spa over MQTT. My spa's controller has an MQTT setting in its app. I created a dedicated low-privilege login on the Mosquitto broker, entered it in the spa app, and the controller published Home Assistant MQTT discovery messages, so about 26 entities (water temperature, set temperature, pumps, blower, light, heat pump, faults) appeared by themselves with no YAML. If your spa sits on a different network segment, it needs a narrow firewall rule to the broker on port 1883. The spa's own phone app kept working alongside MQTT.

A 10-day forecast. Home Assistant's weather entity (Met.no in my case) only returned 6 days of daily forecast, so the strip stopped at six. Open-Meteo is free, needs no key, and returns up to 16 days with CORS enabled, so the page fetches it directly. I send it the location rounded to one decimal place (about 10 km), not my exact coordinates, and fall back to Home Assistant's forecast if Open-Meteo is unreachable.

fetch('https://api.open-meteo.com/v1/forecast?latitude=' + lat + '&longitude=' + lon +
      '&daily=weather_code,temperature_2m_max,temperature_2m_min&forecast_days=10&timezone=auto')

A news card. The launcher itself downloads a handful of public RSS feeds (ABC, BBC, SBS, Guardian) every 15 minutes with HttpURLConnection and XmlPullParser, then rotates one headline at a time with a fade. It is a card in the top bar rather than a scrolling ticker, because a scrolling line is unreadable in a narrow space. If a feed is down it is silently skipped.

World clocks. Two extra times beside the main clock for family overseas, using the browser's time-zone support (no library), with a +1 or -1 marker when the date differs:

n.toLocaleTimeString('en-US', { timeZone: 'Pacific/Auckland', hour: 'numeric', minute: '2-digit' })

Step 10: Themes, glass and a day/night schedule

The whole look is CSS variables on <body data-theme="...">, so a theme is a handful of lines. I ended up with five, switched by a button in the top bar (reachable with the remote) or automatically.

Sci-fi theme

Graphite glass theme

Aurora (warm taupe) theme

Wave theme (purple ribbons)

Minimal theme

The glass look is backdrop-filter: blur() on the panels over a wallpaper. A flat gradient looked cheap, so the wallpaper is drawn once on a <canvas> at load: a few big radial gradients with screen blending, a diagonal light sheen, a vignette and a pinch of grain to kill banding. Because it is painted a single time, it costs the TV nothing while running.

x.globalCompositeOperation = 'screen';
blobs.forEach(function(b){
  var g = x.createRadialGradient(cx, cy, 0, cx, cy, r);
  g.addColorStop(0, b.color + 'dd'); g.addColorStop(.55, b.color + '55'); g.addColorStop(1, b.color + '00');
  x.fillStyle = g; x.fillRect(0, 0, w, h);
});
// then: sheen (linear gradient band), vignette (radial), grain (random +/- on the pixel data)

Camera grading (everything but the sci-fi theme): a touch more contrast and saturation, and a soft-light tint per theme so grey night-vision footage matches the palette. mix-blend-mode: soft-light over the image does the tinting.

Automatic day/night. The launcher picks a theme by the clock (a lighter one from 06:00 to 18:00, a calm one at night) and reloads the page at the boundary. A manual pick overrides it until you choose "Auto" again.

String t() {
  if (!theme.equals("auto")) return theme;
  int h = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
  return (h >= 6 && h < 18) ? "wave" : "aurora";
}

A few honest design lessons: colours that look fine in a screenshot can look awful on the real TV (a bright green wallpaper lasted about a minute), so build in a quick way to cycle themes and keep the default conservative; and the cameras cover most of the screen, so most of a fancy wallpaper is only visible in the margins and behind the side panels.

Lessons learned

  • set-home-activity and the HOME role are not enough on Google TV. Priority decides, and a user app is at the bottom.
  • The shell cannot disable a single component (SecurityException), only whole packages.
  • Reboot-test before you trust it. My first success was only the state before a reboot.
  • Wireless debugging resets. Expect to re-pair after a reboot or a long sleep and to look up the new connect port.
  • Usage stats on Android TV are nearly useless for deciding what is unused.
  • grep for package names with -x, or a prefix match will fool you.
  • Test video before designing around it. Snapshots with a cross-fade were better than HLS on this hardware.
  • Round the location you send to third-party APIs, and fetch third-party data from the device so nothing on your server has to stay up.
  • Never publish screenshots of your own cameras. The screenshots here come from the real page with stubbed data and generated placeholder images.

Undo everything

# re-enable all disabled packages
bash restore-all.sh 192.168.1.50:43491

# or one by one
adb shell pm enable com.google.android.apps.tv.launcherx
adb shell pm enable com.google.android.tungsten.setupwraith

# reset animations
adb shell "settings put global window_animation_scale 1; settings put global transition_animation_scale 1; settings put global animator_duration_scale 1"

# remove the custom launcher
adb uninstall my.package

With no computer: Settings > Apps > See all apps > Show system apps, pick "Android TV Launcher" and "Setup Wizard" (or anything else you disabled) and choose Enable. Because the Settings fallback home screen stays available, the TV is never stranded.

Security notes

  • Turn Wireless debugging off when you have finished. It is a remote-control interface for the TV.
  • The TV's Home Assistant user is non-admin and local-only; revoke it by deleting that user.
  • Keep tokens in a file with restricted permissions and read them inside scripts. Do not paste them into chat, tickets or command lines.
  • The launcher only allows plain HTTP to the single Home Assistant host, and refuses to navigate anywhere else.
  • The page is read-only, but remember a non-admin Home Assistant user can still call services if someone gets the token. Treat the token like a house key.

Wrapping up

The result is a TV that boots straight to a screen I designed, shows the cameras and the house at a glance, still opens Netflix, YouTube, Prime Video and Jellyfin in one press, still mirrors my phone and casts YouTube, and has roughly 150 to 250 MB more free memory than before. The clean-up is mostly an afternoon of careful pm disable-user commands. The launcher and dashboard are a fun weekend project on top.

If you try it, start with Steps 1 to 5 only. That alone removes most of the clutter and is completely reversible, and you can decide later whether you want your own home screen.

Read more