2014-11-06 08:31:55

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 00/14] 2nd part of handsfree Android 5.0 adaptation code

From: Andrei Emeltchenko <[email protected]>

Add support for Android 5.0 interfaces (2nd part of patches) - callbacks.

Andrei Emeltchenko (14):
android/handsfree: Add support for new API for vr_cmd_cb
android/handsfree: Add support for new API for handle_answer
android/handsfree: Add support for new API for hangup_call_cmd_cb
android/handsfree: Add support for new API for volume_cmd_cb
android/handsfree: Add support for new API for dial_call_cmd_cb
android/handsfree: Add support for new API for handle_dtmf
android/handsfree: Add support for new API for nrec_cmd_cb
android/handsfree: Add support for new API for chld_cmd_cb
android/handsfree: Add support for new API for cnum_cmd_cb
android/handsfree: Add support for new API for cind_cmd_cb
android/handsfree: Add support for new API for cops_cmd_cb
android/handsfree: Add support for new API for clcc_cmd_cb
android/handsfree: Add support for new API for unknown_at_cmd_cb
android/handsfree: Add support for new API for key_pressed_cmd_cb

android/hal-handsfree.c | 95 ++++++++++++++++++++++++++++++++++++++++++++-----
android/hal-ipc-api.txt | 25 ++++++++-----
android/hal-msg.h | 28 +++++++++++++++
android/handsfree.c | 48 +++++++++++++++++++++----
4 files changed, 172 insertions(+), 24 deletions(-)

--
1.9.1



2014-11-06 11:42:47

by Szymon Janc

[permalink] [raw]
Subject: Re: [PATCH 00/14] 2nd part of handsfree Android 5.0 adaptation code

Hi Andrei,

On Thursday 06 of November 2014 10:31:55 Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <[email protected]>
>
> Add support for Android 5.0 interfaces (2nd part of patches) - callbacks.
>
> Andrei Emeltchenko (14):
> android/handsfree: Add support for new API for vr_cmd_cb
> android/handsfree: Add support for new API for handle_answer
> android/handsfree: Add support for new API for hangup_call_cmd_cb
> android/handsfree: Add support for new API for volume_cmd_cb
> android/handsfree: Add support for new API for dial_call_cmd_cb
> android/handsfree: Add support for new API for handle_dtmf
> android/handsfree: Add support for new API for nrec_cmd_cb
> android/handsfree: Add support for new API for chld_cmd_cb
> android/handsfree: Add support for new API for cnum_cmd_cb
> android/handsfree: Add support for new API for cind_cmd_cb
> android/handsfree: Add support for new API for cops_cmd_cb
> android/handsfree: Add support for new API for clcc_cmd_cb
> android/handsfree: Add support for new API for unknown_at_cmd_cb
> android/handsfree: Add support for new API for key_pressed_cmd_cb
>
> android/hal-handsfree.c | 95 ++++++++++++++++++++++++++++++++++++++++++++-----
> android/hal-ipc-api.txt | 25 ++++++++-----
> android/hal-msg.h | 28 +++++++++++++++
> android/handsfree.c | 48 +++++++++++++++++++++----
> 4 files changed, 172 insertions(+), 24 deletions(-)

All patches applied, thanks a lot.

--
Best regards,
Szymon Janc

2014-11-06 08:31:58

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 03/14] android/handsfree: Add support for new API for hangup_call_cmd_cb

From: Andrei Emeltchenko <[email protected]>

Hangup Call Command notification callback has new parameter bdaddr.
Currently use global device bdaddr.
---
android/hal-handsfree.c | 9 ++++++++-
android/hal-ipc-api.txt | 2 +-
android/hal-msg.h | 3 +++
android/handsfree.c | 5 ++++-
4 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index f1ddfe1..dc40a17 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -80,8 +80,15 @@ static void handle_answer(void *buf, uint16_t len, int fd)

static void handle_hangup(void *buf, uint16_t len, int fd)
{
- if (cbs->hangup_call_cmd_cb)
+ if (cbs->hangup_call_cmd_cb) {
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+ struct hal_ev_handsfree_hangup *ev = buf;
+
+ cbs->hangup_call_cmd_cb((bt_bdaddr_t *) (ev->bdaddr));
+#else
cbs->hangup_call_cmd_cb();
+#endif
+ }
}

static void handle_volume(void *buf, uint16_t len, int fd)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 48d30c9..751c6ee 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1019,7 +1019,7 @@ Notifications:

Opcode 0x85 - Hangup Call Command notification

- Notification parameters: <none>
+ Notification parameters: Remote address (6 octets)

Opcode 0x86 - Volume Command notification

