예제 #1
0
        private void OnValidatePatchEnter(int eventID, FSMState preState, FSMState currentState)
        {
            PreloadingUIView.SetProgressName("正在校验更新文件...");
            Debug.Log("校验补丁包");
            string newPatch = this.GetNewPatchPath();

            Loom.Current.RunAsync(delegate
            {
                bool flag         = false;
                FileInfo fileInfo = new FileInfo(newPatch);
                if (fileInfo.get_Exists())
                {
                    string text = MD5Util.EncryptFile(newPatch);
                    FileBaseInfo newPatchFileInfo = this.GetNewPatchFileInfo();
                    flag = text.Equals(newPatchFileInfo.Md5);
                    if (!flag && fileInfo.get_Length() == (long)newPatchFileInfo.FileSize)
                    {
                        File.Delete(newPatch);
                    }
                }
                if (flag)
                {
                    this.ReactSync(UpdateEvent2.True);
                }
                else
                {
                    this.ReactSync(UpdateEvent2.False);
                }
            });
        }
예제 #2
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);
         });
     });
 }
예제 #3
0
 public static void GetApkMd5Async(Action <string> OnGetCallback)
 {
     if (string.IsNullOrEmpty(NativeCallManager.ApkMd5))
     {
         Debug.Log("GetApkMd5Async begin");
         string dataPath = NativeCallManager.GetApkPath();
         Debug.LogFormat("dataPath :{0}", new object[]
         {
             dataPath
         });
         Loom.Current.RunAsync(delegate
         {
             NativeCallManager.ApkMd5 = MD5Util.EncryptFile(dataPath);
             Debug.LogFormat("apk md5 :{0}", new object[]
             {
                 NativeCallManager.ApkMd5
             });
             if (OnGetCallback != null)
             {
                 OnGetCallback.Invoke(NativeCallManager.ApkMd5);
                 Debug.Log("GetApkMd5Async end");
             }
         });
     }
     else if (OnGetCallback != null)
     {
         OnGetCallback.Invoke(NativeCallManager.ApkMd5);
     }
 }
예제 #4
0
    private void InstallByApkPatch()
    {
        this.InstallUpdate = new Action(this.InstallByApkPatchUpdate);
        Debug.LogFormat("InstallByApkPatch", new object[0]);
        string newApk  = this.GetNewApkPath();
        string current = NativeCallManager.GetApkPath();
        string patch   = this.GetNewPatchPath();

        Loom.Current.RunAsync(delegate
        {
            FileInfo fileInfo = new FileInfo(newApk);
            if (fileInfo.get_Exists() && fileInfo.get_Length() >= (long)this.UpdateInfo.CurrentApkInfo.ApkFileInfo.FileSize)
            {
                string text = MD5Util.EncryptFile(newApk);
                if (this.UpdateInfo.CurrentApkInfo.ApkFileInfo.Md5.Equals(text))
                {
                    Loom.Current.QueueOnMainThread(delegate
                    {
                        NativeCallManager.InstallPackage(newApk);
                        this.InstallNext();
                    });
                }
                else
                {
                    this.ClearApk();
                    this.ClearApkPatch();
                    Action onClick = delegate
                    {
                        this.ReactSync(UpdateEvent.False);
                    };
                    Loom.Current.QueueOnMainThread(delegate
                    {
                        this.ShowDownloadFailed(onClick);
                    });
                }
            }
            else
            {
                string directoryName = Path.GetDirectoryName(newApk);
                DirectoryUtil.CreateIfNotExist(directoryName);
                FileHelper.DeleteIfExist(newApk);
                this.MergeFile = new FileInfo(newApk);
                using (FileStream fileStream = File.Open(current, 3, 1, 1))
                {
                    using (FileStream fileStream2 = File.Open(newApk, 2, 2))
                    {
                        BinaryPatchUtility.Apply(fileStream, () => File.Open(patch, 3, 1, 1), fileStream2);
                    }
                }
                Loom.Current.QueueOnMainThread(delegate
                {
                    this.InstallByApkPatch();
                });
            }
        });
    }
예제 #5
0
 public static string GetApkMd5()
 {
     Debug.Log("GetApkMd5 begin");
     if (string.IsNullOrEmpty(NativeCallManager.ApkMd5))
     {
         NativeCallManager.ApkMd5 = MD5Util.EncryptFile(PathSystem.DataPath);
     }
     Debug.Log("GetApkMd5 end");
     return(NativeCallManager.ApkMd5);
 }