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

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

Merge "floss: supports local name in advertising data"

parents 62b59185 614408f7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -929,7 +929,7 @@ impl CommandHandler {
                    manufacturer_data: HashMap::<i32, Vec<u8>>::from([(0, vec![0, 1, 2])]),
                    service_data: HashMap::<String, Vec<u8>>::new(),
                    include_tx_power_level: true,
                    include_device_name: false,
                    include_device_name: true,
                };

                let reg_id = self
+3 −2
Original line number Diff line number Diff line
@@ -265,13 +265,14 @@ fn main() -> Result<(), Box<dyn Error>> {
        {
            intf.lock().unwrap().initialize(get_bt_dispatcher(tx.clone()), init_flags);

            bluetooth_media.lock().unwrap().set_adapter(bluetooth.clone());
            let adapter = bluetooth.clone();
            bluetooth_media.lock().unwrap().set_adapter(adapter.clone());

            let mut bluetooth = bluetooth.lock().unwrap();
            bluetooth.init_profiles();
            bluetooth.enable();

            bluetooth_gatt.lock().unwrap().init_profiles(tx.clone());
            bluetooth_gatt.lock().unwrap().init_profiles(tx.clone(), adapter.clone());
            bt_sock_mgr.lock().unwrap().initialize(intf.clone());
        }

+6 −4
Original line number Diff line number Diff line
@@ -459,11 +459,13 @@ impl Advertisers {

    /// Removes an advertiser callback and unregisters all advertising sets associated with that callback.
    pub(crate) fn remove_callback(&mut self, callback_id: CallbackId, gatt: &mut Gatt) -> bool {
        for (_, s) in self.sets.iter_mut().filter(|(_, s)| s.callback_id() == callback_id) {
            if None != s.advertiser_id {
        for (_, s) in self
            .sets
            .iter()
            .filter(|(_, s)| s.callback_id() == callback_id && s.advertiser_id.is_some())
        {
            gatt.advertiser.unregister(s.adv_id());
        }
        }
        self.sets.retain(|_, s| s.callback_id() != callback_id);

        self.callbacks.remove_callback(callback_id)
+10 −4
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ use bt_topshim::profiles::gatt::{
};
use bt_topshim::topstack;

use crate::bluetooth::{Bluetooth, IBluetooth};
use crate::bluetooth_adv::{
    AdvertiseData, Advertisers, AdvertisingSetInfo, AdvertisingSetParameters,
    IAdvertisingSetCallback, PeriodicAdvertisingParameters,
@@ -686,6 +687,7 @@ pub struct ScanFilter {}
pub struct BluetoothGatt {
    intf: Arc<Mutex<BluetoothInterface>>,
    gatt: Option<Gatt>,
    adapter: Option<Arc<Mutex<Box<Bluetooth>>>>,

    context_map: ContextMap,
    reliable_queue: HashSet<String>,
@@ -704,6 +706,7 @@ impl BluetoothGatt {
        BluetoothGatt {
            intf: intf,
            gatt: None,
            adapter: None,
            context_map: ContextMap::new(),
            reliable_queue: HashSet::new(),
            scanner_callbacks: Callbacks::new(tx.clone(), Message::ScannerCallbackDisconnected),
@@ -713,9 +716,10 @@ impl BluetoothGatt {
        }
    }

    pub fn init_profiles(&mut self, tx: Sender<Message>) {
    pub fn init_profiles(&mut self, tx: Sender<Message>, adapter: Arc<Mutex<Box<Bluetooth>>>) {
        println!("woot woot");
        self.gatt = Gatt::new(&self.intf.lock().unwrap());
        self.adapter = Some(adapter);

        let tx_clone = tx.clone();
        let gatt_client_callbacks_dispatcher = GattClientCallbacksDispatcher {
@@ -816,11 +820,13 @@ impl BluetoothGatt {
    }

    fn get_adapter_name(&self) -> String {
        // TODO(b/233128394): initialize the adaptert from service and
        // get local adapter name here.
        if let Some(adapter) = &self.adapter {
            adapter.lock().unwrap().get_name()
        } else {
            String::new()
        }
    }
}

#[derive(Debug, FromPrimitive, ToPrimitive)]
#[repr(u8)]