Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit c9b652e

Browse files
committed
Bug 1752362 - Add mach adb to use bootstrap version of adb r=geckoview-reviewers,m_kato
This is a very simple shim to get access the same adb that is installed by mach bootstrap without needing to muck with environment variables. This is useful for basic troubleshooting (`adb kill-server`, `adb devices`, etc). Differential Revision: https://phabricator.services.mozilla.com/D235662
1 parent 3c38008 commit c9b652e

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

mobile/android/mach_commands.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,3 +755,32 @@ def emulator(
755755
"Unable to retrieve Android emulator return code.",
756756
)
757757
return 0
758+
759+
760+
@Command(
761+
"adb",
762+
category="devenv",
763+
description="Run the version of Android Debug Bridge (adb) utility that the build system would use.",
764+
)
765+
@CommandArgument("args", nargs=argparse.REMAINDER)
766+
def adb(
767+
command_context,
768+
args,
769+
):
770+
"""Run the version of Android Debug Bridge (adb) utility that the build
771+
system would use."""
772+
from mozrunner.devices.android_device import get_adb_path
773+
774+
adb_path = get_adb_path(command_context)
775+
if not adb_path:
776+
command_context.log(
777+
logging.ERROR,
778+
"adb",
779+
{},
780+
"ADB not found. Did you run `mach bootstrap` with Android selected yet?",
781+
)
782+
return 1
783+
784+
return command_context.run_process(
785+
[adb_path] + args, pass_thru=True, ensure_exit_code=False
786+
)

python/mach/mach/command_util.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def __init__(
4848

4949

5050
MACH_COMMANDS = {
51+
"adb": MachCommandReference("mobile/android/mach_commands.py"),
5152
"addstory": MachCommandReference("toolkit/content/widgets/mach_commands.py"),
5253
"addtest": MachCommandReference("testing/mach_commands.py"),
5354
"addwidget": MachCommandReference("toolkit/content/widgets/mach_commands.py"),

0 commit comments

Comments
 (0)