add support of screen brightness settings for Android

and use standrad Android API to query battery level and charging status
This should fix #2025, fix #1759 and fix #1415.
pull/2102/head
chrox 8 years ago
parent f3732fd04d
commit 687b6df4f2

@ -11,6 +11,7 @@ local Device = Generic:new{
hasKeys = yes,
hasDPad = no,
isAndroid = yes,
hasFrontlight = yes,
firmware_rev = "none",
display_dpi = ffi.C.AConfiguration_getDensity(android.app.config),
}

@ -1,6 +1,9 @@
local BasePowerD = require("device/generic/powerd")
local _, android = pcall(require, "android")
local AndroidPowerD = BasePowerD:new{
fl_min = 0, fl_max = 25,
fl_intensity = 10,
batt_capacity_file = "/sys/class/power_supply/battery/capacity",
is_charging_file = "/sys/class/power_supply/battery/charging_enabled",
battCapacity = nil,
@ -11,16 +14,17 @@ function AndroidPowerD:init()
end
function AndroidPowerD:setIntensityHW()
android.setScreenBrightness(math.floor(255 * self.fl_intensity / 25))
end
function AndroidPowerD:getCapacityHW()
self.battCapacity = self:read_int_file(self.batt_capacity_file)
self.battCapacity = android.getBatteryLevel()
return self.battCapacity
end
function AndroidPowerD:isChargingHW()
self.is_charging = self:read_int_file(self.is_charging_file)
return self.is_charging == 1
self.is_charging = android.isCharging()
return self.is_charging
end
return AndroidPowerD

@ -1,3 +1,5 @@
local DEBUG = require("dbg")
local BasePowerD = {
fl_min = 0, -- min frontlight intensity
fl_max = 10, -- max frontlight intensity
@ -59,6 +61,7 @@ end
function BasePowerD:setIntensity(intensity)
if intensity == self.fl_intensity then return end
self.fl_intensity = self:normalizeIntensity(intensity)
DEBUG("set light intensity", self.fl_intensity)
self:setIntensityHW()
end

@ -37,9 +37,11 @@ local function update()
local update_file = io.open(new_update, "r")
if update_file ~= nil then
io.close(update_file)
A.showProgress()
if os.execute("tar xf " .. new_update) == 0 then
os.execute("mv " .. new_update .. " " .. installed)
end
A.dismissProgress()
end
end

@ -1 +1 @@
Subproject commit e3560e777558efbb1dc913250024afa7ecb40868
Subproject commit d0e2274673d683fbbd7e6a2e11d46f2b60b440d5
Loading…
Cancel
Save