2014-11-04 08:18:23

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 00/47] BlueZ support for Android 5.0 Lollipop

From: Andrei Emeltchenko <[email protected]>

First version of BlueZ compatible with Android 5.0 Lollipop.

Build against https://android.googlesource.com/platform/hardware/libhardware
branch lollipop-release

Andrei Emeltchenko (47):
android: Set exact Android version
android/hal-bluetooth: Add parameter to create_bond
android/hal-bluetooth: Add missing functions
android/hal-audio: Add support for new Android API
android/hal-audio: Implement dummy Audio HAL functions
android/hal-sco: Add support for new Android API
android/hal-sco: Remove deprecated API usage
android/hal-sco: Implement dummy SCO HAL functions
android/hal-sco: Save bd_addr for output stream of Audio SCO HAL
android/hal-sco: Save bd_addr for input stream of Audio SCO HAL
android/hal-sco: Add remote address parameter in Get SCO fd command
android/hal-sco: Use bdaddr parameter in Get SCO fd command
android/gatt: Add support for new API
android/gatt: Add support for new parameter for connect
android/gatt: Add support for new parameter in srv connect()
android/client: Support new API for Audio HAL
android/client: Support new API for SCO HAL
android/client: Add new API argument for scan()
android/client: Add support for new Android API for PAN HAL
android/client: Add support for new GATT HAL API
android/client: Add new API support for handsfree client
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/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/handsfree: Use bdaddr provided for find_device()
android/handsfree: Return default device for zero bdaddr
android/build: Disable declaration-after-statement warnings

android/Android.mk | 7 +-
android/Makefile.am | 2 +-
android/client/if-audio.c | 11 +++
android/client/if-bt.c | 12 +++
android/client/if-gatt.c | 32 +++++++
android/client/if-hf.c | 209 ++++++++++++++++++++++++++++++++++++++++++-
android/client/if-pan.c | 5 ++
android/client/if-sco.c | 19 ++++
android/gatt.c | 18 ++--
android/hal-audio.c | 75 +++++++++++++++-
android/hal-bluetooth.c | 47 ++++++++++
android/hal-gatt.c | 24 +++++
android/hal-handsfree.c | 223 ++++++++++++++++++++++++++++++++++++++++++++--
android/hal-ipc-api.txt | 37 +++++---
android/hal-msg.h | 48 ++++++++++
android/hal-sco.c | 131 +++++++++++++++++++++++++--
android/handsfree.c | 110 +++++++++++++++++++----
android/handsfree.h | 3 +-
android/main.c | 3 +-
android/sco-ipc-api.txt | 2 +-
android/sco-msg.h | 4 +
21 files changed, 961 insertions(+), 61 deletions(-)

--
1.9.1



2014-11-04 14:03:38

by Szymon Janc

[permalink] [raw]
Subject: Re: [PATCHv1 01/47] android: Set exact Android version

Hi Andrei,

On Tuesday 04 of November 2014 10:18:24 Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <[email protected]>
>
> For local build set exact current Android version.
> ---
> android/Makefile.am | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/android/Makefile.am b/android/Makefile.am
> index 496fbc4..bd05654 100644
> --- a/android/Makefile.am
> +++ b/android/Makefile.am
> @@ -1,6 +1,6 @@
> if ANDROID
>
> -AM_CFLAGS += -DANDROID_VERSION=0xFFFFFF -DBLUEZ_EXTENSIONS
> +AM_CFLAGS += -DANDROID_VERSION=0x040404 -DBLUEZ_EXTENSIONS
>
> android_plugindir = $(abs_top_srcdir)/android/.libs
>

This patch is now applied, thanks.

--
Best regards,
Szymon Janc

