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

Unified Diff: tools/telemetry/telemetry/core/platform/android_device.py

Issue 760653002: Telemetry --device (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
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()

Powered by Google App Engine
This is Rietveld 408576698