MCPcopy Index your code
hub / github.com/TencentQQGYLab/AppAgent / swipe

Method swipe

scripts/and_controller.py:154–173  ·  view source on GitHub ↗
(self, x, y, direction, dist="medium", quick=False)

Source from the content-addressed store, hash-verified

152 return ret
153
154 def swipe(self, x, y, direction, dist="medium", quick=False):
155 unit_dist = int(self.width / 10)
156 if dist == "long":
157 unit_dist *= 3
158 elif dist == "medium":
159 unit_dist *= 2
160 if direction == "up":
161 offset = 0, -2 * unit_dist
162 elif direction == "down":
163 offset = 0, 2 * unit_dist
164 elif direction == "left":
165 offset = -1 * unit_dist, 0
166 elif direction == "right":
167 offset = unit_dist, 0
168 else:
169 return "ERROR"
170 duration = 100 if quick else 400
171 adb_command = f"adb -s {self.device} shell input swipe {x} {y} {x+offset[0]} {y+offset[1]} {duration}"
172 ret = execute_adb(adb_command)
173 return ret
174
175 def swipe_precise(self, start, end, duration=400):
176 start_x, start_y = start

Callers 3

task_executor.pyFile · 0.80
step_recorder.pyFile · 0.80
self_explorer.pyFile · 0.80

Calls 1

execute_adbFunction · 0.85

Tested by

no test coverage detected