summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Kiryanov <rkir@google.com>2022-03-03 12:59:45 -0800
committerRoman Kiryanov <rkir@google.com>2022-03-03 13:56:11 -0800
commit52ae3bd2dce9502b2204a886a09d4fdc5c5fd538 (patch)
tree8d980b36e7c3026127443738617e0d240720331b
parent0239107ed55c14a6facbe8d05e90e31c24377c5f (diff)
downloadbase-52ae3bd2dce9502b2204a886a09d4fdc5c5fd538.tar.gz
Log emulator's clipboard access to logcat
to help debugging clipboard issues. Bug: 219611030 Bug: 206758809 Test: boot the emulator with Test: `-append-userspace-opt androidboot.qemu.log_clipboard_access=1` Test: use the clipboard, check the logcat for Test: messages from EmulatorClipboardMonitor Signed-off-by: Roman Kiryanov <rkir@google.com> Change-Id: I7fc0a96560f4e9805fd3bc91cb5b40a1fc149141
-rw-r--r--services/core/java/com/android/server/clipboard/EmulatorClipboardMonitor.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/clipboard/EmulatorClipboardMonitor.java b/services/core/java/com/android/server/clipboard/EmulatorClipboardMonitor.java
index 62b701aff398..11c451e01d4c 100644
--- a/services/core/java/com/android/server/clipboard/EmulatorClipboardMonitor.java
+++ b/services/core/java/com/android/server/clipboard/EmulatorClipboardMonitor.java
@@ -18,6 +18,7 @@ package com.android.server.clipboard;
import android.annotation.Nullable;
import android.content.ClipData;
+import android.os.SystemProperties;
import android.system.ErrnoException;
import android.system.Os;
import android.system.OsConstants;
@@ -39,6 +40,8 @@ class EmulatorClipboardMonitor implements Consumer<ClipData> {
private static final String PIPE_NAME = "pipe:clipboard";
private static final int HOST_PORT = 5000;
private final Thread mHostMonitorThread;
+ private static final boolean LOG_CLIBOARD_ACCESS =
+ SystemProperties.getBoolean("ro.boot.qemu.log_clipboard_access", false);
private FileDescriptor mPipe = null;
private static byte[] createOpenHandshake() {
@@ -132,6 +135,9 @@ class EmulatorClipboardMonitor implements Consumer<ClipData> {
new String[]{"text/plain"},
new ClipData.Item(str));
+ if (LOG_CLIBOARD_ACCESS) {
+ Slog.i(TAG, "Setting the guest clipboard to '" + str + "'");
+ }
setAndroidClipboard.accept(clip);
} catch (ErrnoException | InterruptedIOException e) {
closePipe();
@@ -156,6 +162,10 @@ class EmulatorClipboardMonitor implements Consumer<ClipData> {
}
private void setHostClipboardImpl(final String value) {
+ if (LOG_CLIBOARD_ACCESS) {
+ Slog.i(TAG, "Setting the host clipboard to '" + value + "'");
+ }
+
try {
if (isPipeOpened()) {
sendMessage(value.getBytes());