示例#1
0
        public void editManifest(ChannelItem channel, PackageItem packageItem, string versionName)
        {
            string      manifestFile = getTempPath("WMAppManifest.xml");
            XmlDocument xd           = new XmlDocument();

            xd.Load(manifestFile);

            XmlNode xnApp = xd.DocumentElement.SelectSingleNode("App");

            xnApp.Attributes["Version"].Value     = versionName;
            xnApp.Attributes["Title"].Value       = packageItem.AppName;
            xnApp.Attributes["Publisher"].Value   = packageItem.AppName;
            xnApp.Attributes["Description"].Value = packageItem.WinPhoneDescription;
            xnApp.Attributes["ProductID"].Value   = packageItem.WinPhoneProductID;

            XmlNode xnTitle = xnApp.SelectSingleNode("Tokens/PrimaryToken/TemplateFlip/Title");

            xnTitle.InnerText = packageItem.AppName;

            xd.Save(manifestFile);
        }
示例#2
0
        public void loadConfig()
        {
            {
                XmlDocument xd = new XmlDocument();
                xd.Load(Path.Combine(Application.StartupPath, "config/channelList.xml"));

                XmlNodeList xnList = xd.SelectNodes("config/channelList/channel");

                ChannelList.Clear();
                foreach (XmlNode xn in xnList)
                {
                    ChannelItem item = new ChannelItem();
                    item.ChannelName = xn.SelectSingleNode("channelName").InnerText;
                    item.ChannelId   = xn.SelectSingleNode("channelId").InnerText;
                    ChannelList.Add(item);
                }
            }

            {
                XmlDocument xd = new XmlDocument();
                xd.Load(Path.Combine(Application.StartupPath, "config/packageList.xml"));

                XmlNodeList xnList = xd.SelectNodes("config/packageList/package");
                PackageList.Clear();
                foreach (XmlNode xn in xnList)
                {
                    PackageItem item = new PackageItem();
                    item.Title               = xn.SelectSingleNode("pkgTitle").InnerText;
                    item.PackageName         = xn.SelectSingleNode("pkgName").InnerText;
                    item.AppName             = xn.SelectSingleNode("AppName").InnerText;
                    item.ResourceDelete      = xn.SelectSingleNode("ResourceDelete").InnerText;
                    item.ResourceEncrypt     = xn.SelectSingleNode("ResourceEncrypt").InnerText;
                    item.ResourceNormal      = xn.SelectSingleNode("ResourceNormal").InnerText;
                    item.WinPhoneDescription = xn.SelectSingleNode("WinPhoneDescription").InnerText;
                    item.WinPhoneProductID   = xn.SelectSingleNode("WinPhoneProductID").InnerText;

                    XmlNodeList metaDataList = xn.SelectNodes("metaData/item");
                    foreach (XmlNode metaData in metaDataList)
                    {
                        string k = metaData.Attributes["name"].Value;
                        string v = metaData.Attributes["value"].Value;
                        item.MetaData.Add(k, v);
                    }

                    PackageList.Add(item);
                }
            }


            {
                XmlDocument xd = new XmlDocument();
                xd.Load(Path.Combine(Application.StartupPath, "config/enableList.xml"));

                XmlNodeList xnList = xd.SelectNodes("config/enableList/item");
                foreach (XmlNode xn in xnList)
                {
                    switch (xn.Attributes["name"].Value)
                    {
                    case "EnableMM":
                        EnableMM = xn.Attributes["value"].Value.Equals("true");
                        break;

                    case "EnableCopyFile":
                        EnableCopyFile = xn.Attributes["value"].Value.Equals("true");
                        break;

                    case "DeleteTemp":
                        DeleteTemp = xn.Attributes["value"].Value.Equals("true");
                        break;

                    default:
                        break;
                    }
                }

                xnList = xd.SelectNodes("config/encryptConfig/item");
                foreach (XmlNode xn in xnList)
                {
                    switch (xn.Attributes["name"].Value)
                    {
                    case "AllExts":
                    {
                        EncryptCfg.AllExts.Clear();
                        string   attrValue = xn.Attributes["value"].Value;
                        string[] strArr    = attrValue.Split(';');
                        foreach (string item in strArr)
                        {
                            EncryptCfg.AllExts.Add("." + item);
                        }
                    }
                    break;

                    case "PartExts":
                    {
                        EncryptCfg.PartExts.Clear();
                        string   attrValue = xn.Attributes["value"].Value;
                        string[] strArr    = attrValue.Split(';');
                        foreach (string item in strArr)
                        {
                            EncryptCfg.PartExts.Add("." + item);
                        }
                    }
                    break;

                    case "PartLength":
                        EncryptCfg.PartLength = Convert.ToInt32(xn.Attributes["value"].Value);
                        break;

                    default:
                        break;
                    }
                }


                CopyFileList.Clear();
                xnList = xd.SelectNodes("config/copyFileList/item");
                foreach (XmlNode xn in xnList)
                {
                    CopyFileList.Add(xn.Attributes["name"].Value);
                }

                ResourceFileList.Clear();
                xnList = xd.SelectNodes("config/resourceFileList/item");
                foreach (XmlNode xn in xnList)
                {
                    ResourceFileList.Add(xn.Attributes["name"].Value);
                }

                WinPhoneFileList.Clear();
                xnList = xd.SelectNodes("config/winPhoneFileList/item");
                foreach (XmlNode xn in xnList)
                {
                    WinPhoneFileList.Add(xn.Attributes["name"].Value);
                }
            }
        }
