您好,登錄后才能下訂單哦!
def adbcmdapk(filepath):
if not os.path.exists(filepath):
return 0
getPackageActivity = 'aapt d badging %s |findstr "package launchable-activity"' % (filepath)
result = os.popen(getPackageActivity).readlines()
packageandpackage = {}
package = ""
activity = ""
for i in range(len(result)):
if "package" in result[i]:
nameNumber = result[i].find("e='")
versionCodeNumber = result[i].find("' v")
package = result[i][nameNumber + 3:versionCodeNumber]
if "launchable-activity" in result[i]:
nameNumber = result[i].find("e='")
versionCodeNumber = result[i].find("' l")
activity = result[i][nameNumber + 3:versionCodeNumber]
# 添加到字典中
packageandpackage[package] = activity
return packageandpackage
if __name__ == '__main__':
pa = "E:\\toontest3.8.1.apk"
print(adbcmdapk(pa))
{'com.systoon.toon': 'com.systoon.toon.user.login.view.WelcomeActivity'}
class ApkInfo():
def __init__(self, apkPath):
self.apkPath = apkPath
def getApkBaseInfo(self):
p = subprocess.Popen("aapt dump badging %s" % self.apkPath, stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE, shell=True)
(output, err) = p.communicate()
match = re.compile("package: name='(\S+)' versionCode='(\d+)' versionName='(\S+)'").match(output.decode())
if not match:
raise Exception("can't get packageinfo")
packagename = match.group(1)
versionCode = match.group(2)
versionName = match.group(3)
print('packagename:' + packagename)
print('versionCode:' + versionCode)
print('versionName:' + versionName)
return packagename, versionName, versionCode
if name == 'main':
ApkInfo(r"E:\toontest3.8.1.apk").getApkBaseInfo()
packagename:com.systoon.toon
versionCode:1803060450
versionName:3.8.1
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。