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

feat: drop DebugLinkShowText functionality

This commit is contained in:
matejcik 2021-03-17 11:24:55 +01:00
parent 56ee7d33a9
commit cb7152542d
18 changed files with 3 additions and 310 deletions

View File

@ -58,32 +58,6 @@ message DebugLinkRecordScreen {
optional string target_directory = 1; // empty or missing to stop recording optional string target_directory = 1; // empty or missing to stop recording
} }
/**
* Request: Show text on the screen
* @start
* @next Success
*/
message DebugLinkShowText {
optional string header_text = 1; // screen header text
repeated DebugLinkShowTextItem body_text = 2; // body text segments
optional string header_icon = 3; // icon name in ui.style
optional string icon_color = 4; // color name in ui.style
message DebugLinkShowTextItem {
optional DebugLinkShowTextStyle style = 1;
optional string content = 2;
}
enum DebugLinkShowTextStyle {
NORMAL = 0;
BOLD = 1;
MONO = 2;
BR = 4;
BR_HALF = 5;
SET_COLOR = 6;
}
}
/** /**
* Request: Computer asks for device state * Request: Computer asks for device state
* @start * @start

View File

@ -136,7 +136,6 @@ enum MessageType {
MessageType_DebugLinkLayout = 9001 [(wire_debug_out) = true]; MessageType_DebugLinkLayout = 9001 [(wire_debug_out) = true];
MessageType_DebugLinkReseedRandom = 9002 [(wire_debug_in) = true]; MessageType_DebugLinkReseedRandom = 9002 [(wire_debug_in) = true];
MessageType_DebugLinkRecordScreen = 9003 [(wire_debug_in) = true]; MessageType_DebugLinkRecordScreen = 9003 [(wire_debug_in) = true];
MessageType_DebugLinkShowText = 9004 [(wire_debug_in) = true];
MessageType_DebugLinkEraseSdCard = 9005 [(wire_debug_in) = true]; MessageType_DebugLinkEraseSdCard = 9005 [(wire_debug_in) = true];
MessageType_DebugLinkWatchLayout = 9006 [(wire_debug_in) = true]; MessageType_DebugLinkWatchLayout = 9006 [(wire_debug_in) = true];

View File

@ -57,6 +57,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Removed ### Removed
- PIVX support - PIVX support
- dropped debug-only `DebugLinkShowText` functionality
### Fixed ### Fixed
- Path warning is not shown on `GetAddress(show_display=False)` call. [#1206] - Path warning is not shown on `GetAddress(show_display=False)` call. [#1206]

View File

@ -185,7 +185,6 @@ if __debug__:
config.wipe() config.wipe()
wire.add(MessageType.LoadDevice, __name__, "load_device") wire.add(MessageType.LoadDevice, __name__, "load_device")
wire.add(MessageType.DebugLinkShowText, __name__, "show_text")
wire.register(MessageType.DebugLinkDecision, dispatch_DebugLinkDecision) # type: ignore wire.register(MessageType.DebugLinkDecision, dispatch_DebugLinkDecision) # type: ignore
wire.register(MessageType.DebugLinkGetState, dispatch_DebugLinkGetState) wire.register(MessageType.DebugLinkGetState, dispatch_DebugLinkGetState)
wire.register(MessageType.DebugLinkReseedRandom, dispatch_DebugLinkReseedRandom) wire.register(MessageType.DebugLinkReseedRandom, dispatch_DebugLinkReseedRandom)

View File

@ -1,49 +0,0 @@
import trezor.messages.DebugLinkShowTextStyle as S
from trezor import ui, wire
from trezor.messages.DebugLinkShowText import DebugLinkShowText
from trezor.messages.Success import Success
from trezor.ui import style, text
from trezor.ui.components.tt.text import Text
from apps.common.confirm import confirm
STYLES = {
S.NORMAL: ui.NORMAL,
S.BOLD: ui.BOLD,
S.MONO: ui.MONO,
S.BR: text.BR,
S.BR_HALF: text.BR_HALF,
}
async def show_text(ctx: wire.Context, msg: DebugLinkShowText) -> Success:
if msg.header_icon is not None:
icon_name = "ICON_" + msg.header_icon
icon = getattr(style, icon_name)
if not isinstance(icon, str):
raise wire.DataError("Invalid icon name: {}".format(msg.header_icon))
else:
icon = style.ICON_DEFAULT
if msg.icon_color is not None:
color = getattr(style, msg.icon_color)
if not isinstance(color, int):
raise wire.DataError("Invalid color name: {}".format(msg.icon_color))
else:
color = style.ORANGE_ICON
dlg = Text(msg.header_text, icon, color, new_lines=False)
for item in msg.body_text:
if item.style in STYLES:
dlg.content.append(STYLES[item.style])
elif item.style == S.SET_COLOR:
color = getattr(style, item.content)
if not isinstance(color, int):
raise wire.DataError("Invalid color name: {}".format(item.content))
dlg.content.append(color)
elif item.content is not None:
dlg.content.append(item.content)
await confirm(ctx, dlg)
return Success("text shown")

View File

@ -1,38 +0,0 @@
# Automatically generated by pb2py
# fmt: off
import protobuf as p
from .DebugLinkShowTextItem import DebugLinkShowTextItem
if __debug__:
try:
from typing import Dict, List # noqa: F401
from typing_extensions import Literal # noqa: F401
except ImportError:
pass
class DebugLinkShowText(p.MessageType):
MESSAGE_WIRE_TYPE = 9004
def __init__(
self,
*,
body_text: List[DebugLinkShowTextItem] = None,
header_text: str = None,
header_icon: str = None,
icon_color: str = None,
) -> None:
self.body_text = body_text if body_text is not None else []
self.header_text = header_text
self.header_icon = header_icon
self.icon_color = icon_color
@classmethod
def get_fields(cls) -> Dict:
return {
1: ('header_text', p.UnicodeType, None),
2: ('body_text', DebugLinkShowTextItem, p.FLAG_REPEATED),
3: ('header_icon', p.UnicodeType, None),
4: ('icon_color', p.UnicodeType, None),
}

View File

@ -1,30 +0,0 @@
# Automatically generated by pb2py
# fmt: off
import protobuf as p
if __debug__:
try:
from typing import Dict, List # noqa: F401
from typing_extensions import Literal # noqa: F401
EnumTypeDebugLinkShowTextStyle = Literal[0, 1, 2, 4, 5, 6]
except ImportError:
pass
class DebugLinkShowTextItem(p.MessageType):
def __init__(
self,
*,
style: EnumTypeDebugLinkShowTextStyle = None,
content: str = None,
) -> None:
self.style = style
self.content = content
@classmethod
def get_fields(cls) -> Dict:
return {
1: ('style', p.EnumType("DebugLinkShowTextStyle", (0, 1, 2, 4, 5, 6)), None),
2: ('content', p.UnicodeType, None),
}

View File

@ -1,14 +0,0 @@
# Automatically generated by pb2py
# fmt: off
if __debug__:
try:
from typing_extensions import Literal # noqa: F401
except ImportError:
pass
NORMAL: Literal[0] = 0
BOLD: Literal[1] = 1
MONO: Literal[2] = 2
BR: Literal[4] = 4
BR_HALF: Literal[5] = 5
SET_COLOR: Literal[6] = 6

View File

@ -89,7 +89,6 @@ DebugLinkFlashErase: Literal[113] = 113
DebugLinkLayout: Literal[9001] = 9001 DebugLinkLayout: Literal[9001] = 9001
DebugLinkReseedRandom: Literal[9002] = 9002 DebugLinkReseedRandom: Literal[9002] = 9002
DebugLinkRecordScreen: Literal[9003] = 9003 DebugLinkRecordScreen: Literal[9003] = 9003
DebugLinkShowText: Literal[9004] = 9004
DebugLinkEraseSdCard: Literal[9005] = 9005 DebugLinkEraseSdCard: Literal[9005] = 9005
DebugLinkWatchLayout: Literal[9006] = 9006 DebugLinkWatchLayout: Literal[9006] = 9006
if not utils.BITCOIN_ONLY: if not utils.BITCOIN_ONLY:

View File

@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed ### Removed
- dropped Python 3.5 support [#810] - dropped Python 3.5 support [#810]
- dropped debug-only `trezorctl debug show-text` functionality
## [0.12.2] - 2020-08-27 ## [0.12.2] - 2020-08-27

View File

@ -16,9 +16,7 @@
import click import click
from .. import debuglink, mapping, messages, protobuf from .. import mapping, messages, protobuf
from ..messages import DebugLinkShowTextStyle as S
from . import with_client
@click.group(name="debug") @click.group(name="debug")
@ -26,51 +24,6 @@ def cli():
"""Miscellaneous debug features.""" """Miscellaneous debug features."""
STYLES = {
"@@NORMAL": S.NORMAL,
"@@BOLD": S.BOLD,
"@@MONO": S.MONO,
"@@BR": S.BR,
"@@BR_HALF": S.BR_HALF,
}
@cli.command()
@click.option("-i", "--icon", help="Header icon name")
@click.option("-c", "--color", help="Header icon color")
@click.option("-h", "--header", help="Header text", default="Showing text")
@click.argument("body")
@with_client
def show_text(client, icon, color, header, body):
"""Show text on Trezor display.
For usage instructions, see:
https://github.com/trezor/trezor-firmware/blob/master/docs/python/show-text.md
"""
body = body.split()
body_text = []
words = []
def _flush():
if words:
body_text.append((None, " ".join(words)))
words.clear()
for word in body:
if word in STYLES:
_flush()
body_text.append((STYLES[word], None))
elif word.startswith("%%"):
_flush()
body_text.append((S.SET_COLOR, word[2:]))
else:
words.append(word)
_flush()
return debuglink.show_text(client, header, body_text, icon=icon, icon_color=color)
@cli.command() @cli.command()
@click.argument("message_name_or_type") @click.argument("message_name_or_type")
@click.argument("hex_data") @click.argument("hex_data")

View File

@ -63,7 +63,6 @@ COMMAND_ALIASES = {
"sd-protect": device.sd_protect, "sd-protect": device.sd_protect,
"load-device": device.load, "load-device": device.load,
"self-test": device.self_test, "self-test": device.self_test,
"show-text": debug.show_text,
"get-entropy": crypto.get_entropy, "get-entropy": crypto.get_entropy,
"encrypt-keyvalue": crypto.encrypt_keyvalue, "encrypt-keyvalue": crypto.encrypt_keyvalue,
"decrypt-keyvalue": crypto.decrypt_keyvalue, "decrypt-keyvalue": crypto.decrypt_keyvalue,

View File

@ -664,18 +664,3 @@ def self_test(client):
payload=b"\x00\xFF\x55\xAA\x66\x99\x33\xCCABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!\x00\xFF\x55\xAA\x66\x99\x33\xCC" payload=b"\x00\xFF\x55\xAA\x66\x99\x33\xCCABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!\x00\xFF\x55\xAA\x66\x99\x33\xCC"
) )
) )
@expect(messages.Success, field="message")
def show_text(client, header_text, body_text, icon=None, icon_color=None):
body_text = [
messages.DebugLinkShowTextItem(style=style, content=content)
for style, content in body_text
]
msg = messages.DebugLinkShowText(
header_text=header_text,
body_text=body_text,
header_icon=icon,
icon_color=icon_color,
)
return client.call(msg)

View File

@ -1,38 +0,0 @@
# Automatically generated by pb2py
# fmt: off
from .. import protobuf as p
from .DebugLinkShowTextItem import DebugLinkShowTextItem
if __debug__:
try:
from typing import Dict, List # noqa: F401
from typing_extensions import Literal # noqa: F401
except ImportError:
pass
class DebugLinkShowText(p.MessageType):
MESSAGE_WIRE_TYPE = 9004
def __init__(
self,
*,
body_text: List[DebugLinkShowTextItem] = None,
header_text: str = None,
header_icon: str = None,
icon_color: str = None,
) -> None:
self.body_text = body_text if body_text is not None else []
self.header_text = header_text
self.header_icon = header_icon
self.icon_color = icon_color
@classmethod
def get_fields(cls) -> Dict:
return {
1: ('header_text', p.UnicodeType, None),
2: ('body_text', DebugLinkShowTextItem, p.FLAG_REPEATED),
3: ('header_icon', p.UnicodeType, None),
4: ('icon_color', p.UnicodeType, None),
}

View File

@ -1,30 +0,0 @@
# Automatically generated by pb2py
# fmt: off
from .. import protobuf as p
if __debug__:
try:
from typing import Dict, List # noqa: F401
from typing_extensions import Literal # noqa: F401
EnumTypeDebugLinkShowTextStyle = Literal[0, 1, 2, 4, 5, 6]
except ImportError:
pass
class DebugLinkShowTextItem(p.MessageType):
def __init__(
self,
*,
style: EnumTypeDebugLinkShowTextStyle = None,
content: str = None,
) -> None:
self.style = style
self.content = content
@classmethod
def get_fields(cls) -> Dict:
return {
1: ('style', p.EnumType("DebugLinkShowTextStyle", (0, 1, 2, 4, 5, 6)), None),
2: ('content', p.UnicodeType, None),
}

View File

@ -1,14 +0,0 @@
# Automatically generated by pb2py
# fmt: off
if __debug__:
try:
from typing_extensions import Literal # noqa: F401
except ImportError:
pass
NORMAL: Literal[0] = 0
BOLD: Literal[1] = 1
MONO: Literal[2] = 2
BR: Literal[4] = 4
BR_HALF: Literal[5] = 5
SET_COLOR: Literal[6] = 6

View File

@ -87,7 +87,6 @@ DebugLinkFlashErase: Literal[113] = 113
DebugLinkLayout: Literal[9001] = 9001 DebugLinkLayout: Literal[9001] = 9001
DebugLinkReseedRandom: Literal[9002] = 9002 DebugLinkReseedRandom: Literal[9002] = 9002
DebugLinkRecordScreen: Literal[9003] = 9003 DebugLinkRecordScreen: Literal[9003] = 9003
DebugLinkShowText: Literal[9004] = 9004
DebugLinkEraseSdCard: Literal[9005] = 9005 DebugLinkEraseSdCard: Literal[9005] = 9005
DebugLinkWatchLayout: Literal[9006] = 9006 DebugLinkWatchLayout: Literal[9006] = 9006
EthereumGetPublicKey: Literal[450] = 450 EthereumGetPublicKey: Literal[450] = 450

View File

@ -59,8 +59,6 @@ from .DebugLinkMemoryRead import DebugLinkMemoryRead
from .DebugLinkMemoryWrite import DebugLinkMemoryWrite from .DebugLinkMemoryWrite import DebugLinkMemoryWrite
from .DebugLinkRecordScreen import DebugLinkRecordScreen from .DebugLinkRecordScreen import DebugLinkRecordScreen
from .DebugLinkReseedRandom import DebugLinkReseedRandom from .DebugLinkReseedRandom import DebugLinkReseedRandom
from .DebugLinkShowText import DebugLinkShowText
from .DebugLinkShowTextItem import DebugLinkShowTextItem
from .DebugLinkState import DebugLinkState from .DebugLinkState import DebugLinkState
from .DebugLinkStop import DebugLinkStop from .DebugLinkStop import DebugLinkStop
from .DebugLinkWatchLayout import DebugLinkWatchLayout from .DebugLinkWatchLayout import DebugLinkWatchLayout
@ -312,7 +310,6 @@ from . import Capability
from . import CardanoAddressType from . import CardanoAddressType
from . import CardanoCertificateType from . import CardanoCertificateType
from . import CardanoPoolRelayType from . import CardanoPoolRelayType
from . import DebugLinkShowTextStyle
from . import DebugSwipeDirection from . import DebugSwipeDirection
from . import DecredStakingSpendType from . import DecredStakingSpendType
from . import FailureType from . import FailureType