2014-11-04 08:19:07

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 44/47] 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 55021c5..b072af7 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(4, 4, 4)
+ 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 02bddb8..15cdfca 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 1862178..358e368 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -1143,6 +1143,7 @@ static void at_cmd_ckpd(struct hfp_gw_result *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_gw_result *result, enum hfp_gw_cmd_type type,
if (hfp_gw_result_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-04 08:19:05

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 42/47] 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 3fa91e9..2833c49 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(4, 4, 4)
+ 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 2b4f362..c2e4b7d 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 c4c031b..4cc1755 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -633,6 +633,7 @@ static void at_cmd_clcc(struct hfp_gw_result *result, 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_gw_result *result, enum hfp_gw_cmd_type type,
if (hfp_gw_result_has_next(result))
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-04 08:19:06

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 43/47] 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 2833c49..55021c5 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(4, 4, 4)
+ 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 c2e4b7d..02bddb8 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 4cc1755..1862178 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-04 08:19:01

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 38/47] 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 2554c97..bebeef7 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(4, 4, 4)
+ 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 60c107a..baea3a1 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 904dc00..eba761f 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -1352,6 +1352,7 @@ static void at_cmd_chld(struct hfp_gw_result *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-04 08:19:00

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 37/47] 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 a640f9c..2554c97 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(4, 4, 4)
+ 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 bd1e460..60c107a 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 ee5cab5..904dc00 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -871,6 +871,7 @@ static void at_cmd_nrec(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
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-04 08:18:58

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 35/47] 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 38eee0b..eddde37 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(4, 4, 4)
+ 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 7c24e8e..d0d2869 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 e9b6af5..88a9ed5 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -537,6 +537,8 @@ static void at_cmd_d(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
(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_gw_result *result, enum hfp_gw_cmd_type type,
if (hfp_gw_result_has_next(result))
break;

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

ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HANDSFREE,
--
1.9.1


2014-11-04 08:18:59

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 36/47] 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 eddde37..a640f9c 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(4, 4, 4)
+ 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 d0d2869..bd1e460 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 88a9ed5..ee5cab5 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -730,6 +730,7 @@ static void at_cmd_vts(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
if (hfp_gw_result_has_next(result))
break;

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

ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HANDSFREE,
--
1.9.1


2014-11-04 08:18:50

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 27/47] android/handsfree: Add support for new API for cind_response

From: Andrei Emeltchenko <[email protected]>

cind_response has new parameter bdaddr in new Android API.
---
android/hal-handsfree.c | 14 ++++++++++++++
android/hal-ipc-api.txt | 1 +
android/hal-msg.h | 1 +
android/handsfree.c | 5 ++++-
4 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index f28b8c7..b240f84 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -488,9 +488,16 @@ static bt_status_t cops_response(const char *cops)
len, cmd, NULL, NULL, NULL);
}

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+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)
+#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)
+#endif
{
struct hal_cmd_handsfree_cind_response cmd;

@@ -499,6 +506,13 @@ static bt_status_t cind_response(int svc, int num_active, int num_held,
if (!interface_ready())
return BT_STATUS_NOT_READY;

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ if (!bd_addr)
+ return BT_STATUS_PARM_INVALID;
+
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+#endif
+
cmd.svc = svc;
cmd.num_active = num_active;
cmd.num_held = num_held;
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 4a591b1..27572e4 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 7089f7c..3ef19d7 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


2014-11-04 08:18:57

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 34/47] 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 ccd30a1..38eee0b 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(4, 4, 4)
+ 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 8a77b06..7c24e8e 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 d31b14a..e9b6af5 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -361,6 +361,7 @@ static void at_cmd_vgm(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,

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_gw_result *result, enum hfp_gw_cmd_type type,

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-04 08:18:53

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 30/47] android/handsfree: Add support for new API for clcc_response

From: Andrei Emeltchenko <[email protected]>

clcc_response has new parameter bdaddr in new Android API.
---
android/hal-handsfree.c | 17 +++++++++++++++++
android/hal-ipc-api.txt | 1 +
android/hal-msg.h | 1 +
android/handsfree.c | 5 ++++-
4 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index e9388b8..f19ca1a 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -590,12 +590,22 @@ static bt_status_t at_response(bthf_at_response_t response, int error)
sizeof(cmd), &cmd, NULL, NULL, NULL);
}

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+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)
+#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)
+#endif
{
char buf[IPC_MTU];
struct hal_cmd_handsfree_clcc_response *cmd = (void *) buf;
@@ -606,6 +616,13 @@ static bt_status_t clcc_response(int index, bthf_call_direction_t dir,
if (!interface_ready())
return BT_STATUS_NOT_READY;

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ if (!bd_addr)
+ return BT_STATUS_PARM_INVALID;
+
+ memcpy(cmd->bdaddr, bd_addr, sizeof(cmd->bdaddr));
+#endif
+
cmd->index = index;
cmd->dir = dir;
cmd->state = state;
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index b5d5557..4181d40 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 92a341a..ba94011 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


2014-11-04 08:18:44

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 21/47] android/client: Add new API support for handsfree client

From: Andrei Emeltchenko <[email protected]>

Add support for handsfree client new API by adding missing parameters
to functions and callbacks.
---
android/client/if-hf.c | 209 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 208 insertions(+), 1 deletion(-)

diff --git a/android/client/if-hf.c b/android/client/if-hf.c
index 77216df..0f77d28 100644
--- a/android/client/if-hf.c
+++ b/android/client/if-hf.c
@@ -136,110 +136,226 @@ static void audio_state_cb(bthf_audio_state_t state, bt_bdaddr_t *bd_addr)
* Callback for VR connection state change.
* state will have one of the values from BtHfVRState
*/
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static void vr_cmd_cb(bthf_vr_state_t state, bt_bdaddr_t *bd_addr)
+{
+ haltest_info("%s: state=%s bd_addr=%s\n", __func__,
+ bthf_vr_state_t2str(state),
+ bt_bdaddr_t2str(bd_addr, last_addr));
+}
+#else
static void vr_cmd_cb(bthf_vr_state_t state)
{
haltest_info("%s: state=%s\n", __func__, bthf_vr_state_t2str(state));
}
+#endif

/* Callback for answer incoming call (ATA) */
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static void answer_call_cmd_cb(bt_bdaddr_t *bd_addr)
+{
+ haltest_info("%s: bd_addr=%s\n", __func__,
+ bt_bdaddr_t2str(bd_addr, last_addr));
+}
+#else
static void answer_call_cmd_cb(void)
{
haltest_info("%s\n", __func__);
}
+#endif

/* Callback for disconnect call (AT+CHUP) */
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static void hangup_call_cmd_cb(bt_bdaddr_t *bd_addr)
+{
+ haltest_info("%s: bd_addr=%s\n", __func__,
+ bt_bdaddr_t2str(bd_addr, last_addr));
+}
+#else
static void hangup_call_cmd_cb(void)
{
haltest_info("%s\n", __func__);
}
+#endif

/*
* Callback for disconnect call (AT+CHUP)
* type will denote Speaker/Mic gain (BtHfVolumeControl).
*/
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static void volume_cmd_cb(bthf_volume_type_t type, int volume,
+ bt_bdaddr_t *bd_addr)
+{
+ haltest_info("%s: type=%s volume=%d bd_addr=%s\n", __func__,
+ bthf_volume_type_t2str(type), volume,
+ bt_bdaddr_t2str(bd_addr, last_addr));
+}
+#else
static void volume_cmd_cb(bthf_volume_type_t type, int volume)
{
haltest_info("%s: type=%s volume=%d\n", __func__,
bthf_volume_type_t2str(type), volume);
}
+#endif

/*
* Callback for dialing an outgoing call
* If number is NULL, redial
*/
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static void dial_call_cmd_cb(char *number, bt_bdaddr_t *bd_addr)
+{
+ haltest_info("%s: number=%s bd_addr=%s\n", __func__, number,
+ bt_bdaddr_t2str(bd_addr, last_addr));
+}
+#else
static void dial_call_cmd_cb(char *number)
{
haltest_info("%s: number=%s\n", __func__, number);
}
+#endif

/*
* Callback for sending DTMF tones
* tone contains the dtmf character to be sent
*/
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static void dtmf_cmd_cb(char tone, bt_bdaddr_t *bd_addr)
+{
+ haltest_info("%s: tone=%d bd_addr=%s\n", __func__, tone,
+ bt_bdaddr_t2str(bd_addr, last_addr));
+}
+#else
static void dtmf_cmd_cb(char tone)
{
haltest_info("%s: tone=%d\n", __func__, tone);
}
+#endif

/*
* Callback for enabling/disabling noise reduction/echo cancellation
* value will be 1 to enable, 0 to disable
*/
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static void nrec_cmd_cb(bthf_nrec_t nrec, bt_bdaddr_t *bd_addr)
+{
+ haltest_info("%s: nrec=%s bd_addr=%s\n", __func__,
+ bthf_nrec_t2str(nrec),
+ bt_bdaddr_t2str(bd_addr, last_addr));
+}
+#else
static void nrec_cmd_cb(bthf_nrec_t nrec)
{
haltest_info("%s: nrec=%s\n", __func__, bthf_nrec_t2str(nrec));
}
+#endif

/*
* Callback for call hold handling (AT+CHLD)
* value will contain the call hold command (0, 1, 2, 3)
*/
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static void chld_cmd_cb(bthf_chld_type_t chld, bt_bdaddr_t *bd_addr)
+{
+ haltest_info("%s: chld=%s bd_addr=%s\n", __func__,
+ bthf_chld_type_t2str(chld),
+ bt_bdaddr_t2str(bd_addr, last_addr));
+}
+#else
static void chld_cmd_cb(bthf_chld_type_t chld)
{
haltest_info("%s: chld=%s\n", __func__, bthf_chld_type_t2str(chld));
}
+#endif

/* Callback for CNUM (subscriber number) */
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static void cnum_cmd_cb(bt_bdaddr_t *bd_addr)
+{
+ haltest_info("%s: bd_addr=%s\n", __func__,
+ bt_bdaddr_t2str(bd_addr, last_addr));
+}
+#else
static void cnum_cmd_cb(void)
{
haltest_info("%s\n", __func__);
}
+#endif

/* Callback for indicators (CIND) */
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static void cind_cmd_cb(bt_bdaddr_t *bd_addr)
+{
+ haltest_info("%s: bd_addr=%s\n", __func__,
+ bt_bdaddr_t2str(bd_addr, last_addr));
+}
+#else
static void cind_cmd_cb(void)
{
haltest_info("%s\n", __func__);
}
+#endif

/* Callback for operator selection (COPS) */
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static void cops_cmd_cb(bt_bdaddr_t *bd_addr)
+{
+ haltest_info("%s: bd_addr=%s\n", __func__,
+ bt_bdaddr_t2str(bd_addr, last_addr));
+}
+#else
static void cops_cmd_cb(void)
{
haltest_info("%s\n", __func__);
}
+#endif

/* Callback for call list (AT+CLCC) */
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static void clcc_cmd_cb(bt_bdaddr_t *bd_addr)
+{
+ haltest_info("%s: bd_addr=%s\n", __func__,
+ bt_bdaddr_t2str(bd_addr, last_addr));
+}
+#else
static void clcc_cmd_cb(void)
{
haltest_info("%s\n", __func__);
}
+#endif

/*
* Callback for unknown AT command recd from HF
* at_string will contain the unparsed AT string
*/
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static void unknown_at_cmd_cb(char *at_string, bt_bdaddr_t *bd_addr)
+{
+ haltest_info("%s: at_string=%s bd_addr=%s\n", __func__, at_string,
+ bt_bdaddr_t2str(bd_addr, last_addr));
+}
+#else
static void unknown_at_cmd_cb(char *at_string)
{
haltest_info("%s: at_string=%s\n", __func__, at_string);
}
+#endif

/* Callback for keypressed (HSP) event. */
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static void key_pressed_cmd_cb(bt_bdaddr_t *bd_addr)
+{
+ haltest_info("%s: bd_addr=%s\n", __func__,
+ bt_bdaddr_t2str(bd_addr, last_addr));
+}
+#else
static void key_pressed_cmd_cb(void)
{
haltest_info("%s\n", __func__);
}
+#endif

static bthf_callbacks_t hf_cbacks = {
-
.size = sizeof(hf_cbacks),
.connection_state_cb = connection_state_cb,
.audio_state_cb = audio_state_cb,
@@ -263,9 +379,22 @@ static bthf_callbacks_t hf_cbacks = {

static void init_p(int argc, const char **argv)
{
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ int max_hf_clients;
+#endif
+
RETURN_IF_NULL(if_hf);

+#if ANDROID_VERSION <= PLATFORM_VER(4, 4, 4)
EXEC(if_hf->init, &hf_cbacks);
+#else
+ if (argc < 2)
+ max_hf_clients = 1;
+ else
+ max_hf_clients = atoi(argv[2]);
+
+ EXEC(if_hf->init, &hf_cbacks, max_hf_clients);
+#endif
}

/* connect */
@@ -351,18 +480,38 @@ static void disconnect_audio_p(int argc, const char **argv)

static void start_voice_recognition_p(int argc, const char **argv)
{
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ bt_bdaddr_t addr;
+#endif
+
RETURN_IF_NULL(if_hf);

+#if ANDROID_VERSION <= PLATFORM_VER(4, 4, 4)
EXEC(if_hf->start_voice_recognition);
+#else
+ VERIFY_ADDR_ARG(2, &addr);
+
+ EXEC(if_hf->start_voice_recognition, &addr);
+#endif
}

/* stop voice recognition */

static void stop_voice_recognition_p(int argc, const char **argv)
{
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ bt_bdaddr_t addr;
+#endif
+
RETURN_IF_NULL(if_hf);

+#if ANDROID_VERSION <= PLATFORM_VER(4, 4, 4)
EXEC(if_hf->stop_voice_recognition);
+#else
+ VERIFY_ADDR_ARG(2, &addr);
+
+ EXEC(if_hf->stop_voice_recognition, &addr);
+#endif
}

/* volume control */
@@ -380,6 +529,9 @@ static void volume_control_p(int argc, const char **argv)
{
bthf_volume_type_t type;
int volume;
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ bt_bdaddr_t addr;
+#endif

RETURN_IF_NULL(if_hf);

@@ -397,7 +549,13 @@ static void volume_control_p(int argc, const char **argv)
}
volume = atoi(argv[3]);

+#if ANDROID_VERSION <= PLATFORM_VER(4, 4, 4)
EXEC(if_hf->volume_control, type, volume);
+#else
+ VERIFY_ADDR_ARG(4, &addr);
+
+ EXEC(if_hf->volume_control, type, volume, &addr);
+#endif
}

/* Combined device status change notification */
@@ -460,6 +618,10 @@ static void device_status_notification_p(int argc, const char **argv)

static void cops_response_p(int argc, const char **argv)
{
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ bt_bdaddr_t addr;
+#endif
+
RETURN_IF_NULL(if_hf);

/* response */
@@ -468,7 +630,13 @@ static void cops_response_p(int argc, const char **argv)
return;
}

+#if ANDROID_VERSION <= PLATFORM_VER(4, 4, 4)
EXEC(if_hf->cops_response, argv[2]);
+#else
+ VERIFY_ADDR_ARG(3, &addr);
+
+ EXEC(if_hf->cops_response, argv[2], &addr);
+#endif
}

/* Response for CIND command */
@@ -491,6 +659,9 @@ static void cind_response_p(int argc, const char **argv)
int signal;
int roam;
int batt_chg;
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ bt_bdaddr_t addr;
+#endif

RETURN_IF_NULL(if_hf);

@@ -543,14 +714,25 @@ static void cind_response_p(int argc, const char **argv)
}
batt_chg = atoi(argv[8]);

