static void Process_LebianClientChId(BuildAndriodTask task) { try { string text = File.ReadAllText(Application.dataPath + "/Plugins/Android/lebian/lebian_app.gradle"); int firstIndex = text.IndexOf('['); int lastIndex = text.LastIndexOf(']'); if (firstIndex != -1 && lastIndex != -1) { string match = text.Substring(firstIndex, (lastIndex - firstIndex) + 1); string replace; #if LEBIAN_TENCENT if (task.devconfig_download_sources == 2 || task.devconfig_download_sources == 1) { replace = "[\"ClientChId\": \"" + "tencent" + "\"]"; } #else if (false) { } #endif else if (task.devconfig_download_sources == 0) { replace = "[\"ClientChId\": \"" + "Official" + "\"]"; } else { replace = "[\"ClientChId\": \"" + task.devconfig_download_sources.ToString() + "\"]"; } text = text.Replace(match, replace); File.WriteAllText(Application.dataPath + "/Plugins/Android/lebian/lebian_app.gradle", text); } else { Debug.LogError("Process_LebianClientChId error"); } } catch (Exception e) { Debug.LogError(e.Message); } }
static void Process_PUSH_SDK(BuildAndriodTask task) { string fileName = null; switch (task.devconfig_download_sources) { case 5: fileName = "HGTPush_Support_HW.zip"; break; case 6: fileName = "HGTPush_Support_XM.zip"; break; case 11: fileName = "HGTPush_Support_OPPO.zip"; break; case 13: fileName = "HGTPush_Support_MZ.zip"; break; } string root = Application.dataPath + "/Plugins/Push"; if (Directory.Exists(root)) { Directory.Delete(root, true); } string ori_path = Application.dataPath + "/PushExtention"; if (!string.IsNullOrEmpty(fileName)) { Directory.CreateDirectory(root); if (File.Exists(ori_path + "/" + fileName)) { FileStream zipFileStream = File.OpenRead(ori_path + "/" + fileName); ZipInputStream unzipStream = new ZipInputStream(zipFileStream); ZipEntry theEntry; while ((theEntry = unzipStream.GetNextEntry()) != null) { string fullName = root + "/" + theEntry.Name; string dirName = Path.GetDirectoryName(fullName); if (!Directory.Exists(dirName)) { Directory.CreateDirectory(dirName); } if (theEntry.IsFile) { try { FileStream fs = File.Create(fullName); byte[] content = new byte[theEntry.Size]; int readlen = unzipStream.Read(content, 0, content.Length); fs.Write(content, 0, readlen); fs.Flush(); fs.Close(); fs.Dispose(); } catch (Exception e) { Debug.LogError("unzip read errorMsg==={0}" + e.Message); } } } unzipStream.Close(); zipFileStream.Close(); } } AssetDatabase.Refresh(); }
static void Process_AD_SDK(BuildAndriodTask task) { foreach (var p in BuildSettings.ad_sdk_delete_dir) { try { Directory.Delete(p, true); } catch (Exception e) { Debug.LogWarning(e.Message); } } try { File.Delete("Assets/Plugins/Android/assets/UCGameConfig.ini"); } catch (Exception e) { } foreach (var sdk_id in task.ad_sdk_type) { if (sdk_id == 0 && task.process_NGAD_type != 0) { //process_NGAD_type==0表示 无需ini文件 //type ==0 表示是九游的广告 需要特殊配置文件 File.Copy("PlatformFiles/Android/UCGameConfig_" + task.process_NGAD_type + ".ini", "Assets/Plugins/Android/assets/UCGameConfig.ini", true); } } ADSdkType type = new ADSdkType(); type.ad_sdk_type = task.ad_sdk_type; var str = JsonUtility.ToJson(type); try { File.Delete("Assets/Resources/ad_sdk_type.txt"); } catch (Exception e) { } if (str.Length < 5) { throw new NullReferenceException("json error"); } File.WriteAllText("Assets/Resources/ad_sdk_type.txt", str); //remake foreach (var id in task.ad_sdk_type) { string path = "Assets/Plugins/"; string file = BuildSettings.ad_sdk_id_2_zip[id]; // "TTAD.zip"; try { //没有存储目录应创建 if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string full_name = path + "/" + file; using (var zipFileStream = File.OpenRead("Assets/AdZipFile/" + file)) { using (ZipInputStream unzipStream = new ZipInputStream(zipFileStream)) { ZipEntry theEntry; while ((theEntry = unzipStream.GetNextEntry()) != null) { string fullName = path + theEntry.Name; string dirName = Path.GetDirectoryName(fullName); // throw new NullReferenceException(); if (!Directory.Exists(dirName)) { Directory.CreateDirectory(dirName); } if (theEntry.IsFile) { try { FileStream fs = File.Create(fullName); byte[] content = new byte[theEntry.Size]; int readlen = unzipStream.Read(content, 0, content.Length); fs.Write(content, 0, readlen); fs.Flush(); fs.Close(); fs.Dispose(); } catch (Exception e) { Debug.LogError("unzip read errorMsg==={0}" + e.Message); } } } } } } catch (Exception e) { Debug.LogError("unzip errorMsg==={0}" + e.Message); } } }