//public IEnumerator DownloadAPK(System.Action callback = null) //{ // if (updateAPK) // { // //todo // if (FileUtils.ExistsInPersistent(apkName) && apkMd5 == ResCommon.GetFileMD5(Application.persistentDataPath + "/" + apkName)) // { // updateAPK = false; // InstallApk(Application.persistentDataPath + "/" + apkName); // } // else // { // string urlNewApk = ""; // yield return GetChannelApk((ret) => // { // urlNewApk = string.Format("{0}/{1}/{2}", ret, newVersion, apkName); // }); // yield return DownloadAPKFile(urlNewApk, OnLoadedApk); // } // } // yield return new WaitForEndOfFrame(); // if (callback != null) callback(); //} /// <summary> /// 这个下载APK的时候要注意quick渠道的资源是quick,母包的大小包也在quick目录下,但是子包APK路径不一样 /// </summary> /// <returns></returns> // private IEnumerator GetChannelApk(System.Action<string> callback) // { // string tag = "_release/"; // string channelName = ResSetting.channelResName; //#if SDK_Quick // int id = quicksdk.QuickSDK.getInstance().channelType(); // yield return GetChannelNameByID(id, (ret) => // { // channelName = ret; // }); //#endif // //if (FileUtils.isInternalNetwork) // //{ // // tag = "_debug/"; // //} // //else // //{ // // tag = "_release/"; // //} // if (callback != null) // { // callback(channelName + tag + ResSetting.GetPlatformName()); // } // yield return null; // } //private Dictionary<int, string> paths = new Dictionary<int, string>(); //private IEnumerator GetChannelNameByID(int id, System.Action<string> callback) //{ // if (paths != null && paths.Count == 0) // { // string urlForFile = string.Format("{0}", "channel.txt") // + "?time=" + System.DateTime.Now.Ticks + "&r=" + UnityEngine.Random.Range(int.MinValue, int.MaxValue); // yield return DownloadFile(urlForFile, // (www) => // { // if (string.IsNullOrEmpty(www.error)) // { // string content = www.text; // content = content.Replace("\r\n", "\n").Replace(" ", ""); // string[] lines = content.Split('\n'); // foreach (var k in lines) // { // if (k.Contains("=")) // { // string[] kv = k.Split('='); // paths.Add(int.Parse(kv[0]), kv[1]); // Debug.LogError("channel id " + kv[0] + " res path " + kv[1]); // } // } // if (paths.ContainsKey(id)) // { // Debug.LogError("use channel id " + id + " apk path " + paths[id]); // if (callback != null) // callback(paths[id]); // } // else // throw new System.Exception("channel path not find id -> " + id); // } // else // { // //没网络 // UIMessageBoxHelper.Show("获取channel.txt资源失败", // () => // { // ReStart(); // } // ); // } // }); // } // else // { // if (paths.ContainsKey(id)) // { // if (callback != null) // callback(paths[id]); // } // else // throw new System.Exception("channel path not find id -> " + id); // } //} public IEnumerator DoLastJob() { tip = " 缓存目录保存MD文件 "; Debug.LogError(tip); SafeWriteFileInPersistent(mdFile, JsonMapper.ToJson(cdnMapHash)); tip = " 缓存目录保存MD2文件 "; Debug.LogError(tip); SafeWriteFileInPersistent(md2File, cdnMD2.ToJson()); //if (updateAPK) //{ // yield return DownloadAPK(); //} tip = " 更新完毕,保存版本号 "; Debug.LogError(tip); currentResVersion = newVersion; Version.SaveVersion(currentResVersion); SetFileUtilInfos(); yield return(null); SuperBoBo.EventManager.Instance.FireEvent(UpdateEvent.Updater_UpdateDone, null); finished = true; }
public void CompareMD2(JsonData j1, JsonData j2) { if (j1["hashCode"].ToString() == j2["hashCode"].ToString()) //不需要下载MD文件 { //tip = " 不用下载MD文件,直接比较APK "; //Debug.LogError(tip); //if (updateAPK) //{ // if (FileUtils.ExistsInPersistent(apkName) && apkMd5 == ResCommon.GetFileMD5(Application.persistentDataPath + "/" + apkName)) // { // updateAPK = false; // InstallApk(Application.persistentDataPath + "/" + apkName); // tip = " 更新完毕,保存版本号 "; // Debug.LogError(tip); // currentResVersion = newVersion; // Version.SaveVersion(currentResVersion); // //StartGame(); // SuperBoBo.EventManager.Instance.FireEvent(GameEventType.Updater_UpdateDone, null); // } // else // { // ShowTip(apkSize, () => // { // StartCoroutine(DownloadAPK(() => // { // tip = " 更新完毕,保存版本号 "; // Debug.LogError(tip); // currentResVersion = newVersion; // Version.SaveVersion(currentResVersion); // //StartGame(); // SuperBoBo.EventManager.Instance.FireEvent(GameEventType.Updater_UpdateDone, null); // //UILoadingStupid.instacne.logo.gameObject.SetActive(false); // })); // }); // } //} //else //{ tip = " 更新完毕,保存版本号 "; Debug.LogError(tip); currentResVersion = newVersion; Version.SaveVersion(currentResVersion); //StartGame(); SuperBoBo.EventManager.Instance.FireEvent(UpdateEvent.Updater_UpdateDone, null); //} } else//需要下载MD文件 { SuperBoBo.EventManager.Instance.FireEvent(UpdateEvent.Updater_DownloadMD2Done, null); // DownLoadMD(); } }