diff --git a/app/src/main/java/com/gh/base/GlobalActivityLifecycleObserver.kt b/app/src/main/java/com/gh/base/GlobalActivityLifecycleObserver.kt index f81a48f2f9..9ece998764 100644 --- a/app/src/main/java/com/gh/base/GlobalActivityLifecycleObserver.kt +++ b/app/src/main/java/com/gh/base/GlobalActivityLifecycleObserver.kt @@ -61,7 +61,7 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks { NightModeSwitchHelper.showNightModeSwitchFloatingView(activity) } - if (activity is AppCompatActivity) { + if (activity is AppCompatActivity && activity !is SplashScreenActivity) { VHelper.showFeedbackDialogIfLastSuccessfulLaunchedGameExitUnexpectedly(activity) } } 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 c3991a0a3a..3f1b7c0955 100644 --- a/app/src/main/java/com/gh/common/constant/Config.java +++ b/app/src/main/java/com/gh/common/constant/Config.java @@ -25,6 +25,7 @@ import com.gh.gamecenter.eventbus.EBReuse; import com.gh.gamecenter.common.retrofit.BiResponse; import com.gh.gamecenter.common.retrofit.Response; import com.gh.gamecenter.retrofit.RetrofitManager; +import com.gh.vspace.VHelper; import com.halo.assistant.HaloApp; import com.lightgame.utils.Utils; @@ -115,6 +116,17 @@ public class Config { return false; } + /** + * 是否启用畅玩游戏 + */ + public static boolean isVGameEnabled() { + if (getSettings() == null) { + return false; + } + + return !"off".equals(getSettings().getGameSmooth()); + } + public static boolean isShowPlugin(String gameId) { SharedPreferences preferences = getPreferences(); @@ -185,6 +197,9 @@ public class Config { // 加载完设置后刷新下 PackageHelper.initList(); + + // 初始化畅玩相关的东西 + VHelper.init(HaloApp.getInstance()); } @Nullable diff --git a/app/src/main/java/com/gh/gamecenter/entity/SettingsEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/SettingsEntity.kt index a8e8a55ee1..38162da908 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/SettingsEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/SettingsEntity.kt @@ -32,7 +32,9 @@ data class SettingsEntity( @SerializedName("permission_popup_switch") var permissionPopupSwitch: String = "off",//权限引导弹窗开关,on/off @SerializedName("permission_popup_applied_versions") - var permissionPopupAppliedVersions: PermissionPopupAppliedVersions = PermissionPopupAppliedVersions() + var permissionPopupAppliedVersions: PermissionPopupAppliedVersions = PermissionPopupAppliedVersions(), + @SerializedName("game_smooth") + var gameSmooth: String = "off" // 畅玩功能,on/off,默认off ) { fun setCommunityEntrance(communityEntrance: String) { diff --git a/app/src/main/java/com/gh/vspace/VHelper.kt b/app/src/main/java/com/gh/vspace/VHelper.kt index 8bc998661f..897899b6cd 100644 --- a/app/src/main/java/com/gh/vspace/VHelper.kt +++ b/app/src/main/java/com/gh/vspace/VHelper.kt @@ -75,6 +75,8 @@ object VHelper { private var mUpdateEntity: AppEntity? = null + private var mIsInitialized = false // 是否已初始化 + // 当前正卡在安装中的 VA 游戏,避免重复调用安装 private val mInstallingVaPathSet by lazy { Collections.synchronizedSet(hashSetOf()) } @@ -102,7 +104,9 @@ object VHelper { @SuppressLint("CheckResult") @JvmStatic fun init(context: Context) { - if (isVGameOn()) { + if (isVGameOn() && !mIsInitialized) { + mIsInitialized = true + val config = Config.getVSettingEntity()?.va if (config != null && PackageUtils.isInstalled(context, config.arch64?.packageName)) { connectService(true) @@ -543,6 +547,10 @@ object VHelper { } Utils.log(LOG_TAG, "卸载应用结果 -> $result") + + runOnIoThread { + VBackupHelper.backupDBToExternalStorage(HaloApp.getInstance()) + } } catch (e: Exception) { ToastUtils.toast(e.localizedMessage ?: "") } @@ -831,6 +839,8 @@ object VHelper { } @JvmStatic - fun isVGameOn() = BuildConfig.IS_VGAME_ON && Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1 + fun isVGameOn() = BuildConfig.IS_VGAME_ON + && Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1 + && Config.isVGameEnabled() } \ No newline at end of file