| 39 | } |
| 40 | |
| 41 | void 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 |
nothing calls this directly
no test coverage detected