Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 Args: | 53 Args: |
| 54 device: Either a device serial, an existing AdbWrapper instance, an | 54 device: Either a device serial, an existing AdbWrapper instance, an |
| 55 an existing AndroidCommands instance, or nothing. | 55 an existing AndroidCommands instance, or nothing. |
| 56 default_timeout: An integer containing the default number of seconds to | 56 default_timeout: An integer containing the default number of seconds to |
| 57 wait for an operation to complete if no explicit value | 57 wait for an operation to complete if no explicit value |
| 58 is provided. | 58 is provided. |
| 59 default_retries: An integer containing the default number or times an | 59 default_retries: An integer containing the default number or times an |
| 60 operation should be retried on failure if no explicit | 60 operation should be retried on failure if no explicit |
| 61 value is provided. | 61 value is provided. |
| 62 """ | 62 """ |
| 63 self.adb = None | |
| 63 self.old_interface = None | 64 self.old_interface = None |
| 64 if isinstance(device, basestring): | 65 if isinstance(device, basestring): |
| 66 self.adb = adb_wrapper.AdbWrapper(device) | |
| 65 self.old_interface = pylib.android_commands.AndroidCommands(device) | 67 self.old_interface = pylib.android_commands.AndroidCommands(device) |
| 66 elif isinstance(device, adb_wrapper.AdbWrapper): | 68 elif isinstance(device, adb_wrapper.AdbWrapper): |
| 69 self.adb = device | |
| 67 self.old_interface = pylib.android_commands.AndroidCommands(str(device)) | 70 self.old_interface = pylib.android_commands.AndroidCommands(str(device)) |
| 68 elif isinstance(device, pylib.android_commands.AndroidCommands): | 71 elif isinstance(device, pylib.android_commands.AndroidCommands): |
| 72 self.adb = adb_wrapper.AdbWrapper(device.GetDevice()) | |
| 69 self.old_interface = device | 73 self.old_interface = device |
| 70 elif not device: | 74 elif not device: |
| 71 self.old_interface = pylib.android_commands.AndroidCommands() | 75 self.old_interface = pylib.android_commands.AndroidCommands() |
| 72 else: | 76 else: |
| 73 raise ValueError('Unsupported type passed for argument "device"') | 77 raise ValueError('Unsupported type passed for argument "device"') |
| 74 self._default_timeout = default_timeout | 78 self._default_timeout = default_timeout |
| 75 self._default_retries = default_retries | 79 self._default_retries = default_retries |
| 76 assert(hasattr(self, decorators.DEFAULT_TIMEOUT_ATTR)) | 80 assert(hasattr(self, decorators.DEFAULT_TIMEOUT_ATTR)) |
| 77 assert(hasattr(self, decorators.DEFAULT_RETRIES_ATTR)) | 81 assert(hasattr(self, decorators.DEFAULT_RETRIES_ATTR)) |
| 78 | 82 |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 694 property_name: A string containing the name of the property to set on | 698 property_name: A string containing the name of the property to set on |
| 695 the device. | 699 the device. |
| 696 value: A string containing the value to set to the property on the | 700 value: A string containing the value to set to the property on the |
| 697 device. | 701 device. |
| 698 timeout: timeout in seconds | 702 timeout: timeout in seconds |
| 699 retries: number of retries | 703 retries: number of retries |
| 700 | 704 |
| 701 Raises: | 705 Raises: |
| 702 CommandTimeoutError on timeout. | 706 CommandTimeoutError on timeout. |
| 703 """ | 707 """ |
| 708 is_persist_property = property_name.startswith('persist.') | |
| 709 if is_persist_property: | |
| 710 self._RunShellCommandImpl('stop') | |
|
tonyg
2014/08/15 17:19:43
Seems like this should be in system_properties, no
jbudorick
2014/08/15 17:41:47
It could be, although I'm plotting to get rid of s
| |
| 704 self.old_interface.system_properties[property_name] = value | 711 self.old_interface.system_properties[property_name] = value |
| 712 if is_persist_property: | |
| 713 self.adb.WaitForDevice() | |
| 714 self._RunShellCommandImpl('start') | |
| 715 self.old_interface.WaitForDevicePm() | |
| 705 | 716 |
| 706 @decorators.WithTimeoutAndRetriesFromInstance() | 717 @decorators.WithTimeoutAndRetriesFromInstance() |
| 707 def GetPids(self, process_name, timeout=None, retries=None): | 718 def GetPids(self, process_name, timeout=None, retries=None): |
| 708 """Returns the PIDs of processes with the given name. | 719 """Returns the PIDs of processes with the given name. |
| 709 | 720 |
| 710 Note that the |process_name| is often the package name. | 721 Note that the |process_name| is often the package name. |
| 711 | 722 |
| 712 Args: | 723 Args: |
| 713 process_name: A string containing the process name to get the PIDs for. | 724 process_name: A string containing the process name to get the PIDs for. |
| 714 timeout: timeout in seconds | 725 timeout: timeout in seconds |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 815 A Parallelizer operating over |devices|. | 826 A Parallelizer operating over |devices|. |
| 816 """ | 827 """ |
| 817 if not devices or len(devices) == 0: | 828 if not devices or len(devices) == 0: |
| 818 devices = pylib.android_commands.GetAttachedDevices() | 829 devices = pylib.android_commands.GetAttachedDevices() |
| 819 parallelizer_type = (parallelizer.Parallelizer if async | 830 parallelizer_type = (parallelizer.Parallelizer if async |
| 820 else parallelizer.SyncParallelizer) | 831 else parallelizer.SyncParallelizer) |
| 821 return parallelizer_type([ | 832 return parallelizer_type([ |
| 822 d if isinstance(d, DeviceUtils) else DeviceUtils(d) | 833 d if isinstance(d, DeviceUtils) else DeviceUtils(d) |
| 823 for d in devices]) | 834 for d in devices]) |
| 824 | 835 |
| OLD | NEW |