示例#3
0
        public void editAndroidManifest(ChannelItem channel, PackageItem packageItem, List <string> permissionDelete,
                                        string versionName, int versionCode)
        {
            string      manifestFile = getTempPath(@"AndroidManifest.xml");
            XmlDocument xd           = new XmlDocument();

            xd.Load(manifestFile);

            XmlNode nodeManifest = xd.SelectSingleNode("manifest");

            nodeManifest.Attributes["package"].Value = packageItem.PackageName;

            string apkFile = getTempPath(@"apktool.yml");

            var fileData = File.ReadAllText(getTempPath("apktool.yml"));

            int index = fileData.IndexOf('\n');

            var subFileData = fileData.Substring(index, fileData.Length - index);//头不明类型的引用

            var titleFileData = fileData.Substring(0, index);

            var input = new StringReader(subFileData);

            var deserializer = new Deserializer(namingConvention: new CamelCaseNamingConvention());

            var manifestData = deserializer.Deserialize <AndroidManifestData>(input);



            if (!String.IsNullOrEmpty(versionName))
            {
                manifestData.VersionInfo.versionName = versionName;
            }
            if (versionCode > 0)
            {
                manifestData.VersionInfo.versionCode = versionCode.ToString();
            }

            var serializer = new Serializer(namingConvention: new CamelCaseNamingConvention());

            StringWriter textWriter = new StringWriter();

            textWriter.ToString();
            serializer.Serialize(textWriter, manifestData);


            string directorypath = titleFileData + "\n" + textWriter;

            System.IO.File.WriteAllText(apkFile, directorypath, Encoding.Default);
            System.Console.ReadLine();


            if (permissionDelete.Count != 0)
            {
                XmlNodeList permissionList = xd.SelectNodes("manifest/uses-permission");
                foreach (XmlNode item in permissionList)
                {
                    if (item.Attributes["android:name"] != null && item.Attributes["android:name"].Value != null &&
                        permissionDelete.Contains(item.Attributes["android:name"].Value))
                    {
                        item.ParentNode.RemoveChild(item);
                        logText("remove permission=" + item.Attributes["android:name"].Value);
                    }
                }
            }

            XmlNodeList xnList = xd.SelectNodes("manifest/application/meta-data");

            foreach (XmlNode metaItem in xnList)
            {
                string androidName = metaItem.Attributes["android:name"].Value;
                if (packageItem.MetaData.ContainsKey(androidName))
                {
                    metaItem.Attributes["android:value"].Value = packageItem.MetaData[androidName];
                }
            }

            if (Config.EnableMM)
            {
                bool        edited         = false;
                XmlNodeList nodeActionList = findXmlNode(xd, "manifest/application/service", "android:name", "mm.purchasesdk.iapservice.PurchaseService")
                                             .SelectNodes("intent-filter/action");

                foreach (XmlNode nodeItem in nodeActionList)
                {
                    string attrName = nodeItem.Attributes["android:name"].Value;
                    if (attrName.StartsWith("com.") && attrName.EndsWith(".purchaseservice.BIND"))
                    {
                        nodeItem.Attributes["android:name"].Value = packageItem.PackageName + ".purchaseservice.BIND";
                        edited = true;
                        break;
                    }
                }

                if (!edited)
                {
                    throw new ApplicationException("mm.purchasesdk.iapservice.PurchaseService edit error");
                }

                edited         = false;
                nodeActionList = findXmlNode(xd, "manifest/application/activity", "android:name", "mm.purchasesdk.iapservice.BillingLayoutActivity")
                                 .SelectNodes("intent-filter/action");

                foreach (XmlNode nodeItem in nodeActionList)
                {
                    string attrName = nodeItem.Attributes["android:name"].Value;
                    if (attrName.StartsWith("com.") && attrName.EndsWith(".com.mmiap.activity"))
                    {
                        nodeItem.Attributes["android:name"].Value = packageItem.PackageName + ".com.mmiap.activity";
                        edited = true;
                        break;
                    }
                }

                if (!edited)
                {
                    throw new ApplicationException("mm.purchasesdk.iapservice.BillingLayoutActivity edit error");
                }
            }

            //微信支付相关配置信息
            XmlNode xmlWeChat = findXmlNode(xd, "manifest/application/activity", "android:name", "com.bantu.fsyjz.wxapi.WXPayEntryActivity");

            if (xmlWeChat != null)
            {
                xmlWeChat.Attributes["android:name"].Value = packageItem.PackageName + ".wxapi.WXPayEntryActivity";
            }
            XmlNode xmlWXLogin = findXmlNode(xd, "manifest/application/activity", "android:name", "com.bantu.fsyjz.wxapi.WXEntryActivity");

            if (xmlWXLogin != null)
            {
                xmlWXLogin.Attributes["android:name"].Value = packageItem.PackageName + ".wxapi.WXEntryActivity";
            }

            //个推相关配置信息
            XmlNode xmlUsesPermission = findXmlNode(xd, "manifest/uses-permission", "android:name", "getui.permission.GetuiService.com.bantu.fsyjz");

            if (xmlUsesPermission != null)
            {
                xmlUsesPermission.Attributes["android:name"].Value = "getui.permission.GetuiService." + packageItem.PackageName;
            }
            XmlNode xmlPermission = findXmlNode(xd, "manifest/permission", "android:name", "getui.permission.GetuiService.com.bantu.fsyjz");

            if (xmlPermission != null)
            {
                xmlPermission.Attributes["android:name"].Value = "getui.permission.GetuiService." + packageItem.PackageName;
            }
            XmlNode xmlDownload = findXmlNode(xd, "manifest/application/provider", "android:name", "com.igexin.download.DownloadProvider");

            if (xmlDownload != null)
            {
                xmlDownload.Attributes["android:authorities"].Value = "downloads." + packageItem.PackageName;
            }
            XmlNode xmlReceiver = findXmlNode(xd, "manifest/application/receiver", "android:name", "com.igexin.getuiext.service.PayloadReceiver");

            if (xmlReceiver != null)
            {
                XmlNodeList xmlReceiverList = xmlReceiver.SelectNodes("intent-filter/action");
                foreach (XmlNode nodeItem in xmlReceiverList)
                {
                    string attrName = nodeItem.Attributes["android:name"].Value;
                    if (attrName.StartsWith("com.igexin.sdk.action.") && !attrName.EndsWith("7fjUl2Z3LH6xYy7NQK4ni4"))
                    {
                        if (packageItem.MetaData.ContainsKey("PUSH_APPID"))
                        {
                            nodeItem.Attributes["android:name"].Value = "com.igexin.sdk.action." + packageItem.MetaData["PUSH_APPID"];
                            break;
                        }
                    }
                }
            }
            xd.Save(manifestFile);
        }
