Esempio n. 1
0
 private void OnValidatePatchEnter(int eventID, FSMState preState, FSMState currentState)
 {
     Debug.Log("正在校验补丁");
     PreloadingUIView.SetProgressName("正在校验更新文件,过程中不消耗流量");
     Loom.Current.RunAsync(delegate
     {
         bool isAllValid = true;
         for (UpdateManager.PatchFileType patchFileType = UpdateManager.PatchFileType.Extend; patchFileType < UpdateManager.PatchFileType.Max; patchFileType++)
         {
             UpdateManager.DownloadFileInfo downloadInfo = this.UpdateInfo.GetDownloadInfo(patchFileType);
             if (downloadInfo != null)
             {
                 string text = MD5Util.EncryptFile(downloadInfo.LocalPath);
                 if (!downloadInfo.TargetBaseInfo.Md5.Equals(text))
                 {
                     isAllValid = false;
                     downloadInfo.TargetFileInfo.Delete();
                     downloadInfo.TargetFileInfo.Refresh();
                 }
             }
         }
         Loom.Current.QueueOnMainThread(delegate
         {
             this.OnValidateFinish(isAllValid);
         });
     });
 }
Esempio n. 2
0
 private void InstallByApk()
 {
     Debug.LogFormat("InstallByApk", new object[0]);
     UpdateManager.DownloadFileInfo downloadInfo = this.UpdateInfo.GetDownloadInfo(UpdateManager.PatchFileType.Apk);
     NativeCallManager.InstallPackage(downloadInfo.LocalPath);
     this.InstallNext();
 }
Esempio n. 3
0
    private void DoDownload()
    {
        List <string> list  = new List <string>();
        List <string> list2 = new List <string>();
        List <string> list3 = new List <string>();
        List <long>   list4 = new List <long>();

        for (UpdateManager.PatchFileType patchFileType = UpdateManager.PatchFileType.Extend; patchFileType < UpdateManager.PatchFileType.Max; patchFileType++)
        {
            UpdateManager.DownloadFileInfo downloadInfo = this.UpdateInfo.GetDownloadInfo(patchFileType);
            if (downloadInfo != null)
            {
                if (!downloadInfo.IfFull())
                {
                    list.Add(downloadInfo.Url);
                    list2.Add(downloadInfo.LocalPath);
                    list3.Add(downloadInfo.TargetBaseInfo.Md5);
                    list4.Add((long)downloadInfo.TargetBaseInfo.FileSize);
                }
            }
        }
        PreloadingUIView.SetProgressName("正在下载更新文件...");
        PreloadingUIView.ResetProgress();
        this.Downloading = true;
        this.CurrentDownloader.Download(list, list2, list3, list4, null, new Action <bool>(this.OnDownloadEnd));
    }
Esempio n. 4
0
 private void AddResPatchDownload(UpdateManager.PatchFileType fileType, UpdateManager.ResPathDir dir, string version, UpdateManager.FileBaseInfo fbi)
 {
     UpdateManager.DownloadFileInfo info = new UpdateManager.DownloadFileInfo
     {
         FileType       = fileType,
         Url            = this.GetResPatchUrl(dir, version),
         LocalPath      = this.GetResPatchPath(dir, version),
         TargetBaseInfo = fbi
     };
     this.UpdateInfo.AddDownloadFile(info);
 }
Esempio n. 5
0
 public void AddDownloadFile(UpdateManager.DownloadFileInfo info)
 {
     this.DownloadAmmount += (long)info.TargetBaseInfo.FileSize;
     if (info.TargetFileInfo.get_Exists() && info.TargetFileInfo.get_Length() > (long)info.TargetBaseInfo.FileSize)
     {
         info.TargetFileInfo.Delete();
         info.TargetFileInfo.Refresh();
     }
     Debug.LogFormat("添加更新文件:{0}", new object[]
     {
         info.Url
     });
     this.DownloadFiles.Add(info.FileType, info);
 }
Esempio n. 6
0
        public long GetCurrentFilesSize()
        {
            long num = 0L;

            for (UpdateManager.PatchFileType patchFileType = UpdateManager.PatchFileType.Extend; patchFileType < UpdateManager.PatchFileType.Max; patchFileType++)
            {
                UpdateManager.DownloadFileInfo downloadInfo = this.GetDownloadInfo(patchFileType);
                if (downloadInfo != null)
                {
                    downloadInfo.TargetFileInfo.Refresh();
                    if (downloadInfo.TargetFileInfo.get_Exists())
                    {
                        num += downloadInfo.TargetFileInfo.get_Length();
                    }
                }
            }
            return(num);
        }
