Fall back to adb on PATH if platform-tools not present.

Log adb --version. Example:

INFO:root:adb --version: Android Debug Bridge version 1.0.41
Version 31.0.3-7562133
Installed as /{snip}/third_party/android_sdk/public/platform-tools/adb

When not found -> "Installed as /usr/bin/adb"

Bug: angleproject:6854
Change-Id: I3c19c4eda2211480f2c93b7d14f72f5641b3bfc2
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3602821
Reviewed-by: Jamie Madill <[email protected]>
Commit-Queue: Roman Lavrov <[email protected]>
This commit is contained in:
Roman Lavrov authored and Angle LUCI CQ committed 2022-04-22 15:38:51 +00:00
1 parent 2dd13ebbda
commit d988db39b0
1 file changed
+21 -5
+21 -5
View File
@@ -3,10 +3,12 @@
# found in the LICENSE file.
import contextlib
import functools
import glob
import json
import logging
import os
import pathlib
import posixpath
import random
import subprocess
@@ -37,13 +39,27 @@ def _Run(cmd):
return output
@functools.lru_cache()
def _FindAdb():
platform_tools = (
pathlib.Path(angle_path_util.ANGLE_ROOT_DIR) / 'third_party' / 'android_sdk' / 'public' /
'platform-tools')
if platform_tools.exists():
adb = str(platform_tools / 'adb')
else:
adb = 'adb'
adb_info = subprocess.check_output([adb, '--version']).decode()
logging.info('adb --version: %s', adb_info)
return adb
class Adb(object):
def __init__(self, adb_path=None):
if not adb_path:
adb_path = os.path.join(angle_path_util.ANGLE_ROOT_DIR,
'third_party/android_sdk/public/platform-tools/adb')
self._adb_path = adb_path
def __init__(self):
self._adb_path = _FindAdb()
def Run(self, args):
return _Run([self._adb_path] + args)