diff options
author | zzy <zhenye@broadcom.com> | 2013-04-16 17:17:37 -0700 |
---|---|---|
committer | Matthew Xie <mattx@google.com> | 2013-04-24 00:24:34 -0700 |
commit | 71bfafc84af4b820748b12e1a1010b0dfa7bdea6 (patch) | |
tree | 68d7af239f31abb6ebb440b72fad3c2b51ca48be /core/java/android/bluetooth/BluetoothSocket.java | |
parent | 51f7ca4521c3508a233eefe97f53092213eacb60 (diff) | |
download | frameworks_base-71bfafc84af4b820748b12e1a1010b0dfa7bdea6.zip frameworks_base-71bfafc84af4b820748b12e1a1010b0dfa7bdea6.tar.gz frameworks_base-71bfafc84af4b820748b12e1a1010b0dfa7bdea6.tar.bz2 |
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/bluetooth/BluetoothSocket.java')
-rw-r--r-- | core/java/android/bluetooth/BluetoothSocket.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/java/android/bluetooth/BluetoothSocket.java b/core/java/android/bluetooth/BluetoothSocket.java index 8029a1a..a19341c 100644 --- a/core/java/android/bluetooth/BluetoothSocket.java +++ b/core/java/android/bluetooth/BluetoothSocket.java @@ -192,6 +192,7 @@ public final class BluetoothSocket implements Closeable { if (VDBG) Log.d(TAG, "socket fd passed by stack fds: " + fds); if(fds == null || fds.length != 1) { Log.e(TAG, "socket fd passed from stack failed, fds: " + fds); + as.close(); throw new IOException("bt socket acept failed"); } as.mSocket = new LocalSocket(fds[0]); @@ -407,6 +408,17 @@ public final class BluetoothSocket implements Closeable { if (VDBG) Log.d(TAG, "available: " + mSocketIS); return mSocketIS.available(); } + /** + * Wait until the data in sending queue is emptied. A polling version + * for flush implementation. Used to ensure the writing data afterwards will + * be packed in new RFCOMM frame. + * @throws IOException + * if an i/o error occurs. + */ + /*package*/ void flush() throws IOException { + if (VDBG) Log.d(TAG, "flush: " + mSocketOS); + mSocketOS.flush(); + } /*package*/ int read(byte[] b, int offset, int length) throws IOException { |