| 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 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 - A dict containing the overall memory usage statistics for the PID. | 783 - A dict containing the overall memory usage statistics for the PID. |
| 784 - A dict containing memory usage statistics broken down by mapping. | 784 - A dict containing memory usage statistics broken down by mapping. |
| 785 | 785 |
| 786 Raises: | 786 Raises: |
| 787 CommandTimeoutError on timeout. | 787 CommandTimeoutError on timeout. |
| 788 """ | 788 """ |
| 789 return self.old_interface.GetMemoryUsageForPid(pid) | 789 return self.old_interface.GetMemoryUsageForPid(pid) |
| 790 | 790 |
| 791 def __str__(self): | 791 def __str__(self): |
| 792 """Returns the device serial.""" | 792 """Returns the device serial.""" |
| 793 return self.old_interface.GetDevice() | 793 s = self.old_interface.GetDevice() |
| 794 if not s: |
| 795 s = self.old_interface.Adb().GetSerialNumber() |
| 796 return s |
| 794 | 797 |
| 795 @staticmethod | 798 @staticmethod |
| 796 def parallel(devices=None, async=False): | 799 def parallel(devices=None, async=False): |
| 797 """Creates a Parallelizer to operate over the provided list of devices. | 800 """Creates a Parallelizer to operate over the provided list of devices. |
| 798 | 801 |
| 799 If |devices| is either |None| or an empty list, the Parallelizer will | 802 If |devices| is either |None| or an empty list, the Parallelizer will |
| 800 operate over all attached devices. | 803 operate over all attached devices. |
| 801 | 804 |
| 802 Args: | 805 Args: |
| 803 devices: A list of either DeviceUtils instances or objects from | 806 devices: A list of either DeviceUtils instances or objects from |
| 804 from which DeviceUtils instances can be constructed. If None, | 807 from which DeviceUtils instances can be constructed. If None, |
| 805 all attached devices will be used. | 808 all attached devices will be used. |
| 806 async: If true, returns a Parallelizer that runs operations | 809 async: If true, returns a Parallelizer that runs operations |
| 807 asynchronously. | 810 asynchronously. |
| 808 | 811 |
| 809 Returns: | 812 Returns: |
| 810 A Parallelizer operating over |devices|. | 813 A Parallelizer operating over |devices|. |
| 811 """ | 814 """ |
| 812 if not devices or len(devices) == 0: | 815 if not devices or len(devices) == 0: |
| 813 devices = pylib.android_commands.GetAttachedDevices() | 816 devices = pylib.android_commands.GetAttachedDevices() |
| 814 parallelizer_type = (parallelizer.Parallelizer if async | 817 parallelizer_type = (parallelizer.Parallelizer if async |
| 815 else parallelizer.SyncParallelizer) | 818 else parallelizer.SyncParallelizer) |
| 816 return parallelizer_type([ | 819 return parallelizer_type([ |
| 817 d if isinstance(d, DeviceUtils) else DeviceUtils(d) | 820 d if isinstance(d, DeviceUtils) else DeviceUtils(d) |
| 818 for d in devices]) | 821 for d in devices]) |
| 819 | 822 |
| OLD | NEW |