Skip to content

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

examples/xiaomi-mitv-mosr4: second unit notes and remote keys

Yveaux18824bf1f30f
diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.md
index 523e3a37b..2c7c371e3 100644
--- a/docs/TROUBLESHOOTING.md
+++ b/docs/TROUBLESHOOTING.md
@@ -177,7 +177,11 @@ Things that bit us or contributors, so they don't bite you. Commands use `tools/
If it names setupwraith, forget the network and join it again in Settings > Network & Internet (it
then belongs to `android.uid.system`), or use Ethernet. `tools/disable.sh` skips setupwraith while it
owns the network (`FORCE_SETUPWRAITH=1` overrides). Already offline? Rejoin from the TV with its own
- remote or a USB keyboard, then turn Wireless debugging back on if it was in use.
+ remote or a USB keyboard, then turn Wireless debugging back on if it was in use. Reconnecting is not
+ enough; forget the network first (Xiaomi MiTV-MOSR4, where this also switched USB debugging off).
+- **A reboot on setupwraith's recovery screen factory-reset the TV** (Xiaomi MiTV-MOSR4). Disable
+ setupwraith before launcherx. If `mFocusedApp` shows `.RecoveryActivity`, re-enable launcherx
+ first and do not reboot. [Notes](devices/xiaomi-mitv-mosr4.md).
- **Casting from a phone fails with "Untrusted device" after setupwraith is disabled**, seen on
Chromecast with Google TV HD (`boreal`) on Google TV 14 build UTTC.250917.004, the build the
`examples/google-chromecast-gtv-4k/` list was made on. YouTube on the phone says "Untrusted device.
@@ -312,6 +316,9 @@ tools/tv.py 'dumpsys accessibility'
`tools/tv.py 'getevent -lt'` in `settings_key_scancodes` and install with `HOME_KEY_SERVICE=1`
(an RC-36 remote sends its gear on scancode 240 and its notifications button on 362 that way; see
[the FPD CG50-C3 note](devices/fpd-cg50-c3.md)).
+- **All vendor buttons die at once** and `logcat` says `GLOBAL_BUTTON ... process is bad`: the
+ global-key receiver crashes on the disabled launcherx and Android stops starting it. Map every such
+ keycode in the helpers, also for disabled apps. See [the MOSR4 note](devices/xiaomi-mitv-mosr4.md).
A force-stop switches the helpers off for good: after `am force-stop com.gathin.tvhome` (or Force stop in
Settings > Apps) Android removes the launcher's services from the enabled list, and they do not come back
diff --git a/docs/devices/xiaomi-mitv-mosr4.md b/docs/devices/xiaomi-mitv-mosr4.md
new file mode 100644
index 000000000..a6b7ac760
--- /dev/null
+++ b/docs/devices/xiaomi-mitv-mosr4.md
@@ -0,0 +1,64 @@
+# Xiaomi MiTV-MOSR4 (irobot): second unit, EU firmware
+
+Google TV / Android 11, build `RTM5.220609.003/1585` (same as the first unit), 1.4 GB RAM.
+List: [`examples/xiaomi-mitv-mosr4/debloat.txt`](../../examples/xiaomi-mitv-mosr4/debloat.txt).
+First-day report, two reboots.
+
+## Takeover order
+
+Disabling launcherx while setupwraith was still enabled left Home on
+`setupwraith/.RecoveryActivity`. ADB was lost while the Wi-Fi was being re-saved, the TV was
+rebooted in that state, setup ran again and the TV was **factory reset**.
+
+If `mFocusedApp` shows `.RecoveryActivity`, re-enable launcherx first. Do not reboot there.
+
+What worked, reboot-checked:
+
+1. Re-save the Wi-Fi (below), switch USB debugging back on.
+2. Disable setupwraith while launcherx is still enabled.
+3. Disable launcherx, `set-home-activity`, press Home, check `mFocusedApp`.
+
+## Wi-Fi
+
+The network saved during setup belongs to setupwraith (`dumpsys wifi`, `cname=`). Reconnecting
+keeps that owner (same network ID). Forget it and join again; it then belongs to
+`com.android.tv.settings`. Forgetting it switched USB debugging off on this TV.
+
+## Remote buttons
+
+| Button | Scancode | Keycode |
+| --- | --- | --- |
+| Input | `000c00b2` | 178 `TV_INPUT` |
+| Settings | `000c018f` | 176 `SETTINGS` |
+| YouTube | `000c0188` | 190 `BUTTON_3` |
+| Netflix | `000c008e` | 193 `BUTTON_6` |
+| Prime Video | `000c00b0` | 194 `BUTTON_7` |
+
+With launcherx disabled all five do nothing. They are global keys for
+`com.xiaomi.android.tvsetup.partnercustomizer/.GlobalKeyReceiver`, which starts launcherx
+activities and crashes. After a few crashes Android stops starting it:
+
+```
+Unable to launch app com.xiaomi.android.tvsetup.partnercustomizer/1000 for broadcast
+ Intent { act=android.intent.action.GLOBAL_BUTTON ... }: process is bad
+```
+
+Catch the keys before they get there:
+
+```sh
+INPUT_KEY_SERVICE=1 HOME_KEY_SERVICE=1 TV_HOST=<tv ip> launcher/build-and-install.sh
+TV_HOST=<tv ip> tools/theme.sh examples/xiaomi-mitv-mosr4
+```
+
+`config.json` maps 190/193/194. A mapped button whose app is disabled is swallowed. Checked with
+the real remote (no `GLOBAL_BUTTON` lines, no crashes), using an equivalent key filter in a
+stand-alone launcher; not yet with `com.gathin.tvhome`. The Netflix button went to this receiver,
+not to overseaservice. The mic button keeps working.
+
+## Other
+
+- `com.mitv.tvhome.mitvplus` is re-enabled at every boot.
+- `com.xiaomi.mitv.manualhelp` exists here (`/system/customer-app`).
+- HDMI switching: `ACTION_VIEW` on a passthrough URI opens `com.mitv.livetv/.tv.MainActivity`.
+- `screencap -p` prints a banner before the PNG; capture to `/sdcard` and pull.
+- The Wi-Fi name in the top bar needs Location on.
diff --git a/examples/README.md b/examples/README.md
index 82d19b3bd..5abbe2684 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -172,7 +172,7 @@ on that firmware, grouped and commented. These are starting points: comment out
| `xiaomi-mitv-mffu0/` | Xiaomi TV S Pro 100 Mini LED 2025 (小米电视 S Pro 100, L100MB-SP, MiTV-MFFU0, finch, MediaTek), China firmware OS3.0.115.0.UFFMATV, 4 GB RAM | Android 14 (HyperOS 3, CN build) | First HyperOS 3 Xiaomi: Mi analytics, MiSight log upload, TV QS reporting, cloud control, video-daily promos with the Mi ad SDK, shopping, web promos, Pictorial, AI translate; alarms, health, game SDK off by choice; **keep TV Manager** (XiaoAI's "open an app" voice command runs through its provider) and **keep the stock launcher** (non-system launchers cannot own Home, not even as preferred home); ADB closes on every reboot; CEC set-top-box black-screen note; voice, casting, Mi Home, OTA, Hyper screensaver kept; debloat only |
| `xiaomi-mitv-moeu0/` | Xiaomi TV S Mini LED 75 2025 (MiTV-MOEU0, ladybird, MediaTek) | Google TV 14 | Mi TV+ banners and MiChannel rows, Mi analytics, TV Manager cleaner, Play auto-installs; setupwraith off (its Wi-Fi network belonged to the system here); remote's Settings 176, YouTube 190, Apps 284 and Xiaomi TV+ 192 noted |
| `xiaomi-mitv-moor2/` | Xiaomi MiTV-MOOR2 (venom, MediaTek) | Google TV 11 | Mi ad row and PatchWall, Mi analytics, MiLink, store demo; setup wizard off so a third-party launcher can own Home |
-| `xiaomi-mitv-mosr4/` | Xiaomi MiTV-MOSR4 (irobot, MediaTek) | Google TV 11 | Mi ad rows and PatchWall, Mi analytics, TV Manager, Miracast sink, OTA off by choice; setup wizard off so a third-party launcher can own Home; `overseaservice` hosts the Netflix key and must stay |
+| `xiaomi-mitv-mosr4/` | Xiaomi MiTV-MOSR4 (irobot, MediaTek) | Google TV 11 | Mi ad rows and PatchWall, Mi analytics, TV Manager, Miracast sink, OTA off by choice; setup wizard off so a third-party launcher can own Home; `overseaservice` hosts the Netflix key and must stay; second unit: setupwraith before launcherx, remote buttons need both key services and `config.json`; [notes](../docs/devices/xiaomi-mitv-mosr4.md) |
| `xiaomi-mitv-mssp0/` | Xiaomi MiTV-MSSP0 / Xiaomi Mi TV 4A 32 (amelie), firmware PI.5926 | Android TV 9 | Xiaomi telemetry and promo helpers, Google recommendation feeds; Assistant, Gallery and media browser off by owner choice; Clock replaces Backdrop; TV inputs, Gboard, Bluetooth and firmware update settings kept; 11 packages, applied October 19 and checked again October 21 |
| `xiaomi-mitv-mssp3/` | Xiaomi MiTV-MSSP3 (machuca, MediaTek) | Android TV 11 | PatchWall, Mi analytics, Netflix observer; Chromecast, screensavers, unused streaming apps off by choice |
| `xiaomi-mitv-mssp3-android9/` | Xiaomi MiTV-MSSP3 (machuca, MediaTek), Android 9 firmware PI.7524 | Android TV 9 | Same model before its Android 11 update: PatchWall, Mi analytics, TV Manager, OTA; voice assistant re-enables itself at every boot (updated system app rescan); screensaver, preloaded apps off; 1.8 GB, swap full before; notes for the older PI.4663 build (two packages absent, old leanback home to disable) |
diff --git a/examples/xiaomi-mitv-mosr4/config.json b/examples/xiaomi-mitv-mosr4/config.json
new file mode 100644
index 000000000..dff2e7693
--- /dev/null
+++ b/examples/xiaomi-mitv-mosr4/config.json
@@ -0,0 +1,8 @@
+{
+ "live_tv_package": "com.mitv.livetv",
+ "app_keys": [
+ "190:com.google.android.youtube.tv",
+ "193:com.netflix.ninja",
+ "194:com.amazon.amazonvideo.livingroom"
+ ]
+}
diff --git a/examples/xiaomi-mitv-mosr4/debloat.txt b/examples/xiaomi-mitv-mosr4/debloat.txt
index 322a916c8..80ef4a9a5 100644
--- a/examples/xiaomi-mitv-mosr4/debloat.txt
+++ b/examples/xiaomi-mitv-mosr4/debloat.txt
@@ -17,6 +17,15 @@
# disabled too - on the first run setupwraith/.RecoveryActivity took Home back and the install script's
# rollback re-enabled launcherx. Same story as examples/xiaomi-mitv-moor2.
#
+# Second unit (EU firmware, same build). Details: docs/devices/xiaomi-mitv-mosr4.md
+# - Disable setupwraith BEFORE launcherx. The other order left Home on RecoveryActivity, and a
+# reboot there re-ran setup and factory-reset the TV.
+# - The setup Wi-Fi belongs to setupwraith: forget it and re-join (reconnecting is not enough).
+# This switched USB debugging off.
+# - mitvplus is re-enabled at every boot.
+# - Input/Settings/YouTube/Netflix/Prime die (Xiaomi GlobalKeyReceiver crashes, "process is bad").
+# Fix: INPUT_KEY_SERVICE=1 HOME_KEY_SERVICE=1 build-and-install.sh, then theme.sh with config.json.
+#
# DO NOT DISABLE on this model, verified with dumpsys on the unit this list was written against:
# com.mitv.livetv owns .input.SelectInputActivity - the HDMI/source switcher lives
# inside the Live TV app, so disabling it costs you input switching
@@ -37,6 +46,7 @@ com.miui.tv.analytics
com.xiaomi.statistic
com.xiaomi.tvqs.overseas # Firebase analytics + DOWNLOAD_WITHOUT_NOTIFICATION
com.google.android.partnersetup # Google RLZ attribution pings
+com.google.android.feedback # feedback reporter (second unit)
# Ad rows, promos and content providers on the home screen ("Teruskan menonton", "Film terlaris")
com.mitv.tvhome.oemtab # holds ACCESS_ADSERVICES_AD_ID/_ATTRIBUTION - the ad row
@@ -51,7 +61,8 @@ fusion.android.tv.demo # in-store demo loop
com.xiaomi.mitv.tvmanager # "TV Manager" cleaner
com.xiaomo.tv.milegal # legal notices app
android.autoinstalls.config.xiaomi.amelie # silent preload installer config
-# com.xiaomi.mitv.manualhelp # not on this model (there is no on-screen manual package)
+com.xiaomi.mitv.manualhelp # on-screen manual (second unit only)
+com.android.printspooler # print spooler (second unit)
# Mi Cast / Miracast - Chromecast built-in (mediashell) still works without them
# com.mitv.milinkservice # not on this model
@@ -63,6 +74,7 @@ com.xiaomi.mimusic2 # Mi Music
com.google.android.play.games # Play Games
com.mitv.videoplayer # Pemutar media
com.mitv.gallery # Galeri
+# com.google.android.apps.tv.dreamx # ambient screensaver; set screensaver_components first
# Firmware updates off by request - re-enable com.xiaomi.mitv.updateservice to get OTA again
com.xiaomi.mitv.updateservice