Loading system/gd/rust/linux/stack/src/bluetooth.rs +7 −1 Original line number Diff line number Diff line Loading @@ -684,6 +684,8 @@ impl Bluetooth { } pub fn init_profiles(&mut self) { self.bluetooth_gatt.lock().unwrap().enable(true); let sdptx = self.tx.clone(); self.sdp = Some(Sdp::new(&self.intf.lock().unwrap())); self.sdp.as_mut().unwrap().initialize(SdpCallbacksDispatcher { Loading Loading @@ -1898,7 +1900,11 @@ impl IBluetooth for Bluetooth { } fn disable(&mut self) -> bool { self.intf.lock().unwrap().disable() == 0 let success = self.intf.lock().unwrap().disable() == 0; if success { self.bluetooth_gatt.lock().unwrap().enable(false); } success } fn cleanup(&mut self) { Loading system/gd/rust/linux/stack/src/bluetooth_gatt.rs +18 −0 Original line number Diff line number Diff line Loading @@ -1403,6 +1403,7 @@ pub struct BluetoothGatt { small_rng: SmallRng, gatt_async: Arc<tokio::sync::Mutex<GattAsyncIntf>>, enabled: bool, } impl BluetoothGatt { Loading Loading @@ -1436,6 +1437,7 @@ impl BluetoothGatt { async_helper_msft_adv_monitor_remove, async_helper_msft_adv_monitor_enable, })), enabled: false, } } Loading Loading @@ -1530,6 +1532,10 @@ impl BluetoothGatt { }); } pub fn enable(&mut self, enabled: bool) { self.enabled = enabled; } /// Remove a scanner callback and unregisters all scanners associated with that callback. pub fn remove_scanner_callback(&mut self, callback_id: u32) -> bool { let affected_scanner_ids: Vec<u8> = self Loading Loading @@ -1641,6 +1647,10 @@ impl BluetoothGatt { /// The resume_scan method is used to resume scanning after system suspension. /// It assumes that scanner.filter has already had the filter data. fn resume_scan(&mut self, scanner_id: u8) -> BtStatus { if !self.enabled { return BtStatus::Fail; } let scan_suspend_mode = self.get_scan_suspend_mode(); if scan_suspend_mode != SuspendMode::Normal && scan_suspend_mode != SuspendMode::Resuming { return BtStatus::Busy; Loading Loading @@ -2004,6 +2014,10 @@ impl IBluetoothGatt for BluetoothGatt { settings: Option<ScanSettings>, filter: Option<ScanFilter>, ) -> BtStatus { if !self.enabled { return BtStatus::Fail; } let scan_suspend_mode = self.get_scan_suspend_mode(); if scan_suspend_mode != SuspendMode::Normal && scan_suspend_mode != SuspendMode::Resuming { return BtStatus::Busy; Loading Loading @@ -2036,6 +2050,10 @@ impl IBluetoothGatt for BluetoothGatt { } fn stop_scan(&mut self, scanner_id: u8) -> BtStatus { if !self.enabled { return BtStatus::Fail; } let scan_suspend_mode = self.get_scan_suspend_mode(); if scan_suspend_mode != SuspendMode::Normal && scan_suspend_mode != SuspendMode::Suspending { Loading Loading
system/gd/rust/linux/stack/src/bluetooth.rs +7 −1 Original line number Diff line number Diff line Loading @@ -684,6 +684,8 @@ impl Bluetooth { } pub fn init_profiles(&mut self) { self.bluetooth_gatt.lock().unwrap().enable(true); let sdptx = self.tx.clone(); self.sdp = Some(Sdp::new(&self.intf.lock().unwrap())); self.sdp.as_mut().unwrap().initialize(SdpCallbacksDispatcher { Loading Loading @@ -1898,7 +1900,11 @@ impl IBluetooth for Bluetooth { } fn disable(&mut self) -> bool { self.intf.lock().unwrap().disable() == 0 let success = self.intf.lock().unwrap().disable() == 0; if success { self.bluetooth_gatt.lock().unwrap().enable(false); } success } fn cleanup(&mut self) { Loading
system/gd/rust/linux/stack/src/bluetooth_gatt.rs +18 −0 Original line number Diff line number Diff line Loading @@ -1403,6 +1403,7 @@ pub struct BluetoothGatt { small_rng: SmallRng, gatt_async: Arc<tokio::sync::Mutex<GattAsyncIntf>>, enabled: bool, } impl BluetoothGatt { Loading Loading @@ -1436,6 +1437,7 @@ impl BluetoothGatt { async_helper_msft_adv_monitor_remove, async_helper_msft_adv_monitor_enable, })), enabled: false, } } Loading Loading @@ -1530,6 +1532,10 @@ impl BluetoothGatt { }); } pub fn enable(&mut self, enabled: bool) { self.enabled = enabled; } /// Remove a scanner callback and unregisters all scanners associated with that callback. pub fn remove_scanner_callback(&mut self, callback_id: u32) -> bool { let affected_scanner_ids: Vec<u8> = self Loading Loading @@ -1641,6 +1647,10 @@ impl BluetoothGatt { /// The resume_scan method is used to resume scanning after system suspension. /// It assumes that scanner.filter has already had the filter data. fn resume_scan(&mut self, scanner_id: u8) -> BtStatus { if !self.enabled { return BtStatus::Fail; } let scan_suspend_mode = self.get_scan_suspend_mode(); if scan_suspend_mode != SuspendMode::Normal && scan_suspend_mode != SuspendMode::Resuming { return BtStatus::Busy; Loading Loading @@ -2004,6 +2014,10 @@ impl IBluetoothGatt for BluetoothGatt { settings: Option<ScanSettings>, filter: Option<ScanFilter>, ) -> BtStatus { if !self.enabled { return BtStatus::Fail; } let scan_suspend_mode = self.get_scan_suspend_mode(); if scan_suspend_mode != SuspendMode::Normal && scan_suspend_mode != SuspendMode::Resuming { return BtStatus::Busy; Loading Loading @@ -2036,6 +2050,10 @@ impl IBluetoothGatt for BluetoothGatt { } fn stop_scan(&mut self, scanner_id: u8) -> BtStatus { if !self.enabled { return BtStatus::Fail; } let scan_suspend_mode = self.get_scan_suspend_mode(); if scan_suspend_mode != SuspendMode::Normal && scan_suspend_mode != SuspendMode::Suspending { Loading