验证中...
开源中国 2018 年度最后一场技术盛会邀你来约~错过就要等明年啦!点此立即预约
getApksFromPhone.py
原始数据 复制代码
#coding:utf-8
import os
class getApksFromPhone:
apkPackageList = []
deviceName = ''
def __init__(self, deviceName):
self.deviceName = deviceName
@staticmethod
def execCmd(cmd):
try:
return os.popen(cmd).read()
except Exception:
return None
def getAllPackageNames(self):
apps = self.execCmd("adb -s " + self.deviceName + " shell pm list packages -3")
# print 'apps:', apps
self.apkPackageList = apps.split('\n')
for apkPackage in self.apkPackageList:
if apkPackage == '':
self.apkPackageList.remove(apkPackage)
continue
elif 'wifi' in apkPackage or 'uiautomator' in apkPackage:
self.apkPackageList.remove(apkPackage)
continue
elif 'supersu' in apkPackage:
self.apkPackageList.remove(apkPackage)
continue
else:
# print apkPackage
pass
def pullApksFromPhone(self):
self.getAllPackageNames()
for apkPackage in self.apkPackageList:
packageName = apkPackage.split(":")[1]
apkpath = self.execCmd("adb shell pm path " + packageName);
apkRealPath = apkpath.split(":")[1].replace("\n", "")
str1 = "adb pull " + apkRealPath + " ./apks/" + packageName + ".apk"
print str1
self.execCmd(str1)
# main function
if __name__ == '__main__':
getApks = getApksFromPhone('CJL7N16831000492') # 改成你的手机ID
getApks.pullApksFromPhone()

评论列表( 0 )

你可以在登录后,发表评论

搜索帮助

12_float_left_people 12_float_left_close