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 if s == 'unknown': |
| 797 raise device_errors.NoDevicesError() |
| 798 return s |
794 | 799 |
795 @staticmethod | 800 @staticmethod |
796 def parallel(devices=None, async=False): | 801 def parallel(devices=None, async=False): |
797 """Creates a Parallelizer to operate over the provided list of devices. | 802 """Creates a Parallelizer to operate over the provided list of devices. |
798 | 803 |
799 If |devices| is either |None| or an empty list, the Parallelizer will | 804 If |devices| is either |None| or an empty list, the Parallelizer will |
800 operate over all attached devices. | 805 operate over all attached devices. |
801 | 806 |
802 Args: | 807 Args: |
803 devices: A list of either DeviceUtils instances or objects from | 808 devices: A list of either DeviceUtils instances or objects from |
804 from which DeviceUtils instances can be constructed. If None, | 809 from which DeviceUtils instances can be constructed. If None, |
805 all attached devices will be used. | 810 all attached devices will be used. |
806 async: If true, returns a Parallelizer that runs operations | 811 async: If true, returns a Parallelizer that runs operations |
807 asynchronously. | 812 asynchronously. |
808 | 813 |
809 Returns: | 814 Returns: |
810 A Parallelizer operating over |devices|. | 815 A Parallelizer operating over |devices|. |
811 """ | 816 """ |
812 if not devices or len(devices) == 0: | 817 if not devices or len(devices) == 0: |
813 devices = pylib.android_commands.GetAttachedDevices() | 818 devices = pylib.android_commands.GetAttachedDevices() |
814 parallelizer_type = (parallelizer.Parallelizer if async | 819 parallelizer_type = (parallelizer.Parallelizer if async |
815 else parallelizer.SyncParallelizer) | 820 else parallelizer.SyncParallelizer) |
816 return parallelizer_type([ | 821 return parallelizer_type([ |
817 d if isinstance(d, DeviceUtils) else DeviceUtils(d) | 822 d if isinstance(d, DeviceUtils) else DeviceUtils(d) |
818 for d in devices]) | 823 for d in devices]) |
819 | 824 |
OLD | NEW |