From bfb2ee703aebc0b8c4a4332bd8a8326609b2c05a Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 16 Oct 2015 02:49:39 +0200 Subject: [PATCH] Force poll the battery when showing the menu. Making sure to always show up to date info. Also fix the battery polling cache invalidation logic to actually work? Should make it behave properly on devices where we handle resuming ourselves. --- frontend/device/generic/powerd.lua | 3 ++- frontend/ui/widget/touchmenu.lua | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/device/generic/powerd.lua b/frontend/device/generic/powerd.lua index 920ca0a65..036f2b300 100644 --- a/frontend/device/generic/powerd.lua +++ b/frontend/device/generic/powerd.lua @@ -74,7 +74,8 @@ function BasePowerD:getCapacity() end function BasePowerD:refreshCapacity() - self:getCapacityHW() + -- We want our next getCapacity call to actually pull up to date info instead of a cached value ;) + self.capacity_pulled_count = self.capacity_cached_count end function BasePowerD:isCharging() diff --git a/frontend/ui/widget/touchmenu.lua b/frontend/ui/widget/touchmenu.lua index 77c375f78..a23cd44e5 100644 --- a/frontend/ui/widget/touchmenu.lua +++ b/frontend/ui/widget/touchmenu.lua @@ -381,6 +381,8 @@ function TouchMenu:init() } self.bar:switchToTab(self.last_index or 1) + -- Make sure we always show an up to date battery status when first opening the menu... + Device:getPowerDevice():refreshCapacity() self:updateItems() end