+#if ANDROID_VERSION <= PLATFORM_VER(4, 4, 4)
EXEC(if_hf->cind_response, svc, num_active, num_held, call_setup_state,
signal, roam, batt_chg);
+#else
+ VERIFY_ADDR_ARG(9, &addr);
+
+ EXEC(if_hf->cind_response, svc, num_active, num_held, call_setup_state,
+ signal, roam, batt_chg, &addr);
+#endif
}

/* Pre-formatted AT response, typically in response to unknown AT cmd */

static void formatted_at_response_p(int argc, const char **argv)
{
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ bt_bdaddr_t addr;
+#endif
+
RETURN_IF_NULL(if_hf);

/* response */
@@ -559,7 +741,13 @@ static void formatted_at_response_p(int argc, const char **argv)
return;
}

+#if ANDROID_VERSION <= PLATFORM_VER(4, 4, 4)
EXEC(if_hf->formatted_at_response, argv[2]);
+#else
+ VERIFY_ADDR_ARG(3, &addr);
+
+ EXEC(if_hf->formatted_at_response, argv[2], &addr);
+#endif
}

/* at_response */
@@ -577,6 +765,9 @@ static void at_response_p(int argc, const char **argv)
{
bthf_at_response_t response_code;
int error_code;
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ bt_bdaddr_t addr;
+#endif

RETURN_IF_NULL(if_hf);

@@ -593,7 +784,13 @@ static void at_response_p(int argc, const char **argv)
else
error_code = atoi(argv[3]);

+#if ANDROID_VERSION <= PLATFORM_VER(4, 4, 4)
EXEC(if_hf->at_response, response_code, error_code);
+#else
+ VERIFY_ADDR_ARG(4, &addr);
+
+ EXEC(if_hf->at_response, response_code, error_code, &addr);
+#endif
}

/* response for CLCC command */
@@ -628,6 +825,9 @@ static void clcc_response_p(int argc, const char **argv)
bthf_call_mpty_type_t mpty;
const char *number;
bthf_call_addrtype_t type;
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ bt_bdaddr_t addr;
+#endif

RETURN_IF_NULL(if_hf);

@@ -680,8 +880,15 @@ static void clcc_response_p(int argc, const char **argv)
}
type = str2bthf_call_addrtype_t(argv[8]);

+#if ANDROID_VERSION <= PLATFORM_VER(4, 4, 4)
EXEC(if_hf->clcc_response, index, dir, state, mode, mpty, number,
type);
+#else
+ VERIFY_ADDR_ARG(9, &addr);
+
+ EXEC(if_hf->clcc_response, index, dir, state, mode, mpty, number,
+ type, &addr);
+#endif
}

/* phone state change */
--
1.9.1


2014-11-04 08:18:33

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 10/47] android/hal-sco: Save bd_addr for input stream of Audio SCO HAL

From: Andrei Emeltchenko <[email protected]>

Make use of address field which makes possible to query right SCO fd
from handsfree multi-client code.
---
android/hal-sco.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/android/hal-sco.c b/android/hal-sco.c
index d5af29d..b6d95a1 100644
--- a/android/hal-sco.c
+++ b/android/hal-sco.c
@@ -103,6 +103,8 @@ struct sco_stream_in {
struct resampler_itfe *resampler;
int16_t *resample_buf;
uint32_t resample_frame_num;
+
+ bt_bdaddr_t bd_addr;
};

struct sco_dev {
@@ -1150,6 +1152,14 @@ static int sco_open_input_stream(struct audio_hw_device *dev,
in->stream.read = in_read;
in->stream.get_input_frames_lost = in_get_input_frames_lost;

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ if (address) {
+ DBG("address %s", address);
+
+ str2bt_bdaddr_t(address, &in->bd_addr);
+ }
+#endif
+
if (config) {
DBG("config: rate %u chan mask %x format %d offload %p",
config->sample_rate, config->channel_mask,
--
1.9.1


2014-11-04 08:18:40

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 17/47] android/client: Support new API for SCO HAL

From: Andrei Emeltchenko <[email protected]>

Add support for new parameters in open_output_stream() and
open_inut_stream().
---
android/client/if-sco.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/android/client/if-sco.c b/android/client/if-sco.c
index e7197b2..96dc083 100644
--- a/android/client/if-sco.c
+++ b/android/client/if-sco.c
@@ -62,7 +62,9 @@ SINTMAP(audio_channel_mask_t, -1, "(AUDIO_CHANNEL_INVALID)")
DELEMENT(AUDIO_CHANNEL_OUT_MONO),
DELEMENT(AUDIO_CHANNEL_OUT_STEREO),
DELEMENT(AUDIO_CHANNEL_OUT_QUAD),
+#if ANDROID_VERSION <= PLATFORM_VER(4, 4, 4)
DELEMENT(AUDIO_CHANNEL_OUT_SURROUND),
+#endif
DELEMENT(AUDIO_CHANNEL_OUT_5POINT1),
DELEMENT(AUDIO_CHANNEL_OUT_7POINT1),
DELEMENT(AUDIO_CHANNEL_OUT_ALL),
@@ -509,12 +511,21 @@ static void open_output_stream_p(int argc, const char **argv)
config->format = AUDIO_FORMAT_PCM_16_BIT;
}

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ err = if_audio_sco->open_output_stream(if_audio_sco,
+ 0,
+ AUDIO_DEVICE_OUT_ALL_SCO,
+ AUDIO_OUTPUT_FLAG_NONE,
+ config,
+ &stream_out, NULL);
+#else
err = if_audio_sco->open_output_stream(if_audio_sco,
0,
AUDIO_DEVICE_OUT_ALL_SCO,
AUDIO_OUTPUT_FLAG_NONE,
config,
&stream_out);
+#endif
if (err < 0) {
haltest_error("open output stream returned %d\n", err);
goto failed;
@@ -572,11 +583,19 @@ static void open_input_stream_p(int argc, const char **argv)
config->format = AUDIO_FORMAT_PCM_16_BIT;
}

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ err = if_audio_sco->open_input_stream(if_audio_sco,
+ 0,
+ AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET,
+ config,
+ &stream_in, 0, NULL, 0);
+#else
err = if_audio_sco->open_input_stream(if_audio_sco,
0,
AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET,
config,
&stream_in);
+#endif
if (err < 0) {
haltest_error("open output stream returned %d\n", err);
goto failed;
--
1.9.1


2014-11-04 08:18:38

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 15/47] android/gatt: Add support for new parameter in srv connect()

From: Andrei Emeltchenko <[email protected]>

Support transport parameter in new Android API.
---
android/gatt.c | 2 ++
android/hal-gatt.c | 8 ++++++++
android/hal-msg.h | 1 +
3 files changed, 11 insertions(+)

diff --git a/android/gatt.c b/android/gatt.c
index e930b5a..7cf612f 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -4184,6 +4184,8 @@ static void handle_server_connect(const void *buf, uint16_t len)

android2bdaddr(&cmd->bdaddr, &addr);

+ /* TODO: Handle transport flag */
+
status = handle_connect(cmd->server_if, &addr);

ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT, HAL_OP_GATT_SERVER_CONNECT,
diff --git a/android/hal-gatt.c b/android/hal-gatt.c
index 9379192..d525603 100644
--- a/android/hal-gatt.c
+++ b/android/hal-gatt.c
@@ -1124,8 +1124,13 @@ static bt_status_t unregister_server(int server_if)
sizeof(cmd), &cmd, NULL, NULL, NULL);
}

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static bt_status_t server_connect(int server_if, const bt_bdaddr_t *bd_addr,
+ bool is_direct, int transport)
+#else
static bt_status_t server_connect(int server_if, const bt_bdaddr_t *bd_addr,
bool is_direct)
+#endif
{
struct hal_cmd_gatt_server_connect cmd;

@@ -1134,6 +1139,9 @@ static bt_status_t server_connect(int server_if, const bt_bdaddr_t *bd_addr,

cmd.server_if = server_if;
cmd.is_direct = is_direct;
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ cmd.transport = transport;
+#endif

memcpy(cmd.bdaddr, bd_addr, sizeof(*bd_addr));

diff --git a/android/hal-msg.h b/android/hal-msg.h
index 8dd00a0..1876d6b 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -919,6 +919,7 @@ struct hal_cmd_gatt_server_connect {
int32_t server_if;
uint8_t bdaddr[6];
uint8_t is_direct;
+ int32_t transport;
} __attribute__((packed));

#define HAL_OP_GATT_SERVER_DISCONNECT 0x1a
--
1.9.1


2014-11-04 08:18:39

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 16/47] android/client: Support new API for Audio HAL

From: Andrei Emeltchenko <[email protected]>

Add support for new parameter in open_output_stream().
---
android/client/if-audio.c | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/android/client/if-audio.c b/android/client/if-audio.c
index f3f87fb..41604d9 100644
--- a/android/client/if-audio.c
+++ b/android/client/if-audio.c
@@ -60,7 +60,9 @@ SINTMAP(audio_channel_mask_t, -1, "(AUDIO_CHANNEL_INVALID)")
DELEMENT(AUDIO_CHANNEL_OUT_MONO),
DELEMENT(AUDIO_CHANNEL_OUT_STEREO),
DELEMENT(AUDIO_CHANNEL_OUT_QUAD),
+#if ANDROID_VERSION <= PLATFORM_VER(4, 4, 4)
DELEMENT(AUDIO_CHANNEL_OUT_SURROUND),
+#endif
DELEMENT(AUDIO_CHANNEL_OUT_5POINT1),
DELEMENT(AUDIO_CHANNEL_OUT_7POINT1),
DELEMENT(AUDIO_CHANNEL_OUT_ALL),
@@ -305,12 +307,21 @@ static void open_output_stream_p(int argc, const char **argv)
}
pthread_mutex_unlock(&state_mutex);

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ err = if_audio->open_output_stream(if_audio,
+ 0,
+ AUDIO_DEVICE_OUT_ALL_A2DP,
+ AUDIO_OUTPUT_FLAG_NONE,
+ NULL,
+ &stream_out, NULL);
+#else
err = if_audio->open_output_stream(if_audio,
0,
AUDIO_DEVICE_OUT_ALL_A2DP,
AUDIO_OUTPUT_FLAG_NONE,
NULL,
&stream_out);
+#endif
if (err < 0) {
haltest_error("open output stream returned %d\n", err);
return;
--
1.9.1


2014-11-04 08:18:37

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 14/47] android/gatt: Add support for new parameter for connect

