public static ApkInfo Parse(DumpModel model) { if (!model.isSuccess) { return(new ApkInfo()); } var filters = new List <BaseFilter>() { new SDKFilter(), new PackageFilter(), new PermissionFilter(), new SupportScrFilter(), new ApplicationFilter() }; foreach (string msg in model.Messages) { foreach (var f in filters) { if (f.canHandle(msg)) { f.addMessage(msg); continue; } } } return(ApkInfo.Merge(filters.Select(f => f.getAPK()))); }
public static ApkInfo ExtractIcon(DumpModel model, ApkInfo apk) { bool hasIcon = false; string iconName = string.Empty; using (var archive = ZipFile.OpenRead(model.FilePath)) { ZipArchiveEntry entry; int i = archive.Entries.Count - 1; // Loop from bottom of the collection. // The largest icon is usually position at the end of package // (sorting by alphabet) for (; i > 0; i--) { entry = archive.Entries[i]; if (entry.Name.Equals(apk.IconName)) { hasIcon = true; iconName = DateTime.Now.ToString("yyyyMMddhhmmssffffff") + ".png"; entry.ExtractToFile(AAPTool.TempPath + @"\" + iconName); break; } } } apk.IconName = hasIcon ? iconName : string.Empty; return(apk); }
public static ApkInfo Parse(DumpModel model) { if (!model.isSuccess) { return(ApkInfo.Empty); } var permissions = new System.Collections.Generic.List <string>(); var supportScrs = new System.Collections.Generic.List <string>(); string ver = string.Empty, minSDK = string.Empty, targetSDK = string.Empty, icon = string.Empty, name = string.Empty, per = string.Empty, package = string.Empty; foreach (string msg in model.Messages) { if (msg.StartsWith("application:")) { icon = splitValueFromString(msg, @"icon='[\w-.\\\/]*[^']"); name = splitValueFromString(msg, @"label='[\w-.() \\\/\[\]]*[^']"); continue; } if (msg.StartsWith("package:")) { ver = splitValueFromString(msg, @"versionName='[\w-.() \/]*[^']"); package = splitValueFromString(msg, @"name='[\w.]*[^']"); continue; } if (msg.StartsWith("sdkVersion:")) { minSDK = splitValueFromString(msg, @"sdkVersion:'[0-9]{0,1}[^']"); continue; } if (msg.StartsWith("targetSdkVersion:")) { targetSDK = splitValueFromString(msg, @"targetSdkVersion:'[0-9]{0,1}[^']"); continue; } if (msg.StartsWith("uses-permission:")) { per = splitValueFromString(msg, @"'([A-Z0-9._])*"); permissions.Add(per); continue; } if (msg.StartsWith("supports-screens:")) { if (msg.Contains(ApkInfo.SmallScreen)) { supportScrs.Add(ApkInfo.SmallScreen); } if (msg.Contains(ApkInfo.NormalScreen)) { supportScrs.Add(ApkInfo.NormalScreen); } if (msg.Contains(ApkInfo.LargeScreen)) { supportScrs.Add(ApkInfo.LargeScreen); } if (msg.Contains(ApkInfo.xLargeScreen)) { supportScrs.Add(ApkInfo.xLargeScreen); } continue; } } return(new ApkInfo() { FullPath = model.FilePath, AppName = name, PackageName = package, Version = ver, MinSDK = SDKInfo.GetInfo(minSDK), TargetSDK = SDKInfo.GetInfo(targetSDK), IconName = icon, Permissions = permissions, SupportScreens = supportScrs }); }