diff --git a/android/cutils/properties.h b/android/cutils/properties.h
index dff812f..66a4a84 100644
--- a/android/cutils/properties.h
+++ b/android/cutils/properties.h
#include <sys/socket.h>
#include <sys/un.h>
+#define PROPERTY_VALUE_MAX 32
+
+static inline int property_get(const char *key, char *value,
+ const char *default_value)
+{
+ return 0;
+}
+
/* property_set: returns 0 on success, < 0 on failure
*/
static inline int property_set(const char *key, const char *value)
diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index 7a28e0f..4117ed0 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
#include <string.h>
#include <stdlib.h>
+#include <cutils/properties.h>
+
#include "hal-log.h"
#include "hal.h"
#include "hal-msg.h"
{handle_hsp_key_press, false, 0},
};
+static uint8_t get_mode(void)
+{
+ char value[PROPERTY_VALUE_MAX];
+
+ if (property_get("bluetooth.handsfree_mode", value, "") > 0 &&
+ (!strcasecmp(value, "hsp_only")))
+ return HAL_MODE_HANDSFREE_HSP_ONLY;
+
+ return HAL_MODE_DEFAULT;
+}
+
static bt_status_t init(bthf_callbacks_t *callbacks)
{
struct hal_cmd_register_module cmd;
sizeof(ev_handlers)/sizeof(ev_handlers[0]));
cmd.service_id = HAL_SERVICE_ID_HANDSFREE;
- cmd.mode = HAL_MODE_DEFAULT;
+ cmd.mode = get_mode();
ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
sizeof(cmd), &cmd, 0, NULL, NULL);
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 8eb97c3..dd25f6e 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
/* Handsfree HAL API */
+#define HAL_MODE_HANDSFREE_HSP_ONLY 0x01
+
#define HAL_OP_HANDSFREE_CONNECT 0x01
struct hal_cmd_handsfree_connect {
uint8_t bdaddr[6];
diff --git a/android/handsfree.c b/android/handsfree.c
index 6149c62..4f69e68 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
bool bt_handsfree_register(struct ipc *ipc, const bdaddr_t *addr, uint8_t mode)
{
- DBG("");
+ DBG("mode 0x%x", mode);
bacpy(&adapter_addr, addr);
if (!enable_hsp_ag())
return false;
- if (!enable_hfp_ag()) {
+ if (mode != HAL_MODE_HANDSFREE_HSP_ONLY && !enable_hfp_ag()) {
cleanup_hsp_ag();
return false;
}