| Index: tools/telemetry/telemetry/core/platform/android_device.py
|
| diff --git a/tools/telemetry/telemetry/core/platform/android_device.py b/tools/telemetry/telemetry/core/platform/android_device.py
|
| index 1c5fac47495c0a68cc0080c9ffee43b6649bbc8e..c7dc378bff8c1809e27366ae592313a25941f7ed 100644
|
| --- a/tools/telemetry/telemetry/core/platform/android_device.py
|
| +++ b/tools/telemetry/telemetry/core/platform/android_device.py
|
| @@ -1,18 +1,16 @@
|
| # Copyright 2014 The Chromium Authors. All rights reserved.
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
| -
|
| import logging
|
| import os
|
| +import re
|
| +import subprocess
|
| +import sys
|
|
|
| +from telemetry.core.backends import adb_commands
|
| from telemetry.core.platform import device
|
| from telemetry.core.platform.profiler import monsoon
|
| from telemetry.core import util
|
| -
|
| -util.AddDirToPythonPath(util.GetChromiumSrcDir(), 'build', 'android')
|
| -from pylib import constants # pylint: disable=import-error
|
| -from pylib.device import device_errors # pylint: disable=import-error
|
| -from pylib.device import device_utils # pylint: disable=import-error
|
|
|
|
|
| class AndroidDevice(device.Device):
|
| @@ -46,8 +44,7 @@
|
|
|
|
|
| def GetDeviceSerials():
|
| - device_serials = [d.adb.GetDeviceSerial()
|
| - for d in device_utils.DeviceUtils.HealthyDevices()]
|
| + device_serials = adb_commands.GetAttachedDevices()
|
| # The monsoon provides power for the device, so for devices with no
|
| # real battery, we need to turn them on after the monsoon enables voltage
|
| # output to the device.
|
| @@ -68,9 +65,8 @@
|
|
|
| Waiting for device...
|
| """)
|
| - util.WaitFor(device_utils.DeviceUtils.HealthyDevices, 600)
|
| - device_serials = [d.adb.GetDeviceSerial()
|
| - for d in device_utils.DeviceUtils.HealthyDevices()]
|
| + util.WaitFor(adb_commands.GetAttachedDevices, 600)
|
| + device_serials = adb_commands.GetAttachedDevices()
|
| except IOError:
|
| return []
|
| return device_serials
|
| @@ -102,16 +98,33 @@
|
|
|
| def CanDiscoverDevices():
|
| """Returns true if devices are discoverable via adb."""
|
| - adb_path = constants.GetAdbPath()
|
| - if os.path.isabs(adb_path) and not os.path.exists(adb_path):
|
| + if not adb_commands.IsAndroidSupported():
|
| + logging.info(
|
| + 'Android build commands unavailable on this machine. '
|
| + 'Have you installed Android build dependencies?')
|
| return False
|
| -
|
| try:
|
| - device_utils.DeviceUtils.HealthyDevices()
|
| + with open(os.devnull, 'w') as devnull:
|
| + adb_process = subprocess.Popen(
|
| + ['adb', 'devices'], stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
| + stdin=devnull)
|
| + stdout = adb_process.communicate()[0]
|
| + if re.search(re.escape('????????????\tno permissions'), stdout) != None:
|
| + logging.warn('adb devices gave a permissions error. '
|
| + 'Consider running adb as root:')
|
| + logging.warn(' adb kill-server')
|
| + logging.warn(' sudo `which adb` devices\n\n')
|
| return True
|
| - except (device_errors.CommandFailedError, device_errors.CommandTimeoutError,
|
| - OSError):
|
| - return False
|
| + except OSError:
|
| + pass
|
| + chromium_adb_path = os.path.join(
|
| + util.GetChromiumSrcDir(), 'third_party', 'android_tools', 'sdk',
|
| + 'platform-tools', 'adb')
|
| + if sys.platform.startswith('linux') and os.path.exists(chromium_adb_path):
|
| + os.environ['PATH'] = os.pathsep.join(
|
| + [os.path.dirname(chromium_adb_path), os.environ['PATH']])
|
| + return True
|
| + return False
|
|
|
|
|
| def FindAllAvailableDevices(_):
|
|
|