private void PatchStringsXml() { AndroidXmlDocument document = new AndroidXmlDocument(Path.Combine(this._stagingArea, "res/values/strings.xml")); document.PatchStringRes("string", "app_name", PlayerSettings.productName); document.Save(); }
public void OnPostGenerateGradleAndroidProject(string basePath) { var androidManifest = new AndroidXmlDocument(GetManifestPath(basePath)); androidManifest.ApplyReflectChanges(); androidManifest.Save(); }
public void Execute(PostProcessorContext context) { if (this.OnProgress != null) { this.OnProgress(this, "Patching settings file"); } this._stagingArea = context.Get <string>("StagingArea"); bool flag = context.Get <bool>("UseObb"); string str = context.Get <string>("AndroidPluginsPath"); if (Directory.Exists(Path.Combine(str, "assets"))) { FileUtil.CopyDirectoryRecursiveForPostprocess(Path.Combine(str, "assets"), Path.Combine(this._stagingArea, "assets"), true); } this.PatchStringsXml(); int num = !PlayerSettings.advancedLicense ? 0 : ((int)PlayerSettings.Android.splashScreenScale); AndroidXmlDocument document = new AndroidXmlDocument(Path.Combine(this._stagingArea, "assets/bin/Data/settings.xml")); document.PatchStringRes("integer", "splash_mode", num.ToString()); document.PatchStringRes("bool", "useObb", flag.ToString()); context.Set <AndroidXmlDocument>("SettingsXml", document); document.Save(); }
private void BuildObb(PostProcessorContext context) { bool flag = File.Exists(Path.Combine(this._stagingArea, "obb.ap_")); bool flag2 = File.Exists(Path.Combine(this._stagingArea, "rawobb.ap_")); if (flag || flag2) { string str = Path.Combine(Environment.CurrentDirectory, this._stagingArea); string[] first = new string[] { "apk", $"{str}/main.obb", "-u" }; if (flag) { string[] second = new string[] { "-z", $"{str}/obb.ap_" }; first = first.Concat <string>(second).ToArray <string>(); } if (flag2) { string[] textArray3 = new string[] { "-z", $"{str}/rawobb.ap_" }; first = first.Concat <string>(textArray3).ToArray <string>(); } string message = TasksCommon.SDKTool(context, first, this._stagingArea, "Failed to build OBB."); string fileName = Path.Combine(this._stagingArea, "main.obb"); FileInfo info = new FileInfo(fileName); if (!File.Exists(fileName) || (info.Length == 0L)) { Debug.LogError(message); CancelPostProcess.AbortBuildPointToConsole("OBB Builder Failed!", "Failed to build OBB package."); } if (info.Length >= 0x80000000L) { Debug.LogError(message); CancelPostProcess.AbortBuildPointToConsole("OBB Builder Failed!", "OBB file too big for Android Market (max 2GB)."); } AndroidXmlDocument document = context.Get <AndroidXmlDocument>("SettingsXml"); document.PatchStringRes("bool", TasksCommon.GetMD5HashOfEOCD(fileName), true.ToString()); document.Save(); } }
private void CreatePackagesWithFastzip(PostProcessorContext context) { string str5; string str6; string str7; FileInfo info; string workingdir = context.Get <string>("StagingArea"); bool flag = context.Get <bool>("UseObb"); AndroidLibraries libraries = context.Get <AndroidLibraries>("AndroidLibraries"); AndroidXmlDocument document = context.Get <AndroidXmlDocument>("SettingsXml"); string command = context.Get <string>("FastzipExe"); string str3 = "Package.apk"; string errorMsg = "Fastzip failed."; string str8 = " -j --seq -5"; if (flag) { if (this.OnProgress != null) { this.OnProgress(this, "Using fastzip to build expansion package (OBB)"); } str6 = ("main.obb" + str8 + " obbassets=assets") + " rawobb=assets"; str5 = TasksCommon.Exec(command, str6, workingdir, errorMsg, 0); str7 = Path.Combine(workingdir, "main.obb"); info = new FileInfo(str7); if (!File.Exists(str7) || (info.Length == 0L)) { Debug.LogError(str5); CancelPostProcess.AbortBuildPointToConsole("OBB Builder Failed!", "Failed to build OBB package."); } if (info.Length >= 0x80000000L) { Debug.LogError(str5); CancelPostProcess.AbortBuildPointToConsole("OBB Builder Failed!", "OBB file too big for Android Market (max 2GB)."); } document.PatchStringRes("bool", TasksCommon.GetMD5HashOfEOCD(str7), true.ToString()); document.Save(); } if (this.OnProgress != null) { this.OnProgress(this, "Using fastzip to build target package (APK)"); } string str9 = " libs=lib"; foreach (string str10 in libraries.GetLibraryDirectories()) { str9 = str9 + $" {str10}=libs"; } string str11 = " --apk"; if (PlayerSettings.Android.keyaliasName.Length != 0) { string str12 = !Path.IsPathRooted(PlayerSettings.Android.keystoreName) ? Path.Combine(Directory.GetCurrentDirectory(), PlayerSettings.Android.keystoreName) : PlayerSettings.Android.keystoreName; str11 = $" -A --sign={str12},{PlayerSettings.Android.keyaliasPass},{PlayerSettings.Android.keyaliasName}"; } string[] textArray1 = new string[] { str3, str8, str11, str9, " bin/classes.dex assets -0 -Z bin/resources.ap_ raw=assets" }; str6 = string.Concat(textArray1); str5 = TasksCommon.Exec(command, str6, workingdir, errorMsg, 0); str7 = Path.Combine(workingdir, str3); info = new FileInfo(str7); if (!File.Exists(str7) || (info.Length == 0L)) { Debug.LogError(str5); CancelPostProcess.AbortBuildPointToConsole("Fastzip Failed!", "Failed to build APK package."); } }