mirror of
https://github.com/revanced/jadb.git
synced 2025-05-25 03:12:06 +02:00
Fixing a problem where errors during pull where not handled correctly.
This commit is contained in:
parent
c28902385f
commit
c051da8e7f
@ -70,10 +70,14 @@ class SyncTransport {
|
|||||||
output.write(buffer, offset, length);
|
output.write(buffer, offset, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int readChunk(byte[] buffer) throws IOException {
|
private int readChunk(byte[] buffer) throws IOException, JadbException {
|
||||||
String id = readString(4);
|
String id = readString(4);
|
||||||
if (!"DATA".equals(id)) return -1;
|
|
||||||
int n = readInt();
|
int n = readInt();
|
||||||
|
if ("FAIL".equals(id))
|
||||||
|
{
|
||||||
|
throw new JadbException(readString(n));
|
||||||
|
}
|
||||||
|
if (!"DATA".equals(id)) return -1;
|
||||||
return input.read(buffer, 0, n);
|
return input.read(buffer, 0, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +90,7 @@ class SyncTransport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readChunksTo(OutputStream stream) throws IOException {
|
public void readChunksTo(OutputStream stream) throws IOException, JadbException {
|
||||||
byte[] buffer = new byte[1024 * 64];
|
byte[] buffer = new byte[1024 * 64];
|
||||||
int n = readChunk(buffer);
|
int n = readChunk(buffer);
|
||||||
while (n != -1) {
|
while (n != -1) {
|
||||||
|
@ -62,4 +62,12 @@ public class RealDeviceTestCases {
|
|||||||
JadbDevice any = jadb.getAnyDevice();
|
JadbDevice any = jadb.getAnyDevice();
|
||||||
any.pull(new RemoteFile("/sdcard/README.md"), new File("foobar.md"));
|
any.pull(new RemoteFile("/sdcard/README.md"), new File("foobar.md"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected = JadbException.class)
|
||||||
|
public void testPullInvalidFile() throws Exception
|
||||||
|
{
|
||||||
|
JadbConnection jadb = new JadbConnection();
|
||||||
|
JadbDevice any = jadb.getAnyDevice();
|
||||||
|
any.pull(new RemoteFile("/file/does/not/exist"), new File("xyz"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user