コード例 #1
0
        private static void SetIcons(ApkInfo apkInfo, string[] apkOut, string apkFilePath)
        {
            var icons = new HashSet <string>();

            for (var i = 3; i < apkOut.Length; i++)
            {
                if (apkOut[i].StartsWith(AppIcon))
                {
                    var splited = apkOut[i].Split('\'');
                    icons.Add(splited[1]);
                }
            }
            var rootPath = ApkTempFilePath(apkInfo.PackageName, apkInfo.VersionName);

            foreach (var icon in icons)
            {
                var dir = Path.GetDirectoryName(Path.Combine(rootPath, icon));
                if (dir == null)
                {
                    continue;
                }
                Directory.CreateDirectory(dir);
                ConsoleExecutor.Execute(@"Extensions\unzip.exe", "-j", "-o", "\"" + apkFilePath + "\"",
                                        icon, "-d", "\"" + dir + "\"");
                apkInfo.Icons.Add(new Uri(Path.Combine(rootPath, icon)));
            }
        }
コード例 #2
0
        /// <summary>
        /// Parses an apk file and returns its major information
        /// </summary>
        /// <param name="apkFilePath">path to the apk file</param>
        /// <returns><see cref="ApkInfo"/> major info of the apk</returns>
        public static ApkInfo Parse(string apkFilePath)
        {
            if (!File.Exists(apkFilePath))
            {
                throw new FileNotFoundException(apkFilePath + " file not found!");
            }
            string output = ConsoleExecutor.Execute(@"Extensions\aapt.exe", "dump",
                                                    "badging", "\"" + apkFilePath + "\"");

            string[] apkOut  = output.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            ApkInfo  apkInfo = new ApkInfo();

            SetPackageData(apkInfo, apkOut[0]);
            SetSdkData(apkInfo, apkOut[1], apkOut[2]);
            SetPermissionsAndLabel(apkInfo, apkOut);
            SetIcons(apkInfo, apkOut, apkFilePath);
            return(apkInfo);
        }