-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInstallTopXFreeApps.py
More file actions
122 lines (111 loc) · 3.2 KB
/
InstallTopXFreeApps.py
File metadata and controls
122 lines (111 loc) · 3.2 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import uiautomator,os,sys,datetime,time
from uiautomator import Device
device='null'
def intializtion():
global device
print 'Getting Device Info'
os.system('adb devices > deviceinfo')
devinf = open('deviceinfo','rb')
dev = devinf.readlines()[1].split('\t')[0]
print dev
devinf.close()
device=Device(dev)
def launch_store():
global device
print 'Launching Playstore'
os.system('adb shell am start -n com.android.vending/com.google.android.finsky.activities.MainActivity')
while True :
if device(text="APPS").exists :
device(text="APPS").click()
print "Success ; APPS Tab Launched"
time.sleep(1)
break
while True :
if device(text="TOP FREE").exists :
device(text="TOP FREE").click()
print "Success ; TOP FREE Tab Launched"
time.sleep(1)
break
def install(n):
global device
lastnum=n-2
num=str(n)
num=num+"."
while True :
if device(textStartsWith=num).exists :
device(textStartsWith=num).click()
print "Success ; APP%s Details Launched" % n
time.sleep(1)
break
else :
# device(textStartsWith=lastnum).swipe.up(steps=400)
device().scroll.vert.forward(steps=1000)
install_needed=0
while True :
if device(text="OPEN").exists :
print "Already Installaed Skipping Installation of APP %s" % n
time.sleep(2)
break
if device(text="INSTALL").exists :
device(text="INSTALL").click()
install_needed=1
print "Success ; APP%s Install Clicked; Waiting for permission accept.." % n
time.sleep(2)
break
if device(description='Cancel this download' , className='android.widget.ImageView').exists :
print "Already installation in progress Skipping Installation of APP %s" % n
time.sleep(2)
break
if install_needed :
while True :
if device(text="ACCEPT").exists :
device(text="ACCEPT").click()
print "Success ; Installing APP%s " % n
time.sleep(2)
break
if device(text="PROCEED").exists :
device(text="PROCEED").click()
if device(text="OK").exists :
device(text="OK").click()
break
'''
os.system("adb shell input keyevent KEYCODE_DPAD_DOWN")
os.system("adb shell input keyevent KEYCODE_DPAD_DOWN")
os.system("adb shell input keyevent KEYCODE_DPAD_DOWN")
os.system("adb shell input keyevent KEYCODE_DPAD_DOWN")
os.system("adb shell input keyevent KEYCODE_DPAD_DOWN")
os.system("adb shell input keyevent KEYCODE_ENTER")
print "Success ; Installing Game%s .." % n
'''
'''
while True :
if device(text="OPEN").exists :
device(text="OPEN").click()
time.sleep(10)
print "Success ; Installation of Game%s Complete.." % n
break
'''
device.screenshot("APP"+str(n)+".jpg")
print 'Going back to APP list'
device.press.back()
# os.system("adb shell am force-stop com.android.vending")
def main():
intializtion()
launch_store()
if sys.argv==2 :
print 'Installing Top %s Apps ' % sys.argv[2]
n=int(sys.argv[1])
else :
print 'Default : Installing Top 50 Apps '
n=50
for i in xrange(1,n+1):
print "Install APP %s " % i
install(i)
print "Done, Installation"
'''
current_time = datetime.datetime.now().time()
current_date = datetime.datetime.now().date()
timestamp = current_date.isoformat()+'-'+current_time.isoformat().split('.')[0].replace(':','-')
'''
if __name__=='__main__':
main()