-
Notifications
You must be signed in to change notification settings - Fork 7
/
GetPermission.py
69 lines (63 loc) · 2.03 KB
/
GetPermission.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
#coding=utf-8
import thread
import threading
from uiautomator import Device
class GetPermission(threading.Thread):
def __init__(self,deviceId):
threading.Thread.__init__(self)
self._deviceId=deviceId
self._isRunning=True
def stop(self):
self._isRunning=False
def run(self):
device=Device(self._deviceId)
print("GetPermission --> "+self._deviceId)
while self._isRunning:
try:
if device(text=u"允许").wait.exists(timeout=2000):
device(text=u"允许",className="android.widget.Button").click()
print("允许")
device(text=u"允许",className="android.widget.Button").click()
print("允许")
elif device(text=u"同意").wait.exists(timeout=2000):
device(text=u"同意",className="android.widget.Button").click()
print("同意")
device(text=u"同意",className="android.widget.Button").click()
print("同意")
elif device(text=u"继续安装").wait.exists(timeout=2000):
device(text=u"继续安装",className="android.widget.Button").click()
print("继续安装")
device(text=u"继续安装",className="android.widget.Button").click()
print("继续安装")
except:
pass
# try:
# device(text=u"允许",className="android.widget.Button").click()
# print("允许")
# device(text=u"允许",className="android.widget.Button").click()
# print("允许")
# except:
# pass
# if(not self._isRunning):
# print("exit GetPermission")
# break
# try:
# device(text=u"同意",className="android.widget.Button").click()
# print("同意")
# device(text=u"同意",className="android.widget.Button").click()
# print("同意")
# except:
# pass
# if(not self._isRunning):
# print("exit GetPermission")
# break
# try:
# device(text=u"继续安装",className="android.widget.Button").click()
# print("继续安装")
# device(text=u"继续安装",className="android.widget.Button").click()
# print("继续安装")
# except:
# pass
# if(not self._isRunning):
# print("exit GetPermission")
# break