代码如下:
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‘}
原文地址:https://blog.51cto.com/357712148/2371626
时间: 2024-10-14 01:37:23