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

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

Change-Id: Ibb0ffb33f4659bf50b2895834bb6856ef66e0958
This commit is contained in:
Treehugger Robot
2021-03-23 14:04:19 +00:00
committed by Automerger Merge Worker

View File

@@ -121,6 +121,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;
} }
@@ -142,10 +153,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) {}
} }
} }