| 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 70dbf460a66a9800c1449dc279ca4575c448c247..4eb61ae38f54e6a86588e0728363b13d3d1e6f91 100644
|
| --- a/tools/telemetry/telemetry/core/platform/android_device.py
|
| +++ b/tools/telemetry/telemetry/core/platform/android_device.py
|
| @@ -2,6 +2,10 @@
|
| # 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 import util
|
| from telemetry.core.backends import adb_commands
|
| @@ -61,3 +65,50 @@ Waiting for device...
|
| @property
|
| def enable_performance_mode(self):
|
| return self._enable_performance_mode
|
| +
|
| + def FindAllAvailableBrowsers(self, options):
|
| + return []
|
| +
|
| +
|
| +def CanFindAvailableBrowsers():
|
| + return CanFindAvailableDevices()
|
| +
|
| +
|
| +def CanFindAvailableDevices():
|
| + if not adb_commands.IsAndroidSupported():
|
| + logging.info('Android build commands unavailable on this machine. Have '
|
| + 'you installed Android build dependencies?')
|
| + return False
|
| +
|
| + try:
|
| + with open(os.devnull, 'w') as devnull:
|
| + proc = subprocess.Popen(
|
| + ['adb', 'devices'],
|
| + stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=devnull)
|
| + stdout, _ = proc.communicate()
|
| + if re.search(re.escape('????????????\tno permissions'), stdout) != None:
|
| + logging.warn('adb devices reported a permissions error. Consider '
|
| + 'restarting adb as root:')
|
| + logging.warn(' adb kill-server')
|
| + logging.warn(' sudo `which adb` devices\n\n')
|
| + return True
|
| + except OSError:
|
| + platform_tools_path = os.path.join(util.GetChromiumSrcDir(),
|
| + 'third_party', 'android_tools', 'sdk', 'platform-tools')
|
| + if (sys.platform.startswith('linux') and
|
| + os.path.exists(os.path.join(platform_tools_path, 'adb'))):
|
| + os.environ['PATH'] = os.pathsep.join([platform_tools_path,
|
| + os.environ['PATH']])
|
| + return True
|
| + return False
|
| +
|
| +
|
| +def FindAllAvailableDevices(options):
|
| + """Returns a list of available device types.
|
| + """
|
| + if not CanFindAvailableDevices():
|
| + logging.info('No adb command found. ' +
|
| + 'Will not try searching for Android browsers.')
|
| + return []
|
| + else:
|
| + return AndroidDevice.GetAllConnectedDevices()
|
|
|