Skip to content

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

docs: one MiTV-AFMU1 list instead of two (#855)

xbsheng838c32644cc3
diff --git a/README.md b/README.md
index e90b28262..09f99f965 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@
</p>
<p align="center">
- <a href="docs/PRESS.md"><img src="docs/card.jpg" alt="213 TV models · 63 brands · 24 languages · 445 KB launcher. Featured in TechCrunch, TechRadar, Tom's Guide, Mashable, Android Authority, XDA, FlatpanelsHD, It's FOSS, Phandroid, GIGAZINE, Xataka, WinFuture, Frandroid, Macitynet, Techaeris, TechPP and 67 more: 83 articles from 22 countries. Before: stock Google TV home with a sponsored ad. After: the Clean Your TV launcher." width="800"></a>
+ <a href="docs/PRESS.md"><img src="docs/card.jpg" alt="212 TV models · 63 brands · 24 languages · 445 KB launcher. Featured in TechCrunch, TechRadar, Tom's Guide, Mashable, Android Authority, XDA, FlatpanelsHD, It's FOSS, Phandroid, GIGAZINE, Xataka, WinFuture, Frandroid, Macitynet, Techaeris, TechPP and 67 more: 83 articles from 22 countries. Before: stock Google TV home with a sponsored ad. After: the Clean Your TV launcher." width="800"></a>
</p>
**The viral tweet:** [x.com/gathint/status/2111379569030939102](https://x.com/gathint/status/2111379569030939102)
@@ -303,7 +303,6 @@ Anker Nebula, BYINTEK, Epson, Gadnic, JMGO, Portronics, Stellamore, Wanbo and XG
| Xiaomi Mi Box S 2nd gen (MiTV-AFKR0, jaws), streaming box | Google TV 11 |
| Xiaomi Mi TV (MiTV-MOOQ0, croods) | Android TV 10 |
| Xiaomi Mi TV 4A (MiTV-MOOQ1) | Android TV 10 |
-| Xiaomi Mi TV Stick 4K 2nd gen (MiTV-AFMU1, adastra) | Android TV 14 |
| Xiaomi MiTV-AESP0 stick (aquaman, 1 GB) | Android TV 9 |
| Xiaomi MiTV-ANSP0 (小米电视5 Pro 65", jobs, Amlogic), China firmware 23.6.5.3226, 4 GB RAM | Android TV 9 (CN build) |
| Xiaomi MiTV-ASTP0 (mulan, sold as L55M7-EA), China firmware 22.12.2.1630, 1.5 GB RAM | Android TV 9 (CN build) |
diff --git a/examples/README.md b/examples/README.md
index 1fd77920d..16eb1a1c7 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -196,7 +196,6 @@ on that firmware, grouped and commented. These are starting points: comment out
| `xiaomi-mi-box-s-2nd-gen/` | Xiaomi Mi Box S 2nd gen (MiTV-AFKR0, jaws), streaming box | Google TV 11 | Mi ad row and PatchWall, Mi analytics, partner auto-installs, update service off by choice; setup wizard off for the launcher, Wi-Fi password re-entry note |
| `xiaomi-mitv-mooq0/` | Xiaomi Mi TV (MiTV-MOOQ0, croods) | Android TV 10 | PatchWall, Mi analytics, MiChannel, TV Manager, Alexa bridge; factory test app also claims HOME; notes from #81 |
| `xiaomi-mi-tv-4a/` | Xiaomi Mi TV 4A (MiTV-MOOQ1) | Android TV 10 | PatchWall, Mi analytics, SmartShare, MiLink |
-| `xiaomi-mi-tv-stick-4k-gen2/` | Xiaomi Mi TV Stick 4K 2nd gen (MiTV-AFMU1, adastra) | Android TV 14 | Provisional, tested one day: Mi analytics and ad services, promo rows, casting and Mi video off; stock launcher and setupwraith out (Wi-Fi checked first); YouTube app left enabled; firmware updater (com.xiaomi.mitv.updateservice) DISABLED, so no firmware updates |
| `xiaomi-mitv-aesp0/` | Xiaomi MiTV-AESP0 stick (aquaman, 1 GB) | Android TV 9 | No inputs; Home key sends ALL_APPS, needs `HOME_KEY_SERVICE=1`; Chromecast kept |
| `xiaomi-mitv-ansp0/` | Xiaomi MiTV-ANSP0 (小米电视5 Pro 65", jobs, Amlogic), China firmware 23.6.5.3226, 4 GB RAM | Android TV 9 (CN build) | Second CN-firmware Xiaomi, no Google apps: Mi analytics/push/cloud control, ad web container, shop plugin, promo reels, TV Manager, game SDK, preloaded apps, office-mode second home and voice off; updater kept; **keep PatchWall enabled** (disabling it leaves FallbackHome's black screen), set the new launcher as preferred home instead; inputs switch only with the vendor's `EXTSRC_PLAY` extra; ADB closes on every reboot; [more notes](../docs/devices/xiaomi-mitv-ansp0-jobs.txt) |
| `xiaomi-mitv-astp0/` | Xiaomi MiTV-ASTP0 (mulan, sold as L55M7-EA), China firmware 22.12.2.1630, 1.5 GB RAM | Android TV 9 (CN build) | Sibling of ASTP1: Mi analytics/push/cloud control, shop plugin, TV Manager, the Chinese wake word (~30% CPU) and the phone-remote relay that loops at 100-190% CPU off; casting except AirPlay, payment, voice and Mi Video off by choice; keep `com.mitv.tvhome` (Home falls to FallbackHome without it); inputs switch only with Xiaomi's `EXTSRC_PLAY`; time zone ships as Asia/Shanghai |
@@ -216,7 +215,7 @@ on that firmware, grouped and commented. These are starting points: comment out
| `xiaomi-mitv-mssp2/` | Xiaomi MiTV-MSSP2 (volver, MediaTek), firmware PI.4621, low-RAM | Android TV 9 | PatchWall, Mi analytics, TV Manager, partner auto-installs, Google feedback/bug reports, old leanback home still installed; hotkeys, phone remote, Media Player, updater and Chromecast kept; empty Live TV/HDMI screenshots |
| `xiaomi-tv-a-pro-2026/` | Xiaomi TV A Pro 75" 2026 (MiTV-MZTU0, river, MediaTek) | Google TV 14 | PatchWall/Mi Home tab, Mi analytics, TV Manager, updaters; setup wizard off, launcherx crash-loop notes; mediashell kept for Stremio playback |
| `xiaomi-mitv-afmu0/` | Xiaomi TV Box S 3rd gen (MiTV-AFMU0, twilight, Amlogic), streaming box | Google TV 14 | Mi analytics, PatchWall/Mi Home tab, Mi connect/SmartShare; voice and phone remote off by choice; setup wizard off so launcherx can go |
-| `xiaomi-mitv-afmu1/` | Xiaomi TV Stick 4K 2nd gen (MiTV-AFMU1, twilight, adastra, Amlogic), streaming stick | Google TV 14 | Mi analytics, PatchWall/Mi Home tab, Amlogic auto-installs, preloaded apps off; voice, phone remote and Miracast kept; setup wizard off (re-join Wi-Fi first) so launcherx can go |
+| `xiaomi-mitv-afmu1/` | Xiaomi TV Stick 4K 2nd gen (MiTV-AFMU1, twilight, adastra, Amlogic), streaming stick | Google TV 14 | Two units on the same build (UKG3.250826.001), one list: Mi analytics, PatchWall/Mi Home tab, Amlogic auto-installs, preloaded apps off; voice, phone remote and Miracast kept on one unit and off on the other; setup wizard off (re-join Wi-Fi first) so launcherx can go; the second unit also took the Privacy Sandbox ad services and the firmware updater (com.xiaomi.mitv.updateservice DISABLED, so no firmware updates); provisional, one day each |
| `xiaomi-mitv-ayfr0/` | Xiaomi TV Stick 4K (MiTV-AYFR0, soul, Amlogic), streaming stick | Android TV 14 | Mi analytics, PatchWall, auto-installs (`mibox3` + `soc.amlogic`), update service; `setupwraith` does not claim HOME (kept enabled, Wi-Fi stays intact); remote Home key and CEC One Touch Play verified |
Notes for models that have no tested list yet live in [`docs/devices/`](../docs/devices/):
diff --git a/examples/xiaomi-mi-tv-stick-4k-gen2/debloat.txt b/examples/xiaomi-mi-tv-stick-4k-gen2/debloat.txt
deleted file mode 100644
index 3353ee22c..000000000
--- a/examples/xiaomi-mi-tv-stick-4k-gen2/debloat.txt
+++ /dev/null
@@ -1,68 +0,0 @@
-# Xiaomi Mi TV Stick 4K (2nd gen) (MiTV-AFMU1, codename adastra, device twilight), Android TV 14 (Google TV),
-# SDK 34, firmware UKG3.250826.001.V816.0.7.0.UZFAATK. 1.9 GB RAM, /system is full (100%), so nothing frees there.
-#
-# Apply: TV_HOST=<tv ip> tools/disable.sh examples/xiaomi-mi-tv-stick-4k-gen2/debloat.txt
-# Undo: TV_HOST=<tv ip> tools/restore.sh examples/xiaomi-mi-tv-stick-4k-gen2/debloat.txt
-# Everything is DISABLED, not uninstalled. Comment out any line you want to keep.
-#
-# Tested for one day, in batches with screenshots between them, then a reboot. Treat this as provisional
-# until it has been used for a few days (CONTRIBUTING.md).
-#
-# Already disabled by the firmware before any change (not listed): Netflix, Prime Video, Mi channels
-# (michannel, atv), Google calendar sync, partner setup, Talkback, Health Connect controller.
-# Removed for user 0 by the firmware after the first reboot (not listed): YouTube Music and Mi Plus.
-#
-# Notes from this stick:
-# - Stock launcher com.google.android.apps.tv.launcherx must go, but disabling it alone makes Home resolve to
-# setupwraith's RecoveryActivity. Disable setupwraith in the same list, after checking
-# `dumpsys wifi | grep -o 'cname=[^ ]*'`: here the saved network belonged to android.uid.system, so it
-# stayed on Wi-Fi. If it belongs to setupwraith, forget and re-join the network first.
-# - build-and-install.ps1 disables launcherx after the new launcher takes Home; run this list after that.
-# - Mi TV Stick 4K gen 2 with the cleanyourtv launcher: install with launcher/build-and-install.ps1 -TvHost <ip>.
-# - Wireless debugging (port 41817, TLS) is not supported by tools/tv.py; use USB debugging on port 5555.
-# - Network debugging was off after a reboot here (observed once); re-enable it before running the tools.
-# - Keeping on purpose: Google Play Store, Play Services, TV input and remote services, Bluetooth, Droidlogic.
-#
-# Kept by choice, re-enable if you want them:
-# - com.google.android.youtube.tv: NOT disabled by this list. The YouTube app stays enabled.
-# - com.google.android.apps.mediashell (Chromecast), com.google.android.katniss (Google Assistant voice),
-# com.google.android.apps.tv.dreamx (Google ambient screensaver, replaced by the launcher clock screensaver).
-# - com.xiaomi.mitv.updateservice: DISABLED by this list. The TV will not offer firmware updates.
-# Re-enable it (pm enable --user 0 com.xiaomi.mitv.updateservice) to check for updates.
-# - Casting (smartshare, wfdsinkhelperservice, mi_connect_service) is off here. Phone casting was not tested.
-
-# Xiaomi and Google telemetry
-com.miui.tv.analytics
-com.xiaomi.statistic
-com.xiaomi.tvqs.overseas.y24 # quality-stats uploader and quick panel
-com.google.android.feedback
-com.android.tv.feedbackconsent
-
-# Ad personalisation (Privacy Sandbox and on-device ad services)
-com.android.adservices.api
-com.android.ondevicepersonalization.services
-com.android.federatedcompute.services
-
-# Content rows, promos and auto-installs
-com.mitv.tvhome.oemtab
-com.xm.webcontent # Xiaomi promo web pages
-android.autoinstalls.config.soc.amlogic # Amlogic partner auto-installs
-
-# Preloaded apps and services not needed on a stick
-com.google.android.play.games
-com.google.android.apps.mediashell # Chromecast built-in (see note above)
-com.google.android.katniss # Google Assistant voice search (see note above)
-com.google.android.apps.tv.dreamx # Google ambient screensaver (see note above)
-com.netflix.tokenmanager # Netflix sign-in token, Netflix itself is already off
-com.android.printspooler # printing
-com.android.providers.contacts # contacts, nothing on a TV uses it
-com.android.health.connect.backuprestore
-com.xiaomi.mitv.smartshare # Xiaomi screen share
-com.xiaomi.wfdsinkhelperservice # Miracast sink helper
-com.xiaomi.mi_connect_service # Mi Connect
-com.mitv.videoplayer # Mi video player
-com.xiaomi.mitv.updateservice # DISABLED: firmware updates are not offered (see note above)
-
-# Stock launcher and setup wizard, replaced by launcher/ (see notes above)
-com.google.android.apps.tv.launcherx
-com.google.android.tungsten.setupwraith
diff --git a/examples/xiaomi-mitv-afmu1/debloat.txt b/examples/xiaomi-mitv-afmu1/debloat.txt
index 5090117d5..622048620 100644
--- a/examples/xiaomi-mitv-afmu1/debloat.txt
+++ b/examples/xiaomi-mitv-afmu1/debloat.txt
@@ -1,69 +1,86 @@
# Xiaomi TV Stick 4K 2nd gen (MiTV-AFMU1, codename twilight, product adastra, Amlogic), Google TV 14 (SDK 34),
-# firmware UKG3.250826.001 / V816.0.7.0.UZFAATK.
+# firmware UKG3.250826.001 / V816.0.7.0.UZFAATK. 1.9 GB RAM; /system is full (100%), so nothing frees there.
# Fingerprint: Xiaomi/adastra/twilight:14/UKG3.250826.001/V816.0.7.0.UZFAATK:user/release-keys
#
+# One list from two owners (#740 and #749) who reported the same stick: same board, product and firmware.
+# Everything below was disabled on at least one of those units; where only one disabled it, or where the two
+# chose differently, the line says so. Both ran it for a day, in batches with a reboot in between, so treat
+# the package set as provisional (CONTRIBUTING.md) until it has been used for a few days.
+#
# Apply: TV_HOST=<stick ip> tools/disable.sh examples/xiaomi-mitv-afmu1/debloat.txt
# Undo: TV_HOST=<stick ip> tools/restore.sh examples/xiaomi-mitv-afmu1/debloat.txt com.google.android.apps.tv.launcherx
# Everything is DISABLED, not uninstalled. Comment out any line you want to keep.
#
# A streaming stick: no HDMI-in or tuner, so leave live_tv_package empty in config.xml.
-# Stock launcher: com.google.android.apps.tv.launcherx (disabled by launcher/build-and-install.sh).
+# Stock launcher: com.google.android.apps.tv.launcherx (build-and-install.sh disables it after Home moves).
#
-# Notes from this stick:
-# - Shares the twilight board with Xiaomi TV Box S 3rd gen (MiTV-AFMU0), but product is adastra
-# and Xiaomi's local media apps (mimusic2, mediaexplorer, mitv.gallery) are not installed.
-# - setupwraith's RecoveryActivity (HOME priority 1, launcherx priority 2) takes Home once
-# launcherx is off, so setupwraith has to go too, and it has to go FIRST. Re-enable setupwraith
-# if you need to re-pair the remote.
-# - Disabling setupwraith takes the stick off Wi-Fi if the network was saved during first setup:
-# that network belongs to setupwraith, and Android deletes it with the app.
-# On the stick, forget the network and join it again in Settings > Network & Internet first.
-# The re-joined network belongs to android.uid.system and survives disabling launcherx and setupwraith.
+# Notes from these sticks:
+# - Shares the twilight board with the Xiaomi TV Box S 3rd gen (MiTV-AFMU0), but the product is adastra and
+# Xiaomi's local media apps (mimusic2, mediaexplorer, mitv.gallery) are not installed.
+# - setupwraith's RecoveryActivity (HOME priority 1, launcherx priority 2) takes Home once launcherx is off,
+# so setupwraith has to go too, and it has to go FIRST. Re-enable setupwraith to re-pair the remote.
+# - Disabling setupwraith takes the stick off Wi-Fi if the network was saved during first setup: that network
+# belongs to setupwraith, and Android deletes it with the app. Forget the network and join it again in
+# Settings > Network & Internet first; the re-joined network belongs to android.uid.system and survives
+# disabling launcherx and setupwraith.
# Check before disabling: tools/tv.py "dumpsys wifi" | grep -o 'cname=[^ ]*'
-# - Kept on purpose: Google Assistant (katniss), phone remote (tv.remote.service),
-# Miracast / Mi Share (smartshare, wfdsinkhelperservice, mi_connect_service),
-# YouTube, Google Ambient screensaver (dreamx).
-# - Leave alone: com.xiaomi.android.tvsetup.partnercustomizer, mitv.service, com.droidlogic*.
+# - Already disabled by the firmware before any change (not listed): Netflix, Prime Video, Mi channels
+# (michannel, atv), Google calendar sync, partner setup, Talkback, Health Connect controller.
+# Removed for user 0 by the firmware after the first reboot (not listed): YouTube Music and Mi Plus.
+# - Wireless debugging (port 41817, TLS) is not supported by tools/tv.py; use USB debugging on port 5555.
+# Network debugging was off after a reboot on one unit (seen once); re-enable it before running the tools.
+# - Keeping on purpose: Google Play Store, Play Services, TV input and remote services, Bluetooth, Droidlogic.
+# - Leave alone: com.xiaomi.android.tvsetup.partnercustomizer, mitv.service, com.droidlogic*, and the YouTube
+# app (com.google.android.youtube.tv stays enabled on both units).
+#
+# Kept by choice - the two units disagreed here. One kept all of these, the other disabled them and saw no
+# problem; uncomment the ones you are happy to lose. The Assistant line costs voice search, and the four after
+# it cost casting (Chromecast, Miracast and Mi Connect; phone casting was not tested on the second unit).
+# com.google.android.katniss # Google Assistant voice search
+# com.google.android.apps.mediashell # Chromecast built-in
+# com.xiaomi.mitv.smartshare # Xiaomi screen share
+# com.xiaomi.wfdsinkhelperservice # Miracast sink helper
+# com.xiaomi.mi_connect_service # Mi Connect
+# com.google.android.tv.remote.service # phone remote
+# com.google.android.apps.tv.dreamx # Google ambient screensaver (switch to the Clock dream first)
+#
+# Streaming apps, kept enabled: uncomment the ones you never use (Netflix and Prime Video are already off at
+# the firmware level on this build).
+# com.netflix.ninja
+# com.google.android.youtube.tv # stays enabled on both units
+# com.amazon.amazonvideo.livingroom
# Telemetry and feedback
com.miui.tv.analytics
com.xiaomi.statistic
-com.xiaomi.tvqs.overseas.y24 # Xiaomi quality-stats uploader
+com.xiaomi.tvqs.overseas.y24 # Xiaomi quality-stats uploader and quick panel
com.google.android.feedback
com.android.tv.feedbackconsent
+# Ad personalisation (Privacy Sandbox and on-device ad services): one unit only
+com.android.adservices.api
+com.android.ondevicepersonalization.services
+com.android.federatedcompute.services
+
# PatchWall, content rows, promos, auto-installs
-com.mitv.tvhome.atv
-com.mitv.tvhome.michannel
-com.mitv.tvhome.mitvplus
+com.mitv.tvhome.atv # one unit only; already off at the firmware level on the other
+com.mitv.tvhome.michannel # one unit only; already off at the firmware level on the other
+com.mitv.tvhome.mitvplus # one unit only
com.mitv.tvhome.oemtab
-com.xm.webcontent
-android.autoinstalls.config.soc.amlogic
+com.xm.webcontent # Xiaomi promo web pages
+android.autoinstalls.config.soc.amlogic # Amlogic partner auto-installs
-# Personal choice: voice assistant, phone remote, Mi cast/share (uncomment to disable; the mic button stops working)
-# com.google.android.katniss
-# com.google.android.tv.remote.service
-# com.xiaomi.mitv.smartshare
-# com.xiaomi.wfdsinkhelperservice
-# com.xiaomi.mi_connect_service
-
-# Preloaded apps
-com.google.android.youtube.tvmusic
+# Preloaded apps and services not needed on a stick
+com.google.android.youtube.tvmusic # one unit only; the firmware removed it for user 0 after the first reboot
com.google.android.play.games
-com.google.android.marvin.talkback
-com.mitv.videoplayer
-com.android.printspooler
-
-# Personal choice: preloaded streaming apps, kept enabled here. Uncomment the ones you don't use
-# com.netflix.ninja # Netflix
-# com.google.android.youtube.tv # YouTube
-# com.amazon.amazonvideo.livingroom # Prime Video
+com.google.android.marvin.talkback # one unit only; already off at the firmware level on the other
+com.mitv.videoplayer # Mi video player
+com.android.printspooler # printing
+com.netflix.tokenmanager # Netflix sign-in token, Netflix itself is already off
+com.android.providers.contacts # contacts, nothing on a TV uses it
+com.android.health.connect.backuprestore
+com.xiaomi.mitv.updateservice # DISABLED: no firmware updates offered; pm enable it to check again
-# Optional, uncomment if unused
-# com.google.android.apps.tv.dreamx # Google ambient screensaver (switch to the Clock dream first)
-
-# Setup wizard, takes Home after the stock launcher is disabled
+# Stock launcher and setup wizard, replaced by launcher/ (see notes above)
+com.google.android.apps.tv.launcherx # build-and-install.sh also disables it, after Home has moved
com.google.android.tungsten.setupwraith
-
-# Stock Google TV launcher, replaced by launcher/ (build-and-install.sh disables it after Home moves)
-# com.google.android.apps.tv.launcherx
\ No newline at end of file
diff --git a/tests/test_afmu1_single_list.py b/tests/test_afmu1_single_list.py
new file mode 100644
index 000000000..0e0cef766
--- /dev/null
+++ b/tests/test_afmu1_single_list.py
@@ -0,0 +1,208 @@
+"""The MiTV-AFMU1 stick had two lists; this pins the one that is left (#740, #749, issue #855).
+
+Both PRs were merged for the same stick - same board, product and firmware - so the two folders were
+folded into `examples/xiaomi-mitv-afmu1/`. Consolidating by hand is easy to get wrong in a quiet way:
+a package can disappear, or a fact that only one of the two owners recorded can go with it, and nothing
+in the repo would notice. These tests compare the merged list against the two reports it came from, so
+the merge is either exact or it fails here.
+
+Run from the repository root: python3 -m unittest discover -s tests -v
+"""
+import re
+from pathlib import Path
+import unittest
+
+
+ROOT = Path(__file__).resolve().parents[1]
+MERGED = ROOT / "examples" / "xiaomi-mitv-afmu1" / "debloat.txt"
+GONE = "xiaomi-mi-tv-stick-4k-gen2"
+PACKAGE = re.compile(r"^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z0-9_]+)+$")
+
+# The packages each report disabled, as they stood on main before the merge.
+UNIT_A = """
+com.miui.tv.analytics
+com.xiaomi.statistic
+com.xiaomi.tvqs.overseas.y24
+com.google.android.feedback
+com.android.tv.feedbackconsent
+com.mitv.tvhome.atv
+com.mitv.tvhome.michannel
+com.mitv.tvhome.mitvplus
+com.mitv.tvhome.oemtab
+com.xm.webcontent
+android.autoinstalls.config.soc.amlogic
+com.google.android.youtube.tvmusic
+com.google.android.play.games
+com.google.android.marvin.talkback
+com.mitv.videoplayer
+com.android.printspooler
+com.google.android.tungsten.setupwraith
+"""
+
+# The packages the first unit left enabled and commented out (personal choice, plus the stock launcher,
+# which build-and-install.sh disables itself).
+UNIT_A_KEPT = """
+com.google.android.katniss
+com.google.android.tv.remote.service
+com.xiaomi.mitv.smartshare
+com.xiaomi.wfdsinkhelperservice
+com.xiaomi.mi_connect_service
+com.google.android.apps.tv.dreamx
+com.google.android.apps.tv.launcherx
+com.netflix.ninja
+com.google.android.youtube.tv
+com.amazon.amazonvideo.livingroom
+"""
+
+UNIT_B = """
+com.miui.tv.analytics
+com.xiaomi.statistic
+com.xiaomi.tvqs.overseas.y24
+com.google.android.feedback
+com.android.tv.feedbackconsent
+com.android.adservices.api
+com.android.ondevicepersonalization.services
+com.android.federatedcompute.services
+com.mitv.tvhome.oemtab
+com.xm.webcontent
+android.autoinstalls.config.soc.amlogic
+com.google.android.play.games
+com.google.android.apps.mediashell
+com.google.android.katniss
+com.google.android.apps.tv.dreamx
+com.netflix.tokenmanager
+com.android.printspooler
+com.android.providers.contacts
+com.android.health.connect.backuprestore
+com.xiaomi.mitv.smartshare
+com.xiaomi.wfdsinkhelperservice
+com.xiaomi.mi_connect_service
+com.mitv.videoplayer
+com.xiaomi.mitv.updateservice
+com.google.android.apps.tv.launcherx
+com.google.android.tungsten.setupwraith
+"""
+
+SOURCES = {"#740": UNIT_A, "#749": UNIT_B, "#740 kept by choice": UNIT_A_KEPT}
+
+
+def packages(text):
+ """Package names a list actually disables: the whole line, not the trailing comment."""
+ found = set()
+ for line in text.splitlines():
+ body = line.split("#", 1)[0].strip()
+ if PACKAGE.match(body):
+ found.add(body)
+ return found
+
+
+def mentioned(text):
+ """Package names a list mentions anywhere, including the ones commented out as kept."""
+ found = set()
+ for line in text.splitlines():
+ body = line.lstrip("#").split("#", 1)[0].strip()
+ if PACKAGE.match(body):
+ found.add(body)
+ return found
+
+
+def missing(merged, sources):
+ return {name: sorted(packages(text) - mentioned(merged)) for name, text in sources.items()}
+
+
+def invented(merged, sources):
+ known = set().union(*(packages(text) for text in sources.values()))
+ return sorted(mentioned(merged) - known)
+
+
+class MergedListTest(unittest.TestCase):
+ def merged(self):
+ return MERGED.read_text(encoding="utf-8")
+
+ def test_the_second_folder_is_gone(self):
+ self.assertFalse((ROOT / "examples" / GONE).exists(),
+ f"examples/{GONE} is the duplicate the merge was meant to remove")
+
+ def test_nothing_still_points_at_the_removed_folder(self):
+ offenders = []
+ for path in ROOT.rglob("*"):
+ if not path.is_file() or ".git" in path.parts:
+ continue
+ # This file names the folder on purpose, in GONE.
+ if path == Path(__file__):
+ continue
+ try:
+ text = path.read_text(encoding="utf-8")
+ except (UnicodeDecodeError, OSError):
+ continue
+ if GONE in text:
+ offenders.append(str(path.relative_to(ROOT)))
+ self.assertEqual(offenders, [], "these still reference the removed folder")
+
+ def test_no_package_from_either_report_was_dropped(self):
+ dropped = missing(self.merged(), SOURCES)
+ self.assertEqual({k: v for k, v in dropped.items() if v}, {},
+ "packages the merge lost")
+
+ def test_the_merged_list_invents_nothing(self):
+ self.assertEqual(invented(self.merged(), SOURCES), [])
+
+ def test_both_reports_are_named_and_their_facts_survive(self):
+ text = self.merged()
+ # One fact per line, each recorded by only one of the two reports, so a merge that dropped
+ # either folder's header is visible here and not just in the package list.
+ for fact in (
+ "#740 and #749", # both reports named
+ "Fingerprint: Xiaomi/adastra/twilight", # #740 only
+ "cname=", # #740: the Wi-Fi ownership check
+ "RecoveryActivity (HOME priority 1", # #740: why setupwraith goes first
+ "live_tv_package empty", # #740: no tuner on a stick
+ "/system is full", # #749 only
+ "port 41817", # #749: wireless debugging unsupported
+ "com.xiaomi.mitv.updateservice", # #749: no firmware updates
+ "health.connect.backuprestore", # #749 only
+ ):
+ with self.subTest(fact=fact):
+ self.assertIn(fact, text)
+
+ def test_the_two_units_disagreements_are_still_readable(self):
+ text = self.merged()
+ self.assertIn("disagreed", text, "the kept/did-not-keep choices need saying, not a silent pick")
+ for choice in ("com.google.android.katniss", "com.google.android.apps.mediashell",
+ "com.google.android.tv.remote.service", "com.google.android.apps.tv.dreamx"):
+ with self.subTest(package=choice):
+ self.assertNotIn(choice, packages(text),
+ "a package only one unit was happy to lose must stay a choice")
+
+
+class CheckerTest(unittest.TestCase):
+ """The comparison above only means something if it can fail."""
+
+ def test_a_commented_line_is_kept_out_of_the_package_list(self):
+ text = "# My TV\ncom.example.one\n# com.example.kept # uncomment to disable\ncom.example.two\n"
+ self.assertEqual(packages(text), {"com.example.one", "com.example.two"})
+ self.assertEqual(mentioned(text), {"com.example.one", "com.example.two", "com.example.kept"})
+
+ def test_prose_is_not_a_package(self):
+ text = ("# - Check before disabling: tools/tv.py \"dumpsys wifi\" | grep -o 'cname=[^ ]*'\n"
+ "# Xiaomi/adastra/twilight:14/UKG3.250826.001/V816.0.7.0.UZFAATK:user/release-keys\n"
+ "# 1.9 GB RAM; /system is full (100%)\n")
+ self.assertEqual(mentioned(text), set())
+
+ def test_a_dropped_package_is_reported(self):
+ source = {"a": "com.example.one\ncom.example.two\n"}
+ self.assertEqual(missing("com.example.one\n", source), {"a": ["com.example.two"]})
+ self.assertEqual(missing("com.example.one\ncom.example.two\n", source), {"a": []})
+
+ def test_a_package_kept_as_a_comment_still_counts_as_mentioned(self):
+ # The merged file comments out what one unit kept on purpose; that is a mention, not a loss.
+ self.assertEqual(missing("com.example.one\n# com.example.two\n", {"a": "com.example.one\ncom.example.two\n"}), {"a": []})
+
+ def test_an_invented_package_is_reported(self):
+ self.assertEqual(invented("com.example.one\ncom.example.extra\n", {"a": "com.example.one\n"}),
+ ["com.example.extra"])
+ self.assertEqual(invented("com.example.one\n", {"a": "com.example.one\n"}), [])
+
+
+if __name__ == "__main__":
+ unittest.main()