From 9f88b345bb8e4ccab4f2ab9a20c79802e9f9485e Mon Sep 17 00:00:00 2001 From: Thierry Bultel Date: Wed, 12 Sep 2018 16:55:55 +0200 Subject: hal-bt-data: ignore devices with no UUIDs just ignore devices that do not have any UUIDs Change-Id: Ic3cb25d8f8521e8f6c73afa173745a26e9c873ce Signed-off-by: Thierry Bultel --- plugins/lib/bluetooth/hal-bt-data.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/lib/bluetooth/hal-bt-data.c b/plugins/lib/bluetooth/hal-bt-data.c index eefd9f1..61d774b 100644 --- a/plugins/lib/bluetooth/hal-bt-data.c +++ b/plugins/lib/bluetooth/hal-bt-data.c @@ -173,14 +173,14 @@ int HalBtDataHandleReceivedSingleBtDeviceData(struct HalBtPluginData *halBtPlugi char *currentBtDeviceAddress, *currentBtDeviceIsConnectedString, *currentBtDeviceIsAVPConnectedString; - json_object *currentBtAllProfilesJ, *currentBtCurrentProfileJ; + json_object *currentBtAllProfilesJ = NULL, *currentBtCurrentProfileJ; struct HalBtDeviceData *currentBtDevice; if(! halBtPluginData || ! currentSingleBtDeviceDataJ) return -1; if(wrap_json_unpack(currentSingleBtDeviceDataJ, - "{s:s s:s s:s s:o}", + "{s:s s:s s:s s?:o}", "Address", ¤tBtDeviceAddress, "Connected", ¤tBtDeviceIsConnectedString, "AVPConnected", ¤tBtDeviceIsAVPConnectedString, @@ -188,6 +188,11 @@ int HalBtDataHandleReceivedSingleBtDeviceData(struct HalBtPluginData *halBtPlugi return -2; } + if(! currentBtAllProfilesJ) { + AFB_ApiInfo(halBtPluginData->currentHalApiHandle, "Bluetooth device (address = %s) has no specified profiles, ignore it", currentBtDeviceAddress); + return 0; + } + if(json_object_is_type(currentBtAllProfilesJ, json_type_array)) { btProfilesCount = json_object_array_length(currentBtAllProfilesJ); @@ -260,9 +265,10 @@ int HalBtDataHandleReceivedMutlipleBtDeviceData(struct HalBtPluginData *halBtPlu btDeviceNumber = json_object_array_length(currentMultipleBtDeviceDataJ); for(idx = 0; idx < btDeviceNumber; idx++) { - if((err = HalBtDataHandleReceivedSingleBtDeviceData(halBtPluginData, json_object_array_get_idx(currentMultipleBtDeviceDataJ, (unsigned int) idx)))) + if((err = HalBtDataHandleReceivedSingleBtDeviceData(halBtPluginData, json_object_array_get_idx(currentMultipleBtDeviceDataJ, (unsigned int) idx)))) { return ((int) idx * err * 10); + } } return 0; -} \ No newline at end of file +} -- cgit 1.2.3-korg