Exemplo n.º 1
0
        // 从resDic中的id信息生成R*smali文件
        public static void rebuidR_smali(Dictionary <String, List <xmlNode> > resDic, String TargetDir, String packageName, Cmd.Callback call)
        {
            if (resDic == null || resDic.Count == 0)
            {
                return;
            }

            // 创建包名对应的路径
            String TargetPath = TargetDir + "\\" + packageName.Trim('.').Replace('.', '\\');    // 形如 com\ltsdk_56_base\leshi

            DependentFiles.checkDir(TargetPath);

            // 按照res中的type类型,生成对应的R$type.smali文件资源到指定的包名、路径下
            foreach (String typeName in resDic.Keys)
            {
                if (typeName.Equals("AllType"))
                {
                    continue;
                }

                List <xmlNode> typeList = resDic[typeName];
                createSmali(TargetPath, packageName, typeName, typeList, call);
            }

            // 生成BuildConfig.smali
            createBuildConfig(TargetPath, packageName, call);
        }
Exemplo n.º 2
0
        // 应用程序,入口逻辑
        public static void call()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (Update.Updated())
            {
                DependentFiles.checksAll();     // 检测工具运行依赖文件
                ToolSetting.Instance();         // 载入工具的配置信息

                //Application.Run(new Form2());
                Application.Run(new Form4());
            }
        }
Exemplo n.º 3
0
        // 将Source中的选中项添加到Target中
        private void move(List <String> Source, List <String> Target, ListBox.SelectedIndexCollection collection, bool updateFile = false)
        {
            List <String> iteams = new List <string>();

            foreach (int index in collection)
            {
                if (!Target.Contains(Source[index]))
                {
                    Target.Add(Source[index]);

                    // 更新渠道包配置信息到本地
                    if (updateFile)
                    {
                        DependentFiles.updateFiles("渠道计费包/" + Source[index] + "/");
                    }
                }
                iteams.Add(Source[index]);
            }

            foreach (String iteam in iteams)
            {
                Source.Remove(iteam);
            }
        }
Exemplo n.º 4
0
        // 载入所需信息
        private void load()
        {
            ToolSetting.instance = null;                             // 请除原有配置信息
            settting             = ToolSetting.Instance();           // 载入配置信息
            if (StartParam.AutoRun && !StartParam.OUTDIR.Equals("")) // 设置apk输出目录
            {
                settting.outputAPK_dir = StartParam.OUTDIR;
            }

            Form1.loadSigns(comboBox_sign);                 // 载入签名文件信息

            gameList = gameList_Data.getGameList(OutPut);   // 获取游戏列表信息
            gameIds  = gameList.Keys.ToList();              // 记录游戏id信息

            if (StartParam.AutoRun)
            {
                // 设置打包的游戏id
                int index = gameIds.Contains(StartParam.GAMEID) ? gameIds.IndexOf(StartParam.GAMEID) : 0;
                Form3.setGameList(comboBox_selectGame, gameList, index);
            }
            else
            {
                Form3.setGameList(comboBox_selectGame, gameList);
            }

            channelList = channelList_Data.getChannelList(OutPut);                     // 获取游戏列表信息
            settting.AppendLocalChannels(channelList);                                 // 向渠道列表信息中添加本地的渠道列表信息

            channelIds = channelList.Keys.ToList();                                    // 记录渠道id信息

            setStartButtonEnable(gameList.Count > 0 && channelList.Count > 0, "网络异常"); // 设置打包按钮是否可用


            // 从左侧渠道列表中移除右侧已选中的渠道信息
            if (selectChannelIds.Count > 0)
            {
                foreach (string id in selectChannelIds)
                {
                    if (channelIds.Contains(id))
                    {
                        channelIds.Remove(id);
                    }
                }
            }

            //channelIds = getSubDirNames(settting.chargeAPK_dir);    // 获取所有计费渠道信息
            ShowChannelList(listBox2.Items.Count > 0);

            // 载入通用配置信息
            if (initLoading)
            {
                initLoading = false;

                DependentFiles.updateFiles("渠道计费包/通用配置.txt");
                DependentFiles.updateFiles("渠道计费包/所有渠道/");
                DependentFiles.updateFiles("游戏裸包/1000/v1.test/");
                DependentFiles.updateFiles("游戏附加配置/");

                if (StartParam.AutoRun)
                {
                    // 设置选择的渠道id
                    String[] channels = StartParam.CHANNELID.Replace(',', ',').Replace(';', ',').Replace(';', ',').Split(',');
                    String[] ICONDIRs = StartParam.ICONDIR.Replace(',', ',').Replace(';', ',').Replace(';', ',').Split(',');    // 渠道id对应的Icon

                    for (int i = 0; i < channels.Length; i++)
                    {
                        String channel = channels[i];
                        if (channelIds.Contains(channel))
                        {
                            int index = channelIds.IndexOf(channel);
                            listBox1.SetSelected(index, true);
                        }

                        if (i < ICONDIRs.Length && !channelIconDir.ContainsKey(channel))
                        {
                            channelIconDir.Add(channel, ICONDIRs[i]);
                        }
                    }
                    button1_Click(null, null);
                }
            }
        }
