Index: build/android/devil/android/sdk/adb_wrapper.py |
diff --git a/build/android/devil/android/sdk/adb_wrapper.py b/build/android/devil/android/sdk/adb_wrapper.py |
index 5a81c7fe503b634f583e29d40f92bd6515948bf8..184568f60cd05d29bb05ad0b7734af85f9d97bd5 100644 |
--- a/build/android/devil/android/sdk/adb_wrapper.py |
+++ b/build/android/devil/android/sdk/adb_wrapper.py |
@@ -13,12 +13,13 @@ import errno |
import logging |
import os |
import re |
+import threading |
+from devil import devil_env |
from devil.android import decorators |
from devil.android import device_errors |
from devil.utils import cmd_helper |
from devil.utils import timeout_retry |
-from pylib import constants |
_DEFAULT_TIMEOUT = 30 |
@@ -49,6 +50,9 @@ DeviceStat = collections.namedtuple('DeviceStat', |
class AdbWrapper(object): |
"""A wrapper around a local Android Debug Bridge executable.""" |
+ _adb_path = None |
+ _adb_path_lock = threading.Lock() |
+ |
def __init__(self, device_serial): |
"""Initializes the AdbWrapper. |
@@ -59,19 +63,25 @@ class AdbWrapper(object): |
raise ValueError('A device serial must be specified') |
self._device_serial = str(device_serial) |
- # pylint: disable=unused-argument |
+ @classmethod |
+ def _GetAdbPath(cls): |
+ if not cls._adb_path: |
+ with cls._adb_path_lock: |
+ if not cls._adb_path: |
+ cls._adb_path = devil_env.config.FetchPath('adb') |
+ return cls._adb_path |
+ |
@classmethod |
def _BuildAdbCmd(cls, args, device_serial, cpu_affinity=None): |
if cpu_affinity is not None: |
cmd = ['taskset', '-c', str(cpu_affinity)] |
else: |
cmd = [] |
- cmd.append(constants.GetAdbPath()) |
+ cmd.append(cls._GetAdbPath()) |
if device_serial is not None: |
cmd.extend(['-s', device_serial]) |
cmd.extend(args) |
return cmd |
- # pylint: enable=unused-argument |
# pylint: disable=unused-argument |
@classmethod |