Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: emulator lock and pin sequence #205

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ def run_emulator_command(self) -> dict:
y = self.request_dict["y"]
emulator.click(x=x, y=y)
return {"response": f"Clicked in emulator: x: {x}, y: {y}"}
elif self.command == "emulator-use_pin_sequence":
sequence = self.request_dict["sequence"]
emulator.use_pin_sequence(sequence)
return {"response": f"Seq: {sequence}"}
elif self.command == "emulator-lock":
emulator.lock()
return {"response": f"Device locked"}
elif self.command == "emulator-read-and-confirm-mnemonic":
emulator.read_and_confirm_mnemonic()
return {"response": "Read and confirm mnemonic"}
Expand Down
10 changes: 9 additions & 1 deletion src/emulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@ def press_no() -> None:


# enter recovery word or pin
# enter pin not possible for T2, it is locked, for T1 it is possible
# change pin possible, use input(word=pin-string)
def input(value: str) -> None:
with connect_to_debuglink() as debug:
Expand All @@ -400,6 +399,15 @@ def swipe(direction: str) -> None:
elif direction == "left":
debug.swipe_left()

def use_pin_sequence(sequence) -> None:
with connect_to_client() as client:
client.use_pin_sequence(sequence)
time.sleep(SLEEP)

def lock() -> None:
with connect_to_client() as client:
client.lock()
time.sleep(SLEEP)

def read_and_confirm_mnemonic() -> None:
with connect_to_debuglink() as debug:
Expand Down