From: Andrei Emeltchenko <[email protected]>

Add support for new parameter in gatt client connect() for new Android
API.
---
android/gatt.c | 2 ++
android/hal-gatt.c | 8 ++++++++
android/hal-msg.h | 1 +
3 files changed, 11 insertions(+)

diff --git a/android/gatt.c b/android/gatt.c
index 5a531d9..e930b5a 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -2066,6 +2066,8 @@ static void handle_client_connect(const void *buf, uint16_t len)

/* TODO handle is_direct flag */

+ /* TODO handle transport flag */
+
status = handle_connect(cmd->client_if, &addr);

ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT, HAL_OP_GATT_CLIENT_CONNECT,
diff --git a/android/hal-gatt.c b/android/hal-gatt.c
index d0e9184..9379192 100644
--- a/android/hal-gatt.c
+++ b/android/hal-gatt.c
@@ -617,8 +617,13 @@ static bt_status_t scan(int client_if, bool start)
sizeof(cmd), &cmd, NULL, NULL, NULL);
}

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static bt_status_t connect(int client_if, const bt_bdaddr_t *bd_addr,
+ bool is_direct, int transport)
+#else
static bt_status_t connect(int client_if, const bt_bdaddr_t *bd_addr,
bool is_direct)
+#endif
{
struct hal_cmd_gatt_client_connect cmd;

@@ -627,6 +632,9 @@ static bt_status_t connect(int client_if, const bt_bdaddr_t *bd_addr,

cmd.client_if = client_if;
cmd.is_direct = is_direct;
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ cmd.transport = transport;
+#endif

memcpy(cmd.bdaddr, bd_addr, sizeof(*bd_addr));

diff --git a/android/hal-msg.h b/android/hal-msg.h
index bcb73b2..8dd00a0 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -721,6 +721,7 @@ struct hal_cmd_gatt_client_connect {
int32_t client_if;
uint8_t bdaddr[6];
uint8_t is_direct;
+ int32_t transport;
} __attribute__((packed));

#define HAL_OP_GATT_CLIENT_DISCONNECT 0x05
--
1.9.1


2014-11-04 08:18:31

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 08/47] android/hal-sco: Implement dummy SCO HAL functions

From: Andrei Emeltchenko <[email protected]>

Prevent from crash and print debug statements.
---
android/hal-sco.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)

diff --git a/android/hal-sco.c b/android/hal-sco.c
index 7434804..d5e9f0a 100644
--- a/android/hal-sco.c
+++ b/android/hal-sco.c
@@ -1237,6 +1237,51 @@ static int sco_dump(const audio_hw_device_t *device, int fd)
return 0;
}

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static int set_master_mute(struct audio_hw_device *dev, bool mute)
+{
+ DBG("");
+ return -ENOSYS;
+}
+
+static int get_master_mute(struct audio_hw_device *dev, bool *mute)
+{
+ DBG("");
+ return -ENOSYS;
+}
+
+static int create_audio_patch(struct audio_hw_device *dev,
+ unsigned int num_sources,
+ const struct audio_port_config *sources,
+ unsigned int num_sinks,
+ const struct audio_port_config *sinks,
+ audio_patch_handle_t *handle)
+{
+ DBG("");
+ return -ENOSYS;
+}
+
+static int release_audio_patch(struct audio_hw_device *dev,
+ audio_patch_handle_t handle)
+{
+ DBG("");
+ return -ENOSYS;
+}
+
+static int get_audio_port(struct audio_hw_device *dev, struct audio_port *port)
+{
+ DBG("");
+ return -ENOSYS;
+}
+
+static int set_audio_port_config(struct audio_hw_device *dev,
+ const struct audio_port_config *config)
+{
+ DBG("");
+ return -ENOSYS;
+}
+#endif
+
static int sco_close(hw_device_t *device)
{
DBG("");
@@ -1390,6 +1435,14 @@ static int sco_open(const hw_module_t *module, const char *name,
dev->dev.open_input_stream = sco_open_input_stream;
dev->dev.close_input_stream = sco_close_input_stream;
dev->dev.dump = sco_dump;
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ dev->dev.set_master_mute = set_master_mute;
+ dev->dev.get_master_mute = get_master_mute;
+ dev->dev.create_audio_patch = create_audio_patch;
+ dev->dev.release_audio_patch = release_audio_patch;
+ dev->dev.get_audio_port = get_audio_port;
+ dev->dev.set_audio_port_config = set_audio_port_config;
+#endif

*device = &dev->dev.common;

--
1.9.1


2014-11-04 08:18:32

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 09/47] android/hal-sco: Save bd_addr for output stream of Audio SCO HAL

From: Andrei Emeltchenko <[email protected]>

Make use of address field which makes possible to query right SCO fd
from handsfree multi-client code.
---
android/Android.mk | 3 ++-
android/hal-sco.c | 10 ++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/android/Android.mk b/android/Android.mk
index aefe41c..bfdf03f 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -382,7 +382,8 @@ include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS)

-LOCAL_SRC_FILES := bluez/android/hal-sco.c
+LOCAL_SRC_FILES := bluez/android/hal-sco.c \
+ bluez/android/hal-utils.c

LOCAL_C_INCLUDES = \
$(call include-path-for, system-core) \
diff --git a/android/hal-sco.c b/android/hal-sco.c
index d5e9f0a..d5af29d 100644
--- a/android/hal-sco.c
+++ b/android/hal-sco.c
@@ -79,6 +79,8 @@ struct sco_stream_out {
struct resampler_itfe *resampler;
int16_t *resample_buf;
uint32_t resample_frame_num;
+
+ bt_bdaddr_t bd_addr;
};

static void sco_close_socket(void)
@@ -676,6 +678,14 @@ static int sco_open_output_stream(struct audio_hw_device *dev,
out->stream.write = out_write;
out->stream.get_render_position = out_get_render_position;

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ if (address) {
+ DBG("address %s", address);
+
+ str2bt_bdaddr_t(address, &out->bd_addr);
+ }
+#endif
+
if (config) {
DBG("config: rate %u chan mask %x format %d offload %p",
config->sample_rate, config->channel_mask,
--
1.9.1


2014-11-04 08:18:43

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 20/47] android/client: Add support for new GATT HAL API

From: Andrei Emeltchenko <[email protected]>

Support scan(), client and server connect() commands new API.
---
android/client/if-gatt.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)

diff --git a/android/client/if-gatt.c b/android/client/if-gatt.c
index d593022..d749922 100644
--- a/android/client/if-gatt.c
+++ b/android/client/if-gatt.c
@@ -933,6 +933,7 @@ static void scan_p(int argc, const char **argv)

RETURN_IF_NULL(if_gatt);

+#if ANDROID_VERSION <= PLATFORM_VER(4, 4, 4)
VERIFY_CLIENT_IF(2, client_if);

/* start */
@@ -940,6 +941,13 @@ static void scan_p(int argc, const char **argv)
start = atoi(argv[3]);

EXEC(if_gatt->client->scan, client_if, start);
+#else
+ /* start */
+ if (argc >= 3)
+ start = atoi(argv[2]);
+
+ EXEC(if_gatt->client->scan, start);
+#endif
}

/* connect */
@@ -961,6 +969,9 @@ static void connect_p(int argc, const char **argv)
int client_if;
bt_bdaddr_t bd_addr;
int is_direct = 1;
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ int transport = 1;
+#endif

