diff --git a/src/se/vidstige/jadb/server/AdbProtocolHandler.java b/src/se/vidstige/jadb/server/AdbProtocolHandler.java index fffbed4..c541904 100644 --- a/src/se/vidstige/jadb/server/AdbProtocolHandler.java +++ b/src/se/vidstige/jadb/server/AdbProtocolHandler.java @@ -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); + } }