Esempio n. 7
0
    private void UnZipFileFinish(UpdateManager.DownloadFileInfo info)
    {
        switch (info.FileType)
        {
        case UpdateManager.PatchFileType.Extend:
            this.SetVersionFileText("ExtendVersion", this.UpdateInfo.CurrentResInfo.ExtendVersion);
            this.ClearExtend();
            break;

        case UpdateManager.PatchFileType.ExtendPatch:
            this.SetVersionFileText("ExtendVersion", GameManager.Instance.ResVersion);
            this.ClearExtendPatch();
            break;

        case UpdateManager.PatchFileType.CorePatch:
            this.SetVersionFileText("CoreVersion", GameManager.Instance.ResVersion);
            this.ClearCorePatch();
            break;
        }
        this.InstallNext();
    }
Esempio n. 8
0
    private void InstallByType(UpdateManager.PatchFileType type)
    {
        switch (type)
        {
        case UpdateManager.PatchFileType.Extend:
        case UpdateManager.PatchFileType.ExtendPatch:
        case UpdateManager.PatchFileType.CorePatch:
        {
            UpdateManager.DownloadFileInfo downloadInfo = this.UpdateInfo.GetDownloadInfo(type);
            this.UnzipPatch(downloadInfo);
            break;
        }

        case UpdateManager.PatchFileType.ApkPatch:
            this.InstallByApkPatch();
            break;

        case UpdateManager.PatchFileType.Apk:
            this.InstallByApk();
            break;
        }
    }
Esempio n. 9
0
 private void DoRecordApkInfo(string apkMd5)
 {
     try
     {
         UpdateManager.FileBaseInfo targetBaseInfo = null;
         Debug.Log("获取apk下载信息");
         UpdateManager.DownloadFileInfo info;
         if (this.UpdateInfo.CurrentApkInfo.PatchFileInfo.TryGetValue(apkMd5, ref targetBaseInfo))
         {
             Debug.Log("下载apkpatch");
             info = new UpdateManager.DownloadFileInfo
             {
                 FileType       = UpdateManager.PatchFileType.ApkPatch,
                 Url            = GameManager.Instance.GetApkPatchUrl(this.GetNewPatchName()),
                 LocalPath      = this.GetNewPatchPath(),
                 TargetBaseInfo = targetBaseInfo
             };
         }
         else
         {
             Debug.Log("下载apk整包");
             info = new UpdateManager.DownloadFileInfo
             {
                 FileType       = UpdateManager.PatchFileType.Apk,
                 Url            = GameManager.Instance.GetApkPatchUrl(this.GetNewApkName()),
                 LocalPath      = this.GetNewApkPath(),
                 TargetBaseInfo = this.UpdateInfo.CurrentApkInfo.ApkFileInfo
             };
         }
         this.UpdateInfo.AddDownloadFile(info);
         this.RecordCount++;
     }
     catch (Exception ex)
     {
         Debug.LogException(ex);
         throw ex;
     }
 }
Esempio n. 10
0
 private void UnzipPatch(UpdateManager.DownloadFileInfo info)
 {
     Debug.LogFormat("解压文件 :{0}", new object[]
     {
         info.LocalPath
     });
     UnZipFile.Instance.ThreadNum = Environment.get_ProcessorCount() * 2;
     Loom.Current.RunAsync(delegate
     {
         this.InstallUpdate      = new Action(this.UnZipUpdate);
         ZipFileArgs zipFileArgs = new ZipFileArgs();
         zipFileArgs.OverWrite   = true;
         zipFileArgs.TarDir      = PathSystem.PersistentDataPath;
         zipFileArgs.unZipFinish = delegate
         {
             this.UnZipFileFinish(info);
         };
         zipFileArgs.zipFile   = info.LocalPath;
         zipFileArgs.FilterDir = new List <string>();
         zipFileArgs.FilterDir.Add("assets/");
         UnZipFile.Instance.UnZip(zipFileArgs);
     });
 }