Exemplo n.º 5
0
        //从dirTarget目录下获取res资源,重新编译生成public.xml
        private static bool UpdatePublicXML(String dirTarget, Cmd.Callback call)
        {
            ToolSetting settting = ToolSetting.Instance();  // 载入设置信息

            if (call != null)
            {
                call("【I】- 2.解包Empty.apk");
            }
            String emptyApk = DependentFiles.curDir() + "\\tools\\Empty.apk";   // 空项目资源路径

            if (emptyApk.Contains("\\\\"))
            {
                emptyApk = emptyApk.Replace("\\\\", "\\");
            }
            String emptyDir = Apktool.unPackage(emptyApk, null, false);         // 解包空apk

            if (emptyDir.Contains("【E】") && call != null)
            {
                call("【E】  解包Empty.apk异常");
                return(false);
            }

            if (call != null)
            {
                call("【I】-   复制游戏res资源");
            }
            String Res = emptyDir + "\\res";

            ApkCombine.CopyFolderTo(dirTarget + "\\res", Res, true); // 复制Target目录到res目录,到空工程解包路径下

            Program.Delay(3000);                                     // 部分机器复制文件,存在异步延时,确保文件复制完成
            if (call != null)
            {
                call("【I】- 3.使用新的res资源,生成新的Empty.apk");
            }
            String apkFile = Apktool.package(emptyDir, null);                   // 使用apktool进行打包

            if (apkFile.Contains("【E】") && call != null)
            {
                call("【E】  打包Empty.apk异常");
                call("【E】  异常信息:" + apkFile);
                return(false);
            }

            if (call != null)
            {
                call("【I】- 4.解包Empty.apk");
            }
            string unpackDir = Apktool.unPackage(apkFile, null, false);         // 使用apktool进行apk的解包,生成新的public.xml

            if (unpackDir.Contains("【E】") || unpackDir.Trim().Equals(""))
            {
                if (call != null)
                {
                    call("【E】  解包Empty.apk异常");
                }
                return(false);
            }

            if (call != null)
            {
                call("【I】- 5.复制生成的public.xml文件,到游戏res目录中");
            }
            String relativePath = @"\res\values\public.xml";

            File.Copy(unpackDir + relativePath, dirTarget + relativePath, true);      // 替换原有public.xml

            relativePath = @"\res\drawable\empty_ic_launcher.png";
            File.Copy(unpackDir + relativePath, dirTarget + relativePath, true);
            relativePath = @"\res\layout\empty_activity_main.xml";
            File.Copy(unpackDir + relativePath, dirTarget + relativePath, true);

            if (call != null)
            {
                call("【I】-   清除Empty.apk相关缓存资源...");
            }

            // 清除缓存资源
            Directory.Delete(emptyDir, true);       // 删除空项目解包文件
            File.Delete(apkFile);                   // 删除生成的临时文件
            Directory.Delete(unpackDir, true);      // 删除空工程解包目录

            return(true);
        }
Exemplo n.º 6
0
        // 根据type类型从Src拷贝仅存在与Src中的项到Target目录下
        private static void copyR_smali(String source, String target, String pNameSrc, String pNameTar, List <String> typeListSrc, List <String> typeListTar, Dictionary <String, List <xmlNode> > DicSrc, Dictionary <String, List <xmlNode> > DicTar, Cmd.Callback call, bool delet = false)
        {
            String SourcePath = source + "\\smali\\" + pNameSrc.Trim('.').Replace('.', '\\');    // 形如 com\ltsdk_56_base\leshi
            String TargetPath = target + "\\smali\\" + pNameTar.Trim('.').Replace('.', '\\');

            DependentFiles.checkDir(TargetPath);

            foreach (String type in typeListSrc)
            {
                String name       = "R$" + type + ".smali";
                String fileSource = SourcePath + "\\" + name;          // 获取type类型对应的smali文件
                String fileTarget = TargetPath + "\\" + name;
                if (File.Exists(fileSource))
                {
                    if (!typeListTar.Contains(type))                   // 该smali文件之前未曾生成,则自动复制
                    {
                        List <xmlNode> listSrc = new List <xmlNode>();
                        List <xmlNode> listTar = new List <xmlNode>();

                        if (DicSrc.ContainsKey(type))
                        {
                            listSrc = DicSrc[type];
                        }
                        else
                        {
                            listSrc = DicSrc["AllType"];
                        }
                        //{
                        //    if (call != null) call("【I】" + SourcePath + "对应的public.xml不含有type类型:" + type);
                        //    //listSrc = ToListNode(DicSrc);   // 获取DicSrc中所有节点id信息
                        //}

                        if (DicTar.ContainsKey(type))
                        {
                            listTar = DicTar[type];
                        }
                        else
                        {
                            listTar = DicTar["AllType"];
                        }
                        //{
                        //    if (call != null) call("【I】" + TargetPath + "对应的public.xml不含有type类型:" + type);
                        //    //listTar = ToListNode(DicTar);   // 获取DicTar中所有节点id信息
                        //}

                        if (call != null)
                        {
                            call("【I】复制" + name + "从" + SourcePath + "->" + TargetPath);
                        }
                        //File.Copy(fileSource, fileTarget, true);
                        MoveR_smali(fileSource, fileTarget, pNameSrc, pNameTar, listSrc, listTar, call, delet);
                    }
                    else if (delet && !fileSource.Equals(fileTarget)) // 原文件与目标文件不是相同文件,则删除
                    {
                        File.Delete(fileSource);
                        if (call != null)
                        {
                            call("【I】删除文件," + fileSource);
                        }
                    }
                }
                else if (call != null)
                {
                    call("【I】文件丢失," + fileSource + "...");
                }
            }

            if (delet) // 删除原有的R.smali
            {
                String fileSource = SourcePath + "\\R.smali";
                if (File.Exists(fileSource))
                {
                    File.Delete(fileSource);
                    if (call != null)
                    {
                        call("【I】删除文件," + fileSource);
                    }
                }
            }
        }