Merge "Short fix for changing return type of constructClipboardHeader" into main
diff --git a/vmlauncher_app/java/com/android/virtualization/vmlauncher/MainActivity.java b/vmlauncher_app/java/com/android/virtualization/vmlauncher/MainActivity.java
index 22adac2..ef94be5 100644
--- a/vmlauncher_app/java/com/android/virtualization/vmlauncher/MainActivity.java
+++ b/vmlauncher_app/java/com/android/virtualization/vmlauncher/MainActivity.java
@@ -506,13 +506,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() {
@@ -535,7 +535,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();
@@ -544,7 +544,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");
@@ -556,14 +556,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) {