Loading system/gd/rust/linux/client/src/command_handler.rs +9 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ use crate::{console_red, console_yellow, print_error, print_info}; use bt_topshim::btif::BtTransport; use btstack::bluetooth::{BluetoothDevice, IBluetooth}; use btstack::bluetooth_gatt::IBluetoothGatt; use btstack::uuid::UuidHelper; use btstack::uuid::{Profile, UuidHelper}; use manager_service::iface_bluetooth_manager::IBluetoothManager; const INDENT_CHAR: &str = " "; Loading Loading @@ -273,6 +273,13 @@ impl CommandHandler { let cod = adapter_dbus.get_bluetooth_class(); let multi_adv_supported = adapter_dbus.is_multi_advertisement_supported(); let le_ext_adv_supported = adapter_dbus.is_le_extended_advertising_supported(); let uuid_helper = UuidHelper::new(); let enabled_profiles = uuid_helper.get_enabled_profiles(); let connected_profiles: Vec<Profile> = enabled_profiles .iter() .filter(|&&prof| adapter_dbus.get_profile_connection_state(prof) > 0) .cloned() .collect(); print_info!("Address: {}", address); print_info!("Name: {}", name); print_info!("State: {}", if enabled { "enabled" } else { "disabled" }); Loading @@ -281,6 +288,7 @@ impl CommandHandler { print_info!("Class: {:#06x}", cod); print_info!("IsMultiAdvertisementSupported: {}", multi_adv_supported); print_info!("IsLeExtendedAdvertisingSupported: {}", le_ext_adv_supported); print_info!("Connected profiles: {:?}", connected_profiles); print_info!( "Uuids: {}", DisplayList( Loading system/gd/rust/linux/client/src/dbus_iface.rs +7 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ use btstack::bluetooth_gatt::{ IScannerCallback, LePhy, ScanFilter, ScanSettings, }; use btstack::uuid::Profile; use dbus::arg::{AppendAll, RefArg}; use dbus::nonblock::SyncConnection; Loading Loading @@ -42,6 +43,7 @@ impl_dbus_arg_enum!(GattStatus); impl_dbus_arg_enum!(GattWriteType); impl_dbus_arg_enum!(LePhy); impl_dbus_arg_enum!(GattWriteRequestStatus); impl_dbus_arg_enum!(Profile); // Represents Uuid128Bit as an array in D-Bus. impl DBusArg for Uuid128Bit { Loading Loading @@ -386,6 +388,11 @@ impl IBluetooth for BluetoothDBus { dbus_generated!() } #[dbus_method("GetProfileConnectionState")] fn get_profile_connection_state(&self, profile: Profile) -> u32 { dbus_generated!() } #[dbus_method("GetRemoteUuids")] fn get_remote_uuids(&self, device: BluetoothDevice) -> Vec<Uuid128Bit> { dbus_generated!() Loading system/gd/rust/linux/service/src/iface_bluetooth.rs +7 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ use bt_topshim::btif::{BtSspVariant, BtTransport, Uuid128Bit}; use btstack::bluetooth::{ BluetoothDevice, IBluetooth, IBluetoothCallback, IBluetoothConnectionCallback, }; use btstack::uuid::Profile; use btstack::RPCProxy; use dbus::arg::RefArg; Loading Loading @@ -64,6 +65,7 @@ impl IBluetoothCallback for BluetoothCallbackDBus { impl_dbus_arg_enum!(BtTransport); impl_dbus_arg_enum!(BtSspVariant); impl_dbus_arg_enum!(Profile); #[allow(dead_code)] struct BluetoothConnectionCallbackDBus {} Loading Loading @@ -235,6 +237,11 @@ impl IBluetooth for IBluetoothDBus { dbus_generated!() } #[dbus_method("GetProfileConnectionState")] fn get_profile_connection_state(&self, _profile: Profile) -> u32 { dbus_generated!() } #[dbus_method("GetRemoteUuids")] fn get_remote_uuids(&self, _device: BluetoothDevice) -> Vec<Uuid128Bit> { dbus_generated!() Loading system/gd/rust/linux/stack/src/bluetooth.rs +16 −0 Original line number Diff line number Diff line Loading @@ -125,6 +125,9 @@ pub trait IBluetooth { /// Gets the connection state of a single device. fn get_connection_state(&self, device: BluetoothDevice) -> u32; /// Gets the connection state of a specific profile. fn get_profile_connection_state(&self, profile: Profile) -> u32; /// Returns the cached UUIDs of a remote device. fn get_remote_uuids(&self, device: BluetoothDevice) -> Vec<Uuid128Bit>; Loading Loading @@ -1086,6 +1089,19 @@ impl IBluetooth for Bluetooth { self.intf.lock().unwrap().get_connection_state(&addr.unwrap()) } fn get_profile_connection_state(&self, profile: Profile) -> u32 { match profile { Profile::A2dpSink | Profile::A2dpSource => { self.bluetooth_media.lock().unwrap().get_a2dp_connection_state() } Profile::Hfp | Profile::HfpAg => { self.bluetooth_media.lock().unwrap().get_hfp_connection_state() } // TODO: (b/223431229) Profile::Hid and Profile::Hogp _ => 0, } } fn get_remote_uuids(&self, device: BluetoothDevice) -> Vec<Uuid128Bit> { match self.get_remote_device_property(&device, &BtPropertyType::Uuids) { Some(BluetoothProperty::Uuids(uuids)) => { Loading system/gd/rust/linux/stack/src/bluetooth_media.rs +15 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ use bt_topshim::profiles::hfp::{ use bt_topshim::topstack; use log::{info, warn}; use num_traits::cast::ToPrimitive; use std::collections::HashMap; use std::convert::TryFrom; use std::sync::Arc; Loading Loading @@ -253,6 +253,20 @@ impl BluetoothMedia { f(&callback.1); } } pub fn get_hfp_connection_state(&self) -> u32 { for state in self.hfp_states.values() { return BthfConnectionState::to_u32(state).unwrap_or(0); } 0 } pub fn get_a2dp_connection_state(&self) -> u32 { for state in self.a2dp_states.values() { return BtavConnectionState::to_u32(state).unwrap_or(0); } 0 } } fn get_a2dp_dispatcher(tx: Sender<Message>) -> A2dpCallbacksDispatcher { Loading Loading
system/gd/rust/linux/client/src/command_handler.rs +9 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ use crate::{console_red, console_yellow, print_error, print_info}; use bt_topshim::btif::BtTransport; use btstack::bluetooth::{BluetoothDevice, IBluetooth}; use btstack::bluetooth_gatt::IBluetoothGatt; use btstack::uuid::UuidHelper; use btstack::uuid::{Profile, UuidHelper}; use manager_service::iface_bluetooth_manager::IBluetoothManager; const INDENT_CHAR: &str = " "; Loading Loading @@ -273,6 +273,13 @@ impl CommandHandler { let cod = adapter_dbus.get_bluetooth_class(); let multi_adv_supported = adapter_dbus.is_multi_advertisement_supported(); let le_ext_adv_supported = adapter_dbus.is_le_extended_advertising_supported(); let uuid_helper = UuidHelper::new(); let enabled_profiles = uuid_helper.get_enabled_profiles(); let connected_profiles: Vec<Profile> = enabled_profiles .iter() .filter(|&&prof| adapter_dbus.get_profile_connection_state(prof) > 0) .cloned() .collect(); print_info!("Address: {}", address); print_info!("Name: {}", name); print_info!("State: {}", if enabled { "enabled" } else { "disabled" }); Loading @@ -281,6 +288,7 @@ impl CommandHandler { print_info!("Class: {:#06x}", cod); print_info!("IsMultiAdvertisementSupported: {}", multi_adv_supported); print_info!("IsLeExtendedAdvertisingSupported: {}", le_ext_adv_supported); print_info!("Connected profiles: {:?}", connected_profiles); print_info!( "Uuids: {}", DisplayList( Loading
system/gd/rust/linux/client/src/dbus_iface.rs +7 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ use btstack::bluetooth_gatt::{ IScannerCallback, LePhy, ScanFilter, ScanSettings, }; use btstack::uuid::Profile; use dbus::arg::{AppendAll, RefArg}; use dbus::nonblock::SyncConnection; Loading Loading @@ -42,6 +43,7 @@ impl_dbus_arg_enum!(GattStatus); impl_dbus_arg_enum!(GattWriteType); impl_dbus_arg_enum!(LePhy); impl_dbus_arg_enum!(GattWriteRequestStatus); impl_dbus_arg_enum!(Profile); // Represents Uuid128Bit as an array in D-Bus. impl DBusArg for Uuid128Bit { Loading Loading @@ -386,6 +388,11 @@ impl IBluetooth for BluetoothDBus { dbus_generated!() } #[dbus_method("GetProfileConnectionState")] fn get_profile_connection_state(&self, profile: Profile) -> u32 { dbus_generated!() } #[dbus_method("GetRemoteUuids")] fn get_remote_uuids(&self, device: BluetoothDevice) -> Vec<Uuid128Bit> { dbus_generated!() Loading
system/gd/rust/linux/service/src/iface_bluetooth.rs +7 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ use bt_topshim::btif::{BtSspVariant, BtTransport, Uuid128Bit}; use btstack::bluetooth::{ BluetoothDevice, IBluetooth, IBluetoothCallback, IBluetoothConnectionCallback, }; use btstack::uuid::Profile; use btstack::RPCProxy; use dbus::arg::RefArg; Loading Loading @@ -64,6 +65,7 @@ impl IBluetoothCallback for BluetoothCallbackDBus { impl_dbus_arg_enum!(BtTransport); impl_dbus_arg_enum!(BtSspVariant); impl_dbus_arg_enum!(Profile); #[allow(dead_code)] struct BluetoothConnectionCallbackDBus {} Loading Loading @@ -235,6 +237,11 @@ impl IBluetooth for IBluetoothDBus { dbus_generated!() } #[dbus_method("GetProfileConnectionState")] fn get_profile_connection_state(&self, _profile: Profile) -> u32 { dbus_generated!() } #[dbus_method("GetRemoteUuids")] fn get_remote_uuids(&self, _device: BluetoothDevice) -> Vec<Uuid128Bit> { dbus_generated!() Loading
system/gd/rust/linux/stack/src/bluetooth.rs +16 −0 Original line number Diff line number Diff line Loading @@ -125,6 +125,9 @@ pub trait IBluetooth { /// Gets the connection state of a single device. fn get_connection_state(&self, device: BluetoothDevice) -> u32; /// Gets the connection state of a specific profile. fn get_profile_connection_state(&self, profile: Profile) -> u32; /// Returns the cached UUIDs of a remote device. fn get_remote_uuids(&self, device: BluetoothDevice) -> Vec<Uuid128Bit>; Loading Loading @@ -1086,6 +1089,19 @@ impl IBluetooth for Bluetooth { self.intf.lock().unwrap().get_connection_state(&addr.unwrap()) } fn get_profile_connection_state(&self, profile: Profile) -> u32 { match profile { Profile::A2dpSink | Profile::A2dpSource => { self.bluetooth_media.lock().unwrap().get_a2dp_connection_state() } Profile::Hfp | Profile::HfpAg => { self.bluetooth_media.lock().unwrap().get_hfp_connection_state() } // TODO: (b/223431229) Profile::Hid and Profile::Hogp _ => 0, } } fn get_remote_uuids(&self, device: BluetoothDevice) -> Vec<Uuid128Bit> { match self.get_remote_device_property(&device, &BtPropertyType::Uuids) { Some(BluetoothProperty::Uuids(uuids)) => { Loading
system/gd/rust/linux/stack/src/bluetooth_media.rs +15 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ use bt_topshim::profiles::hfp::{ use bt_topshim::topstack; use log::{info, warn}; use num_traits::cast::ToPrimitive; use std::collections::HashMap; use std::convert::TryFrom; use std::sync::Arc; Loading Loading @@ -253,6 +253,20 @@ impl BluetoothMedia { f(&callback.1); } } pub fn get_hfp_connection_state(&self) -> u32 { for state in self.hfp_states.values() { return BthfConnectionState::to_u32(state).unwrap_or(0); } 0 } pub fn get_a2dp_connection_state(&self) -> u32 { for state in self.a2dp_states.values() { return BtavConnectionState::to_u32(state).unwrap_or(0); } 0 } } fn get_a2dp_dispatcher(tx: Sender<Message>) -> A2dpCallbacksDispatcher { Loading