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

Commit d5ef921a authored by Ying Hsu's avatar Ying Hsu Committed by Ying Hsu
Browse files

Floss: updating enum BtDeviceType and changing its default value

Aligning the definition with enum BluetoothDeviceType in Chromium.
In case topshim gets an invalid device type from libbluetooth,
it will be converted to 'Unknown' device type for correctness and
clarity.

Bug: 231248387
Tag: #floss
Test: manual test on classic and dual mode devices
Change-Id: Ieac91b26f13958ce974f528ac476f85594beb08b
parent ee9b6265
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -118,10 +118,10 @@ impl From<bindings::bt_acl_state_t> for BtAclState {
#[derive(Clone, Debug, FromPrimitive, ToPrimitive, PartialEq, PartialOrd)]
#[derive(Clone, Debug, FromPrimitive, ToPrimitive, PartialEq, PartialOrd)]
#[repr(u32)]
#[repr(u32)]
pub enum BtDeviceType {
pub enum BtDeviceType {
    Bredr = 0x1,
    Unknown = 0,
    Bredr,
    Ble,
    Ble,
    Dual,
    Dual,
    Unknown,
}
}


#[derive(Clone, Debug, Eq, Hash, FromPrimitive, ToPrimitive, PartialEq, PartialOrd)]
#[derive(Clone, Debug, Eq, Hash, FromPrimitive, ToPrimitive, PartialEq, PartialOrd)]
@@ -487,7 +487,7 @@ impl From<bindings::bt_property_t> for BluetoothProperty {
                BluetoothProperty::ClassOfDevice(u32_from_bytes(slice))
                BluetoothProperty::ClassOfDevice(u32_from_bytes(slice))
            }
            }
            BtPropertyType::TypeOfDevice => BluetoothProperty::TypeOfDevice(
            BtPropertyType::TypeOfDevice => BluetoothProperty::TypeOfDevice(
                BtDeviceType::from_u32(u32_from_bytes(slice)).unwrap_or(BtDeviceType::Bredr),
                BtDeviceType::from_u32(u32_from_bytes(slice)).unwrap_or(BtDeviceType::Unknown),
            ),
            ),
            BtPropertyType::ServiceRecord => {
            BtPropertyType::ServiceRecord => {
                let v = unsafe { *(prop.val as *const bindings::bt_service_record_t) };
                let v = unsafe { *(prop.val as *const bindings::bt_service_record_t) };