Merge "Emulator cleanup in ClipboardService.java (openPipe)" am: 003db3a53e am: e6e19e0c2c am: d5f8f2f06a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1634487 Change-Id: I8adf83784f0e61af39932a4fd6239cf5ff3e2369
This commit is contained in:
@@ -106,16 +106,19 @@ class HostClipboardMonitor implements Runnable {
|
||||
return bits;
|
||||
}
|
||||
|
||||
private void openPipe() {
|
||||
private boolean openPipe() {
|
||||
try {
|
||||
mPipe = new RandomAccessFile(PIPE_DEVICE, "rw");
|
||||
mPipe.write(createOpenHandshake());
|
||||
} catch (IOException e) {
|
||||
final RandomAccessFile pipe = new RandomAccessFile(PIPE_DEVICE, "rw");
|
||||
try {
|
||||
if (mPipe != null) mPipe.close();
|
||||
} catch (IOException ee) {}
|
||||
mPipe = null;
|
||||
pipe.write(createOpenHandshake());
|
||||
mPipe = pipe;
|
||||
return true;
|
||||
} catch (IOException ignore) {
|
||||
pipe.close();
|
||||
}
|
||||
} catch (IOException ignore) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public HostClipboardMonitor(HostClipboardCallback cb) {
|
||||
@@ -129,8 +132,7 @@ class HostClipboardMonitor implements Runnable {
|
||||
// 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
|
||||
// retry on failure indefinitely.
|
||||
while (mPipe == null) {
|
||||
openPipe();
|
||||
while ((mPipe == null) && !openPipe()) {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
int size = mPipe.readInt();
|
||||
|
||||
Reference in New Issue
Block a user