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
*
*/
+#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
#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
#include <stdio.h>
#include <string.h>
#include <stdint.h>
+#include <stdbool.h>
+
+#include <cutils/properties.h>
#include "hal-utils.h"
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
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
*