Merge "Emulator cleanup in ClipboardService.java (closePipe)" am: 43a464cb70

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

Change-Id: I003e714fce002d63fb9a37fec0194b99a59102d0
This commit is contained in:
Treehugger Robot
2021-03-23 08:44:12 +00:00
committed by Automerger Merge Worker

View File

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