fix:畅玩游戏无法更新的问题

This commit is contained in:
yangfei
2024-02-23 17:57:42 +08:00
parent e4c5d950eb
commit 053fd1eebd
4 changed files with 32 additions and 21 deletions

View File

@ -728,10 +728,10 @@ public class MainActivity extends BaseActivity {
ToastUtils.showToast("游戏启动中,请稍后~");
handler.postDelayed(() -> {
if (VHelper.isLegacyGame(gamePackageName)) {
VHelper.postOnInitialized(launchGame(gamePackageName));
} else {
if(VHelper.isInnerInstalled(gamePackageName)) {
launchGame(gamePackageName).invoke();
} else {
VHelper.postOnInitialized(launchGame(gamePackageName));
}
}, 500);
break;

View File

@ -248,6 +248,12 @@ object VHelper {
mIsAppVisible = false
}
})
runOnIoThread {
val allGames = vGameDao.getAll().map { it.packageName }.toArrayList()
if (allGames.isNotEmpty()) {
PackageRepository.addInstalledGames(allGames, true)
}
}
}
val config = Config.getVSettingEntity()?.va
@ -477,10 +483,18 @@ object VHelper {
}
/**
* 旧版畅玩组件是否安装此包名的畅玩游戏
* 此语义是判断是否安装的畅玩游戏
* 畅玩组件是否已安装此包名的畅玩游戏, 包含 1. 分体式畅玩, 2. 一体式畅玩 两个地方
* 否则应该单独针对分体式和一体式判断
*/
@JvmStatic
fun isInstalled(packageName: String?): Boolean {
fun isInstalled(packageName: String?) = isInnerInstalled(packageName) || isLegacyInstalled(packageName)
/**
* 分体式畅玩是否安装了游戏
*/
@JvmStatic
fun isLegacyInstalled(packageName: String?): Boolean {
var isInstalled = mInstalledInfoList.any { it.packageName == packageName }
Utils.log(LOG_TAG, "$packageName 已安装列表里 -> $isInstalled")
@ -530,15 +544,15 @@ object VHelper {
* 获取游戏占用的空间
*/
fun getAppOccupiedSpace(packageName: String): Long {
return if (isLegacyGame(packageName)) {
return if(isInnerInstalled(packageName)) {
VaApp.get().appManager.getAppOccupiedSpace(packageName)
} else {
try {
mDelegateManager.getAppOccupiedSpace(packageName)
} catch (e: Exception) {
e.printStackTrace()
0
}
} else {
VaApp.get().appManager.getAppOccupiedSpace(packageName)
}
}
@ -696,7 +710,7 @@ object VHelper {
return
}
if(new32UpdateEntity != null && (PackageUtils.getVersionCodeByPackageName(vaArch32.packageName) < new32UpdateEntity.versionCode)) {
if (new32UpdateEntity != null && (PackageUtils.getVersionCodeByPackageName(vaArch32.packageName) < new32UpdateEntity.versionCode)) {
val dialogType = if (new32UpdateEntity.isForce) "强制更新" else "提示更新"
NewFlatLogUtils.logHaloFunUpdateDialogShow(
gameEntity?.id ?: "",
@ -725,7 +739,7 @@ object VHelper {
},
confirmClickCallback = {
NewFlatLogUtils.logHaloFunUpdateDialogClick(dialogType, "继续游戏", "")
if(!new32UpdateEntity.isForce) {
if (!new32UpdateEntity.isForce) {
callback.invoke()
}
},
@ -784,9 +798,6 @@ object VHelper {
return ArrayList(list)
}
@JvmStatic
fun isLegacyGame(packageName: String) = isInstalled(packageName)
private fun gotoVspaceLoading(
context: Context,
downloadEntity: DownloadEntity,
@ -815,7 +826,7 @@ object VHelper {
) {
Utils.log(LOG_TAG, "尝试安装新游戏 ${downloadEntity.path}")
// 如果一个游戏存在旧版畅玩助手内,此次安装就是游戏更新
val isLegacyGame = isLegacyGame(downloadEntity.packageName)
val isLegacyGame = isLegacyInstalled(downloadEntity.packageName)
// 更新此包名对应的 gameId Map
mTempPackageNameAndGameIdMap[downloadEntity.packageName] = downloadEntity.gameId
@ -1187,7 +1198,7 @@ object VHelper {
category = gameType
setApk(arrayListOf(ApkEntity(packageName = packageName, bit = bit)))
}) {
if (isLegacyGame(packageName) || isInnerInstalled(packageName)) {
if (isInstalled(packageName)) {
launch(context, packageName)
return@validateVSpaceBeforeAction
}
@ -1221,7 +1232,7 @@ object VHelper {
showLoading: Boolean = true
) {
Utils.log(LOG_TAG, "尝试打开应用 $packageName")
val isLegacyGame = isLegacyGame(packageName)
val isLegacyGame = isLegacyInstalled(packageName)
// 置空下载挂起回调(能 launch 游戏说明畅玩组件已安装)
mPendingDownloadCallback = null
@ -1276,7 +1287,7 @@ object VHelper {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(intent)
} else {
if (isLegacyGame(packageName)) {
if (isLegacyGame) {
VirtualAppManager.get().launchGame(packageName)
} else {
VaApp.get().appManager.launchGame(packageName)

View File

@ -100,10 +100,10 @@ class ShortcutManager private constructor() {
}
}
}
if (VHelper.isLegacyGame(gamePkg)) {
VHelper.postOnInitialized(createShortcutLambda)
} else {
if (VHelper.isInnerInstalled(gamePkg)) {
createShortcutLambda.invoke()
} else {
VHelper.postOnInitialized(createShortcutLambda)
}
}