From 062ff5af1a93c03c8ddcd47ed45c7d070be48cfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Wed, 14 Nov 2018 17:10:45 +0100 Subject: [PATCH] [apps] Update the battery level after an update --- apps/apps_container.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/apps_container.cpp b/apps/apps_container.cpp index 368818d0c..4ee6492f5 100644 --- a/apps/apps_container.cpp +++ b/apps/apps_container.cpp @@ -136,6 +136,10 @@ bool AppsContainer::dispatchEvent(Ion::Events::Event event) { if (event == Ion::Events::USBEnumeration) { if (Ion::USB::isPlugged()) { App::Snapshot * activeSnapshot = (activeApp() == nullptr ? appSnapshotAtIndex(0) : activeApp()->snapshot()); + /* Just after a software update, the battery timer does not have time to + * fire before the calculator enters DFU mode. As the DFU mode blocks the + * event loop, we update the battery state "manually" here. */ + updateBatteryState(); switchTo(usbConnectedAppSnapshot()); Ion::USB::DFU(); switchTo(activeSnapshot); @@ -237,9 +241,10 @@ void AppsContainer::run() { } bool AppsContainer::updateBatteryState() { - if (m_window.updateBatteryLevel() || - m_window.updateIsChargingState() || - m_window.updatePluggedState()) { + bool batteryLevelUpdated = m_window.updateBatteryLevel(); + bool pluggedStateUpdated = m_window.updatePluggedState(); + bool chargingStateUpdated = m_window.updateIsChargingState(); + if (batteryLevelUpdated || pluggedStateUpdated || chargingStateUpdated) { return true; } return false;