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/jni | |
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/jni')
-rw-r--r-- | core/jni/android_net_LocalSocketImpl.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/core/jni/android_net_LocalSocketImpl.cpp b/core/jni/android_net_LocalSocketImpl.cpp index 1426b2c..f2b69c6 100644 --- a/core/jni/android_net_LocalSocketImpl.cpp +++ b/core/jni/android_net_LocalSocketImpl.cpp @@ -371,7 +371,31 @@ static void socket_setOption( return; } } +static jint socket_pending (JNIEnv *env, jobject object, + jobject fileDescriptor) +{ + int fd; + + fd = jniGetFDFromFileDescriptor(env, fileDescriptor); + + if (env->ExceptionOccurred() != NULL) { + return (jint)-1; + } + + int pending; + int ret = ioctl(fd, TIOCOUTQ, &pending); + // If this were a non-socket fd, there would be other cases to worry + // about... + + //ALOGD("socket_pending, ioctl ret:%d, pending:%d", ret, pending); + if (ret < 0) { + jniThrowIOException(env, errno); + return (jint) 0; + } + + return (jint)pending; +} static jint socket_available (JNIEnv *env, jobject object, jobject fileDescriptor) { @@ -893,6 +917,7 @@ static JNINativeMethod gMethods[] = { {"accept", "(Ljava/io/FileDescriptor;Landroid/net/LocalSocketImpl;)Ljava/io/FileDescriptor;", (void*)socket_accept}, {"shutdown", "(Ljava/io/FileDescriptor;Z)V", (void*)socket_shutdown}, {"available_native", "(Ljava/io/FileDescriptor;)I", (void*) socket_available}, + {"pending_native", "(Ljava/io/FileDescriptor;)I", (void*) socket_pending}, {"close_native", "(Ljava/io/FileDescriptor;)V", (void*) socket_close}, {"read_native", "(Ljava/io/FileDescriptor;)I", (void*) socket_read}, {"readba_native", "([BIILjava/io/FileDescriptor;)I", (void*) socket_readba}, |