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

Commit 267dc78f authored by Michael Sun's avatar Michael Sun Committed by Gerrit Code Review
Browse files

Merge "floss: update bond and connect calls to provide status" into main

parents 9716aff3 fb102e50
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -783,14 +783,14 @@ impl CommandHandler {
                    .into());
                }

                let success = self
                let status = self
                    .lock_context()
                    .adapter_dbus
                    .as_mut()
                    .unwrap()
                    .create_bond(device.clone(), BtTransport::Auto);

                if success {
                if status == BtStatus::Success {
                    self.lock_context().bonding_attempt = Some(device);
                }
            }
@@ -832,14 +832,14 @@ impl CommandHandler {
                    name: String::from("Classic Device"),
                };

                let success = self
                let status = self
                    .lock_context()
                    .adapter_dbus
                    .as_mut()
                    .unwrap()
                    .connect_all_enabled_profiles(device.clone());

                if success {
                if status == BtStatus::Success {
                    println!("Connecting to {}", &device.address);
                } else {
                    println!("Can't connect to {}", &device.address);
+2 −2
Original line number Diff line number Diff line
@@ -846,7 +846,7 @@ impl IBluetooth for BluetoothDBus {
    }

    #[dbus_method("CreateBond")]
    fn create_bond(&mut self, device: BluetoothDevice, transport: BtTransport) -> bool {
    fn create_bond(&mut self, device: BluetoothDevice, transport: BtTransport) -> BtStatus {
        dbus_generated!()
    }

@@ -981,7 +981,7 @@ impl IBluetooth for BluetoothDBus {
    }

    #[dbus_method("ConnectAllEnabledProfiles")]
    fn connect_all_enabled_profiles(&mut self, device: BluetoothDevice) -> bool {
    fn connect_all_enabled_profiles(&mut self, device: BluetoothDevice) -> BtStatus {
        dbus_generated!()
    }

+1 −1
Original line number Diff line number Diff line
[package]
name = "manager_service"
version = "0.3.0"
version = "0.4.0"
edition = "2018"
build = "build.rs"

+2 −2
Original line number Diff line number Diff line
@@ -557,7 +557,7 @@ impl IBluetooth for IBluetoothDBus {
    }

    #[dbus_method("CreateBond")]
    fn create_bond(&mut self, device: BluetoothDevice, transport: BtTransport) -> bool {
    fn create_bond(&mut self, device: BluetoothDevice, transport: BtTransport) -> BtStatus {
        dbus_generated!()
    }

@@ -692,7 +692,7 @@ impl IBluetooth for IBluetoothDBus {
    }

    #[dbus_method("ConnectAllEnabledProfiles")]
    fn connect_all_enabled_profiles(&mut self, device: BluetoothDevice) -> bool {
    fn connect_all_enabled_profiles(&mut self, device: BluetoothDevice) -> BtStatus {
        dbus_generated!()
    }

+12 −12
Original line number Diff line number Diff line
@@ -156,7 +156,7 @@ pub trait IBluetooth {
    fn get_discovery_end_millis(&self) -> u64;

    /// Initiates pairing to a remote device. Triggers connection if not already started.
    fn create_bond(&mut self, device: BluetoothDevice, transport: BtTransport) -> bool;
    fn create_bond(&mut self, device: BluetoothDevice, transport: BtTransport) -> BtStatus;

    /// Cancels any pending bond attempt on given device.
    fn cancel_bond_process(&mut self, device: BluetoothDevice) -> bool;
@@ -237,7 +237,7 @@ pub trait IBluetooth {
    fn remove_sdp_record(&self, handle: i32) -> bool;

    /// Connect all profiles supported by device and enabled on adapter.
    fn connect_all_enabled_profiles(&mut self, device: BluetoothDevice) -> bool;
    fn connect_all_enabled_profiles(&mut self, device: BluetoothDevice) -> BtStatus;

    /// Disconnect all profiles supported by device and enabled on adapter.
    /// Note that it includes all custom profiles enabled by the users e.g. through SocketManager or
@@ -2279,7 +2279,7 @@ impl IBluetooth for Bluetooth {
        }
    }

    fn create_bond(&mut self, device: BluetoothDevice, transport: BtTransport) -> bool {
    fn create_bond(&mut self, device: BluetoothDevice, transport: BtTransport) -> BtStatus {
        let addr = RawAddress::from_string(device.address.clone());

        if addr.is_none() {
@@ -2292,7 +2292,7 @@ impl IBluetooth for Bluetooth {
                0,
            );
            warn!("Can't create bond. Address {} is not valid", device.address);
            return false;
            return BtStatus::InvalidParam;
        }

        let address = addr.unwrap();
@@ -2308,7 +2308,7 @@ impl IBluetooth for Bluetooth {
                DisplayAddress(&address),
                DisplayAddress(&active_address)
            );
            return false;
            return BtStatus::Busy;
        }

        // There could be a race between bond complete and bond cancel, which makes
@@ -2335,7 +2335,7 @@ impl IBluetooth for Bluetooth {
                BtBondState::NotBonded,
                0,
            );
            return false;
            return BtStatus::from(status as u32);
        }

        // Creating bond automatically create ACL connection as well, therefore also log metrics
@@ -2347,7 +2347,7 @@ impl IBluetooth for Bluetooth {
            metrics::acl_connect_attempt(address, BtAclState::Connected);
        }

        return true;
        return BtStatus::Success;
    }

    fn cancel_bond_process(&mut self, device: BluetoothDevice) -> bool {
@@ -2691,17 +2691,17 @@ impl IBluetooth for Bluetooth {
        self.sdp.as_ref().unwrap().remove_sdp_record(handle) == BtStatus::Success
    }

    fn connect_all_enabled_profiles(&mut self, device: BluetoothDevice) -> bool {
    fn connect_all_enabled_profiles(&mut self, device: BluetoothDevice) -> BtStatus {
        // Profile init must be complete before this api is callable
        if !self.profiles_ready {
            return false;
            return BtStatus::NotReady;
        }

        let mut addr = match RawAddress::from_string(device.address.clone()) {
            Some(v) => v,
            None => {
                warn!("Can't connect profiles on invalid address [{}]", &device.address);
                return false;
                return BtStatus::InvalidParam;
            }
        };

@@ -2773,7 +2773,7 @@ impl IBluetooth for Bluetooth {
                                let transport =
                                    match self.get_remote_device_if_found(&device.address) {
                                        Some(context) => context.acl_reported_transport,
                                        None => return false,
                                        None => return BtStatus::RemoteDeviceDown,
                                    };
                                let device_to_send = device.clone();
                                let transport = match self.get_remote_type(device.clone()) {
@@ -2821,7 +2821,7 @@ impl IBluetooth for Bluetooth {
            self.resume_discovery();
        }

        return true;
        return BtStatus::Success;
    }

    fn disconnect_all_enabled_profiles(&mut self, device: BluetoothDevice) -> bool {