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

Commit 3c96c809 authored by Abhishek Pandit-Subedi's avatar Abhishek Pandit-Subedi
Browse files

floss: Get DeviceType before device can be deleted

Bug: 232098615
Tag: #floss
Test: Manual test
Change-Id: Id612e0227ebd5588a00a2df557a1e1df241f18c9
parent 19a91c3e
Loading
Loading
Loading
Loading
+12 −11
Original line number Diff line number Diff line
@@ -780,6 +780,18 @@ impl BtifBluetoothCallbacks for Bluetooth {
    ) {
        let address = addr.to_string();

        // Get the device type before the device is potentially deleted.
        let device_type = match self.get_remote_device_if_found(&address) {
            Some(d) => match d.properties.get(&BtPropertyType::TypeOfDevice) {
                Some(prop) => match prop {
                    BluetoothProperty::TypeOfDevice(type_of_device) => type_of_device.clone(),
                    _ => BtDeviceType::Unknown,
                },
                _ => BtDeviceType::Unknown,
            },
            _ => BtDeviceType::Unknown,
        };

        // Easy case of not bonded -- we remove the device from the bonded list and change the bond
        // state in the found list (in case it was previously bonding).
        if &bond_state == &BtBondState::NotBonded {
@@ -824,17 +836,6 @@ impl BtifBluetoothCallbacks for Bluetooth {
            );
        });

        let device_type = match self.get_remote_device_if_found(&address) {
            Some(d) => match d.properties.get(&BtPropertyType::TypeOfDevice) {
                Some(prop) => match prop {
                    BluetoothProperty::TypeOfDevice(type_of_device) => type_of_device.clone(),
                    _ => BtDeviceType::Unknown,
                },
                _ => BtDeviceType::Unknown,
            },
            _ => BtDeviceType::Unknown,
        };

        metrics::bond_state_changed(addr, device_type, status, bond_state, fail_reason);
    }