Files
gitlab-instance-0a899031_sh/android13/patch_bootstrap_setupwizard.py
2026-04-09 21:01:21 -05:00

21 lines
944 B
Python

from pathlib import Path
path = Path('/home/eric/redroid-android13/bootstrap_redroid.py')
text = path.read_text()
old = ''' try_shell(backend, "pm disable-user --user 0 com.android.setupwizard")
try_shell(backend, "pm disable-user --user 0 com.google.android.setupwizard")
try_shell(backend, "appops set com.android.shell android:mock_location allow")
'''
new = ''' for package in ("com.android.setupwizard", "com.google.android.setupwizard"):
packages = backend.exec_shell(
"pm list packages --user 0",
check=False,
capture_output=True,
).stdout
if package in packages:
try_shell(backend, "pm disable-user --user 0 {}".format(shell_quote(package)))
try_shell(backend, "appops set com.android.shell android:mock_location allow")
'''
if old not in text:
raise SystemExit('expected setupwizard block not found')
path.write_text(text.replace(old, new))