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

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

Issue 1212643002: [Telemetry] Remove adb_commands usage from android_device. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 | « no previous file | tools/telemetry/telemetry/core/platform/android_device_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b5732526fbed68511de562030e4c35bc5ebf88a6..2584b090a3cbb815125a72fa74408af64b2e5c5e 100644
--- a/tools/telemetry/telemetry/core/platform/android_device.py
+++ b/tools/telemetry/telemetry/core/platform/android_device.py
@@ -3,14 +3,15 @@
# found in the LICENSE file.
import logging
import os
-import re
-import subprocess
-import sys
from telemetry.core.platform import device
from telemetry.core.platform.profiler import monsoon
from telemetry.core import util
-from telemetry.internal.backends import adb_commands
+
+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):
@@ -42,9 +43,10 @@ class AndroidDevice(device.Device):
def enable_performance_mode(self):
return self._enable_performance_mode
-
def GetDeviceSerials():
- device_serials = adb_commands.GetAttachedDevices()
+ device_serials = [d.adb.GetDeviceSerial()
+ for d in device_utils.DeviceUtils.HealthyDevices()]
+
# 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.
@@ -65,8 +67,9 @@ The Monsoon's power output has been enabled. Please now ensure that:
Waiting for device...
""")
- util.WaitFor(adb_commands.GetAttachedDevices, 600)
- device_serials = adb_commands.GetAttachedDevices()
+ util.WaitFor(device_utils.DeviceUtils.HealthyDevices, 600)
+ device_serials = [d.adb.GetDeviceSerial()
+ for d in device_utils.DeviceUtils.HealthyDevices()]
except IOError:
return []
return device_serials
@@ -98,33 +101,15 @@ def GetDevice(finder_options):
def CanDiscoverDevices():
"""Returns true if devices are discoverable via adb."""
- if not adb_commands.IsAndroidSupported():
- logging.info(
- 'Android build commands unavailable on this machine. '
- 'Have you installed Android build dependencies?')
+ adb_path = constants.GetAdbPath()
+ if os.path.isabs(adb_path) and not os.path.exists(adb_path):
return False
try:
- 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 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']])
+ device_utils.DeviceUtils.HealthyDevices()
return True
- return False
+ except (device_errors.CommandFailedError, device_errors.CommandTimeoutError,
+ OSError):
+ return False
def FindAllAvailableDevices(_):
« no previous file with comments | « no previous file | tools/telemetry/telemetry/core/platform/android_device_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698