From b86e372e5b8e464e641ecb298f329fca08b85e46 Mon Sep 17 00:00:00 2001 From: chenjuntao Date: Thu, 1 Jun 2023 11:16:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=A6=86=E7=9B=96?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E6=97=B6=E5=9B=A0=E4=B8=BA=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E8=8E=B7=E5=8F=96=E8=AE=BE=E7=BD=AE=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E8=80=8C=E5=AF=BC=E8=87=B4=E5=8A=9F=E8=83=BD=E8=A2=AB?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gh/common/constant/Config.java | 13 ++----------- app/src/main/java/com/gh/vspace/VHelper.kt | 17 ++++++++++++++++- module_common/build.gradle | 1 - scripts/build_with_simple_backup.sh | 2 -- 4 files changed, 18 insertions(+), 15 deletions(-) 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 038f045a46..cabf74a0e5 100644 --- a/app/src/main/java/com/gh/common/constant/Config.java +++ b/app/src/main/java/com/gh/common/constant/Config.java @@ -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(); } diff --git a/app/src/main/java/com/gh/vspace/VHelper.kt b/app/src/main/java/com/gh/vspace/VHelper.kt index 52f11df73f..dd10594320 100644 --- a/app/src/main/java/com/gh/vspace/VHelper.kt +++ b/app/src/main/java/com/gh/vspace/VHelper.kt @@ -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 + } + } /** * 检查畅玩游戏是否满足生成存档要求 diff --git a/module_common/build.gradle b/module_common/build.gradle index 6aff66dcb3..f74c66134a 100644 --- a/module_common/build.gradle +++ b/module_common/build.gradle @@ -33,7 +33,6 @@ android { */ buildConfigField "long", "BUILD_TIME", "0" buildConfigField "boolean", "IS_DARK_MODE_ON", "true" - buildConfigField "boolean", "IS_VGAME_ON", "true" } buildFeatures { diff --git a/scripts/build_with_simple_backup.sh b/scripts/build_with_simple_backup.sh index 42307dbf32..e7519ce322 100755 --- a/scripts/build_with_simple_backup.sh +++ b/scripts/build_with_simple_backup.sh @@ -21,8 +21,6 @@ else sed -i '1 a plugins { id "io.sentry.android.gradle" version "2.1.5" }' app/build.gradle fi -sed -i 's/buildConfigField "boolean", "IS_VGAME_ON", "true"/buildConfigField "boolean", "IS_VGAME_ON", "true"/g' module_common/build.gradle - ./gradlew --stop ./gradlew clean