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
Safety: restore turns the stock launcher back on only when the record says it was on (#1714)
Gathin23a9e244e5a49e
diff --git a/README.md b/README.mdindex c82573280..5b256d907 100644--- a/README.md+++ b/README.md@@ -780,8 +780,12 @@ yourself stays disabled and Home goes back to the component that owned it:The `stock launcher` argument is only a fallback: with a record, the launcher that actually owned Homeis the one that gets it back, and the argument is used only when nothing answered HOME at the time-or this project's launcher owned it. The stock launcher is enabled again either way, unless it was-already disabled when the record was taken.+or this project's launcher owned it. The record also notes whether the known stock launchers were on,+listed or not, and the stock launcher is enabled again only if it was. One that was already off (from+the factory, or because the install script had disabled it before you applied this list) stays off,+and if this project's launcher owned Home then, Home goes back to it. A record from before this note+was added does not say, so the script leaves that launcher as it is and prints the+`tools/tv.py 'pm enable <package>'` that turns it on.Without a record (an older run, or a record you deleted) the script says so and falls back toenabling the whole list and resetting the scales to `1.0`, which is what it used to do.diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.mdindex 4e226de52..f72d8bdd7 100644--- a/docs/TROUBLESHOOTING.md+++ b/docs/TROUBLESHOOTING.md@@ -313,7 +313,8 @@ Things that bit us or contributors, so they don't bite you. Commands use `tools/`Remove-Item Env:HANDLERS_ALLOW` after those two, or a later `check.py --fix` on your main listskips the guard too. To turn the app back on, use`tools/tv.py 'pm enable --user 0 <package>'`. `tools/restore.sh` with that list turns it back on- as well, but it also turns the stock launcher back on and makes it Home, as it does for any list.+ as well, and leaves Home on this project's launcher: it turns the stock launcher back on and makes+ it Home only if the stock launcher was on when the list was applied (#1714).Report another one rather than reading it as a firmware quirk: the wrong-handler case needsa source change, not a setting.- **`adb exec-out screencap -p` gives a broken PNG** on some MediaTek sets (Xiaomi, and Amazon'sdiff --git a/tests/test_recovery_home_chooser.py b/tests/test_recovery_home_chooser.pyindex 4dec8f01f..7a173534a 100644--- a/tests/test_recovery_home_chooser.py+++ b/tests/test_recovery_home_chooser.py@@ -50,10 +50,12 @@ class RecoveryHomeChooserTest(unittest.TestCase):record = self.record()self.assertIsNone(record["home"])# No "android" entry: it is not a package name, and a record holding it cannot be read back.+ # The installed stock launcher is recorded too, so undo knows it was on (#1714).self.assertEqual(record["packages"], {"com.example.enabled": "enabled","com.example.already_off": "disabled","com.example.absent": "absent",+ STOCK: "enabled",})self.assertIn("Android's chooser", result.stdout)diff --git a/tests/test_recovery_home_not_a_launcher.py b/tests/test_recovery_home_not_a_launcher.pyindex cd0e12f47..fdf4aeaec 100644--- a/tests/test_recovery_home_not_a_launcher.py+++ b/tests/test_recovery_home_not_a_launcher.py@@ -83,8 +83,11 @@ class RecoveryHomeNotALauncherTest(unittest.TestCase):self.assertEqual(result.returncode, 0, result.stderr)record = self.record()self.assertIsNone(record["home"])- # The package keeps its entry: it was enabled before cleanup.- self.assertEqual(record["packages"], {**LIST_STATES, home.split("/", 1)[0]: "enabled"})+ # The package keeps its entry: it was enabled before cleanup. So do the two stock+ # launchers installed here, which undo turns back on only because they were on (#1714).+ self.assertEqual(record["packages"], {**LIST_STATES, home.split("/", 1)[0]: "enabled",+ "com.google.android.tvlauncher": "enabled",+ LAUNCHERX: "enabled"})self.assertIn(f"HOME before: {home}, which is not a launcher", result.stdout)def test_a_launcher_is_still_recorded(self):@@ -99,7 +102,8 @@ class RecoveryHomeNotALauncherTest(unittest.TestCase):def test_restore_after_the_recovery_screen_resolves_the_stock_launcher(self):# The Acer R4G case: launcherx is the stock launcher, and Home goes to what it resolves to,- # never to setupwraith's recovery screen.+ # never to setupwraith's recovery screen. Both stock launchers were on when the record was+ # taken, so both are in it and both come back, in the record's order (#1714).self.tv_on(RECOVERY)self.assertEqual(self.run_script("disable.sh", str(self.list_path)).returncode, 0)self.clear_sent()@@ -107,8 +111,9 @@ class RecoveryHomeNotALauncherTest(unittest.TestCase):self.assertEqual(result.returncode, 0, result.stderr)self.assertEqual(self.sent(), ["pm enable com.example.enabled",- f"pm enable {SETUPWRAITH}",f"pm enable {LAUNCHERX}",+ f"pm enable {SETUPWRAITH}",+ "pm enable com.google.android.tvlauncher","cmd package set-home-activity --user 0 $(cmd package resolve-activity --brief -a "f"android.intent.action.MAIN -c android.intent.category.HOME {LAUNCHERX} | tail -n 1)","settings put global window_animation_scale 0.5",diff --git a/tests/test_recovery_old_chooser_record.py b/tests/test_recovery_old_chooser_record.pyindex c63c29667..78aae4e81 100644--- a/tests/test_recovery_old_chooser_record.py+++ b/tests/test_recovery_old_chooser_record.py@@ -99,12 +99,14 @@ class OldChooserRecordTest(unittest.TestCase):self.assertEqual(result.returncode, 0, result.stderr)record = self.record()self.assertIsNone(record["home"])- # The entries from before cleanup are kept as they were, not the TV as it is now.+ # The entries from before cleanup are kept as they were, not the TV as it is now, including+ # the stock launcher save() recorded alongside the list (#1714).self.assertEqual(record["packages"], {"com.example.enabled": "enabled","com.example.already_off": "disabled","com.example.absent": "absent","com.example.added_later": "enabled",+ STOCK: "enabled",})self.assertEqual(record["created"], first["created"])self.assertEqual(record["settings"], first["settings"])diff --git a/tests/test_restore_stock_launcher.py b/tests/test_restore_stock_launcher.pynew file mode 100644index 000000000..f63c541ac--- /dev/null+++ b/tests/test_restore_stock_launcher.py@@ -0,0 +1,190 @@+"""Undo turns the stock launcher back on only when the record says it was on before cleanup (#1714).++`restore_commands()` sent `pm enable <stock launcher>` whenever the record did not hold that launcher+as disabled, and save() recorded only the list and the package that owned Home. A stock launcher in+neither was missing from the record, so restore turned it on whatever its state had been:++1. examples/verizon-stream-tv leaves tvlauncher out of its list because the factory disabled it, and+ restore.sh turned it on anyway.+2. After launcher/build-and-install.sh made com.gathin.tvhome Home and disabled tvlauncher, undoing a+ second list (privacy.py prints `tools/restore.sh privacy.txt`) turned tvlauncher back on and, as+ the recorded Home was this project's launcher, gave Home to tvlauncher too.++Now save() records the state of every installed stock launcher that build-and-install.sh knows, listed+or not, and restore enables only what the record holds as enabled. When this project's launcher owned+Home and the stock launcher was not on, Home goes back to this project's launcher. A record taken+before this change holds no state for an unlisted stock launcher, so restore leaves it alone and says+how to turn it on by hand.++The cases borrow the fake TV and helpers of tests/test_recovery_record.py. The restore.ps1 case needs+`pwsh` on PATH and skips without it; CI's Ubuntu runner has it.++Run from the repository root: python3 -m unittest discover -s tests -v+"""+import json+import os+from pathlib import Path+import re+import shutil+import subprocess+import sys+import unittest++ROOT = Path(__file__).resolve().parents[1]+sys.path.insert(0, str(ROOT / "tools"))+sys.path.insert(0, str(ROOT / "tests"))+import recovery # noqa: E402+import test_recovery_record as records # noqa: E402++STOCK = "com.google.android.tvlauncher"+CUSTOM_HOME = f"{recovery.CUSTOM_LAUNCHER}/.MainActivity"+VERIZON_HOME = "com.verizon.tv.launcher/.HomeActivity"+PWSH = shutil.which("pwsh")+++def home_commands(sent):+ return [c for c in sent if c.startswith("cmd package set-home-activity")]+++class RestoreStockLauncherTest(unittest.TestCase):+ # Borrowed rather than inherited, so the tests of tests/test_recovery_record.py do not run a+ # second time under this class.+ setUp = records.RecoveryRecordTest.setUp+ write_list = records.RecoveryRecordTest.write_list+ tv = records.RecoveryRecordTest.tv+ run_script = records.RecoveryRecordTest.run_script+ record = records.RecoveryRecordTest.record+ sent = records.RecoveryRecordTest.sent+ clear_sent = records.RecoveryRecordTest.clear_sent++ def disable_then_restore(self, *restore_args, **tv):+ self.write_list(["com.example.ads"])+ self.tv(**tv)+ result = self.run_script("disable.sh", str(self.list_path))+ self.assertEqual(result.returncode, 0, result.stderr)+ self.clear_sent()+ result = self.run_script("restore.sh", str(self.list_path), *restore_args)+ self.assertEqual(result.returncode, 0, result.stderr)+ return result++ def test_a_stock_launcher_the_factory_disabled_stays_off(self):+ # Case 1, examples/verizon-stream-tv: tvlauncher is off from the factory, Verizon's launcher is Home.+ self.disable_then_restore(installed=["com.example.ads", STOCK, "com.verizon.tv.launcher"],+ disabled=[STOCK], home=VERIZON_HOME)+ self.assertEqual(self.record()["packages"][STOCK], "disabled")+ sent = self.sent()+ self.assertNotIn(f"pm enable {STOCK}", sent)+ self.assertEqual(home_commands(sent), [f"cmd package set-home-activity --user 0 {VERIZON_HOME}"])++ def test_undoing_a_second_list_leaves_this_projects_launcher_on_home(self):+ # Case 2: build-and-install.sh made com.gathin.tvhome Home and disabled tvlauncher, then a second+ # list (privacy.txt) was applied and is now undone with no launcher argument.+ result = self.disable_then_restore(+ installed=["com.example.ads", STOCK, recovery.CUSTOM_LAUNCHER], disabled=[STOCK],+ home=CUSTOM_HOME)+ sent = self.sent()+ self.assertNotIn(f"pm enable {STOCK}", sent)+ self.assertIn(f"pm enable {recovery.CUSTOM_LAUNCHER}", sent)+ self.assertEqual(home_commands(sent), [f"cmd package set-home-activity --user 0 {CUSTOM_HOME}"])+ self.assertLess(sent.index(f"pm enable {recovery.CUSTOM_LAUNCHER}"), sent.index(home_commands(sent)[0]))+ self.assertIn(f"{STOCK} was disabled then", re.sub(r"\s+", " ", result.stderr))++ def test_a_stock_launcher_that_was_on_comes_back_and_takes_home(self):+ # What README promises: the stock launcher was on when the record was taken (the install+ # script disabled it afterwards), so undo turns it on and gives it Home, as before.+ self.disable_then_restore(installed=["com.example.ads", STOCK, recovery.CUSTOM_LAUNCHER],+ home=CUSTOM_HOME)+ self.assertEqual(self.record()["packages"][STOCK], "enabled")+ sent = self.sent()+ self.assertEqual(sent.count(f"pm enable {STOCK}"), 1)+ home = home_commands(sent)+ self.assertEqual(len(home), 1, sent)+ self.assertIn(f"resolve-activity --brief -a android.intent.action.MAIN -c "+ f"android.intent.category.HOME {STOCK}", home[0])+ self.assertLess(sent.index(f"pm enable {STOCK}"), sent.index(home[0]))++ def test_only_installed_stock_launchers_are_recorded(self):+ self.disable_then_restore(installed=["com.example.ads", STOCK], home=f"{STOCK}/.MainActivity")+ packages = self.record()["packages"]+ self.assertEqual(packages, {"com.example.ads": "enabled", STOCK: "enabled"})+ self.assertNotIn("com.google.android.apps.tv.launcherx", packages)++ def test_no_home_and_a_stock_launcher_that_was_off_leaves_home_alone(self):+ result = self.disable_then_restore(installed=["com.example.ads", STOCK], disabled=[STOCK],+ home=None)+ sent = self.sent()+ self.assertNotIn(f"pm enable {STOCK}", sent)+ self.assertEqual(home_commands(sent), [])+ self.assertIn("leaving Home alone", result.stderr)++ def old_record_without_the_stock_launcher(self, home):+ """A record taken before save() noted the stock launchers: the list and Home only."""+ self.write_list(["com.example.ads"])+ self.tv(installed=["com.example.ads", STOCK, recovery.CUSTOM_LAUNCHER], disabled=[STOCK],+ home=home)+ self.assertEqual(self.run_script("disable.sh", str(self.list_path)).returncode, 0)+ path = next((self.home / ".cleanyourtv").glob("recovery-*.json"))+ record = json.loads(path.read_text())+ record["packages"].pop(STOCK)+ path.write_text(json.dumps(record, indent=2, sort_keys=True) + "\n")+ self.clear_sent()++ def test_an_old_record_does_not_turn_on_a_stock_launcher_it_does_not_hold(self):+ self.old_record_without_the_stock_launcher(CUSTOM_HOME)+ result = self.run_script("restore.sh", str(self.list_path))+ self.assertEqual(result.returncode, 0, result.stderr)+ sent = self.sent()+ self.assertNotIn(f"pm enable {STOCK}", sent)+ self.assertEqual(home_commands(sent), [f"cmd package set-home-activity --user 0 {CUSTOM_HOME}"])+ said = re.sub(r"\s+", " ", result.stderr)+ self.assertIn(f"{STOCK} was not in the record then", said)+ self.assertIn(f"tools/tv.py 'pm enable {STOCK}'", said)++ def test_an_old_record_with_no_home_still_resolves_the_stock_launcher(self):+ # Nothing says the stock launcher was off, so Home still goes to whatever it resolves to; only+ # the `pm enable` is gone.+ self.old_record_without_the_stock_launcher(None)+ result = self.run_script("restore.sh", str(self.list_path))+ self.assertEqual(result.returncode, 0, result.stderr)+ sent = self.sent()+ self.assertNotIn(f"pm enable {STOCK}", sent)+ home = home_commands(sent)+ self.assertEqual(len(home), 1, sent)+ self.assertIn(f"android.intent.category.HOME {STOCK}", home[0])++ def test_restore_ps1_sends_the_same_batch(self):+ # restore.ps1 hands the same arguments to recovery.py, so case 2 gives the same batch.+ if not PWSH:+ raise unittest.SkipTest("restore.ps1 needs pwsh on PATH")+ tools = self.repo / "tools"+ shutil.copy2(ROOT / "tools" / "restore.ps1", tools / "restore.ps1")+ client = tools / "venv" / "Scripts" / "python.exe"+ client.parent.mkdir(parents=True, exist_ok=True)+ client.write_text(f'#!/bin/sh\nexec "{sys.executable}" "$@"\n')+ client.chmod(0o755)+ self.disable_then_restore(installed=["com.example.ads", STOCK, recovery.CUSTOM_LAUNCHER],+ disabled=[STOCK], home=CUSTOM_HOME)+ expected = self.sent()+ self.clear_sent()+ env = dict(os.environ, TV_HOST="192.168.1.50", HOME=str(self.home),+ FAKE_TV_STATE=str(self.state_path))+ result = subprocess.run([PWSH, "-NoProfile", "-File", str(tools / "restore.ps1"),+ str(self.list_path)], cwd=self.repo, env=env, capture_output=True,+ text=True, timeout=120)+ self.assertEqual(result.returncode, 0, result.stdout + result.stderr)+ self.assertEqual(self.sent(), expected)+ self.assertNotIn(f"pm enable {STOCK}", expected)+++class StockLaunchersInStepTest(unittest.TestCase):+ def test_recovery_knows_the_stock_launchers_build_and_install_knows(self):+ sh = (ROOT / "launcher" / "build-and-install.sh").read_text(encoding="utf-8")+ ps1 = (ROOT / "launcher" / "build-and-install.ps1").read_text(encoding="utf-8")+ sh_known = re.search(r'^KNOWN_STOCK_LAUNCHERS="([^"]+)"', sh, re.M).group(1).split()+ ps1_known = re.findall(r"'([^']+)'", re.search(r"^\$knownStock = @\(([^)]*)\)", ps1, re.M).group(1))+ self.assertEqual(list(recovery.STOCK_LAUNCHERS), sh_known)+ self.assertEqual(list(recovery.STOCK_LAUNCHERS), ps1_known)+++if __name__ == "__main__":+ unittest.main()diff --git a/tests/test_wrong_handler_note.py b/tests/test_wrong_handler_note.pyindex 1f6ca725e..3458a817f 100644--- a/tests/test_wrong_handler_note.py+++ b/tests/test_wrong_handler_note.py@@ -12,8 +12,9 @@ print; the scripts are run here to show that is what they do.Two more things the bullet has to say. `$env:HANDLERS_ALLOW=1` stays set in the PowerShell window,so the next disable.ps1 or check.py --fix on the main list would skip the guard as well; the bulletsays to clear it. And the undo is `pm enable` for that app: the one-app list's record holds this-project's launcher as Home and nothing for the stock launcher, so restore.sh with it turns the stock-launcher back on and makes it Home, as it does for any list; that is run here too.+project's launcher as Home and the stock launcher as disabled (launcher/build-and-install.sh turned it+off before), so restore.sh with it turns the app back on and leaves Home on this project's launcher+(#1714); that is run here too.The doc tests borrow the bullet reader of tests/test_input_intent_note.py, the disable.sh tests thefake client of tests/test_handler_guard.py, the check.py tests the fake TV of@@ -90,7 +91,8 @@ class WrongHandlerNoteTest(unittest.TestCase):def test_the_bullet_says_what_restore_does_to_home(self):# Pinned by WrongHandlerRestoreTest below.self.assertIn("`tools/restore.sh` with that list", self.note)- self.assertIn("turns the stock launcher back on and makes it Home", self.note)+ self.assertIn("leaves Home on this project's launcher", self.note)+ self.assertIn("only if the stock launcher was on when the list was applied", self.note)class WrongHandlerDisableTest(unittest.TestCase):@@ -148,9 +150,11 @@ class WrongHandlerRestoreTest(unittest.TestCase):sent = rec.RecoveryRecordTest.sentclear_sent = rec.RecoveryRecordTest.clear_sent- def test_restoring_the_one_app_list_brings_the_stock_launcher_back_as_home(self):+ def test_restoring_the_one_app_list_leaves_this_projects_launcher_on_home(self):# The main list is applied and launcher/build-and-install.sh has made this project's# launcher Home, disabling the stock launcher outside any list. Then the one-app list goes on.+ # The record notes the stock launcher as disabled, so undo leaves it off and Home where it+ # was (#1714); it used to turn the stock launcher on and hand it Home.custom = "com.gathin.tvhome/.MainActivity"stock = "com.google.android.tvlauncher"self.write_list([ES])@@ -160,18 +164,16 @@ class WrongHandlerRestoreTest(unittest.TestCase):self.assertEqual(result.returncode, 0, result.stderr)self.assertIn(f"pm disable-user --user 0 {ES}", self.sent())self.assertEqual(self.record()["home"], custom)- self.assertNotIn(stock, self.record()["packages"])+ self.assertEqual(self.record()["packages"][stock], "disabled")self.clear_sent()result = self.run_script("restore.sh", str(self.list_path))self.assertEqual(result.returncode, 0, result.stderr)sent = self.sent()self.assertIn(f"pm enable {ES}", sent)- self.assertIn(f"pm enable {stock}", sent)+ self.assertNotIn(f"pm enable {stock}", sent)home = [c for c in sent if c.startswith("cmd package set-home-activity")]- self.assertEqual(len(home), 1, sent)- self.assertIn("resolve-activity", home[0])- self.assertIn(stock, home[0])+ self.assertEqual(home, [f"cmd package set-home-activity --user 0 {custom}"])if __name__ == "__main__":diff --git a/tools/recovery.py b/tools/recovery.pyindex ef6bf147f..471325101 100644--- a/tools/recovery.py+++ b/tools/recovery.py@@ -32,9 +32,15 @@ PACKAGE_RE = re.compile(r"[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z0-9_]+)+")HOME_RE = re.compile(r"[A-Za-z_][\w.]*/[\w.$]+")SCALE_RE = re.compile(r"-?\d+(\.\d+)?")SETTINGS = ("window_animation_scale", "transition_animation_scale", "animator_duration_scale")-# This project's own launcher. When it already owned Home before debloating, restoring Home to it-# would leave the stock launcher off, so restore goes back to the stock one instead.+# This project's own launcher. When it already owned Home before debloating while the stock launcher+# was on, restoring Home to it would leave the stock launcher's Home unused, so restore goes back to the+# stock one instead. When the stock launcher was already off then, this launcher keeps Home (#1714).CUSTOM_LAUNCHER = "com.gathin.tvhome"+# The stock launchers launcher/build-and-install.sh knows (its KNOWN_STOCK_LAUNCHERS). save() records+# the state of each one installed, listed or not, so restore turns one back on only when it was on+# before cleanup (#1714). tests/test_restore_stock_launcher.py keeps the two lists in step.+STOCK_LAUNCHERS = ("com.google.android.tvlauncher", "com.google.android.apps.tv.launcherx",+ "com.google.android.leanbacklauncher", "com.mitv.tvhome")# What answers HOME without being a launcher, the cases disable.sh, disable.ps1 and check.py skip too:# the setup wizards and the settings apps (on Google TV, setupwraith's .RecoveryActivity takes Home and# system_server crash-loops on it), a vendor's FallbackHome, the placeholder a TCL or a Xiaomi shows@@ -441,6 +447,11 @@ def save(list_path, host):# The launcher that owns Home may not be in the list, but it is what undo has to put back.home_package = home.split("/", 1)[0] if home else Nonetargets = packages + ([home_package] if home_package and home_package not in packages else [])+ # So may an installed stock launcher: undo needs its state from before, so that it turns it back+ # on only when it was on (#1714). One the factory had disabled (examples/verizon-stream-tv), or+ # that launcher/build-and-install.sh had disabled before this list, is recorded as disabled and+ # stays off.+ targets += [name for name in STOCK_LAUNCHERS if name in installed and name not in targets]# A Home that is no launcher (setupwraith's recovery screen, a FallbackHome, a factory test) is not# recorded as Home either: restore would pin Home to it with the stock launcher enabled again, so# it resolves the stock launcher instead. Its package keeps the entry above: that state is real.@@ -524,19 +535,34 @@ def restore_commands(list_path, stock, host):for name, state in untouched:sys.stderr.write(f" leaving {name} alone ({state} when the record was taken)\n")- # The stock launcher comes back unless the owner had disabled it before cleanup: the list may- # have disabled it even when it was not the recorded Home (e.g. the custom launcher owned Home).+ # The stock launcher comes back only when the record holds it as enabled, which re_enable above+ # already covers (#1714): restore enables what was on before cleanup and nothing else. One the+ # record holds as disabled was off before this list (the factory, or launcher/build-and-install.sh+ # before the list), and one it does not hold at all (a record taken before save() noted the stock+ # launchers) cannot be said to have been on, so neither is turned on here.fallback = stock or "com.google.android.tvlauncher"- if states.get(fallback) != "disabled" and fallback not in re_enable:- commands.append(f"pm enable {fallback}")+ fallback_state = states.get(fallback)home = record.get("home")if home and home.split("/", 1)[0] != CUSTOM_LAUNCHER:commands.append(f"cmd package set-home-activity --user 0 {home}")+ elif home and fallback_state != "enabled":+ # This project's launcher owned Home and the stock launcher was not on: Home stays where it+ # was. Its package is in the record as enabled, so it was enabled above.+ commands.append(f"cmd package set-home-activity --user 0 {home}")+ sys.stderr.write(f" Home goes back to {home}, which owned it when the record was taken: "+ f"{fallback} was {fallback_state or 'not in the record'} then, so it stays as "+ f"it is. To have it back: tools/tv.py 'pm enable {fallback}', then make it "+ f"Home.\n")+ elif not home and fallback_state in ("disabled", "absent"):+ # No Home was recorded and the stock launcher was off or missing: there is nothing to resolve.+ sys.stderr.write(f" leaving Home alone: none was recorded, and {fallback} was {fallback_state} "+ f"when the record was taken\n")else:# Nothing handled HOME before cleanup (fresh TV, chooser only), only something that is no- # launcher did, or this project's launcher did, so there is no stock component to replay; ask- # the TV to resolve the stock launcher the way restore.sh always did.+ # launcher did, or this project's launcher did while the stock launcher was on, so there is no+ # stock component to replay; ask the TV to resolve the stock launcher the way restore.sh+ # always did.commands.append(f"cmd package set-home-activity --user 0 $(cmd package resolve-activity "f"--brief -a android.intent.action.MAIN -c android.intent.category.HOME "f"{fallback} | tail -n 1)")