summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <treehugger-gerrit@google.com> 2021-03-15 20:49:30 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2021-03-15 20:49:30 +0000
commitf97ab8c413b677d21b8cbda2e66b91200d80e1e4 (patch)
treef69abc5f27a478d4c5db1b1e3f07c018eeb3de30
parentfa31d37ac7cfbd75a546619ec154e5bd1503dcfd (diff)
parentac9b08281c8c437798353700be833b0a31bb0119 (diff)
Merge "Emulator cleanup in ClipboardService.java"
-rw-r--r--services/core/java/com/android/server/clipboard/ClipboardService.java24
1 files changed, 12 insertions, 12 deletions
diff --git a/services/core/java/com/android/server/clipboard/ClipboardService.java b/services/core/java/com/android/server/clipboard/ClipboardService.java
index ed3a223b5dd7..d2b642c21713 100644
--- a/services/core/java/com/android/server/clipboard/ClipboardService.java
+++ b/services/core/java/com/android/server/clipboard/ClipboardService.java
@@ -65,6 +65,7 @@ import com.android.server.wm.WindowManagerInternal;
import java.io.IOException;
import java.io.RandomAccessFile;
+import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
@@ -80,21 +81,20 @@ class HostClipboardMonitor implements Runnable {
private static final String PIPE_NAME = "pipe:clipboard";
private static final String PIPE_DEVICE = "/dev/qemu_pipe";
+ private static byte[] createOpenHandshake() {
+ // String.getBytes doesn't include the null terminator,
+ // but the QEMU pipe device requires the pipe service name
+ // to be null-terminated.
+
+ final byte[] bits = Arrays.copyOf(PIPE_NAME.getBytes(), PIPE_NAME.length() + 1);
+ bits[PIPE_NAME.length()] = 0;
+ return bits;
+ }
+
private void openPipe() {
try {
- // String.getBytes doesn't include the null terminator,
- // but the QEMU pipe device requires the pipe service name
- // to be null-terminated.
- byte[] b = new byte[PIPE_NAME.length() + 1];
- b[PIPE_NAME.length()] = 0;
- System.arraycopy(
- PIPE_NAME.getBytes(),
- 0,
- b,
- 0,
- PIPE_NAME.length());
mPipe = new RandomAccessFile(PIPE_DEVICE, "rw");
- mPipe.write(b);
+ mPipe.write(createOpenHandshake());
} catch (IOException e) {
try {
if (mPipe != null) mPipe.close();