Skip to content

field_note · · 7 min

A remote-first home screen for my parents' Android TV box, in 25 KB of plain Java

Turning an ISP-issued Android 7 set-top box into something two people who don't read English can run with one remote: a custom launcher with no build system, news that opens in under a second, ads that survived a hosts-file block, a phone remote, and the three commands that must never be sent to this box.

My parents' TV box came from their internet provider. It runs Android 7 on 1 GB of RAM, its home screen is in English and built around the provider's own catalogue, and its YouTube app had stopped working years ago. They don't read English. The box's remote was broken, so the only control was whatever I gave them.

This is part one of a three-part series. It covers what I built on the box in one day. Part two is how my last command of that day bricked it, and part three is the camera and the talk button I added after it came back.

The constraints that decided everything

ConstraintWhat it ruled out
They read Nepali, not EnglishAny stock launcher, any settings screen they could land on
One remote, arrows and OKTouch-first apps, long-press, anything with a keyboard
Android 7, 1 GB RAM, a 2016 WebViewModern web apps, heavy launchers, current TikTok
userdebug firmware, adb root worksNothing. This is what made the rest possible

The launcher: one file, no Gradle

The home app is one Java file, about 25 KB as an APK. It has no Gradle, no AndroidX and no image assets. It builds with the SDK's own tools in five commands:

terminal
aapt2 link -o base.apk -I android.jar --manifest AndroidManifest.xml --min-sdk-version 21
javac --release 8 -classpath android.jar -d classes $(find src -name '*.java')
d8 --min-api 21 --lib android.jar --output out classes/**/*.class
zipalign -f 4 unsigned.apk aligned.apk && apksigner sign --ks ghar.keystore --out ghar.apk aligned.apk

Every icon is drawn in code on a 24-unit grid, so there is nothing to load and nothing to scale badly. Layout uses one coordinate space, 1280 × 720, multiplied by S = screenWidth / 1280, so the same numbers work at 720p and 1080p.

figure 1 · the home screen, remote rules
टिभी
युट्युब
समाचार
राशिफल
छोटो भिडियो
क्यामेरा

Click the grid, then use the arrow keys, Enter and Backspace. Or the buttons.

Six tiles, one remote. Right and left walk the tiles in reading order and wrap at the ends, because people think of the arrows as next and previous, not as directions on a grid. Back always lands on the tile you left from, so the remote never loses your place.

Three rules came from watching them use it, not from Android's defaults:

  • Left and right mean previous and next. Android's focus search treats arrows as directions on a grid, and right at the end of a row goes nowhere. My father pressed right expecting the next thing. Now right walks the tiles in reading order and wraps.
  • Back returns to the tile you came from. Not the first tile, not wherever focus search lands. Coming back from the news should leave you on समाचार.
  • The guide at the bottom is a drawing of their remote's OK ring, with the part to press in yellow. A line of text saying "use the arrows" was the first version. They did not read it.

The clock in the corner speaks the way they do: बिहान, दिउँसो, बेलुका, राति instead of AM and PM, Devanagari digits, and the day of the week.

News that opens in under a second

The समाचार tile shows the newest full bulletin from each channel they watch. It is not the newest video, because the newest video is usually a 40-second clip. There is no YouTube API key. Every channel has a public feed at youtube.com/feeds/videos.xml?channel_id=…, and a regex over 15 entries is cheaper than an XML parser on this box.

Three things made it reliable:

  • A title filter per channel. One channel calls its bulletin समाचार, another "NEWS TIME", another "mukhya samachar". Each channel has its own pattern.
  • Skip entries with views="0". The national broadcaster's tile was "broken". Its feed lists the next bulletin as soon as it is scheduled, hours before it starts, so the newest entry was a stream that did not exist yet. Zero views means not started.
  • Fetch early, in parallel, and retry once. The feeds load in the background when the home screen resumes, so pressing OK shows a list that is already there. Fifteen parallel requests got some refused, so news loads first, short videos second, and a refused feed gets one retry 1.5 s later.

