public void ABMD5Callback(ABClassDownInfo ABDowninfo, DownStatus downResult = DownStatus.Sucess, string downError = "") { switch (downResult) { case DownStatus.Downloding: break; case DownStatus.Fail: AFLogger.e("下载MD5文件失败,Error:" + downError); break; case DownStatus.NoNetwork: AFLogger.e("没有网络,请检查!"); break; case DownStatus.Sucess: break; } }
public void ABMD5Callback(ABClassDownInfo ABDowninfo, DownStatus downResult = DownStatus.Sucess, string downError = "") { switch (downResult) { case DownStatus.Downloding: break; case DownStatus.Fail: MD5Text.text = "下载MD5文件失败,Error:" + downError; break; case DownStatus.NoNetwork: MD5Text.text = "没有网络,请检查!"; break; case DownStatus.Sucess: MD5Text.text = GetABStatusStr(ABDowninfo.aBState); break; } }
/// <summary> /// MD5检测回调 /// </summary> public void ABMD5ResultCallback(ABClassDownInfo ABDowninfo, DownStatus downResult, string downError) { //从保存下载的字典里移除 RemoveDownload(ABDowninfo.ResClass, true, ABDataHolder.Instance.GetMD5DownURL() + ABDowninfo.ResClass.ToString() + "Info.txt"); AddProductDownInfo(ABDowninfo); //回调MD5的结果,可根据结果进行处理 ABDowninfo.ABMD5Callback.InvokeGracefully(ABDowninfo, downResult, downError); if (downResult == DownStatus.Sucess) { //Debug.Log("MD5检测结果:" + ABDowninfo.aBState); //这里分成了产品AB包和普通AB包,如果产品AB包需要直接下载,可在ABMD5callback回调中自己实现 if (ABDowninfo.isHasRecog) { if (ABDowninfo.aBState != ABState.Newest) { //覆盖本地info.txt FileHelper.CreatFile(GetSavePathByClass(ABDowninfo.ResClass, false), System.Text.Encoding.UTF8.GetBytes(SerializeHelper.ToJson(ABDowninfo.newClassInfo)), true); } } else { //Debug.Log("不是识别AB包的下载"); if (ABDowninfo.aBState == ABState.Newest) { //覆盖本地info.txt FileHelper.CreatFile(GetSavePathByClass(ABDowninfo.ResClass, false), System.Text.Encoding.UTF8.GetBytes(SerializeHelper.ToJson(ABDowninfo.newClassInfo)), true); //没有需要热更的 mABDownInfo[ABDowninfo.ResClass].IsDownFinish = true; //下载完成 ABDowninfo.ABprocessevent.InvokeGracefully(1, true, DownStatus.Sucess, ""); } else { //计算大小并下载 DownClassAB(ABDowninfo.ResClass); } } } }
public HttpABMD5(ABClassDownInfo aBDownInfo) : base(aBDownInfo) { }
public override void DownloadFinish() { base.DownloadFinish(); ABClassDownInfo aBDownInfo = (ABClassDownInfo)httpInfo; OneABClassInfo NewABInfo = SerializeHelper.FromJson <OneABClassInfo>(FileHelper.ReadTxtToStr(m_saveFilePath)); List <string> downStr = new List <string>(); bool isLocalABComplete = true; bool isNeedHot = false; if (aBDownInfo.oldClassInfo != null) { List <string> keys = new List <string>(NewABInfo.FileMD5.Keys); for (int i = 0; i < keys.Count; i++) { if (aBDownInfo.oldClassInfo.FileMD5.ContainsKey(keys[i])) { if (NewABInfo.FileMD5[keys[i]].Equals(aBDownInfo.oldClassInfo.FileMD5[keys[i]])) // MD5相等 { if (!FileHelper.JudgeFilePathExit(PathTool.PersistentDataPath + keys[i])) //本地没有AB存在 { AFLogger.d("检测MD5:本地没有AB存在111"); isLocalABComplete = false; //本地AB包不完整 isNeedHot = true; downStr.Add(keys[i]); } } else { isNeedHot = true; downStr.Add(keys[i]); if (!FileHelper.JudgeFilePathExit(PathTool.PersistentDataPath + "/" + keys[i])) //本地没有AB存在 { AFLogger.d("检测MD5:本地没有AB存在222"); isLocalABComplete = false; //本地AB包不完整 } } } else { isLocalABComplete = false; //本地AB包不完整 isNeedHot = true; downStr.Add(keys[i]); } } } else { isLocalABComplete = false; isNeedHot = true; List <string> keys = new List <string>(NewABInfo.FileMD5.Keys); for (int i = 0; i < keys.Count; i++) { FileHelper.DeleteFile(PathTool.PersistentDataPath + "/" + keys[i]); downStr.Add(keys[i]); } } if (aBDownInfo.ABMD5Callback != null) { ABState aBState = ABState.Newest; if (isNeedHot) { if (isLocalABComplete) { aBState = ABState.UpdateAndLocalComplete; } else { aBState = ABState.UpdateAndLocalNotComplete; } } aBDownInfo.CheckMD5Call(NewABInfo, aBState, downStr); aBDownInfo.ABMD5CallbackLocal(aBDownInfo, downResult, downError); } }