RETURN_IF_NULL(if_gatt);
VERIFY_CLIENT_IF(2, client_if);
@@ -970,7 +981,16 @@ static void connect_p(int argc, const char **argv)
if (argc > 4)
is_direct = atoi(argv[4]);

+#if ANDROID_VERSION <= PLATFORM_VER(4, 4, 4)
EXEC(if_gatt->client->connect, client_if, &bd_addr, is_direct);
+#else
+ /* transport */
+ if (argc > 5)
+ transport = atoi(argv[5]);
+
+ EXEC(if_gatt->client->connect, client_if, &bd_addr, is_direct,
+ transport);
+#endif
}

/* disconnect */
@@ -1574,6 +1594,9 @@ static void gatts_connect_p(int argc, const char *argv[])
int server_if;
bt_bdaddr_t bd_addr;
int is_direct = 1;
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ int transport = 1;
+#endif

RETURN_IF_NULL(if_gatt);
VERIFY_SERVER_IF(2, server_if);
@@ -1583,7 +1606,16 @@ static void gatts_connect_p(int argc, const char *argv[])
if (argc > 4)
is_direct = atoi(argv[4]);

+#if ANDROID_VERSION <= PLATFORM_VER(4, 4, 4)
EXEC(if_gatt->server->connect, server_if, &bd_addr, is_direct);
+#else
+ /* transport */
+ if (argc > 5)
+ transport = atoi(argv[5]);
+
+ EXEC(if_gatt->server->connect, server_if, &bd_addr, is_direct,
+ transport);
+#endif
}

/* disconnect */
--
1.9.1


2014-11-04 08:19:08

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 45/47] android/handsfree: Use bdaddr provided for find_device()

From: Andrei Emeltchenko <[email protected]>

---
android/handsfree.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/android/handsfree.c b/android/handsfree.c
index 358e368..67df4cf 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -2901,14 +2901,18 @@ static void disable_sco_server(void)

static void bt_sco_get_fd(const void *buf, uint16_t len)
{
- int fd;
- GError *err;
+ const struct sco_cmd_get_fd *cmd = buf;
struct sco_rsp_get_fd rsp;
struct hf_device *dev;
+ bdaddr_t bdaddr;
+ GError *err;
+ int fd;

DBG("");

- dev = find_default_device();
+ android2bdaddr(cmd->bdaddr, &bdaddr);
+
+ dev = find_device(&bdaddr);
if (!dev || !dev->sco)
goto failed;

--
1.9.1


2014-11-04 08:18:56

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 33/47] 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 01663ec..ccd30a1 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(4, 4, 4)
+ 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 cfde814..8a77b06 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 26d01bb..d31b14a 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -596,6 +596,7 @@ static void at_cmd_chup(struct hfp_gw_result *result, 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_gw_result *result, enum hfp_gw_cmd_type type,
if (hfp_gw_result_has_next(result))
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-04 08:18:41

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 18/47] android/client: Add new API argument for scan()

From: Andrei Emeltchenko <[email protected]>

New Android API has new argument transport.
---
android/client/if-bt.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/android/client/if-bt.c b/android/client/if-bt.c
index 2d7ac79..306e237 100644
--- a/android/client/if-bt.c
+++ b/android/client/if-bt.c
@@ -609,11 +609,23 @@ static void cancel_discovery_p(int argc, const char **argv)
static void create_bond_p(int argc, const char **argv)
{
bt_bdaddr_t addr;
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ int transport;
+#endif

RETURN_IF_NULL(if_bluetooth);
VERIFY_ADDR_ARG(2, &addr);

+#if ANDROID_VERSION <= PLATFORM_VER(4, 4, 4)
EXEC(if_bluetooth->create_bond, &addr);
+#else
+ if (argc < 3)
+ transport = 0;
+ else
+ transport = atoi(argv[3]);
+
+ EXEC(if_bluetooth->create_bond, &addr, transport);
+#endif
}

/* Just addres to complete, use complete_addr_c */
--
1.9.1


2014-11-04 08:18:42

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 19/47] android/client: Add support for new Android API for PAN HAL

From: Andrei Emeltchenko <[email protected]>

Fixes parameters order for new API.
---
android/client/if-pan.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/android/client/if-pan.c b/android/client/if-pan.c
index 6207f6e..c128482 100644
--- a/android/client/if-pan.c
+++ b/android/client/if-pan.c
@@ -40,8 +40,13 @@ SINTMAP(btpan_control_state_t, -1, "(unknown)")
DELEMENT(BTPAN_STATE_DISABLED),
ENDMAP

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static void control_state_cb(btpan_control_state_t state, int local_role,
+ bt_status_t error, const char *ifname)
+#else
static void control_state_cb(btpan_control_state_t state, bt_status_t error,
int local_role, const char *ifname)
+#endif
{
haltest_info("%s: state=%s error=%s local_role=%s ifname=%s\n",
__func__, btpan_control_state_t2str(state),
--
1.9.1


2014-11-04 08:18:47

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 24/47] android/handsfree: Add support for new API for stop_vr

From: Andrei Emeltchenko <[email protected]>

stop_voice_recognition() in new Android API has bd_addr parameter.
---
android/hal-handsfree.c | 20 ++++++++++++++++++++
android/hal-ipc-api.txt | 2 +-
android/hal-msg.h | 3 +++
android/handsfree.c | 6 +++++-
4 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index ffc9497..8b4f026 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -371,6 +371,25 @@ static bt_status_t start_voice_recognition(void)
}
#endif

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static bt_status_t stop_voice_recognition(bt_bdaddr_t *bd_addr)
+{
+ struct hal_cmd_handsfree_stop_vr cmd;
+
+ DBG("");
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ if (!bd_addr)
+ return BT_STATUS_PARM_INVALID;
+
+ 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);
+}
+#else
static bt_status_t stop_voice_recognition(void)
{
DBG("");
@@ -381,6 +400,7 @@ static bt_status_t stop_voice_recognition(void)
return hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE, HAL_OP_HANDSFREE_STOP_VR,
0, NULL, NULL, NULL, NULL);
}
+#endif

static bt_status_t volume_control(bthf_volume_type_t type, int volume)
{
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 2dacffd..bdf76c9 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 d858caf..410b979 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


2014-11-04 08:18:46

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 23/47] android/handsfree: Add support for new API for start_vr

From: Andrei Emeltchenko <[email protected]>

start_voice_recognition() in new Android API has bd_addr parameter.
---
android/hal-handsfree.c | 20 ++++++++++++++++++++
android/hal-ipc-api.txt | 2 +-
android/hal-msg.h | 3 +++
android/handsfree.c | 6 +++++-
4 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index 5ed4497..ffc9497 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -340,6 +340,25 @@ static bt_status_t disconnect_audio(bt_bdaddr_t *bd_addr)
&cmd, NULL, NULL, NULL);
}

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static bt_status_t start_voice_recognition(bt_bdaddr_t *bd_addr)
+{
+ struct hal_cmd_handsfree_start_vr cmd;
+
+ DBG("");
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ if (!bd_addr)
+ return BT_STATUS_PARM_INVALID;
+
+ 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);
+}
+#else
static bt_status_t start_voice_recognition(void)
{
DBG("");
@@ -350,6 +369,7 @@ static bt_status_t start_voice_recognition(void)
return hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE, HAL_OP_HANDSFREE_START_VR,
0, NULL, NULL, NULL, NULL);
}
+#endif

static bt_status_t stop_voice_recognition(void)
{
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 4a9e261..2dacffd 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 b54a606..d858caf 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


2014-11-04 08:18:29

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 06/47] android/hal-sco: Add support for new Android API

From: Andrei Emeltchenko <[email protected]>

Add new parameters to sco_open_input_stream() and
sco_open_output_stream() for the new API.
---
android/hal-sco.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)

diff --git a/android/hal-sco.c b/android/hal-sco.c
index 91a3baf..231be33 100644
--- a/android/hal-sco.c
+++ b/android/hal-sco.c
@@ -612,12 +612,22 @@ static int out_remove_audio_effect(const struct audio_stream *stream,
return -ENOSYS;
}

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static int sco_open_output_stream(struct audio_hw_device *dev,
+ audio_io_handle_t handle,
+ audio_devices_t devices,
+ audio_output_flags_t flags,
+ struct audio_config *config,
+ struct audio_stream_out **stream_out,
+ const char *address)
+#else
static int sco_open_output_stream(struct audio_hw_device *dev,
audio_io_handle_t handle,
audio_devices_t devices,
audio_output_flags_t flags,
struct audio_config *config,
struct audio_stream_out **stream_out)
+#endif
{
struct sco_dev *adev = (struct sco_dev *) dev;
struct sco_stream_out *out;
@@ -1060,11 +1070,22 @@ static uint32_t in_get_input_frames_lost(struct audio_stream_in *stream)
return -ENOSYS;
}

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static int sco_open_input_stream(struct audio_hw_device *dev,
+ audio_io_handle_t handle,
+ audio_devices_t devices,
+ struct audio_config *config,
+ struct audio_stream_in **stream_in,
+ audio_input_flags_t flags,
+ const char *address,
+ audio_source_t source)
+#else
static int sco_open_input_stream(struct audio_hw_device *dev,
audio_io_handle_t handle,
audio_devices_t devices,
struct audio_config *config,
struct audio_stream_in **stream_in)
+#endif
{
struct sco_dev *sco_dev = (struct sco_dev *) dev;
struct sco_stream_in *in;
--
1.9.1


2014-11-04 08:19:10

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 47/47] android/build: Disable declaration-after-statement warnings

From: Andrei Emeltchenko <[email protected]>

When building Android system libraries for Audio HAL produce lots of
warnings.
---
android/Android.mk | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/android/Android.mk b/android/Android.mk
index bfdf03f..16f94b9 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -367,7 +367,7 @@ LOCAL_SHARED_LIBRARIES := \
libcutils \
libsbc \

-LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
+LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS) -Wno-declaration-after-statement
LOCAL_LDFLAGS := -ldl

LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
@@ -394,7 +394,7 @@ LOCAL_SHARED_LIBRARIES := \
libcutils \
libaudioutils \

-LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
+LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS) -Wno-declaration-after-statement

LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
LOCAL_MODULE_TAGS := optional
--
1.9.1


2014-11-04 08:19:09

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 46/47] android/handsfree: Return default device for zero bdaddr

From: Andrei Emeltchenko <[email protected]>

For the old Android API use find_default_device() function.
---
android/handsfree.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/android/handsfree.c b/android/handsfree.c
index 67df4cf..baa2893 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -290,6 +290,11 @@ static bool match_by_bdaddr(const void *data, const void *match_data)

static struct hf_device *find_device(const bdaddr_t *bdaddr)
{
+ uint8_t zero_addr[6] = { 0 };
+
+ if (!memcmp(bdaddr, zero_addr, sizeof(zero_addr)))
+ return find_default_device();
+
return queue_find(devices, match_by_bdaddr, bdaddr);
}

--
1.9.1


2014-11-04 08:18:45

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 22/47] android/handsfree: Add support for new API for handsfree init

From: Andrei Emeltchenko <[email protected]>

Add max_client parameter to IPC following new parameter for HF init().
---
android/hal-handsfree.c | 10 ++++++++++
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, 20 insertions(+), 3 deletions(-)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index 0c51789..5ed4497 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -226,7 +226,11 @@ static uint8_t get_mode(void)
return HAL_MODE_HANDSFREE_HSP_ONLY;
}

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static bt_status_t init(bthf_callbacks_t *callbacks, int max_hf_clients)
+#else
static bt_status_t init(bthf_callbacks_t *callbacks)
+#endif
{
struct hal_cmd_register_module cmd;
int ret;
@@ -244,6 +248,12 @@ static bt_status_t init(bthf_callbacks_t *callbacks)
cmd.service_id = HAL_SERVICE_ID_HANDSFREE;
cmd.mode = get_mode();

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ cmd.max_clients = max_hf_clients;
+#else
+ cmd.max_clients = 1;
+#endif
+
ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
sizeof(cmd), &cmd, NULL, NULL, NULL);

diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 3a3ae92..4a9e261 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 aaf4f7a..b54a606 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


2014-11-04 08:18:35

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 12/47] android/hal-sco: Use bdaddr parameter in Get SCO fd command

From: Andrei Emeltchenko <[email protected]>

---
android/hal-sco.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/android/hal-sco.c b/android/hal-sco.c
index b6d95a1..1daeaac 100644
--- a/android/hal-sco.c
+++ b/android/hal-sco.c
@@ -281,20 +281,23 @@ failed:
return SCO_STATUS_FAILED;
}

