From: Piotr Kosko/Engineer/Native/Web API (PLT) /SRPOL/Samsung Electronics
Date: Thu, 24 Oct 2019 06:59:52 +0000 (+0200)
Subject: [Bluetooth] Fixed issues related to BLE
X-Git-Tag: submit/tizen_3.0/20200610.123619~15
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ccdb9235a0e03fd3b1976db6cd2878d0fa3452c9;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git
[Bluetooth] Fixed issues related to BLE
[Bug/Fix]
1. Prevent possible crash in case of invalid data passed from native
2. Prevent type mismatch exception in JS in case of LE devices advertising
serviceData.
[Verification] tct passrate 100%
Checked in chrome console and le device with serviceData.
Change-Id: Iecc9929a77a1acfd1b33eb325ea287011b9a6096
---
diff --git a/src/bluetooth/bluetooth_api.js b/src/bluetooth/bluetooth_api.js
index 7a6540a..984fb77 100755
--- a/src/bluetooth/bluetooth_api.js
+++ b/src/bluetooth/bluetooth_api.js
@@ -610,6 +610,7 @@ var BluetoothLEDevice = function(data) {
uuids = data.uuids || null;
solicitationuuids = data.solicitationuuids || null;
if (data.serviceData) {
+ serviceData = [];
data.serviceData.forEach(function(d) {
serviceData.push(new tizen.BluetoothLEServiceData(d));
});
diff --git a/src/bluetooth/bluetooth_le_device.cc b/src/bluetooth/bluetooth_le_device.cc
index 62caee5..f680cc1 100644
--- a/src/bluetooth/bluetooth_le_device.cc
+++ b/src/bluetooth/bluetooth_le_device.cc
@@ -434,6 +434,7 @@ void BluetoothLEDevice::GattConnectionState(int result, bool connected, const ch
// check state change success
PlatformResult operation_success = ValidateConnectionChange(result);
+
if (operation_success) {
if (connected) { // connect success
le_device->is_connected_.insert(remote_address);
@@ -470,12 +471,16 @@ void BluetoothLEDevice::CleanClientInfo(const char* remote_address) {
void BluetoothLEDevice::TriggerConnectCallback(const char* remote_address, PlatformResult result) {
ScopeLogger();
- auto it = connecting_.find(remote_address);
- if (connecting_.end() != it) {
- instance_.AsyncResponse(it->second, result);
- connecting_.erase(it);
+ if (remote_address) {
+ auto it = connecting_.find(remote_address);
+ if (connecting_.end() != it) {
+ instance_.AsyncResponse(it->second, result);
+ connecting_.erase(it);
+ } else {
+ LoggerW("Given address is not in waiting connections list");
+ }
} else {
- LoggerW("Given address is not in waiting connections list");
+ LoggerE("Connection failed, returned remote_address is null. Callback will be not triggered");
}
}