def getPKGInfo(): keyword = input("请输入您需要过滤的package关键字,多个关键字以逗号区分:") filterList = keyword.split(",") pkgList = [] for item in filterList: pmStr = "pm list package |grep " + item out = d.shell(pmStr) pkglist1 = str(out).split("='")[1].split("',")[0].split("package:")[1:] pkgList.extend(pkglist1) # print(pkgList) pkgFile = open("./pkgInfoFile_PList.txt", mode="w+") actFile = open("./pkgInfoFile_AList.txt", mode="w+") packageNameList = [] activityNameList = [] # 过滤掉不具备Launcher属性的package for item in pkgList: launcherStr = "dumpsys package " + item.strip("\n") + " |grep LAUNCHER" out = d.shell(launcherStr) # 提取具有Launcher属性的package if str(out).find("LAUNCHER") != -1: packageName = item.strip("\n") packageNameList.append(packageName + "n") actStr = "dumpsys package " + item.strip("\n") + " |grep " + item.strip("\n") # 提取ActivityName out = d.shell(str(actStr)) activityName = str(out).split("\n")[0].split(" ")[9] activityNameList.append(activityName + "n") pkgFile.writelines(packageNameList) actFile.writelines(activityNameList) pkgFile.flush() actFile.flush() pkgFile.close() actFile.close()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)