Diff between 0ff83edff0c13fcea2a2a1b21365867fd01e098a and bc5b5fdf13f67fb2af564aba802ea498bb8c288b

Changed Files

File Additions Deletions Status
android/Android.mk +2 -1 modified
android/bluetoothd-wrapper.c +5 -8 modified
android/hal-bluetooth.c +9 -15 modified
android/hal-handsfree.c +7 -8 modified

Full Patch

diff --git a/android/Android.mk b/android/Android.mk
index 4a14474..db5032d 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -636,7 +636,8 @@ ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	bluez/android/bluetoothd-wrapper.c
+	bluez/android/bluetoothd-wrapper.c \
+	bluez/android/hal-utils.c
 
 LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
 
diff --git a/android/bluetoothd-wrapper.c b/android/bluetoothd-wrapper.c
index 90ed292..5e15dd8 100644
--- a/android/bluetoothd-wrapper.c
+++ b/android/bluetoothd-wrapper.c
@@ -19,14 +19,11 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <stdbool.h>
 
 #include <cutils/properties.h>
 
-#define PROPERTY_VALGRIND_NAME "persist.sys.bluetooth.valgrind"
-
-#define PROPERTY_DEBUG_NAME "persist.sys.bluetooth.debug"
-
-#define PROPERTY_MGMT_DEBUG_NAME "persist.sys.bluetooth.mgmtdbg"
+#include "hal-utils.h"
 
 #define VALGRIND_BIN "/system/bin/valgrind"
 
@@ -73,17 +70,17 @@ int main(int argc, char *argv[])
 	int debug = 0;
 	int mgmt_dbg = 0;
 
-	if (property_get(PROPERTY_DEBUG_NAME, value, "") > 0 &&
+	if (get_config("debug", value, NULL) > 0 &&
 			(!strcasecmp(value, "true") || atoi(value) > 0))
 			debug = 1;
 
-	if (property_get(PROPERTY_MGMT_DEBUG_NAME, value, "") > 0 &&
+	if (get_config("mgmtdbg", value, NULL) > 0 &&
 			(!strcasecmp(value, "true") || atoi(value) > 0)) {
 			debug = 1;
 			mgmt_dbg = 1;
 	}
 
-	if (property_get(PROPERTY_VALGRIND_NAME, value, "") > 0 &&
+	if (get_config("valgrind", value, NULL) > 0 &&
 			(!strcasecmp(value, "true") || atoi(value) > 0))
 		run_valgrind(debug, mgmt_dbg);
 
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 7c86b4f..db735d1 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -29,12 +29,6 @@
 #include "hal-ipc.h"
 #include "hal-utils.h"
 
-#define MODE_PROPERTY_NAME "persist.sys.bluetooth.mode"
-
-#define CONFIG_PROP_VENDOR "ro.product.manufacturer"
-#define CONFIG_PROP_NAME "ro.product.name"
-#define CONFIG_PROP_MODEL "ro.product.model"
-
 static const bt_callbacks_t *bt_hal_cbacks = NULL;
 
 #define enum_prop_to_hal(prop, hal_prop, type) do { \
@@ -398,13 +392,13 @@ static uint8_t get_mode(void)
 {
 	char value[PROPERTY_VALUE_MAX];
 
-	if (property_get(MODE_PROPERTY_NAME, value, "") > 0 &&
-					(!strcasecmp(value, "bredr")))
-		return HAL_MODE_BREDR;
+	if (get_config("mode", value, NULL) > 0) {
+		if (!strcasecmp(value, "bredr"))
+			return HAL_MODE_BREDR;
 
-	if (property_get(MODE_PROPERTY_NAME, value, "") > 0 &&
-					(!strcasecmp(value, "le")))
-		return HAL_MODE_LE;
+		if (!strcasecmp(value, "le"))
+			return HAL_MODE_LE;
+	}
 
 	return HAL_MODE_DEFAULT;
 }
@@ -435,17 +429,17 @@ static int send_configuration(void)
 	cmd->num = 0;
 	hal_prop = &cmd->props[0];
 
-	if (property_get(CONFIG_PROP_VENDOR, prop, NULL) > 0) {
+	if (get_config("vendor", prop, "ro.product.manufacturer") > 0) {
 		hal_prop = add_prop(prop, HAL_CONFIG_VENDOR, hal_prop);
 		cmd->num++;
 	}
 
-	if (property_get(CONFIG_PROP_NAME, prop, NULL) > 0) {
+	if (get_config("name", prop, "ro.product.name") > 0) {
 		hal_prop = add_prop(prop, HAL_CONFIG_NAME, hal_prop);
 		cmd->num++;
 	}
 
-	if (property_get(CONFIG_PROP_MODEL, prop, NULL) > 0) {
+	if (get_config("model", prop, "ro.product.model") > 0) {
 		hal_prop = add_prop(prop, HAL_CONFIG_MODEL, hal_prop);
 		cmd->num++;
 	}
diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index 986e745..0c51789 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -27,8 +27,7 @@
 #include "hal-msg.h"
 #include "ipc-common.h"
 #include "hal-ipc.h"
-
-#define MODE_PROPERTY_NAME "persist.sys.bluetooth.handsfree"
+#include "hal-utils.h"
 
 static const bthf_callbacks_t *cbs = NULL;
 
@@ -216,13 +215,13 @@ static uint8_t get_mode(void)
 {
 	char value[PROPERTY_VALUE_MAX];
 
-	if (property_get(MODE_PROPERTY_NAME, value, "") > 0 &&
-					(!strcasecmp(value, "hfp")))
-		return HAL_MODE_HANDSFREE_HFP;
+	if (get_config("handsfree", value, NULL) > 0) {
+		if (!strcasecmp(value, "hfp"))
+			return HAL_MODE_HANDSFREE_HFP;
 
-	if (property_get(MODE_PROPERTY_NAME, value, "") > 0 &&
-					(!strcasecmp(value, "hfp_wbs")))
-		return HAL_MODE_HANDSFREE_HFP_WBS;
+		if (!strcasecmp(value, "hfp_wbs"))
+			return HAL_MODE_HANDSFREE_HFP_WBS;
+	}
 
 	return HAL_MODE_HANDSFREE_HSP_ONLY;
 }