MCPcopy Create free account
hub / github.com/comaps/comaps / RequestBatteryLevel

Method RequestBatteryLevel

libs/platform/battery_tracker.cpp:41–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41void BatteryLevelTracker::RequestBatteryLevel()
42{
43 if (m_subscribers.empty())
44 {
45 m_isTrackingInProgress = false;
46 return;
47 }
48
49 if (IsLevelExpired(m_lastRequestTime))
50 {
51 m_lastReceivedLevel = GetPlatform().GetBatteryLevel();
52 m_lastRequestTime = std::chrono::system_clock::now();
53 }
54
55 for (auto s : m_subscribers)
56 s->OnBatteryLevelReceived(m_lastReceivedLevel);
57
58 GetPlatform().RunDelayedTask(Platform::Thread::Background, kBatteryTrackingInterval, [this]
59 { GetPlatform().RunTask(Platform::Thread::Gui, [this] { RequestBatteryLevel(); }); });
60}
61} // namespace platform

Callers

nothing calls this directly

Calls 6

IsLevelExpiredFunction · 0.85
RunDelayedTaskMethod · 0.80
RunTaskMethod · 0.80
emptyMethod · 0.45
GetBatteryLevelMethod · 0.45

Tested by

no test coverage detected