feat(common): Add INFO button to DebugLinkDecision.

[no changelog]
pull/2074/head
Andrew Kozlik 2 years ago committed by matejcik
parent b35e6ca5c4
commit ba4f046d6f

@ -17,7 +17,7 @@ import "messages-management.proto";
* @next DebugLinkLayout
*/
message DebugLinkDecision {
optional bool yes_no = 1; // true for "Confirm", false for "Cancel"
optional DebugButton button = 1; // button press
optional DebugSwipeDirection swipe = 2; // swipe direction
optional string input = 3; // keyboard input
/**
@ -30,6 +30,15 @@ message DebugLinkDecision {
RIGHT = 3;
}
/**
* Structure representing button presses
*/
enum DebugButton {
NO = 0;
YES = 1;
INFO = 2;
}
optional uint32 x = 4; // touch X coordinate
optional uint32 y = 5; // touch Y coordinate
optional bool wait = 6; // wait for layout change

@ -94,6 +94,8 @@ trezor.enums.ButtonRequestType
import trezor.enums.ButtonRequestType
trezor.enums.Capability
import trezor.enums.Capability
trezor.enums.DebugButton
import trezor.enums.DebugButton
trezor.enums.DebugSwipeDirection
import trezor.enums.DebugSwipeDirection
trezor.enums.DecredStakingSpendType

@ -62,14 +62,18 @@ if __debug__:
layout_change_chan.publish(storage.current_content)
async def dispatch_debuglink_decision(msg: DebugLinkDecision) -> None:
from trezor.enums import DebugButton
from trezor.enums import DebugSwipeDirection
from trezor.ui import Result
from trezor.ui.components.tt import confirm, swipe
if msg.yes_no is not None:
await confirm_chan.put(
Result(confirm.CONFIRMED if msg.yes_no else confirm.CANCELLED)
)
if msg.button is not None:
if msg.button == DebugButton.NO:
await confirm_chan.put(Result(confirm.CANCELLED))
elif msg.button == DebugButton.YES:
await confirm_chan.put(Result(confirm.CONFIRMED))
elif msg.button == DebugButton.INFO:
await confirm_chan.put(Result(confirm.INFO))
if msg.swipe is not None:
if msg.swipe == DebugSwipeDirection.UP:
await swipe_chan.put(swipe.SWIPE_UP)

@ -0,0 +1,7 @@
# Automatically generated by pb2py
# fmt: off
# isort:skip_file
NO = 0
YES = 1
INFO = 2

@ -429,6 +429,11 @@ if TYPE_CHECKING:
LEFT = 2
RIGHT = 3
class DebugButton(IntEnum):
NO = 0
YES = 1
INFO = 2
class EthereumDataType(IntEnum):
UINT = 1
INT = 2

@ -32,6 +32,7 @@ if TYPE_CHECKING:
from trezor.enums import CardanoTxAuxiliaryDataSupplementType # noqa: F401
from trezor.enums import CardanoTxSigningMode # noqa: F401
from trezor.enums import CardanoTxWitnessType # noqa: F401
from trezor.enums import DebugButton # noqa: F401
from trezor.enums import DebugSwipeDirection # noqa: F401
from trezor.enums import DecredStakingSpendType # noqa: F401
from trezor.enums import EthereumDataType # noqa: F401
@ -2258,7 +2259,7 @@ if TYPE_CHECKING:
return isinstance(msg, cls)
class DebugLinkDecision(protobuf.MessageType):
yes_no: "bool | None"
button: "DebugButton | None"
swipe: "DebugSwipeDirection | None"
input: "str | None"
x: "int | None"
@ -2269,7 +2270,7 @@ if TYPE_CHECKING:
def __init__(
self,
*,
yes_no: "bool | None" = None,
button: "DebugButton | None" = None,
swipe: "DebugSwipeDirection | None" = None,
input: "str | None" = None,
x: "int | None" = None,

@ -91,7 +91,7 @@ bool protectButton(ButtonRequestType type, bool confirm_only) {
if (msg_tiny_id == MessageType_MessageType_DebugLinkDecision) {
msg_tiny_id = 0xFFFF;
DebugLinkDecision *dld = (DebugLinkDecision *)msg_tiny;
result = dld->yes_no;
result = dld->button;
debug_decided = true;
}

@ -0,0 +1 @@
Add press_info() to DebugLink.

@ -147,7 +147,7 @@ class DebugLink:
def input(
self,
word: Optional[str] = None,
button: Optional[bool] = None,
button: Optional[messages.DebugButton] = None,
swipe: Optional[messages.DebugSwipeDirection] = None,
x: Optional[int] = None,
y: Optional[int] = None,
@ -162,7 +162,7 @@ class DebugLink:
raise ValueError("Invalid input - must use one of word, button, swipe")
decision = messages.DebugLinkDecision(
yes_no=button, swipe=swipe, input=word, x=x, y=y, wait=wait, hold_ms=hold_ms
button=button, swipe=swipe, input=word, x=x, y=y, wait=wait, hold_ms=hold_ms
)
ret = self._call(decision, nowait=not wait)
if ret is not None:
@ -177,10 +177,13 @@ class DebugLink:
return self.input(x=x, y=y, wait=wait)
def press_yes(self) -> None:
self.input(button=True)
self.input(button=messages.DebugButton.YES)
def press_no(self) -> None:
self.input(button=False)
self.input(button=messages.DebugButton.NO)
def press_info(self) -> None:
self.input(button=messages.DebugButton.INFO)
def swipe_up(self, wait: bool = False) -> None:
self.input(swipe=messages.DebugSwipeDirection.UP, wait=wait)

@ -462,6 +462,12 @@ class DebugSwipeDirection(IntEnum):
RIGHT = 3
class DebugButton(IntEnum):
NO = 0
YES = 1
INFO = 2
class EthereumDataType(IntEnum):
UINT = 1
INT = 2
@ -3529,7 +3535,7 @@ class RebootToBootloader(protobuf.MessageType):
class DebugLinkDecision(protobuf.MessageType):
MESSAGE_WIRE_TYPE = 100
FIELDS = {
1: protobuf.Field("yes_no", "bool", repeated=False, required=False),
1: protobuf.Field("button", "DebugButton", repeated=False, required=False),
2: protobuf.Field("swipe", "DebugSwipeDirection", repeated=False, required=False),
3: protobuf.Field("input", "string", repeated=False, required=False),
4: protobuf.Field("x", "uint32", repeated=False, required=False),
@ -3541,7 +3547,7 @@ class DebugLinkDecision(protobuf.MessageType):
def __init__(
self,
*,
yes_no: Optional["bool"] = None,
button: Optional["DebugButton"] = None,
swipe: Optional["DebugSwipeDirection"] = None,
input: Optional["str"] = None,
x: Optional["int"] = None,
@ -3549,7 +3555,7 @@ class DebugLinkDecision(protobuf.MessageType):
wait: Optional["bool"] = None,
hold_ms: Optional["int"] = None,
) -> None:
self.yes_no = yes_no
self.button = button
self.swipe = swipe
self.input = input
self.x = x

@ -126,7 +126,7 @@ def send_clicks(dest):
echo("Please wait...")
if key == "confirm":
output = "debug.input(button=True)"
output = "debug.input(button=messages.DebugButton.YES)"
DEBUGLINK.press_yes()
elif key in "uj":
output = "debug.input(swipe=messages.DebugSwipeDirection.UP)"

@ -49,7 +49,7 @@ int DEV_touch(struct U2Fob* device) {
return 0;
}
sleep(1);
// send DebugLinkDecision{yes_no=True} to DebugLink interface
// send DebugLinkDecision{button=DebugButton.YES} to DebugLink interface
hid_write(device->dev_debug, (const uint8_t *)"\x00?##\x00" "d\x00\x00\x00\x02\x08\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 65);
sleep(1);
return 1;

Loading…
Cancel
Save