Skip to content

let your agent control your phone

fix: rest pins the device before putting it to sleep

ShawnPana166bbb9197d1
diff --git a/src/phone_harness/android.py b/src/phone_harness/android.py
index e580a4c..5de13ee 100644
--- a/src/phone_harness/android.py
+++ b/src/phone_harness/android.py
@@ -703,10 +703,12 @@ def cli(args):
else:
print("no awake session running")
try:
- _run("shell", "input", "keyevent", "KEYCODE_SLEEP", timeout=10)
- print("phone put to sleep")
- except RuntimeError:
- pass
+ phone = Android()
+ if phone._resolve() is not None:
+ phone._sh("input keyevent KEYCODE_SLEEP", timeout=10)
+ print("phone put to sleep")
+ except RuntimeError as e:
+ print(f"(could not put the phone to sleep: {e})")
return 0
if cmd == "pair":