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

Side by Side Diff: devil/devil/android/device_utils.py

Issue 2781953002: Allow atrace over adb tcp/ip (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | systrace/systrace/tracing_agents/atrace_agent.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 4
5 """Provides a variety of device interactions based on adb. 5 """Provides a variety of device interactions based on adb.
6 6
7 Eventually, this will be based on adb_wrapper. 7 Eventually, this will be based on adb_wrapper.
8 """ 8 """
9 # pylint: disable=unused-argument 9 # pylint: disable=unused-argument
10 10
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 # makes sure that the last line is also terminated, and is more memory 251 # makes sure that the last line is also terminated, and is more memory
252 # efficient than first appending an end-line to each line and then joining 252 # efficient than first appending an end-line to each line and then joining
253 # all of them together. 253 # all of them together.
254 return ''.join(s for line in lines for s in (line, '\n')) 254 return ''.join(s for line in lines for s in (line, '\n'))
255 255
256 256
257 def _IsGceInstance(serial): 257 def _IsGceInstance(serial):
258 return _IPV4_ADDRESS_RE.match(serial) 258 return _IPV4_ADDRESS_RE.match(serial)
259 259
260 260
261 def _CreateAdbWrapper(device): 261 def _CreateAdbWrapper(device, disable_gce=False):
262 if _IsGceInstance(str(device)): 262 if not disable_gce and _IsGceInstance(str(device)):
263 return gce_adb_wrapper.GceAdbWrapper(str(device)) 263 return gce_adb_wrapper.GceAdbWrapper(str(device))
264 else: 264 else:
265 if isinstance(device, adb_wrapper.AdbWrapper): 265 if isinstance(device, adb_wrapper.AdbWrapper):
266 return device 266 return device
267 else: 267 else:
268 return adb_wrapper.AdbWrapper(device) 268 return adb_wrapper.AdbWrapper(device)
269 269
270 270
271 def _FormatPartialOutputError(output): 271 def _FormatPartialOutputError(output):
272 lines = output.splitlines() if isinstance(output, basestring) else output 272 lines = output.splitlines() if isinstance(output, basestring) else output
(...skipping 15 matching lines...) Expand all
288 r'\s*mCurrentFocus.*(Launcher|launcher).*') 288 r'\s*mCurrentFocus.*(Launcher|launcher).*')
289 _VALID_SHELL_VARIABLE = re.compile('^[a-zA-Z_][a-zA-Z0-9_]*$') 289 _VALID_SHELL_VARIABLE = re.compile('^[a-zA-Z_][a-zA-Z0-9_]*$')
290 290
291 LOCAL_PROPERTIES_PATH = posixpath.join('/', 'data', 'local.prop') 291 LOCAL_PROPERTIES_PATH = posixpath.join('/', 'data', 'local.prop')
292 292
293 # Property in /data/local.prop that controls Java assertions. 293 # Property in /data/local.prop that controls Java assertions.
294 JAVA_ASSERT_PROPERTY = 'dalvik.vm.enableassertions' 294 JAVA_ASSERT_PROPERTY = 'dalvik.vm.enableassertions'
295 295
296 def __init__(self, device, enable_device_files_cache=False, 296 def __init__(self, device, enable_device_files_cache=False,
297 default_timeout=_DEFAULT_TIMEOUT, 297 default_timeout=_DEFAULT_TIMEOUT,
298 default_retries=_DEFAULT_RETRIES): 298 default_retries=_DEFAULT_RETRIES, disable_gce=False):
jbudorick 2017/03/28 20:36:03 I don't think this is the right way to handle this
sahilja 2017/04/04 19:24:16 Done.
299 """DeviceUtils constructor. 299 """DeviceUtils constructor.
300 300
301 Args: 301 Args:
302 device: Either a device serial, an existing AdbWrapper instance, or an 302 device: Either a device serial, an existing AdbWrapper instance, or an
303 an existing AndroidCommands instance. 303 an existing AndroidCommands instance.
304 enable_device_files_cache: For PushChangedFiles(), cache checksums of 304 enable_device_files_cache: For PushChangedFiles(), cache checksums of
305 pushed files rather than recomputing them on a subsequent call. 305 pushed files rather than recomputing them on a subsequent call.
306 default_timeout: An integer containing the default number of seconds to 306 default_timeout: An integer containing the default number of seconds to
307 wait for an operation to complete if no explicit value is provided. 307 wait for an operation to complete if no explicit value is provided.
308 default_retries: An integer containing the default number or times an 308 default_retries: An integer containing the default number or times an
309 operation should be retried on failure if no explicit value is provided. 309 operation should be retried on failure if no explicit value is provided.
310 """ 310 """
311 self.adb = None 311 self.adb = None
312 if isinstance(device, basestring): 312 if isinstance(device, basestring):
313 self.adb = _CreateAdbWrapper(device) 313 self.adb = _CreateAdbWrapper(device, disable_gce)
314 elif isinstance(device, adb_wrapper.AdbWrapper): 314 elif isinstance(device, adb_wrapper.AdbWrapper):
315 self.adb = device 315 self.adb = device
316 else: 316 else:
317 raise ValueError('Unsupported device value: %r' % device) 317 raise ValueError('Unsupported device value: %r' % device)
318 self._commands_installed = None 318 self._commands_installed = None
319 self._default_timeout = default_timeout 319 self._default_timeout = default_timeout
320 self._default_retries = default_retries 320 self._default_retries = default_retries
321 self._enable_device_files_cache = enable_device_files_cache 321 self._enable_device_files_cache = enable_device_files_cache
322 self._cache = {} 322 self._cache = {}
323 self._client_caches = {} 323 self._client_caches = {}
(...skipping 2316 matching lines...) Expand 10 before | Expand all | Expand 10 after
2640 on: bool to decide state to switch to. True = on False = off. 2640 on: bool to decide state to switch to. True = on False = off.
2641 """ 2641 """
2642 def screen_test(): 2642 def screen_test():
2643 return self.IsScreenOn() == on 2643 return self.IsScreenOn() == on
2644 2644
2645 if screen_test(): 2645 if screen_test():
2646 logger.info('Screen already in expected state.') 2646 logger.info('Screen already in expected state.')
2647 return 2647 return
2648 self.SendKeyEvent(keyevent.KEYCODE_POWER) 2648 self.SendKeyEvent(keyevent.KEYCODE_POWER)
2649 timeout_retry.WaitFor(screen_test, wait_period=1) 2649 timeout_retry.WaitFor(screen_test, wait_period=1)
OLDNEW
« no previous file with comments | « no previous file | systrace/systrace/tracing_agents/atrace_agent.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698