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

Commit fd997b34 authored by Hsin-chen Chuang's avatar Hsin-chen Chuang Committed by Gerrit Code Review
Browse files

Merge "floss: Don't bookmark connectable mode if set mode failed" into main

parents d1b95a3a 4035363e
Loading
Loading
Loading
Loading
+14 −17
Original line number Original line Diff line number Diff line
@@ -870,15 +870,23 @@ impl Bluetooth {
        if self.is_connectable == mode {
        if self.is_connectable == mode {
            return true;
            return true;
        }
        }
        self.is_connectable = mode;
        if self.discoverable_mode != BtDiscMode::NonDiscoverable {
        if self.discoverable_mode != BtDiscMode::NonDiscoverable {
            // Discoverable always implies connectable. Don't affect the discoverable mode for now
            // Discoverable always implies connectable. Don't affect the discoverable mode for now
            // and the connectable mode would be restored when discoverable becomes off.
            // and the connectable mode would be restored when discoverable becomes off.
            self.is_connectable = mode;
            return true;
            return true;
        }
        }
        let status =
            self.intf.lock().unwrap().set_adapter_property(BluetoothProperty::AdapterScanMode(
            self.intf.lock().unwrap().set_adapter_property(BluetoothProperty::AdapterScanMode(
                if mode { BtScanMode::Connectable } else { BtScanMode::None_ },
                if mode { BtScanMode::Connectable } else { BtScanMode::None_ },
        )) == 0
            ));
        let status = BtStatus::from(status as u32);
        if status != BtStatus::Success {
            warn!("Failed to set connectable mode: {:?}", status);
            return false;
        }
        self.is_connectable = mode;
        return true;
    }
    }


    /// Returns adapter's discoverable mode.
    /// Returns adapter's discoverable mode.
@@ -1335,13 +1343,7 @@ pub(crate) trait BtifBluetoothCallbacks {
    fn discovery_state(&mut self, state: BtDiscoveryState) {}
    fn discovery_state(&mut self, state: BtDiscoveryState) {}


    #[btif_callback(SspRequest)]
    #[btif_callback(SspRequest)]
    fn ssp_request(
    fn ssp_request(&mut self, remote_addr: RawAddress, variant: BtSspVariant, passkey: u32) {}
        &mut self,
        remote_addr: RawAddress,
        variant: BtSspVariant,
        passkey: u32,
    ) {
    }


    #[btif_callback(BondState)]
    #[btif_callback(BondState)]
    fn bond_state(
    fn bond_state(
@@ -1701,12 +1703,7 @@ impl BtifBluetoothCallbacks for Bluetooth {
        }
        }
    }
    }


    fn ssp_request(
    fn ssp_request(&mut self, remote_addr: RawAddress, variant: BtSspVariant, passkey: u32) {
        &mut self,
        remote_addr: RawAddress,
        variant: BtSspVariant,
        passkey: u32,
    ) {
        // Accept the Just-Works pairing that we initiated, reject otherwise.
        // Accept the Just-Works pairing that we initiated, reject otherwise.
        if variant == BtSspVariant::Consent {
        if variant == BtSspVariant::Consent {
            let initiated_by_us = Some(remote_addr.clone()) == self.active_pairing_address;
            let initiated_by_us = Some(remote_addr.clone()) == self.active_pairing_address;