mirror of
https://github.com/revanced/jadb.git
synced 2025-02-11 09:36:48 +01:00
AdbProtocolHandler: extract SyncTransport creation
This commit is contained in:
parent
5750321eaa
commit
ebf5d6b223
@ -77,7 +77,7 @@ class AdbProtocolHandler implements Runnable {
|
||||
try {
|
||||
sync(output, input);
|
||||
} catch (JadbException e) { // sync response with a different type of fail message
|
||||
SyncTransport sync = new SyncTransport(output, input);
|
||||
SyncTransport sync = getSyncTransport(output, input);
|
||||
sync.send("FAIL", e.getMessage());
|
||||
}
|
||||
} else if (command.startsWith("shell:")) {
|
||||
@ -148,14 +148,14 @@ class AdbProtocolHandler implements Runnable {
|
||||
path = remotePath.substring(0, idx);
|
||||
mode = Integer.parseInt(remotePath.substring(idx + 1));
|
||||
}
|
||||
SyncTransport transport = new SyncTransport(output, input);
|
||||
SyncTransport transport = getSyncTransport(output, input);
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
transport.readChunksTo(buffer);
|
||||
selected.filePushed(new RemoteFile(path), mode, buffer);
|
||||
transport.sendStatus("OKAY", 0); // 0 = ignored
|
||||
} else if ("RECV".equals(id)) {
|
||||
String remotePath = readString(input, length);
|
||||
SyncTransport transport = new SyncTransport(output, input);
|
||||
SyncTransport transport = getSyncTransport(output, input);
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
selected.filePulled(new RemoteFile(remotePath), buffer);
|
||||
transport.sendStream(new ByteArrayInputStream(buffer.toByteArray()));
|
||||
@ -171,4 +171,8 @@ class AdbProtocolHandler implements Runnable {
|
||||
writer.writeBytes(getCommandLength(response));
|
||||
writer.writeBytes(response);
|
||||
}
|
||||
|
||||
private SyncTransport getSyncTransport(DataOutput output, DataInput input) {
|
||||
return new SyncTransport(output, input);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user