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

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

Merge "floss: Fix race between adapter prop change and device prop change" into main

parents b877fcdf 7f3f7769
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
@@ -1468,18 +1468,24 @@ impl BtifBluetoothCallbacks for Bluetooth {
                    for addr in bondlist.iter() {
                        let address = addr.to_string();

                        // Update bonded state if already in the list. Otherwise create a new
                        // context with empty properties and name.
                        self.bonded_devices
                            .entry(address.clone())
                            .and_modify(|d| d.bond_state = BtBondState::Bonded)
                            .or_insert(BluetoothDeviceContext::new(
                        // On BT started, the |remote_device_properties_changed| event from BTIF
                        // could comes earlier then this |AdapterBondedDevices| prop. In that case
                        // the updated remote device properties would be stored in |found_devices|,
                        // so we need to move out and reuse them, otherwise those properties
                        // (usually the device name) would be lost.
                        // If the device doesn't exist in both map, create a new context with
                        // empty properties and name.
                        let device = self.found_devices.remove(&address).unwrap_or(
                            BluetoothDeviceContext::new(
                                BtBondState::Bonded,
                                BtAclState::Disconnected,
                                BluetoothDevice::new(address.clone(), "".to_string()),
                                Instant::now(),
                                vec![],
                            ));
                            ),
                        );
                        self.bonded_devices.entry(address.clone()).or_insert(device).bond_state =
                            BtBondState::Bonded;
                    }
                }
                BluetoothProperty::BdName(bdname) => {