Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(405)

Unified Diff: build/android/pylib/device/adb_wrapper.py

Issue 839143002: Roll Chrome into Mojo. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Rebase Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/findbugs_filter/findbugs_known_bugs.txt ('k') | build/android/pylib/device/device_errors.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/device/adb_wrapper.py
diff --git a/build/android/pylib/device/adb_wrapper.py b/build/android/pylib/device/adb_wrapper.py
index 4006a21d5540611c5e23aa72f2b838293b5efadc..1dbb1d89a9a2a8b7d04b007b47d4c7f20845af5a 100644
--- a/build/android/pylib/device/adb_wrapper.py
+++ b/build/android/pylib/device/adb_wrapper.py
@@ -56,8 +56,12 @@ class AdbWrapper(object):
# pylint: disable=unused-argument
@classmethod
- def _BuildAdbCmd(cls, args, device_serial):
- cmd = [constants.GetAdbPath()]
+ 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())
if device_serial is not None:
cmd.extend(['-s', device_serial])
cmd.extend(args)
@@ -68,9 +72,9 @@ class AdbWrapper(object):
@classmethod
@decorators.WithTimeoutAndRetries
def _RunAdbCmd(cls, args, timeout=None, retries=None, device_serial=None,
- check_error=True):
+ check_error=True, cpu_affinity=None):
status, output = cmd_helper.GetCmdStatusAndOutputWithTimeout(
- cls._BuildAdbCmd(args, device_serial),
+ cls._BuildAdbCmd(args, device_serial, cpu_affinity=cpu_affinity),
timeout_retry.CurrentTimeoutThread().GetRemainingTime())
if status != 0:
raise device_errors.AdbCommandFailedError(
@@ -135,6 +139,25 @@ class AdbWrapper(object):
def __repr__(self):
return '%s(\'%s\')' % (self.__class__.__name__, self)
+ # pylint: disable=unused-argument
+ @classmethod
+ def IsServerOnline(cls):
+ status, output = cmd_helper.GetCmdStatusAndOutput(['pgrep', 'adb'])
+ output = [int(x) for x in output.split()]
+ logging.info('PIDs for adb found: %r', output)
+ return status == 0
+ # pylint: enable=unused-argument
+
+ @classmethod
+ def KillServer(cls, timeout=_DEFAULT_TIMEOUT, retries=_DEFAULT_RETRIES):
+ cls._RunAdbCmd(['kill-server'], timeout=timeout, retries=retries)
+
+ @classmethod
+ def StartServer(cls, timeout=_DEFAULT_TIMEOUT, retries=_DEFAULT_RETRIES):
+ # CPU affinity is used to reduce adb instability http://crbug.com/268450
+ cls._RunAdbCmd(['start-server'], timeout=timeout, retries=retries,
+ cpu_affinity=0)
+
# TODO(craigdh): Determine the filter criteria that should be supported.
@classmethod
def GetDevices(cls, timeout=_DEFAULT_TIMEOUT, retries=_DEFAULT_RETRIES):
@@ -222,12 +245,12 @@ class AdbWrapper(object):
status = int(output[output_end+1:])
except ValueError:
logging.warning('exit status of shell command %r missing.', command)
- raise device_errors.AdbCommandFailedError(
- args, output, device_serial=self._device_serial)
+ raise device_errors.AdbShellCommandFailedError(
+ command, output, status=None, device_serial=self._device_serial)
output = output[:output_end]
if status != expect_status:
- raise device_errors.AdbCommandFailedError(
- args, output, status, self._device_serial)
+ raise device_errors.AdbShellCommandFailedError(
+ command, output, status=status, device_serial=self._device_serial)
return output
def Ls(self, path, timeout=_DEFAULT_TIMEOUT, retries=_DEFAULT_RETRIES):
« no previous file with comments | « build/android/findbugs_filter/findbugs_known_bugs.txt ('k') | build/android/pylib/device/device_errors.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698