| OLD | NEW |
| 1 # coding=utf-8 | 1 # coding=utf-8 |
| 2 # Copyright 2015 Google Inc. All rights reserved. | 2 # Copyright 2015 Google Inc. All rights reserved. |
| 3 # | 3 # |
| 4 # Licensed under the Apache License, Version 2.0 (the "License"); | 4 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 # you may not use this file except in compliance with the License. | 5 # you may not use this file except in compliance with the License. |
| 6 # You may obtain a copy of the License at | 6 # You may obtain a copy of the License at |
| 7 # | 7 # |
| 8 # http://www.apache.org/licenses/LICENSE-2.0 | 8 # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 # | 9 # |
| 10 # Unless required by applicable law or agreed to in writing, software | 10 # Unless required by applicable law or agreed to in writing, software |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 # This updates the port path of the device thus clears its cache. | 267 # This updates the port path of the device thus clears its cache. |
| 268 device.Root() | 268 device.Root() |
| 269 return device | 269 return device |
| 270 | 270 |
| 271 devices = parallel.pmap(fn, handles) | 271 devices = parallel.pmap(fn, handles) |
| 272 _PER_DEVICE_CACHE.trim(devices) | 272 _PER_DEVICE_CACHE.trim(devices) |
| 273 return devices | 273 return devices |
| 274 | 274 |
| 275 | 275 |
| 276 def GetLocalDevices( | 276 def GetLocalDevices( |
| 277 banner, default_timeout_ms, auth_timeout_ms, on_error=None, as_root=False): | 277 banner, default_timeout_ms, auth_timeout_ms, on_error=None, as_root=False, |
| 278 enable_resets=False): |
| 278 """Returns the list of devices available. | 279 """Returns the list of devices available. |
| 279 | 280 |
| 280 Caller MUST call CloseDevices(devices) on the return value or call .Close() on | 281 Caller MUST call CloseDevices(devices) on the return value or call .Close() on |
| 281 each element to close the USB handles. | 282 each element to close the USB handles. |
| 282 | 283 |
| 283 Arguments: | 284 Arguments: |
| 284 - banner: authentication banner associated with the RSA keys. It's better to | 285 - banner: authentication banner associated with the RSA keys. It's better to |
| 285 use a constant. | 286 use a constant. |
| 286 - default_timeout_ms: default I/O operation timeout. | 287 - default_timeout_ms: default I/O operation timeout. |
| 287 - auth_timeout_ms: timeout for the user to accept the public key. | 288 - auth_timeout_ms: timeout for the user to accept the public key. |
| 288 - on_error: callback when an internal failure occurs. | 289 - on_error: callback when an internal failure occurs. |
| 289 - as_root: if True, restarts adbd as root if possible. | 290 - as_root: if True, restarts adbd as root if possible. |
| 290 | 291 |
| 291 Returns one of: | 292 Returns one of: |
| 292 - list of HighDevice instances. | 293 - list of HighDevice instances. |
| 293 - None if adb is unavailable. | 294 - None if adb is unavailable. |
| 294 """ | 295 """ |
| 295 with _ADB_KEYS_LOCK: | 296 with _ADB_KEYS_LOCK: |
| 296 if not _ADB_KEYS: | 297 if not _ADB_KEYS: |
| 297 return [] | 298 return [] |
| 298 # Create unopened handles for all usb devices. | 299 # Create unopened handles for all usb devices. |
| 299 handles = list( | 300 handles = list( |
| 300 common.UsbHandle.FindDevicesSafe( | 301 common.UsbHandle.FindDevicesSafe( |
| 301 adb_commands_safe.DeviceIsAvailable, timeout_ms=default_timeout_ms)) | 302 adb_commands_safe.DeviceIsAvailable, timeout_ms=default_timeout_ms)) |
| 302 | 303 |
| 303 return _ConnectFromHandles(handles, banner=banner, | 304 return _ConnectFromHandles(handles, banner=banner, |
| 304 default_timeout_ms=default_timeout_ms, | 305 default_timeout_ms=default_timeout_ms, |
| 305 auth_timeout_ms=auth_timeout_ms, on_error=on_error, | 306 auth_timeout_ms=auth_timeout_ms, on_error=on_error, |
| 306 as_root=as_root) | 307 as_root=as_root, enable_resets=enable_resets) |
| 307 | 308 |
| 308 | 309 |
| 309 def GetRemoteDevices(banner, endpoints, default_timeout_ms, auth_timeout_ms, | 310 def GetRemoteDevices(banner, endpoints, default_timeout_ms, auth_timeout_ms, |
| 310 on_error=None, as_root=False): | 311 on_error=None, as_root=False): |
| 311 """Returns the list of devices available. | 312 """Returns the list of devices available. |
| 312 | 313 |
| 313 Caller MUST call CloseDevices(devices) on the return value or call .Close() on | 314 Caller MUST call CloseDevices(devices) on the return value or call .Close() on |
| 314 each element to close the TCP handles. | 315 each element to close the TCP handles. |
| 315 | 316 |
| 316 Arguments: | 317 Arguments: |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 return out | 979 return out |
| 979 | 980 |
| 980 @classmethod | 981 @classmethod |
| 981 def _Connect(cls, constructor, **kwargs): | 982 def _Connect(cls, constructor, **kwargs): |
| 982 """Called by either ConnectDevice or Connect.""" | 983 """Called by either ConnectDevice or Connect.""" |
| 983 if not kwargs.get('rsa_keys'): | 984 if not kwargs.get('rsa_keys'): |
| 984 with _ADB_KEYS_LOCK: | 985 with _ADB_KEYS_LOCK: |
| 985 kwargs['rsa_keys'] = _ADB_KEYS[:] | 986 kwargs['rsa_keys'] = _ADB_KEYS[:] |
| 986 device = constructor(**kwargs) | 987 device = constructor(**kwargs) |
| 987 return HighDevice(device, _InitCache(device)) | 988 return HighDevice(device, _InitCache(device)) |
| OLD | NEW |