diff --git a/android/hal-msg.h b/android/hal-msg.h
index 195e26c..0abbb1f7 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1355,6 +1355,9 @@ struct hal_ev_handsfree_answer {
} __attribute__((packed));

#define HAL_EV_HANDSFREE_HANGUP 0x85
+struct hal_ev_handsfree_hangup {
+ uint8_t bdaddr[6];
+} __attribute__((packed));

#define HAL_EV_HANDSFREE_VOLUME 0x86
struct hal_ev_handsfree_volume {
diff --git a/android/handsfree.c b/android/handsfree.c
index 1525630..46f9a5d 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -596,6 +596,7 @@ static void at_cmd_chup(struct hfp_context *context,
enum hfp_gw_cmd_type type, void *user_data)
{
struct hf_device *dev = user_data;
+ struct hal_ev_handsfree_hangup ev;

DBG("");

@@ -604,8 +605,10 @@ static void at_cmd_chup(struct hfp_context *context,
if (hfp_context_has_next(context))
break;

+ bdaddr2android(&dev->bdaddr, ev.bdaddr);
+
ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HANDSFREE,
- HAL_EV_HANDSFREE_HANGUP, 0, NULL);
+ HAL_EV_HANDSFREE_HANGUP, sizeof(ev), &ev);

/* Framework is not replying with result for AT+CHUP */
hfp_gw_send_result(dev->gw, HFP_RESULT_OK);
--
1.9.1


2014-11-06 08:32:08

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 13/14] android/handsfree: Add support for new API for unknown_at_cmd_cb

From: Andrei Emeltchenko <[email protected]>

Unknown AT Command notification callback has new parameter bdaddr.
---
android/hal-handsfree.c | 5 +++++
android/hal-ipc-api.txt | 3 ++-
android/hal-msg.h | 1 +
android/handsfree.c | 2 ++
4 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index 83d9909..76e036a 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -228,7 +228,12 @@ static void handle_unknown_at(void *buf, uint16_t len, int fd)
}

if (cbs->unknown_at_cmd_cb)
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+ cbs->unknown_at_cmd_cb((char *) ev->buf,
+ (bt_bdaddr_t *) (ev->bdaddr));
+#else
cbs->unknown_at_cmd_cb((char *) ev->buf);
+#endif
}

static void handle_hsp_key_press(void *buf, uint16_t len, int fd)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 9c9ac35..3e8a38c 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1076,7 +1076,8 @@ Notifications:

Opcode 0x8f - Unknown AT Command notification

- Notification parameters: AT command (string)
+ Notification parameters: Remote address (6 octets)
+ AT command (string)

Opcode 0x90 - Key Pressed Command notification

diff --git a/android/hal-msg.h b/android/hal-msg.h
index 9b9c2b0..f86e6b7 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1421,6 +1421,7 @@ struct hal_ev_handsfree_clcc {

#define HAL_EV_HANDSFREE_UNKNOWN_AT 0x8F
struct hal_ev_handsfree_unknown_at {
+ uint8_t bdaddr[6];
uint16_t len;
uint8_t buf[0];
} __attribute__((packed));
diff --git a/android/handsfree.c b/android/handsfree.c
index 9eaf38f..d9cb929 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -329,6 +329,8 @@ static void at_cmd_unknown(const char *command, void *user_data)
return;
}

+ bdaddr2android(&dev->bdaddr, ev->bdaddr);
+
/* copy while string including terminating NULL */
ev->len = strlen(command) + 1;
memcpy(ev->buf, command, ev->len);
--
1.9.1


2014-11-06 08:31:56

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 01/14] android/handsfree: Add support for new API for vr_cmd_cb

From: Andrei Emeltchenko <[email protected]>

Voice Recognition Command notification callback has new parameter bdaddr.
---
android/hal-handsfree.c | 4 ++++
android/hal-ipc-api.txt | 1 +
android/hal-msg.h | 1 +
android/handsfree.c | 2 ++
4 files changed, 8 insertions(+)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index dfa37e7..c465277 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -58,7 +58,11 @@ static void handle_vr_state(void *buf, uint16_t len, int fd)
struct hal_ev_handsfree_vr_state *ev = buf;

if (cbs->vr_cmd_cb)
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+ cbs->vr_cmd_cb(ev->state, (bt_bdaddr_t *) (ev->bdaddr));
+#else
cbs->vr_cmd_cb(ev->state);
+#endif
}

static void handle_answer(void *buf, uint16_t len, int fd)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 8424136..058af6f 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1008,6 +1008,7 @@ Notifications:
Opcode 0x83 - Voice Recognition Command notification

Notification parameters: Voice recognition state (1 octet)
+ Remote address (6 octets)

