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

chore(core): Use enum for for dealing with device rotations

This commit is contained in:
Lukas Bielesch 2024-08-27 16:20:26 +02:00 committed by Lukáš Bielesch
parent 6d391aa9ac
commit a4da695430
13 changed files with 225 additions and 96 deletions

View File

@ -0,0 +1 @@
Enum for valid device rotations

View File

@ -111,6 +111,8 @@ trezor.enums.DebugWaitType
import trezor.enums.DebugWaitType import trezor.enums.DebugWaitType
trezor.enums.DecredStakingSpendType trezor.enums.DecredStakingSpendType
import trezor.enums.DecredStakingSpendType import trezor.enums.DecredStakingSpendType
trezor.enums.DisplayRotation
import trezor.enums.DisplayRotation
trezor.enums.FailureType trezor.enums.FailureType
import trezor.enums.FailureType import trezor.enums.FailureType
trezor.enums.HomescreenFormat trezor.enums.HomescreenFormat

View File

@ -3,7 +3,7 @@ from typing import TYPE_CHECKING
import storage.device as storage_device import storage.device as storage_device
import trezorui2 import trezorui2
from trezor import TR, utils from trezor import TR, utils
from trezor.enums import ButtonRequestType from trezor.enums import ButtonRequestType, DisplayRotation
from trezor.ui.layouts import confirm_action from trezor.ui.layouts import confirm_action
from trezor.wire import DataError from trezor.wire import DataError
@ -167,17 +167,17 @@ async def _require_confirm_change_passphrase_source(
await confirm_change_passphrase_source(passphrase_always_on_device) await confirm_change_passphrase_source(passphrase_always_on_device)
async def _require_confirm_change_display_rotation(rotation: int) -> None: async def _require_confirm_change_display_rotation(rotation: DisplayRotation) -> None:
if rotation == 0: if rotation == DisplayRotation.North:
label = TR.rotation__north label = TR.rotation__north
elif rotation == 90: elif rotation == DisplayRotation.East:
label = TR.rotation__east label = TR.rotation__east
elif rotation == 180: elif rotation == DisplayRotation.South:
label = TR.rotation__south label = TR.rotation__south
elif rotation == 270: elif rotation == DisplayRotation.West:
label = TR.rotation__west label = TR.rotation__west
else: else:
raise DataError("Unsupported display rotation") raise RuntimeError # Unsupported display rotation
await confirm_action( await confirm_action(
"set_rotation", "set_rotation",

View File

@ -5,7 +5,7 @@ from storage import common
from trezor import utils from trezor import utils
if TYPE_CHECKING: if TYPE_CHECKING:
from trezor.enums import BackupType from trezor.enums import BackupType, DisplayRotation
from typing_extensions import Literal from typing_extensions import Literal
# Namespace: # Namespace:
@ -95,16 +95,27 @@ def get_device_id() -> str:
return dev_id.decode() return dev_id.decode()
def get_rotation() -> int: def get_rotation() -> DisplayRotation:
from trezor.enums import DisplayRotation
rotation = common.get(_NAMESPACE, _ROTATION, public=True) rotation = common.get(_NAMESPACE, _ROTATION, public=True)
if not rotation: if not rotation:
return 0 return DisplayRotation.North # Default to North if no rotation is set
return int.from_bytes(rotation, "big")
value = int.from_bytes(rotation, "big")
if value == 90:
rotation = DisplayRotation.East
elif value == 180:
rotation = DisplayRotation.South
elif value == 270:
rotation = DisplayRotation.West
else:
rotation = DisplayRotation.North
return rotation
def set_rotation(value: int) -> None: def set_rotation(value: DisplayRotation) -> None:
if value not in (0, 90, 180, 270):
raise ValueError # unsupported display rotation
common.set(_NAMESPACE, _ROTATION, value.to_bytes(2, "big"), True) # public common.set(_NAMESPACE, _ROTATION, value.to_bytes(2, "big"), True) # public

View File

@ -0,0 +1,8 @@
# Automatically generated by pb2py
# fmt: off
# isort:skip_file
North = 0
East = 90
South = 180
West = 270

View File

@ -193,6 +193,12 @@ if TYPE_CHECKING:
PromptAlways = 1 PromptAlways = 1
PromptTemporarily = 2 PromptTemporarily = 2
class DisplayRotation(IntEnum):
North = 0
East = 90
South = 180
West = 270
class HomescreenFormat(IntEnum): class HomescreenFormat(IntEnum):
Toif = 1 Toif = 1
Jpeg = 2 Jpeg = 2

View File

@ -42,6 +42,7 @@ if TYPE_CHECKING:
from trezor.enums import DebugSwipeDirection # noqa: F401 from trezor.enums import DebugSwipeDirection # noqa: F401
from trezor.enums import DebugWaitType # noqa: F401 from trezor.enums import DebugWaitType # noqa: F401
from trezor.enums import DecredStakingSpendType # noqa: F401 from trezor.enums import DecredStakingSpendType # noqa: F401
from trezor.enums import DisplayRotation # noqa: F401
from trezor.enums import EthereumDataType # noqa: F401 from trezor.enums import EthereumDataType # noqa: F401
from trezor.enums import EthereumDefinitionType # noqa: F401 from trezor.enums import EthereumDefinitionType # noqa: F401
from trezor.enums import FailureType # noqa: F401 from trezor.enums import FailureType # noqa: F401
@ -2142,7 +2143,7 @@ if TYPE_CHECKING:
passphrase_always_on_device: "bool | None" passphrase_always_on_device: "bool | None"
safety_checks: "SafetyCheckLevel | None" safety_checks: "SafetyCheckLevel | None"
auto_lock_delay_ms: "int | None" auto_lock_delay_ms: "int | None"
display_rotation: "int | None" display_rotation: "DisplayRotation | None"
experimental_features: "bool | None" experimental_features: "bool | None"
busy: "bool | None" busy: "bool | None"
homescreen_format: "HomescreenFormat | None" homescreen_format: "HomescreenFormat | None"
@ -2197,7 +2198,7 @@ if TYPE_CHECKING:
passphrase_always_on_device: "bool | None" = None, passphrase_always_on_device: "bool | None" = None,
safety_checks: "SafetyCheckLevel | None" = None, safety_checks: "SafetyCheckLevel | None" = None,
auto_lock_delay_ms: "int | None" = None, auto_lock_delay_ms: "int | None" = None,
display_rotation: "int | None" = None, display_rotation: "DisplayRotation | None" = None,
experimental_features: "bool | None" = None, experimental_features: "bool | None" = None,
busy: "bool | None" = None, busy: "bool | None" = None,
homescreen_format: "HomescreenFormat | None" = None, homescreen_format: "HomescreenFormat | None" = None,
@ -2251,7 +2252,7 @@ if TYPE_CHECKING:
use_passphrase: "bool | None" use_passphrase: "bool | None"
homescreen: "bytes | None" homescreen: "bytes | None"
auto_lock_delay_ms: "int | None" auto_lock_delay_ms: "int | None"
display_rotation: "int | None" display_rotation: "DisplayRotation | None"
passphrase_always_on_device: "bool | None" passphrase_always_on_device: "bool | None"
safety_checks: "SafetyCheckLevel | None" safety_checks: "SafetyCheckLevel | None"
experimental_features: "bool | None" experimental_features: "bool | None"
@ -2265,7 +2266,7 @@ if TYPE_CHECKING:
use_passphrase: "bool | None" = None, use_passphrase: "bool | None" = None,
homescreen: "bytes | None" = None, homescreen: "bytes | None" = None,
auto_lock_delay_ms: "int | None" = None, auto_lock_delay_ms: "int | None" = None,
display_rotation: "int | None" = None, display_rotation: "DisplayRotation | None" = None,
passphrase_always_on_device: "bool | None" = None, passphrase_always_on_device: "bool | None" = None,
safety_checks: "SafetyCheckLevel | None" = None, safety_checks: "SafetyCheckLevel | None" = None,
experimental_features: "bool | None" = None, experimental_features: "bool | None" = None,

View File

@ -0,0 +1 @@
Enum for valid device rotations

View File

@ -36,7 +36,13 @@ try:
except ImportError: except ImportError:
PIL_AVAILABLE = False PIL_AVAILABLE = False
ROTATION = {"north": 0, "east": 90, "south": 180, "west": 270} ROTATION = {
"north": messages.DisplayRotation.North,
"east": messages.DisplayRotation.East,
"south": messages.DisplayRotation.South,
"west": messages.DisplayRotation.West,
}
SAFETY_LEVELS = { SAFETY_LEVELS = {
"strict": messages.SafetyCheckLevel.Strict, "strict": messages.SafetyCheckLevel.Strict,
"prompt": messages.SafetyCheckLevel.PromptTemporarily, "prompt": messages.SafetyCheckLevel.PromptTemporarily,
@ -261,7 +267,7 @@ def language(
@cli.command() @cli.command()
@click.argument("rotation", type=ChoiceType(ROTATION)) @click.argument("rotation", type=ChoiceType(ROTATION))
@with_client @with_client
def display_rotation(client: "TrezorClient", rotation: int) -> str: def display_rotation(client: "TrezorClient", rotation: messages.DisplayRotation) -> str:
"""Set display rotation. """Set display rotation.
Configure display rotation for Trezor Model T. The options are Configure display rotation for Trezor Model T. The options are

View File

@ -43,7 +43,7 @@ def apply_settings(
homescreen: Optional[bytes] = None, homescreen: Optional[bytes] = None,
passphrase_always_on_device: Optional[bool] = None, passphrase_always_on_device: Optional[bool] = None,
auto_lock_delay_ms: Optional[int] = None, auto_lock_delay_ms: Optional[int] = None,
display_rotation: Optional[int] = None, display_rotation: Optional[messages.DisplayRotation] = None,
safety_checks: Optional[messages.SafetyCheckLevel] = None, safety_checks: Optional[messages.SafetyCheckLevel] = None,
experimental_features: Optional[bool] = None, experimental_features: Optional[bool] = None,
hide_passphrase_from_host: Optional[bool] = None, hide_passphrase_from_host: Optional[bool] = None,

View File

@ -219,6 +219,13 @@ class SafetyCheckLevel(IntEnum):
PromptTemporarily = 2 PromptTemporarily = 2
class DisplayRotation(IntEnum):
North = 0
East = 90
South = 180
West = 270
class HomescreenFormat(IntEnum): class HomescreenFormat(IntEnum):
Toif = 1 Toif = 1
Jpeg = 2 Jpeg = 2
@ -3257,7 +3264,7 @@ class Features(protobuf.MessageType):
36: protobuf.Field("passphrase_always_on_device", "bool", repeated=False, required=False, default=None), 36: protobuf.Field("passphrase_always_on_device", "bool", repeated=False, required=False, default=None),
37: protobuf.Field("safety_checks", "SafetyCheckLevel", repeated=False, required=False, default=None), 37: protobuf.Field("safety_checks", "SafetyCheckLevel", repeated=False, required=False, default=None),
38: protobuf.Field("auto_lock_delay_ms", "uint32", repeated=False, required=False, default=None), 38: protobuf.Field("auto_lock_delay_ms", "uint32", repeated=False, required=False, default=None),
39: protobuf.Field("display_rotation", "uint32", repeated=False, required=False, default=None), 39: protobuf.Field("display_rotation", "DisplayRotation", repeated=False, required=False, default=None),
40: protobuf.Field("experimental_features", "bool", repeated=False, required=False, default=None), 40: protobuf.Field("experimental_features", "bool", repeated=False, required=False, default=None),
41: protobuf.Field("busy", "bool", repeated=False, required=False, default=None), 41: protobuf.Field("busy", "bool", repeated=False, required=False, default=None),
42: protobuf.Field("homescreen_format", "HomescreenFormat", repeated=False, required=False, default=None), 42: protobuf.Field("homescreen_format", "HomescreenFormat", repeated=False, required=False, default=None),
@ -3314,7 +3321,7 @@ class Features(protobuf.MessageType):
passphrase_always_on_device: Optional["bool"] = None, passphrase_always_on_device: Optional["bool"] = None,
safety_checks: Optional["SafetyCheckLevel"] = None, safety_checks: Optional["SafetyCheckLevel"] = None,
auto_lock_delay_ms: Optional["int"] = None, auto_lock_delay_ms: Optional["int"] = None,
display_rotation: Optional["int"] = None, display_rotation: Optional["DisplayRotation"] = None,
experimental_features: Optional["bool"] = None, experimental_features: Optional["bool"] = None,
busy: Optional["bool"] = None, busy: Optional["bool"] = None,
homescreen_format: Optional["HomescreenFormat"] = None, homescreen_format: Optional["HomescreenFormat"] = None,
@ -3416,7 +3423,7 @@ class ApplySettings(protobuf.MessageType):
4: protobuf.Field("homescreen", "bytes", repeated=False, required=False, default=None), 4: protobuf.Field("homescreen", "bytes", repeated=False, required=False, default=None),
5: protobuf.Field("_passphrase_source", "uint32", repeated=False, required=False, default=None), 5: protobuf.Field("_passphrase_source", "uint32", repeated=False, required=False, default=None),
6: protobuf.Field("auto_lock_delay_ms", "uint32", repeated=False, required=False, default=None), 6: protobuf.Field("auto_lock_delay_ms", "uint32", repeated=False, required=False, default=None),
7: protobuf.Field("display_rotation", "uint32", repeated=False, required=False, default=None), 7: protobuf.Field("display_rotation", "DisplayRotation", repeated=False, required=False, default=None),
8: protobuf.Field("passphrase_always_on_device", "bool", repeated=False, required=False, default=None), 8: protobuf.Field("passphrase_always_on_device", "bool", repeated=False, required=False, default=None),
9: protobuf.Field("safety_checks", "SafetyCheckLevel", repeated=False, required=False, default=None), 9: protobuf.Field("safety_checks", "SafetyCheckLevel", repeated=False, required=False, default=None),
10: protobuf.Field("experimental_features", "bool", repeated=False, required=False, default=None), 10: protobuf.Field("experimental_features", "bool", repeated=False, required=False, default=None),
@ -3433,7 +3440,7 @@ class ApplySettings(protobuf.MessageType):
homescreen: Optional["bytes"] = None, homescreen: Optional["bytes"] = None,
_passphrase_source: Optional["int"] = None, _passphrase_source: Optional["int"] = None,
auto_lock_delay_ms: Optional["int"] = None, auto_lock_delay_ms: Optional["int"] = None,
display_rotation: Optional["int"] = None, display_rotation: Optional["DisplayRotation"] = None,
passphrase_always_on_device: Optional["bool"] = None, passphrase_always_on_device: Optional["bool"] = None,
safety_checks: Optional["SafetyCheckLevel"] = None, safety_checks: Optional["SafetyCheckLevel"] = None,
experimental_features: Optional["bool"] = None, experimental_features: Optional["bool"] = None,

View File

@ -437,7 +437,7 @@ pub struct Features {
// @@protoc_insertion_point(field:hw.trezor.messages.management.Features.auto_lock_delay_ms) // @@protoc_insertion_point(field:hw.trezor.messages.management.Features.auto_lock_delay_ms)
pub auto_lock_delay_ms: ::std::option::Option<u32>, pub auto_lock_delay_ms: ::std::option::Option<u32>,
// @@protoc_insertion_point(field:hw.trezor.messages.management.Features.display_rotation) // @@protoc_insertion_point(field:hw.trezor.messages.management.Features.display_rotation)
pub display_rotation: ::std::option::Option<u32>, pub display_rotation: ::std::option::Option<::protobuf::EnumOrUnknown<DisplayRotation>>,
// @@protoc_insertion_point(field:hw.trezor.messages.management.Features.experimental_features) // @@protoc_insertion_point(field:hw.trezor.messages.management.Features.experimental_features)
pub experimental_features: ::std::option::Option<bool>, pub experimental_features: ::std::option::Option<bool>,
// @@protoc_insertion_point(field:hw.trezor.messages.management.Features.busy) // @@protoc_insertion_point(field:hw.trezor.messages.management.Features.busy)
@ -1314,10 +1314,13 @@ impl Features {
self.auto_lock_delay_ms = ::std::option::Option::Some(v); self.auto_lock_delay_ms = ::std::option::Option::Some(v);
} }
// optional uint32 display_rotation = 39; // optional .hw.trezor.messages.management.DisplayRotation display_rotation = 39;
pub fn display_rotation(&self) -> u32 { pub fn display_rotation(&self) -> DisplayRotation {
self.display_rotation.unwrap_or(0) match self.display_rotation {
Some(e) => e.enum_value_or(DisplayRotation::North),
None => DisplayRotation::North,
}
} }
pub fn clear_display_rotation(&mut self) { pub fn clear_display_rotation(&mut self) {
@ -1329,8 +1332,8 @@ impl Features {
} }
// Param is passed by value, moved // Param is passed by value, moved
pub fn set_display_rotation(&mut self, v: u32) { pub fn set_display_rotation(&mut self, v: DisplayRotation) {
self.display_rotation = ::std::option::Option::Some(v); self.display_rotation = ::std::option::Option::Some(::protobuf::EnumOrUnknown::new(v));
} }
// optional bool experimental_features = 40; // optional bool experimental_features = 40;
@ -2043,7 +2046,7 @@ impl ::protobuf::Message for Features {
self.auto_lock_delay_ms = ::std::option::Option::Some(is.read_uint32()?); self.auto_lock_delay_ms = ::std::option::Option::Some(is.read_uint32()?);
}, },
312 => { 312 => {
self.display_rotation = ::std::option::Option::Some(is.read_uint32()?); self.display_rotation = ::std::option::Option::Some(is.read_enum_or_unknown()?);
}, },
320 => { 320 => {
self.experimental_features = ::std::option::Option::Some(is.read_bool()?); self.experimental_features = ::std::option::Option::Some(is.read_bool()?);
@ -2211,7 +2214,7 @@ impl ::protobuf::Message for Features {
my_size += ::protobuf::rt::uint32_size(38, v); my_size += ::protobuf::rt::uint32_size(38, v);
} }
if let Some(v) = self.display_rotation { if let Some(v) = self.display_rotation {
my_size += ::protobuf::rt::uint32_size(39, v); my_size += ::protobuf::rt::int32_size(39, v.value());
} }
if let Some(v) = self.experimental_features { if let Some(v) = self.experimental_features {
my_size += 2 + 1; my_size += 2 + 1;
@ -2373,7 +2376,7 @@ impl ::protobuf::Message for Features {
os.write_uint32(38, v)?; os.write_uint32(38, v)?;
} }
if let Some(v) = self.display_rotation { if let Some(v) = self.display_rotation {
os.write_uint32(39, v)?; os.write_enum(39, ::protobuf::EnumOrUnknown::value(&v))?;
} }
if let Some(v) = self.experimental_features { if let Some(v) = self.experimental_features {
os.write_bool(40, v)?; os.write_bool(40, v)?;
@ -3250,7 +3253,7 @@ pub struct ApplySettings {
// @@protoc_insertion_point(field:hw.trezor.messages.management.ApplySettings.auto_lock_delay_ms) // @@protoc_insertion_point(field:hw.trezor.messages.management.ApplySettings.auto_lock_delay_ms)
pub auto_lock_delay_ms: ::std::option::Option<u32>, pub auto_lock_delay_ms: ::std::option::Option<u32>,
// @@protoc_insertion_point(field:hw.trezor.messages.management.ApplySettings.display_rotation) // @@protoc_insertion_point(field:hw.trezor.messages.management.ApplySettings.display_rotation)
pub display_rotation: ::std::option::Option<u32>, pub display_rotation: ::std::option::Option<::protobuf::EnumOrUnknown<DisplayRotation>>,
// @@protoc_insertion_point(field:hw.trezor.messages.management.ApplySettings.passphrase_always_on_device) // @@protoc_insertion_point(field:hw.trezor.messages.management.ApplySettings.passphrase_always_on_device)
pub passphrase_always_on_device: ::std::option::Option<bool>, pub passphrase_always_on_device: ::std::option::Option<bool>,
// @@protoc_insertion_point(field:hw.trezor.messages.management.ApplySettings.safety_checks) // @@protoc_insertion_point(field:hw.trezor.messages.management.ApplySettings.safety_checks)
@ -3442,10 +3445,13 @@ impl ApplySettings {
self.auto_lock_delay_ms = ::std::option::Option::Some(v); self.auto_lock_delay_ms = ::std::option::Option::Some(v);
} }
// optional uint32 display_rotation = 7; // optional .hw.trezor.messages.management.DisplayRotation display_rotation = 7;
pub fn display_rotation(&self) -> u32 { pub fn display_rotation(&self) -> DisplayRotation {
self.display_rotation.unwrap_or(0) match self.display_rotation {
Some(e) => e.enum_value_or(DisplayRotation::North),
None => DisplayRotation::North,
}
} }
pub fn clear_display_rotation(&mut self) { pub fn clear_display_rotation(&mut self) {
@ -3457,8 +3463,8 @@ impl ApplySettings {
} }
// Param is passed by value, moved // Param is passed by value, moved
pub fn set_display_rotation(&mut self, v: u32) { pub fn set_display_rotation(&mut self, v: DisplayRotation) {
self.display_rotation = ::std::option::Option::Some(v); self.display_rotation = ::std::option::Option::Some(::protobuf::EnumOrUnknown::new(v));
} }
// optional bool passphrase_always_on_device = 8; // optional bool passphrase_always_on_device = 8;
@ -3659,7 +3665,7 @@ impl ::protobuf::Message for ApplySettings {
self.auto_lock_delay_ms = ::std::option::Option::Some(is.read_uint32()?); self.auto_lock_delay_ms = ::std::option::Option::Some(is.read_uint32()?);
}, },
56 => { 56 => {
self.display_rotation = ::std::option::Option::Some(is.read_uint32()?); self.display_rotation = ::std::option::Option::Some(is.read_enum_or_unknown()?);
}, },
64 => { 64 => {
self.passphrase_always_on_device = ::std::option::Option::Some(is.read_bool()?); self.passphrase_always_on_device = ::std::option::Option::Some(is.read_bool()?);
@ -3707,7 +3713,7 @@ impl ::protobuf::Message for ApplySettings {
my_size += ::protobuf::rt::uint32_size(6, v); my_size += ::protobuf::rt::uint32_size(6, v);
} }
if let Some(v) = self.display_rotation { if let Some(v) = self.display_rotation {
my_size += ::protobuf::rt::uint32_size(7, v); my_size += ::protobuf::rt::int32_size(7, v.value());
} }
if let Some(v) = self.passphrase_always_on_device { if let Some(v) = self.passphrase_always_on_device {
my_size += 1 + 1; my_size += 1 + 1;
@ -3749,7 +3755,7 @@ impl ::protobuf::Message for ApplySettings {
os.write_uint32(6, v)?; os.write_uint32(6, v)?;
} }
if let Some(v) = self.display_rotation { if let Some(v) = self.display_rotation {
os.write_uint32(7, v)?; os.write_enum(7, ::protobuf::EnumOrUnknown::value(&v))?;
} }
if let Some(v) = self.passphrase_always_on_device { if let Some(v) = self.passphrase_always_on_device {
os.write_bool(8, v)?; os.write_bool(8, v)?;
@ -10945,6 +10951,83 @@ impl SafetyCheckLevel {
} }
} }
#[derive(Clone,Copy,PartialEq,Eq,Debug,Hash)]
// @@protoc_insertion_point(enum:hw.trezor.messages.management.DisplayRotation)
pub enum DisplayRotation {
// @@protoc_insertion_point(enum_value:hw.trezor.messages.management.DisplayRotation.North)
North = 0,
// @@protoc_insertion_point(enum_value:hw.trezor.messages.management.DisplayRotation.East)
East = 90,
// @@protoc_insertion_point(enum_value:hw.trezor.messages.management.DisplayRotation.South)
South = 180,
// @@protoc_insertion_point(enum_value:hw.trezor.messages.management.DisplayRotation.West)
West = 270,
}
impl ::protobuf::Enum for DisplayRotation {
const NAME: &'static str = "DisplayRotation";
fn value(&self) -> i32 {
*self as i32
}
fn from_i32(value: i32) -> ::std::option::Option<DisplayRotation> {
match value {
0 => ::std::option::Option::Some(DisplayRotation::North),
90 => ::std::option::Option::Some(DisplayRotation::East),
180 => ::std::option::Option::Some(DisplayRotation::South),
270 => ::std::option::Option::Some(DisplayRotation::West),
_ => ::std::option::Option::None
}
}
fn from_str(str: &str) -> ::std::option::Option<DisplayRotation> {
match str {
"North" => ::std::option::Option::Some(DisplayRotation::North),
"East" => ::std::option::Option::Some(DisplayRotation::East),
"South" => ::std::option::Option::Some(DisplayRotation::South),
"West" => ::std::option::Option::Some(DisplayRotation::West),
_ => ::std::option::Option::None
}
}
const VALUES: &'static [DisplayRotation] = &[
DisplayRotation::North,
DisplayRotation::East,
DisplayRotation::South,
DisplayRotation::West,
];
}
impl ::protobuf::EnumFull for DisplayRotation {
fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor {
static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::Lazy::new();
descriptor.get(|| file_descriptor().enum_by_package_relative_name("DisplayRotation").unwrap()).clone()
}
fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor {
let index = match self {
DisplayRotation::North => 0,
DisplayRotation::East => 1,
DisplayRotation::South => 2,
DisplayRotation::West => 3,
};
Self::enum_descriptor().value_by_index(index)
}
}
impl ::std::default::Default for DisplayRotation {
fn default() -> Self {
DisplayRotation::North
}
}
impl DisplayRotation {
fn generated_enum_descriptor_data() -> ::protobuf::reflect::GeneratedEnumDescriptorData {
::protobuf::reflect::GeneratedEnumDescriptorData::new::<DisplayRotation>("DisplayRotation")
}
}
#[derive(Clone,Copy,PartialEq,Eq,Debug,Hash)] #[derive(Clone,Copy,PartialEq,Eq,Debug,Hash)]
// @@protoc_insertion_point(enum:hw.trezor.messages.management.HomescreenFormat) // @@protoc_insertion_point(enum:hw.trezor.messages.management.HomescreenFormat)
pub enum HomescreenFormat { pub enum HomescreenFormat {
@ -11089,7 +11172,7 @@ static file_descriptor_proto_data: &'static [u8] = b"\
\roptions.proto\"\x80\x01\n\nInitialize\x12\x1d\n\nsession_id\x18\x01\ \roptions.proto\"\x80\x01\n\nInitialize\x12\x1d\n\nsession_id\x18\x01\
\x20\x01(\x0cR\tsessionId\x12,\n\x10_skip_passphrase\x18\x02\x20\x01(\ \x20\x01(\x0cR\tsessionId\x12,\n\x10_skip_passphrase\x18\x02\x20\x01(\
\x08R\x0eSkipPassphraseB\x02\x18\x01\x12%\n\x0ederive_cardano\x18\x03\ \x08R\x0eSkipPassphraseB\x02\x18\x01\x12%\n\x0ederive_cardano\x18\x03\
\x20\x01(\x08R\rderiveCardano\"\r\n\x0bGetFeatures\"\xd6\x17\n\x08Featur\ \x20\x01(\x08R\rderiveCardano\"\r\n\x0bGetFeatures\"\x86\x18\n\x08Featur\
es\x12\x16\n\x06vendor\x18\x01\x20\x01(\tR\x06vendor\x12#\n\rmajor_versi\ es\x12\x16\n\x06vendor\x18\x01\x20\x01(\tR\x06vendor\x12#\n\rmajor_versi\
on\x18\x02\x20\x02(\rR\x0cmajorVersion\x12#\n\rminor_version\x18\x03\x20\ on\x18\x02\x20\x02(\rR\x0cmajorVersion\x12#\n\rminor_version\x18\x03\x20\
\x02(\rR\x0cminorVersion\x12#\n\rpatch_version\x18\x04\x20\x02(\rR\x0cpa\ \x02(\rR\x0cminorVersion\x12#\n\rpatch_version\x18\x04\x20\x02(\rR\x0cpa\
@ -11124,49 +11207,50 @@ static file_descriptor_proto_data: &'static [u8] = b"\
\x18$\x20\x01(\x08R\x18passphraseAlwaysOnDevice\x12T\n\rsafety_checks\ \x18$\x20\x01(\x08R\x18passphraseAlwaysOnDevice\x12T\n\rsafety_checks\
\x18%\x20\x01(\x0e2/.hw.trezor.messages.management.SafetyCheckLevelR\x0c\ \x18%\x20\x01(\x0e2/.hw.trezor.messages.management.SafetyCheckLevelR\x0c\
safetyChecks\x12+\n\x12auto_lock_delay_ms\x18&\x20\x01(\rR\x0fautoLockDe\ safetyChecks\x12+\n\x12auto_lock_delay_ms\x18&\x20\x01(\rR\x0fautoLockDe\
layMs\x12)\n\x10display_rotation\x18'\x20\x01(\rR\x0fdisplayRotation\x12\ layMs\x12Y\n\x10display_rotation\x18'\x20\x01(\x0e2..hw.trezor.messages.\
3\n\x15experimental_features\x18(\x20\x01(\x08R\x14experimentalFeatures\ management.DisplayRotationR\x0fdisplayRotation\x123\n\x15experimental_fe\
\x12\x12\n\x04busy\x18)\x20\x01(\x08R\x04busy\x12\\\n\x11homescreen_form\ atures\x18(\x20\x01(\x08R\x14experimentalFeatures\x12\x12\n\x04busy\x18)\
at\x18*\x20\x01(\x0e2/.hw.trezor.messages.management.HomescreenFormatR\ \x20\x01(\x08R\x04busy\x12\\\n\x11homescreen_format\x18*\x20\x01(\x0e2/.\
\x10homescreenFormat\x129\n\x19hide_passphrase_from_host\x18+\x20\x01(\ hw.trezor.messages.management.HomescreenFormatR\x10homescreenFormat\x129\
\x08R\x16hidePassphraseFromHost\x12%\n\x0einternal_model\x18,\x20\x01(\t\ \n\x19hide_passphrase_from_host\x18+\x20\x01(\x08R\x16hidePassphraseFrom\
R\rinternalModel\x12\x1d\n\nunit_color\x18-\x20\x01(\rR\tunitColor\x12!\ Host\x12%\n\x0einternal_model\x18,\x20\x01(\tR\rinternalModel\x12\x1d\n\
\n\x0cunit_btconly\x18.\x20\x01(\x08R\x0bunitBtconly\x12)\n\x10homescree\ \nunit_color\x18-\x20\x01(\rR\tunitColor\x12!\n\x0cunit_btconly\x18.\x20\
n_width\x18/\x20\x01(\rR\x0fhomescreenWidth\x12+\n\x11homescreen_height\ \x01(\x08R\x0bunitBtconly\x12)\n\x10homescreen_width\x18/\x20\x01(\rR\
\x180\x20\x01(\rR\x10homescreenHeight\x12+\n\x11bootloader_locked\x181\ \x0fhomescreenWidth\x12+\n\x11homescreen_height\x180\x20\x01(\rR\x10home\
\x20\x01(\x08R\x10bootloaderLocked\x12>\n\x18language_version_matches\ screenHeight\x12+\n\x11bootloader_locked\x181\x20\x01(\x08R\x10bootloade\
\x182\x20\x01(\x08:\x04trueR\x16languageVersionMatches\x12%\n\x0eunit_pa\ rLocked\x12>\n\x18language_version_matches\x182\x20\x01(\x08:\x04trueR\
ckaging\x183\x20\x01(\rR\runitPackaging\x12'\n\x0fhaptic_feedback\x184\ \x16languageVersionMatches\x12%\n\x0eunit_packaging\x183\x20\x01(\rR\run\
\x20\x01(\x08R\x0ehapticFeedback\x12P\n\rrecovery_type\x185\x20\x01(\x0e\ itPackaging\x12'\n\x0fhaptic_feedback\x184\x20\x01(\x08R\x0ehapticFeedba\
2+.hw.trezor.messages.management.RecoveryTypeR\x0crecoveryType\x12\x1d\n\ ck\x12P\n\rrecovery_type\x185\x20\x01(\x0e2+.hw.trezor.messages.manageme\
\noptiga_sec\x186\x20\x01(\rR\toptigaSec\"C\n\x12BackupAvailability\x12\ nt.RecoveryTypeR\x0crecoveryType\x12\x1d\n\noptiga_sec\x186\x20\x01(\rR\
\x10\n\x0cNotAvailable\x10\0\x12\x0c\n\x08Required\x10\x01\x12\r\n\tAvai\ \toptigaSec\"C\n\x12BackupAvailability\x12\x10\n\x0cNotAvailable\x10\0\
lable\x10\x02\"7\n\x0eRecoveryStatus\x12\x0b\n\x07Nothing\x10\0\x12\x0c\ \x12\x0c\n\x08Required\x10\x01\x12\r\n\tAvailable\x10\x02\"7\n\x0eRecove\
\n\x08Recovery\x10\x01\x12\n\n\x06Backup\x10\x02\"\xc2\x04\n\nCapability\ ryStatus\x12\x0b\n\x07Nothing\x10\0\x12\x0c\n\x08Recovery\x10\x01\x12\n\
\x12\x1c\n\x12Capability_Bitcoin\x10\x01\x1a\x04\x80\xa6\x1d\x01\x12\x1b\ \n\x06Backup\x10\x02\"\xc2\x04\n\nCapability\x12\x1c\n\x12Capability_Bit\
\n\x17Capability_Bitcoin_like\x10\x02\x12\x16\n\x12Capability_Binance\ coin\x10\x01\x1a\x04\x80\xa6\x1d\x01\x12\x1b\n\x17Capability_Bitcoin_lik\
\x10\x03\x12\x16\n\x12Capability_Cardano\x10\x04\x12\x1b\n\x11Capability\ e\x10\x02\x12\x16\n\x12Capability_Binance\x10\x03\x12\x16\n\x12Capabilit\
_Crypto\x10\x05\x1a\x04\x80\xa6\x1d\x01\x12\x12\n\x0eCapability_EOS\x10\ y_Cardano\x10\x04\x12\x1b\n\x11Capability_Crypto\x10\x05\x1a\x04\x80\xa6\
\x06\x12\x17\n\x13Capability_Ethereum\x10\x07\x12\x17\n\x0fCapability_Li\ \x1d\x01\x12\x12\n\x0eCapability_EOS\x10\x06\x12\x17\n\x13Capability_Eth\
sk\x10\x08\x1a\x02\x08\x01\x12\x15\n\x11Capability_Monero\x10\t\x12\x12\ ereum\x10\x07\x12\x17\n\x0fCapability_Lisk\x10\x08\x1a\x02\x08\x01\x12\
\n\x0eCapability_NEM\x10\n\x12\x15\n\x11Capability_Ripple\x10\x0b\x12\ \x15\n\x11Capability_Monero\x10\t\x12\x12\n\x0eCapability_NEM\x10\n\x12\
\x16\n\x12Capability_Stellar\x10\x0c\x12\x14\n\x10Capability_Tezos\x10\r\ \x15\n\x11Capability_Ripple\x10\x0b\x12\x16\n\x12Capability_Stellar\x10\
\x12\x12\n\x0eCapability_U2F\x10\x0e\x12\x1b\n\x11Capability_Shamir\x10\ \x0c\x12\x14\n\x10Capability_Tezos\x10\r\x12\x12\n\x0eCapability_U2F\x10\
\x0f\x1a\x04\x80\xa6\x1d\x01\x12!\n\x17Capability_ShamirGroups\x10\x10\ \x0e\x12\x1b\n\x11Capability_Shamir\x10\x0f\x1a\x04\x80\xa6\x1d\x01\x12!\
\x1a\x04\x80\xa6\x1d\x01\x12$\n\x1aCapability_PassphraseEntry\x10\x11\ \n\x17Capability_ShamirGroups\x10\x10\x1a\x04\x80\xa6\x1d\x01\x12$\n\x1a\
\x1a\x04\x80\xa6\x1d\x01\x12\x15\n\x11Capability_Solana\x10\x12\x12!\n\ Capability_PassphraseEntry\x10\x11\x1a\x04\x80\xa6\x1d\x01\x12\x15\n\x11\
\x17Capability_Translations\x10\x13\x1a\x04\x80\xa6\x1d\x01\x12\x1f\n\ Capability_Solana\x10\x12\x12!\n\x17Capability_Translations\x10\x13\x1a\
\x15Capability_Brightness\x10\x14\x1a\x04\x80\xa6\x1d\x01\x12\x1b\n\x11C\ \x04\x80\xa6\x1d\x01\x12\x1f\n\x15Capability_Brightness\x10\x14\x1a\x04\
apability_Haptic\x10\x15\x1a\x04\x80\xa6\x1d\x01\x1a\x04\xc8\xf3\x18\x01\ \x80\xa6\x1d\x01\x12\x1b\n\x11Capability_Haptic\x10\x15\x1a\x04\x80\xa6\
\"\x0c\n\nLockDevice\"&\n\x07SetBusy\x12\x1b\n\texpiry_ms\x18\x01\x20\ \x1d\x01\x1a\x04\xc8\xf3\x18\x01\"\x0c\n\nLockDevice\"&\n\x07SetBusy\x12\
\x01(\rR\x08expiryMs\"\x0c\n\nEndSession\"\xc4\x04\n\rApplySettings\x12\ \x1b\n\texpiry_ms\x18\x01\x20\x01(\rR\x08expiryMs\"\x0c\n\nEndSession\"\
\x1e\n\x08language\x18\x01\x20\x01(\tR\x08languageB\x02\x18\x01\x12\x14\ \xf4\x04\n\rApplySettings\x12\x1e\n\x08language\x18\x01\x20\x01(\tR\x08l\
\n\x05label\x18\x02\x20\x01(\tR\x05label\x12%\n\x0euse_passphrase\x18\ anguageB\x02\x18\x01\x12\x14\n\x05label\x18\x02\x20\x01(\tR\x05label\x12\
\x03\x20\x01(\x08R\rusePassphrase\x12\x1e\n\nhomescreen\x18\x04\x20\x01(\ %\n\x0euse_passphrase\x18\x03\x20\x01(\x08R\rusePassphrase\x12\x1e\n\nho\
\x0cR\nhomescreen\x120\n\x12_passphrase_source\x18\x05\x20\x01(\rR\x10Pa\ mescreen\x18\x04\x20\x01(\x0cR\nhomescreen\x120\n\x12_passphrase_source\
ssphraseSourceB\x02\x18\x01\x12+\n\x12auto_lock_delay_ms\x18\x06\x20\x01\ \x18\x05\x20\x01(\rR\x10PassphraseSourceB\x02\x18\x01\x12+\n\x12auto_loc\
(\rR\x0fautoLockDelayMs\x12)\n\x10display_rotation\x18\x07\x20\x01(\rR\ k_delay_ms\x18\x06\x20\x01(\rR\x0fautoLockDelayMs\x12Y\n\x10display_rota\
\x0fdisplayRotation\x12=\n\x1bpassphrase_always_on_device\x18\x08\x20\ tion\x18\x07\x20\x01(\x0e2..hw.trezor.messages.management.DisplayRotatio\
nR\x0fdisplayRotation\x12=\n\x1bpassphrase_always_on_device\x18\x08\x20\
\x01(\x08R\x18passphraseAlwaysOnDevice\x12T\n\rsafety_checks\x18\t\x20\ \x01(\x08R\x18passphraseAlwaysOnDevice\x12T\n\rsafety_checks\x18\t\x20\
\x01(\x0e2/.hw.trezor.messages.management.SafetyCheckLevelR\x0csafetyChe\ \x01(\x0e2/.hw.trezor.messages.management.SafetyCheckLevelR\x0csafetyChe\
cks\x123\n\x15experimental_features\x18\n\x20\x01(\x08R\x14experimentalF\ cks\x123\n\x15experimental_features\x18\n\x20\x01(\x08R\x14experimentalF\
@ -11253,12 +11337,13 @@ static file_descriptor_proto_data: &'static [u8] = b"\
\x10\x02\x12\x1c\n\x18Slip39_Single_Extendable\x10\x03\x12\x1b\n\x17Slip\ \x10\x02\x12\x1c\n\x18Slip39_Single_Extendable\x10\x03\x12\x1b\n\x17Slip\
39_Basic_Extendable\x10\x04\x12\x1e\n\x1aSlip39_Advanced_Extendable\x10\ 39_Basic_Extendable\x10\x04\x12\x1e\n\x1aSlip39_Advanced_Extendable\x10\
\x05*G\n\x10SafetyCheckLevel\x12\n\n\x06Strict\x10\0\x12\x10\n\x0cPrompt\ \x05*G\n\x10SafetyCheckLevel\x12\n\n\x06Strict\x10\0\x12\x10\n\x0cPrompt\
Always\x10\x01\x12\x15\n\x11PromptTemporarily\x10\x02*0\n\x10HomescreenF\ Always\x10\x01\x12\x15\n\x11PromptTemporarily\x10\x02*=\n\x0fDisplayRota\
ormat\x12\x08\n\x04Toif\x10\x01\x12\x08\n\x04Jpeg\x10\x02\x12\x08\n\x04T\ tion\x12\t\n\x05North\x10\0\x12\x08\n\x04East\x10Z\x12\n\n\x05South\x10\
oiG\x10\x03*H\n\x0cRecoveryType\x12\x12\n\x0eNormalRecovery\x10\0\x12\n\ \xb4\x01\x12\t\n\x04West\x10\x8e\x02*0\n\x10HomescreenFormat\x12\x08\n\
\n\x06DryRun\x10\x01\x12\x18\n\x14UnlockRepeatedBackup\x10\x02BB\n#com.s\ \x04Toif\x10\x01\x12\x08\n\x04Jpeg\x10\x02\x12\x08\n\x04ToiG\x10\x03*H\n\
atoshilabs.trezor.lib.protobufB\x17TrezorMessageManagement\x80\xa6\x1d\ \x0cRecoveryType\x12\x12\n\x0eNormalRecovery\x10\0\x12\n\n\x06DryRun\x10\
\x01\ \x01\x12\x18\n\x14UnlockRepeatedBackup\x10\x02BB\n#com.satoshilabs.trezo\
r.lib.protobufB\x17TrezorMessageManagement\x80\xa6\x1d\x01\
"; ";
/// `FileDescriptorProto` object which was a source for this generated file /// `FileDescriptorProto` object which was a source for this generated file
@ -11324,9 +11409,10 @@ pub fn file_descriptor() -> &'static ::protobuf::reflect::FileDescriptor {
messages.push(UnlockBootloader::generated_message_descriptor_data()); messages.push(UnlockBootloader::generated_message_descriptor_data());
messages.push(SetBrightness::generated_message_descriptor_data()); messages.push(SetBrightness::generated_message_descriptor_data());
messages.push(backup_device::Slip39Group::generated_message_descriptor_data()); messages.push(backup_device::Slip39Group::generated_message_descriptor_data());
let mut enums = ::std::vec::Vec::with_capacity(11); let mut enums = ::std::vec::Vec::with_capacity(12);
enums.push(BackupType::generated_enum_descriptor_data()); enums.push(BackupType::generated_enum_descriptor_data());
enums.push(SafetyCheckLevel::generated_enum_descriptor_data()); enums.push(SafetyCheckLevel::generated_enum_descriptor_data());
enums.push(DisplayRotation::generated_enum_descriptor_data());
enums.push(HomescreenFormat::generated_enum_descriptor_data()); enums.push(HomescreenFormat::generated_enum_descriptor_data());
enums.push(RecoveryType::generated_enum_descriptor_data()); enums.push(RecoveryType::generated_enum_descriptor_data());
enums.push(features::BackupAvailability::generated_enum_descriptor_data()); enums.push(features::BackupAvailability::generated_enum_descriptor_data());

View File

@ -74,9 +74,9 @@ def test_apply_settings_rotation(client: Client):
with client: with client:
_set_expected_responses(client) _set_expected_responses(client)
device.apply_settings(client, display_rotation=270) device.apply_settings(client, display_rotation=messages.DisplayRotation.West)
assert client.features.display_rotation == 270 assert client.features.display_rotation == messages.DisplayRotation.West
@pytest.mark.setup_client(pin=PIN4, passphrase=False) @pytest.mark.setup_client(pin=PIN4, passphrase=False)