summaryrefslogtreecommitdiff
path: root/core/java/android/net/LocalSocketImpl.java
diff options
context:
space:
mode:
authorzzy <zhenye@broadcom.com>2013-04-16 17:17:37 -0700
committerMatthew Xie <mattx@google.com>2013-04-24 00:24:34 -0700
commit71bfafc84af4b820748b12e1a1010b0dfa7bdea6 (patch)
tree68d7af239f31abb6ebb440b72fad3c2b51ca48be /core/java/android/net/LocalSocketImpl.java
parent51f7ca4521c3508a233eefe97f53092213eacb60 (diff)
Added flush() for bluetooth output stream
Bug 8498784 Zebra QL420 Plus Bluetooth printer fails on Android 4.2.2
Diffstat (limited to 'core/java/android/net/LocalSocketImpl.java')
-rw-r--r--core/java/android/net/LocalSocketImpl.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/core/java/android/net/LocalSocketImpl.java b/core/java/android/net/LocalSocketImpl.java
index 6c36a7d62ff3..8e129cb53f60 100644
--- a/core/java/android/net/LocalSocketImpl.java
+++ b/core/java/android/net/LocalSocketImpl.java
@@ -136,8 +136,28 @@ class LocalSocketImpl
write_native(b, myFd);
}
}
+
+ /**
+ * Wait until the data in sending queue is emptied. A polling version
+ * for flush implementation.
+ * @throws IOException
+ * if an i/o error occurs.
+ */
+ @Override
+ public void flush() throws IOException {
+ FileDescriptor myFd = fd;
+ if (myFd == null) throw new IOException("socket closed");
+ while(pending_native(fd) > 0) {
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException ie) {
+ return;
+ }
+ }
+ }
}
+ private native int pending_native(FileDescriptor fd) throws IOException;
private native int available_native(FileDescriptor fd) throws IOException;
private native void close_native(FileDescriptor fd) throws IOException;
private native int read_native(FileDescriptor fd) throws IOException;