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

Commit d33c96ef authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Floss: Refresh peripheral battery data if cache is empty" into main am:...

Merge "Floss: Refresh peripheral battery data if cache is empty" into main am: e898de76 am: 692be2cd

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/3393519



Change-Id: If219950cd72ac3f60b7351c9cf74da972d2816c7
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 2e1be911 692be2cd
Loading
Loading
Loading
Loading
+14 −2
Original line number Original line Diff line number Diff line
@@ -57,8 +57,20 @@ impl BatteryProviderManager {
    }
    }


    /// Get the best battery info available for a given device.
    /// Get the best battery info available for a given device.
    pub fn get_battery_info(&self, remote_address: RawAddress) -> Option<BatterySet> {
    pub fn get_battery_info(&mut self, remote_address: RawAddress) -> Option<BatterySet> {
        self.battery_info.get(&remote_address)?.pick_best()
        if let Some(info) = self.battery_info.get(&remote_address) {
            return info.pick_best();
        }

        // If no battery info found, refresh and retry
        self.refresh_battery_info();
        match self.battery_info.get(&remote_address) {
            None => {
                debug!("No battery info found for [{}]", DisplayAddress(&remote_address));
                return None;
            }
            Some(info) => return info.pick_best(),
        }
    }
    }


    /// Removes a battery provider callback.
    /// Removes a battery provider callback.