[Bluetooth] Prevent "Wrong listener identifier" errors for BLE scan 78/250778/2
authorPawel Wasowski <p.wasowski2@samsung.com>
Tue, 1 Dec 2020 09:30:10 +0000 (11:30 +0200)
committerPiotr Kosko/Native/Web API (PLT) /SRPOL/Engineer/Samsung Electronics <p.kosko@samsung.com>
Mon, 4 Jan 2021 11:48:30 +0000 (12:48 +0100)
The following app code caused aforementioned errors:

var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan();
setTimeout(function() {
        adapter.stopScan();
}, 10000);

Now, the error is not thrown.

[Validation] tct-bluetooth-tizen-tests: auto: 100% pass rate,
             manual Bluetooth04_BLE_wearable suite: 100% pass rate
             The code above runs in ChromeDevTools without errors

Change-Id: Id9ec278b4bb1c5ce38d0b3ffb1324498152ab645
Signed-off-by: Pawel Wasowski <p.wasowski2@samsung.com>
src/bluetooth/bluetooth_api.js

index 984fb77..1869e14 100755 (executable)
@@ -1514,12 +1514,12 @@ BluetoothLEAdapter.prototype.startScan = function() {
 BluetoothLEAdapter.prototype.stopScan = function() {
     privUtils_.log('Entered BluetoothLEAdapter.stopScan()');
 
-    _bleScanListener.removeListener();
-
     var result = native.callSync('BluetoothLEAdapter_stopScan', {});
     if (native.isFailure(result)) {
         throw native.getErrorObject(result);
     }
+
+    _bleScanListener.removeListener();
 };
 
 var _BluetoothAdvertisePacketType = {