Skip to content

Instantly share code, notes, and snippets.

@Malinskiy
Created January 11, 2021 03:53
Show Gist options
  • Save Malinskiy/ca79344a66990041f63a808bf0b28242 to your computer and use it in GitHub Desktop.
Save Malinskiy/ca79344a66990041f63a808bf0b28242 to your computer and use it in GitHub Desktop.
private ByteArrayOutputStream mPendingData = new ByteArrayOutputStream();
public void addOutput(byte[] data, int offset, int length) {
mPendingData.write(data, offset, length);
try {
InstrumentationData.Session session =
InstrumentationData.Session.parseFrom(mPendingData.toByteArray());
mPendingData.reset();
updateState(session);
}
catch (InvalidProtocolBufferException e) {
// InvalidProtocolBufferException may happen if a given new output data is incomplete.
// Let's just skip updating mSession and wait for incoming data.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment