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

Commit 1b8d9974 authored by Katherine Lai's avatar Katherine Lai Committed by Automerger Merge Worker
Browse files

Merge "floss: Add IsLEAudioStable API" into main am: 93eb01fa am: 993eacc7

parents 4bd5104e 993eacc7
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -889,6 +889,7 @@ impl CommandHandler {
                    uuids,
                    wake_allowed,
                    dual_mode_audio,
                    le_audio_stable,
                ) = {
                    let ctx = self.lock_context();
                    let adapter = ctx.adapter_dbus.as_ref().unwrap();
@@ -908,6 +909,7 @@ impl CommandHandler {
                    let uuids = adapter.get_remote_uuids(device.clone());
                    let wake_allowed = adapter.get_remote_wake_allowed(device.clone());
                    let dual_mode_audio = adapter.is_dual_mode_audio_sink_device(device.clone());
                    let le_audio_stable = adapter.is_le_audio_stable(device.clone());

                    (
                        name,
@@ -921,6 +923,7 @@ impl CommandHandler {
                        uuids,
                        wake_allowed,
                        dual_mode_audio,
                        le_audio_stable,
                    )
                };

@@ -935,6 +938,7 @@ impl CommandHandler {
                print_info!("Bond State: {:?}", bonded);
                print_info!("Connection State: {}", connection_state);
                print_info!("Dual Mode Audio Device: {}", dual_mode_audio);
                print_info!("Is LE Audio Stable: {}", le_audio_stable);
                print_info!(
                    "Uuids: {}",
                    DisplayList(
+5 −0
Original line number Diff line number Diff line
@@ -1036,6 +1036,11 @@ impl IBluetooth for BluetoothDBus {
        dbus_generated!()
    }

    #[dbus_method("IsLEAudioStable")]
    fn is_le_audio_stable(&self, device: BluetoothDevice) -> bool {
        dbus_generated!()
    }

    #[dbus_method("GetDumpsys")]
    fn get_dumpsys(&self) -> String {
        dbus_generated!()
+5 −0
Original line number Diff line number Diff line
@@ -771,6 +771,11 @@ impl IBluetooth for IBluetoothDBus {
        dbus_generated!()
    }

    #[dbus_method("IsLEAudioStable", DBusLog::Disable)]
    fn is_le_audio_stable(&self, device: BluetoothDevice) -> bool {
        dbus_generated!()
    }

    #[dbus_method("GetDumpsys", DBusLog::Disable)]
    fn get_dumpsys(&self) -> String {
        dbus_generated!()
+18 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ use bt_topshim::{
    },
    profiles::sdp::{BtSdpRecord, Sdp, SdpCallbacks, SdpCallbacksDispatcher},
    profiles::ProfileConnectionState,
    topstack,
    sysprop, topstack,
};

use bt_utils::array_utils;
@@ -265,6 +265,9 @@ pub trait IBluetooth {
    /// LE Audio sink roles).
    fn is_dual_mode_audio_sink_device(&self, device: BluetoothDevice) -> bool;

    /// Returns whether the remote device is LE audio stable.
    fn is_le_audio_stable(&self, device: BluetoothDevice) -> bool;

    /// Gets diagnostic output.
    fn get_dumpsys(&self) -> String;
}
@@ -3004,6 +3007,20 @@ impl IBluetooth for Bluetooth {
        })
    }

    fn is_le_audio_stable(&self, device: BluetoothDevice) -> bool {
        let model_name =
            match self.get_remote_device_property(&device, &BtPropertyType::RemoteModelName) {
                Some(BluetoothProperty::RemoteModelName(name)) => name,
                _ => {
                    return false;
                }
            };

        sysprop::get_string(sysprop::PropertyString::LeAudioAllowList)
            .split(",")
            .any(|model| model == model_name)
    }

    fn get_dumpsys(&self) -> String {
        NamedTempFile::new()
            .and_then(|file| {
+10 −1
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ pub enum BtPropertyType {
    // Unimplemented:
    //  BT_PROPERTY_REMOTE_ASHA_CAPABILITY,
    //  BT_PROPERTY_REMOTE_ASHA_TRUNCATED_HISYNCID,
    //  BT_PROPERTY_REMOTE_MODEL_NUM,
    RemoteModelName = 0x17,
    RemoteAddrType = 0x18,

    Unknown = 0xFE,
@@ -586,6 +586,7 @@ pub enum BluetoothProperty {
    RemoteIsCoordinatedSetMember(bool),
    Appearance(u16),
    VendorProductInfo(BtVendorProductInfo),
    RemoteModelName(String),
    RemoteAddrType(BtAddrType),
    RemoteDeviceTimestamp(),

@@ -630,6 +631,7 @@ impl BluetoothProperty {
            BluetoothProperty::Appearance(_) => BtPropertyType::Appearance,
            BluetoothProperty::VendorProductInfo(_) => BtPropertyType::VendorProductInfo,
            BluetoothProperty::RemoteDeviceTimestamp() => BtPropertyType::RemoteDeviceTimestamp,
            BluetoothProperty::RemoteModelName(_) => BtPropertyType::RemoteModelName,
            BluetoothProperty::RemoteAddrType(_) => BtPropertyType::RemoteAddrType,
            BluetoothProperty::Unknown() => BtPropertyType::Unknown,
        }
@@ -661,6 +663,7 @@ impl BluetoothProperty {
            BluetoothProperty::RemoteIsCoordinatedSetMember(_) => mem::size_of::<bool>(),
            BluetoothProperty::Appearance(_) => mem::size_of::<u16>(),
            BluetoothProperty::VendorProductInfo(_) => mem::size_of::<BtVendorProductInfo>(),
            BluetoothProperty::RemoteModelName(name) => name.len(),
            BluetoothProperty::RemoteAddrType(_) => mem::size_of::<BtAddrType>(),

            // TODO(abps) - Figure out sizes for these
@@ -770,6 +773,9 @@ impl BluetoothProperty {
                };
                data.copy_from_slice(&slice);
            }
            BluetoothProperty::RemoteModelName(name) => {
                data.copy_from_slice(name.as_bytes());
            }
            BluetoothProperty::RemoteAddrType(addr_type) => {
                data.copy_from_slice(
                    &BtAddrType::to_u32(addr_type).unwrap_or_default().to_ne_bytes(),
@@ -851,6 +857,9 @@ impl From<bindings::bt_property_t> for BluetoothProperty {
                let v = unsafe { (prop.val as *const BtVendorProductInfo).read_unaligned() };
                BluetoothProperty::VendorProductInfo(BtVendorProductInfo::from(v))
            }
            BtPropertyType::RemoteModelName => {
                BluetoothProperty::RemoteModelName(ascii_to_string(slice, len))
            }
            BtPropertyType::RemoteAddrType => BluetoothProperty::RemoteAddrType(
                BtAddrType::from_u32(u32_from_bytes(slice)).unwrap_or(BtAddrType::Unknown),
            ),
Loading