示例#4
0
        public void editAndroidManifest(ChannelItem channel, PackageItem packageItem, List <string> permissionDelete,
                                        string versionName, int versionCode)
        {
            string      manifestFile = getTempPath(@"AndroidManifest.xml");
            XmlDocument xd           = new XmlDocument();

            xd.Load(manifestFile);

            XmlNode nodeManifest = xd.SelectSingleNode("manifest");

            nodeManifest.Attributes["package"].Value = packageItem.PackageName;
            if (!String.IsNullOrEmpty(versionName))
            {
                nodeManifest.Attributes["android:versionName"].Value = versionName;
            }
            if (versionCode > 0)
            {
                nodeManifest.Attributes["android:versionCode"].Value = versionCode.ToString();
            }

            if (permissionDelete.Count != 0)
            {
                XmlNodeList permissionList = xd.SelectNodes("manifest/uses-permission");
                foreach (XmlNode item in permissionList)
                {
                    if (item.Attributes["android:name"] != null && item.Attributes["android:name"].Value != null &&
                        permissionDelete.Contains(item.Attributes["android:name"].Value))
                    {
                        item.ParentNode.RemoveChild(item);
                        logText("remove permission=" + item.Attributes["android:name"].Value);
                    }
                }
            }

            XmlNodeList xnList = xd.SelectNodes("manifest/application/meta-data");

            foreach (XmlNode metaItem in xnList)
            {
                string androidName = metaItem.Attributes["android:name"].Value;
                if (packageItem.MetaData.ContainsKey(androidName))
                {
                    metaItem.Attributes["android:value"].Value = packageItem.MetaData[androidName];
                }
            }

            if (Config.EnableMM)
            {
                bool        edited         = false;
                XmlNodeList nodeActionList = findXmlNode(xd, "manifest/application/service", "android:name", "mm.purchasesdk.iapservice.PurchaseService")
                                             .SelectNodes("intent-filter/action");

                foreach (XmlNode nodeItem in nodeActionList)
                {
                    string attrName = nodeItem.Attributes["android:name"].Value;
                    if (attrName.StartsWith("com.") && attrName.EndsWith(".purchaseservice.BIND"))
                    {
                        nodeItem.Attributes["android:name"].Value = packageItem.PackageName + ".purchaseservice.BIND";
                        edited = true;
                        break;
                    }
                }

                if (!edited)
                {
                    throw new ApplicationException("mm.purchasesdk.iapservice.PurchaseService edit error");
                }

                edited         = false;
                nodeActionList = findXmlNode(xd, "manifest/application/activity", "android:name", "mm.purchasesdk.iapservice.BillingLayoutActivity")
                                 .SelectNodes("intent-filter/action");

                foreach (XmlNode nodeItem in nodeActionList)
                {
                    string attrName = nodeItem.Attributes["android:name"].Value;
                    if (attrName.StartsWith("com.") && attrName.EndsWith(".com.mmiap.activity"))
                    {
                        nodeItem.Attributes["android:name"].Value = packageItem.PackageName + ".com.mmiap.activity";
                        edited = true;
                        break;
                    }
                }

                if (!edited)
                {
                    throw new ApplicationException("mm.purchasesdk.iapservice.BillingLayoutActivity edit error");
                }
            }

            //微信支付相关配置信息
            XmlNode xmlWeChat = findXmlNode(xd, "manifest/application/activity", "android:name", "com.bantu.ssgwz.wxapi.WXPayEntryActivity");

            if (xmlWeChat != null)
            {
                xmlWeChat.Attributes["android:name"].Value = packageItem.PackageName + ".wxapi.WXPayEntryActivity";
            }
            XmlNode xmlWXLogin = findXmlNode(xd, "manifest/application/activity", "android:name", "com.bantu.ssgwz.wxapi.WXEntryActivity");

            if (xmlWXLogin != null)
            {
                xmlWXLogin.Attributes["android:name"].Value = packageItem.PackageName + ".wxapi.WXEntryActivity";
            }

            //个推相关配置信息
            XmlNode xmlUsesPermission = findXmlNode(xd, "manifest/uses-permission", "android:name", "getui.permission.GetuiService.com.bantu.ssgwz");

            if (xmlUsesPermission != null)
            {
                xmlUsesPermission.Attributes["android:name"].Value = "getui.permission.GetuiService." + packageItem.PackageName;
            }
            XmlNode xmlPermission = findXmlNode(xd, "manifest/permission", "android:name", "getui.permission.GetuiService.com.bantu.ssgwz");

            if (xmlPermission != null)
            {
                xmlPermission.Attributes["android:name"].Value = "getui.permission.GetuiService." + packageItem.PackageName;
            }
            XmlNode xmlDownload = findXmlNode(xd, "manifest/application/provider", "android:name", "com.igexin.download.DownloadProvider");

            if (xmlDownload != null)
            {
                xmlDownload.Attributes["android:authorities"].Value = "downloads." + packageItem.PackageName;
            }
            XmlNode xmlReceiver = findXmlNode(xd, "manifest/application/receiver", "android:name", "com.igexin.getuiext.service.PayloadReceiver");

            if (xmlReceiver != null)
            {
                XmlNodeList xmlReceiverList = xmlReceiver.SelectNodes("intent-filter/action");
                foreach (XmlNode nodeItem in xmlReceiverList)
                {
                    string attrName = nodeItem.Attributes["android:name"].Value;
                    if (attrName.StartsWith("com.igexin.sdk.action.") && !attrName.EndsWith("7fjUl2Z3LH6xYy7NQK4ni4"))
                    {
                        if (packageItem.MetaData.ContainsKey("PUSH_APPID"))
                        {
                            nodeItem.Attributes["android:name"].Value = "com.igexin.sdk.action." + packageItem.MetaData["PUSH_APPID"];
                            break;
                        }
                    }
                }
            }
            xd.Save(manifestFile);
        }