Valid voice recognition states: 0x00 = Stopped
0x01 = Started
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 9b08966..4ea30dac 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1346,6 +1346,7 @@ struct hal_ev_handsfree_audio_state {
#define HAL_EV_HANDSFREE_VR 0x83
struct hal_ev_handsfree_vr_state {
uint8_t state;
+ uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_EV_HANDSFREE_ANSWER 0x84
diff --git a/android/handsfree.c b/android/handsfree.c
index e6e0f33..a5d4184 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -822,6 +822,8 @@ static void at_cmd_bvra(struct hfp_context *context,
else
ev.state = HAL_HANDSFREE_VR_STOPPED;

+ bdaddr2android(&dev->bdaddr, ev.bdaddr);
+
ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HANDSFREE,
HAL_EV_HANDSFREE_VR, sizeof(ev), &ev);
return;
--
1.9.1


2014-11-06 08:32:09

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 14/14] android/handsfree: Add support for new API for key_pressed_cmd_cb

From: Andrei Emeltchenko <[email protected]>

Key Pressed Command notification callback has new parameter bdaddr.
---
android/hal-handsfree.c | 9 ++++++++-
android/hal-ipc-api.txt | 2 +-
android/hal-msg.h | 3 +++
android/handsfree.c | 6 +++++-
4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index 76e036a..2834c80 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -238,8 +238,15 @@ static void handle_unknown_at(void *buf, uint16_t len, int fd)

static void handle_hsp_key_press(void *buf, uint16_t len, int fd)
{
- if (cbs->key_pressed_cmd_cb)
+ if (cbs->key_pressed_cmd_cb) {
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+ struct hal_ev_handsfree_hsp_key_press *ev = buf;
+
+ cbs->key_pressed_cmd_cb((bt_bdaddr_t *) (ev->bdaddr));
+#else
cbs->key_pressed_cmd_cb();
+#endif
+ }
}

/*
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 3e8a38c..c7d5c59 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1081,7 +1081,7 @@ Notifications:

Opcode 0x90 - Key Pressed Command notification

- Notification parameters: <none>
+ Notification parameters: Remote address (6 octets)


Bluetooth Advanced Audio HAL (ID 6)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index f86e6b7..eef226e 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1427,6 +1427,9 @@ struct hal_ev_handsfree_unknown_at {
} __attribute__((packed));

#define HAL_EV_HANDSFREE_HSP_KEY_PRESS 0x90
+struct hal_ev_handsfree_hsp_key_press {
+ uint8_t bdaddr[6];
+} __attribute__((packed));

#define HAL_AVRCP_FEATURE_NONE 0x00
#define HAL_AVRCP_FEATURE_METADATA 0x01
diff --git a/android/handsfree.c b/android/handsfree.c
index d9cb929..4d8dff4 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -1143,6 +1143,7 @@ static void at_cmd_ckpd(struct hfp_context *result, enum hfp_gw_cmd_type type,
void *user_data)
{
struct hf_device *dev = user_data;
+ struct hal_ev_handsfree_hsp_key_press ev;
unsigned int val;

DBG("");
@@ -1155,8 +1156,11 @@ static void at_cmd_ckpd(struct hfp_context *result, enum hfp_gw_cmd_type type,
if (hfp_context_has_next(result))
break;

+ bdaddr2android(&dev->bdaddr, ev.bdaddr);
+
ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HANDSFREE,
- HAL_EV_HANDSFREE_HSP_KEY_PRESS, 0, NULL);
+ HAL_EV_HANDSFREE_HSP_KEY_PRESS,
+ sizeof(ev), &ev);

hfp_gw_send_result(dev->gw, HFP_RESULT_OK);
return;
--
1.9.1


2014-11-06 08:32:07

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 12/14] android/handsfree: Add support for new API for clcc_cmd_cb

From: Andrei Emeltchenko <[email protected]>

CLCC Command notification callback has new parameter bdaddr.
---
android/hal-handsfree.c | 9 ++++++++-
android/hal-ipc-api.txt | 2 +-
android/hal-msg.h | 3 +++
android/handsfree.c | 5 ++++-
4 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index ea9614b..83d9909 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -206,8 +206,15 @@ static void handle_cops(void *buf, uint16_t len, int fd)

static void handle_clcc(void *buf, uint16_t len, int fd)
{
- if (cbs->clcc_cmd_cb)
+ if (cbs->clcc_cmd_cb) {
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+ struct hal_ev_handsfree_clcc *ev = buf;
+
+ cbs->clcc_cmd_cb((bt_bdaddr_t *) (ev->bdaddr));
+#else
cbs->clcc_cmd_cb();
+#endif
+ }
}

static void handle_unknown_at(void *buf, uint16_t len, int fd)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 64adf57..9c9ac35 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1072,7 +1072,7 @@ Notifications:

Opcode 0x8e - CLCC Command notification

- Notification parameters: <none>
+ Notification parameters: Remote address (6 octets)

Opcode 0x8f - Unknown AT Command notification

diff --git a/android/hal-msg.h b/android/hal-msg.h
index 5793a5b..9b9c2b0 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1415,6 +1415,9 @@ struct hal_ev_handsfree_cops {
} __attribute__((packed));

#define HAL_EV_HANDSFREE_CLCC 0x8E
+struct hal_ev_handsfree_clcc {
+ uint8_t bdaddr[6];
+} __attribute__((packed));

#define HAL_EV_HANDSFREE_UNKNOWN_AT 0x8F
struct hal_ev_handsfree_unknown_at {
diff --git a/android/handsfree.c b/android/handsfree.c
index b64dcc6..9eaf38f 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -633,6 +633,7 @@ static void at_cmd_clcc(struct hfp_context *context,
enum hfp_gw_cmd_type type, void *user_data)
{
struct hf_device *dev = user_data;
+ struct hal_ev_handsfree_clcc ev;

DBG("");

@@ -641,8 +642,10 @@ static void at_cmd_clcc(struct hfp_context *context,
if (hfp_context_has_next(context))
break;

+ bdaddr2android(&dev->bdaddr, ev.bdaddr);
+
ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HANDSFREE,
- HAL_EV_HANDSFREE_CLCC, 0, NULL);
+ HAL_EV_HANDSFREE_CLCC, sizeof(ev), &ev);
return;
case HFP_GW_CMD_TYPE_READ:
case HFP_GW_CMD_TYPE_TEST:
--
1.9.1


2014-11-06 08:32:06

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 11/14] android/handsfree: Add support for new API for cops_cmd_cb

From: Andrei Emeltchenko <[email protected]>

COPS Command notification callback has new parameter bdaddr.
---
android/hal-handsfree.c | 9 ++++++++-
android/hal-ipc-api.txt | 2 +-
android/hal-msg.h | 3 +++
android/handsfree.c | 5 ++++-
4 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index 1ea8a9c..ea9614b 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -193,8 +193,15 @@ static void handle_cind(void *buf, uint16_t len, int fd)

static void handle_cops(void *buf, uint16_t len, int fd)
{
- if (cbs->cops_cmd_cb)
+ if (cbs->cops_cmd_cb) {
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+ struct hal_ev_handsfree_cops *ev = buf;
+
+ cbs->cops_cmd_cb((bt_bdaddr_t *) (ev->bdaddr));
+#else
cbs->cops_cmd_cb();
+#endif
+ }
}

static void handle_clcc(void *buf, uint16_t len, int fd)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 97c5440..64adf57 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1068,7 +1068,7 @@ Notifications:

Opcode 0x8d - COPS Command notification

- Notification parameters: <none>
+ Notification parameters: Remote address (6 octets)

Opcode 0x8e - CLCC Command notification

diff --git a/android/hal-msg.h b/android/hal-msg.h
index 86a79c7..5793a5b 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1410,6 +1410,9 @@ struct hal_ev_handsfree_cind {
} __attribute__((packed));

#define HAL_EV_HANDSFREE_COPS 0x8D
+struct hal_ev_handsfree_cops {
+ uint8_t bdaddr[6];
+} __attribute__((packed));

#define HAL_EV_HANDSFREE_CLCC 0x8E

diff --git a/android/handsfree.c b/android/handsfree.c
index 6ca25e3..b64dcc6 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -418,6 +418,7 @@ static void at_cmd_cops(struct hfp_context *context,
enum hfp_gw_cmd_type type, void *user_data)
{
struct hf_device *dev = user_data;
+ struct hal_ev_handsfree_cops ev;
unsigned int val;

switch (type) {
@@ -434,8 +435,10 @@ static void at_cmd_cops(struct hfp_context *context,
hfp_gw_send_result(dev->gw, HFP_RESULT_OK);
return;
case HFP_GW_CMD_TYPE_READ:
+ bdaddr2android(&dev->bdaddr, ev.bdaddr);
+
ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HANDSFREE,
- HAL_EV_HANDSFREE_COPS, 0, NULL);
+ HAL_EV_HANDSFREE_COPS, sizeof(ev), &ev);
return;
case HFP_GW_CMD_TYPE_TEST:
case HFP_GW_CMD_TYPE_COMMAND:
--
1.9.1


2014-11-06 08:31:59

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 04/14] android/handsfree: Add support for new API for volume_cmd_cb

From: Andrei Emeltchenko <[email protected]>

Volume Command notification callback has new parameter bdaddr.
---
android/hal-handsfree.c | 5 +++++
android/hal-ipc-api.txt | 1 +
android/hal-msg.h | 1 +
android/handsfree.c | 2 ++
4 files changed, 9 insertions(+)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index dc40a17..bb64da0 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -96,7 +96,12 @@ static void handle_volume(void *buf, uint16_t len, int fd)
struct hal_ev_handsfree_volume *ev = buf;

if (cbs->volume_cmd_cb)
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+ cbs->volume_cmd_cb(ev->type, ev->volume,
+ (bt_bdaddr_t *) (ev->bdaddr));
+#else
cbs->volume_cmd_cb(ev->type, ev->volume);
+#endif
}

static void handle_dial(void *buf, uint16_t len, int fd)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 751c6ee..e462363 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1025,6 +1025,7 @@ Notifications:

Notification parameters: Volume type (1 octet)
Volume (1 octet)
+ Remote address (6 octets)

Valid volume types: 0x00 = Speaker
0x01 = Microphone
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 0abbb1f7..889b45e 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1363,6 +1363,7 @@ struct hal_ev_handsfree_hangup {
struct hal_ev_handsfree_volume {
uint8_t type;
uint8_t volume;
+ uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_EV_HANDSFREE_DIAL 0x87
diff --git a/android/handsfree.c b/android/handsfree.c
index 46f9a5d..83cc326 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -361,6 +361,7 @@ static void at_cmd_vgm(struct hfp_context *context,

ev.type = HAL_HANDSFREE_VOLUME_TYPE_MIC;
ev.volume = val;
+ bdaddr2android(&dev->bdaddr, ev.bdaddr);

ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HANDSFREE,
HAL_EV_HANDSFREE_VOLUME, sizeof(ev), &ev);
@@ -396,6 +397,7 @@ static void at_cmd_vgs(struct hfp_context *context,

ev.type = HAL_HANDSFREE_VOLUME_TYPE_SPEAKER;
ev.volume = val;
+ bdaddr2android(&dev->bdaddr, ev.bdaddr);

ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HANDSFREE,
HAL_EV_HANDSFREE_VOLUME, sizeof(ev), &ev);
--
1.9.1


2014-11-06 08:32:01

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 06/14] android/handsfree: Add support for new API for handle_dtmf

From: Andrei Emeltchenko <[email protected]>

DTMF Command notification callback has new parameter bdaddr.
---
android/hal-handsfree.c | 4 ++++
android/hal-ipc-api.txt | 1 +
android/hal-msg.h | 1 +
android/handsfree.c | 1 +
4 files changed, 7 insertions(+)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index 3a5eec6..21d4444 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -134,7 +134,11 @@ static void handle_dtmf(void *buf, uint16_t len, int fd)
struct hal_ev_handsfree_dtmf *ev = buf;

if (cbs->dtmf_cmd_cb)
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+ cbs->dtmf_cmd_cb(ev->tone, (bt_bdaddr_t *) (ev->bdaddr));
+#else
cbs->dtmf_cmd_cb(ev->tone);
+#endif
}

static void handle_nrec(void *buf, uint16_t len, int fd)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index bc41993..962650b 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1038,6 +1038,7 @@ Notifications:
Opcode 0x88 - DTMF Command notification

Notification parameters: Tone (1 octet)
+ Remote address (6 octets)

Opcode 0x89 - NREC Command notification

diff --git a/android/hal-msg.h b/android/hal-msg.h
index a1cfff1..00e66e2 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1376,6 +1376,7 @@ struct hal_ev_handsfree_dial {
#define HAL_EV_HANDSFREE_DTMF 0x88
struct hal_ev_handsfree_dtmf {
uint8_t tone;
+ uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_HANDSFREE_NREC_STOP 0x00
diff --git a/android/handsfree.c b/android/handsfree.c
index 6b67af5..53f3fd1 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -730,6 +730,7 @@ static void at_cmd_vts(struct hfp_context *context,
if (hfp_context_has_next(context))
break;

+ bdaddr2android(&dev->bdaddr, ev.bdaddr);
ev.tone = str[0];

ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HANDSFREE,
--
1.9.1


2014-11-06 08:32:03

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 08/14] android/handsfree: Add support for new API for chld_cmd_cb

From: Andrei Emeltchenko <[email protected]>

CHLD Command notification callback has new parameter bdaddr.
---
android/hal-handsfree.c | 4 ++++
android/hal-ipc-api.txt | 1 +
android/hal-msg.h | 1 +
android/handsfree.c | 1 +
4 files changed, 7 insertions(+)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index 76a2e0f..e4ade61 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -158,7 +158,11 @@ static void handle_chld(void *buf, uint16_t len, int fd)
struct hal_ev_handsfree_chld *ev = buf;

if (cbs->chld_cmd_cb)
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+ cbs->chld_cmd_cb(ev->chld, (bt_bdaddr_t *) (ev->bdaddr));
+#else
cbs->chld_cmd_cb(ev->chld);
+#endif
}

static void handle_cnum(void *buf, uint16_t len, int fd)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 10808f4..06a2beb 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1051,6 +1051,7 @@ Notifications:
Opcode 0x8a - CHLD Command notification

Notification parameters: NREC types (1 octet)
+ Remote address (6 octets)

Valid CHLD types: 0x00 = Release and hold
0x01 = Release active and accept held
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 321f193..24780f5 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1396,6 +1396,7 @@ struct hal_ev_handsfree_nrec {
#define HAL_EV_HANDSFREE_CHLD 0x8A
struct hal_ev_handsfree_chld {
uint8_t chld;
+ uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_EV_HANDSFREE_CNUM 0x8B
diff --git a/android/handsfree.c b/android/handsfree.c
index f47eaae..3bfb2ee 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -1352,6 +1352,7 @@ static void at_cmd_chld(struct hfp_context *result, enum hfp_gw_cmd_type type,

/* value match HAL type */
ev.chld = val;
+ bdaddr2android(&dev->bdaddr, ev.bdaddr);

ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HANDSFREE,
HAL_EV_HANDSFREE_CHLD, sizeof(ev), &ev);
--
1.9.1


