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
diff --git a/core/jni/android_server_BluetoothService.cpp b/core/jni/android_server_BluetoothService.cpp
index 2aeca86..9dbe774 100644
--- a/core/jni/android_server_BluetoothService.cpp
+++ b/core/jni/android_server_BluetoothService.cpp
@@ -1645,6 +1645,25 @@
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) {