summaryrefslogtreecommitdiff
path: root/android/bluetooth.c
diff options
context:
space:
mode:
authorSzymon Janc <szymon.janc@tieto.com>2015-02-14 21:19:41 +0100
committerSzymon Janc <szymon.janc@tieto.com>2015-02-15 15:34:32 +0100
commite17b9495e5fc249aa03ea4f31c61984613f88394 (patch)
treeeddc50404fdad3b4257c08e1084c9446da7ed84c /android/bluetooth.c
parent534f929e469da311d967735580634685085726c1 (diff)
downloadbluez-e17b9495e5fc249aa03ea4f31c61984613f88394.tar.gz
android/bluetooth: Implement get_connection_state on daemon
Track if ACL is connected and response corretly to get_connection_state call. This seems to be used by some application to query for device connection state.
Diffstat (limited to 'android/bluetooth.c')
-rw-r--r--android/bluetooth.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/android/bluetooth.c b/android/bluetooth.c
index fdf7b9112..f39f1e6f0 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -137,6 +137,8 @@ struct device {
bool in_white_list;
+ bool connected;
+
char *name;
char *friendly_name;
@@ -2089,6 +2091,8 @@ static void mgmt_device_connected_event(uint16_t index, uint16_t length,
if (!dev)
return;
+ dev->connected = true;
+
get_device_android_addr(dev, hal_ev.bdaddr);
ipc_send_notif(hal_ipc, HAL_SERVICE_ID_BLUETOOTH,
@@ -2136,6 +2140,8 @@ static void mgmt_device_disconnected_event(uint16_t index, uint16_t length,
if (device_is_paired(dev, type) && !device_is_bonded(dev))
update_device_state(dev, type, HAL_STATUS_SUCCESS, false,
false, false);
+
+ dev->connected = false;
}
static uint8_t status_mgmt2hal(uint8_t mgmt)
@@ -5222,17 +5228,20 @@ static void handle_get_connection_state(const void *buf, uint16_t len)
{
const struct hal_cmd_get_connection_state *cmd = buf;
struct hal_rsp_get_connection_state rsp;
+ struct device *dev;
char address[18];
bdaddr_t bdaddr;
android2bdaddr(cmd->bdaddr, &bdaddr);
ba2str(&bdaddr, address);
- DBG("%s", address);
-
- /* TODO */
+ dev = find_device_android(cmd->bdaddr);
+ if (dev && dev->connected)
+ rsp.connection_state = 1;
+ else
+ rsp.connection_state = 0;
- rsp.connection_state = 0;
+ DBG("%s %u", address, rsp.connection_state);
ipc_send_rsp_full(hal_ipc, HAL_SERVICE_ID_BLUETOOTH,
HAL_OP_GET_CONNECTION_STATE, sizeof(rsp), &rsp,