2014-11-06 08:27:10

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH] 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 4d8dff4..98d1f56 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-06 12:57:19

by Szymon Janc

[permalink] [raw]
Subject: Re: [PATCHv2] android/handsfree: Return default device for zero bdaddr

Hi Andrei,

On Thursday 06 of November 2014 14:45:58 Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <[email protected]>
>
> For the old Android API use find_default_device() function.
> ---
> android/handsfree.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/android/handsfree.c b/android/handsfree.c
> index b410f5d..33fcbdd 100644
> --- a/android/handsfree.c
> +++ b/android/handsfree.c
> @@ -290,6 +290,9 @@ static bool match_by_bdaddr(const void *data, const void *match_data)
>
> static struct hf_device *find_device(const bdaddr_t *bdaddr)
> {
> + if (!bacmp(bdaddr, BDADDR_ANY))
> + return find_default_device();
> +
> return queue_find(devices, match_by_bdaddr, bdaddr);
> }
>

Applied, thanks.

--
Best regards,
Szymon Janc

2014-11-06 12:45:58

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCHv2] 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 | 3 +++
1 file changed, 3 insertions(+)

diff --git a/android/handsfree.c b/android/handsfree.c
index b410f5d..33fcbdd 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -290,6 +290,9 @@ static bool match_by_bdaddr(const void *data, const void *match_data)

static struct hf_device *find_device(const bdaddr_t *bdaddr)
{
+ if (!bacmp(bdaddr, BDADDR_ANY))
+ return find_default_device();
+
return queue_find(devices, match_by_bdaddr, bdaddr);
}

--
1.9.1


2014-11-06 10:41:10

by Szymon Janc

[permalink] [raw]
Subject: Re: [PATCH] android/handsfree: Return default device for zero bdaddr

Hi Andrei,

On Thursday 06 of November 2014 10:27:10 Andrei Emeltchenko wrote:
> 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 4d8dff4..98d1f56 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);
> }

Please use bacmp and BDADDR_ANY here.

--
Best regards,
Szymon Janc