From 3c4b0c6997f4f096a44b112ac698dc67f6a10a86 Mon Sep 17 00:00:00 2001 From: Jano Svitok Date: Tue, 19 Feb 2019 15:32:32 +0100 Subject: [PATCH] Small fixes - replace if with switch - remove unnecessary toString() --- src/se/vidstige/jadb/JadbDevice.java | 2 +- .../jadb/server/AdbProtocolHandler.java | 20 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/se/vidstige/jadb/JadbDevice.java b/src/se/vidstige/jadb/JadbDevice.java index 3e70600..31d90a3 100644 --- a/src/se/vidstige/jadb/JadbDevice.java +++ b/src/se/vidstige/jadb/JadbDevice.java @@ -186,7 +186,7 @@ public class JadbDevice { public void push(InputStream source, long lastModified, int mode, RemoteFile remote) throws IOException, JadbException { try (Transport transport = getTransport()) { SyncTransport sync = transport.startSync(); - sync.send("SEND", remote.getPath() + "," + Integer.toString(mode)); + sync.send("SEND", remote.getPath() + "," + mode); sync.sendStream(source); diff --git a/src/se/vidstige/jadb/server/AdbProtocolHandler.java b/src/se/vidstige/jadb/server/AdbProtocolHandler.java index 2d6f112..dc27407 100644 --- a/src/se/vidstige/jadb/server/AdbProtocolHandler.java +++ b/src/se/vidstige/jadb/server/AdbProtocolHandler.java @@ -178,13 +178,19 @@ class AdbProtocolHandler implements Runnable { try { String id = readString(input, 4); int length = readInt(input); - if ("SEND".equals(id)) { - syncSend(output, input, length); - } else if ("RECV".equals(id)) { - syncRecv(output, input, length); - } else if ("LIST".equals(id)) { - syncList(output, input, length); - } else throw new JadbException("Unknown sync id " + id); + switch (id) { + case "SEND": + syncSend(output, input, length); + break; + case "RECV": + syncRecv(output, input, length); + break; + case "LIST": + syncList(output, input, length); + break; + default: + throw new JadbException("Unknown sync id " + id); + } } catch (JadbException e) { // sync response with a different type of fail message SyncTransport sync = getSyncTransport(output, input); sync.send("FAIL", e.getMessage());