2018-02-19 19:36:12 +00:00
|
|
|
from trezor import config, loop, res, ui
|
2017-12-15 20:06:29 +00:00
|
|
|
from trezor.pin import pin_to_int, show_pin_timeout
|
|
|
|
from apps.common.request_pin import request_pin
|
2017-12-14 16:14:15 +00:00
|
|
|
|
|
|
|
|
2018-02-19 19:36:12 +00:00
|
|
|
async def bootscreen():
|
2017-10-24 11:59:09 +00:00
|
|
|
while True:
|
2018-02-19 19:36:12 +00:00
|
|
|
try:
|
|
|
|
if not config.has_pin():
|
|
|
|
config.unlock(pin_to_int(''), show_pin_timeout)
|
|
|
|
return
|
|
|
|
await lockscreen()
|
|
|
|
while True:
|
|
|
|
pin = await request_pin()
|
|
|
|
if config.unlock(pin_to_int(pin), show_pin_timeout):
|
|
|
|
return
|
2018-02-26 23:29:00 +00:00
|
|
|
except: # noqa: E722
|
2018-02-19 19:36:12 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
async def lockscreen():
|
|
|
|
from apps.common import storage
|
|
|
|
|
|
|
|
label = storage.get_label()
|
|
|
|
image = storage.get_homescreen()
|
|
|
|
if not label:
|
|
|
|
label = 'My TREZOR'
|
|
|
|
if not image:
|
|
|
|
image = res.load('apps/homescreen/res/bg.toif')
|
|
|
|
|
|
|
|
await ui.backlight_slide(ui.BACKLIGHT_DIM)
|
|
|
|
|
|
|
|
ui.display.bar(0, 0, 240, 240, ui.WHITE)
|
|
|
|
ui.display.avatar(48, 48, image, ui.BLACK, ui.WHITE)
|
|
|
|
ui.display.text_center(120, 35, label, ui.BOLD, ui.BLACK, ui.WHITE)
|
2017-10-24 11:59:09 +00:00
|
|
|
|
2018-02-19 19:36:12 +00:00
|
|
|
ui.display.text_center(130, 220, 'Tap to unlock', ui.BOLD, ui.DARK_GREY, ui.WHITE)
|
|
|
|
ui.display.icon(45, 202, res.load(ui.ICON_CLICK), ui.DARK_GREY, ui.WHITE)
|
2017-10-24 11:59:09 +00:00
|
|
|
|
2018-02-19 19:36:12 +00:00
|
|
|
await ui.backlight_slide(ui.BACKLIGHT_NORMAL)
|
|
|
|
await ui.click()
|
2017-10-24 11:59:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
config.init()
|
2018-02-19 19:36:12 +00:00
|
|
|
ui.display.backlight(ui.BACKLIGHT_NONE)
|
|
|
|
loop.schedule(bootscreen())
|
2017-10-24 11:59:09 +00:00
|
|
|
loop.run()
|