Merge "Emulator cleanup in ClipboardService.java (openPipe)" am: 003db3a53e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1634487 Change-Id: If63c59524daf8b2765e85daa473f7385bbb52909
This commit is contained in:
@@ -91,16 +91,19 @@ class HostClipboardMonitor implements Runnable {
|
|||||||
return bits;
|
return bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openPipe() {
|
private boolean openPipe() {
|
||||||
try {
|
try {
|
||||||
mPipe = new RandomAccessFile(PIPE_DEVICE, "rw");
|
final RandomAccessFile pipe = new RandomAccessFile(PIPE_DEVICE, "rw");
|
||||||
mPipe.write(createOpenHandshake());
|
|
||||||
} catch (IOException e) {
|
|
||||||
try {
|
try {
|
||||||
if (mPipe != null) mPipe.close();
|
pipe.write(createOpenHandshake());
|
||||||
} catch (IOException ee) {}
|
mPipe = pipe;
|
||||||
mPipe = null;
|
return true;
|
||||||
|
} catch (IOException ignore) {
|
||||||
|
pipe.close();
|
||||||
|
}
|
||||||
|
} catch (IOException ignore) {
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HostClipboardMonitor(HostClipboardCallback cb) {
|
public HostClipboardMonitor(HostClipboardCallback cb) {
|
||||||
@@ -114,8 +117,7 @@ class HostClipboardMonitor implements Runnable {
|
|||||||
// There's no guarantee that QEMU pipes will be ready at the moment
|
// There's no guarantee that QEMU pipes will be ready at the moment
|
||||||
// this method is invoked. We simply try to get the pipe open and
|
// this method is invoked. We simply try to get the pipe open and
|
||||||
// retry on failure indefinitely.
|
// retry on failure indefinitely.
|
||||||
while (mPipe == null) {
|
while ((mPipe == null) && !openPipe()) {
|
||||||
openPipe();
|
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
}
|
}
|
||||||
int size = mPipe.readInt();
|
int size = mPipe.readInt();
|
||||||
|
|||||||
Reference in New Issue
Block a user