1. Phone to open adb debug
2. The program can implement multiple APK batch installation for Android phone
1.getseriaonum.py module, which gets the serial number of the connected phone
ImportOSImportThreadingImport TimeImportAdbmoduleImportGetseriaonumclassinstallapk (Threading. Thread):def __init__(self): threading. Thread.__init__(self)defRun (self): Arraydev=[] Arrayapkpackage= [R'C:\Users\liangraorao\Desktop\apk\iBiliPlayer-bili.apk'] whiletrue:udid_list=getseriaonum.get_devices () forUdidinchudid_list:ifUdidinchArraydev:Continueadbmodule.installapk (Udid, Arrayapkpackage). Start () arraydev.append (UDID) ifLen (Arraydev) > 10: Arraydev.clear ()#number of phones to install = = Number of phones installed, end loopnum =Len (getseriaonum.get_devices ())ifLen (arraydev) = =Num: BreakTime.sleep (10) installapk (). Start ()
View Code
The result is: [' 1713d0b20204 ', ' 192.168.1.101:5555 ']
2.adbmodule.py package installation and uninstallation of ADB commands
1 ImportThreading2 ImportOS3 """4 arrayapkpackage: List of apk to install5 arraypackagename: APK package name to uninstall6 """7 8 classinstallapk (Threading. Thread):9 def __init__(self, Udid, arrayapkpackage):TenThreading. Thread.__init__(self) OneSelf.udid =Udid ASelf.arrayapkpackage =Arrayapkpackage - - defRun (self): the forApkpackageinchSelf.arrayapkpackage: -Os.popen ('adb-s'+ Self.udid +'Install-r'+apkpackage) - - classunstallapk (Threading. Thread): + def __init__(self, Udid, arraypackagename): -Threading. Thread.__init__(self) +Self.udid =Udid ASelf.arraypackagename =Arraypackagename at - defRun (self): - forPackageNameinchSelf.arraypackagename: -Os.popen ('adb-s'+ Self.udid +'Uninstall'+packagename)
View Code
3.exeinstall.py Batch Install APK module
1 ImportOS2 ImportThreading3 Import Time4 ImportAdbmodule5 ImportGetseriaonum6 7 8 classinstallapk (Threading. Thread):9 def __init__(self):TenThreading. Thread.__init__(self) One A defRun (self): -Arraydev = [] -Arrayapkpackage = [R'C:\Users\admin\Desktop\apk\iBiliPlayer-bili.apk'] the whileTrue: -Udid_list =getseriaonum.get_devices () - forUdidinchudid_list: - ifUdidinchArraydev: + Continue - adbmodule.installapk (Udid, Arrayapkpackage). Start () + arraydev.append (Udid) A ifLen (Arraydev) > 10: at arraydev.clear () - - #number of phones to install = = Number of phones installed, end loop -num =Len (getseriaonum.get_devices ()) - - ifLen (arraydev) = =Num: in Break -Time.sleep (10) to +INSTALLAPK (). Start ()
View Code
4.exeuninstall.py Batch Uninstall APK
1 ImportThreading2 ImportOS3 ImportGetseriaonum4 ImportAdbmodule5 6 classunintallapk (Threading. Thread):7 def __init__(self):8Threading. Thread.__init__(self)9 Ten defRun (self): OneArraydev = [] AArraypackagename = ['Tv.danmaku.bili'] - whileTrue: -Udid_list =getseriaonum.get_devices () the forUdidinchudid_list: - ifUdidinchArraydev: - Continue - adbmodule.unstallapk (Udid, Arraypackagename). Start () + arraydev.append (Udid) - ifLen (Arraydev) > 10: + arraydev.clear () A at #number of phones to install = = Number of phones installed, end loop -num =Len (getseriaonum.get_devices ()) - - ifLen (arraydev) = =Num: - Break -Time.sleep (10) in -UNINTALLAPK (). Start ()
View Code
Batch install APK on multiple phones