Skip to content

Commit 669a9a4

Browse files
committed
fix(core): fix the vibrate issue with long press and misc fix
1 parent 0d05a16 commit 669a9a4

File tree

19 files changed

+107
-99
lines changed

19 files changed

+107
-99
lines changed

core/embed/extmod/modtrezorconfig/modtrezorconfig.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorconfig_unlock_obj, 2, 3,
167167
mod_trezorconfig_unlock);
168168

169169
/// def check_pin(pin: str, ext_salt: bytes | None, pin_use_type: int = 0) ->
170-
/// bool:
170+
/// tuple[bool, int]:
171171
/// """
172172
/// Check the given PIN with the given external salt.
173173
/// Returns True on success, False on failure.

core/mocks/generated/trezorconfig.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def unlock(pin: str, ext_salt: bytes | None, pin_use_type: int = 0)
2929

3030
# extmod/modtrezorconfig/modtrezorconfig.c
3131
def check_pin(pin: str, ext_salt: bytes | None, pin_use_type: int = 0) ->
32-
bool:
32+
tuple[bool, int]:
3333
"""
3434
Check the given PIN with the given external salt.
3535
Returns True on success, False on failure.

core/src/all_modules.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
import storage.sd_salt
6666
trezor
6767
import trezor
68+
trezor.config
69+
import trezor.config
6870
trezor.crypto
6971
import trezor.crypto
7072
trezor.crypto.base32

core/src/apps/base.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ async def handle_CancelAuthorization(
456456
)
457457

458458

459-
def set_homescreen() -> None:
459+
def set_homescreen(show_app_guide: bool = False) -> None:
460460
import lvgl as lv # type: ignore[Import "lvgl" could not be resolved]
461461

462462
from trezor.lvglui.scrs import fingerprints
@@ -483,6 +483,11 @@ def set_homescreen() -> None:
483483

484484
store_ble_name(ble_name)
485485
screen = MainScreen(device_name, ble_name, dev_state)
486+
if show_app_guide:
487+
from trezor.lvglui.scrs import app_guide
488+
489+
app_guide.GuideAppDownload()
490+
486491
if not first_unlock:
487492
first_unlock = True
488493
if (

core/src/apps/common/request_pin.py

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,7 @@ async def verify_user_pin(
163163

164164
if not config.is_unlocked():
165165
try:
166-
result = config.unlock(pin, salt, pin_use_type)
167-
if isinstance(result, tuple):
168-
verified, usertype = result
169-
else:
170-
verified = result
171-
usertype = PinResult.USER_PIN_ENTERED
172-
print("usertype", usertype)
173-
166+
verified, usertype = config.unlock(pin, salt, pin_use_type)
174167
if verified:
175168
if usertype == PinResult.PASSPHRASE_PIN_ENTERED:
176169
device.set_passphrase_pin_enabled(True)
@@ -181,12 +174,9 @@ async def verify_user_pin(
181174
raise wire.PinCancelled("cancle")
182175
else:
183176
try:
184-
result = config.check_pin(pin, salt, pin_use_type)
185-
if isinstance(result, tuple):
186-
verified, usertype = result
187-
else:
188-
verified = result
189-
usertype = PinResult.USER_PIN_ENTERED
177+
verified, usertype = config.check_pin(
178+
pin, salt, pin_use_type, auto_vibrate=True
179+
)
190180
if verified:
191181
if usertype == PinResult.PASSPHRASE_PIN_ENTERED:
192182
device.set_passphrase_pin_enabled(True)
@@ -224,19 +214,11 @@ async def verify_user_pin(
224214

225215
try:
226216
if not config.is_unlocked():
227-
result = config.unlock(pin, salt, pin_use_type)
228-
if isinstance(result, tuple):
229-
verified, usertype = result
230-
else:
231-
verified = result
232-
usertype = PinResult.USER_PIN_ENTERED
233-
else:
234-
result = config.check_pin(pin, salt, pin_use_type)
235-
if isinstance(result, tuple):
236-
verified, usertype = result
217+
verified, usertype = config.unlock(pin, salt, pin_use_type)
237218
else:
238-
verified = result
239-
usertype = PinResult.USER_PIN_ENTERED
219+
verified, usertype = config.check_pin(
220+
pin, salt, pin_use_type, auto_vibrate=True
221+
)
240222
except Exception:
241223
raise wire.PinCancelled("cal cale ..")
242224

core/src/apps/ethereum/layout.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ async def require_confirm_safe_tx(
615615
int.from_bytes(msg.safeTxGas, "big"),
616616
int.from_bytes(msg.baseGas, "big"),
617617
format_ethereum_amount(int.from_bytes(msg.gasPrice, "big"), None, msg.chain_id),
618-
msg.gasToken if not is_native_token(msg.gasToken) else "ETH",
618+
msg.gasToken,
619619
msg.refundReceiver,
620620
int.from_bytes(msg.nonce, "big"),
621621
msg.verifyingContract,
@@ -625,14 +625,6 @@ async def require_confirm_safe_tx(
625625
)
626626

627627

628-
def is_native_token(token_address: str) -> bool:
629-
token_address = token_address.lower()
630-
return token_address in (
631-
"0x0000000000000000000000000000000000000000",
632-
"0000000000000000000000000000000000000000",
633-
)
634-
635-
636628
def format_approve_title(
637629
approve_token: tokens.EthereumTokenInfo,
638630
value: int,

core/src/apps/ethereum/onekey/sign_tx.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ async def sign_tx(
9797

9898
from trezor.ui.layouts.lvgl import confirm_turbo
9999

100-
await confirm_turbo(ctx, (_(i18n_keys.LIST_VALUE__SEND) + suffix), network.name)
100+
if value == 0:
101+
title = _(i18n_keys.TITLE_REQUEST_CONFIRMATION)
102+
else:
103+
title = _(i18n_keys.LIST_VALUE__SEND) + suffix
104+
await confirm_turbo(ctx, title, network.name)
101105

102106
elif approve_info:
103107
from .providers import provider_by_chain_address

core/src/apps/management/change_pin.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,7 @@ async def change_pin(ctx: wire.Context, msg: ChangePin) -> Success:
3737
from apps.common.pin_constants import PinType, PinResult
3838

3939
if curpin and not msg.remove:
40-
result = config.check_pin(curpin, salt, PinType.USER_CHECK)
41-
if isinstance(result, tuple):
42-
verified, usertype = result
43-
else:
44-
verified = result
45-
usertype = PinType.USER_CHECK
40+
verified = config.check_pin(curpin, salt, PinType.USER_CHECK)[0]
4641
if not verified:
4742
await error_pin_invalid(ctx)
4843

@@ -55,12 +50,7 @@ async def change_pin(ctx: wire.Context, msg: ChangePin) -> Success:
5550
newpin = ""
5651

5752
if newpin:
58-
result = config.check_pin(newpin, salt, PinType.PASSPHRASE_PIN)
59-
if isinstance(result, tuple):
60-
verified, usertype = result
61-
else:
62-
verified = result
63-
usertype = PinResult.PASSPHRASE_PIN_ENTERED
53+
verified, usertype = config.check_pin(newpin, salt, PinType.PASSPHRASE_PIN)
6454
if usertype == PinResult.PASSPHRASE_PIN_ENTERED:
6555
return await error_pin_used(ctx)
6656

core/src/apps/management/change_wipe_code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async def change_wipe_code(ctx: wire.Context, msg: ChangeWipeCode) -> Success:
3030

3131
if not msg.remove:
3232
# Pre-check the entered PIN.
33-
if config.has_pin() and not config.check_pin(pin, salt):
33+
if config.has_pin() and not config.check_pin(pin, salt)[0]:
3434
await error_pin_invalid(ctx)
3535

3636
# Get new wipe code.

core/src/apps/management/recovery_device/__init__.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import storage.recovery
55
from trezor import config, loop, utils, wire
66
from trezor.enums import ButtonRequestType
7-
from trezor.lvglui.i18n import gettext, i18n_refresh, keys as i18n_keys
7+
from trezor.lvglui.i18n import gettext as _, i18n_refresh, keys as i18n_keys
88
from trezor.lvglui.scrs import fingerprints
99
from trezor.messages import Success
1010
from trezor.ui.layouts import confirm_action, confirm_reset_device
@@ -44,7 +44,7 @@ async def recovery_device(
4444

4545
if msg.language is not None:
4646
i18n_refresh(msg.language)
47-
await show_popup(gettext(i18n_keys.TITLE__PLEASE_WAIT), None, timeout_ms=1000)
47+
await show_popup(_(i18n_keys.TITLE__PLEASE_WAIT), None, timeout_ms=1000)
4848
# wipe storage to make sure the device is in a clear state
4949
storage.reset()
5050
if msg.language is not None:
@@ -62,17 +62,13 @@ async def recovery_device(
6262
if msg.dry_run:
6363
curpin, salt = await request_pin_and_sd_salt(
6464
ctx,
65-
gettext(i18n_keys.TITLE__ENTER_PIN),
65+
_(i18n_keys.TITLE__ENTER_PIN),
6666
allow_fingerprint=False,
6767
standy_wall_only=True,
6868
)
6969
from apps.common.pin_constants import PinType
7070

71-
result = config.check_pin(curpin, salt, PinType.USER_CHECK)
72-
if isinstance(result, tuple):
73-
verified, _ = result
74-
else:
75-
verified = result
71+
verified = config.check_pin(curpin, salt, PinType.USER_CHECK)[0]
7672
if not verified:
7773
await error_pin_invalid(ctx)
7874
newpin = None
@@ -131,18 +127,18 @@ async def _continue_dialog(ctx: wire.Context, msg: RecoveryDevice) -> None:
131127
if not msg.dry_run:
132128
await confirm_reset_device(
133129
ctx,
134-
gettext(i18n_keys.SUBTITLE__DEVICE_RECOVER_RESTORE_WALLET),
130+
_(i18n_keys.SUBTITLE__DEVICE_RECOVER_RESTORE_WALLET),
135131
recovery=True,
136132
)
137133
else:
138134
await confirm_action(
139135
ctx,
140136
"confirm_seedcheck",
141-
title=gettext(i18n_keys.TITLE__CHECK_RECOVERY_PHRASE),
142-
description=gettext(
137+
title=_(i18n_keys.TITLE__CHECK_RECOVERY_PHRASE),
138+
description=_(
143139
i18n_keys.SUBTITLE__DEVICE_RECOVER_CHECK_CHECK_RECOVERY_PHRASE
144140
),
145-
verb=gettext(i18n_keys.BUTTON__CONTINUE),
141+
verb=_(i18n_keys.BUTTON__CONTINUE),
146142
icon="A:/res/check-seed.png",
147143
br_code=ButtonRequestType.ProtectCall,
148144
anim_dir=2,

0 commit comments

Comments
 (0)