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

Commit 545cc3b0 authored by Hsin-chen Chuang's avatar Hsin-chen Chuang Committed by Gerrit Code Review
Browse files

Merge changes Iac9352b9,Iea9ae139 into main

* changes:
  floss: Log pretty UUID in DBus debugging log
  floss: Remove Uuid128Bit
parents 26e9c7e5 ce082498
Loading
Loading
Loading
Loading
+10 −14
Original line number Original line Diff line number Diff line
@@ -10,9 +10,7 @@ use crate::dbus_iface::{
};
};
use crate::{console_red, console_yellow, print_error, print_info};
use crate::{console_red, console_yellow, print_error, print_info};
use crate::{ClientContext, GattRequest};
use crate::{ClientContext, GattRequest};
use bt_topshim::btif::{
use bt_topshim::btif::{BtBondState, BtPropertyType, BtSspVariant, BtStatus, RawAddress, Uuid};
    BtBondState, BtPropertyType, BtSspVariant, BtStatus, RawAddress, Uuid128Bit,
};
use bt_topshim::profiles::gatt::{AdvertisingStatus, GattStatus, LePhy};
use bt_topshim::profiles::gatt::{AdvertisingStatus, GattStatus, LePhy};
use bt_topshim::profiles::hfp::HfpCodecId;
use bt_topshim::profiles::hfp::HfpCodecId;
use bt_topshim::profiles::le_audio::{
use bt_topshim::profiles::le_audio::{
@@ -39,7 +37,6 @@ use btstack::socket_manager::{
    IBluetoothSocketManagerCallbacks, SocketId,
    IBluetoothSocketManagerCallbacks, SocketId,
};
};
use btstack::suspend::ISuspendCallback;
use btstack::suspend::ISuspendCallback;
use btstack::uuid::UuidWrapper;
use btstack::{RPCProxy, SuspendMode};
use btstack::{RPCProxy, SuspendMode};
use chrono::{TimeZone, Utc};
use chrono::{TimeZone, Utc};
use dbus::nonblock::SyncConnection;
use dbus::nonblock::SyncConnection;
@@ -304,14 +301,14 @@ impl IBluetoothCallback for BtCallback {
    fn on_sdp_search_complete(
    fn on_sdp_search_complete(
        &mut self,
        &mut self,
        remote_device: BluetoothDevice,
        remote_device: BluetoothDevice,
        searched_uuid: Uuid128Bit,
        searched_uuid: Uuid,
        sdp_records: Vec<BtSdpRecord>,
        sdp_records: Vec<BtSdpRecord>,
    ) {
    ) {
        print_info!(
        print_info!(
            "SDP search of [{}: {:?}] for UUID {} returned {} results",
            "SDP search of [{}: {:?}] for UUID {} returned {} results",
            remote_device.address.to_string(),
            remote_device.address.to_string(),
            remote_device.name,
            remote_device.name,
            UuidWrapper(&searched_uuid),
            searched_uuid,
            sdp_records.len()
            sdp_records.len()
        );
        );
        if !sdp_records.is_empty() {
        if !sdp_records.is_empty() {
@@ -419,17 +416,13 @@ impl ScannerCallback {
}
}


impl IScannerCallback for ScannerCallback {
impl IScannerCallback for ScannerCallback {
    fn on_scanner_registered(&mut self, uuid: Uuid128Bit, scanner_id: u8, status: GattStatus) {
    fn on_scanner_registered(&mut self, uuid: Uuid, scanner_id: u8, status: GattStatus) {
        if status != GattStatus::Success {
        if status != GattStatus::Success {
            print_error!("Failed registering scanner, status = {}", status);
            print_error!("Failed registering scanner, status = {}", status);
            return;
            return;
        }
        }


        print_info!(
        print_info!("Scanner callback registered, uuid = {}, id = {}", uuid, scanner_id);
            "Scanner callback registered, uuid = {}, id = {}",
            UuidWrapper(&uuid),
            scanner_id
        );
    }
    }


    fn on_scan_result(&mut self, scan_result: ScanResult) {
    fn on_scan_result(&mut self, scan_result: ScanResult) {
@@ -491,8 +484,11 @@ impl AdminCallback {
}
}


impl IBluetoothAdminPolicyCallback for AdminCallback {
impl IBluetoothAdminPolicyCallback for AdminCallback {
    fn on_service_allowlist_changed(&mut self, allowlist: Vec<Uuid128Bit>) {
    fn on_service_allowlist_changed(&mut self, allowlist: Vec<Uuid>) {
        print_info!("new allowlist: {:?}", allowlist);
        print_info!(
            "new allowlist: [{}]",
            allowlist.into_iter().map(|uu| uu.to_string()).collect::<Vec<String>>().join(", ")
        );
    }
    }


    fn on_device_policy_effect_changed(
    fn on_device_policy_effect_changed(
+18 −26
Original line number Original line Diff line number Diff line
@@ -25,7 +25,7 @@ use btstack::bluetooth_gatt::{
use btstack::bluetooth_media::{IBluetoothMedia, IBluetoothTelephony};
use btstack::bluetooth_media::{IBluetoothMedia, IBluetoothTelephony};
use btstack::bluetooth_qa::IBluetoothQA;
use btstack::bluetooth_qa::IBluetoothQA;
use btstack::socket_manager::{IBluetoothSocketManager, SocketResult};
use btstack::socket_manager::{IBluetoothSocketManager, SocketResult};
use btstack::uuid::{Profile, UuidHelper, UuidWrapper};
use btstack::uuid::{Profile, UuidHelper};
use manager_service::iface_bluetooth_manager::IBluetoothManager;
use manager_service::iface_bluetooth_manager::IBluetoothManager;


const INDENT_CHAR: &str = " ";
const INDENT_CHAR: &str = " ";
@@ -552,8 +552,8 @@ impl CommandHandler {
                let connected_profiles: Vec<(Profile, ProfileConnectionState)> = supported_profiles
                let connected_profiles: Vec<(Profile, ProfileConnectionState)> = supported_profiles
                    .iter()
                    .iter()
                    .map(|&prof| {
                    .map(|&prof| {
                        if let Some(uuid) = UuidHelper::get_profile_uuid(&prof) {
                        if let Some(&uuid) = UuidHelper::get_profile_uuid(&prof) {
                            (prof, adapter_dbus.get_profile_connection_state(uuid.clone()))
                            (prof, adapter_dbus.get_profile_connection_state(uuid))
                        } else {
                        } else {
                            (prof, ProfileConnectionState::Disconnected)
                            (prof, ProfileConnectionState::Disconnected)
                        }
                        }
@@ -1383,15 +1383,14 @@ impl CommandHandler {
                }
                }
            }
            }
            "server-add-basic-service" => {
            "server-add-basic-service" => {
                let service_uuid =
                let service_uuid = Uuid::from_string(BATTERY_SERVICE_UUID).unwrap();
                    Uuid::from(UuidHelper::from_string(BATTERY_SERVICE_UUID).unwrap());


                let server_id = String::from(get_arg(args, 1)?)
                let server_id = String::from(get_arg(args, 1)?)
                    .parse::<i32>()
                    .parse::<i32>()
                    .or(Err("Failed to parse server_id"))?;
                    .or(Err("Failed to parse server_id"))?;


                let service = BluetoothGattService::new(
                let service = BluetoothGattService::new(
                    service_uuid.into(),
                    service_uuid,
                    0, // libbluetooth assigns this handle once the service is added
                    0, // libbluetooth assigns this handle once the service is added
                    GattDbElementType::PrimaryService.into(),
                    GattDbElementType::PrimaryService.into(),
                );
                );
@@ -1399,15 +1398,11 @@ impl CommandHandler {
                self.lock_context().gatt_dbus.as_mut().unwrap().add_service(server_id, service);
                self.lock_context().gatt_dbus.as_mut().unwrap().add_service(server_id, service);
            }
            }
            "server-add-service" => {
            "server-add-service" => {
                let service_uuid =
                let service_uuid = Uuid::from_string(HEART_RATE_SERVICE_UUID).unwrap();
                    Uuid::from(UuidHelper::from_string(HEART_RATE_SERVICE_UUID).unwrap());
                let characteristic_uuid = Uuid::from_string(HEART_RATE_MEASUREMENT_UUID).unwrap();
                let characteristic_uuid =
                let descriptor_uuid = Uuid::from_string(GENERIC_UUID).unwrap();
                    Uuid::from(UuidHelper::from_string(HEART_RATE_MEASUREMENT_UUID).unwrap());
                let ccc_descriptor_uuid = Uuid::from_string(CCC_DESCRIPTOR_UUID).unwrap();
                let descriptor_uuid = Uuid::from(UuidHelper::from_string(GENERIC_UUID).unwrap());
                let included_service_uuid = Uuid::from_string(BATTERY_SERVICE_UUID).unwrap();
                let ccc_descriptor_uuid =
                    Uuid::from(UuidHelper::from_string(CCC_DESCRIPTOR_UUID).unwrap());
                let included_service_uuid =
                    Uuid::from(UuidHelper::from_string(BATTERY_SERVICE_UUID).unwrap());


                let server_id = String::from(get_arg(args, 1)?)
                let server_id = String::from(get_arg(args, 1)?)
                    .parse::<i32>()
                    .parse::<i32>()
@@ -1418,17 +1413,17 @@ impl CommandHandler {
                        .or(Err("Failed to parse included service instance id"))?;
                        .or(Err("Failed to parse included service instance id"))?;


                let mut service = BluetoothGattService::new(
                let mut service = BluetoothGattService::new(
                    service_uuid.into(),
                    service_uuid,
                    0,
                    0,
                    GattDbElementType::PrimaryService.into(),
                    GattDbElementType::PrimaryService.into(),
                );
                );
                let included_service = BluetoothGattService::new(
                let included_service = BluetoothGattService::new(
                    included_service_uuid.into(),
                    included_service_uuid,
                    included_service_instance_id,
                    included_service_instance_id,
                    GattDbElementType::IncludedService.into(),
                    GattDbElementType::IncludedService.into(),
                );
                );
                let mut characteristic = BluetoothGattCharacteristic::new(
                let mut characteristic = BluetoothGattCharacteristic::new(
                    characteristic_uuid.into(),
                    characteristic_uuid,
                    0,
                    0,
                    BluetoothGattCharacteristic::PROPERTY_READ
                    BluetoothGattCharacteristic::PROPERTY_READ
                        | BluetoothGattCharacteristic::PROPERTY_WRITE
                        | BluetoothGattCharacteristic::PROPERTY_WRITE
@@ -1437,13 +1432,13 @@ impl CommandHandler {
                        | BluetoothGattCharacteristic::PERMISSION_WRITE,
                        | BluetoothGattCharacteristic::PERMISSION_WRITE,
                );
                );
                let descriptor = BluetoothGattDescriptor::new(
                let descriptor = BluetoothGattDescriptor::new(
                    descriptor_uuid.into(),
                    descriptor_uuid,
                    0,
                    0,
                    BluetoothGattCharacteristic::PERMISSION_READ
                    BluetoothGattCharacteristic::PERMISSION_READ
                        | BluetoothGattCharacteristic::PERMISSION_WRITE,
                        | BluetoothGattCharacteristic::PERMISSION_WRITE,
                );
                );
                let ccc_descriptor = BluetoothGattDescriptor::new(
                let ccc_descriptor = BluetoothGattDescriptor::new(
                    ccc_descriptor_uuid.into(),
                    ccc_descriptor_uuid,
                    0,
                    0,
                    BluetoothGattCharacteristic::PERMISSION_READ
                    BluetoothGattCharacteristic::PERMISSION_READ
                        | BluetoothGattCharacteristic::PERMISSION_WRITE,
                        | BluetoothGattCharacteristic::PERMISSION_WRITE,
@@ -1545,7 +1540,7 @@ impl CommandHandler {
                    .unwrap()
                    .unwrap()
                    .register_scanner(scanner_callback_id);
                    .register_scanner(scanner_callback_id);


                print_info!("Scanner to be registered with UUID = {}", UuidWrapper(&uuid));
                print_info!("Scanner to be registered with UUID = {}", uuid);
            }
            }
            "unregister-scanner" => {
            "unregister-scanner" => {
                let scanner_id = String::from(get_arg(args, 1)?)
                let scanner_id = String::from(get_arg(args, 1)?)
@@ -1739,10 +1734,7 @@ impl CommandHandler {
                    address: RawAddress::from_string(get_arg(args, 1)?).ok_or("Invalid Address")?,
                    address: RawAddress::from_string(get_arg(args, 1)?).ok_or("Invalid Address")?,
                    name: String::from(""),
                    name: String::from(""),
                };
                };
                let uuid = match UuidHelper::parse_string(get_arg(args, 2)?) {
                let uuid = Uuid::from_string(get_arg(args, 2)?).ok_or("Invalid UUID")?;
                    Some(uu) => uu.uu,
                    None => return Err(CommandError::Failed("Invalid UUID".into())),
                };
                let success =
                let success =
                    self.lock_context().adapter_dbus.as_ref().unwrap().sdp_search(device, uuid);
                    self.lock_context().adapter_dbus.as_ref().unwrap().sdp_search(device, uuid);
                if !success {
                if !success {
@@ -1910,7 +1902,7 @@ impl CommandHandler {
                            }
                            }
                        }
                        }
                        "rfcomm" => {
                        "rfcomm" => {
                            let uuid = match UuidHelper::parse_string(*psm_or_uuid) {
                            let uuid = match Uuid::from_string(*psm_or_uuid) {
                                Some(uu) => uu,
                                Some(uu) => uu,
                                None => {
                                None => {
                                    return Err(CommandError::Failed(format!(
                                    return Err(CommandError::Failed(format!(
+16 −51
Original line number Original line Diff line number Diff line
@@ -3,7 +3,6 @@
use bt_topshim::btif::{
use bt_topshim::btif::{
    BtAddrType, BtBondState, BtConnectionState, BtDeviceType, BtDiscMode, BtPropertyType,
    BtAddrType, BtBondState, BtConnectionState, BtDeviceType, BtDiscMode, BtPropertyType,
    BtSspVariant, BtStatus, BtTransport, BtVendorProductInfo, DisplayAddress, RawAddress, Uuid,
    BtSspVariant, BtStatus, BtTransport, BtVendorProductInfo, DisplayAddress, RawAddress, Uuid,
    Uuid128Bit,
};
};
use bt_topshim::profiles::a2dp::{
use bt_topshim::profiles::a2dp::{
    A2dpCodecBitsPerSample, A2dpCodecChannelMode, A2dpCodecConfig, A2dpCodecIndex,
    A2dpCodecBitsPerSample, A2dpCodecChannelMode, A2dpCodecConfig, A2dpCodecIndex,
@@ -113,40 +112,6 @@ impl_dbus_arg_from_into!(Uuid, Vec<u8>);
impl_dbus_arg_enum!(BthhReportType);
impl_dbus_arg_enum!(BthhReportType);
impl_dbus_arg_enum!(BtAdapterRole);
impl_dbus_arg_enum!(BtAdapterRole);


impl RefArgToRust for Uuid {
    type RustType = Vec<u8>;

    fn ref_arg_to_rust(
        arg: &(dyn dbus::arg::RefArg + 'static),
        name: String,
    ) -> Result<Self::RustType, Box<dyn std::error::Error>> {
        <Vec<u8> as RefArgToRust>::ref_arg_to_rust(arg, name)
    }
}

// Represents Uuid128Bit as an array in D-Bus.
impl DBusArg for Uuid128Bit {
    type DBusType = Vec<u8>;

    fn from_dbus(
        data: Vec<u8>,
        _conn: Option<Arc<SyncConnection>>,
        _remote: Option<dbus::strings::BusName<'static>>,
        _disconnect_watcher: Option<Arc<std::sync::Mutex<DisconnectWatcher>>>,
    ) -> Result<[u8; 16], Box<dyn std::error::Error>> {
        return Ok(data.try_into().unwrap());
    }

    fn to_dbus(data: [u8; 16]) -> Result<Vec<u8>, Box<dyn std::error::Error>> {
        return Ok(data.to_vec());
    }

    // We don't log in btclient.
    fn log(_data: &[u8; 16]) -> String {
        String::new()
    }
}

impl_dbus_arg_enum!(BtSdpType);
impl_dbus_arg_enum!(BtSdpType);


#[dbus_propmap(BtSdpHeaderOverlay)]
#[dbus_propmap(BtSdpHeaderOverlay)]
@@ -414,14 +379,14 @@ impl DBusArg for RawAddress {


#[dbus_propmap(BluetoothGattDescriptor)]
#[dbus_propmap(BluetoothGattDescriptor)]
pub struct BluetoothGattDescriptorDBus {
pub struct BluetoothGattDescriptorDBus {
    uuid: Uuid128Bit,
    uuid: Uuid,
    instance_id: i32,
    instance_id: i32,
    permissions: i32,
    permissions: i32,
}
}


#[dbus_propmap(BluetoothGattCharacteristic)]
#[dbus_propmap(BluetoothGattCharacteristic)]
pub struct BluetoothGattCharacteristicDBus {
pub struct BluetoothGattCharacteristicDBus {
    uuid: Uuid128Bit,
    uuid: Uuid,
    instance_id: i32,
    instance_id: i32,
    properties: i32,
    properties: i32,
    permissions: i32,
    permissions: i32,
@@ -432,7 +397,7 @@ pub struct BluetoothGattCharacteristicDBus {


#[dbus_propmap(BluetoothGattService)]
#[dbus_propmap(BluetoothGattService)]
pub struct BluetoothGattServiceDBus {
pub struct BluetoothGattServiceDBus {
    pub uuid: Uuid128Bit,
    pub uuid: Uuid,
    pub instance_id: i32,
    pub instance_id: i32,
    pub service_type: i32,
    pub service_type: i32,
    pub characteristics: Vec<BluetoothGattCharacteristic>,
    pub characteristics: Vec<BluetoothGattCharacteristic>,
@@ -594,7 +559,7 @@ struct ScanResultDBus {
    rssi: i8,
    rssi: i8,
    periodic_adv_int: u16,
    periodic_adv_int: u16,
    flags: u8,
    flags: u8,
    service_uuids: Vec<Uuid128Bit>,
    service_uuids: Vec<Uuid>,
    service_data: HashMap<String, Vec<u8>>,
    service_data: HashMap<String, Vec<u8>>,
    manufacturer_data: HashMap<u16, Vec<u8>>,
    manufacturer_data: HashMap<u16, Vec<u8>>,
    adv_data: Vec<u8>,
    adv_data: Vec<u8>,
@@ -685,7 +650,7 @@ impl IBluetoothCallback for IBluetoothCallbackDBus {
    fn on_sdp_search_complete(
    fn on_sdp_search_complete(
        &mut self,
        &mut self,
        remote_device: BluetoothDevice,
        remote_device: BluetoothDevice,
        searched_uuid: Uuid128Bit,
        searched_uuid: Uuid,
        sdp_records: Vec<BtSdpRecord>,
        sdp_records: Vec<BtSdpRecord>,
    ) {
    ) {
    }
    }
@@ -720,7 +685,7 @@ impl RPCProxy for IScannerCallbackDBus {}
)]
)]
impl IScannerCallback for IScannerCallbackDBus {
impl IScannerCallback for IScannerCallbackDBus {
    #[dbus_method("OnScannerRegistered", DBusLog::Disable)]
    #[dbus_method("OnScannerRegistered", DBusLog::Disable)]
    fn on_scanner_registered(&mut self, uuid: Uuid128Bit, scanner_id: u8, status: GattStatus) {
    fn on_scanner_registered(&mut self, uuid: Uuid, scanner_id: u8, status: GattStatus) {
        dbus_generated!()
        dbus_generated!()
    }
    }


@@ -826,7 +791,7 @@ impl IBluetooth for BluetoothDBus {
    }
    }


    #[dbus_method("GetUuids")]
    #[dbus_method("GetUuids")]
    fn get_uuids(&self) -> Vec<Uuid128Bit> {
    fn get_uuids(&self) -> Vec<Uuid> {
        dbus_generated!()
        dbus_generated!()
    }
    }


@@ -1001,12 +966,12 @@ impl IBluetooth for BluetoothDBus {
    }
    }


    #[dbus_method("GetProfileConnectionState")]
    #[dbus_method("GetProfileConnectionState")]
    fn get_profile_connection_state(&self, profile: Uuid128Bit) -> ProfileConnectionState {
    fn get_profile_connection_state(&self, profile: Uuid) -> ProfileConnectionState {
        dbus_generated!()
        dbus_generated!()
    }
    }


    #[dbus_method("GetRemoteUuids")]
    #[dbus_method("GetRemoteUuids")]
    fn get_remote_uuids(&self, device: BluetoothDevice) -> Vec<Uuid128Bit> {
    fn get_remote_uuids(&self, device: BluetoothDevice) -> Vec<Uuid> {
        dbus_generated!()
        dbus_generated!()
    }
    }


@@ -1016,7 +981,7 @@ impl IBluetooth for BluetoothDBus {
    }
    }


    #[dbus_method("SdpSearch")]
    #[dbus_method("SdpSearch")]
    fn sdp_search(&self, device: BluetoothDevice, uuid: Uuid128Bit) -> bool {
    fn sdp_search(&self, device: BluetoothDevice, uuid: Uuid) -> bool {
        dbus_generated!()
        dbus_generated!()
    }
    }


@@ -1384,17 +1349,17 @@ impl BluetoothAdminDBus {
#[generate_dbus_interface_client(BluetoothAdminDBusRPC)]
#[generate_dbus_interface_client(BluetoothAdminDBusRPC)]
impl IBluetoothAdmin for BluetoothAdminDBus {
impl IBluetoothAdmin for BluetoothAdminDBus {
    #[dbus_method("IsServiceAllowed")]
    #[dbus_method("IsServiceAllowed")]
    fn is_service_allowed(&self, uuid: Uuid128Bit) -> bool {
    fn is_service_allowed(&self, uuid: Uuid) -> bool {
        dbus_generated!()
        dbus_generated!()
    }
    }


    #[dbus_method("SetAllowedServices")]
    #[dbus_method("SetAllowedServices")]
    fn set_allowed_services(&mut self, services: Vec<Uuid128Bit>) -> bool {
    fn set_allowed_services(&mut self, services: Vec<Uuid>) -> bool {
        dbus_generated!()
        dbus_generated!()
    }
    }


    #[dbus_method("GetAllowedServices")]
    #[dbus_method("GetAllowedServices")]
    fn get_allowed_services(&self) -> Vec<Uuid128Bit> {
    fn get_allowed_services(&self) -> Vec<Uuid> {
        dbus_generated!()
        dbus_generated!()
    }
    }


@@ -1419,7 +1384,7 @@ impl IBluetoothAdmin for BluetoothAdminDBus {


#[dbus_propmap(PolicyEffect)]
#[dbus_propmap(PolicyEffect)]
pub struct PolicyEffectDBus {
pub struct PolicyEffectDBus {
    pub service_blocked: Vec<Uuid128Bit>,
    pub service_blocked: Vec<Uuid>,
    pub affected: bool,
    pub affected: bool,
}
}


@@ -1433,7 +1398,7 @@ impl RPCProxy for IBluetoothAdminPolicyCallbackDBus {}
)]
)]
impl IBluetoothAdminPolicyCallback for IBluetoothAdminPolicyCallbackDBus {
impl IBluetoothAdminPolicyCallback for IBluetoothAdminPolicyCallbackDBus {
    #[dbus_method("OnServiceAllowlistChanged", DBusLog::Disable)]
    #[dbus_method("OnServiceAllowlistChanged", DBusLog::Disable)]
    fn on_service_allowlist_changed(&mut self, allowed_list: Vec<Uuid128Bit>) {
    fn on_service_allowlist_changed(&mut self, allowed_list: Vec<Uuid>) {
        dbus_generated!()
        dbus_generated!()
    }
    }


@@ -1496,7 +1461,7 @@ impl IBluetoothGatt for BluetoothGattDBus {
    }
    }


    #[dbus_method("RegisterScanner")]
    #[dbus_method("RegisterScanner")]
    fn register_scanner(&mut self, callback_id: u32) -> Uuid128Bit {
    fn register_scanner(&mut self, callback_id: u32) -> Uuid {
        dbus_generated!()
        dbus_generated!()
    }
    }


+25 −14
Original line number Original line Diff line number Diff line
use bt_topshim::btif::{
use bt_topshim::btif::{
    BtAddrType, BtBondState, BtConnectionState, BtDeviceType, BtDiscMode, BtPropertyType,
    BtAddrType, BtBondState, BtConnectionState, BtDeviceType, BtDiscMode, BtPropertyType,
    BtSspVariant, BtStatus, BtTransport, BtVendorProductInfo, DisplayAddress, RawAddress, Uuid,
    BtSspVariant, BtStatus, BtTransport, BtVendorProductInfo, DisplayAddress, RawAddress, Uuid,
    Uuid128Bit,
};
};
use bt_topshim::profiles::socket::SocketType;
use bt_topshim::profiles::socket::SocketType;
use bt_topshim::profiles::ProfileConnectionState;
use bt_topshim::profiles::ProfileConnectionState;
@@ -42,16 +41,28 @@ use std::sync::{Arc, Mutex};
use crate::dbus_arg::{DBusArg, DBusArgError, DirectDBus, RefArgToRust};
use crate::dbus_arg::{DBusArg, DBusArgError, DirectDBus, RefArgToRust};


// Represents Uuid as an array in D-Bus.
// Represents Uuid as an array in D-Bus.
impl_dbus_arg_from_into!(Uuid, Vec<u8>);
impl DBusArg for Uuid {
    type DBusType = Vec<u8>;
    fn from_dbus(
        data: Vec<u8>,
        _conn: Option<Arc<SyncConnection>>,
        _remote: Option<dbus::strings::BusName<'static>>,
        _disconnect_watcher: Option<Arc<Mutex<dbus_projection::DisconnectWatcher>>>,
    ) -> Result<Uuid, Box<dyn std::error::Error>> {
        Ok(Uuid::try_from(data.clone()).or_else(|_| {
            Err(format!(
                "Invalid Uuid: first 4 bytes={:?}",
                data.iter().take(4).collect::<Vec<_>>()
            ))
        })?)
    }


impl RefArgToRust for Uuid {
    fn to_dbus(data: Uuid) -> Result<Vec<u8>, Box<dyn std::error::Error>> {
    type RustType = Vec<u8>;
        Ok(data.try_into()?)
    }


    fn ref_arg_to_rust(
    fn log(data: &Uuid) -> String {
        arg: &(dyn dbus::arg::RefArg + 'static),
        format!("{}", data)
        name: String,
    ) -> Result<Self::RustType, Box<dyn std::error::Error>> {
        <Vec<u8> as RefArgToRust>::ref_arg_to_rust(arg, name)
    }
    }
}
}


@@ -146,7 +157,7 @@ impl IBluetoothCallback for BluetoothCallbackDBus {
    fn on_sdp_search_complete(
    fn on_sdp_search_complete(
        &mut self,
        &mut self,
        remote_device: BluetoothDevice,
        remote_device: BluetoothDevice,
        searched_uuid: Uuid128Bit,
        searched_uuid: Uuid,
        sdp_records: Vec<BtSdpRecord>,
        sdp_records: Vec<BtSdpRecord>,
    ) {
    ) {
        dbus_generated!()
        dbus_generated!()
@@ -515,7 +526,7 @@ impl IBluetooth for IBluetoothDBus {
    }
    }


    #[dbus_method("GetUuids", DBusLog::Disable)]
    #[dbus_method("GetUuids", DBusLog::Disable)]
    fn get_uuids(&self) -> Vec<Uuid128Bit> {
    fn get_uuids(&self) -> Vec<Uuid> {
        dbus_generated!()
        dbus_generated!()
    }
    }


@@ -690,12 +701,12 @@ impl IBluetooth for IBluetoothDBus {
    }
    }


    #[dbus_method("GetProfileConnectionState", DBusLog::Disable)]
    #[dbus_method("GetProfileConnectionState", DBusLog::Disable)]
    fn get_profile_connection_state(&self, profile: Uuid128Bit) -> ProfileConnectionState {
    fn get_profile_connection_state(&self, profile: Uuid) -> ProfileConnectionState {
        dbus_generated!()
        dbus_generated!()
    }
    }


    #[dbus_method("GetRemoteUuids", DBusLog::Disable)]
    #[dbus_method("GetRemoteUuids", DBusLog::Disable)]
    fn get_remote_uuids(&self, device: BluetoothDevice) -> Vec<Uuid128Bit> {
    fn get_remote_uuids(&self, device: BluetoothDevice) -> Vec<Uuid> {
        dbus_generated!()
        dbus_generated!()
    }
    }


@@ -705,7 +716,7 @@ impl IBluetooth for IBluetoothDBus {
    }
    }


    #[dbus_method("SdpSearch")]
    #[dbus_method("SdpSearch")]
    fn sdp_search(&self, device: BluetoothDevice, uuid: Uuid128Bit) -> bool {
    fn sdp_search(&self, device: BluetoothDevice, uuid: Uuid) -> bool {
        dbus_generated!()
        dbus_generated!()
    }
    }


+6 −6
Original line number Original line Diff line number Diff line
@@ -8,7 +8,7 @@ use dbus_projection::prelude::*;


use crate::dbus_arg::{DBusArg, DBusArgError, RefArgToRust};
use crate::dbus_arg::{DBusArg, DBusArgError, RefArgToRust};


use bt_topshim::btif::Uuid128Bit;
use bt_topshim::btif::Uuid;


use btstack::bluetooth::BluetoothDevice;
use btstack::bluetooth::BluetoothDevice;
use btstack::RPCProxy;
use btstack::RPCProxy;
@@ -19,14 +19,14 @@ struct IBluetoothAdminPolicyCallbackDBus {}


#[dbus_propmap(PolicyEffect)]
#[dbus_propmap(PolicyEffect)]
pub struct PolicyEffectDBus {
pub struct PolicyEffectDBus {
    pub service_blocked: Vec<Uuid128Bit>,
    pub service_blocked: Vec<Uuid>,
    pub affected: bool,
    pub affected: bool,
}
}


#[dbus_proxy_obj(AdminPolicyCallback, "org.chromium.bluetooth.AdminPolicyCallback")]
#[dbus_proxy_obj(AdminPolicyCallback, "org.chromium.bluetooth.AdminPolicyCallback")]
impl IBluetoothAdminPolicyCallback for IBluetoothAdminPolicyCallbackDBus {
impl IBluetoothAdminPolicyCallback for IBluetoothAdminPolicyCallbackDBus {
    #[dbus_method("OnServiceAllowlistChanged")]
    #[dbus_method("OnServiceAllowlistChanged")]
    fn on_service_allowlist_changed(&mut self, allowlist: Vec<Uuid128Bit>) {
    fn on_service_allowlist_changed(&mut self, allowlist: Vec<Uuid>) {
        dbus_generated!()
        dbus_generated!()
    }
    }


@@ -43,17 +43,17 @@ impl IBluetoothAdminPolicyCallback for IBluetoothAdminPolicyCallbackDBus {
#[generate_dbus_exporter(export_bluetooth_admin_dbus_intf, "org.chromium.bluetooth.BluetoothAdmin")]
#[generate_dbus_exporter(export_bluetooth_admin_dbus_intf, "org.chromium.bluetooth.BluetoothAdmin")]
impl IBluetoothAdmin for IBluetoothAdminDBus {
impl IBluetoothAdmin for IBluetoothAdminDBus {
    #[dbus_method("IsServiceAllowed")]
    #[dbus_method("IsServiceAllowed")]
    fn is_service_allowed(&self, uuid: Uuid128Bit) -> bool {
    fn is_service_allowed(&self, uuid: Uuid) -> bool {
        dbus_generated!()
        dbus_generated!()
    }
    }


    #[dbus_method("SetAllowedServices")]
    #[dbus_method("SetAllowedServices")]
    fn set_allowed_services(&mut self, services: Vec<Uuid128Bit>) -> bool {
    fn set_allowed_services(&mut self, services: Vec<Uuid>) -> bool {
        dbus_generated!()
        dbus_generated!()
    }
    }


    #[dbus_method("GetAllowedServices")]
    #[dbus_method("GetAllowedServices")]
    fn get_allowed_services(&self) -> Vec<Uuid128Bit> {
    fn get_allowed_services(&self) -> Vec<Uuid> {
        dbus_generated!()
        dbus_generated!()
    }
    }


Loading