Short fix for changing return type of constructClipboardHeader
Due to the small refactoring, errorprone catched using array() method
Bug: 349702327
Test: m
Change-Id: I7dc7fb7f9f83eb31984ae48f5e74dc1ab349238f
diff --git a/vmlauncher_app/java/com/android/virtualization/vmlauncher/MainActivity.java b/vmlauncher_app/java/com/android/virtualization/vmlauncher/MainActivity.java
index dd0766b..cf83bff 100644
--- a/vmlauncher_app/java/com/android/virtualization/vmlauncher/MainActivity.java
+++ b/vmlauncher_app/java/com/android/virtualization/vmlauncher/MainActivity.java
@@ -486,13 +486,13 @@
// Byte 0: Data type
// Byte 1-3: Padding alignment & Reserved for other use cases in the future
// Byte 4-7: Data size of the payload
- private ByteBuffer constructClipboardHeader(byte type, int dataSize) {
+ private byte[] constructClipboardHeader(byte type, int dataSize) {
ByteBuffer header = ByteBuffer.allocate(8);
header.clear();
header.order(ByteOrder.LITTLE_ENDIAN);
header.put(0, type);
header.putInt(4, dataSize);
- return header;
+ return header.array();
}
private ParcelFileDescriptor connectClipboardSharingServer() {
@@ -515,7 +515,7 @@
}
ClipData clip = clipboardManager.getPrimaryClip();
String text = clip.getItemAt(0).getText().toString();
- ByteBuffer header =
+ byte[] header =
constructClipboardHeader(
WRITE_CLIPBOARD_TYPE_TEXT_PLAIN, text.getBytes().length + 1);
ParcelFileDescriptor pfd = connectClipboardSharingServer();
@@ -524,7 +524,7 @@
return false;
}
try (OutputStream stream = new AutoCloseOutputStream(pfd)) {
- stream.write(header.array());
+ stream.write(header);
stream.write(text.getBytes());
stream.flush();
Log.d(TAG, "successfully wrote clipboard data to the VM");
@@ -536,14 +536,14 @@
}
private boolean readClipboardFromVm() {
- ByteBuffer request = constructClipboardHeader(READ_CLIPBOARD_FROM_VM, 0);
+ byte[] request = constructClipboardHeader(READ_CLIPBOARD_FROM_VM, 0);
ParcelFileDescriptor pfd = connectClipboardSharingServer();
if (pfd == null) {
Log.d(TAG, "file descriptor of ClipboardSharingServer is null");
return false;
}
try (OutputStream output = new AutoCloseOutputStream(pfd)) {
- output.write(request.array());
+ output.write(request);
output.flush();
Log.d(TAG, "successfully send request to the VM for reading clipboard");
} catch (IOException e) {