-static int ipc_get_sco_fd(void)
+static int ipc_get_sco_fd(bt_bdaddr_t *bd_addr)
{
int ret = SCO_STATUS_SUCCESS;

pthread_mutex_lock(&sco_mutex);

if (sco_fd < 0) {
+ struct sco_cmd_get_fd cmd;
struct sco_rsp_get_fd rsp;
size_t rsp_len = sizeof(rsp);

DBG("Getting SCO fd");

- ret = sco_ipc_cmd(SCO_SERVICE_ID, SCO_OP_GET_FD, 0, NULL,
- &rsp_len, &rsp, &sco_fd);
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+
+ ret = sco_ipc_cmd(SCO_SERVICE_ID, SCO_OP_GET_FD, sizeof(cmd),
+ &cmd, &rsp_len, &rsp, &sco_fd);

/* Sometimes mtu returned is wrong */
sco_mtu = /* rsp.mtu */ 48;
@@ -453,7 +456,7 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,

DBG("write to fd %d bytes %zu", sco_fd, bytes);

- if (ipc_get_sco_fd() != SCO_STATUS_SUCCESS)
+ if (ipc_get_sco_fd(&out->bd_addr) != SCO_STATUS_SUCCESS)
return -1;

if (!out->downmix_buf) {
@@ -654,9 +657,6 @@ static int sco_open_output_stream(struct audio_hw_device *dev,
return -EIO;
}

- if (ipc_get_sco_fd() != SCO_STATUS_SUCCESS)
- DBG("SCO is not connected yet; get fd on write()");
-
out = calloc(1, sizeof(struct sco_stream_out));
if (!out)
return -ENOMEM;
@@ -688,6 +688,9 @@ static int sco_open_output_stream(struct audio_hw_device *dev,
}
#endif

+ if (ipc_get_sco_fd(&out->bd_addr) != SCO_STATUS_SUCCESS)
+ DBG("SCO is not connected yet; get fd on write()");
+
if (config) {
DBG("config: rate %u chan mask %x format %d offload %p",
config->sample_rate, config->channel_mask,
@@ -1047,7 +1050,7 @@ static ssize_t in_read(struct audio_stream_in *stream, void *buffer,

DBG("Read from fd %d bytes %zu", sco_fd, bytes);

- if (ipc_get_sco_fd() != SCO_STATUS_SUCCESS)
+ if (ipc_get_sco_fd(&in->bd_addr) != SCO_STATUS_SUCCESS)
return -1;

if (!in->resampler && in->cfg.rate != AUDIO_STREAM_SCO_RATE) {
--
1.9.1


2014-11-04 08:18:34

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 11/47] android/hal-sco: Add remote address parameter in Get SCO fd command

From: Andrei Emeltchenko <[email protected]>

---
android/sco-ipc-api.txt | 2 +-
android/sco-msg.h | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/android/sco-ipc-api.txt b/android/sco-ipc-api.txt
index 17372fe..27d5ef2 100644
--- a/android/sco-ipc-api.txt
+++ b/android/sco-ipc-api.txt
@@ -32,6 +32,6 @@ SCO Audio Service (ID 0)

Opcode 0x01 - Get SCO fd command

- Command parameters: <none>
+ Command parameters: Remote address (6 octets)
Response parameters: MTU (2 octets)
File descriptor (inline)
diff --git a/android/sco-msg.h b/android/sco-msg.h
index 74f25b8..d1b13d7 100644
--- a/android/sco-msg.h
+++ b/android/sco-msg.h
@@ -31,6 +31,10 @@ static const char BLUEZ_SCO_SK_PATH[] = "\0bluez_sco_socket";
#define SCO_OP_STATUS IPC_OP_STATUS

#define SCO_OP_GET_FD 0x01
+struct sco_cmd_get_fd {
+ uint8_t bdaddr[6];
+} __attribute__((packed));
+
struct sco_rsp_get_fd {
uint16_t mtu;
} __attribute__((packed));
--
1.9.1


2014-11-04 08:18:48

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 25/47] android/handsfree: Add support for new API for volume_control

From: Andrei Emeltchenko <[email protected]>

volume_control() in new Android API has bd_addr parameter.
---
android/hal-handsfree.c | 12 ++++++++++++
android/hal-ipc-api.txt | 1 +
android/hal-msg.h | 1 +
android/handsfree.c | 5 ++++-
4 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index 8b4f026..ef42ad4 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -402,7 +402,12 @@ static bt_status_t stop_voice_recognition(void)
}
#endif

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static bt_status_t volume_control(bthf_volume_type_t type, int volume,
+ bt_bdaddr_t *bd_addr)
+#else
static bt_status_t volume_control(bthf_volume_type_t type, int volume)
+#endif
{
struct hal_cmd_handsfree_volume_control cmd;

@@ -414,6 +419,13 @@ static bt_status_t volume_control(bthf_volume_type_t type, int volume)
cmd.type = type;
cmd.volume = volume;

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ if (!bd_addr)
+ return BT_STATUS_PARM_INVALID;
+
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+#endif
+
return hal_ipc_cmd(HAL_SERVICE_ID_HANDSFREE,
HAL_OP_HANDSFREE_VOLUME_CONTROL, sizeof(cmd),
&cmd, NULL, NULL, NULL);
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index bdf76c9..902141c 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 410b979..d948eec 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


2014-11-04 08:18:55

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 32/47] 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 88636a3..01663ec 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(4, 4, 4)
+ 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 cabf32d..cfde814 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 99057b0..26d01bb 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -493,6 +493,7 @@ static void at_cmd_a(struct hfp_gw_result *result, 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_gw_result *result, enum hfp_gw_cmd_type type,
if (hfp_gw_result_has_next(result))
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


2014-11-04 08:18:54

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 31/47] 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 f19ca1a..88636a3 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(4, 4, 4)
+ 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 4181d40..cabf32d 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 ba94011..99057b0 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -822,6 +822,8 @@ static void at_cmd_bvra(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
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-04 08:19:02

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 39/47] 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 bebeef7..f3f537b 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(4, 4, 4)
+ 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 baea3a1..6587021 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 eba761f..211e628 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -752,6 +752,7 @@ static void at_cmd_cnum(struct hfp_gw_result *result, 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_gw_result *result, enum hfp_gw_cmd_type type,
if (hfp_gw_result_has_next(result))
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-04 08:19:04

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 41/47] 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 c41209c..3fa91e9 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(4, 4, 4)
+ 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 8a95f6c..2b4f362 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 2e624a4..c4c031b 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -418,6 +418,7 @@ static void at_cmd_cops(struct hfp_gw_result *result, 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_gw_result *result, enum hfp_gw_cmd_type type,
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-04 08:19:03

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 40/47] 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 f3f537b..c41209c 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(4, 4, 4)
+ 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 6587021..8a95f6c 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 211e628..2e624a4 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -1246,6 +1246,7 @@ static void at_cmd_cind(struct hfp_gw_result *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_gw_result *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-04 08:18:51

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 28/47] android/handsfree: Add support for new API for formatted_at_response

From: Andrei Emeltchenko <[email protected]>

formatted_at_response has new parameter bdaddr in new Android API.
---
android/hal-handsfree.c | 11 +++++++++++
android/hal-ipc-api.txt | 1 +
android/hal-msg.h | 1 +
android/handsfree.c | 5 ++++-
4 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index b240f84..058df79 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -526,7 +526,11 @@ 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(4, 4, 4)
+static bt_status_t formatted_at_response(const char *rsp, bt_bdaddr_t *bd_addr)
+#else
static bt_status_t formatted_at_response(const char *rsp)
+#endif
{
char buf[IPC_MTU];
struct hal_cmd_handsfree_formatted_at_response *cmd = (void *) buf;
@@ -540,6 +544,13 @@ static bt_status_t formatted_at_response(const char *rsp)
if (!rsp)
return BT_STATUS_PARM_INVALID;

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ if (!bd_addr)
+ return BT_STATUS_PARM_INVALID;
+
+ memcpy(cmd->bdaddr, bd_addr, sizeof(cmd->bdaddr));
+#endif
+
cmd->len = strlen(rsp) + 1;
memcpy(cmd->buf, rsp, cmd->len);

diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 27572e4..806114a 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 3ef19d7..19a46f6 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


2014-11-04 08:18:52

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 29/47] android/handsfree: Add support for new API for at_response

From: Andrei Emeltchenko <[email protected]>

at_response has new parameter bdaddr in new Android API.
---
android/hal-handsfree.c | 12 ++++++++++++
android/hal-ipc-api.txt | 1 +
android/hal-msg.h | 1 +
android/handsfree.c | 5 ++++-
4 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index 058df79..e9388b8 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -561,7 +561,12 @@ static bt_status_t formatted_at_response(const char *rsp)
len, cmd, NULL, NULL, NULL);
}

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static bt_status_t at_response(bthf_at_response_t response, int error,
+ bt_bdaddr_t *bd_addr)
+#else
static bt_status_t at_response(bthf_at_response_t response, int error)
+#endif
{
struct hal_cmd_handsfree_at_response cmd;

@@ -570,6 +575,13 @@ static bt_status_t at_response(bthf_at_response_t response, int error)
if (!interface_ready())
return BT_STATUS_NOT_READY;

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ if (!bd_addr)
+ return BT_STATUS_PARM_INVALID;
+
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+#endif
+
cmd.response = response;
cmd.error = error;

diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 806114a..b5d5557 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 19a46f6..92a341a 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


2014-11-04 08:18:36

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 13/47] android/gatt: Add support for new API

From: Andrei Emeltchenko <[email protected]>

In new Android API client_if parameter is removed.
---
android/gatt.c | 14 ++++++++------
android/hal-gatt.c | 8 ++++++++
2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/android/gatt.c b/android/gatt.c
index b3dd6d3..5a531d9 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -1730,15 +1730,17 @@ static void handle_client_scan(const void *buf, uint16_t len)
{
const struct hal_cmd_gatt_client_scan *cmd = buf;
uint8_t status;
- void *registered;

DBG("new state %d", cmd->start);

- registered = find_app_by_id(cmd->client_if);
- if (!registered) {
- error("gatt: Client not registered");
- status = HAL_STATUS_FAILED;
- goto reply;
+ if (cmd->client_if != 0) {
+ void *registered = find_app_by_id(cmd->client_if);
+
+ if (!registered) {
+ error("gatt: Client not registered");
+ status = HAL_STATUS_FAILED;
+ goto reply;
+ }
}

/* Turn off scan */
diff --git a/android/hal-gatt.c b/android/hal-gatt.c
index c563fe9..d0e9184 100644
--- a/android/hal-gatt.c
+++ b/android/hal-gatt.c
@@ -595,14 +595,22 @@ static bt_status_t unregister_client(int client_if)
sizeof(cmd), &cmd, NULL, NULL, NULL);
}

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static bt_status_t scan(bool start)
+#else
static bt_status_t scan(int client_if, bool start)
+#endif
{
struct hal_cmd_gatt_client_scan cmd;

if (!interface_ready())
return BT_STATUS_NOT_READY;

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ cmd.client_if = 0;
+#else
cmd.client_if = client_if;
+#endif
cmd.start = start;

return hal_ipc_cmd(HAL_SERVICE_ID_GATT, HAL_OP_GATT_CLIENT_SCAN,
--
1.9.1


2014-11-04 08:18:49

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 26/47] android/handsfree: Add support for new API for cops_response

From: Andrei Emeltchenko <[email protected]>

cops_response has new parameter bdaddr in new Android API.
---
android/hal-handsfree.c | 12 ++++++++++++
android/hal-ipc-api.txt | 1 +
android/hal-msg.h | 1 +
android/handsfree.c | 5 ++++-
4 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/android/hal-handsfree.c b/android/hal-handsfree.c
index ef42ad4..f28b8c7 100644
--- a/android/hal-handsfree.c
+++ b/android/hal-handsfree.c
@@ -452,7 +452,11 @@ static bt_status_t device_status_notification(bthf_network_state_t state,
sizeof(cmd), &cmd, NULL, NULL, NULL);
}

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static bt_status_t cops_response(const char *cops, bt_bdaddr_t *bd_addr)
+#else
static bt_status_t cops_response(const char *cops)
+#endif
{
char buf[IPC_MTU];
struct hal_cmd_handsfree_cops_response *cmd = (void *) buf;
@@ -466,6 +470,14 @@ static bt_status_t cops_response(const char *cops)
if (!cops)
return BT_STATUS_PARM_INVALID;

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ if (!bd_addr)
+ return BT_STATUS_PARM_INVALID;
+
+ memcpy(cmd->bdaddr, bd_addr, sizeof(cmd->bdaddr));
+#endif
+
+ /* Size of cmd.buf */
cmd->len = strlen(cops) + 1;
memcpy(cmd->buf, cops, cmd->len);

diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 902141c..4a591b1 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 d948eec..7089f7c 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


2014-11-04 08:18:28

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 05/47] android/hal-audio: Implement dummy Audio HAL functions

From: Andrei Emeltchenko <[email protected]>

Enable debug prints and prevent crash.
---
android/hal-audio.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)

diff --git a/android/hal-audio.c b/android/hal-audio.c
index d140071..12b1569 100644
--- a/android/hal-audio.c
+++ b/android/hal-audio.c
@@ -1320,6 +1320,51 @@ static int audio_dump(const audio_hw_device_t *device, int fd)
return -ENOSYS;
}

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static int set_master_mute(struct audio_hw_device *dev, bool mute)
+{
+ DBG("");
+ return -ENOSYS;
+}
+
+static int get_master_mute(struct audio_hw_device *dev, bool *mute)
+{
+ DBG("");
+ return -ENOSYS;
+}
+
+static int create_audio_patch(struct audio_hw_device *dev,
+ unsigned int num_sources,
+ const struct audio_port_config *sources,
+ unsigned int num_sinks,
+ const struct audio_port_config *sinks,
+ audio_patch_handle_t *handle)
+{
+ DBG("");
+ return -ENOSYS;
+}
+
+static int release_audio_patch(struct audio_hw_device *dev,
+ audio_patch_handle_t handle)
+{
+ DBG("");
+ return -ENOSYS;
+}
+
+static int get_audio_port(struct audio_hw_device *dev, struct audio_port *port)
+{
+ DBG("");
+ return -ENOSYS;
+}
+
+static int set_audio_port_config(struct audio_hw_device *dev,
+ const struct audio_port_config *config)
+{
+ DBG("");
+ return -ENOSYS;
+}
+#endif
+
static int audio_close(hw_device_t *device)
{
struct a2dp_audio_dev *a2dp_dev = (struct a2dp_audio_dev *)device;
@@ -1516,6 +1561,14 @@ static int audio_open(const hw_module_t *module, const char *name,
a2dp_dev->dev.open_input_stream = audio_open_input_stream;
a2dp_dev->dev.close_input_stream = audio_close_input_stream;
a2dp_dev->dev.dump = audio_dump;
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ a2dp_dev->dev.set_master_mute = set_master_mute;
+ a2dp_dev->dev.get_master_mute = get_master_mute;
+ a2dp_dev->dev.create_audio_patch = create_audio_patch;
+ a2dp_dev->dev.release_audio_patch = release_audio_patch;
+ a2dp_dev->dev.get_audio_port = get_audio_port;
+ a2dp_dev->dev.set_audio_port_config = set_audio_port_config;
+#endif

for (i = 0; i < NUM_CODECS; i++) {
const struct audio_codec *codec = audio_codecs[i].get_codec();
--
1.9.1


2014-11-04 08:18:25

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 02/47] android/hal-bluetooth: Add parameter to create_bond

From: Andrei Emeltchenko <[email protected]>

Add parameter to create_bond following new bluetooth.h HAL, transport is
defined in bluedroid include/bt_types.h. Bluetooth daemon shall check
transport parameter and make needed decisions, by default parameter is
unknown and this is the way bluedroid manage it itself.
---
android/hal-bluetooth.c | 13 +++++++++++++
android/hal-ipc-api.txt | 1 +
android/hal-msg.h | 5 +++++
3 files changed, 19 insertions(+)

diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 97440e2..5b6e99d 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -736,7 +736,11 @@ static int cancel_discovery(void)
NULL, NULL, NULL, NULL);
}

