Small fixes

- replace if with switch
- remove unnecessary toString()
This commit is contained in:
Jano Svitok 2019-02-19 15:32:32 +01:00
parent a6dcb3ec38
commit 3c4b0c6997
2 changed files with 14 additions and 8 deletions

View File

@ -186,7 +186,7 @@ public class JadbDevice {
public void push(InputStream source, long lastModified, int mode, RemoteFile remote) throws IOException, JadbException { public void push(InputStream source, long lastModified, int mode, RemoteFile remote) throws IOException, JadbException {
try (Transport transport = getTransport()) { try (Transport transport = getTransport()) {
SyncTransport sync = transport.startSync(); SyncTransport sync = transport.startSync();
sync.send("SEND", remote.getPath() + "," + Integer.toString(mode)); sync.send("SEND", remote.getPath() + "," + mode);
sync.sendStream(source); sync.sendStream(source);

View File

@ -178,13 +178,19 @@ class AdbProtocolHandler implements Runnable {
try { try {
String id = readString(input, 4); String id = readString(input, 4);
int length = readInt(input); int length = readInt(input);
if ("SEND".equals(id)) { switch (id) {
syncSend(output, input, length); case "SEND":
} else if ("RECV".equals(id)) { syncSend(output, input, length);
syncRecv(output, input, length); break;
} else if ("LIST".equals(id)) { case "RECV":
syncList(output, input, length); syncRecv(output, input, length);
} else throw new JadbException("Unknown sync id " + id); 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 } catch (JadbException e) { // sync response with a different type of fail message
SyncTransport sync = getSyncTransport(output, input); SyncTransport sync = getSyncTransport(output, input);
sync.send("FAIL", e.getMessage()); sync.send("FAIL", e.getMessage());