Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eddf4cfc authored by Yun-hao Chung's avatar Yun-hao Chung Committed by Automerger Merge Worker
Browse files

Merge "Floss: Wire remote address type to DBus" into main am: 6032dc61 am:...

Merge "Floss: Wire remote address type to DBus" into main am: 6032dc61 am: 7d3bd91d am: ef411854

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2765393



Change-Id: Iac5e43ef21c3dedeee0f7513ac03e2f7d69968a7
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents aafbd6fb ef411854
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -755,6 +755,7 @@ impl CommandHandler {
                    name,
                    name,
                    alias,
                    alias,
                    device_type,
                    device_type,
                    addr_type,
                    class,
                    class,
                    appearance,
                    appearance,
                    bonded,
                    bonded,
@@ -767,6 +768,7 @@ impl CommandHandler {


                    let name = adapter.get_remote_name(device.clone());
                    let name = adapter.get_remote_name(device.clone());
                    let device_type = adapter.get_remote_type(device.clone());
                    let device_type = adapter.get_remote_type(device.clone());
                    let addr_type = adapter.get_remote_address_type(device.clone());
                    let alias = adapter.get_remote_alias(device.clone());
                    let alias = adapter.get_remote_alias(device.clone());
                    let class = adapter.get_remote_class(device.clone());
                    let class = adapter.get_remote_class(device.clone());
                    let appearance = adapter.get_remote_appearance(device.clone());
                    let appearance = adapter.get_remote_appearance(device.clone());
@@ -783,6 +785,7 @@ impl CommandHandler {
                        name,
                        name,
                        alias,
                        alias,
                        device_type,
                        device_type,
                        addr_type,
                        class,
                        class,
                        appearance,
                        appearance,
                        bonded,
                        bonded,
@@ -795,7 +798,8 @@ impl CommandHandler {
                print_info!("Address: {}", &device.address);
                print_info!("Address: {}", &device.address);
                print_info!("Name: {}", name);
                print_info!("Name: {}", name);
                print_info!("Alias: {}", alias);
                print_info!("Alias: {}", alias);
                print_info!("Type: {:?}", device_type);
                print_info!("Device Type: {:?}", device_type);
                print_info!("Address Type: {:?}", addr_type);
                print_info!("Class: {}", class);
                print_info!("Class: {}", class);
                print_info!("Appearance: {}", appearance);
                print_info!("Appearance: {}", appearance);
                print_info!("Wake Allowed: {}", wake_allowed);
                print_info!("Wake Allowed: {}", wake_allowed);
+8 −2
Original line number Original line Diff line number Diff line
//! D-Bus proxy implementations of the APIs.
//! D-Bus proxy implementations of the APIs.


use bt_topshim::btif::{
use bt_topshim::btif::{
    BtBondState, BtConnectionState, BtDeviceType, BtDiscMode, BtPropertyType, BtSspVariant,
    BtAddrType, BtBondState, BtConnectionState, BtDeviceType, BtDiscMode, BtPropertyType,
    BtStatus, BtTransport, BtVendorProductInfo, Uuid, Uuid128Bit,
    BtSspVariant, BtStatus, BtTransport, BtVendorProductInfo, Uuid, Uuid128Bit,
};
};
use bt_topshim::profiles::a2dp::{
use bt_topshim::profiles::a2dp::{
    A2dpCodecBitsPerSample, A2dpCodecChannelMode, A2dpCodecConfig, A2dpCodecIndex,
    A2dpCodecBitsPerSample, A2dpCodecChannelMode, A2dpCodecConfig, A2dpCodecIndex,
@@ -78,6 +78,7 @@ impl_dbus_arg_enum!(AdvertisingStatus);
impl_dbus_arg_enum!(BtBondState);
impl_dbus_arg_enum!(BtBondState);
impl_dbus_arg_enum!(BtConnectionState);
impl_dbus_arg_enum!(BtConnectionState);
impl_dbus_arg_enum!(BtDeviceType);
impl_dbus_arg_enum!(BtDeviceType);
impl_dbus_arg_enum!(BtAddrType);
impl_dbus_arg_enum!(BtPropertyType);
impl_dbus_arg_enum!(BtPropertyType);
impl_dbus_arg_enum!(BtSspVariant);
impl_dbus_arg_enum!(BtSspVariant);
impl_dbus_arg_enum!(BtStatus);
impl_dbus_arg_enum!(BtStatus);
@@ -923,6 +924,11 @@ impl IBluetooth for BluetoothDBus {
        dbus_generated!()
        dbus_generated!()
    }
    }


    #[dbus_method("GetRemoteAddressType")]
    fn get_remote_address_type(&self, device: BluetoothDevice) -> BtAddrType {
        dbus_generated!()
    }

    #[dbus_method("GetConnectedDevices")]
    #[dbus_method("GetConnectedDevices")]
    fn get_connected_devices(&self) -> Vec<BluetoothDevice> {
    fn get_connected_devices(&self) -> Vec<BluetoothDevice> {
        dbus_generated!()
        dbus_generated!()
+8 −2
Original line number Original line Diff line number Diff line
use bt_topshim::btif::{
use bt_topshim::btif::{
    BtBondState, BtConnectionState, BtDeviceType, BtDiscMode, BtPropertyType, BtSspVariant,
    BtAddrType, BtBondState, BtConnectionState, BtDeviceType, BtDiscMode, BtPropertyType,
    BtStatus, BtTransport, BtVendorProductInfo, Uuid, Uuid128Bit,
    BtSspVariant, BtStatus, BtTransport, BtVendorProductInfo, Uuid, Uuid128Bit,
};
};
use bt_topshim::profiles::socket::SocketType;
use bt_topshim::profiles::socket::SocketType;
use bt_topshim::profiles::ProfileConnectionState;
use bt_topshim::profiles::ProfileConnectionState;
@@ -157,6 +157,7 @@ impl IBluetoothCallback for BluetoothCallbackDBus {
impl_dbus_arg_enum!(BtBondState);
impl_dbus_arg_enum!(BtBondState);
impl_dbus_arg_enum!(BtConnectionState);
impl_dbus_arg_enum!(BtConnectionState);
impl_dbus_arg_enum!(BtDeviceType);
impl_dbus_arg_enum!(BtDeviceType);
impl_dbus_arg_enum!(BtAddrType);
impl_dbus_arg_enum!(BtPropertyType);
impl_dbus_arg_enum!(BtPropertyType);
impl_dbus_arg_enum!(BtSspVariant);
impl_dbus_arg_enum!(BtSspVariant);
impl_dbus_arg_enum!(BtTransport);
impl_dbus_arg_enum!(BtTransport);
@@ -636,6 +637,11 @@ impl IBluetooth for IBluetoothDBus {
        dbus_generated!()
        dbus_generated!()
    }
    }


    #[dbus_method("GetRemoteAddressType", DBusLog::Disable)]
    fn get_remote_address_type(&self, device: BluetoothDevice) -> BtAddrType {
        dbus_generated!()
    }

    #[dbus_method("GetConnectedDevices", DBusLog::Disable)]
    #[dbus_method("GetConnectedDevices", DBusLog::Disable)]
    fn get_connected_devices(&self) -> Vec<BluetoothDevice> {
    fn get_connected_devices(&self) -> Vec<BluetoothDevice> {
        dbus_generated!()
        dbus_generated!()
+11 −1
Original line number Original line Diff line number Diff line
@@ -2,7 +2,7 @@


use bt_topshim::btif::{
use bt_topshim::btif::{
    BaseCallbacks, BaseCallbacksDispatcher, BluetoothInterface, BluetoothProperty, BtAclState,
    BaseCallbacks, BaseCallbacksDispatcher, BluetoothInterface, BluetoothProperty, BtAclState,
    BtBondState, BtConnectionDirection, BtConnectionState, BtDeviceType, BtDiscMode,
    BtAddrType, BtBondState, BtConnectionDirection, BtConnectionState, BtDeviceType, BtDiscMode,
    BtDiscoveryState, BtHciErrorCode, BtPinCode, BtPropertyType, BtScanMode, BtSspVariant, BtState,
    BtDiscoveryState, BtHciErrorCode, BtPinCode, BtPropertyType, BtScanMode, BtSspVariant, BtState,
    BtStatus, BtThreadEvent, BtTransport, BtVendorProductInfo, DisplayAddress, RawAddress,
    BtStatus, BtThreadEvent, BtTransport, BtVendorProductInfo, DisplayAddress, RawAddress,
    ToggleableProfile, Uuid, Uuid128Bit,
    ToggleableProfile, Uuid, Uuid128Bit,
@@ -194,6 +194,9 @@ pub trait IBluetooth {
    /// Gets the vendor and product information of the remote device.
    /// Gets the vendor and product information of the remote device.
    fn get_remote_vendor_product_info(&self, device: BluetoothDevice) -> BtVendorProductInfo;
    fn get_remote_vendor_product_info(&self, device: BluetoothDevice) -> BtVendorProductInfo;


    /// Get the address type of the remote device.
    fn get_remote_address_type(&self, device: BluetoothDevice) -> BtAddrType;

    /// Returns a list of connected devices.
    /// Returns a list of connected devices.
    fn get_connected_devices(&self) -> Vec<BluetoothDevice>;
    fn get_connected_devices(&self) -> Vec<BluetoothDevice>;


@@ -2371,6 +2374,13 @@ impl IBluetooth for Bluetooth {
        }
        }
    }
    }


    fn get_remote_address_type(&self, device: BluetoothDevice) -> BtAddrType {
        match self.get_remote_device_property(&device, &BtPropertyType::RemoteAddrType) {
            Some(BluetoothProperty::RemoteAddrType(addr_type)) => addr_type,
            _ => BtAddrType::Unknown,
        }
    }

    fn get_connected_devices(&self) -> Vec<BluetoothDevice> {
    fn get_connected_devices(&self) -> Vec<BluetoothDevice> {
        let bonded_connected: HashMap<String, BluetoothDevice> = self
        let bonded_connected: HashMap<String, BluetoothDevice> = self
            .bonded_devices
            .bonded_devices
+40 −1
Original line number Original line Diff line number Diff line
@@ -153,6 +153,12 @@ pub enum BtPropertyType {
    RemoteIsCoordinatedSetMember,
    RemoteIsCoordinatedSetMember,
    Appearance,
    Appearance,
    VendorProductInfo,
    VendorProductInfo,
    // Unimplemented:
    //  BT_PROPERTY_WL_MEDIA_PLAYERS_LIST,
    //  BT_PROPERTY_REMOTE_ASHA_CAPABILITY,
    //  BT_PROPERTY_REMOTE_ASHA_TRUNCATED_HISYNCID,
    //  BT_PROPERTY_REMOTE_MODEL_NUM,
    RemoteAddrType = 0x18,


    Unknown = 0xFE,
    Unknown = 0xFE,
    RemoteDeviceTimestamp = 0xFF,
    RemoteDeviceTimestamp = 0xFF,
@@ -361,6 +367,29 @@ impl From<bindings::bt_io_cap_t> for BtIoCap {
    }
    }
}
}


#[derive(Clone, Debug, FromPrimitive, ToPrimitive, PartialEq, PartialOrd)]
#[repr(u32)]
pub enum BtAddrType {
    Public,
    Random,
    PublicId,
    RandomId,
    Unknown = 0xfe,
    Anonymous = 0xff,
}

impl From<u32> for BtAddrType {
    fn from(num: u32) -> Self {
        BtAddrType::from_u32(num).unwrap_or(BtAddrType::Unknown)
    }
}

impl Into<u32> for BtAddrType {
    fn into(self) -> u32 {
        self.to_u32().unwrap_or(0)
    }
}

pub type BtHciErrorCode = u8;
pub type BtHciErrorCode = u8;
pub type BtLocalLeFeatures = bindings::bt_local_le_features_t;
pub type BtLocalLeFeatures = bindings::bt_local_le_features_t;
pub type BtPinCode = bindings::bt_pin_code_t;
pub type BtPinCode = bindings::bt_pin_code_t;
@@ -467,6 +496,7 @@ pub enum BluetoothProperty {
    RemoteIsCoordinatedSetMember(bool),
    RemoteIsCoordinatedSetMember(bool),
    Appearance(u16),
    Appearance(u16),
    VendorProductInfo(BtVendorProductInfo),
    VendorProductInfo(BtVendorProductInfo),
    RemoteAddrType(BtAddrType),
    RemoteDeviceTimestamp(),
    RemoteDeviceTimestamp(),


    Unknown(),
    Unknown(),
@@ -503,6 +533,7 @@ impl BluetoothProperty {
            BluetoothProperty::Appearance(_) => BtPropertyType::Appearance,
            BluetoothProperty::Appearance(_) => BtPropertyType::Appearance,
            BluetoothProperty::VendorProductInfo(_) => BtPropertyType::VendorProductInfo,
            BluetoothProperty::VendorProductInfo(_) => BtPropertyType::VendorProductInfo,
            BluetoothProperty::RemoteDeviceTimestamp() => BtPropertyType::RemoteDeviceTimestamp,
            BluetoothProperty::RemoteDeviceTimestamp() => BtPropertyType::RemoteDeviceTimestamp,
            BluetoothProperty::RemoteAddrType(_) => BtPropertyType::RemoteAddrType,
            BluetoothProperty::Unknown() => BtPropertyType::Unknown,
            BluetoothProperty::Unknown() => BtPropertyType::Unknown,
        }
        }
    }
    }
@@ -533,6 +564,7 @@ impl BluetoothProperty {
            BluetoothProperty::RemoteIsCoordinatedSetMember(_) => mem::size_of::<bool>(),
            BluetoothProperty::RemoteIsCoordinatedSetMember(_) => mem::size_of::<bool>(),
            BluetoothProperty::Appearance(_) => mem::size_of::<u16>(),
            BluetoothProperty::Appearance(_) => mem::size_of::<u16>(),
            BluetoothProperty::VendorProductInfo(_) => mem::size_of::<BtVendorProductInfo>(),
            BluetoothProperty::VendorProductInfo(_) => mem::size_of::<BtVendorProductInfo>(),
            BluetoothProperty::RemoteAddrType(_) => mem::size_of::<BtAddrType>(),


            // TODO(abps) - Figure out sizes for these
            // TODO(abps) - Figure out sizes for these
            BluetoothProperty::DynamicAudioBuffer() => 0,
            BluetoothProperty::DynamicAudioBuffer() => 0,
@@ -641,6 +673,11 @@ impl BluetoothProperty {
                };
                };
                data.copy_from_slice(&slice);
                data.copy_from_slice(&slice);
            }
            }
            BluetoothProperty::RemoteAddrType(addr_type) => {
                data.copy_from_slice(
                    &BtAddrType::to_u32(addr_type).unwrap_or_default().to_ne_bytes(),
                );
            }


            BluetoothProperty::DynamicAudioBuffer() => (),
            BluetoothProperty::DynamicAudioBuffer() => (),
            BluetoothProperty::RemoteDeviceTimestamp() => (),
            BluetoothProperty::RemoteDeviceTimestamp() => (),
@@ -717,7 +754,9 @@ impl From<bindings::bt_property_t> for BluetoothProperty {
                let v = unsafe { (prop.val as *const BtVendorProductInfo).read_unaligned() };
                let v = unsafe { (prop.val as *const BtVendorProductInfo).read_unaligned() };
                BluetoothProperty::VendorProductInfo(BtVendorProductInfo::from(v))
                BluetoothProperty::VendorProductInfo(BtVendorProductInfo::from(v))
            }
            }

            BtPropertyType::RemoteAddrType => BluetoothProperty::RemoteAddrType(
                BtAddrType::from_u32(u32_from_bytes(slice)).unwrap_or(BtAddrType::Unknown),
            ),
            // TODO(abps) - Figure out if these values should actually have contents
            // TODO(abps) - Figure out if these values should actually have contents
            BtPropertyType::DynamicAudioBuffer => BluetoothProperty::DynamicAudioBuffer(),
            BtPropertyType::DynamicAudioBuffer => BluetoothProperty::DynamicAudioBuffer(),
            BtPropertyType::RemoteDeviceTimestamp => BluetoothProperty::RemoteDeviceTimestamp(),
            BtPropertyType::RemoteDeviceTimestamp => BluetoothProperty::RemoteDeviceTimestamp(),