Add OnConnectionStateChanged to IBluetoothGattServerCallback
Currently native GattServer clients can't tell wether someone connected
or disconnnected to the device. This patch fixed that, by exposing
OnConnectionStateChangedCallback
Bug: 29835693
Change-Id: Ia7ef592f4031d021ab1b45808126ca57f9348d0e
diff --git a/service/gatt_server.cc b/service/gatt_server.cc
index 0180eb4..b0441a6 100644
--- a/service/gatt_server.cc
+++ b/service/gatt_server.cc
@@ -477,6 +477,9 @@
break;
}
+ if (delegate_)
+ delegate_->OnConnectionStateChanged(this, device_address, false);
+
return;
}
@@ -491,6 +494,9 @@
std::shared_ptr<Connection> connection(new Connection(conn_id, bda));
conn_id_map_[conn_id] = connection;
conn_addr_map_[device_address].push_back(connection);
+
+ if (delegate_)
+ delegate_->OnConnectionStateChanged(this, device_address, true);
}
void GattServer::ServiceAddedCallback(