|
|
@@ -1,6 +1,7 @@
|
|
|
import cv2
|
|
|
import numpy as np
|
|
|
import os
|
|
|
+import threading
|
|
|
from io import BytesIO
|
|
|
from PIL import Image
|
|
|
from ppadb.client import Client as AdbClient
|
|
|
@@ -35,6 +36,18 @@ def find_center(x1, y1, x2, y2):
|
|
|
return centerX, centerY
|
|
|
|
|
|
|
|
|
+def call_device_shell(action, timeout=10):
|
|
|
+ def target():
|
|
|
+ device.shell(action)
|
|
|
+
|
|
|
+ thread = threading.Thread(target=target)
|
|
|
+ thread.start()
|
|
|
+ thread.join(timeout)
|
|
|
+ if thread.is_alive():
|
|
|
+ print("ran into timeout")
|
|
|
+ thread.join()
|
|
|
+
|
|
|
+
|
|
|
def tap(x, y=None):
|
|
|
# Check if x is an int
|
|
|
if isinstance(x, int):
|
|
|
@@ -53,7 +66,7 @@ def tap(x, y=None):
|
|
|
# Assuming 'device' is a previously defined object with a 'shell' method
|
|
|
action = f"input tap {location}"
|
|
|
print(action)
|
|
|
- device.shell(action)
|
|
|
+ call_device_shell(action, timeout=5)
|
|
|
|
|
|
|
|
|
def tap_button(template):
|
|
|
@@ -66,7 +79,7 @@ def tap_button(template):
|
|
|
def swipe(start, end, duration=1000):
|
|
|
action = f"input swipe {start} {end} {duration}"
|
|
|
print(action)
|
|
|
- device.shell(action)
|
|
|
+ call_device_shell(action, timeout=5)
|
|
|
|
|
|
|
|
|
def look_for_templates(templates):
|