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

Commit a8a60639 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes Ie058a4ba,Id612e022

* changes:
  floss: Refactor GATT apis to use GattStatus
  floss: Get DeviceType before device can be deleted
parents 6c3e5134 89384b82
Loading
Loading
Loading
Loading
+24 −13
Original line number Diff line number Diff line
@@ -299,8 +299,8 @@ impl ScannerCallback {
}

impl IScannerCallback for ScannerCallback {
    fn on_scanner_registered(&self, uuid: Uuid128Bit, scanner_id: u8, status: u8) {
        if status != 0 {
    fn on_scanner_registered(&self, uuid: Uuid128Bit, scanner_id: u8, status: GattStatus) {
        if status != GattStatus::Success {
            print_error!("Failed registering scanner, status = {}", status);
            return;
        }
@@ -349,14 +349,14 @@ impl BtGattCallback {
}

impl IBluetoothGattCallback for BtGattCallback {
    fn on_client_registered(&self, status: i32, client_id: i32) {
    fn on_client_registered(&self, status: GattStatus, client_id: i32) {
        print_info!("GATT Client registered status = {}, client_id = {}", status, client_id);
        self.context.lock().unwrap().gatt_client_id = Some(client_id);
    }

    fn on_client_connection_state(
        &self,
        status: i32,
        status: GattStatus,
        client_id: i32,
        connected: bool,
        addr: String,
@@ -390,7 +390,12 @@ impl IBluetoothGattCallback for BtGattCallback {
        );
    }

    fn on_search_complete(&self, addr: String, services: Vec<BluetoothGattService>, status: i32) {
    fn on_search_complete(
        &self,
        addr: String,
        services: Vec<BluetoothGattService>,
        status: GattStatus,
    ) {
        print_info!(
            "GATT DB Search complete: addr = {}, services = {:?}, status = {}",
            addr,
@@ -399,7 +404,13 @@ impl IBluetoothGattCallback for BtGattCallback {
        );
    }

    fn on_characteristic_read(&self, addr: String, status: i32, handle: i32, value: Vec<u8>) {
    fn on_characteristic_read(
        &self,
        addr: String,
        status: GattStatus,
        handle: i32,
        value: Vec<u8>,
    ) {
        print_info!(
            "GATT Characteristic read: addr = {}, status = {}, handle = {}, value = {:?}",
            addr,
@@ -409,7 +420,7 @@ impl IBluetoothGattCallback for BtGattCallback {
        );
    }

    fn on_characteristic_write(&self, addr: String, status: i32, handle: i32) {
    fn on_characteristic_write(&self, addr: String, status: GattStatus, handle: i32) {
        print_info!(
            "GATT Characteristic write: addr = {}, status = {}, handle = {}",
            addr,
@@ -418,11 +429,11 @@ impl IBluetoothGattCallback for BtGattCallback {
        );
    }

    fn on_execute_write(&self, addr: String, status: i32) {
    fn on_execute_write(&self, addr: String, status: GattStatus) {
        print_info!("GATT execute write addr = {}, status = {}", addr, status);
    }

    fn on_descriptor_read(&self, addr: String, status: i32, handle: i32, value: Vec<u8>) {
    fn on_descriptor_read(&self, addr: String, status: GattStatus, handle: i32, value: Vec<u8>) {
        print_info!(
            "GATT Descriptor read: addr = {}, status = {}, handle = {}, value = {:?}",
            addr,
@@ -432,7 +443,7 @@ impl IBluetoothGattCallback for BtGattCallback {
        );
    }

    fn on_descriptor_write(&self, addr: String, status: i32, handle: i32) {
    fn on_descriptor_write(&self, addr: String, status: GattStatus, handle: i32) {
        print_info!(
            "GATT Descriptor write: addr = {}, status = {}, handle = {}",
            addr,
@@ -445,11 +456,11 @@ impl IBluetoothGattCallback for BtGattCallback {
        print_info!("GATT Notification: addr = {}, handle = {}, value = {:?}", addr, handle, value);
    }

    fn on_read_remote_rssi(&self, addr: String, rssi: i32, status: i32) {
    fn on_read_remote_rssi(&self, addr: String, rssi: i32, status: GattStatus) {
        print_info!("Remote RSSI read: addr = {}, rssi = {}, status = {}", addr, rssi, status);
    }

    fn on_configure_mtu(&self, addr: String, mtu: i32, status: i32) {
    fn on_configure_mtu(&self, addr: String, mtu: i32, status: GattStatus) {
        print_info!("MTU configured: addr = {}, mtu = {}, status = {}", addr, mtu, status);
    }

@@ -459,7 +470,7 @@ impl IBluetoothGattCallback for BtGattCallback {
        interval: i32,
        latency: i32,
        timeout: i32,
        status: i32,
        status: GattStatus,
    ) {
        print_info!(
            "Connection updated: addr = {}, interval = {}, latency = {}, timeout = {}, status = {}",
+25 −12
Original line number Diff line number Diff line
@@ -198,7 +198,7 @@ impl RPCProxy for IScannerCallbackDBus {}
)]
impl IScannerCallback for IScannerCallbackDBus {
    #[dbus_method("OnScannerRegistered")]
    fn on_scanner_registered(&self, uuid: Uuid128Bit, scanner_id: u8, status: u8) {}
    fn on_scanner_registered(&self, uuid: Uuid128Bit, scanner_id: u8, status: GattStatus) {}
}

// Implements RPC-friendly wrapper methods for calling IBluetooth, generated by
@@ -1018,12 +1018,12 @@ impl RPCProxy for IBluetoothGattCallbackDBus {}
)]
impl IBluetoothGattCallback for IBluetoothGattCallbackDBus {
    #[dbus_method("OnClientRegistered")]
    fn on_client_registered(&self, status: i32, client_id: i32) {}
    fn on_client_registered(&self, status: GattStatus, client_id: i32) {}

    #[dbus_method("OnClientConnectionState")]
    fn on_client_connection_state(
        &self,
        status: i32,
        status: GattStatus,
        client_id: i32,
        connected: bool,
        addr: String,
@@ -1037,31 +1037,44 @@ impl IBluetoothGattCallback for IBluetoothGattCallbackDBus {
    fn on_phy_read(&self, addr: String, tx_phy: LePhy, rx_phy: LePhy, status: GattStatus) {}

    #[dbus_method("OnSearchComplete")]
    fn on_search_complete(&self, addr: String, services: Vec<BluetoothGattService>, status: i32) {}
    fn on_search_complete(
        &self,
        addr: String,
        services: Vec<BluetoothGattService>,
        status: GattStatus,
    ) {
    }

    #[dbus_method("OnCharacteristicRead")]
    fn on_characteristic_read(&self, addr: String, status: i32, handle: i32, value: Vec<u8>) {}
    fn on_characteristic_read(
        &self,
        addr: String,
        status: GattStatus,
        handle: i32,
        value: Vec<u8>,
    ) {
    }

    #[dbus_method("OnCharacteristicWrite")]
    fn on_characteristic_write(&self, addr: String, status: i32, handle: i32) {}
    fn on_characteristic_write(&self, addr: String, status: GattStatus, handle: i32) {}

    #[dbus_method("OnExecuteWrite")]
    fn on_execute_write(&self, addr: String, status: i32) {}
    fn on_execute_write(&self, addr: String, status: GattStatus) {}

    #[dbus_method("OnDescriptorRead")]
    fn on_descriptor_read(&self, addr: String, status: i32, handle: i32, value: Vec<u8>) {}
    fn on_descriptor_read(&self, addr: String, status: GattStatus, handle: i32, value: Vec<u8>) {}

    #[dbus_method("OnDescriptorWrite")]
    fn on_descriptor_write(&self, addr: String, status: i32, handle: i32) {}
    fn on_descriptor_write(&self, addr: String, status: GattStatus, handle: i32) {}

    #[dbus_method("OnNotify")]
    fn on_notify(&self, addr: String, handle: i32, value: Vec<u8>) {}

    #[dbus_method("OnReadRemoteRssi")]
    fn on_read_remote_rssi(&self, addr: String, rssi: i32, status: i32) {}
    fn on_read_remote_rssi(&self, addr: String, rssi: i32, status: GattStatus) {}

    #[dbus_method("OnConfigureMtu")]
    fn on_configure_mtu(&self, addr: String, mtu: i32, status: i32) {}
    fn on_configure_mtu(&self, addr: String, mtu: i32, status: GattStatus) {}

    #[dbus_method("OnConnectionUpdated")]
    fn on_connection_updated(
@@ -1070,7 +1083,7 @@ impl IBluetoothGattCallback for IBluetoothGattCallbackDBus {
        interval: i32,
        latency: i32,
        timeout: i32,
        status: i32,
        status: GattStatus,
    ) {
    }

+23 −12
Original line number Diff line number Diff line
@@ -30,14 +30,14 @@ struct BluetoothGattCallbackDBus {}
#[dbus_proxy_obj(BluetoothGattCallback, "org.chromium.bluetooth.BluetoothGattCallback")]
impl IBluetoothGattCallback for BluetoothGattCallbackDBus {
    #[dbus_method("OnClientRegistered")]
    fn on_client_registered(&self, status: i32, scanner_id: i32) {
    fn on_client_registered(&self, status: GattStatus, scanner_id: i32) {
        dbus_generated!()
    }

    #[dbus_method("OnClientConnectionState")]
    fn on_client_connection_state(
        &self,
        status: i32,
        status: GattStatus,
        client_id: i32,
        connected: bool,
        addr: String,
@@ -56,32 +56,43 @@ impl IBluetoothGattCallback for BluetoothGattCallbackDBus {
    }

    #[dbus_method("OnSearchComplete")]
    fn on_search_complete(&self, addr: String, services: Vec<BluetoothGattService>, status: i32) {
    fn on_search_complete(
        &self,
        addr: String,
        services: Vec<BluetoothGattService>,
        status: GattStatus,
    ) {
        dbus_generated!()
    }

    #[dbus_method("OnCharacteristicRead")]
    fn on_characteristic_read(&self, addr: String, status: i32, handle: i32, value: Vec<u8>) {
    fn on_characteristic_read(
        &self,
        addr: String,
        status: GattStatus,
        handle: i32,
        value: Vec<u8>,
    ) {
        dbus_generated!()
    }

    #[dbus_method("OnCharacteristicWrite")]
    fn on_characteristic_write(&self, addr: String, status: i32, handle: i32) {
    fn on_characteristic_write(&self, addr: String, status: GattStatus, handle: i32) {
        dbus_generated!()
    }

    #[dbus_method("OnExecuteWrite")]
    fn on_execute_write(&self, addr: String, status: i32) {
    fn on_execute_write(&self, addr: String, status: GattStatus) {
        dbus_generated!()
    }

    #[dbus_method("OnDescriptorRead")]
    fn on_descriptor_read(&self, addr: String, status: i32, handle: i32, value: Vec<u8>) {
    fn on_descriptor_read(&self, addr: String, status: GattStatus, handle: i32, value: Vec<u8>) {
        dbus_generated!()
    }

    #[dbus_method("OnDescriptorWrite")]
    fn on_descriptor_write(&self, addr: String, status: i32, handle: i32) {
    fn on_descriptor_write(&self, addr: String, status: GattStatus, handle: i32) {
        dbus_generated!()
    }

@@ -91,12 +102,12 @@ impl IBluetoothGattCallback for BluetoothGattCallbackDBus {
    }

    #[dbus_method("OnReadRemoteRssi")]
    fn on_read_remote_rssi(&self, addr: String, rssi: i32, status: i32) {
    fn on_read_remote_rssi(&self, addr: String, rssi: i32, status: GattStatus) {
        dbus_generated!()
    }

    #[dbus_method("OnConfigureMtu")]
    fn on_configure_mtu(&self, addr: String, mtu: i32, status: i32) {
    fn on_configure_mtu(&self, addr: String, mtu: i32, status: GattStatus) {
        dbus_generated!()
    }

@@ -107,7 +118,7 @@ impl IBluetoothGattCallback for BluetoothGattCallbackDBus {
        interval: i32,
        latency: i32,
        timeout: i32,
        status: i32,
        status: GattStatus,
    ) {
        dbus_generated!()
    }
@@ -142,7 +153,7 @@ struct ScannerCallbackDBus {}
#[dbus_proxy_obj(ScannerCallback, "org.chromium.bluetooth.ScannerCallback")]
impl IScannerCallback for ScannerCallbackDBus {
    #[dbus_method("OnScannerRegistered")]
    fn on_scanner_registered(&self, uuid: Uuid128Bit, scanner_id: u8, status: u8) {
    fn on_scanner_registered(&self, uuid: Uuid128Bit, scanner_id: u8, status: GattStatus) {
        dbus_generated!()
    }
}
+12 −11
Original line number Diff line number Diff line
@@ -780,6 +780,18 @@ impl BtifBluetoothCallbacks for Bluetooth {
    ) {
        let address = addr.to_string();

        // Get the device type before the device is potentially deleted.
        let device_type = match self.get_remote_device_if_found(&address) {
            Some(d) => match d.properties.get(&BtPropertyType::TypeOfDevice) {
                Some(prop) => match prop {
                    BluetoothProperty::TypeOfDevice(type_of_device) => type_of_device.clone(),
                    _ => BtDeviceType::Unknown,
                },
                _ => BtDeviceType::Unknown,
            },
            _ => BtDeviceType::Unknown,
        };

        // Easy case of not bonded -- we remove the device from the bonded list and change the bond
        // state in the found list (in case it was previously bonding).
        if &bond_state == &BtBondState::NotBonded {
@@ -824,17 +836,6 @@ impl BtifBluetoothCallbacks for Bluetooth {
            );
        });

        let device_type = match self.get_remote_device_if_found(&address) {
            Some(d) => match d.properties.get(&BtPropertyType::TypeOfDevice) {
                Some(prop) => match prop {
                    BluetoothProperty::TypeOfDevice(type_of_device) => type_of_device.clone(),
                    _ => BtDeviceType::Unknown,
                },
                _ => BtDeviceType::Unknown,
            },
            _ => BtDeviceType::Unknown,
        };

        metrics::bond_state_changed(addr, device_type, status, bond_state, fail_reason);
    }

+107 −72

File changed.

Preview size limit exceeded, changes collapsed.

Loading