mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge pull request #2102 from chrox/android_fixes
add support of screen brightness settings for Android
This commit is contained in:
@@ -11,6 +11,7 @@ local Device = Generic:new{
|
|||||||
hasKeys = yes,
|
hasKeys = yes,
|
||||||
hasDPad = no,
|
hasDPad = no,
|
||||||
isAndroid = yes,
|
isAndroid = yes,
|
||||||
|
hasFrontlight = yes,
|
||||||
firmware_rev = "none",
|
firmware_rev = "none",
|
||||||
display_dpi = ffi.C.AConfiguration_getDensity(android.app.config),
|
display_dpi = ffi.C.AConfiguration_getDensity(android.app.config),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
local BasePowerD = require("device/generic/powerd")
|
local BasePowerD = require("device/generic/powerd")
|
||||||
|
local _, android = pcall(require, "android")
|
||||||
|
|
||||||
local AndroidPowerD = BasePowerD:new{
|
local AndroidPowerD = BasePowerD:new{
|
||||||
|
fl_min = 0, fl_max = 25,
|
||||||
|
fl_intensity = 10,
|
||||||
batt_capacity_file = "/sys/class/power_supply/battery/capacity",
|
batt_capacity_file = "/sys/class/power_supply/battery/capacity",
|
||||||
is_charging_file = "/sys/class/power_supply/battery/charging_enabled",
|
is_charging_file = "/sys/class/power_supply/battery/charging_enabled",
|
||||||
battCapacity = nil,
|
battCapacity = nil,
|
||||||
@@ -11,16 +14,17 @@ function AndroidPowerD:init()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function AndroidPowerD:setIntensityHW()
|
function AndroidPowerD:setIntensityHW()
|
||||||
|
android.setScreenBrightness(math.floor(255 * self.fl_intensity / 25))
|
||||||
end
|
end
|
||||||
|
|
||||||
function AndroidPowerD:getCapacityHW()
|
function AndroidPowerD:getCapacityHW()
|
||||||
self.battCapacity = self:read_int_file(self.batt_capacity_file)
|
self.battCapacity = android.getBatteryLevel()
|
||||||
return self.battCapacity
|
return self.battCapacity
|
||||||
end
|
end
|
||||||
|
|
||||||
function AndroidPowerD:isChargingHW()
|
function AndroidPowerD:isChargingHW()
|
||||||
self.is_charging = self:read_int_file(self.is_charging_file)
|
self.is_charging = android.isCharging()
|
||||||
return self.is_charging == 1
|
return self.is_charging
|
||||||
end
|
end
|
||||||
|
|
||||||
return AndroidPowerD
|
return AndroidPowerD
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
local DEBUG = require("dbg")
|
||||||
|
|
||||||
local BasePowerD = {
|
local BasePowerD = {
|
||||||
fl_min = 0, -- min frontlight intensity
|
fl_min = 0, -- min frontlight intensity
|
||||||
fl_max = 10, -- max frontlight intensity
|
fl_max = 10, -- max frontlight intensity
|
||||||
@@ -59,6 +61,7 @@ end
|
|||||||
function BasePowerD:setIntensity(intensity)
|
function BasePowerD:setIntensity(intensity)
|
||||||
if intensity == self.fl_intensity then return end
|
if intensity == self.fl_intensity then return end
|
||||||
self.fl_intensity = self:normalizeIntensity(intensity)
|
self.fl_intensity = self:normalizeIntensity(intensity)
|
||||||
|
DEBUG("set light intensity", self.fl_intensity)
|
||||||
self:setIntensityHW()
|
self:setIntensityHW()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -37,9 +37,11 @@ local function update()
|
|||||||
local update_file = io.open(new_update, "r")
|
local update_file = io.open(new_update, "r")
|
||||||
if update_file ~= nil then
|
if update_file ~= nil then
|
||||||
io.close(update_file)
|
io.close(update_file)
|
||||||
|
A.showProgress()
|
||||||
if os.execute("tar xf " .. new_update) == 0 then
|
if os.execute("tar xf " .. new_update) == 0 then
|
||||||
os.execute("mv " .. new_update .. " " .. installed)
|
os.execute("mv " .. new_update .. " " .. installed)
|
||||||
end
|
end
|
||||||
|
A.dismissProgress()
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Submodule platform/android/luajit-launcher updated: e3560e7775...d0e2274673
Reference in New Issue
Block a user