From 67ac47f0873530105947445852df820df406c5f4 Mon Sep 17 00:00:00 2001 From: Jan Pochyla Date: Thu, 20 Oct 2016 15:12:25 +0200 Subject: [PATCH] apps.homescreen: respond with ~correct data, handle GetFeatures --- src/apps/homescreen/__init__.py | 43 +++++++++++++++++---------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/apps/homescreen/__init__.py b/src/apps/homescreen/__init__.py index 08af2c8aa..7d55b1bbb 100644 --- a/src/apps/homescreen/__init__.py +++ b/src/apps/homescreen/__init__.py @@ -1,29 +1,30 @@ from trezor.wire import register_type, protobuf_handler, write_message from trezor.utils import unimport -from trezor.messages.wire_types import Initialize +from trezor.messages.wire_types import Initialize, GetFeatures -@unimport -async def dispatch_Initialize(_, session_id): +async def respond(_, session_id): + from ..common import storage from trezor.messages.Features import Features - features = Features( - revision='deadbeef', - bootloader_hash='deadbeef', - device_id='DEADBEEF', - coins=[], - imported=False, - initialized=False, - label='My TREZOR', - major_version=2, - minor_version=0, - patch_version=0, - pin_cached=False, - pin_protection=True, - passphrase_cached=False, - passphrase_protection=False, - vendor='bitcointrezor.com') - await write_message(session_id, features) + + f = Features() + f.vendor = 'bitcointrezor.com' + f.revision = '0123456789' + f.bootloader_hash = '0123456789' + f.major_version = 2 + f.minor_version = 0 + f.patch_version = 0 + f.coins = [] + + f.device_id = storage.get_device_id() + f.label = storage.get_label() + f.initialized = storage.is_initialized() + f.pin_protection = storage.is_protected_by_pin() + f.passphrase_protection = storage.is_protected_by_passphrase() + + await write_message(session_id, f) def boot(): - register_type(Initialize, protobuf_handler, dispatch_Initialize) + register_type(Initialize, protobuf_handler, respond) + register_type(GetFeatures, protobuf_handler, respond)