Skip to content

Commit c8b8f50

Browse files
committed
fix initialize logic
1 parent 4fc4980 commit c8b8f50

File tree

5 files changed

+11
-26
lines changed

5 files changed

+11
-26
lines changed

core/src/apps/base.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -252,17 +252,9 @@ async def handle_Initialize(
252252
else:
253253
storage.cache.delete(storage.cache.APP_COMMON_CLIENT_CONTAINS_ATTACH)
254254

255-
prev_session_id = storage.cache.get_session_id()
256-
257-
from apps.common import passphrase
258-
259-
passphrase_pin_enabled = passphrase.is_passphrase_pin_enabled()
260255
if (
261-
device_is_unlocked()
262-
and prev_session_id != msg.session_id
263-
and hasattr(msg, "passphrase_state")
256+
hasattr(msg, "passphrase_state")
264257
and msg.passphrase_state is not None
265-
and passphrase_pin_enabled
266258
and msg.passphrase_state != ""
267259
and se_thd89.check_passphrase_btc_test_address(
268260
msg.passphrase_state
@@ -271,8 +263,17 @@ async def handle_Initialize(
271263
)
272264
):
273265
session_id = storage.cache.start_session()
266+
elif msg.session_id is not None:
267+
if (
268+
not hasattr(msg, "passphrase_state")
269+
or msg.passphrase_state is None
270+
or msg.passphrase_state == ""
271+
):
272+
session_id = storage.cache.start_session()
273+
else:
274+
session_id = storage.cache.start_session(msg.session_id)
274275
else:
275-
session_id = storage.cache.start_session(msg.session_id)
276+
session_id = storage.cache.start_session()
276277
if not utils.BITCOIN_ONLY:
277278
if utils.USE_THD89:
278279
if msg.derive_cardano is not None and msg.derive_cardano:
@@ -664,7 +665,6 @@ def get_pinlocked_handler(
664665

665666
async def wrapper(ctx: wire.Context, msg: wire.Msg) -> protobuf.MessageType:
666667
await unlock_device(ctx)
667-
storage.cache.start_session()
668668
return await orig_handler(ctx, msg)
669669

670670
return wrapper
@@ -756,7 +756,6 @@ async def handle_UnLockDevice(
756756
"""Handle UnLockDevice message to unlock the device if needed."""
757757
if not config.is_unlocked():
758758
await unlock_device(ctx, pin_use_type=PinType.USER_AND_PASSPHRASE_PIN)
759-
storage.cache.start_session()
760759

761760
# Get current device state after unlock attempt
762761
from apps.common import passphrase

core/src/apps/homescreen/lockscreen.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ async def lockscreen() -> None:
1616
# to an unlocked state.
1717
try:
1818
await unlock_device()
19-
storage.cache.start_session()
2019
except wire.PinCancelled:
2120
pass
2221

core/src/apps/webauthn/fido2.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -663,9 +663,6 @@ async def verify_user(keepalive_callback: KeepaliveCallback) -> bool:
663663
trezor.pin.keepalive_callback = keepalive_callback
664664

665665
await unlock_device()
666-
import storage.cache
667-
668-
storage.cache.start_session()
669666
return True
670667
except Exception:
671668
return False
@@ -809,9 +806,6 @@ async def confirm_dialog(self) -> bool:
809806

810807
try:
811808
await unlock_device()
812-
import storage.cache
813-
814-
storage.cache.start_session()
815809
return True
816810
except Exception:
817811
return False

core/src/boot.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ async def bootscreen() -> None:
3636
from apps.common.pin_constants import PinType
3737

3838
await verify_user_pin(pin_use_type=PinType.USER_AND_PASSPHRASE_PIN)
39-
storage.cache.start_session()
4039
storage.init_unlocked()
4140
loop.close(lvgl_task)
4241
return

core/src/trezor/uart.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,6 @@ async def handle_fingerprint():
160160
if __debug__:
161161
print(f"fingerprint unlock result {res}")
162162
await base.unlock_device()
163-
import storage.cache
164-
165-
storage.cache.start_session()
166163

167164
# await loop.sleep(2000)
168165
return
@@ -335,9 +332,6 @@ async def _deal_ble_pair(value):
335332
if not base.device_is_unlocked():
336333
try:
337334
await base.unlock_device()
338-
import storage.cache
339-
340-
storage.cache.start_session()
341335
except Exception:
342336
await safe_reloop()
343337
workflow.spawn(utils.internal_reloop())

0 commit comments

Comments
 (0)