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

Side by Side Diff: tools/telemetry/telemetry/core/backends/adb_commands.py

Issue 99713002: Factor out a system_properties interface for interacting with getprop/setprop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 """Brings in Chrome Android's android_commands module, which itself is a 4 """Brings in Chrome Android's android_commands module, which itself is a
5 thin(ish) wrapper around adb.""" 5 thin(ish) wrapper around adb."""
6 6
7 import logging 7 import logging
8 import os 8 import os
9 import shutil 9 import shutil
10 import stat 10 import stat
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 51
52 def ResetTestServerPortAllocation(): 52 def ResetTestServerPortAllocation():
53 return ports.ResetTestServerPortAllocation() 53 return ports.ResetTestServerPortAllocation()
54 54
55 55
56 class AdbCommands(object): 56 class AdbCommands(object):
57 """A thin wrapper around ADB""" 57 """A thin wrapper around ADB"""
58 58
59 def __init__(self, device): 59 def __init__(self, device):
60 self._adb = android_commands.AndroidCommands(device) 60 self._adb = android_commands.AndroidCommands(device, api_strict_mode=True)
61 self._device = device 61 self._device = device
62 62
63 def device(self): 63 def device(self):
64 return self._device 64 return self._device
65 65
66 @property
67 def system_properties(self):
68 return self._adb.system_properties
69
66 def Adb(self): 70 def Adb(self):
67 return self._adb 71 return self._adb
68 72
69 def Forward(self, local, remote): 73 def Forward(self, local, remote):
70 ret = self._adb.Adb().SendCommand('forward %s %s' % (local, remote)) 74 ret = self._adb.Adb().SendCommand('forward %s %s' % (local, remote))
71 assert ret == '' 75 assert ret == ''
72 76
73 def RunShellCommand(self, command, timeout_time=20, log_result=False): 77 def RunShellCommand(self, command, timeout_time=20, log_result=False):
74 """Send a command to the adb shell and return the result. 78 """Send a command to the adb shell and return the result.
75 79
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 if os.path.join(build_dir, build_type) in path: 190 if os.path.join(build_dir, build_type) in path:
187 return build_type 191 return build_type
188 return None 192 return None
189 193
190 194
191 def SetupPrebuiltTools(adb): 195 def SetupPrebuiltTools(adb):
192 # TODO(bulach): build the host tools for mac, and the targets for x86/mips. 196 # TODO(bulach): build the host tools for mac, and the targets for x86/mips.
193 # Prebuilt tools from r226197. 197 # Prebuilt tools from r226197.
194 has_prebuilt = sys.platform.startswith('linux') 198 has_prebuilt = sys.platform.startswith('linux')
195 if has_prebuilt: 199 if has_prebuilt:
196 abi = adb.RunShellCommand('getprop ro.product.cpu.abi') 200 abi = adb.system_properties['ro.product.cpu.abi']
197 has_prebuilt = abi and abi[0].startswith('armeabi') 201 has_prebuilt = abi.startswith('armeabi')
198 if not has_prebuilt: 202 if not has_prebuilt:
199 logging.error( 203 logging.error(
200 'Prebuilt android tools only available for Linux host and ARM device.') 204 'Prebuilt android tools only available for Linux host and ARM device.')
201 return False 205 return False
202 206
203 prebuilt_tools = [ 207 prebuilt_tools = [
204 'forwarder_dist/device_forwarder', 208 'forwarder_dist/device_forwarder',
205 'host_forwarder', 209 'host_forwarder',
206 'md5sum_dist/md5sum_bin', 210 'md5sum_dist/md5sum_bin',
207 'md5sum_bin_host', 211 'md5sum_bin_host',
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 self._port_pairs = new_port_pairs 247 self._port_pairs = new_port_pairs
244 forwarder.Forwarder.Map(new_port_pairs, self._adb) 248 forwarder.Forwarder.Map(new_port_pairs, self._adb)
245 249
246 @property 250 @property
247 def url(self): 251 def url(self):
248 return 'http://127.0.0.1:%i' % self._host_port 252 return 'http://127.0.0.1:%i' % self._host_port
249 253
250 def Close(self): 254 def Close(self):
251 for (device_port, _) in self._port_pairs: 255 for (device_port, _) in self._port_pairs:
252 forwarder.Forwarder.UnmapDevicePort(device_port, self._adb) 256 forwarder.Forwarder.UnmapDevicePort(device_port, self._adb)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698