2014-10-30 18:42:18 +00:00
|
|
|
local BasePowerD = require("device/generic/powerd")
|
2016-06-23 17:50:24 +00:00
|
|
|
local _, android = pcall(require, "android")
|
2014-07-15 08:23:38 +00:00
|
|
|
|
|
|
|
local AndroidPowerD = BasePowerD:new{
|
2016-06-23 17:50:24 +00:00
|
|
|
fl_min = 0, fl_max = 25,
|
|
|
|
fl_intensity = 10,
|
2014-07-15 08:23:38 +00:00
|
|
|
batt_capacity_file = "/sys/class/power_supply/battery/capacity",
|
|
|
|
is_charging_file = "/sys/class/power_supply/battery/charging_enabled",
|
|
|
|
battCapacity = nil,
|
|
|
|
is_charging = nil,
|
|
|
|
}
|
|
|
|
|
|
|
|
function AndroidPowerD:init()
|
|
|
|
end
|
|
|
|
|
|
|
|
function AndroidPowerD:setIntensityHW()
|
2016-06-23 17:50:24 +00:00
|
|
|
android.setScreenBrightness(math.floor(255 * self.fl_intensity / 25))
|
2014-07-15 08:23:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function AndroidPowerD:getCapacityHW()
|
2016-06-23 17:50:24 +00:00
|
|
|
self.battCapacity = android.getBatteryLevel()
|
2014-07-15 08:23:38 +00:00
|
|
|
return self.battCapacity
|
|
|
|
end
|
|
|
|
|
|
|
|
function AndroidPowerD:isChargingHW()
|
2016-06-23 17:50:24 +00:00
|
|
|
self.is_charging = android.isCharging()
|
|
|
|
return self.is_charging
|
2014-07-15 08:23:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return AndroidPowerD
|