Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 024ec11c authored by Katherine Lai's avatar Katherine Lai
Browse files

Floss: Add ServiceRemoved callback

Adds a callback to indicate a service was removed from the GATT
server to IBluetoothGattServerCallback.

Bug: 193685791
Tag: #floss
Test: emerge-dedede floss and WIP btclient
Change-Id: Id7e92b1914df22f4384bb7bc5a56ce82174e4d7f
parent 1a3a86ed
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -781,6 +781,10 @@ impl IBluetoothGattServerCallback for BtGattServerCallback {
        print_info!("GATT service added with status = {}, service = {:?}", status, service)
    }

    fn on_service_removed(&self, status: GattStatus, handle: i32) {
        print_info!("GATT service removed with status = {}, handle = {:?}", status, handle);
    }

    fn on_characteristic_read_request(
        &self,
        addr: String,
+3 −0
Original line number Diff line number Diff line
@@ -1483,6 +1483,9 @@ impl IBluetoothGattServerCallback for IBluetoothGattCallbackDBus {
    #[dbus_method("OnServiceAdded")]
    fn on_service_added(&self, status: GattStatus, service: BluetoothGattService) {}

    #[dbus_method("OnServiceRemoved")]
    fn on_service_removed(&self, status: GattStatus, handle: i32) {}

    #[dbus_method("OnCharacteristicReadRequest")]
    fn on_characteristic_read_request(
        &self,
+5 −0
Original line number Diff line number Diff line
@@ -156,6 +156,11 @@ impl IBluetoothGattServerCallback for BluetoothGattServerCallbackDBus {
        dbus_generated!()
    }

    #[dbus_method("OnServiceRemoved")]
    fn on_service_removed(&self, status: GattStatus, handle: i32) {
        dbus_generated!()
    }

    #[dbus_method("OnCharacteristicReadRequest")]
    fn on_characteristic_read_request(
        &self,
+11 −0
Original line number Diff line number Diff line
@@ -966,6 +966,9 @@ pub trait IBluetoothGattServerCallback: RPCProxy {
    /// When there is a service added to the GATT server.
    fn on_service_added(&self, _status: GattStatus, _service: BluetoothGattService);

    /// When a service has been removed from the GATT server.
    fn on_service_removed(&self, status: GattStatus, handle: i32);

    /// When a remote device has requested to read a characteristic.
    fn on_characteristic_read_request(
        &self,
@@ -3295,6 +3298,14 @@ impl BtifGattServerCallbacks for BluetoothGatt {
        if status == GattStatus::Success {
            self.server_context_map.delete_service(server_id, handle);
        }

        if let Some(cb) = self
            .server_context_map
            .get_by_server_id(server_id)
            .and_then(|server| self.server_context_map.get_callback_from_callback_id(server.cbid))
        {
            cb.on_service_removed(status, handle);
        }
    }

    fn request_read_characteristic_cb(