From e39172a7cdc3a930505218e595e3209d67bfa545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Thu, 18 Apr 2019 13:58:42 +0200 Subject: [PATCH] [apps] AppsContainer: 'shutdownDueToLowBattery' can be call when the battery is actually LOW (due to some oscillations between LOW and EMPTY). Handle that case --- apps/apps_container.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/apps_container.cpp b/apps/apps_container.cpp index c79eac063..6e7cef01d 100644 --- a/apps/apps_container.cpp +++ b/apps/apps_container.cpp @@ -312,6 +312,14 @@ void AppsContainer::displayExamModePopUp(bool activate) { } void AppsContainer::shutdownDueToLowBattery() { + if (Ion::Battery::level() != Ion::Battery::Charge::EMPTY) { + /* We early escape here. When the battery switches from LOW to EMPTY, it + * oscillates a few times before stabilizing to EMPTY. So we might call + * 'shutdownDueToLowBattery' but the battery level still answers LOW instead + * of EMPTY. We want to avoid uselessly redrawing the whole window in that + * case. */ + return; + } while (Ion::Battery::level() == Ion::Battery::Charge::EMPTY) { Ion::Backlight::setBrightness(0); m_emptyBatteryWindow.redraw(true);