summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jaikumar Ganesh <jaikumar@google..com> 2011-12-14 10:25:55 -0800
committer Jaikumar Ganesh <jaikumar@google.com> 2011-12-14 14:00:44 -0800
commit82477b5e3cfe4bca1e3611c136dbe701ca8f603c (patch)
treed5b2a9b7c8a455c18a348b3abfbd90231da65f96
parent78137d77991f129b349b258474ef8b5133b300d9 (diff)
Change the fd to be blocking for health profile.
This is sync with the java IO stream APIs for the public APIs. Change-Id: I5c7958687275d89257ac26f6a5abd08906327d02
-rw-r--r--core/jni/android_server_BluetoothService.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/core/jni/android_server_BluetoothService.cpp b/core/jni/android_server_BluetoothService.cpp
index 2aeca86d7828..9dbe77422f8a 100644
--- a/core/jni/android_server_BluetoothService.cpp
+++ b/core/jni/android_server_BluetoothService.cpp
@@ -1645,6 +1645,25 @@ static jobject getChannelFdNative(JNIEnv *env, jobject object, jstring channelPa
fd = dbus_returns_unixfd(env, reply);
if (fd == -1) return NULL;
+ int flags = fcntl(fd, F_GETFL);
+ if (flags < 0) {
+ LOGE("Can't get flags with fcntl(): %s (%d)",
+ strerror(errno), errno);
+ releaseChannelFdNative(env, object, channelPath);
+ close(fd);
+ return NULL;
+ }
+
+ flags &= ~O_NONBLOCK;
+ int status = fcntl(fd, F_SETFL, flags);
+ if (status < 0) {
+ LOGE("Can't set flags with fcntl(): %s (%d)",
+ strerror(errno), errno);
+ releaseChannelFdNative(env, object, channelPath);
+ close(fd);
+ return NULL;
+ }
+
// Create FileDescriptor object
jobject fileDesc = jniCreateFileDescriptor(env, fd);
if (fileDesc == NULL) {