fix tinkerId show update log

This commit is contained in:
CsHeng
2017-11-07 10:39:40 +08:00
parent 6c5dc556e8
commit ce312aea72
3 changed files with 39 additions and 17 deletions

View File

@ -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<String, Set<String>> tinkerIdMap = new HashMap<>();
String tinkerId = TinkerManager.getTinkerId();
String newTinkerId = TinkerManager.getNewTinkerId();
if (newTinkerId == null) {
//这是一个新的母包,没有任何补丁信息
return;
}
Set<String> 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