diff --git a/core/src/storage/cache.py b/core/src/storage/cache.py index a2ce17bb0a..bc8b1bb032 100644 --- a/core/src/storage/cache.py +++ b/core/src/storage/cache.py @@ -20,6 +20,7 @@ APP_COMMON_AUTHORIZATION_DATA = 4 # Keys that are valid across sessions APP_COMMON_SEED_WITHOUT_PASSPHRASE = 0 | _SESSIONLESS_FLAG APP_COMMON_SAFETY_CHECKS_TEMPORARY = 1 | _SESSIONLESS_FLAG +STORAGE_DEVICE_EXPERIMENTAL_FEATURES = 2 | _SESSIONLESS_FLAG class InvalidSessionError(Exception): @@ -77,6 +78,7 @@ class SessionlessCache(DataCache): self.fields = ( 64, # APP_COMMON_SEED_WITHOUT_PASSPHRASE 1, # APP_COMMON_SAFETY_CHECKS_TEMPORARY + 1, # STORAGE_DEVICE_EXPERIMENTAL_FEATURES ) super().__init__() diff --git a/core/src/storage/device.py b/core/src/storage/device.py index 35d15a0272..4e689f0488 100644 --- a/core/src/storage/device.py +++ b/core/src/storage/device.py @@ -1,6 +1,7 @@ from micropython import const from ubinascii import hexlify +import storage.cache from storage import common if False: @@ -318,9 +319,19 @@ def set_safety_check_level(level: StorageSafetyCheckLevel) -> None: common.set_uint8(_NAMESPACE, _SAFETY_CHECK_LEVEL, level) +@storage.cache.stored(storage.cache.STORAGE_DEVICE_EXPERIMENTAL_FEATURES) +def _get_experimental_features() -> bytes: + if common.get_bool(_NAMESPACE, _EXPERIMENTAL_FEATURES): + return b"\x01" + else: + return b"" + + def get_experimental_features() -> bool: - return common.get_bool(_NAMESPACE, _EXPERIMENTAL_FEATURES) + return bool(_get_experimental_features()) def set_experimental_features(enabled: bool) -> None: + cached_bytes = b"\x01" if enabled else b"" + storage.cache.set(storage.cache.STORAGE_DEVICE_EXPERIMENTAL_FEATURES, cached_bytes) common.set_true_or_delete(_NAMESPACE, _EXPERIMENTAL_FEATURES, enabled) diff --git a/tests/device_tests/test_msg_applysettings.py b/tests/device_tests/test_msg_applysettings.py index 37dd3b7415..d52d8856d8 100644 --- a/tests/device_tests/test_msg_applysettings.py +++ b/tests/device_tests/test_msg_applysettings.py @@ -247,6 +247,21 @@ class TestMsgApplysettings: ) experimental_call() + # relock and try again + client.lock() + with client: + client.use_pin_sequence([PIN4]) + client.set_expected_responses( + [ + messages.ButtonRequest, + messages.ButtonRequest, + messages.ButtonRequest, + messages.Success, + ] + ) + experimental_call() + + # unset experimental features with client: client.set_expected_responses([messages.Success, messages.Features]) device.apply_settings(client, experimental_features=False)