2014-11-06 08:32:00

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 05/14] android/handsfree: Add support for new API for dial_call_cmd_cb

From: Andrei Emeltchenko <[email protected]>

Dial Call Command notification callback has new parameter bdaddr.
---
android/hal-handsfree.c | 4 ++++
android/hal-ipc-api.txt | 3 ++-
android/hal-msg.h | 1 +
android/handsfree.c | 3 +++
4 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index bb64da0..3a5eec6 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -122,7 +122,11 @@ static void handle_dial(void *buf, uint16_t len, int fd)
if (ev->number_len)
number = (char *) ev->number;

+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+ cbs->dial_call_cmd_cb(number, (bt_bdaddr_t *) (ev->bdaddr));
+#else
cbs->dial_call_cmd_cb(number);
+#endif
}

static void handle_dtmf(void *buf, uint16_t len, int fd)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index e462363..bc41993 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1032,7 +1032,8 @@ Notifications:

Opcode 0x87 - Dial Call Command notification

- Notification parameters: Number (string)
+ Notification parameters: Remote address (6 octets)
+ Number (string)

Opcode 0x88 - DTMF Command notification

diff --git a/android/hal-msg.h b/android/hal-msg.h
index 889b45e..a1cfff1 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1368,6 +1368,7 @@ struct hal_ev_handsfree_volume {

#define HAL_EV_HANDSFREE_DIAL 0x87
struct hal_ev_handsfree_dial {
+ 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 83cc326..6b67af5 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -537,6 +537,8 @@ static void at_cmd_d(struct hfp_context *context,
(char *) ev->number, 255))
break;

+ bdaddr2android(&dev->bdaddr, ev->bdaddr);
+
ev->number_len = strlen((char *) ev->number);

if (ev->number[ev->number_len - 1] != ';')
@@ -794,6 +796,7 @@ static void at_cmd_bldn(struct hfp_context *context,
if (hfp_context_has_next(context))
break;

+ bdaddr2android(&dev->bdaddr, ev.bdaddr);
ev.number_len = 0;

ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HANDSFREE,
--
1.9.1


2014-11-06 08:32:04

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 09/14] android/handsfree: Add support for new API for cnum_cmd_cb

From: Andrei Emeltchenko <[email protected]>

CNUM Command notification callback has new parameter bdaddr.
Currently use global device bdaddr.
---
android/hal-handsfree.c | 11 +++++++++--
android/hal-ipc-api.txt | 2 +-
android/hal-msg.h | 3 +++
android/handsfree.c | 5 ++++-
4 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index e4ade61..8618ddf 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -167,8 +167,15 @@ static void handle_chld(void *buf, uint16_t len, int fd)

static void handle_cnum(void *buf, uint16_t len, int fd)
{
- if (cbs->cnum_cmd_cb)
- cbs->cnum_cmd_cb();
+ if (cbs->cnum_cmd_cb) {
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+ struct hal_ev_handsfree_cnum *ev = buf;
+
+ cbs->cnum_cmd_cb((bt_bdaddr_t *) (ev->bdaddr));
+#else
+ cbs->cnum_cmd_cb(NULL);
+#endif
+ }
}

static void handle_cind(void *buf, uint16_t len, int fd)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 06a2beb..27a0c24 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1060,7 +1060,7 @@ Notifications:

Opcode 0x8b - CNUM Command notification

- Notification parameters: <none>
+ Notification parameters: Remote address (6 octets)

Opcode 0x8c - CIND Command notification

diff --git a/android/hal-msg.h b/android/hal-msg.h
index 24780f5..2650d36 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1400,6 +1400,9 @@ struct hal_ev_handsfree_chld {
} __attribute__((packed));

#define HAL_EV_HANDSFREE_CNUM 0x8B
+struct hal_ev_handsfree_cnum {
+ uint8_t bdaddr[6];
+} __attribute__((packed));

#define HAL_EV_HANDSFREE_CIND 0x8C

diff --git a/android/handsfree.c b/android/handsfree.c
index 3bfb2ee..0b846e6 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -752,6 +752,7 @@ static void at_cmd_cnum(struct hfp_context *context,
enum hfp_gw_cmd_type type, void *user_data)
{
struct hf_device *dev = user_data;
+ struct hal_ev_handsfree_cnum ev;

DBG("");

@@ -760,8 +761,10 @@ static void at_cmd_cnum(struct hfp_context *context,
if (hfp_context_has_next(context))
break;

+ bdaddr2android(&dev->bdaddr, ev.bdaddr);
+
ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HANDSFREE,
- HAL_EV_HANDSFREE_CNUM, 0, NULL);
+ HAL_EV_HANDSFREE_CNUM, sizeof(ev), &ev);
return;
case HFP_GW_CMD_TYPE_SET:
case HFP_GW_CMD_TYPE_READ:
--
1.9.1


2014-11-06 08:32:02

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 07/14] android/handsfree: Add support for new API for nrec_cmd_cb

