90 lines
2.6 KiB
Python
90 lines
2.6 KiB
Python
import adb
|
|
import random
|
|
|
|
class _Action:
|
|
def __init__(self, id, scr_w, scr_h):
|
|
self.id = id
|
|
self.scr_w = scr_w
|
|
self.scr_h = scr_h
|
|
self.operator = adb.Operator(self.id)
|
|
|
|
# 唤醒
|
|
def wakeup(self):
|
|
pass
|
|
|
|
# 解锁
|
|
def unlock(self):
|
|
pass
|
|
|
|
# 锁屏
|
|
def lock(self):
|
|
self.operator.home()
|
|
self.operator.power()
|
|
|
|
# 返回
|
|
def back(self):
|
|
self.operator.back()
|
|
|
|
# 划动
|
|
def swipe(self, x1, y1, x2, y2, time):
|
|
self.operator.swipe(x1, y1, x2, y2, time)
|
|
|
|
# 上滑
|
|
def swipe_up(self, dist, speed):
|
|
|
|
x1 = int(self.scr_w * 0.45) + int(random.uniform(-10, 10))
|
|
y1 = int(self.scr_h * 0.7) + int(random.uniform(-10, 10))
|
|
x2 = x1 + int(random.uniform(-10, 10))
|
|
y2 = y1 - dist + int(random.uniform(-10, 10))
|
|
time = speed - int(random.uniform(-10, 10))
|
|
self.operator.swipe(x1, y1, x2, y2, time)
|
|
|
|
# 下滑
|
|
def swipe_down(self, dist, speed):
|
|
x1 = int(self.scr_w * 0.45) + int(random.uniform(-10, 10))
|
|
y1 = int(self.scr_h * 0.6) + int(random.uniform(-10, 10))
|
|
x2 = x1 + int(random.uniform(-10, 10))
|
|
y2 = y1 + dist + int(random.uniform(-10, 10))
|
|
time = speed + int(random.uniform(-10, 10))
|
|
self.operator.swipe(x1, y1, x2, y2, time)
|
|
|
|
# 左滑
|
|
def swipe_left(self, dist, speed):
|
|
x1 = int(self.scr_w * 0.7) + int(random.uniform(-10, 10))
|
|
y1 = int(self.scr_h * 0.75) + int(random.uniform(-10, 10))
|
|
x2 = x1 - dist + int(random.uniform(-10, 10))
|
|
y2 = y1 + int(random.uniform(-10, 10))
|
|
time = speed + int(random.uniform(-10, 10))
|
|
self.operator.swipe(x1, y1, x2, y2, time)
|
|
|
|
# 右滑
|
|
def swipe_right(self, dist, speed):
|
|
x1 = int(self.scr_w * 0.3) + int(random.uniform(-10, 10))
|
|
y1 = int(self.scr_h * 0.75) + int(random.uniform(-10, 10))
|
|
x2 = x1 + dist + int(random.uniform(-10, 10))
|
|
y2 = y1 + int(random.uniform(-10, 10))
|
|
time = speed + int(random.uniform(-10, 10))
|
|
self.operator.swipe(x1, y1, x2, y2, time)
|
|
|
|
# 点击
|
|
def click(self, point):
|
|
self.operator.touch(point.x, point.y)
|
|
|
|
class _Device(_Action):
|
|
|
|
def __init__(self, id, scr_w, scr_h):
|
|
super().__init__(id, scr_w, scr_h)
|
|
self.id = id
|
|
self.scr_w = scr_w
|
|
self.scr_h = scr_h
|
|
self.apps = []
|
|
|
|
def screen_width(self):
|
|
return self.scr_w
|
|
|
|
def screen_height(self):
|
|
return self.scr_h
|
|
|
|
class WikoHi70m(_Device):
|
|
def __init__(self, id):
|
|
super().__init__(id, 900, 1600) |