Loading system/gd/rust/linux/stack/src/bluetooth.rs +19 −25 Original line number Diff line number Diff line Loading @@ -308,8 +308,8 @@ pub trait IBluetoothQALegacy { fn send_hid_data(&mut self, addr: RawAddress, data: String) -> BtStatus; } /// Delayed actions from adapter events. pub enum DelayedActions { /// Action events from lib.rs pub enum AdapterActions { /// Check whether the current set of found devices are still fresh. DeviceFreshnessCheck, Loading Loading @@ -1092,22 +1092,22 @@ impl Bluetooth { ); } /// Handle some delayed and recurring actions within the adapter. pub(crate) fn handle_delayed_actions(&mut self, action: DelayedActions) { /// Handle adapter actions. pub(crate) fn handle_actions(&mut self, action: AdapterActions) { match action { DelayedActions::DeviceFreshnessCheck => { AdapterActions::DeviceFreshnessCheck => { self.trigger_freshness_check(); } DelayedActions::ConnectAllProfiles(device) => { AdapterActions::ConnectAllProfiles(device) => { self.connect_all_enabled_profiles(device); } DelayedActions::ConnectProfiles(uuids, device) => { AdapterActions::ConnectProfiles(uuids, device) => { self.connect_profiles_internal(&uuids, device); } DelayedActions::BleDiscoveryScannerRegistered(uuid, scanner_id, status) => { AdapterActions::BleDiscoveryScannerRegistered(uuid, scanner_id, status) => { if let Some(app_uuid) = self.ble_scanner_uuid { if app_uuid == uuid { if status == GattStatus::Success { Loading @@ -1119,7 +1119,7 @@ impl Bluetooth { } } DelayedActions::BleDiscoveryScannerResult(result) => { AdapterActions::BleDiscoveryScannerResult(result) => { // Generate a vector of properties from ScanResult. let properties = { let mut props = vec![]; Loading Loading @@ -1164,11 +1164,11 @@ impl Bluetooth { )); } DelayedActions::ResetDiscoverable => { AdapterActions::ResetDiscoverable => { self.set_discoverable(BtDiscMode::NonDiscoverable, 0); } DelayedActions::CreateBond => { AdapterActions::CreateBond => { if let Some((device, transport)) = self.pending_create_bond.take() { let status = self.create_bond(device, transport); if status != BtStatus::Success { Loading Loading @@ -1335,9 +1335,7 @@ impl Bluetooth { let tx = self.tx.clone(); tokio::spawn(async move { let _ = tx .send(Message::DelayedAdapterActions(DelayedActions::ConnectProfiles( new_uuids, device, ))) .send(Message::AdapterActions(AdapterActions::ConnectProfiles(new_uuids, device))) .await; }); } Loading Loading @@ -1668,9 +1666,7 @@ impl BtifBluetoothCallbacks for Bluetooth { loop { time::sleep(FOUND_DEVICE_FRESHNESS).await; let _ = txl .send(Message::DelayedAdapterActions( DelayedActions::DeviceFreshnessCheck, )) .send(Message::AdapterActions(AdapterActions::DeviceFreshnessCheck)) .await; } })); Loading Loading @@ -1821,7 +1817,7 @@ impl BtifBluetoothCallbacks for Bluetooth { debug!("Invoking delayed CreateBond"); let tx = self.tx.clone(); tokio::spawn(async move { let _ = tx.send(Message::DelayedAdapterActions(DelayedActions::CreateBond)).await; let _ = tx.send(Message::AdapterActions(AdapterActions::CreateBond)).await; }); } } Loading Loading @@ -2173,9 +2169,9 @@ impl IScannerCallback for BleDiscoveryCallbacks { let tx = self.tx.clone(); tokio::spawn(async move { let _ = tx .send(Message::DelayedAdapterActions( DelayedActions::BleDiscoveryScannerRegistered(uuid, scanner_id, status), )) .send(Message::AdapterActions(AdapterActions::BleDiscoveryScannerRegistered( uuid, scanner_id, status, ))) .await; }); } Loading @@ -2184,7 +2180,7 @@ impl IScannerCallback for BleDiscoveryCallbacks { let tx = self.tx.clone(); tokio::spawn(async move { let _ = tx .send(Message::DelayedAdapterActions(DelayedActions::BleDiscoveryScannerResult( .send(Message::AdapterActions(AdapterActions::BleDiscoveryScannerResult( scan_result, ))) .await; Loading Loading @@ -2339,9 +2335,7 @@ impl IBluetooth for Bluetooth { let txl = self.tx.clone(); self.discoverable_timeout = Some(tokio::spawn(async move { time::sleep(Duration::from_secs(duration.into())).await; let _ = txl .send(Message::DelayedAdapterActions(DelayedActions::ResetDiscoverable)) .await; let _ = txl.send(Message::AdapterActions(AdapterActions::ResetDiscoverable)).await; })); } Loading system/gd/rust/linux/stack/src/lib.rs +5 −6 Original line number Diff line number Diff line Loading @@ -31,8 +31,8 @@ use crate::battery_manager::{BatteryManager, BatterySet}; use crate::battery_provider_manager::BatteryProviderManager; use crate::battery_service::{BatteryService, BatteryServiceActions}; use crate::bluetooth::{ dispatch_base_callbacks, dispatch_hid_host_callbacks, dispatch_sdp_callbacks, Bluetooth, BluetoothDevice, DelayedActions, IBluetooth, dispatch_base_callbacks, dispatch_hid_host_callbacks, dispatch_sdp_callbacks, AdapterActions, Bluetooth, BluetoothDevice, IBluetooth, }; use crate::bluetooth_admin::{AdminActions, BluetoothAdmin, IBluetoothAdmin}; use crate::bluetooth_adv::{dispatch_le_adv_callbacks, AdvertiserActions}; Loading Loading @@ -105,8 +105,7 @@ pub enum Message { AdapterCallbackDisconnected(u32), ConnectionCallbackDisconnected(u32), // Some delayed actions for the adapter. DelayedAdapterActions(DelayedActions), AdapterActions(AdapterActions), // Follows IBluetooth's on_device_(dis)connected and bond_state callbacks // but doesn't require depending on Bluetooth. Loading Loading @@ -429,8 +428,8 @@ impl Stack { bluetooth.lock().unwrap().connection_callback_disconnected(id); } Message::DelayedAdapterActions(action) => { bluetooth.lock().unwrap().handle_delayed_actions(action); Message::AdapterActions(action) => { bluetooth.lock().unwrap().handle_actions(action); } // Any service needing an updated list of devices can have an Loading system/gd/rust/linux/stack/src/suspend.rs +2 −4 Original line number Diff line number Diff line //! Suspend/Resume API. use crate::bluetooth::{Bluetooth, BluetoothDevice, BtifBluetoothCallbacks, DelayedActions}; use crate::bluetooth::{AdapterActions, Bluetooth, BluetoothDevice, BtifBluetoothCallbacks}; use crate::bluetooth_media::BluetoothMedia; use crate::callbacks::Callbacks; use crate::{BluetoothGatt, Message, RPCProxy}; Loading Loading @@ -337,9 +337,7 @@ impl ISuspend for Suspend { // Queue up connections. for device in reconnect_list { let _unused: Option<()> = txl .send(Message::DelayedAdapterActions(DelayedActions::ConnectAllProfiles( device, ))) .send(Message::AdapterActions(AdapterActions::ConnectAllProfiles(device))) .await .ok(); } Loading Loading
system/gd/rust/linux/stack/src/bluetooth.rs +19 −25 Original line number Diff line number Diff line Loading @@ -308,8 +308,8 @@ pub trait IBluetoothQALegacy { fn send_hid_data(&mut self, addr: RawAddress, data: String) -> BtStatus; } /// Delayed actions from adapter events. pub enum DelayedActions { /// Action events from lib.rs pub enum AdapterActions { /// Check whether the current set of found devices are still fresh. DeviceFreshnessCheck, Loading Loading @@ -1092,22 +1092,22 @@ impl Bluetooth { ); } /// Handle some delayed and recurring actions within the adapter. pub(crate) fn handle_delayed_actions(&mut self, action: DelayedActions) { /// Handle adapter actions. pub(crate) fn handle_actions(&mut self, action: AdapterActions) { match action { DelayedActions::DeviceFreshnessCheck => { AdapterActions::DeviceFreshnessCheck => { self.trigger_freshness_check(); } DelayedActions::ConnectAllProfiles(device) => { AdapterActions::ConnectAllProfiles(device) => { self.connect_all_enabled_profiles(device); } DelayedActions::ConnectProfiles(uuids, device) => { AdapterActions::ConnectProfiles(uuids, device) => { self.connect_profiles_internal(&uuids, device); } DelayedActions::BleDiscoveryScannerRegistered(uuid, scanner_id, status) => { AdapterActions::BleDiscoveryScannerRegistered(uuid, scanner_id, status) => { if let Some(app_uuid) = self.ble_scanner_uuid { if app_uuid == uuid { if status == GattStatus::Success { Loading @@ -1119,7 +1119,7 @@ impl Bluetooth { } } DelayedActions::BleDiscoveryScannerResult(result) => { AdapterActions::BleDiscoveryScannerResult(result) => { // Generate a vector of properties from ScanResult. let properties = { let mut props = vec![]; Loading Loading @@ -1164,11 +1164,11 @@ impl Bluetooth { )); } DelayedActions::ResetDiscoverable => { AdapterActions::ResetDiscoverable => { self.set_discoverable(BtDiscMode::NonDiscoverable, 0); } DelayedActions::CreateBond => { AdapterActions::CreateBond => { if let Some((device, transport)) = self.pending_create_bond.take() { let status = self.create_bond(device, transport); if status != BtStatus::Success { Loading Loading @@ -1335,9 +1335,7 @@ impl Bluetooth { let tx = self.tx.clone(); tokio::spawn(async move { let _ = tx .send(Message::DelayedAdapterActions(DelayedActions::ConnectProfiles( new_uuids, device, ))) .send(Message::AdapterActions(AdapterActions::ConnectProfiles(new_uuids, device))) .await; }); } Loading Loading @@ -1668,9 +1666,7 @@ impl BtifBluetoothCallbacks for Bluetooth { loop { time::sleep(FOUND_DEVICE_FRESHNESS).await; let _ = txl .send(Message::DelayedAdapterActions( DelayedActions::DeviceFreshnessCheck, )) .send(Message::AdapterActions(AdapterActions::DeviceFreshnessCheck)) .await; } })); Loading Loading @@ -1821,7 +1817,7 @@ impl BtifBluetoothCallbacks for Bluetooth { debug!("Invoking delayed CreateBond"); let tx = self.tx.clone(); tokio::spawn(async move { let _ = tx.send(Message::DelayedAdapterActions(DelayedActions::CreateBond)).await; let _ = tx.send(Message::AdapterActions(AdapterActions::CreateBond)).await; }); } } Loading Loading @@ -2173,9 +2169,9 @@ impl IScannerCallback for BleDiscoveryCallbacks { let tx = self.tx.clone(); tokio::spawn(async move { let _ = tx .send(Message::DelayedAdapterActions( DelayedActions::BleDiscoveryScannerRegistered(uuid, scanner_id, status), )) .send(Message::AdapterActions(AdapterActions::BleDiscoveryScannerRegistered( uuid, scanner_id, status, ))) .await; }); } Loading @@ -2184,7 +2180,7 @@ impl IScannerCallback for BleDiscoveryCallbacks { let tx = self.tx.clone(); tokio::spawn(async move { let _ = tx .send(Message::DelayedAdapterActions(DelayedActions::BleDiscoveryScannerResult( .send(Message::AdapterActions(AdapterActions::BleDiscoveryScannerResult( scan_result, ))) .await; Loading Loading @@ -2339,9 +2335,7 @@ impl IBluetooth for Bluetooth { let txl = self.tx.clone(); self.discoverable_timeout = Some(tokio::spawn(async move { time::sleep(Duration::from_secs(duration.into())).await; let _ = txl .send(Message::DelayedAdapterActions(DelayedActions::ResetDiscoverable)) .await; let _ = txl.send(Message::AdapterActions(AdapterActions::ResetDiscoverable)).await; })); } Loading
system/gd/rust/linux/stack/src/lib.rs +5 −6 Original line number Diff line number Diff line Loading @@ -31,8 +31,8 @@ use crate::battery_manager::{BatteryManager, BatterySet}; use crate::battery_provider_manager::BatteryProviderManager; use crate::battery_service::{BatteryService, BatteryServiceActions}; use crate::bluetooth::{ dispatch_base_callbacks, dispatch_hid_host_callbacks, dispatch_sdp_callbacks, Bluetooth, BluetoothDevice, DelayedActions, IBluetooth, dispatch_base_callbacks, dispatch_hid_host_callbacks, dispatch_sdp_callbacks, AdapterActions, Bluetooth, BluetoothDevice, IBluetooth, }; use crate::bluetooth_admin::{AdminActions, BluetoothAdmin, IBluetoothAdmin}; use crate::bluetooth_adv::{dispatch_le_adv_callbacks, AdvertiserActions}; Loading Loading @@ -105,8 +105,7 @@ pub enum Message { AdapterCallbackDisconnected(u32), ConnectionCallbackDisconnected(u32), // Some delayed actions for the adapter. DelayedAdapterActions(DelayedActions), AdapterActions(AdapterActions), // Follows IBluetooth's on_device_(dis)connected and bond_state callbacks // but doesn't require depending on Bluetooth. Loading Loading @@ -429,8 +428,8 @@ impl Stack { bluetooth.lock().unwrap().connection_callback_disconnected(id); } Message::DelayedAdapterActions(action) => { bluetooth.lock().unwrap().handle_delayed_actions(action); Message::AdapterActions(action) => { bluetooth.lock().unwrap().handle_actions(action); } // Any service needing an updated list of devices can have an Loading
system/gd/rust/linux/stack/src/suspend.rs +2 −4 Original line number Diff line number Diff line //! Suspend/Resume API. use crate::bluetooth::{Bluetooth, BluetoothDevice, BtifBluetoothCallbacks, DelayedActions}; use crate::bluetooth::{AdapterActions, Bluetooth, BluetoothDevice, BtifBluetoothCallbacks}; use crate::bluetooth_media::BluetoothMedia; use crate::callbacks::Callbacks; use crate::{BluetoothGatt, Message, RPCProxy}; Loading Loading @@ -337,9 +337,7 @@ impl ISuspend for Suspend { // Queue up connections. for device in reconnect_list { let _unused: Option<()> = txl .send(Message::DelayedAdapterActions(DelayedActions::ConnectAllProfiles( device, ))) .send(Message::AdapterActions(AdapterActions::ConnectAllProfiles(device))) .await .ok(); } Loading