OSDN Git Service

Merge "Fix crashes in btif_sendmsg when worqueue not initialized" into nyc-dev
[android-x86/system-bt.git] / vendor_libs / linux / bt_vendor_linux.c
index be4fa7c..41abc8a 100644 (file)
 #include <sys/socket.h>
 #include <sys/ioctl.h>
 
-#include <cutils/properties.h>
-
 #include "hci/include/bt_vendor_lib.h"
 #include "osi/include/log.h"
+#include "osi/include/properties.h"
 
 #define BTPROTO_HCI     1
 #define HCI_CHANNEL_USER        1
@@ -101,7 +100,7 @@ static int bt_vendor_init(const bt_vendor_callbacks_t *p_cb,
   memcpy(bt_vendor_local_bdaddr, local_bdaddr,
          sizeof(bt_vendor_local_bdaddr));
 
-  property_get("bluetooth.interface", prop_value, "0");
+  osi_property_get("bluetooth.interface", prop_value, "0");
 
   errno = 0;
   if (memcmp(prop_value, "hci", 3))
@@ -113,13 +112,13 @@ static int bt_vendor_init(const bt_vendor_callbacks_t *p_cb,
 
   LOG_INFO(LOG_TAG, "Using interface hci%d", hci_interface);
 
-  property_get("bluetooth.rfkill", prop_value, "0");
+  osi_property_get("bluetooth.rfkill", prop_value, "0");
 
   rfkill_en = atoi(prop_value);
   if (rfkill_en)
     LOG_INFO(LOG_TAG, "RFKILL enabled");
 
-  bt_hwcfg_en = property_get("bluetooth.hwcfg",
+  bt_hwcfg_en = osi_property_get("bluetooth.hwcfg",
                              prop_value, NULL) > 0 ? 1 : 0;
   if (bt_hwcfg_en)
     LOG_INFO(LOG_TAG, "HWCFG enabled");
@@ -133,12 +132,12 @@ static int bt_vendor_hw_cfg(int stop)
     return 0;
 
   if (stop) {
-    if (property_set("bluetooth.hwcfg", "stop") < 0) {
+    if (osi_property_set("bluetooth.hwcfg", "stop") < 0) {
       LOG_ERROR(LOG_TAG, "%s cannot stop btcfg service via prop", __func__);
       return 1;
     }
   } else {
-    if (property_set("bluetooth.hwcfg", "start") < 0) {
+    if (osi_property_set("bluetooth.hwcfg", "start") < 0) {
       LOG_ERROR(LOG_TAG, "%s cannot start btcfg service via prop", __func__);
       return 1;
     }
@@ -180,14 +179,18 @@ static int bt_vendor_wait_hcidev(void)
   ev.opcode = MGMT_OP_INDEX_LIST;
   ev.index = HCI_DEV_NONE;
   ev.len = 0;
-  if (write(fd, &ev, 6) != 6) {
+
+  ssize_t wrote;
+  OSI_NO_INTR(wrote = write(fd, &ev, 6));
+  if (wrote != 6) {
     LOG_ERROR(LOG_TAG, "Unable to write mgmt command: %s", strerror(errno));
     ret = -1;
     goto end;
   }
 
   while (1) {
-    int n = poll(fds, 1, MGMT_EV_POLL_TIMEOUT);
+    int n;
+    OSI_NO_INTR(n = poll(fds, 1, MGMT_EV_POLL_TIMEOUT));
     if (n == -1) {
       LOG_ERROR(LOG_TAG, "Poll error: %s", strerror(errno));
       ret = -1;
@@ -199,10 +202,10 @@ static int bt_vendor_wait_hcidev(void)
     }
 
     if (fds[0].revents & POLLIN) {
-      n = read(fd, &ev, sizeof(struct mgmt_pkt));
+      OSI_NO_INTR(n = read(fd, &ev, sizeof(struct mgmt_pkt)));
       if (n < 0) {
-        LOG_ERROR(LOG_TAG,
-                  "Error reading control channel");
+        LOG_ERROR(LOG_TAG, "Error reading control channel: %s",
+                  strerror(errno));
         ret = -1;
         break;
       }
@@ -273,7 +276,7 @@ static int bt_vendor_close(void *param)
 static int bt_vendor_rfkill(int block)
 {
   struct rfkill_event event;
-  int fd, len;
+  int fd;
 
   LOG_INFO(LOG_TAG, "%s", __func__);
 
@@ -289,7 +292,8 @@ static int bt_vendor_rfkill(int block)
   event.hard = block;
   event.soft = block;
 
-  len = write(fd, &event, sizeof(event));
+  ssize_t len;
+  OSI_NO_INTR(len = write(fd, &event, sizeof(event)));
   if (len < 0) {
     LOG_ERROR(LOG_TAG, "Failed to change rfkill state");
     close(fd);
@@ -411,7 +415,7 @@ static void bt_vendor_cleanup(void)
   bt_vendor_callbacks = NULL;
 }
 
-const bt_vendor_interface_t BLUETOOTH_VENDOR_LIB_INTERFACE = {
+EXPORT_SYMBOL const bt_vendor_interface_t BLUETOOTH_VENDOR_LIB_INTERFACE = {
   sizeof(bt_vendor_interface_t),
   bt_vendor_init,
   bt_vendor_op,