GATTServer has to be stopped in case of last service unregistration.
[ACR] https://code.sec.samsung.net/jira/browse/TWDAPI-263
[TASK] https://code.sec.samsung.net/jira/browse/XWALK-2163
[Verification] Build successful. Tested in Chrome Console.
Server stops when last service is unregistered.
Change-Id: I756bf9d944937e03f7e808c929e31140f4145add
Signed-off-by: Rafal Walczyna <r.walczyna@samsung.com>
return;
}
+ if (false == service_.IsAnyServiceRegistered()) {
+ // Last service unregistered, stop GATTServer
+ // All native objects should be already freed, so just Deinitialize and notify
+ // JS layer about server's state change
+ Deinitialize();
+ SetRunningState(false);
+ }
+
ReportSuccess(out);
}
callback_names_.clear();
}
+bool BluetoothGATTServerService::IsAnyServiceRegistered() {
+ ScopeLogger();
+ return 0 != gatt_objects_.size();
+}
+
} // namespace bluetooth
} // namespace extension
static bool DestroyCharacteristic(int total, int index, bt_gatt_h handle, void* user_data);
static bool DestroyDescriptor(int total, int index, bt_gatt_h handle, void* user_data);
+ bool IsAnyServiceRegistered();
+
private:
BluetoothInstance& instance_;
std::map<int, bt_gatt_h> gatt_objects_;