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:
|
|
|
|
default.close()
|
|
|
|
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()
|
|
|
|
loop.schedule_task(default)
|
|
|
|
ui.display.backlight(ui.BACKLIGHT_NORMAL)
|
2017-09-02 21:10:54 +00:00
|
|
|
log.debug(__name__, 'startdefault')
|