fix: 修复覆盖安装时因为没有成功获取设置配置而导致功能被关闭的问题

This commit is contained in:
chenjuntao
2023-06-01 11:16:42 +08:00
parent 9050a04c3a
commit b86e372e5b
4 changed files with 18 additions and 15 deletions

View File

@ -122,17 +122,6 @@ public class Config {
return false;
}
/**
* 是否启用畅玩游戏
*/
public static boolean isVGameEnabled() {
if (getSettings() == null) {
return false;
}
return !"off".equals(getSettings().getGameSmooth());
}
/**
* VPN 开关选项是否开启
*/
@ -229,6 +218,8 @@ public class Config {
if (!TextUtils.isEmpty(json)) {
mSettingsEntity = GsonUtils.fromJson(json, SettingsEntity.class);
}
mSettingsEntity.setGameSmooth("off");
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -1465,10 +1465,25 @@ object VHelper {
/**
* 畅玩功能是否启用
* 设备系统版本大于 7.1 且后台接口开启时才启用畅玩功能
*/
@JvmStatic
fun isVGameOn() = BuildConfig.DEBUG
|| (BuildConfig.IS_VGAME_ON && Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1 && Config.isVGameEnabled())
|| (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1 && isVGameOnByConfigSettings())
/**
* 后台接口是否启用畅玩功能(若获取不到开关情况时,判断用户是否曾用过畅玩功能)
*/
private fun isVGameOnByConfigSettings(): Boolean {
val configSettings = Config.getSettings()
// 当 settings 为空时,若曾经用过畅玩,也允许用户继续使用畅玩
return if (configSettings == null) {
isVIsUsed()
} else {
"off" == configSettings.gameSmooth
}
}
/**
* 检查畅玩游戏是否满足生成存档要求