From 26741cc7c9fa1302016d05f936befc7f1b79bfd0 Mon Sep 17 00:00:00 2001 From: Jonathan Aillet Date: Tue, 11 Sep 2018 17:19:27 +0200 Subject: Improve Hal-Bt plugin A2DP bt devices detection Consider an A2DP bluetooth device as connected only if its seen as 'AVPConnected' by 'Bluetooth-Manager'. Change-Id: I54511a193ebf64e35a7605723440f3a0fae2b2fd Signed-off-by: Jonathan Aillet --- plugins/lib/bluetooth/hal-bt-data.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'plugins/lib') diff --git a/plugins/lib/bluetooth/hal-bt-data.c b/plugins/lib/bluetooth/hal-bt-data.c index a548039..cfcb57d 100644 --- a/plugins/lib/bluetooth/hal-bt-data.c +++ b/plugins/lib/bluetooth/hal-bt-data.c @@ -96,7 +96,7 @@ struct HalBtDeviceData *HalBtDataAddBtDeviceToBtDeviceList(struct HalBtDeviceDat // TODO JAI : get hci device of bt device here if(wrap_json_unpack(currentSingleBtDeviceDataJ, - "{s:s s:s s:o}", + "{s:s s:s}", "Name", ¤tBtDeviceName, "Address", ¤tBtDeviceAddress)) { HalBtDataRemoveSelectedBtDeviceFromList(firstBtDeviceData, currentBtDeviceData); @@ -171,7 +171,7 @@ int HalBtDataHandleReceivedSingleBtDeviceData(struct HalBtPluginData *halBtPlugi unsigned int idx = 0, currentBtDeviceIsConnected, currentBtDeviceIsA2DP; - char *currentBtDeviceAddress, *currentBtDeviceIsConnectedString; + char *currentBtDeviceAddress, *currentBtDeviceIsConnectedString, *currentBtDeviceIsAVPConnectedString; json_object *currentBtAllProfilesJ, *currentBtCurrentProfileJ; @@ -180,9 +180,10 @@ int HalBtDataHandleReceivedSingleBtDeviceData(struct HalBtPluginData *halBtPlugi return -1; if(wrap_json_unpack(currentSingleBtDeviceDataJ, - "{s:s s:s s:s}", + "{s:s s:s s:s s:o}", "Address", ¤tBtDeviceAddress, "Connected", ¤tBtDeviceIsConnectedString, + "AVPConnected", ¤tBtDeviceIsAVPConnectedString, "UUIDs", ¤tBtAllProfilesJ)) { return -2; } @@ -210,7 +211,8 @@ int HalBtDataHandleReceivedSingleBtDeviceData(struct HalBtPluginData *halBtPlugi if(! currentBtDeviceIsA2DP) return 0; - currentBtDeviceIsConnected = ! strncmp(currentBtDeviceIsConnectedString, "True", strlen(currentBtDeviceIsConnectedString)); + currentBtDeviceIsConnected = ((! strncmp(currentBtDeviceIsConnectedString, "True", strlen(currentBtDeviceIsConnectedString))) && + (! strncmp(currentBtDeviceIsAVPConnectedString, "True", strlen(currentBtDeviceIsAVPConnectedString)))); currentBtDevice = HalBtDataSearchBtDeviceByAddress(&halBtPluginData->first, currentBtDeviceAddress); -- cgit 1.2.3-korg