From 7322216c709d80b0e4e19829efcfc129b0ca040a Mon Sep 17 00:00:00 2001 From: yangfei Date: Fri, 29 Mar 2024 14:48:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B8=B8=E6=88=8F=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=A4=9A=E7=BA=BF=E7=A8=8B=E5=AF=BC=E8=87=B4=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../packagehelper/PackageRepository.kt | 49 +++++++++++++------ .../packagehelper/PackageViewModel.kt | 4 +- .../main/java/com/halo/assistant/HaloApp.java | 1 + module_core/proguard-rules.pro | 6 +-- vasdk | 2 +- 5 files changed, 41 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/com/gh/gamecenter/packagehelper/PackageRepository.kt b/app/src/main/java/com/gh/gamecenter/packagehelper/PackageRepository.kt index 4480be949f..7955ba330d 100644 --- a/app/src/main/java/com/gh/gamecenter/packagehelper/PackageRepository.kt +++ b/app/src/main/java/com/gh/gamecenter/packagehelper/PackageRepository.kt @@ -58,6 +58,8 @@ object PackageRepository { @Volatile private var mIsInitialisingData = false + var installedPkgRefreshed = false + var vaPkgRefreshed = false val gameUpdateLiveData = MutableLiveData>() val gameInstalledLiveData = MutableLiveData>() @@ -73,37 +75,41 @@ object PackageRepository { */ @JvmStatic fun initData() { + Utils.log("xxx", "PackageRepository::initData::mIsInitialisingData = $mIsInitialisingData") if (mIsInitialisingData) return mIsInitialisingData = true + installedPkgRefreshed = false + vaPkgRefreshed = false + runOnIoThread { if (gameInstalled.isNotEmpty()) gameInstalled.clear() if (mInstalledGameList.isNotEmpty()) mInstalledGameList.clear() - if (gameUpdate.isNotEmpty()) gameUpdate.clear() + if (gameUpdate.isNotEmpty()) { + gameUpdate.clear() + Utils.log("xxx", "清除更新数据") + } if (mInstalledPkgList.isNotEmpty()) mInstalledPkgList.clear() - var installedPkgRefreshed = false - var vaPkgRefreshed = false - val list = PackageUtils.getAllPackageName(mApplication) uploadAppList() initFilterPackage(list) { filteredList -> - installedPkgRefreshed = true - mIsInitialisingData = !(installedPkgRefreshed && vaPkgRefreshed) - mInstalledPkgList.addAll(filteredList) notifyInstallPkgData() - - loadInstalledGameDigestAndNotifyData(filteredList) + Utils.log("xxx", "PackageRepository::filteredList::${filteredList}") + loadInstalledGameDigestAndNotifyData(filteredList) { + installedPkgRefreshed = true + mIsInitialisingData = !(installedPkgRefreshed && vaPkgRefreshed) + } } loadGhzsUpdate() // 畅玩游戏更新 var allGames = VHelper.getAllVGameSnapshots() - if(allGames.isNullOrEmpty()) { + if (allGames.isNullOrEmpty()) { VHelper.refreshVGameSnapshot() allGames = VHelper.getAllVGameSnapshots() } @@ -111,9 +117,15 @@ object PackageRepository { if (allGamePkgNames.isNotEmpty()) { notifyInstallPkgData() updateFilterPackage(allGamePkgNames) { - vaPkgRefreshed = true - mIsInitialisingData = !(installedPkgRefreshed && vaPkgRefreshed) - loadInstalledGameDigestAndNotifyData(filteredList = allGamePkgNames, onWorkerThreadOnly = false, isVGame = true) + Utils.log("xxx", "PackageRepository::filteredList::${allGamePkgNames}") + loadInstalledGameDigestAndNotifyData( + filteredList = allGamePkgNames, + onWorkerThreadOnly = false, + isVGame = true + ) { + vaPkgRefreshed = true + mIsInitialisingData = !(installedPkgRefreshed && vaPkgRefreshed) + } } } } @@ -148,7 +160,8 @@ object PackageRepository { PackageUtils.getGhVersionName(), PackageUtils.getGhVersionCode(), HaloApp.getInstance().channel, - Build.VERSION.SDK_INT) + Build.VERSION.SDK_INT + ) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(object : Response() { @@ -223,6 +236,7 @@ object PackageRepository { filteredList: ArrayList, onWorkerThreadOnly: Boolean = false, isVGame: Boolean = false, + loadFinishCallback: (() -> Unit)? = null ) { var isNotifyUpdate = false val maxPageCount = (filteredList.size / PAGE_SIZE) + 1 @@ -231,6 +245,7 @@ object PackageRepository { val latch = ObservableUtil.latch(maxPageCount, { if (isNotifyUpdate || gameUpdateLiveData.value == null) notifyGameUpdateData() notifyGameInstallData() + loadFinishCallback?.invoke() }, Any()) while (++page <= maxPageCount) { @@ -390,7 +405,8 @@ object PackageRepository { for (entity in gameUpdate) { if (entity.packageName == data.packageName && entity.id == data.id - && entity.isVGameUpdate == data.isVGameUpdate) { + && entity.isVGameUpdate == data.isVGameUpdate + ) { isExist = true } } @@ -466,7 +482,8 @@ object PackageRepository { val game = gameUpdate[j] // 仅类型一致时移除更新实体 if (game.packageName == pkgName - && game.isVGameUpdate == isVGame) { + && game.isVGameUpdate == isVGame + ) { gameUpdate.remove(game) notifyGameUpdateData() } else { diff --git a/app/src/main/java/com/gh/gamecenter/packagehelper/PackageViewModel.kt b/app/src/main/java/com/gh/gamecenter/packagehelper/PackageViewModel.kt index 3ddc53b083..1b03f2f0d0 100644 --- a/app/src/main/java/com/gh/gamecenter/packagehelper/PackageViewModel.kt +++ b/app/src/main/java/com/gh/gamecenter/packagehelper/PackageViewModel.kt @@ -3,9 +3,10 @@ package com.gh.gamecenter.packagehelper import android.app.Application import android.text.TextUtils import androidx.lifecycle.* -import com.gh.gamecenter.feature.entity.GameInstall import com.gh.gamecenter.entity.GameUpdateEntity +import com.gh.gamecenter.feature.entity.GameInstall import com.halo.assistant.HaloApp +import com.lightgame.utils.Utils import kotlin.collections.set class PackageViewModel( @@ -79,6 +80,7 @@ class PackageViewModel( if (mRepository.gameInstalled.size == 0 || PackageFilterManager.hasPendingPackage() ) { + Utils.log("xxx", "PackageViewModel call initData") mRepository.initData() } } diff --git a/app/src/main/java/com/halo/assistant/HaloApp.java b/app/src/main/java/com/halo/assistant/HaloApp.java index 74ecbf61bc..7923cb11a2 100644 --- a/app/src/main/java/com/halo/assistant/HaloApp.java +++ b/app/src/main/java/com/halo/assistant/HaloApp.java @@ -376,6 +376,7 @@ public class HaloApp extends MultiDexApplication { RegionSettingHelper.getRegionSetting(); ExtensionsKt.doOnMainProcessOnly(this, () -> { + Utils.log("xxx", "HaloApp call initData"); PackageRepository.initData(); PackageHelper.refreshLocalPackageList(); PackageHelper.initList(); diff --git a/module_core/proguard-rules.pro b/module_core/proguard-rules.pro index 244d3eb35d..f9fa08c847 100644 --- a/module_core/proguard-rules.pro +++ b/module_core/proguard-rules.pro @@ -32,9 +32,9 @@ public static void logMethodWithParams(...); } --assumenosideeffects class com.lightgame.utils.Utils { - public static void log(...); -} +#-assumenosideeffects class com.lightgame.utils.Utils { +# public static void log(...); +#} -assumenosideeffects class com.gh.gamecenter.core.utils.MtaHelper { public static void onEvent(...); diff --git a/vasdk b/vasdk index 0a6c6c2e38..1c0b8ef16d 160000 --- a/vasdk +++ b/vasdk @@ -1 +1 @@ -Subproject commit 0a6c6c2e3899b1c0d2b3d2285298c847af6b2c47 +Subproject commit 1c0b8ef16d387c697a65671d9d30a279e316070d