diff --git a/app/src/main/java/com/gh/common/constant/Config.java b/app/src/main/java/com/gh/common/constant/Config.java index b61496c8c2..b003f6a9ce 100644 --- a/app/src/main/java/com/gh/common/constant/Config.java +++ b/app/src/main/java/com/gh/common/constant/Config.java @@ -40,6 +40,7 @@ public class Config { public static final String PATCH_VERSION_NAME = BuildConfig.PATCH_VERSION_NAME; // 补丁包版本 对应关于->版本号 // http://www.ghzs666.com/article/${articleId}.html public static final String URL_ARTICLE = "http://www.ghzs666.com/article/"; // TODO ghzs/ghzs666 统一 + public static final String PATCHES = "patches"; public static boolean isShow(Context context) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); diff --git a/app/src/main/java/com/gh/gamecenter/MainActivity.java b/app/src/main/java/com/gh/gamecenter/MainActivity.java index dc2dfd64d9..53ca70aff5 100644 --- a/app/src/main/java/com/gh/gamecenter/MainActivity.java +++ b/app/src/main/java/com/gh/gamecenter/MainActivity.java @@ -55,6 +55,7 @@ import com.gh.gamecenter.manager.UpdateManager; import com.gh.gamecenter.retrofit.ObservableUtil; import com.gh.gamecenter.retrofit.Response; import com.gh.gamecenter.retrofit.RetrofitManager; +import com.google.gson.Gson; import com.halo.assistant.HaloApp; import com.lightgame.config.CommonDebug; import com.lightgame.download.DataWatcher; @@ -64,6 +65,7 @@ import com.lightgame.download.FileUtils; import com.lightgame.utils.Utils; import com.tencent.bugly.beta.tinker.TinkerManager; import com.tencent.bugly.crashreport.CrashReport; +import com.tencent.tinker.loader.shareutil.SharePatchFileUtil; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -75,8 +77,10 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -688,25 +692,42 @@ public class MainActivity extends BaseActivity { } private void checkTinkerPath() { - String newTinkerId = TinkerManager.getTinkerId(); - - if (isNewFirstLaunch) { - // 避免首次启动就提示打补丁 - sp.edit().putString("tinkerIds", newTinkerId).apply(); - } - CommonDebug.logMethodWithParams(this, TinkerManager.getTinkerId(), TinkerManager.getNewTinkerId()); CommonDebug.logMethodWithParams(this, CrashReport.getAppVer(), CrashReport.getAppID(), CrashReport.getAppChannel(), CrashReport.getSdkExtraData()); - if (!TextUtils.isEmpty(newTinkerId)) { - String tinkerIds = sp.getString("tinkerIds", ""); - if (!tinkerIds.contains(newTinkerId)) { - DialogUtils.showWarningDialog(this, "补丁更新成功" - , "光环助手已成功更新到V" + PackageUtils.getPatchVersionName() - , null, "知道了", null, null); - sp.edit().putString("tinkerIds", tinkerIds + "/" + newTinkerId).apply(); - } + // 1.(母包)首次启动,tinkerId不为空,newTinkerId(patchTinkerId)应该是空的 + // 2. 补丁包启动,tinkerId和之前一致,但newTinkerId不一致 + // 2.1 显示更新信息弹窗,记录tinkerId+newTinkerId + // 2.1.1 若tinkerId一致,但newTinkerId不一致才能认为是一次补丁更新 + + Gson gson = new Gson(); + + Map> tinkerIdMap = new HashMap<>(); + + String tinkerId = TinkerManager.getTinkerId(); + String newTinkerId = TinkerManager.getNewTinkerId(); + + if (newTinkerId == null) { + //这是一个新的母包,没有任何补丁信息 + return; } + + Set tinkerIdSet = tinkerIdMap.get(tinkerId); + if (tinkerIdSet == null) { + tinkerIdSet = new HashSet<>(); + tinkerIdMap.put(tinkerId, tinkerIdSet); + } + + // 有新的补丁,没有显示过 + if (!tinkerIdSet.contains(newTinkerId)) { + DialogUtils.showWarningDialog(this, "补丁更新成功" + , "光环助手已成功更新到V" + PackageUtils.getPatchVersionName() + , null, "知道了", null, null); + tinkerIdSet.add(newTinkerId); + } + + sp.edit().putString(Config.PATCHES, gson.toJson(tinkerIdMap)).apply(); + } @Override diff --git a/gradle.properties b/gradle.properties index 6e0ebf6cca..8a3edaa6d8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -67,5 +67,5 @@ USERSEA_HOST=https\://usersea.ghzs.com/v1d0/ # 请不要手动改动下面的值,除非你明确需要以某个apk作为基准包,需要打包请以scripts/tinker*.sh为准 TINKER_ENABLE= -TINKER_ID=5860ca72 -TINKER_BASE_APK_DIR=app-1106-15-41-30_5860ca72 +TINKER_ID=6c5dc556 +TINKER_BASE_APK_DIR=app-1107-10-21-10_6c5dc556