| OLD | NEW |
| 1 # Copyright 2014 Google Inc. All rights reserved. | 1 # Copyright 2014 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Licensed under the Apache License, Version 2.0 (the "License"); | 3 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 # you may not use this file except in compliance with the License. | 4 # you may not use this file except in compliance with the License. |
| 5 # You may obtain a copy of the License at | 5 # You may obtain a copy of the License at |
| 6 # | 6 # |
| 7 # http://www.apache.org/licenses/LICENSE-2.0 | 7 # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 # | 8 # |
| 9 # Unless required by applicable law or agreed to in writing, software | 9 # Unless required by applicable law or agreed to in writing, software |
| 10 # distributed under the License is distributed on an "AS IS" BASIS, | 10 # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 # See the License for the specific language governing permissions and | 12 # See the License for the specific language governing permissions and |
| 13 # limitations under the License. | 13 # limitations under the License. |
| 14 """ADB protocol implementation. | 14 """ADB protocol implementation. |
| 15 | 15 |
| 16 Implements the ADB protocol as seen in android's adb/adbd binaries, but only the | 16 Implements the ADB protocol as seen in android's adb/adbd binaries, but only the |
| 17 host side. | 17 host side. |
| 18 """ | 18 """ |
| 19 | 19 |
| 20 import collections | 20 import collections |
| 21 import stat | 21 import stat |
| 22 import struct | 22 import struct |
| 23 import time | 23 import time |
| 24 | 24 |
| 25 import libusb1 | 25 from python_libusb1 import libusb1 |
| 26 | 26 |
| 27 import adb_protocol | 27 import adb_protocol |
| 28 import usb_exceptions | 28 import usb_exceptions |
| 29 | 29 |
| 30 # Default mode for pushed files. | 30 # Default mode for pushed files. |
| 31 DEFAULT_PUSH_MODE = stat.S_IFREG | stat.S_IRWXU | stat.S_IRWXG | 31 DEFAULT_PUSH_MODE = stat.S_IFREG | stat.S_IRWXU | stat.S_IRWXG |
| 32 # Maximum size of a filesync DATA packet. | 32 # Maximum size of a filesync DATA packet. |
| 33 MAX_PUSH_DATA = 2*1024 | 33 MAX_PUSH_DATA = 2*1024 |
| 34 | 34 |
| 35 | 35 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 def _ReadBuffered(self, size): | 211 def _ReadBuffered(self, size): |
| 212 # Ensure recv buffer has enough data. | 212 # Ensure recv buffer has enough data. |
| 213 while len(self.recv_buffer) < size: | 213 while len(self.recv_buffer) < size: |
| 214 _, data = self.adb.ReadUntil('WRTE') | 214 _, data = self.adb.ReadUntil('WRTE') |
| 215 self.recv_buffer += data | 215 self.recv_buffer += data |
| 216 | 216 |
| 217 result = self.recv_buffer[:size] | 217 result = self.recv_buffer[:size] |
| 218 self.recv_buffer = self.recv_buffer[size:] | 218 self.recv_buffer = self.recv_buffer[size:] |
| 219 return result | 219 return result |
| 220 | 220 |
| OLD | NEW |