1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 22:38:08 +00:00

client: allow setting auto-lock delay

This commit is contained in:
Roman Zeyde 2018-03-13 15:53:57 +02:00 committed by matejcik
parent ab62f5db6f
commit 0a10b53e3a
2 changed files with 20 additions and 1 deletions

View File

@ -210,6 +210,23 @@ def set_passphrase_source(connect, source):
return connect().apply_settings(passphrase_source=source)
@cli.command(help='Set auto-lock delay (in seconds).')
@click.argument('delay', type=str)
@click.pass_obj
def set_auto_lock_delay(connect, delay):
value, unit = delay[:-1], delay[-1:]
units = {
's': 1,
'm': 60,
'h': 3600,
}
if unit in units:
seconds = float(value) * units[unit]
else:
seconds = float(delay) # assume seconds if no unit is specified
return connect().apply_settings(auto_lock_delay_ms=int(seconds * 1000))
@cli.command(help='Set device flags.')
@click.argument('flags')
@click.pass_obj

View File

@ -643,7 +643,7 @@ class ProtocolMixin(object):
@field('message')
@expect(proto.Success)
def apply_settings(self, label=None, language=None, use_passphrase=None, homescreen=None, passphrase_source=None):
def apply_settings(self, label=None, language=None, use_passphrase=None, homescreen=None, passphrase_source=None, auto_lock_delay_ms=None):
settings = proto.ApplySettings()
if label is not None:
settings.label = label
@ -655,6 +655,8 @@ class ProtocolMixin(object):
settings.homescreen = homescreen
if passphrase_source is not None:
settings.passphrase_source = passphrase_source
if auto_lock_delay_ms is not None:
settings.auto_lock_delay_ms = auto_lock_delay_ms
out = self.call(settings)
self.init_device() # Reload Features