From 792dadfc4dd5d77da7195ee2d084830136802f5c Mon Sep 17 00:00:00 2001 From: Andrew Kozlik Date: Tue, 9 Aug 2022 10:11:30 +0200 Subject: [PATCH] feat(common): Add SetBusy message. [no changelog] --- common/protob/messages-management.proto | 10 ++++++++++ common/protob/messages.proto | 1 + core/src/trezor/enums/MessageType.py | 1 + core/src/trezor/enums/__init__.py | 1 + core/src/trezor/messages.py | 16 ++++++++++++++++ legacy/firmware/protob/Makefile | 2 +- python/src/trezorlib/messages.py | 18 ++++++++++++++++++ 7 files changed, 48 insertions(+), 1 deletion(-) diff --git a/common/protob/messages-management.proto b/common/protob/messages-management.proto index ae19c4c67..7006e138e 100644 --- a/common/protob/messages-management.proto +++ b/common/protob/messages-management.proto @@ -111,6 +111,7 @@ message Features { optional uint32 auto_lock_delay_ms = 38; // number of milliseconds after which the device locks itself optional uint32 display_rotation = 39; // in degrees from North optional bool experimental_features = 40; // are experimental message types enabled? + optional bool busy = 41; // is the device busy, showing "Do not disconnect"? } /** @@ -121,6 +122,15 @@ message Features { message LockDevice { } +/** + * Request: Show a "Do not disconnect" dialog instead of the standard homescreen. + * @start + * @next Success + */ +message SetBusy { + optional uint32 expiry_ms = 1; // The time in milliseconds after which the dialog will automatically disappear. Overrides any previously set expiry. If not set, then the dialog is hidden. +} + /** * Request: end the current sesson. Following actions must call Initialize again. * Cache for the current session is discarded, other sessions remain intact. diff --git a/common/protob/messages.proto b/common/protob/messages.proto index 60468bdd7..52d20cd64 100644 --- a/common/protob/messages.proto +++ b/common/protob/messages.proto @@ -87,6 +87,7 @@ enum MessageType { MessageType_Entropy = 10 [(bitcoin_only) = true, (wire_out) = true]; MessageType_LoadDevice = 13 [(bitcoin_only) = true, (wire_in) = true]; MessageType_ResetDevice = 14 [(bitcoin_only) = true, (wire_in) = true]; + MessageType_SetBusy = 16 [(bitcoin_only) = true, (wire_in) = true]; MessageType_Features = 17 [(bitcoin_only) = true, (wire_out) = true]; MessageType_PinMatrixRequest = 18 [(bitcoin_only) = true, (wire_out) = true]; MessageType_PinMatrixAck = 19 [(bitcoin_only) = true, (wire_in) = true, (wire_tiny) = true, (wire_no_fsm) = true]; diff --git a/core/src/trezor/enums/MessageType.py b/core/src/trezor/enums/MessageType.py index d0cece478..aebdd82d2 100644 --- a/core/src/trezor/enums/MessageType.py +++ b/core/src/trezor/enums/MessageType.py @@ -14,6 +14,7 @@ GetEntropy = 9 Entropy = 10 LoadDevice = 13 ResetDevice = 14 +SetBusy = 16 Features = 17 PinMatrixRequest = 18 PinMatrixAck = 19 diff --git a/core/src/trezor/enums/__init__.py b/core/src/trezor/enums/__init__.py index 626c6d937..57fb51a8f 100644 --- a/core/src/trezor/enums/__init__.py +++ b/core/src/trezor/enums/__init__.py @@ -31,6 +31,7 @@ if TYPE_CHECKING: Entropy = 10 LoadDevice = 13 ResetDevice = 14 + SetBusy = 16 Features = 17 PinMatrixRequest = 18 PinMatrixAck = 19 diff --git a/core/src/trezor/messages.py b/core/src/trezor/messages.py index b8d6b9aed..2b625aefe 100644 --- a/core/src/trezor/messages.py +++ b/core/src/trezor/messages.py @@ -2050,6 +2050,7 @@ if TYPE_CHECKING: auto_lock_delay_ms: "int | None" display_rotation: "int | None" experimental_features: "bool | None" + busy: "bool | None" def __init__( self, @@ -2091,6 +2092,7 @@ if TYPE_CHECKING: auto_lock_delay_ms: "int | None" = None, display_rotation: "int | None" = None, experimental_features: "bool | None" = None, + busy: "bool | None" = None, ) -> None: pass @@ -2104,6 +2106,20 @@ if TYPE_CHECKING: def is_type_of(cls, msg: protobuf.MessageType) -> TypeGuard["LockDevice"]: return isinstance(msg, cls) + class SetBusy(protobuf.MessageType): + expiry_ms: "int | None" + + def __init__( + self, + *, + expiry_ms: "int | None" = None, + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: protobuf.MessageType) -> TypeGuard["SetBusy"]: + return isinstance(msg, cls) + class EndSession(protobuf.MessageType): @classmethod diff --git a/legacy/firmware/protob/Makefile b/legacy/firmware/protob/Makefile index d6950d136..e3b1b473b 100644 --- a/legacy/firmware/protob/Makefile +++ b/legacy/firmware/protob/Makefile @@ -5,7 +5,7 @@ endif SKIPPED_MESSAGES := Binance Cardano DebugMonero Eos Monero Ontology Ripple SdProtect Tezos WebAuthn \ DebugLinkRecordScreen DebugLinkEraseSdCard DebugLinkWatchLayout \ GetOwnershipProof OwnershipProof GetOwnershipId OwnershipId AuthorizeCoinJoin DoPreauthorized \ - CancelAuthorization DebugLinkLayout GetNonce \ + CancelAuthorization DebugLinkLayout GetNonce SetBusy \ TxAckInput TxAckOutput TxAckPrev TxAckPaymentRequest \ EthereumSignTypedData EthereumTypedDataStructRequest EthereumTypedDataStructAck \ EthereumTypedDataValueRequest EthereumTypedDataValueAck diff --git a/python/src/trezorlib/messages.py b/python/src/trezorlib/messages.py index b4afc81a5..c34869495 100644 --- a/python/src/trezorlib/messages.py +++ b/python/src/trezorlib/messages.py @@ -39,6 +39,7 @@ class MessageType(IntEnum): Entropy = 10 LoadDevice = 13 ResetDevice = 14 + SetBusy = 16 Features = 17 PinMatrixRequest = 18 PinMatrixAck = 19 @@ -3064,6 +3065,7 @@ class Features(protobuf.MessageType): 38: protobuf.Field("auto_lock_delay_ms", "uint32", repeated=False, required=False), 39: protobuf.Field("display_rotation", "uint32", repeated=False, required=False), 40: protobuf.Field("experimental_features", "bool", repeated=False, required=False), + 41: protobuf.Field("busy", "bool", repeated=False, required=False), } def __init__( @@ -3107,6 +3109,7 @@ class Features(protobuf.MessageType): auto_lock_delay_ms: Optional["int"] = None, display_rotation: Optional["int"] = None, experimental_features: Optional["bool"] = None, + busy: Optional["bool"] = None, ) -> None: self.capabilities: Sequence["Capability"] = capabilities if capabilities is not None else [] self.major_version = major_version @@ -3146,12 +3149,27 @@ class Features(protobuf.MessageType): self.auto_lock_delay_ms = auto_lock_delay_ms self.display_rotation = display_rotation self.experimental_features = experimental_features + self.busy = busy class LockDevice(protobuf.MessageType): MESSAGE_WIRE_TYPE = 24 +class SetBusy(protobuf.MessageType): + MESSAGE_WIRE_TYPE = 16 + FIELDS = { + 1: protobuf.Field("expiry_ms", "uint32", repeated=False, required=False), + } + + def __init__( + self, + *, + expiry_ms: Optional["int"] = None, + ) -> None: + self.expiry_ms = expiry_ms + + class EndSession(protobuf.MessageType): MESSAGE_WIRE_TYPE = 83