Diff between 6024744b9e455c04564cc26d29f2b34aaf7d9fbf and 0ff83edff0c13fcea2a2a1b21365867fd01e098a

Changed Files

File Additions Deletions Status
android/client/if-gatt.c +2 -0 modified
android/cutils/properties.h +1 -0 modified
android/hal-utils.c +32 -0 modified
android/hal-utils.h +2 -0 modified

Full Patch

diff --git a/android/client/if-gatt.c b/android/client/if-gatt.c
index 0ceffa6..f021a8b 100644
--- a/android/client/if-gatt.c
+++ b/android/client/if-gatt.c
@@ -15,6 +15,8 @@
  *
  */
 
+#include <stdbool.h>
+
 #include <hardware/bluetooth.h>
 
 #include "../hal-utils.h"
diff --git a/android/cutils/properties.h b/android/cutils/properties.h
index 43f07f1..0163eb5 100644
--- a/android/cutils/properties.h
+++ b/android/cutils/properties.h
@@ -29,6 +29,7 @@
 #include <sys/un.h>
 
 #define PROPERTY_VALUE_MAX 32
+#define PROPERTY_KEY_MAX 32
 
 #define BLUETOOTH_MODE_PROPERTY_NAME "persist.sys.bluetooth.mode"
 #define BLUETOOTH_MODE_PROPERTY_HANDSFREE "persist.sys.bluetooth.handsfree"
diff --git a/android/hal-utils.c b/android/hal-utils.c
index 64ab5a1..0311b81 100644
--- a/android/hal-utils.c
+++ b/android/hal-utils.c
@@ -18,6 +18,9 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
+#include <stdbool.h>
+
+#include <cutils/properties.h>
 
 #include "hal-utils.h"
 
@@ -330,3 +333,32 @@ const char *btproperty2str(const bt_property_t *property)
 
 	return buf;
 }
+
+#define PROP_PREFIX "persist.sys.bluetooth."
+#define PROP_PREFIX_RO "ro.bluetooth."
+
+int get_config(const char *config_key, char *value, const char *fallback)
+{
+	char key[PROPERTY_KEY_MAX];
+	int ret;
+
+	if (strlen(config_key) + sizeof(PROP_PREFIX) >= sizeof(key))
+		return 0;
+
+	snprintf(key, sizeof(key), PROP_PREFIX"%s", config_key);
+
+	ret = property_get(key, value, "");
+	if (ret > 0)
+		return ret;
+
+	snprintf(key, sizeof(key), PROP_PREFIX_RO"%s", config_key);
+
+	ret = property_get(key, value, "");
+	if (ret > 0)
+		return ret;
+
+	if (!fallback)
+		return 0;
+
+	return property_get(fallback, value, "");
+}
diff --git a/android/hal-utils.h b/android/hal-utils.h
index a0aab57..a2ae0f4 100644
--- a/android/hal-utils.h
+++ b/android/hal-utils.h
@@ -36,6 +36,8 @@ void str2bt_uuid_t(const char *str, bt_uuid_t *uuid);
 const char *btproperty2str(const bt_property_t *property);
 const char *bdaddr2str(const bt_bdaddr_t *bd_addr);
 
+int get_config(const char *config_key, char *value, const char *fallback);
+
 /*
  * Begin mapping section
  *