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
tools: require access evidence in the microphone audit
SlivenRed513e1794c276
diff --git a/README.md b/README.mdindex c2693f330..03bb10282 100644--- a/README.md+++ b/README.md@@ -415,7 +415,8 @@ only `INTERNET`.candidates in three groups, each with its evidence — named by the firmware's own`voice_interaction_service`, a known component from [`examples/`](examples/), or nothing but amatching name — plus whether the package declares `RECORD_AUDIO`, whether it shares the system UID,-and whether `appops` shows the microphone op was ever used since boot.+and whether the returned AppOps history contains microphone access. A configured mode or a rejected+attempt alone is not evidence of access.`--write privacy.txt` turns the identified candidates into a normal debloat list, so applying it andundoing it are the commands you already use (`tools/disable.sh`, `tools/restore.sh`). Packages thatdiff --git a/tests/test_privacy_audit.py b/tests/test_privacy_audit.pyindex aa44f80f5..0bd7d15c7 100644--- a/tests/test_privacy_audit.py+++ b/tests/test_privacy_audit.py@@ -16,6 +16,8 @@ import sysimport tempfileimport unittest+from tools import privacy+ROOT = Path(__file__).resolve().parents[1]@@ -116,7 +118,7 @@ class PrivacyAuditTest(unittest.TestCase):},"appops": {"com.google.android.katniss": "No operations.",- "tv.inscape.tvclient.inscapeacr": "RECORD_AUDIO: time=+1m23s ago",+ "tv.inscape.tvclient.inscapeacr": "RECORD_AUDIO: allow; time=+1m23s0ms ago",},"unreachable": False,}@@ -146,10 +148,24 @@ class PrivacyAuditTest(unittest.TestCase):out = self.run_script().stdoutkatniss = out.split("com.google.android.katniss", 1)[1].split("\n\n", 1)[0]self.assertIn("declares RECORD_AUDIO", katniss)- self.assertIn("appops: no RECORD_AUDIO use since boot", katniss)+ self.assertIn("appops: no RECORD_AUDIO history returned", katniss)inscape = out.split("tv.inscape.tvclient.inscapeacr", 1)[1].split("\n\n", 1)[0]- self.assertIn("appops: RECORD_AUDIO was used since boot", inscape)+ self.assertIn("appops: recorded RECORD_AUDIO access", inscape)self.assertNotIn("declares RECORD_AUDIO", inscape)+ self.assertNotIn("since boot", out)++ def test_mode_or_rejection_is_not_reported_as_access(self):+ for answer in ("RECORD_AUDIO: allow",+ "RECORD_AUDIO: ignore; rejectTime=+1m0s0ms ago",+ "RECORD_AUDIO: vendor history unavailable"):+ with self.subTest(answer=answer):+ self.tv(appops={"com.google.android.katniss": answer})+ result = self.run_script()+ self.assertEqual(result.returncode, 0, result.stderr)+ entry = result.stdout.split("com.google.android.katniss", 1)[1].split("\n\n", 1)[0]+ self.assertIn("appops: RECORD_AUDIO access is unknown", entry)+ self.assertNotIn("recorded RECORD_AUDIO access", entry)+ self.assertNotIn("was used", entry)def test_acr_is_kept_apart_from_the_microphone(self):out = self.run_script().stdout@@ -250,6 +266,40 @@ class PrivacyAuditTest(unittest.TestCase):self.assertIn("usage: privacy.py", result.stderr)+class AppOpsEvidenceTest(unittest.TestCase):+ # AppOpsService's `get` prints mode unconditionally, but time/rejectTime separately:+ # https://github.com/aosp-mirror/platform_frameworks_base/blob/android-11.0.0_r1/services/core/java/com/android/server/appop/AppOpsService.java#L4765-L4789++ def test_access_time_or_running_is_evidence(self):+ for answer in (+ "RECORD_AUDIO: allow; time=+1m23s0ms ago; duration=+2s0ms",+ "RECORD_AUDIO: allow; time=0 ago",+ "RECORD_AUDIO: allow; time=-5ms ago",+ "RECORD_AUDIO: allow (running)",+ "RECORD_AUDIO: ignore; time=+1h0m0s0ms ago; rejectTime=+1m0s0ms ago",+ "Uid mode: RECORD_AUDIO: allow\nRECORD_AUDIO: allow; time=+1s0ms ago"):+ with self.subTest(answer=answer):+ self.assertIs(privacy.used_microphone(answer), True)++ def test_no_operations_means_no_returned_history(self):+ for answer in ("No operations.", "No operations.\nDefault mode: allow"):+ with self.subTest(answer=answer):+ self.assertIs(privacy.used_microphone(answer), False)++ def test_unsupported_or_non_access_output_is_unknown(self):+ for answer in (+ "", "Error: unknown package", "SecurityException: denied",+ "RECORD_AUDIO: allow", "Uid mode: RECORD_AUDIO: allow",+ "RECORD_AUDIO: ignore; rejectTime=+1m0s0ms ago",+ "RECORD_AUDIO: allow; duration=+1s0ms",+ "RECORD_AUDIO: vendor history unavailable",+ "RECORD_AUDIO: allow; time=unknown ago",+ "CAMERA: allow; time=+1s0ms ago\nRECORD_AUDIO: allow",+ "No operations could be read: unsupported vendor command"):+ with self.subTest(answer=answer):+ self.assertIsNone(privacy.used_microphone(answer))++class CatalogueTest(unittest.TestCase):"""The catalogue is the part a reader trusts; keep it honest and small."""diff --git a/tools/privacy.py b/tools/privacy.pyindex 19b260fb4..58ca9f6f0 100644--- a/tools/privacy.py+++ b/tools/privacy.py@@ -10,7 +10,7 @@ The honest part is the evidence, not the category. On firmware where most packag`android.uid.system`, about fifty of them "have" RECORD_AUDIO and none of them record anything;a per-package permission scan would call all fifty listeners. So this audit says which names thefirmware itself nominated, which ones are known components with a known job, which ones only matched-by name, and which ones actually touched the microphone op since boot (`appops`). It never claims a+by name, and which ones have microphone access in the returned AppOps history. It never claims apackage is listening.Disabling is left to `tools/disable.sh`, so the undo path is the one every list already uses: the@@ -143,7 +143,7 @@ def voice_setting_owners(dev):def probe(dev, name):- """What the package declares about the microphone, and whether it used it since boot."""+ """What the package declares about the microphone, and its returned AppOps history."""dump = shell(dev, f"dumpsys package {name}")uid = Nonedeclared = None@@ -156,12 +156,19 @@ def probe(dev, name):def used_microphone(ops):- """True / False / None (the TV did not answer) from `appops get <pkg> RECORD_AUDIO`."""+ """True for recorded access, False for no history, None for unknown output."""if not ops or "error" in ops.lower() or "exception" in ops.lower():return None- if "no operations" in ops.lower():- return False- return "RECORD_AUDIO" in ops+ lines = [line.strip() for line in ops.splitlines()]+ for line in lines:+ if not line.startswith("RECORD_AUDIO: "):+ continue+ # A mode (including a UID override) or rejectTime is not evidence of access.+ # AppOps prints time only for a recorded access, using TimeUtils.formatDuration.+ if line.endswith(" (running)") or re.search(+ r"; time=(?:0|[+-](?:\d+[dhms])*\d+ms) ago(?:;| \(running\)|$)", line):+ return True+ return False if "No operations." in lines else Nonedef classify(name, owners, probed):@@ -186,10 +193,12 @@ def classify(name, owners, probed):used = used_microphone(probed.get("appops", ""))if used is False:- evidence.append("appops: no RECORD_AUDIO use since boot")+ evidence.append("appops: no RECORD_AUDIO history returned")elif used is True:- evidence.append("appops: RECORD_AUDIO was used since boot, which is the one line worth "- "reading in full (`appops get <package> RECORD_AUDIO`)")+ evidence.append("appops: recorded RECORD_AUDIO access in the returned history "+ "(read in full with `appops get <package> RECORD_AUDIO`)")+ else:+ evidence.append("appops: RECORD_AUDIO access is unknown from this output")return category, note, evidence