Loading system/gd/rust/linux/client/src/command_handler.rs +2 −2 Original line number Diff line number Diff line Loading @@ -355,7 +355,7 @@ impl CommandHandler { .lock() .unwrap() .adapter_dbus .as_ref() .as_mut() .unwrap() .set_discoverable(true, 60); print_info!( Loading @@ -369,7 +369,7 @@ impl CommandHandler { .lock() .unwrap() .adapter_dbus .as_ref() .as_mut() .unwrap() .set_discoverable(false, 60); print_info!( Loading system/gd/rust/linux/client/src/dbus_iface.rs +1 −1 Original line number Diff line number Diff line Loading @@ -344,7 +344,7 @@ impl IBluetooth for BluetoothDBus { } #[dbus_method("SetDiscoverable")] fn set_discoverable(&self, mode: bool, duration: u32) -> bool { fn set_discoverable(&mut self, mode: bool, duration: u32) -> bool { dbus_generated!() } Loading system/gd/rust/linux/service/src/iface_bluetooth.rs +1 −1 Original line number Diff line number Diff line Loading @@ -217,7 +217,7 @@ impl IBluetooth for IBluetoothDBus { } #[dbus_method("SetDiscoverable")] fn set_discoverable(&self, mode: bool, duration: u32) -> bool { fn set_discoverable(&mut self, mode: bool, duration: u32) -> bool { dbus_generated!() } Loading system/gd/rust/linux/stack/src/bluetooth.rs +34 −17 Original line number Diff line number Diff line Loading @@ -94,7 +94,7 @@ pub trait IBluetooth { fn get_discoverable_timeout(&self) -> u32; /// Sets discoverability. If discoverable, limits the duration with given value. fn set_discoverable(&self, mode: bool, duration: u32) -> bool; fn set_discoverable(&mut self, mode: bool, duration: u32) -> bool; /// Returns whether multi-advertisement is supported. /// A minimum number of 5 advertising instances is required for multi-advertisment support. Loading Loading @@ -345,6 +345,7 @@ pub struct Bluetooth { wait_to_connect: bool, // Internal API members internal_le_rand_queue: VecDeque<OneShotSender<u64>>, discoverable_timeout: Option<JoinHandle<()>>, } impl Bluetooth { Loading Loading @@ -379,6 +380,7 @@ impl Bluetooth { wait_to_connect: false, // Internal API members internal_le_rand_queue: VecDeque::<OneShotSender<u64>>::new(), discoverable_timeout: None, } } Loading Loading @@ -1079,22 +1081,37 @@ impl IBluetooth for Bluetooth { } } fn set_discoverable(&self, mode: bool, duration: u32) -> bool { self.intf fn set_discoverable(&mut self, mode: bool, duration: u32) -> bool { let intf = self.intf.lock().unwrap(); // The old timer should be overwritten regardless of what the new mode is. if let Some(ref handle) = self.discoverable_timeout { handle.abort(); self.discoverable_timeout = None; } let off_mode = if self.is_connectable { BtScanMode::Connectable } else { BtScanMode::None_ }; let new_mode = if mode { BtScanMode::ConnectableDiscoverable } else { off_mode.clone() }; if intf.set_adapter_property(BluetoothProperty::AdapterDiscoverableTimeout(duration)) != 0 || intf.set_adapter_property(BluetoothProperty::AdapterScanMode(new_mode)) != 0 { return false; } if mode && duration != 0 { let intf_clone = self.intf.clone(); self.discoverable_timeout = Some(tokio::spawn(async move { time::sleep(Duration::from_secs(duration.into())).await; intf_clone .lock() .unwrap() .set_adapter_property(BluetoothProperty::AdapterDiscoverableTimeout(duration)); self.intf.lock().unwrap().set_adapter_property(BluetoothProperty::AdapterScanMode( if mode { BtScanMode::ConnectableDiscoverable } else { if self.is_connectable { BtScanMode::Connectable } else { BtScanMode::None_ .set_adapter_property(BluetoothProperty::AdapterScanMode(off_mode)); })); } }, )) == 0 true } fn is_multi_advertisement_supported(&self) -> bool { Loading Loading
system/gd/rust/linux/client/src/command_handler.rs +2 −2 Original line number Diff line number Diff line Loading @@ -355,7 +355,7 @@ impl CommandHandler { .lock() .unwrap() .adapter_dbus .as_ref() .as_mut() .unwrap() .set_discoverable(true, 60); print_info!( Loading @@ -369,7 +369,7 @@ impl CommandHandler { .lock() .unwrap() .adapter_dbus .as_ref() .as_mut() .unwrap() .set_discoverable(false, 60); print_info!( Loading
system/gd/rust/linux/client/src/dbus_iface.rs +1 −1 Original line number Diff line number Diff line Loading @@ -344,7 +344,7 @@ impl IBluetooth for BluetoothDBus { } #[dbus_method("SetDiscoverable")] fn set_discoverable(&self, mode: bool, duration: u32) -> bool { fn set_discoverable(&mut self, mode: bool, duration: u32) -> bool { dbus_generated!() } Loading
system/gd/rust/linux/service/src/iface_bluetooth.rs +1 −1 Original line number Diff line number Diff line Loading @@ -217,7 +217,7 @@ impl IBluetooth for IBluetoothDBus { } #[dbus_method("SetDiscoverable")] fn set_discoverable(&self, mode: bool, duration: u32) -> bool { fn set_discoverable(&mut self, mode: bool, duration: u32) -> bool { dbus_generated!() } Loading
system/gd/rust/linux/stack/src/bluetooth.rs +34 −17 Original line number Diff line number Diff line Loading @@ -94,7 +94,7 @@ pub trait IBluetooth { fn get_discoverable_timeout(&self) -> u32; /// Sets discoverability. If discoverable, limits the duration with given value. fn set_discoverable(&self, mode: bool, duration: u32) -> bool; fn set_discoverable(&mut self, mode: bool, duration: u32) -> bool; /// Returns whether multi-advertisement is supported. /// A minimum number of 5 advertising instances is required for multi-advertisment support. Loading Loading @@ -345,6 +345,7 @@ pub struct Bluetooth { wait_to_connect: bool, // Internal API members internal_le_rand_queue: VecDeque<OneShotSender<u64>>, discoverable_timeout: Option<JoinHandle<()>>, } impl Bluetooth { Loading Loading @@ -379,6 +380,7 @@ impl Bluetooth { wait_to_connect: false, // Internal API members internal_le_rand_queue: VecDeque::<OneShotSender<u64>>::new(), discoverable_timeout: None, } } Loading Loading @@ -1079,22 +1081,37 @@ impl IBluetooth for Bluetooth { } } fn set_discoverable(&self, mode: bool, duration: u32) -> bool { self.intf fn set_discoverable(&mut self, mode: bool, duration: u32) -> bool { let intf = self.intf.lock().unwrap(); // The old timer should be overwritten regardless of what the new mode is. if let Some(ref handle) = self.discoverable_timeout { handle.abort(); self.discoverable_timeout = None; } let off_mode = if self.is_connectable { BtScanMode::Connectable } else { BtScanMode::None_ }; let new_mode = if mode { BtScanMode::ConnectableDiscoverable } else { off_mode.clone() }; if intf.set_adapter_property(BluetoothProperty::AdapterDiscoverableTimeout(duration)) != 0 || intf.set_adapter_property(BluetoothProperty::AdapterScanMode(new_mode)) != 0 { return false; } if mode && duration != 0 { let intf_clone = self.intf.clone(); self.discoverable_timeout = Some(tokio::spawn(async move { time::sleep(Duration::from_secs(duration.into())).await; intf_clone .lock() .unwrap() .set_adapter_property(BluetoothProperty::AdapterDiscoverableTimeout(duration)); self.intf.lock().unwrap().set_adapter_property(BluetoothProperty::AdapterScanMode( if mode { BtScanMode::ConnectableDiscoverable } else { if self.is_connectable { BtScanMode::Connectable } else { BtScanMode::None_ .set_adapter_property(BluetoothProperty::AdapterScanMode(off_mode)); })); } }, )) == 0 true } fn is_multi_advertisement_supported(&self) -> bool { Loading