From: Andrei Emeltchenko <[email protected]>

NREC Command notification callback has new parameter bdaddr.
---
android/hal-handsfree.c | 4 ++++
android/hal-ipc-api.txt | 1 +
android/hal-msg.h | 1 +
android/handsfree.c | 1 +
4 files changed, 7 insertions(+)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index 21d4444..76a2e0f 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -146,7 +146,11 @@ static void handle_nrec(void *buf, uint16_t len, int fd)
struct hal_ev_handsfree_nrec *ev = buf;

if (cbs->nrec_cmd_cb)
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+ cbs->nrec_cmd_cb(ev->nrec, (bt_bdaddr_t *) (ev->bdaddr));
+#else
cbs->nrec_cmd_cb(ev->nrec);
+#endif
}

static void handle_chld(void *buf, uint16_t len, int fd)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 962650b..10808f4 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1043,6 +1043,7 @@ Notifications:
Opcode 0x89 - NREC Command notification

Notification parameters: NREC types (1 octet)
+ Remote address (6 octets)

Valid NREC types: 0x00 = Stop
0x01 = Start
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 00e66e2..321f193 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1385,6 +1385,7 @@ struct hal_ev_handsfree_dtmf {
#define HAL_EV_HANDSFREE_NREC 0x89
struct hal_ev_handsfree_nrec {
uint8_t nrec;
+ uint8_t bdaddr[6];
} __attribute__((packed));

#define HAL_HANDSFREE_CHLD_TYPE_RELEASEHELD 0x00
diff --git a/android/handsfree.c b/android/handsfree.c
index 53f3fd1..f47eaae 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -871,6 +871,7 @@ static void at_cmd_nrec(struct hfp_context *context,
break;

ev.nrec = HAL_HANDSFREE_NREC_STOP;
+ bdaddr2android(&dev->bdaddr, ev.bdaddr);

ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HANDSFREE,
HAL_EV_HANDSFREE_NREC, sizeof(ev), &ev);
--
1.9.1


2014-11-06 08:32:05

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 10/14] android/handsfree: Add support for new API for cind_cmd_cb

