123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using SC;
- using SC.Tools.UpdateAPKSystem.CheckSystem;
- using SC.Tools.UpdateAPKSystem.UpdateSystem;
- namespace SC.Tools.UpdateAPKSystem
- {
- public class UpdateAPKSystem : SystemBase
- {
-
- public CheckSystem.CheckSystem checkSystem;
- public UpdateSystem.UpdateSystem updateSystem;
- public AndroidPluginManifest androidPluginManifest;
- public AndroidPluginUpdateAPK androidPluginUpdateAPK;
- private static UpdateAPKSystem mInstant;
- public static UpdateAPKSystem getInstant {
- get {
- if (mInstant == null) {
- Debug.Log("[UpdateAPKSystem=====================================]: " + "Instantiate Start");
- mInstant = Instantiate((GameObject)Resources.Load("Prefabs/UpdataAPKSystem")).
- GetComponent<UpdateAPKSystem>();
- Debug.Log("[" + mInstant.GetType().ToString() + "]: " + "Instantiate Finish");
- }
- return mInstant;
- }
- }
- public override void Awake() {
- if (mInstant) {
- DestroyImmediate(gameObject);
- return;
- }
- base.Awake();
- mInstant = this;
- DontDestroyOnLoad(gameObject);
-
- CheckSystem.CheckSystem.RegisterCheckFinishCallBack(CheckFinishCallBack);
- AddSubSystem(androidPluginUpdateAPK = AndroidPluginUpdateAPK.getInstant);
- AddSubSystem(androidPluginManifest = AndroidPluginManifest.getInstant);
- AddSubSystem(checkSystem = CheckSystem.CheckSystem.getInstant);
- AddSubSystem(updateSystem = UpdateSystem.UpdateSystem.getInstant);
- }
- public override void OnDestroy() {
- base.OnDestroy();
- CheckSystem.CheckSystem.UnRegisterCheckFinishCallBack(CheckFinishCallBack);
- }
- void CheckFinishCallBack(bool hasNewVersion, bool isForceUpdate,bool isIgnorUpdate) {
- Debug.Log("[" + GetType().ToString() + "]: " + "CheckFinishCallBack:hasNewVersion:"+ hasNewVersion+" isForceUpdate:"+ isForceUpdate
- + " isIgnorUpdate:" + isIgnorUpdate+" isManualMode:"+ checkSystem.isManualMode);
- if (hasNewVersion == false) {
- Debug.Log("[" + GetType().ToString() + "]: " + "hasNewVersion == false ,CloseUpdateAPKSystem");
- SystemStop();
- return;
- }
- if (isIgnorUpdate && checkSystem.isManualMode==false) {
- Debug.Log("[" + GetType().ToString() + "]: " + "isIgnorUpdate == true ,CloseUpdateAPKSystem");
- SystemStop();
- return;
- }
- Debug.Log("[" + GetType().ToString() + "]: " + "Go To UpdateSystem !");
- checkSystem.SystemStop();
- updateSystem.SystemStart();
- return;
- }
- ///后台打开版本检测API,不需要显示Canvas面板
- public override void SystemStart() {
- base.SystemStart();
- updateSystem.SystemStop();
- }
- public override void SystemStop() {
- base.SystemStop();
- checkSystem.isManualMode = false;
- }
- /// <summary>
- /// 当手动打开版本检测API,需要显示Canvas面板
- /// </summary>
- public void Run() {
- checkSystem.isManualMode = true;
- SystemStart();
- }
- /// <summary>
- /// 后台自动运行时API,检测有问题不显示Canvas面板,除有更新出现才会显示Canvas面板
- /// </summary>
- public void RunSilent() {
- checkSystem.isManualMode = false;
- SystemStart();
- }
- /// <summary>
- /// 停用检测API
- /// </summary>
- public void Stop() {
- SystemStop();
- }
- }
- }
|