2017-08-16 13:02:03 +00:00
|
|
|
from trezor import log
|
|
|
|
from trezor import loop
|
|
|
|
from trezor import ui
|
2016-09-21 12:21:18 +00:00
|
|
|
|
2017-08-16 13:02:03 +00:00
|
|
|
started = []
|
|
|
|
default = None
|
|
|
|
default_handler = None
|
2016-09-21 12:21:18 +00:00
|
|
|
|
|
|
|
|
2017-08-16 13:02:03 +00:00
|
|
|
def onstart(w):
|
|
|
|
closedefault()
|
|
|
|
started.append(w)
|
2017-05-31 17:29:04 +00:00
|
|
|
ui.display.backlight(ui.BACKLIGHT_NORMAL)
|
2017-08-16 13:02:03 +00:00
|
|
|
log.debug(__name__, 'onstart: %s', w)
|
2016-09-21 12:21:18 +00:00
|
|
|
|
|
|
|
|
2017-08-16 13:02:03 +00:00
|
|
|
def onclose(w):
|
|
|
|
started.remove(w)
|
|
|
|
log.debug(__name__, 'onclose: %s', w)
|
2016-10-06 10:35:05 +00:00
|
|
|
|
2017-08-16 13:02:03 +00:00
|
|
|
if not started and default_handler:
|
|
|
|
startdefault(default_handler)
|
|
|
|
|
|
|
|
|
|
|
|
def closedefault():
|
|
|
|
global default
|
|
|
|
|
|
|
|
if default:
|
2017-10-10 13:32:43 +00:00
|
|
|
loop.close(default)
|
2017-08-16 13:02:03 +00:00
|
|
|
default = None
|
|
|
|
log.debug(__name__, 'closedefault')
|
2016-09-21 12:21:18 +00:00
|
|
|
|
|
|
|
|
2017-08-16 13:02:03 +00:00
|
|
|
def startdefault(handler):
|
|
|
|
global default
|
|
|
|
global default_handler
|
2016-09-21 12:21:18 +00:00
|
|
|
|
2017-08-16 13:02:03 +00:00
|
|
|
if not default:
|
|
|
|
default_handler = handler
|
|
|
|
default = handler()
|
2017-09-16 13:00:31 +00:00
|
|
|
loop.schedule(default)
|
2017-08-16 13:02:03 +00:00
|
|
|
ui.display.backlight(ui.BACKLIGHT_NORMAL)
|
2017-09-02 21:10:54 +00:00
|
|
|
log.debug(__name__, 'startdefault')
|