From: Andrei Emeltchenko <[email protected]>
Add support for Android 5.0 interfaces (1st part of patches).
Andrei Emeltchenko (9):
android/handsfree: Add support for new API for handsfree init
android/handsfree: Add support for new API for start_vr
android/handsfree: Add support for new API for stop_vr
android/handsfree: Add support for new API for volume_control
android/handsfree: Add support for new API for cops_response
android/handsfree: Add support for new API for cind_response
android/handsfree: Add support for new API for formatted_at_response
android/handsfree: Add support for new API for at_response
android/handsfree: Add support for new API for clcc_response
android/hal-handsfree.c | 209 +++++++++++++++++++++++++++++++++++++++++++++---
android/hal-ipc-api.txt | 11 ++-
android/hal-msg.h | 13 +++
android/handsfree.c | 47 ++++++++---
android/handsfree.h | 3 +-
android/main.c | 3 +-
6 files changed, 260 insertions(+), 26 deletions(-)
--
1.9.1
Hi Andrei,
On Wednesday 05 of November 2014 16:38:44 Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <[email protected]>
>
> Add support for Android 5.0 interfaces (1st part of patches).
>
> Andrei Emeltchenko (9):
> android/handsfree: Add support for new API for handsfree init
> android/handsfree: Add support for new API for start_vr
> android/handsfree: Add support for new API for stop_vr
> android/handsfree: Add support for new API for volume_control
> android/handsfree: Add support for new API for cops_response
> android/handsfree: Add support for new API for cind_response
> android/handsfree: Add support for new API for formatted_at_response
> android/handsfree: Add support for new API for at_response
> android/handsfree: Add support for new API for clcc_response
>
> android/hal-handsfree.c | 209 +++++++++++++++++++++++++++++++++++++++++++++---
> android/hal-ipc-api.txt | 11 ++-
> android/hal-msg.h | 13 +++
> android/handsfree.c | 47 ++++++++---
> android/handsfree.h | 3 +-
> android/main.c | 3 +-
> 6 files changed, 260 insertions(+), 26 deletions(-)
>
All patches in this set are now applied, thanks.
--
Best regards,
Szymon Janc
From: Andrei Emeltchenko <[email protected]>
clcc_response has new parameter bdaddr in new Android API.
---
android/hal-handsfree.c | 35 +++++++++++++++++++++++++++++++++--
android/hal-ipc-api.txt | 1 +
android/hal-msg.h | 1 +
android/handsfree.c | 5 ++++-
4 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index 99485d6..dfa37e7 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -631,12 +631,13 @@ static bt_status_t at_response(bthf_at_response_t response, int error)
}
#endif
-static bt_status_t clcc_response(int index, bthf_call_direction_t dir,
+static bt_status_t clcc_response_real(int index, bthf_call_direction_t dir,
bthf_call_state_t state,
bthf_call_mode_t mode,
bthf_call_mpty_type_t mpty,
const char *number,
- bthf_call_addrtype_t type)
+ bthf_call_addrtype_t type,
+ bt_bdaddr_t *bd_addr)
{
char buf[IPC_MTU];
struct hal_cmd_handsfree_clcc_response *cmd = (void *) buf;
@@ -647,6 +648,11 @@ static bt_status_t clcc_response(int index, bthf_call_direction_t dir,
if (!interface_ready())
return BT_STATUS_NOT_READY;
+ memset(cmd, 0, sizeof(*cmd));
+
+ if (bd_addr)
+ memcpy(cmd->bdaddr, bd_addr, sizeof(cmd->bdaddr));
+
cmd->index = index;
cmd->dir = dir;
cmd->state = state;
@@ -668,6 +674,31 @@ static bt_status_t clcc_response(int index, bthf_call_direction_t dir,
len, cmd, NULL, NULL, NULL);
}
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+static bt_status_t clcc_response(int index, bthf_call_direction_t dir,
+ bthf_call_state_t state,
+ bthf_call_mode_t mode,
+ bthf_call_mpty_type_t mpty,
+ const char *number,
+ bthf_call_addrtype_t type,
+ bt_bdaddr_t *bd_addr)
+{
+ return clcc_response_real(index, dir, state, mode, mpty, number, type,
+ bd_addr);
+}
+#else
+static bt_status_t clcc_response(int index, bthf_call_direction_t dir,
+ bthf_call_state_t state,
+ bthf_call_mode_t mode,
+ bthf_call_mpty_type_t mpty,
+ const char *number,
+ bthf_call_addrtype_t type)
+{
+ return clcc_response_real(index, dir, state, mode, mpty, number, type,
+ NULL);
+}
+#endif
+
static bt_status_t phone_state_change(int num_active, int num_held,
bthf_call_state_t state,
const char *number,
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 1352950..8424136 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -934,6 +934,7 @@ Commands and responses:
Call multiparty type (1 octet)
Call number type (1 octet)
Call number (string)
+ Remote address (6 octets)
Response parameters: <none>
Valid call directions: 0x00 = Outgoing
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 4b3d8b8..9b08966 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -592,6 +592,7 @@ struct hal_cmd_handsfree_clcc_response {
uint8_t mode;
uint8_t mpty;
uint8_t type;
+ uint8_t bdaddr[6];
uint16_t number_len;
uint8_t number[0];
} __attribute__((packed));
diff --git a/android/handsfree.c b/android/handsfree.c
index c8dfc8f..2c325b1 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -2192,6 +2192,7 @@ static void handle_clcc_resp(const void *buf, uint16_t len)
const struct hal_cmd_handsfree_clcc_response *cmd = buf;
struct hf_device *dev;
uint8_t status;
+ bdaddr_t bdaddr;
char *number;
if (len != sizeof(*cmd) + cmd->number_len || (cmd->number_len != 0 &&
@@ -2203,7 +2204,9 @@ static void handle_clcc_resp(const void *buf, uint16_t len)
DBG("");
- dev = find_default_device();
+ android2bdaddr(cmd->bdaddr, &bdaddr);
+
+ dev = find_device(&bdaddr);
if (!dev) {
status = HAL_STATUS_FAILED;
goto done;
--
1.9.1
From: Andrei Emeltchenko <[email protected]>
at_response has new parameter bdaddr in new Android API.
---
android/hal-handsfree.c | 21 ++++++++++++++++++++-
android/hal-ipc-api.txt | 1 +
android/hal-msg.h | 1 +
android/handsfree.c | 5 ++++-
4 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index 294d1e9..99485d6 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -595,7 +595,8 @@ static bt_status_t formatted_at_response(const char *rsp)
}
#endif
-static bt_status_t at_response(bthf_at_response_t response, int error)
+static bt_status_t at_response_real(bthf_at_response_t response, int error,
+ bt_bdaddr_t *bd_addr)
{
struct hal_cmd_handsfree_at_response cmd;
@@ -604,6 +605,11 @@ static bt_status_t at_response(bthf_at_response_t response, int error)
if (!interface_ready())
return BT_STATUS_NOT_READY;
+ if (bd_addr)
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+
+ memset(&cmd, 0, sizeof(cmd));
+
cmd.response = response;
cmd.error = error;
@@ -612,6 +618,19 @@ static bt_status_t at_response(bthf_at_response_t response, int error)
sizeof(cmd), &cmd, NULL, NULL, NULL);
}
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+static bt_status_t at_response(bthf_at_response_t response, int error,
+ bt_bdaddr_t *bd_addr)
+{
+ return at_response_real(response, error, bd_addr);
+}
+#else
+static bt_status_t at_response(bthf_at_response_t response, int error)
+{
+ return at_response_real(response, error, NULL);
+}
+#endif
+
static bt_status_t clcc_response(int index, bthf_call_direction_t dir,
bthf_call_state_t state,
bthf_call_mode_t mode,
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 44cfe23..1352950 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -917,6 +917,7 @@ Commands and responses:
Command parameters: Response code (1 octet)
Error code (1 octet)
+ Remote address (6 octets)
Response parameters: <none>
Valid response codes: 0x00 = ERROR
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 5c5ed22..4b3d8b8 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -568,6 +568,7 @@ struct hal_cmd_handsfree_formatted_at_response {
struct hal_cmd_handsfree_at_response {
uint8_t response;
uint8_t error;
+ uint8_t bdaddr[6];
} __attribute__((packed));
#define HAL_HANDSFREE_CALL_DIRECTION_OUTGOING 0x00
diff --git a/android/handsfree.c b/android/handsfree.c
index 15753bb..c8dfc8f 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -2160,11 +2160,14 @@ static void handle_at_resp(const void *buf, uint16_t len)
{
const struct hal_cmd_handsfree_at_response *cmd = buf;
struct hf_device *dev;
+ bdaddr_t bdaddr;
uint8_t status;
DBG("");
- dev = find_default_device();
+ android2bdaddr(cmd->bdaddr, &bdaddr);
+
+ dev = find_device(&bdaddr);
if (!dev) {
status = HAL_STATUS_FAILED;
goto done;
--
1.9.1
From: Andrei Emeltchenko <[email protected]>
start_voice_recognition() in new Android API has bd_addr parameter.
---
android/hal-handsfree.c | 23 +++++++++++++++++++++--
android/hal-ipc-api.txt | 2 +-
android/hal-msg.h | 3 +++
android/handsfree.c | 6 +++++-
4 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index c575d2b..304281a 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -343,17 +343,36 @@ static bt_status_t disconnect_audio(bt_bdaddr_t *bd_addr)
&cmd, NULL, NULL, NULL);
}
-static bt_status_t start_voice_recognition(void)
+static bt_status_t start_voice_recognition_real(bt_bdaddr_t *bd_addr)
{
+ struct hal_cmd_handsfree_start_vr cmd;
+
DBG("");
if (!interface_ready())
return BT_STATUS_NOT_READY;
+ memset(&cmd, 0, sizeof(cmd));
+
+ if (bd_addr)
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+
return hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE, HAL_OP_HANDSFREE_START_VR,
- 0, NULL, NULL, NULL, NULL);
+ sizeof(cmd), &cmd, NULL, NULL, NULL);
}
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+static bt_status_t start_voice_recognition(bt_bdaddr_t *bd_addr)
+{
+ return start_voice_recognition_real(bd_addr);
+}
+#else
+static bt_status_t start_voice_recognition(void)
+{
+ return start_voice_recognition_real(NULL);
+}
+#endif
+
static bt_status_t stop_voice_recognition(void)
{
DBG("");
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index a9d4c8b..26d885f 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -835,7 +835,7 @@ Commands and responses:
Opcode 0x05 - Start Voice Recognition command/response
- Command parameters: <none>
+ Command parameters: Remote address (6 octets)
Response parameters: <none>
In case of an error, the error response will be returned.
diff --git a/android/hal-msg.h b/android/hal-msg.h
index b5a4125..96a7640 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -494,6 +494,9 @@ struct hal_cmd_handsfree_disconnect_audio {
} __attribute__((packed));
#define HAL_OP_HANDSFREE_START_VR 0x05
+struct hal_cmd_handsfree_start_vr {
+ uint8_t bdaddr[6];
+} __attribute__((packed));
#define HAL_OP_HANDSFREE_STOP_VR 0x06
diff --git a/android/handsfree.c b/android/handsfree.c
index 3bf42f1..60568c2 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -1886,12 +1886,16 @@ done:
static void handle_start_vr(const void *buf, uint16_t len)
{
+ const struct hal_cmd_handsfree_start_vr *cmd = buf;
struct hf_device *dev;
+ bdaddr_t bdaddr;
uint8_t status;
DBG("");
- dev = find_default_device();
+ android2bdaddr(cmd->bdaddr, &bdaddr);
+
+ dev = find_device(&bdaddr);
if (!dev) {
status = HAL_STATUS_FAILED;
goto done;
--
1.9.1
From: Andrei Emeltchenko <[email protected]>
stop_voice_recognition() in new Android API has bd_addr parameter.
---
android/hal-handsfree.c | 25 +++++++++++++++++++++++--
android/hal-ipc-api.txt | 2 +-
android/hal-msg.h | 3 +++
android/handsfree.c | 6 +++++-
4 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index 304281a..e5dd8c5 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -373,17 +373,38 @@ static bt_status_t start_voice_recognition(void)
}
#endif
-static bt_status_t stop_voice_recognition(void)
+static bt_status_t stop_voice_recognition_real(bt_bdaddr_t *bd_addr)
{
+ struct hal_cmd_handsfree_stop_vr cmd;
+
DBG("");
if (!interface_ready())
return BT_STATUS_NOT_READY;
+ memset(&cmd, 0, sizeof(cmd));
+
+ if (bd_addr)
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+
return hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE, HAL_OP_HANDSFREE_STOP_VR,
- 0, NULL, NULL, NULL, NULL);
+ sizeof(cmd), &cmd, NULL, NULL, NULL);
}
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+static bt_status_t stop_voice_recognition(bt_bdaddr_t *bd_addr)
+{
+ return stop_voice_recognition_real(bd_addr);
+}
+#else
+static bt_status_t stop_voice_recognition(void)
+{
+ return stop_voice_recognition_real(NULL);
+}
+#endif
+
static bt_status_t volume_control(bthf_volume_type_t type, int volume)
{
struct hal_cmd_handsfree_volume_control cmd;
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 26d885f..e422529 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -842,7 +842,7 @@ Commands and responses:
Opcode 0x06 - Stop Voice Recognition command/response
- Command parameters: <none>
+ Command parameters: Remote address (6 octets)
Response parameters: <none>
In case of an error, the error response will be returned.
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 96a7640..5d53957 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -499,6 +499,9 @@ struct hal_cmd_handsfree_start_vr {
} __attribute__((packed));
#define HAL_OP_HANDSFREE_STOP_VR 0x06
+struct hal_cmd_handsfree_stop_vr {
+ uint8_t bdaddr[6];
+} __attribute__((packed));
#define HAL_HANDSFREE_VOLUME_TYPE_SPEAKER 0x00
#define HAL_HANDSFREE_VOLUME_TYPE_MIC 0x01
diff --git a/android/handsfree.c b/android/handsfree.c
index 60568c2..d31482c 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -1915,12 +1915,16 @@ done:
static void handle_stop_vr(const void *buf, uint16_t len)
{
+ const struct hal_cmd_handsfree_stop_vr *cmd = buf;
struct hf_device *dev;
+ bdaddr_t bdaddr;
uint8_t status;
DBG("");
- dev = find_default_device();
+ android2bdaddr(cmd->bdaddr, &bdaddr);
+
+ dev = find_device(&bdaddr);
if (!dev) {
status = HAL_STATUS_FAILED;
goto done;
--
1.9.1
From: Andrei Emeltchenko <[email protected]>
cind_response has new parameter bdaddr in new Android API.
---
android/hal-handsfree.c | 29 +++++++++++++++++++++++++++--
android/hal-ipc-api.txt | 1 +
android/hal-msg.h | 1 +
android/handsfree.c | 5 ++++-
4 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index 708d790..642d087 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -504,9 +504,10 @@ static bt_status_t cops_response(const char *cops)
}
#endif
-static bt_status_t cind_response(int svc, int num_active, int num_held,
+static bt_status_t cind_response_real(int svc, int num_active, int num_held,
bthf_call_state_t state, int signal,
- int roam, int batt_chg)
+ int roam, int batt_chg,
+ bt_bdaddr_t *bd_addr)
{
struct hal_cmd_handsfree_cind_response cmd;
@@ -515,6 +516,11 @@ static bt_status_t cind_response(int svc, int num_active, int num_held,
if (!interface_ready())
return BT_STATUS_NOT_READY;
+ memset(&cmd, 0, sizeof(cmd));
+
+ if (bd_addr)
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+
cmd.svc = svc;
cmd.num_active = num_active;
cmd.num_held = num_held;
@@ -528,6 +534,25 @@ static bt_status_t cind_response(int svc, int num_active, int num_held,
sizeof(cmd), &cmd, NULL, NULL, NULL);
}
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+static bt_status_t cind_response(int svc, int num_active, int num_held,
+ bthf_call_state_t state, int signal,
+ int roam, int batt_chg,
+ bt_bdaddr_t *bd_addr)
+{
+ return cind_response_real(svc, num_active, num_held, state, signal,
+ roam, batt_chg, bd_addr);
+}
+#else
+static bt_status_t cind_response(int svc, int num_active, int num_held,
+ bthf_call_state_t state, int signal,
+ int roam, int batt_chg)
+{
+ return cind_response_real(svc, num_active, num_held, state, signal,
+ roam, batt_chg, NULL);
+}
+#endif
+
static bt_status_t formatted_at_response(const char *rsp)
{
char buf[IPC_MTU];
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 4128746..4cfb91e 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -892,6 +892,7 @@ Commands and responses:
Signal strength (1 octet)
Roaming indicator (1 octet)
Battery level (1 octet)
+ Remote address (6 octets)
Response parameters: <none>
Valid call setup states: 0x00 = Active
diff --git a/android/hal-msg.h b/android/hal-msg.h
index a2f2de4..17e6dee 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -551,6 +551,7 @@ struct hal_cmd_handsfree_cind_response {
uint8_t signal;
uint8_t roam;
uint8_t batt_chg;
+ uint8_t bdaddr[6];
} __attribute__((packed));
#define HAL_OP_HANDSFREE_FORMATTED_AT_RESPONSE 0x0B
diff --git a/android/handsfree.c b/android/handsfree.c
index 7a61dfc..f34668d 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -2081,11 +2081,14 @@ static void handle_cind(const void *buf, uint16_t len)
{
const struct hal_cmd_handsfree_cind_response *cmd = buf;
struct hf_device *dev;
+ bdaddr_t bdaddr;
uint8_t status;
DBG("");
- dev = find_default_device();
+ android2bdaddr(cmd->bdaddr, &bdaddr);
+
+ dev = find_device(&bdaddr);
if (!dev) {
status = HAL_STATUS_FAILED;
goto done;
--
1.9.1
From: Andrei Emeltchenko <[email protected]>
cops_response has new parameter bdaddr in new Android API.
---
android/hal-handsfree.c | 20 +++++++++++++++++++-
android/hal-ipc-api.txt | 1 +
android/hal-msg.h | 1 +
android/handsfree.c | 5 ++++-
4 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index c1d8702..708d790 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -462,7 +462,7 @@ static bt_status_t device_status_notification(bthf_network_state_t state,
sizeof(cmd), &cmd, NULL, NULL, NULL);
}
-static bt_status_t cops_response(const char *cops)
+static bt_status_t cops_response_real(const char *cops, bt_bdaddr_t *bd_addr)
{
char buf[IPC_MTU];
struct hal_cmd_handsfree_cops_response *cmd = (void *) buf;
@@ -476,6 +476,12 @@ static bt_status_t cops_response(const char *cops)
if (!cops)
return BT_STATUS_PARM_INVALID;
+ memset(cmd, 0, sizeof(*cmd));
+
+ if (bd_addr)
+ memcpy(cmd->bdaddr, bd_addr, sizeof(cmd->bdaddr));
+
+ /* Size of cmd.buf */
cmd->len = strlen(cops) + 1;
memcpy(cmd->buf, cops, cmd->len);
@@ -486,6 +492,18 @@ static bt_status_t cops_response(const char *cops)
len, cmd, NULL, NULL, NULL);
}
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+static bt_status_t cops_response(const char *cops, bt_bdaddr_t *bd_addr)
+{
+ return cops_response_real(cops, bd_addr);
+}
+#else
+static bt_status_t cops_response(const char *cops)
+{
+ return cops_response_real(cops, NULL);
+}
+#endif
+
static bt_status_t cind_response(int svc, int num_active, int num_held,
bthf_call_state_t state, int signal,
int roam, int batt_chg)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index a4c7777..4128746 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -878,6 +878,7 @@ Commands and responses:
Opcode 0x09 - COPS Response command/response
Command parameters: COPS command response (string)
+ Remote address (6 octets)
Response parameters: <none>
In case of an error, the error response will be returned.
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 9833451..a2f2de4 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -530,6 +530,7 @@ struct hal_cmd_handsfree_device_status_notif {
#define HAL_OP_HANDSFREE_COPS_RESPONSE 0x09
struct hal_cmd_handsfree_cops_response {
uint16_t len;
+ uint8_t bdaddr[6];
uint8_t buf[0];
} __attribute__((packed));
diff --git a/android/handsfree.c b/android/handsfree.c
index fc6605a..7a61dfc 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -2031,6 +2031,7 @@ static void handle_cops(const void *buf, uint16_t len)
{
const struct hal_cmd_handsfree_cops_response *cmd = buf;
struct hf_device *dev;
+ bdaddr_t bdaddr;
uint8_t status;
if (len != sizeof(*cmd) + cmd->len ||
@@ -2042,7 +2043,9 @@ static void handle_cops(const void *buf, uint16_t len)
DBG("");
- dev = find_default_device();
+ android2bdaddr(cmd->bdaddr, &bdaddr);
+
+ dev = find_device(&bdaddr);
if (!dev) {
status = HAL_STATUS_FAILED;
goto done;
--
1.9.1
From: Andrei Emeltchenko <[email protected]>
formatted_at_response has new parameter bdaddr in new Android API.
---
android/hal-handsfree.c | 20 +++++++++++++++++++-
android/hal-ipc-api.txt | 1 +
android/hal-msg.h | 1 +
android/handsfree.c | 5 ++++-
4 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index 642d087..294d1e9 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -553,7 +553,8 @@ static bt_status_t cind_response(int svc, int num_active, int num_held,
}
#endif
-static bt_status_t formatted_at_response(const char *rsp)
+static bt_status_t formatted_at_response_real(const char *rsp,
+ bt_bdaddr_t *bd_addr)
{
char buf[IPC_MTU];
struct hal_cmd_handsfree_formatted_at_response *cmd = (void *) buf;
@@ -567,6 +568,11 @@ static bt_status_t formatted_at_response(const char *rsp)
if (!rsp)
return BT_STATUS_PARM_INVALID;
+ memset(cmd, 0, sizeof(*cmd));
+
+ if (bd_addr)
+ memcpy(cmd->bdaddr, bd_addr, sizeof(cmd->bdaddr));
+
cmd->len = strlen(rsp) + 1;
memcpy(cmd->buf, rsp, cmd->len);
@@ -577,6 +583,18 @@ static bt_status_t formatted_at_response(const char *rsp)
len, cmd, NULL, NULL, NULL);
}
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+static bt_status_t formatted_at_response(const char *rsp, bt_bdaddr_t *bd_addr)
+{
+ return formatted_at_response_real(rsp, bd_addr);
+}
+#else
+static bt_status_t formatted_at_response(const char *rsp)
+{
+ return formatted_at_response_real(rsp, NULL);
+}
+#endif
+
static bt_status_t at_response(bthf_at_response_t response, int error)
{
struct hal_cmd_handsfree_at_response cmd;
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 4cfb91e..44cfe23 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -908,6 +908,7 @@ Commands and responses:
Opcode 0x0b - Formatted AT Response command/response
Command parameters: Pre-formatted AT response (string)
+ Remote address (6 octets)
Response parameters: <none>
In case of an error, the error response will be returned.
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 17e6dee..5c5ed22 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -557,6 +557,7 @@ struct hal_cmd_handsfree_cind_response {
#define HAL_OP_HANDSFREE_FORMATTED_AT_RESPONSE 0x0B
struct hal_cmd_handsfree_formatted_at_response {
uint16_t len;
+ uint8_t bdaddr[6];
uint8_t buf[0];
} __attribute__((packed));
diff --git a/android/handsfree.c b/android/handsfree.c
index f34668d..15753bb 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -2127,6 +2127,7 @@ static void handle_formatted_at_resp(const void *buf, uint16_t len)
{
const struct hal_cmd_handsfree_formatted_at_response *cmd = buf;
struct hf_device *dev;
+ bdaddr_t bdaddr;
uint8_t status;
DBG("");
@@ -2138,7 +2139,9 @@ static void handle_formatted_at_resp(const void *buf, uint16_t len)
return;
}
- dev = find_default_device();
+ android2bdaddr(cmd->bdaddr, &bdaddr);
+
+ dev = find_device(&bdaddr);
if (!dev) {
status = HAL_STATUS_FAILED;
goto done;
--
1.9.1
From: Andrei Emeltchenko <[email protected]>
Add max_client parameter to IPC following new parameter for HF init().
---
android/hal-handsfree.c | 15 ++++++++++++++-
android/hal-ipc-api.txt | 1 +
android/hal-msg.h | 1 +
android/handsfree.c | 5 ++++-
android/handsfree.h | 3 ++-
android/main.c | 3 ++-
6 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index 0c51789..c575d2b 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -226,7 +226,7 @@ static uint8_t get_mode(void)
return HAL_MODE_HANDSFREE_HSP_ONLY;
}
-static bt_status_t init(bthf_callbacks_t *callbacks)
+static bt_status_t init_real(bthf_callbacks_t *callbacks, int max_hf_clients)
{
struct hal_cmd_register_module cmd;
int ret;
@@ -243,6 +243,7 @@ static bt_status_t init(bthf_callbacks_t *callbacks)
cmd.service_id = HAL_SERVICE_ID_HANDSFREE;
cmd.mode = get_mode();
+ cmd.max_clients = max_hf_clients;
ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
sizeof(cmd), &cmd, NULL, NULL, NULL);
@@ -255,6 +256,18 @@ static bt_status_t init(bthf_callbacks_t *callbacks)
return ret;
}
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+static bt_status_t init(bthf_callbacks_t *callbacks, int max_hf_clients)
+{
+ return init_real(callbacks, max_hf_clients);
+}
+#else
+static bt_status_t init(bthf_callbacks_t *callbacks)
+{
+ return init_real(callbacks, 1);
+}
+#endif
+
static bt_status_t handsfree_connect(bt_bdaddr_t *bd_addr)
{
struct hal_cmd_handsfree_connect cmd;
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 1bb591a..a9d4c8b 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -128,6 +128,7 @@ Core Service (ID 0)
Command parameters: Service id (1 octet)
Mode (1 octet)
+ Max Clients (4 octets)
Response parameters: <none>
In case a command is sent for an undeclared service ID, it will
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 1876d6b..b5a4125 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -64,6 +64,7 @@ static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket";
struct hal_cmd_register_module {
uint8_t service_id;
uint8_t mode;
+ int32_t max_clients;
} __attribute__((packed));
#define HAL_OP_UNREGISTER_MODULE 0x02
diff --git a/android/handsfree.c b/android/handsfree.c
index 3aa4522..3bf42f1 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -2901,7 +2901,8 @@ static bool bt_sco_register(ipc_disconnect_cb disconnect)
return true;
}
-bool bt_handsfree_register(struct ipc *ipc, const bdaddr_t *addr, uint8_t mode)
+bool bt_handsfree_register(struct ipc *ipc, const bdaddr_t *addr, uint8_t mode,
+ int max_clients)
{
DBG("mode 0x%x", mode);
@@ -2920,6 +2921,8 @@ bool bt_handsfree_register(struct ipc *ipc, const bdaddr_t *addr, uint8_t mode)
if (mode == HAL_MODE_HANDSFREE_HSP_ONLY)
goto done;
+ /* TODO: Handle max_clients argument */
+
hfp_ag_features = HFP_AG_FEATURES;
if (mode == HAL_MODE_HANDSFREE_HFP_WBS)
diff --git a/android/handsfree.h b/android/handsfree.h
index e5eff47..d4fd649 100644
--- a/android/handsfree.h
+++ b/android/handsfree.h
@@ -21,5 +21,6 @@
*
*/
-bool bt_handsfree_register(struct ipc *ipc, const bdaddr_t *addr, uint8_t mode);
+bool bt_handsfree_register(struct ipc *ipc, const bdaddr_t *addr, uint8_t mode,
+ int max_clients);
void bt_handsfree_unregister(void);
diff --git a/android/main.c b/android/main.c
index b5f6937..58dd9ab 100644
--- a/android/main.c
+++ b/android/main.c
@@ -209,7 +209,8 @@ static void service_register(const void *buf, uint16_t len)
break;
case HAL_SERVICE_ID_HANDSFREE:
- if (!bt_handsfree_register(hal_ipc, &adapter_bdaddr, m->mode)) {
+ if (!bt_handsfree_register(hal_ipc, &adapter_bdaddr, m->mode,
+ m->max_clients)) {
status = HAL_STATUS_FAILED;
goto failed;
}
--
1.9.1
From: Andrei Emeltchenko <[email protected]>
volume_control() in new Android API has bd_addr parameter.
---
android/hal-handsfree.c | 21 ++++++++++++++++++++-
android/hal-ipc-api.txt | 1 +
android/hal-msg.h | 1 +
android/handsfree.c | 5 ++++-
4 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index e5dd8c5..c1d8702 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -405,7 +405,8 @@ static bt_status_t stop_voice_recognition(void)
}
#endif
-static bt_status_t volume_control(bthf_volume_type_t type, int volume)
+static bt_status_t volume_control_real(bthf_volume_type_t type, int volume,
+ bt_bdaddr_t *bd_addr)
{
struct hal_cmd_handsfree_volume_control cmd;
@@ -414,14 +415,32 @@ static bt_status_t volume_control(bthf_volume_type_t type, int volume)
if (!interface_ready())
return BT_STATUS_NOT_READY;
+ memset(&cmd, 0, sizeof(cmd));
+
cmd.type = type;
cmd.volume = volume;
+ if (bd_addr)
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+
return hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE,
HAL_OP_HANDSFREE_VOLUME_CONTROL, sizeof(cmd),
&cmd, NULL, NULL, NULL);
}
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+static bt_status_t volume_control(bthf_volume_type_t type, int volume,
+ bt_bdaddr_t *bd_addr)
+{
+ return volume_control_real(type, volume, bd_addr);
+}
+#else
+static bt_status_t volume_control(bthf_volume_type_t type, int volume)
+{
+ return volume_control_real(type, volume, NULL);
+}
+#endif
+
static bt_status_t device_status_notification(bthf_network_state_t state,
bthf_service_type_t type,
int signal, int battery)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index e422529..a4c7777 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -851,6 +851,7 @@ Commands and responses:
Command parameters: Volume type (1 octet)
Volume (1 octet)
+ Remote address (6 octets)
Response parameters: <none>
Valid volume types: 0x00 = Speaker
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 5d53957..9833451 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -510,6 +510,7 @@ struct hal_cmd_handsfree_stop_vr {
struct hal_cmd_handsfree_volume_control {
uint8_t type;
uint8_t volume;
+ uint8_t bdaddr[6];
} __attribute__((packed));
#define HAL_HANDSFREE_NETWORK_STATE_NOT_AVAILABLE 0x00
diff --git a/android/handsfree.c b/android/handsfree.c
index d31482c..fc6605a 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -1947,10 +1947,13 @@ static void handle_volume_control(const void *buf, uint16_t len)
const struct hal_cmd_handsfree_volume_control *cmd = buf;
struct hf_device *dev;
uint8_t status, volume;
+ bdaddr_t bdaddr;
DBG("type=%u volume=%u", cmd->type, cmd->volume);
- dev = find_default_device();
+ android2bdaddr(cmd->bdaddr, &bdaddr);
+
+ dev = find_device(&bdaddr);
if (!dev) {
status = HAL_STATUS_FAILED;
goto done;
--
1.9.1