+#if ANDROID_VERSION <= PLATFORM_VER(4, 4, 4)
static int create_bond(const bt_bdaddr_t *bd_addr)
+#else
+static int create_bond(const bt_bdaddr_t *bd_addr, int transport)
+#endif
{
struct hal_cmd_create_bond cmd;

@@ -745,6 +749,15 @@ static int create_bond(const bt_bdaddr_t *bd_addr)
if (!interface_ready())
return BT_STATUS_NOT_READY;

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ if (transport < BT_TRANSPORT_UNKNOWN || transport > BT_TRANSPORT_LE)
+ return BT_STATUS_PARM_INVALID;
+
+ cmd.transport = transport;
+#else
+ cmd.transport = BT_TRANSPORT_UNKNOWN;
+#endif
+
memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));

return hal_ipc_cmd(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_CREATE_BOND,
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 6c647b7..3a3ae92 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -275,6 +275,7 @@ Commands and responses:
Opcode 0x0d - Create Bond command/response

Command parameters: Remote address (6 octets)
+ Transport (1 octet)
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 12efcef..bcb73b2 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -190,9 +190,14 @@ struct hal_cmd_get_remote_services {

#define HAL_OP_CANCEL_DISCOVERY 0x0c

+#define BT_TRANSPORT_UNKNOWN 0x00
+#define BT_TRANSPORT_BR_EDR 0x01
+#define BT_TRANSPORT_LE 0x02
+
#define HAL_OP_CREATE_BOND 0x0d
struct hal_cmd_create_bond {
uint8_t bdaddr[6];
+ uint8_t transport;
} __attribute__((packed));

#define HAL_OP_REMOVE_BOND 0x0e
--
1.9.1


2014-11-04 08:18:30

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 07/47] android/hal-sco: Remove deprecated API usage

From: Andrei Emeltchenko <[email protected]>

Instead of deprecated functions use new ones.
---
android/hal-sco.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)

diff --git a/android/hal-sco.c b/android/hal-sco.c
index 231be33..7434804 100644
--- a/android/hal-sco.c
+++ b/android/hal-sco.c
@@ -438,7 +438,11 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,
size_t bytes)
{
struct sco_stream_out *out = (struct sco_stream_out *) stream;
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ size_t frame_num = bytes / audio_stream_out_frame_size(stream);
+#else
size_t frame_num = bytes / audio_stream_frame_size(&out->stream.common);
+#endif
size_t output_frame_num = frame_num;
void *send_buf = out->downmix_buf;
size_t total;
@@ -507,8 +511,13 @@ static int out_set_sample_rate(struct audio_stream *stream, uint32_t rate)
static size_t out_get_buffer_size(const struct audio_stream *stream)
{
struct sco_stream_out *out = (struct sco_stream_out *) stream;
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ size_t size = audio_stream_out_frame_size(&out->stream) *
+ out->cfg.frame_num;
+#else
size_t size = audio_stream_frame_size(&out->stream.common) *
out->cfg.frame_num;
+#endif

/* buffer size without resampling */
if (out->cfg.rate == AUDIO_STREAM_SCO_RATE)
@@ -864,8 +873,13 @@ static int in_set_sample_rate(struct audio_stream *stream, uint32_t rate)
static size_t in_get_buffer_size(const struct audio_stream *stream)
{
struct sco_stream_in *in = (struct sco_stream_in *) stream;
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ size_t size = audio_stream_in_frame_size(&in->stream) *
+ in->cfg.frame_num;
+#else
size_t size = audio_stream_frame_size(&in->stream.common) *
in->cfg.frame_num;
+#endif

/* buffer size without resampling */
if (in->cfg.rate == AUDIO_STREAM_SCO_RATE)
@@ -1008,7 +1022,11 @@ static ssize_t in_read(struct audio_stream_in *stream, void *buffer,
size_t bytes)
{
struct sco_stream_in *in = (struct sco_stream_in *) stream;
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ size_t frame_size = audio_stream_in_frame_size(&in->stream);
+#else
size_t frame_size = audio_stream_frame_size(&stream->common);
+#endif
size_t frame_num = bytes / frame_size;
size_t input_frame_num = frame_num;
void *read_buf = buffer;
--
1.9.1


2014-11-04 08:18:27

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 04/47] android/hal-audio: Add support for new Android API

From: Andrei Emeltchenko <[email protected]>

For new Android API add parameter address to audio_open_output_stream()
and audio_open_input_stream().
---
android/hal-audio.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/android/hal-audio.c b/android/hal-audio.c
index e70351e..d140071 100644
--- a/android/hal-audio.c
+++ b/android/hal-audio.c
@@ -1108,13 +1108,22 @@ static int in_remove_audio_effect(const struct audio_stream *stream,
return -ENOSYS;
}

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static int audio_open_output_stream(struct audio_hw_device *dev,
+ audio_io_handle_t handle,
+ audio_devices_t devices,
+ audio_output_flags_t flags,
+ struct audio_config *config,
+ struct audio_stream_out **stream_out,
+ const char *address)
+#else
static int audio_open_output_stream(struct audio_hw_device *dev,
audio_io_handle_t handle,
audio_devices_t devices,
audio_output_flags_t flags,
struct audio_config *config,
struct audio_stream_out **stream_out)
-
+#endif
{
struct a2dp_audio_dev *a2dp_dev = (struct a2dp_audio_dev *) dev;
struct a2dp_stream_out *out;
@@ -1252,11 +1261,22 @@ static size_t audio_get_input_buffer_size(const struct audio_hw_device *dev,
return -ENOSYS;
}

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static int audio_open_input_stream(struct audio_hw_device *dev,
+ audio_io_handle_t handle,
+ audio_devices_t devices,
+ struct audio_config *config,
+ struct audio_stream_in **stream_in,
+ audio_input_flags_t flags,
+ const char *address,
+ audio_source_t source)
+#else
static int audio_open_input_stream(struct audio_hw_device *dev,
audio_io_handle_t handle,
audio_devices_t devices,
struct audio_config *config,
struct audio_stream_in **stream_in)
+#endif
{
struct audio_stream_in *in;

--
1.9.1


2014-11-04 08:18:26

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 03/47] android/hal-bluetooth: Add missing functions

From: Andrei Emeltchenko <[email protected]>

Add missing HAL functions for new Android version
---
android/hal-bluetooth.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)

diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 5b6e99d..bbbdc37 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -948,6 +948,35 @@ static int config_hci_snoop_log(uint8_t enable)
return BT_STATUS_SUCCESS;
}

+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+static int get_connection_state(const bt_bdaddr_t *bd_addr)
+{
+ DBG("bdaddr: %s", bdaddr2str(bd_addr));
+
+ /* TODO: implement */
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static int set_os_callouts(bt_os_callouts_t *callouts)
+{
+ DBG("callouts: %p", callouts);
+
+ /* TODO: implement */
+
+ return BT_STATUS_SUCCESS;
+}
+
+static int read_energy_info(void)
+{
+ DBG("");
+
+ /* TODO: implement */
+
+ return BT_STATUS_UNSUPPORTED;
+}
+#endif
+
static const bt_interface_t bluetooth_if = {
.size = sizeof(bt_interface_t),
.init = init,
@@ -974,6 +1003,11 @@ static const bt_interface_t bluetooth_if = {
.dut_mode_send = dut_mode_send,
.le_test_mode = le_test_mode,
.config_hci_snoop_log = config_hci_snoop_log,
+#if ANDROID_VERSION > PLATFORM_VER(4, 4, 4)
+ .get_connection_state = get_connection_state,
+ .set_os_callouts = set_os_callouts,
+ .read_energy_info = read_energy_info,
+#endif
};

static const bt_interface_t *get_bluetooth_interface(void)
--
1.9.1


2014-11-04 08:18:24

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv1 01/47] android: Set exact Android version

From: Andrei Emeltchenko <[email protected]>

For local build set exact current Android version.
---
android/Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/android/Makefile.am b/android/Makefile.am
index 496fbc4..bd05654 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -1,6 +1,6 @@
if ANDROID

-AM_CFLAGS += -DANDROID_VERSION=0xFFFFFF -DBLUEZ_EXTENSIONS
+AM_CFLAGS += -DANDROID_VERSION=0x040404 -DBLUEZ_EXTENSIONS

android_plugindir = $(abs_top_srcdir)/android/.libs

--
1.9.1