Merge remote-tracking branch 'goog/ics-aah'
diff --git a/bluedroid/bluetooth.c b/bluedroid/bluetooth.c
index 4cc9204..ee104c9 100644
--- a/bluedroid/bluetooth.c
+++ b/bluedroid/bluetooth.c
@@ -18,6 +18,7 @@
 
 #include <errno.h>
 #include <fcntl.h>
+#include <stdlib.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <sys/types.h>
@@ -55,7 +56,7 @@
         snprintf(path, sizeof(path), "/sys/class/rfkill/rfkill%d/type", id);
         fd = open(path, O_RDONLY);
         if (fd < 0) {
-            LOGW("open(%s) failed: %s (%d)\n", path, strerror(errno), errno);
+            ALOGW("open(%s) failed: %s (%d)\n", path, strerror(errno), errno);
             return -1;
         }
         sz = read(fd, &buf, sizeof(buf));
@@ -82,13 +83,13 @@
 
     fd = open(rfkill_state_path, O_RDONLY);
     if (fd < 0) {
-        LOGE("open(%s) failed: %s (%d)", rfkill_state_path, strerror(errno),
+        ALOGE("open(%s) failed: %s (%d)", rfkill_state_path, strerror(errno),
              errno);
         goto out;
     }
     sz = read(fd, &buffer, 1);
     if (sz != 1) {
-        LOGE("read(%s) failed: %s (%d)", rfkill_state_path, strerror(errno),
+        ALOGE("read(%s) failed: %s (%d)", rfkill_state_path, strerror(errno),
              errno);
         goto out;
     }
@@ -119,13 +120,13 @@
 
     fd = open(rfkill_state_path, O_WRONLY);
     if (fd < 0) {
-        LOGE("open(%s) for write failed: %s (%d)", rfkill_state_path,
+        ALOGE("open(%s) for write failed: %s (%d)", rfkill_state_path,
              strerror(errno), errno);
         goto out;
     }
     sz = write(fd, &buffer, 1);
     if (sz < 0) {
-        LOGE("write(%s) failed: %s (%d)", rfkill_state_path, strerror(errno),
+        ALOGE("write(%s) failed: %s (%d)", rfkill_state_path, strerror(errno),
              errno);
         goto out;
     }
@@ -139,14 +140,14 @@
 static inline int create_hci_sock() {
     int sk = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
     if (sk < 0) {
-        LOGE("Failed to create bluetooth hci socket: %s (%d)",
+        ALOGE("Failed to create bluetooth hci socket: %s (%d)",
              strerror(errno), errno);
     }
     return sk;
 }
 
 int bt_enable() {
-    LOGV(__FUNCTION__);
+    ALOGV(__FUNCTION__);
 
     int ret = -1;
     int hci_sock = -1;
@@ -154,9 +155,9 @@
 
     if (set_bluetooth_power(1) < 0) goto out;
 
-    LOGI("Starting hciattach daemon");
+    ALOGI("Starting hciattach daemon");
     if (property_set("ctl.start", "hciattach") < 0) {
-        LOGE("Failed to start hciattach");
+        ALOGE("Failed to start hciattach");
         set_bluetooth_power(0);
         goto out;
     }
@@ -169,11 +170,11 @@
 
         ret = ioctl(hci_sock, HCIDEVUP, HCI_DEV_ID);
 
-        LOGI("bt_enable: ret: %d, errno: %d", ret, errno);
+        ALOGI("bt_enable: ret: %d, errno: %d", ret, errno);
         if (!ret) {
             break;
         } else if (errno == EALREADY) {
-            LOGW("Bluetoothd already started, unexpectedly!");
+            ALOGW("Bluetoothd already started, unexpectedly!");
             break;
         }
 
@@ -181,18 +182,18 @@
         usleep(100000);  // 100 ms retry delay
     }
     if (attempt == 0) {
-        LOGE("%s: Timeout waiting for HCI device to come up, error- %d, ",
+        ALOGE("%s: Timeout waiting for HCI device to come up, error- %d, ",
             __FUNCTION__, ret);
         if (property_set("ctl.stop", "hciattach") < 0) {
-            LOGE("Error stopping hciattach");
+            ALOGE("Error stopping hciattach");
         }
         set_bluetooth_power(0);
         goto out;
     }
 
-    LOGI("Starting bluetoothd deamon");
+    ALOGI("Starting bluetoothd deamon");
     if (property_set("ctl.start", "bluetoothd") < 0) {
-        LOGE("Failed to start bluetoothd");
+        ALOGE("Failed to start bluetoothd");
         set_bluetooth_power(0);
         goto out;
     }
@@ -205,14 +206,14 @@
 }
 
 int bt_disable() {
-    LOGV(__FUNCTION__);
+    ALOGV(__FUNCTION__);
 
     int ret = -1;
     int hci_sock = -1;
 
-    LOGI("Stopping bluetoothd deamon");
+    ALOGI("Stopping bluetoothd deamon");
     if (property_set("ctl.stop", "bluetoothd") < 0) {
-        LOGE("Error stopping bluetoothd");
+        ALOGE("Error stopping bluetoothd");
         goto out;
     }
     usleep(HCID_STOP_DELAY_USEC);
@@ -221,9 +222,9 @@
     if (hci_sock < 0) goto out;
     ioctl(hci_sock, HCIDEVDOWN, HCI_DEV_ID);
 
-    LOGI("Stopping hciattach deamon");
+    ALOGI("Stopping hciattach deamon");
     if (property_set("ctl.stop", "hciattach") < 0) {
-        LOGE("Error stopping hciattach");
+        ALOGE("Error stopping hciattach");
         goto out;
     }
 
@@ -238,7 +239,7 @@
 }
 
 int bt_is_enabled() {
-    LOGV(__FUNCTION__);
+    ALOGV(__FUNCTION__);
 
     int hci_sock = -1;
     int ret = -1;
@@ -280,7 +281,7 @@
 int str2ba(const char *str, bdaddr_t *ba) {
     int i;
     for (i = 5; i >= 0; i--) {
-        ba->b[i] = (uint8_t) strtoul(str, &str, 16);
+        ba->b[i] = (uint8_t) strtoul(str, (char **) &str, 16);
         str++;
     }
     return 0;
diff --git a/brcm_patchram_plus/brcm_patchram_plus.c b/brcm_patchram_plus/brcm_patchram_plus.c
index 3aa5d24..65a9b31 100644
--- a/brcm_patchram_plus/brcm_patchram_plus.c
+++ b/brcm_patchram_plus/brcm_patchram_plus.c
@@ -130,10 +130,10 @@
 #define LOG_TAG "brcm_patchram_plus"
 #include <cutils/log.h>
 #undef printf
-#define printf LOGD
+#define printf ALOGD
 #undef fprintf
 #define fprintf(x, ...) \
-  { if(x==stderr) LOGE(__VA_ARGS__); else fprintf(x, __VA_ARGS__); }
+  { if(x==stderr) ALOGE(__VA_ARGS__); else fprintf(x, __VA_ARGS__); }
 
 #endif //ANDROID