Merge "Emulator cleanup in ClipboardService.java (closePipe)" am: 43a464cb70 am: 828f46619b am: 5803e055b9 am: 47bc18bd45

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1634488

Change-Id: I318b558bab8fbe2dcde7d618115d5e27694adfab
This commit is contained in:
Treehugger Robot
2021-03-23 14:37:25 +00:00
committed by Automerger Merge Worker

View File

@@ -121,6 +121,17 @@ class HostClipboardMonitor implements Runnable {
return false;
}
private void closePipe() {
try {
final RandomAccessFile pipe = mPipe;
mPipe = null;
if (pipe != null) {
pipe.close();
}
} catch (IOException ignore) {
}
}
public HostClipboardMonitor(HostClipboardCallback cb) {
mHostClipboardCallback = cb;
}
@@ -142,10 +153,7 @@ class HostClipboardMonitor implements Runnable {
mHostClipboardCallback.onHostClipboardUpdated(
new String(receivedData));
} catch (IOException e) {
try {
mPipe.close();
} catch (IOException ee) {}
mPipe = null;
closePipe();
} catch (InterruptedException e) {}
}
}