-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdbutils.py
77 lines (77 loc) · 1.92 KB
/
Adbutils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# import logging
# import os
# import sys
# import time
#
# from AdbClient import AdbClient
#
#
# def resource_path(relative_path):
# """获取资源文件的绝对路径"""
# try:
# base_path = getattr(sys, '_MEIPASS', os.path.abspath("."))
# except AttributeError:
# base_path = os.path.abspath(".")
#
# return os.path.join(base_path, relative_path)
#
#
# def adb_connect(n):
# if n < 5555:
# port = 16384 + 32 * n
# elif n >= 16384:
# port = n
# else:
# port = 5555
# device = AdbClient(ip='127.0.0.1', port=port)
# return device
#
#
# def get_screenshot(device):
# device.shell("screencap -p /sdcard/screenshot.png")
# device.pull('/sdcard/screenshot.png', 'screenshot.png')
#
#
# def swipe(device, start_x, start_y, end_x, end_y):
# device.shell(f"input touchscreen swipe {start_x} {start_y} {end_x} {end_y} 200")
#
#
# def zoom_out(device):
# logging.debug("zoom out")
# device.shell("sh /sdcard/zoom_out.sh") # try running the script to pinchout
#
#
# def zoom_in(device):
# device.shell("sh /sdcard/zoom_in.sh") # try running the script to zoomin
# time.sleep(3)
#
#
# def up(device):
# device.shell("input swipe {} {} {} {}".format(1000, 200, 1000, 500))
#
#
# def down(device):
# device.shell("input swipe {} {} {} {}".format(1000, 800, 1000, 500))
#
#
# def click(device, coordinate):
# x, y = coordinate
# device.shell("input tap {} {}".format(x, y))
#
#
# def back(device):
# device.shell("input keyevent 4")
#
#
# # 把缩小和放大的脚本放到模拟器上
# def send_scripts(device):
# logging.debug("send scripts")
# device.push(resource_path("static/zoom_in.sh"), "/sdcard/zoom_in.sh")
# device.push(resource_path("static/zoom_out.sh"), "/sdcard/zoom_out.sh")
#
# # devic = adb_connect(0)
# # get_screenshot(devic)
# # click(devic, 761, 644)
# # send_scripts(devic)
# # zoom_out(devic)
# # devic.disconnect()