Exemplo n.º 1
0
        // 替换除包名路径下,所有R文件中的id信息
        public static void updateALL_RIds(String unpackDir, String package, Dictionary <String, List <xmlNode> > gemeDicSrc, Dictionary <String, List <xmlNode> > DicSrc, Dictionary <String, List <xmlNode> > DicTar, Cmd.Callback call, bool R_Process_Game = false)
        {
            String        packagePath = unpackDir + "\\smali\\" + package.Trim('.').Replace('.', '\\');
            List <String> R_path      = getR_smaliPath(unpackDir);

            int i = 0;

            foreach (String R_smaliDir in R_path)
            {
                if (!R_smaliDir.Equals(packagePath))                    // 非包名路径下的R文件所在路径
                {
                    //string relative = ApkCombine.relativePath(R_smaliDir, unpackDir);
                    //if (relative.StartsWith("smali\\android\\")) continue;
                    //else if (relative.StartsWith("smali\\com\\helpshift")) continue;

                    //string ortherR = ApkCombine.relativePath(R_smaliDir, unpackDir);
                    //if (ortherR.Contains(@"\android\")) continue;     // 忽略android路径下的R文件修改

                    //String relaPath = ApkCombine.relativePath(R_smaliDir, unpackDir);
                    //if (relaPath.Equals(@"smali\com\google\android\gms\common"))
                    //    relaPath = relaPath + "";

                    if (call != null)
                    {
                        call("【I】- 7." + ++i + " 修改路径" + ApkCombine.relativePath(R_smaliDir, unpackDir) + "下所有R文件id信息");
                    }
                    update_RDirIds(R_smaliDir, DicSrc, DicTar, call);
                    if (R_Process_Game)
                    {
                        update_RDirIds(R_smaliDir, gemeDicSrc, DicTar, call);                  // 修改游戏包中对应的资源id
                    }
                }
            }
        }
Exemplo n.º 2
0
        // -------------------------------------------

        //unknownFiles:
        //com/tencent/mm/sdk/platformtools/rep5402863540997075488.tmp: '8'
        //com/fxlib/util/version.txt: '8'
        /// <summary>
        /// 修改apktool.yml中的Unknown文件列表
        /// </summary>
        public static void appendunknown(String dirTarget, Cmd.Callback call)
        {
            // 获取文件内容
            String apktoolYmlPath = dirTarget + "\\apktool.yml";
            String apktoolYml     = FileProcess.fileToString(apktoolYmlPath);
            String apktoolYml0    = apktoolYml;

            // 获取文件原有unknown部分
            String unknownFiles = "";

            if (apktoolYml.Contains("unknownFiles"))
            {
                unknownFiles = apktoolYml.Substring(apktoolYml.IndexOf("unknownFiles"));
            }

            String unknown = dirTarget + "\\unknown";

            String[] files = getAllFiles(unknown).Split(';');
            if (files != null && files.Length > 0)
            {
                if (call != null)
                {
                    call("【I】- 8.修改apktool.yml中的Unknown文件列表:");
                }

                // 生成新的unknown
                String appendUnknowns = "";
                foreach (String file in files)
                {
                    String relativeName = ApkCombine.relativePath(file, unknown).Replace('\\', '/');
                    appendUnknowns += "\n  " + relativeName + ": '8'";
                    if (call != null)
                    {
                        call("【I】Unknown添加:" + relativeName);
                    }
                }
                if (!appendUnknowns.Equals(""))
                {
                    appendUnknowns = "unknownFiles:" + appendUnknowns + "\n";
                }


                // 替换为新的unknown文件列表信息
                if (unknownFiles.Equals(""))
                {
                    apktoolYml = apktoolYml + appendUnknowns;
                }
                else
                {
                    apktoolYml = apktoolYml.Replace(unknownFiles, appendUnknowns);
                }
            }

            // 文件内容变动,则保存为新的apktoolYml
            if (!apktoolYml.Equals(apktoolYml0))
            {
                FileProcess.SaveProcess(apktoolYml, apktoolYmlPath);
                if (call != null)
                {
                    call("【I】对apktool.yml的修改已保存!\r\n");
                }
            }
        }