@ -155,6 +155,20 @@ function UIManager:init()
Device : getPowerDevice ( ) : toggleFrontlight ( )
Device : getPowerDevice ( ) : toggleFrontlight ( )
end
end
self.event_handlers [ " Charging " ] = function ( )
self.event_handlers [ " Charging " ] = function ( )
self : _beforeCharging ( )
-- NOTE: Plug/unplug events will wake the device up, which is why we put it back to sleep.
if Device.screen_saver_mode then
self : suspend ( )
end
end
self.event_handlers [ " NotCharging " ] = function ( )
-- We need to put the device into suspension, other things need to be done before it.
self : _afterNotCharging ( )
if Device.screen_saver_mode then
self : suspend ( )
end
end
self.event_handlers [ " UsbPlugIn " ] = function ( )
self : _beforeCharging ( )
self : _beforeCharging ( )
-- NOTE: Plug/unplug events will wake the device up, which is why we put it back to sleep.
-- NOTE: Plug/unplug events will wake the device up, which is why we put it back to sleep.
if Device.screen_saver_mode then
if Device.screen_saver_mode then
@ -165,7 +179,7 @@ function UIManager:init()
MassStorage : start ( )
MassStorage : start ( )
end
end
end
end
self.event_handlers [ " NotCharging " ] = function ( )
self.event_handlers [ " UsbPlugOut " ] = function ( )
-- We need to put the device into suspension, other things need to be done before it.
-- We need to put the device into suspension, other things need to be done before it.
self : _afterNotCharging ( )
self : _afterNotCharging ( )
if Device.screen_saver_mode then
if Device.screen_saver_mode then
@ -322,7 +336,7 @@ function UIManager:init()
MassStorage : start ( )
MassStorage : start ( )
end
end
end
end
self.event_handlers [ " U S bPlugOut" ] = function ( )
self.event_handlers [ " U s bPlugOut" ] = function ( )
self : _afterNotCharging ( )
self : _afterNotCharging ( )
if Device.screen_saver_mode then
if Device.screen_saver_mode then
self : suspend ( )
self : suspend ( )