* [PATCH 1/2] android: Add resolve_name parameter to confirm_device_name
@ 2014-02-17 16:26 Lukasz Rymanowski
2014-02-17 16:26 ` [PATCH 2/2] android: Do not resolve name if we have it in the cache Lukasz Rymanowski
2014-02-21 11:02 ` [PATCH 1/2] android: Add resolve_name parameter to confirm_device_name Szymon Janc
0 siblings, 2 replies; 3+ messages in thread
From: Lukasz Rymanowski @ 2014-02-17 16:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lukasz Rymanowski
---
android/bluetooth.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index 525fd27..1827834 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -1012,7 +1012,8 @@ static void mgmt_discovering_event(uint16_t index, uint16_t length,
HAL_EV_DISCOVERY_STATE_CHANGED, sizeof(cp), &cp);
}
-static void confirm_device_name(const bdaddr_t *addr, uint8_t addr_type)
+static void confirm_device_name(const bdaddr_t *addr, uint8_t addr_type,
+ bool resolve_name)
{
struct mgmt_cp_confirm_name cp;
@@ -1020,6 +1021,9 @@ static void confirm_device_name(const bdaddr_t *addr, uint8_t addr_type)
bacpy(&cp.addr.bdaddr, addr);
cp.addr.type = addr_type;
+ if (!resolve_name)
+ cp.name_known = 1;
+
if (mgmt_reply(mgmt_if, MGMT_OP_CONFIRM_NAME, adapter.index,
sizeof(cp), &cp, NULL, NULL, NULL) == 0)
error("Failed to send confirm name request");
@@ -1179,10 +1183,12 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
if (confirm) {
char addr[18];
+ bool resolve_name = true;
ba2str(bdaddr, addr);
- info("Device %s needs name confirmation.", addr);
- confirm_device_name(bdaddr, bdaddr_type);
+ info("Device %s needs name confirmation (resolve_name=%d)",
+ addr, resolve_name);
+ confirm_device_name(bdaddr, bdaddr_type, resolve_name);
}
}
--
1.8.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 2/2] android: Do not resolve name if we have it in the cache
2014-02-17 16:26 [PATCH 1/2] android: Add resolve_name parameter to confirm_device_name Lukasz Rymanowski
@ 2014-02-17 16:26 ` Lukasz Rymanowski
2014-02-21 11:02 ` [PATCH 1/2] android: Add resolve_name parameter to confirm_device_name Szymon Janc
1 sibling, 0 replies; 3+ messages in thread
From: Lukasz Rymanowski @ 2014-02-17 16:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lukasz Rymanowski
With this patch, deamon will not ask kernel to resolve name of remote
device during inquiry in case device name is already in the local cache.
Instead Android will be updated with already known device name.
---
android/bluetooth.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index 1827834..ccfb461 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -1186,6 +1186,14 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
bool resolve_name = true;
ba2str(bdaddr, addr);
+
+ /* Don't need to confirm name if we have it already in cache
+ * Just check if device name is different than bdaddr */
+ if (g_strcmp0(dev->name, addr)) {
+ get_device_name(dev);
+ resolve_name = false;
+ }
+
info("Device %s needs name confirmation (resolve_name=%d)",
addr, resolve_name);
confirm_device_name(bdaddr, bdaddr_type, resolve_name);
--
1.8.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH 1/2] android: Add resolve_name parameter to confirm_device_name
2014-02-17 16:26 [PATCH 1/2] android: Add resolve_name parameter to confirm_device_name Lukasz Rymanowski
2014-02-17 16:26 ` [PATCH 2/2] android: Do not resolve name if we have it in the cache Lukasz Rymanowski
@ 2014-02-21 11:02 ` Szymon Janc
1 sibling, 0 replies; 3+ messages in thread
From: Szymon Janc @ 2014-02-21 11:02 UTC (permalink / raw)
To: Lukasz Rymanowski; +Cc: linux-bluetooth
Hi Łukasz,
On Monday 17 of February 2014 17:26:29 Lukasz Rymanowski wrote:
> ---
> android/bluetooth.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/android/bluetooth.c b/android/bluetooth.c
> index 525fd27..1827834 100644
> --- a/android/bluetooth.c
> +++ b/android/bluetooth.c
> @@ -1012,7 +1012,8 @@ static void mgmt_discovering_event(uint16_t index, uint16_t length,
> HAL_EV_DISCOVERY_STATE_CHANGED, sizeof(cp), &cp);
> }
>
> -static void confirm_device_name(const bdaddr_t *addr, uint8_t addr_type)
> +static void confirm_device_name(const bdaddr_t *addr, uint8_t addr_type,
> + bool resolve_name)
> {
> struct mgmt_cp_confirm_name cp;
>
> @@ -1020,6 +1021,9 @@ static void confirm_device_name(const bdaddr_t *addr, uint8_t addr_type)
> bacpy(&cp.addr.bdaddr, addr);
> cp.addr.type = addr_type;
>
> + if (!resolve_name)
> + cp.name_known = 1;
> +
> if (mgmt_reply(mgmt_if, MGMT_OP_CONFIRM_NAME, adapter.index,
> sizeof(cp), &cp, NULL, NULL, NULL) == 0)
> error("Failed to send confirm name request");
> @@ -1179,10 +1183,12 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
>
> if (confirm) {
> char addr[18];
> + bool resolve_name = true;
>
> ba2str(bdaddr, addr);
> - info("Device %s needs name confirmation.", addr);
> - confirm_device_name(bdaddr, bdaddr_type);
> + info("Device %s needs name confirmation (resolve_name=%d)",
> + addr, resolve_name);
> + confirm_device_name(bdaddr, bdaddr_type, resolve_name);
> }
> }
>
Both patches applied, thanks.
--
Best regards,
Szymon Janc
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-02-21 11:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-17 16:26 [PATCH 1/2] android: Add resolve_name parameter to confirm_device_name Lukasz Rymanowski
2014-02-17 16:26 ` [PATCH 2/2] android: Do not resolve name if we have it in the cache Lukasz Rymanowski
2014-02-21 11:02 ` [PATCH 1/2] android: Add resolve_name parameter to confirm_device_name Szymon Janc
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox