1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-08 22:40:59 +00:00

boot: add lockscreen

This commit is contained in:
Jan Pochyla 2018-02-19 20:36:12 +01:00
parent badd0e5677
commit 34f722f2df
2 changed files with 38 additions and 19 deletions

View File

@ -23,8 +23,8 @@ def display_homescreen():
image = res.load('apps/homescreen/res/bg.toif')
ui.display.bar(0, 0, ui.SCREEN, ui.SCREEN, ui.BG)
ui.display.avatar((ui.SCREEN - 144) // 2, (ui.SCREEN - 144) // 2 - 10, image, ui.WHITE, ui.BLACK)
ui.display.text_center(ui.SCREEN // 2, ui.SCREEN - 20, label, ui.BOLD, ui.FG, ui.BG)
ui.display.avatar(48, 48 - 10, image, ui.WHITE, ui.BLACK)
ui.display.text_center(120, 220, label, ui.BOLD, ui.FG, ui.BG)
@unimport

View File

@ -1,28 +1,47 @@
from trezor import config
from trezor import config, loop, res, ui
from trezor.pin import pin_to_int, show_pin_timeout
from trezor import loop
from trezor import ui
from apps.common.request_pin import request_pin
async def unlock_layout():
async def bootscreen():
while True:
if config.has_pin():
pin = await request_pin()
else:
pin = ''
if config.unlock(pin_to_int(pin), show_pin_timeout):
return
else:
await unlock_failed()
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
except:
pass
async def unlock_failed():
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)
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)
await ui.backlight_slide(ui.BACKLIGHT_NORMAL)
await ui.click()
config.init()
ui.display.backlight(ui.BACKLIGHT_DIM)
loop.schedule(unlock_layout())
ui.display.backlight(ui.BACKLIGHT_NONE)
loop.schedule(bootscreen())
loop.run()