Skip to content

Commit

Permalink
Merge 2931741 into 9cf4e7d
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffLIrion committed Jun 8, 2021
2 parents 9cf4e7d + 2931741 commit 6e03e36
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 12 additions & 2 deletions adb_shell/adb_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,10 +917,20 @@ def _read_until(self, expected_cmds, adb_info):
while True:
cmd, remote_id2, local_id2, data = self._read(expected_cmds, adb_info)

if local_id2 not in (0, adb_info.local_id):
# Enable streaming commands
if not adb_info.clse_received and cmd == constants.CLSE:
if adb_info.local_id == local_id2 and adb_info.remote_id == remote_id2:
# Make note that a `CLSE` packet has been received for this local ID + remote ID transaction
adb_info.clse_received = True
elif adb_info.clse_received and cmd != constants.CLSE:
# This is the start of a new transaction --> update the local ID and remote ID
adb_info.local_id = local_id2
adb_info.remote_id = remote_id2

if adb_info.local_id is not None and local_id2 not in (0, adb_info.local_id):
raise exceptions.InterleavedDataError("We don't support multiple streams...")

if remote_id2 in (0, adb_info.remote_id):
if adb_info.remote_id is not None and remote_id2 in (0, adb_info.remote_id):
break

if time.time() - start > adb_info.read_timeout_s:
Expand Down
3 changes: 3 additions & 0 deletions adb_shell/hidden_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ class _AdbTransactionInfo(object): # pylint: disable=too-few-public-methods
Attributes
----------
clse_received : bool
Whether a ``CLSE`` packet has been received
local_id : int
The ID for the sender (i.e., the device running this code)
read_timeout_s : float
Expand All @@ -137,6 +139,7 @@ def __init__(self, local_id, remote_id, transport_timeout_s=None, read_timeout_s
self.timeout_s = timeout_s
self.read_timeout_s = read_timeout_s if self.timeout_s is None else min(read_timeout_s, self.timeout_s)
self.transport_timeout_s = self.read_timeout_s if transport_timeout_s is None else min(transport_timeout_s, self.read_timeout_s)
self.clse_received = False


class _FileSyncTransactionInfo(object): # pylint: disable=too-few-public-methods
Expand Down

0 comments on commit 6e03e36

Please sign in to comment.