[apps] Update the battery level after an update

This commit is contained in:
Léa Saviot
2018-11-14 17:10:45 +01:00
committed by EmilieNumworks
parent 0eae57da09
commit 062ff5af1a

View File

@@ -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;