feat: 添加养号模式下的桌面检测和自救恢复功能;优化评论操作和定时触发逻辑
This commit is contained in:
1 parent
4d805474db
commit
d36b73d3df
4 files changed
+261
-75
No files matched your search
@@ -2731,6 +2731,10 @@ class underlying_operations:
|
||||
|
||||
def click(self, device_id, x=500, y=500):
|
||||
"""点击坐标位置"""
|
||||
try:
|
||||
print(f"[Underlying] click: device_id={device_id} coord=({x},{y})")
|
||||
except Exception:
|
||||
pass
|
||||
os.system("{} -s {} shell input tap {} {}".format(self._adb(), device_id, x, y))
|
||||
|
||||
def long_press(
|
||||
@@ -3093,9 +3097,17 @@ class underlying_operations:
|
||||
|
||||
# 先确保输入框获得焦点
|
||||
try:
|
||||
try:
|
||||
print(f"[Underlying] paste_text_at: clicking to focus device_id={device_id} coord=({x},{y})")
|
||||
except Exception:
|
||||
pass
|
||||
self.click(device_id, int(x), int(y))
|
||||
time_module.sleep(0.2)
|
||||
# 有些输入框第一次点不进,补一次轻点
|
||||
try:
|
||||
print(f"[Underlying] paste_text_at: clicking again to ensure focus device_id={device_id} coord=({x},{y})")
|
||||
except Exception:
|
||||
pass
|
||||
self.click(device_id, int(x), int(y))
|
||||
time_module.sleep(0.15)
|
||||
except Exception:
|
||||
@@ -3104,19 +3116,50 @@ class underlying_operations:
|
||||
# 0) 优先:ADBKeyboard(如果已安装/可用)
|
||||
# 说明:这一步不依赖剪贴板/粘贴菜单,通常对中文更稳定
|
||||
try:
|
||||
if self.input_text_adbkeyboard(device_id, t, restore_prev=False):
|
||||
ok_adbkb = False
|
||||
try:
|
||||
ok_adbkb = bool(self.input_text_adbkeyboard(device_id, t, restore_prev=False))
|
||||
except Exception:
|
||||
ok_adbkb = False
|
||||
try:
|
||||
print(f"[Underlying] paste_text_at: input_text_adbkeyboard -> {ok_adbkb}")
|
||||
except Exception:
|
||||
pass
|
||||
if ok_adbkb:
|
||||
return True
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 1) 优先:剪贴板 + 粘贴键
|
||||
if self.set_clipboard_text(device_id, t):
|
||||
ok_clip = False
|
||||
try:
|
||||
ok_clip = bool(self.set_clipboard_text(device_id, t))
|
||||
except Exception:
|
||||
ok_clip = False
|
||||
try:
|
||||
print(f"[Underlying] paste_text_at: set_clipboard_text -> {ok_clip}")
|
||||
except Exception:
|
||||
pass
|
||||
if ok_clip:
|
||||
# 给系统一点时间刷新剪贴板
|
||||
time_module.sleep(0.15)
|
||||
if self.paste_from_clipboard(device_id):
|
||||
ok_paste = False
|
||||
try:
|
||||
ok_paste = bool(self.paste_from_clipboard(device_id))
|
||||
except Exception:
|
||||
ok_paste = False
|
||||
try:
|
||||
print(f"[Underlying] paste_text_at: paste_from_clipboard -> {ok_paste}")
|
||||
except Exception:
|
||||
pass
|
||||
if ok_paste:
|
||||
return True
|
||||
|
||||
# 2) 兜底:adb input text(中文可能不稳定)
|
||||
try:
|
||||
print(f"[Underlying] paste_text_at: falling back to input_text for device_id={device_id}")
|
||||
except Exception:
|
||||
pass
|
||||
return self.input_text(device_id, t)
|
||||
|
||||
def _uiautomator_dump(self, device_id: str, local_path: str) -> bool:
|
||||
|
||||
Reference in new issue
Block a user