Loading system/gd/rust/linux/stack/src/bluetooth_media.rs +15 −9 Original line number Diff line number Diff line Loading @@ -73,6 +73,9 @@ pub trait IBluetoothMedia { /// connect to available but missing media profiles fn connect(&mut self, address: String); /// disconnect all profiles from the device /// NOTE: do not call this function from outside unless `is_complete_profiles_required` fn disconnect(&mut self, address: String); // Set the device as the active A2DP device Loading Loading @@ -372,6 +375,7 @@ impl BluetoothMedia { self.delay_volume_update.remove(&profile); if is_profile_critical && self.is_complete_profiles_required() { BluetoothMedia::disconnect_device(self.tx.clone(), addr); self.notify_critical_profile_disconnected(addr); } Loading Loading @@ -480,9 +484,6 @@ impl BluetoothMedia { self.a2dp_caps.remove(&addr); self.a2dp_audio_state.remove(&addr); self.rm_connected_profile(addr, uuid::Profile::A2dpSink, true); if self.is_complete_profiles_required() { self.disconnect(addr.to_string()); } } _ => { self.a2dp_states.insert(addr, state); Loading @@ -500,6 +501,13 @@ impl BluetoothMedia { } } fn disconnect_device(txl: Sender<Message>, addr: RawAddress) { let device = BluetoothDevice::new(addr.to_string(), "".to_string()); topstack::get_runtime().spawn(async move { let _ = txl.send(Message::DisconnectDevice(device)).await; }); } pub fn dispatch_avrcp_callbacks(&mut self, cb: AvrcpCallbacks) { match cb { AvrcpCallbacks::AvrcpDeviceConnected(addr, supported) => { Loading Loading @@ -681,9 +689,6 @@ impl BluetoothMedia { self.hfp_cap.remove(&addr); self.hfp_audio_state.remove(&addr); self.rm_connected_profile(addr, uuid::Profile::Hfp, true); if self.is_complete_profiles_required() { self.disconnect(addr.to_string()); } } BthfConnectionState::Connecting => { info!("[{}]: hfp connecting.", DisplayAddress(&addr)); Loading Loading @@ -1929,9 +1934,9 @@ impl IBluetoothMedia for BluetoothMedia { true } // TODO(b/278963515): Currently this is designed to be called from both the // UI and via disconnection callbacks. Remove this workaround once the // proper fix has landed. // This may not disconnect all media profiles at once, but once the stack // is notified of the disconnection callback, `disconnect_device` will be // invoked as necessary to ensure the device is removed. fn disconnect(&mut self, address: String) { let addr = match RawAddress::from_string(address.clone()) { None => { Loading @@ -1957,6 +1962,7 @@ impl IBluetoothMedia for BluetoothMedia { uuid::Profile::A2dpSink => { // Some headsets (b/278963515) will try reconnecting to A2DP // when HFP is running but (requested to be) disconnected. // TODO: Remove this workaround once proper fix lands. if connected_profiles.contains(&Profile::Hfp) { continue; } Loading system/gd/rust/linux/stack/src/lib.rs +6 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,9 @@ pub enum Message { // Dis callbacks Dis(ServiceCallbacks), // Device removal DisconnectDevice(BluetoothDevice), // Qualification Only QaCallbackDisconnected(u32), QaAddMediaPlayer(String, bool), Loading Loading @@ -367,6 +370,9 @@ impl Stack { Message::Dis(callback) => { bluetooth_dis.lock().unwrap().handle_callbacks(&callback); } Message::DisconnectDevice(addr) => { bluetooth.lock().unwrap().disconnect_all_enabled_profiles(addr); } // Qualification Only Message::QaAddMediaPlayer(name, browsing_supported) => { bluetooth_media.lock().unwrap().add_player(name, browsing_supported); Loading Loading
system/gd/rust/linux/stack/src/bluetooth_media.rs +15 −9 Original line number Diff line number Diff line Loading @@ -73,6 +73,9 @@ pub trait IBluetoothMedia { /// connect to available but missing media profiles fn connect(&mut self, address: String); /// disconnect all profiles from the device /// NOTE: do not call this function from outside unless `is_complete_profiles_required` fn disconnect(&mut self, address: String); // Set the device as the active A2DP device Loading Loading @@ -372,6 +375,7 @@ impl BluetoothMedia { self.delay_volume_update.remove(&profile); if is_profile_critical && self.is_complete_profiles_required() { BluetoothMedia::disconnect_device(self.tx.clone(), addr); self.notify_critical_profile_disconnected(addr); } Loading Loading @@ -480,9 +484,6 @@ impl BluetoothMedia { self.a2dp_caps.remove(&addr); self.a2dp_audio_state.remove(&addr); self.rm_connected_profile(addr, uuid::Profile::A2dpSink, true); if self.is_complete_profiles_required() { self.disconnect(addr.to_string()); } } _ => { self.a2dp_states.insert(addr, state); Loading @@ -500,6 +501,13 @@ impl BluetoothMedia { } } fn disconnect_device(txl: Sender<Message>, addr: RawAddress) { let device = BluetoothDevice::new(addr.to_string(), "".to_string()); topstack::get_runtime().spawn(async move { let _ = txl.send(Message::DisconnectDevice(device)).await; }); } pub fn dispatch_avrcp_callbacks(&mut self, cb: AvrcpCallbacks) { match cb { AvrcpCallbacks::AvrcpDeviceConnected(addr, supported) => { Loading Loading @@ -681,9 +689,6 @@ impl BluetoothMedia { self.hfp_cap.remove(&addr); self.hfp_audio_state.remove(&addr); self.rm_connected_profile(addr, uuid::Profile::Hfp, true); if self.is_complete_profiles_required() { self.disconnect(addr.to_string()); } } BthfConnectionState::Connecting => { info!("[{}]: hfp connecting.", DisplayAddress(&addr)); Loading Loading @@ -1929,9 +1934,9 @@ impl IBluetoothMedia for BluetoothMedia { true } // TODO(b/278963515): Currently this is designed to be called from both the // UI and via disconnection callbacks. Remove this workaround once the // proper fix has landed. // This may not disconnect all media profiles at once, but once the stack // is notified of the disconnection callback, `disconnect_device` will be // invoked as necessary to ensure the device is removed. fn disconnect(&mut self, address: String) { let addr = match RawAddress::from_string(address.clone()) { None => { Loading @@ -1957,6 +1962,7 @@ impl IBluetoothMedia for BluetoothMedia { uuid::Profile::A2dpSink => { // Some headsets (b/278963515) will try reconnecting to A2DP // when HFP is running but (requested to be) disconnected. // TODO: Remove this workaround once proper fix lands. if connected_profiles.contains(&Profile::Hfp) { continue; } Loading
system/gd/rust/linux/stack/src/lib.rs +6 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,9 @@ pub enum Message { // Dis callbacks Dis(ServiceCallbacks), // Device removal DisconnectDevice(BluetoothDevice), // Qualification Only QaCallbackDisconnected(u32), QaAddMediaPlayer(String, bool), Loading Loading @@ -367,6 +370,9 @@ impl Stack { Message::Dis(callback) => { bluetooth_dis.lock().unwrap().handle_callbacks(&callback); } Message::DisconnectDevice(addr) => { bluetooth.lock().unwrap().disconnect_all_enabled_profiles(addr); } // Qualification Only Message::QaAddMediaPlayer(name, browsing_supported) => { bluetooth_media.lock().unwrap().add_player(name, browsing_supported); Loading