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

Commit 8a7425dd authored by Katherine Lai's avatar Katherine Lai Committed by Gerrit Code Review
Browse files

Merge changes Id7e92b19,I69839212

* changes:
  Floss: Add ServiceRemoved callback
  Floss: Add Callbacks:get_by_id_mut
parents f1e050f3 024ec11c
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
@@ -1484,6 +1484,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,
+1 −1
Original line number Diff line number Diff line
@@ -579,7 +579,7 @@ impl Advertisers {
        &mut self,
        s: &AdvertisingSetInfo,
    ) -> Option<&mut Box<dyn IAdvertisingSetCallback + Send>> {
        self.callbacks.get_by_id(s.callback_id())
        self.callbacks.get_by_id_mut(s.callback_id())
    }

    /// Removes an advertiser callback and unregisters all advertising sets associated with that callback.
+13 −5
Original line number Diff line number Diff line
@@ -186,7 +186,7 @@ impl ContextMap {
        &mut self,
        callback_id: u32,
    ) -> Option<&mut GattClientCallback> {
        self.callbacks.get_by_id(callback_id)
        self.callbacks.get_by_id_mut(callback_id)
    }
}

@@ -294,10 +294,7 @@ impl ServerContextMap {
        }
    }

    fn get_callback_from_callback_id(
        &mut self,
        callback_id: u32,
    ) -> Option<&mut GattServerCallback> {
    fn get_callback_from_callback_id(&self, callback_id: u32) -> Option<&GattServerCallback> {
        self.callbacks.get_by_id(callback_id)
    }

@@ -970,6 +967,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,
@@ -3299,6 +3299,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(
Loading