Skip to content

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

docs: the AXFU0 note's config.xml block names the Inputs pill key

xbsheng32ef6f1966c2
diff --git a/docs/devices/xiaomi-mitv-axfu0.md b/docs/devices/xiaomi-mitv-axfu0.md
index e611ce1c6..c03ed93e6 100644
--- a/docs/devices/xiaomi-mitv-axfu0.md
+++ b/docs/devices/xiaomi-mitv-axfu0.md
@@ -76,7 +76,7 @@ On this Amlogic platform, native terrestrial/cable television (DVB-T/T2/C) and e
In `config.xml`, configure the live TV app and channel inputs as:
```xml
<string name="live_tv_package">com.mitv.livetv</string>
-<bool name="show_inputs">true</bool>
+<bool name="show_inputs_pill">true</bool>
```
Keeping `com.droidlogic.tvinput` enabled ensures instant HDMI switching and hardware signal decoding without overhead.
diff --git a/tests/test_example_config_keys.py b/tests/test_example_config_keys.py
index 3a5d3a79f..cee57d0f0 100644
--- a/tests/test_example_config_keys.py
+++ b/tests/test_example_config_keys.py
@@ -12,6 +12,14 @@ The check reads every snake_case name on a line of an examples/ .txt or .md file
config.xml, and asks that it be a resource name in config.xml. examples/README.md is left out: its
table is generated from each folder's tv.json by tools/gen_tables.py.
+A docs/ page shows the setting as the block the owner pastes, so its snippet is read as XML rather
+than guessed from prose: `<bool name="...">` is unambiguous, and every tag config.xml declares its
+resources with is asked for by name. docs/devices/xiaomi-mitv-axfu0.md told an owner to set
+`show_inputs` for the Inputs pill, a key config.xml carried until e6b11e0f replaced it with
+`show_inputs_pill`: pasting that block built a launcher that behaved as before, with nothing saying
+which line had been ignored. A vendor snippet such as skyworth-7t861-a23.md's `<home name="modelhome">`
+is a home-filter rule, not a launcher key, so only the tags config.xml itself uses are read.
+
Run from the repository root: python3 -m unittest discover -s tests -v
"""
import re
@@ -55,6 +63,28 @@ def pages():
if path.is_file() and path.suffix in (".txt", ".md") and path != GENERATED)
+DOCS = ROOT / "docs"
+# <bool name="show_inputs_pill">, <string-array name="app_keys">: the tags config.xml declares its
+# resources with, and the name after each.
+RESOURCE_TAG = re.compile(r'<([a-z]+(?:-array)?)\s+name="([a-z][a-z0-9_]*)"')
+
+
+def resource_tags(config_text):
+ """The resource tags config.xml declares its keys with, comments aside."""
+ return {tag for tag, _ in RESOURCE_TAG.findall(XML_COMMENT.sub("", config_text))}
+
+
+def snippet_keys(text, tags):
+ """(line number, name) for each resource snippet a docs page shows with a tag config.xml uses.
+
+ Line numbers stay the page's own: an XML comment is blanked line for line instead of deleted, so
+ a snippet below a commented block still reports where it sits in the file.
+ """
+ blanked = XML_COMMENT.sub(lambda match: "\n" * match.group(0).count("\n"), text)
+ return [(blanked[:match.start()].count("\n") + 1, match.group(2))
+ for match in RESOURCE_TAG.finditer(blanked) if match.group(1) in tags]
+
+
class ExampleConfigKeysTest(unittest.TestCase):
def test_every_named_config_key_exists(self):
names = resource_names(CONFIG_XML.read_text(encoding="utf-8"))
@@ -72,6 +102,33 @@ class ExampleConfigKeysTest(unittest.TestCase):
self.assertGreaterEqual(read, 30, "far fewer config.xml keys named in examples/ than before")
+class DocsConfigKeysTest(unittest.TestCase):
+ def test_every_config_snippet_names_a_key_config_xml_defines(self):
+ config = CONFIG_XML.read_text(encoding="utf-8")
+ names = resource_names(config)
+ tags = resource_tags(config)
+ # Both halves read something before they are trusted: a vendor <home> rule is not a key, so
+ # its tag must not be one config.xml declares its resources with.
+ self.assertIn("show_inputs_pill", names, "config.xml could not be read")
+ self.assertTrue({"bool", "string"} <= tags, "config.xml's resource tags could not be read")
+ self.assertNotIn("home", tags, "config.xml does not declare resources with <home>")
+
+ pages_read = keys_read = 0
+ for page in sorted(DOCS.rglob("*.md")):
+ pages_read += 1
+ relative = page.relative_to(ROOT).as_posix()
+ for number, name in snippet_keys(page.read_text(encoding="utf-8"), tags):
+ keys_read += 1
+ if name not in names:
+ with self.subTest(line=f"{relative}:{number}", key=name):
+ self.fail(f"{relative}:{number} shows `{name}` as a config.xml key, and config.xml "
+ f"has no such key: an owner who pastes the block builds a launcher that "
+ f"behaves as before, with nothing saying the line was ignored")
+ # A sweep that read nothing would pass for any page.
+ self.assertGreaterEqual(pages_read, 120, "far fewer docs/ pages read than before")
+ self.assertGreaterEqual(keys_read, 20, "far fewer config.xml snippets in docs/ than before")
+
+
class ReaderTest(unittest.TestCase):
"""The readers above, against text written here."""
@@ -111,5 +168,42 @@ class ReaderTest(unittest.TestCase):
self.assertEqual(named_keys(line), [(1, "settings_component")])
+class SnippetReaderTest(unittest.TestCase):
+ """The docs/ readers, against text written here."""
+
+ TAGS = {"bool", "string", "string-array", "integer", "integer-array"}
+
+ def test_a_snippet_is_read_with_its_line(self):
+ text = "In `config.xml`:\n```xml\n<bool name=\"tile_menu\">true</bool>\n```\n"
+ self.assertEqual(snippet_keys(text, self.TAGS), [(3, "tile_menu")])
+
+ def test_a_key_config_xml_no_longer_has_is_still_read(self):
+ # The axfu0 shape: a key that existed once, renamed in e6b11e0f.
+ self.assertEqual(snippet_keys('<bool name="show_inputs">true</bool>\n', self.TAGS),
+ [(1, "show_inputs")])
+ self.assertNotIn("show_inputs", resource_names(CONFIG_XML.read_text(encoding="utf-8")))
+
+ def test_a_vendor_tag_is_not_a_launcher_key(self):
+ text = '<home name="modelhome" relation="and" propcomp="persist.service.model.pkg/x">\n'
+ self.assertEqual(snippet_keys(text, self.TAGS), [])
+
+ def test_a_commented_block_is_skipped_and_later_lines_keep_their_numbers(self):
+ text = '<!--\n<bool name="gone">false</bool>\n-->\n<bool name="tile_menu">true</bool>\n'
+ self.assertEqual(snippet_keys(text, self.TAGS), [(4, "tile_menu")])
+
+ def test_attributes_and_indentation_do_not_hide_a_key(self):
+ text = ' <string name="live_tv_package" translatable="false">com.mitv.livetv</string>\n'
+ self.assertEqual(snippet_keys(text, self.TAGS), [(1, "live_tv_package")])
+
+ def test_a_theme_json_block_is_not_a_config_snippet(self):
+ text = '```json\n{"show_inputs": true, "tile_menu": false}\n```\n'
+ self.assertEqual(snippet_keys(text, self.TAGS), [])
+
+ def test_the_tags_come_from_config_xml_and_leave_vendor_xml_alone(self):
+ tags = resource_tags(CONFIG_XML.read_text(encoding="utf-8"))
+ self.assertTrue({"bool", "string", "string-array", "integer-array"} <= tags)
+ self.assertNotIn("home", tags)
+
+
if __name__ == "__main__":
unittest.main()