From: Andrei Emeltchenko <[email protected]>

CIND Command notification callback has new parameter bdaddr.
Currently use global device bdaddr.
---
android/hal-handsfree.c | 9 ++++++++-
android/hal-ipc-api.txt | 2 +-
android/hal-msg.h | 3 +++
android/handsfree.c | 5 ++++-
4 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index 8618ddf..1ea8a9c 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -180,8 +180,15 @@ static void handle_cnum(void *buf, uint16_t len, int fd)

static void handle_cind(void *buf, uint16_t len, int fd)
{
- if (cbs->cind_cmd_cb)
+ if (cbs->cind_cmd_cb) {
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+ struct hal_ev_handsfree_cind *ev = buf;
+
+ cbs->cind_cmd_cb((bt_bdaddr_t *) (ev->bdaddr));
+#else
cbs->cind_cmd_cb();
+#endif
+ }
}

static void handle_cops(void *buf, uint16_t len, int fd)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 27a0c24..97c5440 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1064,7 +1064,7 @@ Notifications:

Opcode 0x8c - CIND Command notification

- Notification parameters: <none>
+ Notification parameters: Remote address (6 octets)

Opcode 0x8d - COPS Command notification

diff --git a/android/hal-msg.h b/android/hal-msg.h
index 2650d36..86a79c7 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1405,6 +1405,9 @@ struct hal_ev_handsfree_cnum {
} __attribute__((packed));

