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

Side by Side Diff: build/android/pylib/device/device_utils.py

Issue 371813005: [Android] Switch to DeviceUtils versions of Ls, SetJavaAsserts, GetProp, and SetProp. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
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=W0613 9 # pylint: disable=W0613
10 10
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 CommandFailedError if the file could not be written on the device. 539 CommandFailedError if the file could not be written on the device.
540 """ 540 """
541 if as_root: 541 if as_root:
542 if not self.old_interface.CanAccessProtectedFileContents(): 542 if not self.old_interface.CanAccessProtectedFileContents():
543 raise device_errors.CommandFailedError( 543 raise device_errors.CommandFailedError(
544 'Cannot write to %s with root priveleges.' % device_path) 544 'Cannot write to %s with root priveleges.' % device_path)
545 self.old_interface.SetProtectedFileContents(device_path, contents) 545 self.old_interface.SetProtectedFileContents(device_path, contents)
546 else: 546 else:
547 self.old_interface.SetFileContents(device_path, contents) 547 self.old_interface.SetFileContents(device_path, contents)
548 548
549 @decorators.WithTimeoutAndRetriesFromInstance()
550 def Ls(self, device_path, timeout=None, retries=None):
551 """Lists the contents of a directory on the device.
552
553 Args:
554 device_path: A string containing the path of the directory on the device
555 to list.
556 timeout: Same as for |IsOnline|.
557 retries: Same as for |IsOnline|.
558 Returns:
559 The contents of the directory specified by |device_path|.
560 """
561 return self.old_interface.ListPathContents(device_path)
562
563 @decorators.WithTimeoutAndRetriesFromInstance()
564 def SetJavaAsserts(self, enabled, timeout=None, retries=None):
565 """Enables or disables Java asserts.
566
567 Args:
568 enabled: A boolean indicating whether Java asserts should be enabled
569 or disabled.
570 timeout: Same as for |IsOnline|.
571 retries: Same as for |IsOnline|.
572 """
573 self.old_interface.SetJavaAssertsEnabled(enabled)
574
575 @decorators.WithTimeoutAndRetriesFromInstance()
576 def GetProp(self, property_name, timeout=None, retries=None):
577 """Gets a property from the device.
578
579 Args:
580 property_name: A string containing the name of the property to get from
581 the device.
582 timeout: Same as for |IsOnline|.
583 retries: Same as for |IsOnline|.
584 Returns:
585 The value of the device's |property_name| property.
586 """
587 return self.old_interface.system_properties[property_name]
588
589 @decorators.WithTimeoutAndRetriesFromInstance()
590 def SetProp(self, property_name, value, timeout=None, retries=None):
591 """Sets a property on the device.
592
593 Args:
594 property_name: A string containing the name of the property to set on
595 the device.
596 value: A string containing the value to set to the property on the
597 device.
598 timeout: Same as for |IsOnline|.
599 retries: Same as for |IsOnline|.
600 """
601 self.old_interface.system_properties[property_name] = value
602
549 def __str__(self): 603 def __str__(self):
550 """Returns the device serial.""" 604 """Returns the device serial."""
551 return self.old_interface.GetDevice() 605 return self.old_interface.GetDevice()
552 606
553 @staticmethod 607 @staticmethod
554 def parallel(devices=None, async=False): 608 def parallel(devices=None, async=False):
555 """Creates a Parallelizer to operate over the provided list of devices. 609 """Creates a Parallelizer to operate over the provided list of devices.
556 610
557 If |devices| is either |None| or an empty list, the Parallelizer will 611 If |devices| is either |None| or an empty list, the Parallelizer will
558 operate over all attached devices. 612 operate over all attached devices.
559 613
560 Args: 614 Args:
561 devices: A list of either DeviceUtils instances or objects from 615 devices: A list of either DeviceUtils instances or objects from
562 from which DeviceUtils instances can be constructed. If None, 616 from which DeviceUtils instances can be constructed. If None,
563 all attached devices will be used. 617 all attached devices will be used.
564 async: If true, returns a Parallelizer that runs operations 618 async: If true, returns a Parallelizer that runs operations
565 asynchronously. 619 asynchronously.
566 Returns: 620 Returns:
567 A Parallelizer operating over |devices|. 621 A Parallelizer operating over |devices|.
568 """ 622 """
569 if not devices or len(devices) == 0: 623 if not devices or len(devices) == 0:
570 devices = pylib.android_commands.GetAttachedDevices() 624 devices = pylib.android_commands.GetAttachedDevices()
571 parallelizer_type = (parallelizer.Parallelizer if async 625 parallelizer_type = (parallelizer.Parallelizer if async
572 else parallelizer.SyncParallelizer) 626 else parallelizer.SyncParallelizer)
573 return parallelizer_type([ 627 return parallelizer_type([
574 d if isinstance(d, DeviceUtils) else DeviceUtils(d) 628 d if isinstance(d, DeviceUtils) else DeviceUtils(d)
575 for d in devices]) 629 for d in devices])
576 630
OLDNEW
« no previous file with comments | « build/android/pylib/content_settings.py ('k') | build/android/pylib/device/device_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698