A few reMarkable QoL fixes (#6772)

* Enable AutoSuspend plugin on rM

Fix #6769
Re: #6028

* Use the PowerEvent handler on rM

It makes much more sense than the fire & forget & hope for the best
approach copied from the Kindle platform, because we *are* controlling
suspend ourselves (mostly), unlike on Kindle ;).

Fix #6676

* Enable HW inversion on the rM

I mean, we kinda forgot to ever test that, but I don't really see why it
wouldn't work ;).
reviewable/pr6777/r1
NiLuJe 4 years ago committed by GitHub
parent 624762a6bf
commit b932b97b20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -217,7 +217,7 @@ function Device:rescheduleSuspend()
UIManager:scheduleIn(self.suspend_wait_timeout, self.suspend)
end
-- ONLY used for Kobo and PocketBook devices
-- Only used on platforms where we handle suspend ourselves.
function Device:onPowerEvent(ev)
if self.screen_saver_mode then
if ev == "Power" or ev == "Resume" then
@ -228,10 +228,12 @@ function Device:onPowerEvent(ev)
logger.dbg("Resuming...")
local UIManager = require("ui/uimanager")
UIManager:unschedule(self.suspend)
local network_manager = require("ui/network/manager")
if network_manager.wifi_was_on and G_reader_settings:isTrue("auto_restore_wifi") then
network_manager:restoreWifiAsync()
network_manager:scheduleConnectivityCheck()
if self:hasWifiManager() and not self:isEmulator() then
local network_manager = require("ui/network/manager")
if network_manager.wifi_was_on and G_reader_settings:isTrue("auto_restore_wifi") then
network_manager:restoreWifiAsync()
network_manager:scheduleConnectivityCheck()
end
end
self:resume()
-- Restore to previous rotation mode, if need be.
@ -289,22 +291,32 @@ function Device:onPowerEvent(ev)
self.orig_rotation_mode = nil
end
require("ui/screensaver"):show()
-- NOTE: show() will return well before the refresh ioctl is even *sent*:
-- the only thing it's done is *enqueued* the refresh in UIManager's stack.
-- Which is why the actual suspension needs to be delayed by suspend_wait_timeout,
-- otherwise, we'd potentially suspend (or attempt to) too soon.
-- On platforms where suspension is done via a sysfs knob, that'd translate to a failed suspend,
-- and on platforms where we defer to a system tool, it'd probably suspend too early!
-- c.f., #6676
if self:needsScreenRefreshAfterResume() then
self.screen:refreshFull()
end
self.screen_saver_mode = true
UIManager:scheduleIn(0.1, function()
local network_manager = require("ui/network/manager")
-- NOTE: wifi_was_on does not necessarily mean that Wi-Fi is *currently* on! It means *we* enabled it.
-- This is critical on Kobos (c.f., #3936), where it might still be on from KSM or Nickel,
-- without us being aware of it (i.e., wifi_was_on still unset or false),
-- because suspend will at best fail, and at worst deadlock the system if Wi-Fi is on,
-- regardless of who enabled it!
if network_manager:isWifiOn() then
network_manager:releaseIP()
network_manager:turnOffWifi()
end
UIManager:scheduleIn(self.suspend_wait_timeout, self.suspend)
-- NOTE: This side of the check needs to be laxer, some platforms can handle Wi-Fi without WifiManager ;).
if self:hasWifiToggle() then
local network_manager = require("ui/network/manager")
-- NOTE: wifi_was_on does not necessarily mean that Wi-Fi is *currently* on! It means *we* enabled it.
-- This is critical on Kobos (c.f., #3936), where it might still be on from KSM or Nickel,
-- without us being aware of it (i.e., wifi_was_on still unset or false),
-- because suspend will at best fail, and at worst deadlock the system if Wi-Fi is on,
-- regardless of who enabled it!
if network_manager:isWifiOn() then
network_manager:releaseIP()
network_manager:turnOffWifi()
end
end
UIManager:scheduleIn(self.suspend_wait_timeout, self.suspend)
end)
end
end

@ -8,12 +8,15 @@ local Remarkable = Generic:new{
model = "reMarkable",
isRemarkable = yes,
hasKeys = yes,
needsScreenRefreshAfterResume = no,
hasOTAUpdates = yes,
canReboot = yes,
canPowerOff = yes,
isTouchDevice = yes,
hasFrontlight = no,
display_dpi = 226,
-- It's a recent NXP SoC, I see no reason why HW inversion would be buggy there ;).
canHWInvert = yes,
home_dir = "/mnt/root",
}
@ -92,24 +95,6 @@ function Remarkable:setDateTime(year, month, day, hour, min, sec)
return os.execute(command) == 0
end
function Remarkable:intoScreenSaver()
local Screensaver = require("ui/screensaver")
if self.screen_saver_mode == false then
Screensaver:show()
end
self.powerd:beforeSuspend()
self.screen_saver_mode = true
end
function Remarkable:outofScreenSaver()
if self.screen_saver_mode == true then
local Screensaver = require("ui/screensaver")
Screensaver:close()
end
self.powerd:afterResume()
self.screen_saver_mode = false
end
function Remarkable:suspend()
os.execute("systemctl suspend")
end

@ -213,6 +213,14 @@ function UIManager:init()
self:_afterNotCharging()
end
elseif Device:isRemarkable() then
self.event_handlers["Suspend"] = function()
self:_beforeSuspend()
Device:onPowerEvent("Suspend")
end
self.event_handlers["Resume"] = function()
Device:onPowerEvent("Resume")
self:_afterResume()
end
self.event_handlers["PowerPress"] = function()
UIManager:scheduleIn(2, self.poweroff_action)
end
@ -227,16 +235,6 @@ function UIManager:init()
end
end
end
self.event_handlers["Suspend"] = function()
self:_beforeSuspend()
Device:intoScreenSaver()
Device:suspend()
end
self.event_handlers["Resume"] = function()
Device:resume()
Device:outofScreenSaver()
self:_afterResume()
end
self.event_handlers["__default__"] = function(input_event)
-- Same as in Kobo: we want to ignore keys during suspension
if not Device.screen_saver_mode then

@ -1,6 +1,6 @@
local Device = require("device")
if not Device:isCervantes() and not Device:isKobo() and not Device:isSDL() and not Device:isSonyPRSTUX() then
if not Device:isCervantes() and not Device:isKobo() and not Device:isRemarkable() and not Device:isSDL() and not Device:isSonyPRSTUX() then
return { disabled = true, }
end

Loading…
Cancel
Save