From df57c19b99b8a68515b0ec140b593bf25ea13369 Mon Sep 17 00:00:00 2001 From: chrox Date: Tue, 15 Jul 2014 16:45:09 +0800 Subject: [PATCH] check battery status file --- frontend/ui/device/basepowerd.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/ui/device/basepowerd.lua b/frontend/ui/device/basepowerd.lua index 23da99647..5c81b17ca 100644 --- a/frontend/ui/device/basepowerd.lua +++ b/frontend/ui/device/basepowerd.lua @@ -27,10 +27,14 @@ function BasePowerD:suspendHW() end function BasePowerD:wakeUpHW() end function BasePowerD:read_int_file(file) - local f = io.open(file, "r") - local sysint = tonumber(f:read("*all"):match("%d+")) - f:close() - return sysint + local fd = io.open(file, "r") + if fd then + local int = fd:read("*all"):match("%d+") + fd:close() + return int and tonumber(int) or 0 + else + return 0 + end end function BasePowerD:setIntensity(intensity)