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

Commit 14b1d137 authored by Sonny Sasaka's avatar Sonny Sasaka
Browse files

floss: Handle service_changed callback

Bug: 193685325
Tag: #floss
Test: Build floss

Change-Id: Ia4c0452643bc75c1bffc84b7cc0f6d8599dba4da
parent faca4a77
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -85,6 +85,9 @@ impl IBluetoothGattCallback for BluetoothGattCallbackDBus {
        status: i32,
    ) {
    }

    #[dbus_method("OnServiceChanged")]
    fn on_service_changed(&self, addr: String) {}
}

// Represents Uuid128Bit as an array in D-Bus.
+20 −0
Original line number Diff line number Diff line
@@ -395,6 +395,9 @@ pub trait IBluetoothGattCallback: RPCProxy {
        timeout: i32,
        status: i32,
    );

    /// When there is an addition, removal, or change of a GATT service.
    fn on_service_changed(&self, addr: String);
}

/// Interface for scanner callbacks to clients, passed to `IBluetoothGatt::register_scanner`.
@@ -944,6 +947,9 @@ pub(crate) trait BtifGattClientCallbacks {
        status: u8,
    );

    #[btif_callback(ServiceChanged)]
    fn service_changed_cb(&self, conn_id: i32);

    #[btif_callback(ReadPhy)]
    fn read_phy_cb(&mut self, client_id: i32, addr: RawAddress, tx_phy: u8, rx_phy: u8, status: u8);

@@ -1316,6 +1322,20 @@ impl BtifGattClientCallbacks for BluetoothGatt {
            status as i32,
        );
    }

    fn service_changed_cb(&self, conn_id: i32) {
        let address = self.context_map.get_address_by_conn_id(conn_id);
        if address.is_none() {
            return;
        }

        let client = self.context_map.get_client_by_conn_id(conn_id);
        if client.is_none() {
            return;
        }

        client.unwrap().callback.on_service_changed(address.unwrap());
    }
}

#[cfg(test)]