Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.
Python adbadblockandroid-tvandroid-tv-launcherapple-tvbloatware-removalclaude-codedebloatfire-tvgoogle-tvlauncherprivacysmart-tvsony-braviatclvibe-codingxiaomi
tests: the shipped-config guards read a list folder's theme/config.json
xbsheng8e947125f476
diff --git a/tests/test_shipped_config_keys_are_read.py b/tests/test_shipped_config_keys_are_read.pyindex 3ab2386a7..2658a92cd 100644--- a/tests/test_shipped_config_keys_are_read.py+++ b/tests/test_shipped_config_keys_are_read.py@@ -16,10 +16,17 @@ ignored.The readers are not copied in here: they come out of Config.java's own calls on the parsed overlay, soa reader that is renamed or dropped fails this test rather than leaving the key it read quietly dead.+The walk goes all the way down examples/, because a list folder may ship a whole theme in a `theme/`+subfolder - `examples/philips-google-tv-ta7/README.md` says to edit `theme/config.json` for the dock,+the greeting and the hidden apps, and to push it with `tools/theme.sh examples/philips-google-tv-ta7/theme`.+Six folders ship one, and a one-level glob read none of them: the same silent drop as above, on the file+a folder's README tells the owner to edit.+Run from the repository root: python3 -m unittest discover -s tests -v"""import jsonimport re+import tempfilefrom pathlib import Pathimport unittest@@ -41,9 +48,10 @@ def overlay_keys(java_text):return set(NAMED_READER.findall(java_text)) | set(LOOKUP.findall(java_text)) | set(FESTIVAL_READER.findall(java_text))-def shipped_configs():- """(path, values) for every config.json a theme or an example folder ships, in path order."""- paths = sorted((ROOT / "themes").glob("*/config.json")) + sorted((ROOT / "examples").glob("*/config.json"))+def shipped_configs(root=None):+ """(path, values) for every config.json a theme or a list folder ships, at any depth, in path order."""+ root = ROOT if root is None else root+ paths = sorted((root / "themes").glob("*/config.json")) + sorted((root / "examples").rglob("config.json"))return [(path, json.loads(path.read_text(encoding="utf-8"))) for path in paths]@@ -69,32 +77,56 @@ def key_rows(text):class ShippedConfigKeysTest(unittest.TestCase):def setUp(self):+ self.root = ROOTself.known = overlay_keys(CONFIG_JAVA.read_text(encoding="utf-8"))- self.configs = shipped_configs()+ self.configs = shipped_configs(self.root)def test_every_shipped_key_is_read_by_the_launcher(self):problems = []for path, values in self.configs:for key in unread(values, self.known):- problems.append(f"{path.relative_to(ROOT)}: {key} is not read from a theme's config.json "+ problems.append(f"{path.relative_to(self.root)}: {key} is not read from a theme's config.json "f"by Config.java, so a push drops it and the launcher keeps its own value")self.assertEqual([], problems)def test_the_readers_and_the_files_were_really_read(self):# A run that read nothing, or half of Config.java, must not pass by finding no problems.self.assertGreaterEqual(len(self.known), 100, f"only {len(self.known)} overlay keys read out of Config.java")- self.assertGreaterEqual(len(self.configs), 60, f"only {len(self.configs)} shipped config.json files")+ self.assertGreaterEqual(len(self.configs), 100, f"only {len(self.configs)} shipped config.json files")keys = {key for _, values in self.configs for key in values}self.assertGreaterEqual(len(keys), 50, f"only {len(keys)} distinct keys in the shipped configs")for expected in ("dock_apps", "hidden_apps", "live_tv_package", "wallpaper_moods"):self.assertIn(expected, self.known)+ def test_a_list_folders_theme_folder_is_read(self):+ # Six list folders ship a whole theme under theme/; a glob of examples/*/config.json reads none.+ self.assertTrue(any(path.parent.name == "theme" for path, _ in self.configs),+ "no list folder's theme/config.json was read: is the walk one level deep again?")+def test_a_config_with_an_unread_key_is_named(self):# The rule, on a file written here: a key nobody reads is reported with its name.self.assertEqual(["settings_fallback_components"],unread({"settings_fallback_components": ["com.example/com.example.Main"],"dock_apps": []}, self.known))+ def test_a_key_in_a_theme_folder_below_a_list_folder_is_reported(self):+ # The shape a list folder ships: examples/acme-1/theme/config.json, beside the folder's own+ # config.json, both of them files the launcher would push and then drop a key out of.+ with tempfile.TemporaryDirectory() as tmp:+ root = Path(tmp)+ for relative, body in (("examples/acme-1/theme/config.json",+ '{"dock_apps": [], "settings_fallback_components": ["com.example/.Main"]}\n'),+ ("examples/acme-2/config.json", '{"dock_apps": []}\n'),+ ("themes/acme/config.json", '{"dock_apps": []}\n')):+ path = root / relative+ path.parent.mkdir(parents=True, exist_ok=True)+ path.write_text(body, encoding="utf-8")+ read = [path.relative_to(root).as_posix() for path, _ in shipped_configs(root)]+ self.assertEqual(read, ["themes/acme/config.json", "examples/acme-1/theme/config.json",+ "examples/acme-2/config.json"])+ named = [key for _, values in shipped_configs(root) for key in unread(values, self.known)]+ self.assertEqual(named, ["settings_fallback_components"])+def test_config_xml_only_keys_are_in_no_shipped_config(self):# The Keys table says which keys a theme cannot set; those are the ones to keep out, and the# reason the reader above matters is that the launcher cannot answer for them itself.diff --git a/tests/test_shipped_config_values.py b/tests/test_shipped_config_values.pyindex d512e2861..23ecf68ae 100644--- a/tests/test_shipped_config_values.py+++ b/tests/test_shipped_config_values.py@@ -22,6 +22,7 @@ Run from the repository root: python3 -m unittest discover -s tests -v"""import jsonimport re+import tempfilefrom pathlib import Pathimport unittest@@ -81,9 +82,16 @@ def problems(values, kinds):return out-def config_files():- """Every config.json a theme or an example ships, sorted."""- return sorted(ROOT.glob("themes/*/config.json")) + sorted(ROOT.glob("examples/*/config.json"))+def config_files(root=None):+ """Every config.json a theme or a list folder ships at any depth, sorted.++ A list folder may ship a whole theme under theme/, and its README tells the owner to edit that+ config.json and push it with tools/theme.sh (examples/philips-google-tv-ta7). Six folders ship+ one; a glob of examples/*/config.json reads none of them, so a value the launcher drops there+ went out without a word, the shape of the 320 above.+ """+ root = ROOT if root is None else root+ return sorted((root / "themes").glob("*/config.json")) + sorted((root / "examples").rglob("config.json"))class ShippedConfigValuesTest(unittest.TestCase):@@ -106,6 +114,8 @@ class ShippedConfigValuesTest(unittest.TestCase):def test_no_shipped_value_is_one_the_launcher_drops(self):files = config_files()self.assertGreaterEqual(len(files), 50, "fewer config.json files found than the tree ships")+ self.assertTrue(any(path.parent.name == "theme" for path in files),+ "no list folder's theme/config.json was read: is the walk one level deep again?")checked = 0for path in files:values = json.loads(path.read_text(encoding="utf-8"))@@ -116,6 +126,24 @@ class ShippedConfigValuesTest(unittest.TestCase):f"built-in value instead, and nothing says so")self.assertGreaterEqual(checked, 150, "the sweep read far fewer values than the tree carries")+ def test_a_value_in_a_theme_folder_below_a_list_folder_is_reported(self):+ # The shape of the 320 above, in the file examples/philips-google-tv-ta7/README.md tells the+ # owner to edit: 42 columns is outside the 1 to 8 the launcher keeps, and a one-level glob+ # never read the file it is in.+ with tempfile.TemporaryDirectory() as tmp:+ root = Path(tmp)+ nested = root / "examples" / "acme-1" / "theme" / "config.json"+ nested.parent.mkdir(parents=True)+ nested.write_text('{"columns": 42, "dock_apps": ["com.example"]}\n', encoding="utf-8")+ top = root / "examples" / "acme-1" / "config.json"+ top.write_text('{"columns": 5}\n', encoding="utf-8")+ files = config_files(root)+ self.assertEqual([path.relative_to(root).as_posix() for path in files],+ ["examples/acme-1/config.json", "examples/acme-1/theme/config.json"])+ reported = dict(problems(json.loads(nested.read_text(encoding="utf-8")), self.kinds))+ self.assertEqual(sorted(reported), ["columns"])+ self.assertIn("outside 1 to 8", reported["columns"])+def test_the_acer_example_keeps_the_network_name_it_documents(self):# The fix for the 320 above is to ask for a width the launcher keeps, not to stop asking: the# folder's README says the Wi-Fi pill shows the network name.