-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadbshell.py
More file actions
34 lines (27 loc) · 850 Bytes
/
adbshell.py
File metadata and controls
34 lines (27 loc) · 850 Bytes
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
import os
import random
import json
from time import sleep
from logging import debug,info
class ADBHelper:
def __init__(self):
pass
def init_adb(self):
self.runcmd('adb devices')
def runcmd(self,cmd):
debug(cmd)
debug(os.popen(cmd).read())
def tap(self,pos,delay=0):
if delay==0:
self.runcmd(f"adb shell input tap {pos[0]} {pos[1]}")
else:
self.runcmd(f"adb shell input swipe {pos[0]} {pos[1]} {pos[0]} {pos[1]} {delay}")
def pull_screenshot(self):
self.runcmd('adb shell screencap -p /sdcard/screenshot.png')
self.runcmd('adb pull /sdcard/screenshot.png ./')
if __name__=="__main__":
pointdata=None
with open('pointdata.json','r') as f:
pointdata=json.load(f)
adbhelper=ADBHelper()
adbhelper.init_adb()