The TikTok tile that became a Shorts tile

They wanted TikTok. I tried three routes and each one closed:

  • TikTok's Android TV app installs and runs, then shows "Something went wrong" for every feed. The TV app has been discontinued, and the servers reject the last version.
  • TikTok Lite, a phone app, installs on armv7, then locks to a 553-pixel portrait strip, demands sign-up, and ignores the D-pad.
  • The website needs a newer browser engine than the box has. Its system WebView is version 52, from 2016, and replacing it does not fit in 1 GB.

The replacement is छोटो भिडियो: the newest Shorts from the channels they actually watch, interleaved one per channel. OK plays one in SmartTube; when it ends, SmartTube closes (one setting changed in its preferences file); our launcher resumes, shows "अर्को भिडियो आउँदैछ…" for 2.5 seconds, and plays the next. Any key stops the chain. It is TikTok's experience built out of parts the box already had.

The ads that survived a hosts-file block

Blocking ad servers in /system/etc/hosts is the first thing anyone does, and I did it. My father still saw ads on Live TV.

figure 2 · where the next ad comes from
  1. asked 1st · app preferences

    Saved ad list

    serving the ad you see

  2. asked 2nd · image cache on /data

    Saved ad images

  3. asked 3rd · internet

    Ad servers

Ads still play, from the saved ad list.

The first fix everyone reaches for, blocking the ad servers, is already on. Ads still play, because the app asks its own saved copies first and only goes to the network when those are empty. Turn the other two fixes on.

The Live TV app keeps its own copies: a list of ads in its preferences, and the images in two caches on disk, 28 full-screen ads and every banner size. It shows from its saved copies first and only fetches when they are empty. Blocking the servers only stops the copies from being refreshed. The fix was to empty the list and both caches, after backing them up, and to keep the block so they stay empty. One host serves both ads and channel configuration, so it could not be blocked, and that is why the caches had to go.

The phone remote

With the box's remote broken, the phone became the remote. A small Python server on the laptop serves a page to the phone over Tailscale and turns taps into key presses on the box.

The first version used adb shell input keyevent. Every press took about a second, which is unusable for arrows. Starting a JVM for each key is the cost. The second version writes raw events to the box's remote-control input device with sendevent, down and up as separate events. Presses are instant, and holding a button repeats, exactly like the real remote.

Three things on this box must never be sent, and I learned each one by sending it:

CommandWhat it does here
KEYCODE_POWERDeep suspend. The network goes down with it and Wake-on-LAN is disabled, so nothing can wake it. Only unplugging does
Write to /sys/class/display/modeThe TV shows "No signal". Restoring the mode leaves the HDMI output off until a reboot
CEC "standby" to the TVIgnored by this TV. "Wake" and "report status" work, so the phone's power button wakes the TV and never turns anything off

Remote access, the plumbing nobody sees

  • Tailscale on Android 7. The Tailscale app needs Android 8. The static ARM build of tailscaled runs fine as an init service in userspace-networking mode, with a resolv.conf added because Go reads it.
  • adbd takes one network client at a time. On this Android version a second connection is accepted and never read. A dead laptop session holds the slot forever. A 10-second watchdog on the box restarts adbd if an established connection stays unread twice in a row.
  • Find the box by MAC, not IP. The router moves it. Every tool on the laptop finds it through ARP and a one-second parallel ping sweep, never a hard-coded address.
  • SmartTube cannot finish its own updates here. The same watchdog installs the downloaded update at 3 a.m., and only if SmartTube is not on screen.

What the day taught me

Design for the person holding the remote. Every rule here came from watching them use it, not from guidelines. Fix the layer that is actually serving the problem. Hosts blocks, caches and feeds all looked fixed one layer too early. Write down what must never be sent, in the code and in the notes, the first time you learn it.

Then I ran one last clean-up command, and part two begins at 3:05 the next morning.

Working through something like this? I help teams ship AI and cloud systems that hold up, and cost what they should.