#define HAL_EV_HANDSFREE_CIND 0x8C
+struct hal_ev_handsfree_cind {
+ uint8_t bdaddr[6];
+} __attribute__((packed));

#define HAL_EV_HANDSFREE_COPS 0x8D

diff --git a/android/handsfree.c b/android/handsfree.c
index 0b846e6..6ca25e3 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -1246,6 +1246,7 @@ static void at_cmd_cind(struct hfp_context *result, enum hfp_gw_cmd_type type,
void *user_data)
{
struct hf_device *dev = user_data;
+ struct hal_ev_handsfree_cind ev;
char *buf, *ptr;
int len;
unsigned int i;
@@ -1289,8 +1290,10 @@ static void at_cmd_cind(struct hfp_context *result, enum hfp_gw_cmd_type type,
g_free(buf);
return;
case HFP_GW_CMD_TYPE_READ:
+ bdaddr2android(&dev->bdaddr, ev.bdaddr);
+
ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HANDSFREE,
- HAL_EV_HANDSFREE_CIND, 0, NULL);
+ HAL_EV_HANDSFREE_CIND, sizeof(ev), &ev);
return;
case HFP_GW_CMD_TYPE_SET:
case HFP_GW_CMD_TYPE_COMMAND:
--
1.9.1


2014-11-06 08:31:57

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 02/14] android/handsfree: Add support for new API for handle_answer

