trezor-core/src/boot.py

55 lines
1.7 KiB
Python
Raw Normal View History

2018-02-19 11:36:12 -08:00
from trezor import config, loop, res, ui
from trezor.pin import pin_to_int, show_pin_timeout
from apps.common.request_pin import request_pin
2018-02-19 11:36:12 -08:00
async def bootscreen():
2017-10-24 04:59:09 -07:00
while True:
2018-02-19 11:36:12 -08:00
try:
if not config.has_pin():
config.unlock(pin_to_int(''), show_pin_timeout)
return
await lockscreen()
label = None
2018-02-19 11:36:12 -08:00
while True:
pin = await request_pin(label)
2018-02-19 11:36:12 -08:00
if config.unlock(pin_to_int(pin), show_pin_timeout):
return
else:
label = 'Wrong PIN, enter again'
except: # noqa: E722
2018-02-19 11:36:12 -08: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)
2018-02-27 06:34:13 -08:00
ui.display.clear()
ui.display.avatar(48, 48, image, ui.TITLE_GREY, ui.BG)
2018-02-28 16:13:26 -08:00
ui.display.text_center(ui.WIDTH // 2, 35, label, ui.BOLD, ui.TITLE_GREY, ui.BG)
2018-02-27 06:34:13 -08:00
ui.display.bar_radius(40, 100, 160, 40, ui.TITLE_GREY, ui.BG, 4)
ui.display.bar_radius(42, 102, 156, 36, ui.BG, ui.TITLE_GREY, 4)
2018-02-28 16:13:26 -08:00
ui.display.text_center(ui.WIDTH // 2, 128, 'Locked', ui.BOLD, ui.TITLE_GREY, ui.BG)
2018-02-27 06:34:13 -08:00
2018-02-28 16:13:26 -08:00
ui.display.text_center(ui.WIDTH // 2 + 10, 220, 'Tap to unlock', ui.BOLD, ui.TITLE_GREY, ui.BG)
2018-02-27 06:34:13 -08:00
ui.display.icon(45, 202, res.load(ui.ICON_CLICK), ui.TITLE_GREY, ui.BG)
2017-10-24 04:59:09 -07:00
2018-02-19 11:36:12 -08:00
await ui.backlight_slide(ui.BACKLIGHT_NORMAL)
await ui.click()
2017-10-24 04:59:09 -07:00
config.init()
2018-02-19 11:36:12 -08:00
ui.display.backlight(ui.BACKLIGHT_NONE)
loop.schedule(bootscreen())
2017-10-24 04:59:09 -07:00
loop.run()