OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 # pylint: disable=W0212 | 5 # pylint: disable=W0212 |
6 | 6 |
7 import fcntl | 7 import fcntl |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import psutil | 10 import psutil |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 Forwarder._UnmapDevicePortLocked(device_port, device) | 134 Forwarder._UnmapDevicePortLocked(device_port, device) |
135 | 135 |
136 @staticmethod | 136 @staticmethod |
137 def UnmapAllDevicePorts(device): | 137 def UnmapAllDevicePorts(device): |
138 """Unmaps all the previously forwarded ports for the provided device. | 138 """Unmaps all the previously forwarded ports for the provided device. |
139 | 139 |
140 Args: | 140 Args: |
141 device: A DeviceUtils instance. | 141 device: A DeviceUtils instance. |
142 port_pairs: A list of tuples (device_port, host_port) to unmap. | 142 port_pairs: A list of tuples (device_port, host_port) to unmap. |
143 """ | 143 """ |
| 144 # TODO(jbudorick) Remove once telemetry gets switched over. |
| 145 if isinstance(device, pylib.android_commands.AndroidCommands): |
| 146 device = pylib.device.device_utils.DeviceUtils(device) |
144 with _FileLock(Forwarder._LOCK_PATH): | 147 with _FileLock(Forwarder._LOCK_PATH): |
145 if not Forwarder._instance: | 148 if not Forwarder._instance: |
146 return | 149 return |
147 adb_serial = device.old_interface.Adb().GetSerialNumber() | 150 adb_serial = device.old_interface.Adb().GetSerialNumber() |
148 if adb_serial not in Forwarder._instance._initialized_devices: | 151 if adb_serial not in Forwarder._instance._initialized_devices: |
149 return | 152 return |
150 port_map = Forwarder._GetInstanceLocked( | 153 port_map = Forwarder._GetInstanceLocked( |
151 None)._device_to_host_port_map | 154 None)._device_to_host_port_map |
152 for (device_serial, device_port) in port_map.keys(): | 155 for (device_serial, device_port) in port_map.keys(): |
153 if adb_serial == device_serial: | 156 if adb_serial == device_serial: |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 # TODO(pliard): Remove the following call to KillAllBlocking() when we are | 337 # TODO(pliard): Remove the following call to KillAllBlocking() when we are |
335 # sure that the old version of device_forwarder (not supporting | 338 # sure that the old version of device_forwarder (not supporting |
336 # 'kill-server') is not running on the bots anymore. | 339 # 'kill-server') is not running on the bots anymore. |
337 timeout_sec = 5 | 340 timeout_sec = 5 |
338 processes_killed = device.old_interface.KillAllBlocking( | 341 processes_killed = device.old_interface.KillAllBlocking( |
339 'device_forwarder', timeout_sec) | 342 'device_forwarder', timeout_sec) |
340 if not processes_killed: | 343 if not processes_killed: |
341 pids = device.old_interface.ExtractPid('device_forwarder') | 344 pids = device.old_interface.ExtractPid('device_forwarder') |
342 if pids: | 345 if pids: |
343 raise Exception('Timed out while killing device_forwarder') | 346 raise Exception('Timed out while killing device_forwarder') |
OLD | NEW |