From: Andrei Emeltchenko <[email protected]>

Answer Call Command notification callback has new parameter bdaddr.
Currently use global device bdaddr.
---
android/hal-handsfree.c | 9 ++++++++-
android/hal-ipc-api.txt | 2 +-
android/hal-msg.h | 3 +++
android/handsfree.c | 5 ++++-
4 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index c465277..f1ddfe1 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -67,8 +67,15 @@ static void handle_vr_state(void *buf, uint16_t len, int fd)

static void handle_answer(void *buf, uint16_t len, int fd)
{
- if (cbs->answer_call_cmd_cb)
+ if (cbs->answer_call_cmd_cb) {
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+ struct hal_ev_handsfree_answer *ev = buf;
+
+ cbs->answer_call_cmd_cb((bt_bdaddr_t *) (ev->bdaddr));
+#else
cbs->answer_call_cmd_cb();
+#endif
+ }
}

static void handle_hangup(void *buf, uint16_t len, int fd)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 058af6f..48d30c9 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1015,7 +1015,7 @@ Notifications:

Opcode 0x84 - Answer Call Command notification

- Notification parameters: <none>
+ Notification parameters: Remote address (6 octets)

Opcode 0x85 - Hangup Call Command notification

diff --git a/android/hal-msg.h b/android/hal-msg.h
index 4ea30dac..195e26c 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1350,6 +1350,9 @@ struct hal_ev_handsfree_vr_state {
} __attribute__((packed));

#define HAL_EV_HANDSFREE_ANSWER 0x84
+struct hal_ev_handsfree_answer {
+ uint8_t bdaddr[6];
+} __attribute__((packed));

#define HAL_EV_HANDSFREE_HANGUP 0x85

diff --git a/android/handsfree.c b/android/handsfree.c
index a5d4184..1525630 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -493,6 +493,7 @@ static void at_cmd_a(struct hfp_context *context,
enum hfp_gw_cmd_type type, void *user_data)
{
struct hf_device *dev = user_data;
+ struct hal_ev_handsfree_answer ev;

DBG("");

@@ -501,8 +502,10 @@ static void at_cmd_a(struct hfp_context *context,
if (hfp_context_has_next(context))
break;

+ bdaddr2android(&dev->bdaddr, ev.bdaddr);
+
ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HANDSFREE,
- HAL_EV_HANDSFREE_ANSWER, 0, NULL);
+ HAL_EV_HANDSFREE_ANSWER, sizeof(ev), &ev);

/* Framework is not replying with result for ATA */
hfp_gw_send_result(dev->gw, HFP_RESULT_OK);
--
1.9.1