Compare commits
74 Commits
v5.35.0-de
...
v5.35.5-de
| Author | SHA1 | Date | |
|---|---|---|---|
| 18f213ec7d | |||
| 9d7c533207 | |||
| 54ee8a9c69 | |||
| 2b44efd6b3 | |||
| d62c8beb30 | |||
| d46aa81dbe | |||
| 51c0bf27cf | |||
| 06b2d2b416 | |||
| af7580a6a6 | |||
| 1e4375ec8a | |||
| 196e719358 | |||
| dd051b4d13 | |||
| e7f756555c | |||
| b8c4f1403b | |||
| b88698c2a3 | |||
| c897d5ad0f | |||
| 037f453a75 | |||
| ad3a3c1341 | |||
| ba320f7740 | |||
| f3dbc0b779 | |||
| 0c518ac40e | |||
| bf57118900 | |||
| b80a14f2b1 | |||
| 1450064640 | |||
| 90e19d5099 | |||
| 383124dc36 | |||
| 6d6ce2613a | |||
| 8569264b82 | |||
| 59667abf09 | |||
| b651ef8617 | |||
| 76e17eddd7 | |||
| f01e08aec9 | |||
| faddf5d7b6 | |||
| 81cf2f0ddc | |||
| 198561d15a | |||
| 1e721b699c | |||
| 8f48dfd347 | |||
| bc811a2882 | |||
| bfd986fdfd | |||
| a2bd5e01e0 | |||
| 844d227f19 | |||
| 8b1f92e9c4 | |||
| f5834d440b | |||
| f982bf6478 | |||
| 33d7afec71 | |||
| 37ef50f323 | |||
| 4c6acdee3a | |||
| 6beb060e63 | |||
| a552677e41 | |||
| bb148f42b8 | |||
| 065aa96e18 | |||
| d9a90ca80b | |||
| 2aeffb1cc4 | |||
| d3188cc3cd | |||
| 1d7f902a81 | |||
| 13a40806e4 | |||
| b56e5c4022 | |||
| acca1537da | |||
| 6e5b639d58 | |||
| 24000f55af | |||
| d11ccba0b7 | |||
| 3540c4626d | |||
| e6a2758fdb | |||
| a56e2bd16e | |||
| e038c565ff | |||
| ec5905bb11 | |||
| 21f50c4eed | |||
| 5a93f3671b | |||
| 6dcb8b6efe | |||
| d60916b3bc | |||
| 4e00b5db19 | |||
| e6a6bbcf97 | |||
| 0eecc4699f | |||
| 920e7a8038 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -9,4 +9,6 @@ build/
|
||||
release-app/
|
||||
test-app/
|
||||
scripts/apk-channel/
|
||||
app/src/test/java/com/gh/gamecenter
|
||||
app/src/test/java/com/gh/gamecenter
|
||||
app/src/main/assets-debug/
|
||||
app/src/main/assets-release/
|
||||
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -5,9 +5,9 @@
|
||||
[submodule "vspace-bridge"]
|
||||
path = vspace-bridge
|
||||
url = ../../../cwzs/android/vspace-bridge.git
|
||||
[submodule "module_common/src/debug/assets/assistant-android-mock"]
|
||||
path = module_common/src/debug/assets/assistant-android-mock
|
||||
url = ../../../halo/android/assistant-android-mock.git
|
||||
[submodule "ndownload"]
|
||||
path = ndownload
|
||||
url = ../../../android/ndownload.git
|
||||
[submodule "vasdk"]
|
||||
path = vasdk
|
||||
url = ../../../sdg/android/vasdk.git
|
||||
|
||||
@ -75,7 +75,7 @@ android {
|
||||
versionName rootProject.ext.versionName
|
||||
applicationId rootProject.ext.applicationId
|
||||
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt', 'proguard-fresco.txt'
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt', 'proguard-fresco.txt', rootProject.ext.va_proguard_rules
|
||||
|
||||
String CORE_EVENT_GAME_CATEGORY = ""
|
||||
|
||||
@ -164,6 +164,15 @@ android {
|
||||
flavorDimensions("env", "region")
|
||||
|
||||
sourceSets {
|
||||
|
||||
debug {
|
||||
assets.srcDirs += 'src/main/assets-debug'
|
||||
}
|
||||
|
||||
release {
|
||||
assets.srcDirs += 'src/main/assets-release'
|
||||
}
|
||||
|
||||
publish {
|
||||
java.srcDirs = ['src/main/java', "src/default/java"]
|
||||
}
|
||||
@ -368,7 +377,7 @@ dependencies {
|
||||
kapt "com.alibaba:arouter-compiler:$arouterVersion"
|
||||
|
||||
implementation project(':ndownload')
|
||||
implementation project(':vspace-bridge:vspace')
|
||||
implementation project(':vspace-bridge')
|
||||
|
||||
implementation (project(':module_common')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
@ -401,7 +410,7 @@ dependencies {
|
||||
implementation(project(':feature:pkg'))
|
||||
implementation(project(':feature:oaid'))
|
||||
implementation(project(':feature:floating-window'))
|
||||
implementation(project(':feature:csj_ad'))
|
||||
// implementation(project(':feature:csj_ad'))
|
||||
// implementation(project(':feature:beizi_startup_ad'))
|
||||
implementation(project(':feature:xapk-installer'))
|
||||
implementation(project(':feature:qq_game')) {
|
||||
@ -409,12 +418,24 @@ dependencies {
|
||||
}
|
||||
internalImplementation(project(':module_internal_test'))
|
||||
|
||||
// 根据BUILD_PUSH_TYPE决定使用哪个推送SDK,目前默认使用阿里云推送
|
||||
def pushProject = findProperty('BUILD_PUSH_TYPE') == 'jg'
|
||||
? project(':feature:jg_push') : project(':feature:acloud_push')
|
||||
implementation(pushProject) {
|
||||
// def pushProperty = findProperty('BUILD_PUSH_TYPE')
|
||||
// // 根据BUILD_PUSH_TYPE决定使用哪个推送SDK,目前默认使用极光推送
|
||||
// def pushProject = (pushProperty == null || pushProperty == 'jg')
|
||||
// ? project(':feature:jg_push') : project(':feature:acloud_push')
|
||||
// implementation(pushProject) {
|
||||
// exclude group: 'androidx.swiperefreshlayout'
|
||||
// }
|
||||
|
||||
implementation(project(":va-lib"))
|
||||
implementation(project(':va-main')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
debugImplementation "com.bytedance.tools.codelocator:codelocator-core:2.0.3"
|
||||
compileOnly project(":va-core")
|
||||
compileOnly project(":va-plugin-host-lib")
|
||||
implementation project(":va-plugin-host")
|
||||
implementation project(":va-archive")
|
||||
|
||||
}
|
||||
|
||||
File propFile = file('sign.properties')
|
||||
|
||||
@ -1,32 +1,79 @@
|
||||
package com.gh.vspace
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.Keep
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.databinding.LayoutPersonalOtherItemBinding
|
||||
import com.gh.vspace.installexternalgames.InstallExternalGameActivity
|
||||
import com.lg.vspace.VaApp
|
||||
import com.lg.vspace.plugin.host.PluginHelper
|
||||
import com.lightgame.utils.Utils
|
||||
import com.lightgame.utils.toast.ToastHelper
|
||||
import com.lody.virtual.client.core.VirtualCore
|
||||
import java.io.File
|
||||
|
||||
@Keep
|
||||
class ExternalGameUsage : IExternalGamesUsage {
|
||||
override fun addInstallExternalGameButton(viewParent: ViewGroup) {
|
||||
class ExternalGameUsage : ITestCase {
|
||||
|
||||
private fun buttonTemplate(viewParent: ViewGroup, id: Int, fn: (LayoutPersonalOtherItemBinding) -> Unit) {
|
||||
val context = viewParent.context
|
||||
viewParent.findViewById<View>(R.id.install_game_from_external) ?: run {
|
||||
viewParent.findViewById<View>(id) ?: run {
|
||||
val binding = LayoutPersonalOtherItemBinding.inflate(LayoutInflater.from(context)).apply {
|
||||
root.id = R.id.install_game_from_external
|
||||
titleTv.text = context.getString(R.string.title_install_external_game)
|
||||
iconIv.setImageResource(R.drawable.ic_personal_my_game)
|
||||
root.setOnClickListener {
|
||||
VHelper.connectService {
|
||||
context.startActivity(
|
||||
InstallExternalGameActivity.getIntent(context)
|
||||
.apply { flags = flags or Intent.FLAG_ACTIVITY_NEW_TASK })
|
||||
}
|
||||
}
|
||||
root.id = id
|
||||
fn(this)
|
||||
}
|
||||
viewParent.addView(binding.root, 0)
|
||||
}
|
||||
}
|
||||
|
||||
override fun addInstallExternalGameButton(viewParent: ViewGroup) {
|
||||
val context = viewParent.context
|
||||
buttonTemplate(viewParent, R.id.install_game_from_external) {
|
||||
it.titleTv.text = context.getString(R.string.title_install_external_game)
|
||||
it.iconIv.setImageResource(R.drawable.ic_personal_my_game)
|
||||
it.root.setOnClickListener {
|
||||
VHelper.connectService {
|
||||
context.startActivity(
|
||||
InstallExternalGameActivity.getIntent(context)
|
||||
.apply { flags = flags or Intent.FLAG_ACTIVITY_NEW_TASK })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun addInstallPluginButton(viewParent: ViewGroup) {
|
||||
buttonTemplate(viewParent, R.id.install_plugin) {
|
||||
it.titleTv.text = "安装64位插件"
|
||||
it.root.setOnClickListener {
|
||||
val file = File("/data/local/tmp/gh-plugins/artifacts.zip")
|
||||
if (file.exists()) {
|
||||
Utils.log(VHelper.LOG_TAG, "有本地更新文件: 64位插件")
|
||||
// TODO: 补充debug插件更新
|
||||
ToastUtils.showToast("暂未实现debug功能")
|
||||
} else {
|
||||
ToastUtils.showToast("data/local/tmp没有push文件")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun addInstallPlugin32Button(viewParent: ViewGroup) {
|
||||
buttonTemplate(viewParent, R.id.install_plugin_32) {
|
||||
it.titleTv.text = "安装32位插件"
|
||||
it.root.setOnClickListener {
|
||||
val file = File("/data/local/tmp/gh-plugins/artifacts32.zip")
|
||||
if (file.exists()) {
|
||||
// TODO: 补充debug插件更新
|
||||
ToastUtils.showToast("暂未实现debug功能")
|
||||
} else {
|
||||
ToastUtils.showToast("data/local/tmp没有push文件")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -25,6 +25,11 @@ class ExternalGameAdapter(private val games: List<ExternalGameUiState>, private
|
||||
路径:${item.apkPath}
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
holder.update.setOnClickListener {
|
||||
onItemClickListener.onItemClick(item, OnItemClickListener.ClickType.CLICK_INSTALL)
|
||||
}
|
||||
|
||||
holder.install.goneIf(item.isInstalled) {
|
||||
holder.install.setOnClickListener {
|
||||
onItemClickListener.onItemClick(item, OnItemClickListener.ClickType.CLICK_INSTALL)
|
||||
|
||||
@ -8,4 +8,5 @@ class ExternalGameViewHolder(binding: LayoutExternalGameItemBinding) : RecyclerV
|
||||
val install = binding.btnInstall
|
||||
val uninstall = binding.btnUninstall
|
||||
val start = binding.btnStart
|
||||
val update = binding.btnUpdate
|
||||
}
|
||||
@ -16,6 +16,7 @@ import com.gh.gamecenter.databinding.FragmentInstallExternalGamesBinding
|
||||
import com.gh.vspace.VHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lg.vspace.VirtualAppManager
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import io.reactivex.Single
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
@ -105,6 +106,15 @@ class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener {
|
||||
private fun install(externalGameUiState: ExternalGameUiState) {
|
||||
val bit =
|
||||
externalGameUiState.externalGameEntity.cpuAbi.let { if (it.size == 1 && it.contains("armeabi-v7a")) "32" else "64" }
|
||||
|
||||
VHelper.install(requireContext(), DownloadEntity().apply {
|
||||
externalGameUiState.externalGameEntity.apply {
|
||||
packageName = apkPackageName
|
||||
path = apkPath
|
||||
}
|
||||
}, true)
|
||||
|
||||
|
||||
if (VHelper.showDialogIfVSpaceIsNeeded(
|
||||
requireContext(),
|
||||
"",
|
||||
@ -144,7 +154,9 @@ class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener {
|
||||
com.gh.gamecenter.BuildConfig.VERSION_NAME,
|
||||
HaloApp.getInstance().channel,
|
||||
"",
|
||||
""
|
||||
"",
|
||||
com.lg.core.BuildConfig.VERSION_NAME,
|
||||
HaloApp.getInstance().oaid
|
||||
)
|
||||
requireActivity().startActivity(intent)
|
||||
}
|
||||
|
||||
@ -24,6 +24,14 @@
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_update"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/text_update"
|
||||
android:visibility="visible"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_uninstall"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<item name="install_game_from_external" type="id" />
|
||||
<item name="install_plugin" type="id" />
|
||||
<item name="install_plugin_32" type="id" />
|
||||
</resources>
|
||||
@ -2,6 +2,7 @@
|
||||
<resources>
|
||||
<string name="title_install_external_game">从SD卡安装</string>
|
||||
<string name="text_install">安装</string>
|
||||
<string name="text_update">更新</string>
|
||||
<string name="text_uninstall">卸载</string>
|
||||
<string name="text_start">启动</string>
|
||||
</resources>
|
||||
@ -11,6 +11,12 @@
|
||||
<package android:name="com.lg.vspace" />
|
||||
</queries>
|
||||
|
||||
<!-- 华为/荣耀角标 -->
|
||||
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE "/>
|
||||
<uses-permission android:name="com.hihonor.android.launcher.permission.CHANGE_BADGE" />
|
||||
<!-- vivo角标 -->
|
||||
<uses-permission android:name="com.vivo.notification.permission.BADGE_ICON" />
|
||||
|
||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
|
||||
tools:ignore="ScopedStorage" />
|
||||
<!-- 允许应用程序访问网络连接 -->
|
||||
@ -86,7 +92,30 @@
|
||||
com.tencent.qqmini,
|
||||
com.tencent.qqmini.minigame.external,
|
||||
com.tencent.qqmini.minigame.opensdk,
|
||||
com.tencent.qqmini.union.ad" />
|
||||
com.tencent.qqmini.union.ad,
|
||||
com.lg.vspace,
|
||||
io.lg.va.common,
|
||||
com.va.floating,
|
||||
com.lg.cloud,
|
||||
com.lg.archive,
|
||||
com.lg.vclient,
|
||||
com.va.realname,
|
||||
com.lg.vspace.flavor,
|
||||
com.lg.update,
|
||||
com.lg.login,
|
||||
com.lg.accelerator,
|
||||
com.lody.virtual,
|
||||
com.lg.core,
|
||||
com.lg.ads,
|
||||
com.lg.common,
|
||||
com.lg.vspace.network,
|
||||
com.lody.virtual.lib.res,
|
||||
com.va.host,
|
||||
com.lg.vspace.plugin.host,
|
||||
com.lg.plugin.constant,
|
||||
com.bytedance.tools.codelocator,
|
||||
org.chickenhook.restrictionbypass,
|
||||
com.lody.virtual.sandhook,com.lg.vspace.common" />
|
||||
|
||||
<!-- 去掉 SDK 一些流氓权限 -->
|
||||
<uses-permission
|
||||
@ -777,7 +806,8 @@
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
android:grantUriPermissions="true"
|
||||
tools:replace="android:authorities">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/provider_paths" />
|
||||
|
||||
@ -6,8 +6,6 @@
|
||||
<link rel="stylesheet" type="text/css" href="normalize.css">
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
<link rel="stylesheet" type="text/css" href="video-js.min.css">
|
||||
<!-- <link rel="stylesheet" href="https://static-web.ghzs.com/website-static/lib/video-js.min.css">--> <!--在web页面播放视频-->
|
||||
<!--<link rel="stylesheet" type="text/css" href="https://resource.ghzs.com/css/halo_app.css">-->
|
||||
</head>
|
||||
|
||||
<body style="overflow-x: hidden; word-break: break-all;">
|
||||
@ -15,8 +13,5 @@
|
||||
<script type="text/javascript" src="zepto.min.js"></script>
|
||||
<script type="text/javascript" src="rich_editor.js"></script>
|
||||
<script type="text/javascript" src="video.min.js"></script>
|
||||
<!--<script src="https://static-web.ghzs.com/website-static/lib/video.min.js"></script>--> <!--在web页面播放视频-->
|
||||
<!--<script type="text/javascript" src="content.js"></script>-->
|
||||
<!--<script type="text/javascript" src="https://resource.ghzs.com/js/halo_app.js"></script>-->
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -34,18 +34,18 @@ try {
|
||||
var script = document.createElement("script")
|
||||
document.body.appendChild(script)
|
||||
if (isDebug) {
|
||||
script.src = "https://resource.ghzs.com/js/halo_app_test.js" + "?timestamp=" + Math.round(new Date().getTime() / 1000)
|
||||
script.src = "https://dev-and-static.ghzs66.com/web/js/halo.js" + "?timestamp=" + Math.round(new Date().getTime() / 1000)
|
||||
} else {
|
||||
script.src = "https://resource.ghzs.com/js/halo.js" + "?timestamp=" + Math.round(new Date().getTime() / 1000 / 1000)
|
||||
script.src = "https://and-static.ghzs66.com/web/js/halo.js" + "?timestamp=" + Math.round(new Date().getTime() / 1000 / 1000)
|
||||
}
|
||||
|
||||
var style = document.createElement("link")
|
||||
style.rel = "stylesheet"
|
||||
style.type = "text/css"
|
||||
if (isDebug) {
|
||||
style.href = "https://resource.ghzs.com/css/halo_app_test.css" + "?timestamp=" + Math.round(new Date().getTime() / 1000)
|
||||
style.href = "https://dev-and-static.ghzs66.com/web/css/halo.css" + "?timestamp=" + Math.round(new Date().getTime() / 1000)
|
||||
} else {
|
||||
style.href = "https://resource.ghzs.com/css/halo.css" + "?timestamp=" + Math.round(new Date().getTime() / 1000 / 1000)
|
||||
style.href = "https://and-static.ghzs66.com/web/css/halo.css" + "?timestamp=" + Math.round(new Date().getTime() / 1000 / 1000)
|
||||
}
|
||||
|
||||
document.head.appendChild(style)
|
||||
|
||||
@ -191,10 +191,11 @@ object AdDelegateHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* 热启动是否需要显示开屏广告
|
||||
* 热启动是否需要显示开屏广告(目前只展示第三方广告)
|
||||
*/
|
||||
private fun shouldShowStartUpAdWhenHotLaunch() =
|
||||
mSplashAd?.displayRule?.hotStartSplashAd?.type == AD_TYPE_SDK && mSplashAd?.hotStartThirdPartyAd != null
|
||||
private fun shouldShowStartUpAdWhenHotLaunch() = (mCsjAdImpl != null || mBeiziAdImpl != null)
|
||||
&& mSplashAd?.displayRule?.hotStartSplashAd?.type == AD_TYPE_SDK
|
||||
&& mSplashAd?.hotStartThirdPartyAd != null
|
||||
|
||||
/**
|
||||
* 是否需要显示下载管理广告
|
||||
@ -203,6 +204,10 @@ object AdDelegateHelper {
|
||||
return mDownloadManagerAd != null && !isMatchAdFreeRule(mDownloadManagerAd) && isMatchDownloadManagerAdDisplayRule()
|
||||
}
|
||||
|
||||
fun shouldShowHelperLaunchAd(): Boolean {
|
||||
return mVGameLaunchAd != null && !isMatchAdFreeRule(mVGameLaunchAd) && isMatchAdDisplayRule(mVGameLaunchAd, Constants.SP_LAST_HELPER_LAUNCH_AD_SHOW_TIME)
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否需要显示游戏搜索广告
|
||||
*/
|
||||
@ -247,10 +252,11 @@ object AdDelegateHelper {
|
||||
/**
|
||||
* 是否大于广告管理展示间隔时长
|
||||
*/
|
||||
private fun isMatchDownloadManagerAdDisplayRule(): Boolean {
|
||||
mDownloadManagerAd?.displayRule?.run {
|
||||
private fun isMatchDownloadManagerAdDisplayRule(): Boolean = isMatchAdDisplayRule(mDownloadManagerAd, Constants.SP_LAST_DOWNLOAD_MANAGER_AD_SHOW_TIME)
|
||||
private fun isMatchAdDisplayRule(adConfig: AdConfig?, spKey: String): Boolean {
|
||||
adConfig?.displayRule?.run {
|
||||
if (adDisplayInterval > 0) {
|
||||
val lastShowTime = SPUtils.getLong(Constants.SP_LAST_DOWNLOAD_MANAGER_AD_SHOW_TIME, 0L)
|
||||
val lastShowTime = SPUtils.getLong(spKey, 0L)
|
||||
val durationInMinutes = (System.currentTimeMillis() - lastShowTime).toFloat() / 1000 / 60
|
||||
return durationInMinutes > adDisplayInterval
|
||||
} else {
|
||||
|
||||
44
app/src/main/java/com/gh/ad/LaunchAdImpl.kt
Normal file
44
app/src/main/java/com/gh/ad/LaunchAdImpl.kt
Normal file
@ -0,0 +1,44 @@
|
||||
package com.gh.ad
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.utils.goneIf
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.lg.vspace.ui.launcher.ILaunchAd
|
||||
|
||||
@Route(path = RouteConsts.provider.vaAd, name = "畅玩启动页广告")
|
||||
class LaunchAdImpl : ILaunchAd {
|
||||
override fun init(context: Context?) {
|
||||
}
|
||||
|
||||
override fun requestAd(fragment: Fragment, container: ViewGroup, maskView: View) {
|
||||
if (AdDelegateHelper.shouldShowHelperLaunchAd()) {
|
||||
val launchAd = AdDelegateHelper.vGameLaunchAd
|
||||
val showThirdPartyAd = launchAd?.displayRule?.adSource == AdDelegateHelper.AD_TYPE_SDK
|
||||
val thirdPartyAd = launchAd?.thirdPartyAd
|
||||
if (showThirdPartyAd && thirdPartyAd != null) {
|
||||
AdDelegateHelper.requestThirdPartyBannerAd(
|
||||
fragment,
|
||||
container,
|
||||
thirdPartyAd,
|
||||
DisplayUtils.getScreenWidthInDp(fragment.requireActivity()),
|
||||
) { isSuccess ->
|
||||
maskView.goneIf(!isSuccess)
|
||||
if (isSuccess) {
|
||||
SPUtils.setLong(Constants.SP_LAST_HELPER_LAUNCH_AD_SHOW_TIME, System.currentTimeMillis())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -4,6 +4,7 @@ import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.gh.ad.AdDelegateHelper
|
||||
import com.gh.common.util.FloatingBackViewManager
|
||||
import com.gh.common.xapk.XapkInstaller
|
||||
@ -14,9 +15,14 @@ import com.gh.gamecenter.SplashAdActivity
|
||||
import com.gh.gamecenter.SplashScreenActivity
|
||||
import com.gh.gamecenter.authorization.AuthorizationActivity
|
||||
import com.gh.gamecenter.common.base.GlobalActivityManager
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.utils.PackageFlavorHelper
|
||||
import com.gh.gamecenter.core.provider.IPushProvider
|
||||
import com.gh.gamecenter.feedback.view.suggest.SuggestionActivity
|
||||
import com.gh.gamecenter.login.view.LoginActivity
|
||||
import com.gh.vspace.VHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lg.vspace.ui.launcher.LaunchActivity
|
||||
|
||||
// TODO:移动到对应的模块
|
||||
class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
@ -37,11 +43,20 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
&& activity !is SkipActivity
|
||||
&& activity !is AuthorizationActivity
|
||||
&& activity !is SplashAdActivity
|
||||
&& activity !is SuggestionActivity
|
||||
) {
|
||||
activity.startActivity(SplashAdActivity.getIntent(activity))
|
||||
}
|
||||
isFromBackgroundToForeground = false
|
||||
}
|
||||
|
||||
if (activityCount == 1) {
|
||||
// 清除桌面角标
|
||||
if (activity !is SplashScreenActivity && activity !is AuthorizationActivity) {
|
||||
val pushProvider = ARouter.getInstance().build(RouteConsts.provider.push).navigation() as? IPushProvider
|
||||
pushProvider?.cleanBadgeNumber(activity.applicationContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResumed(activity: Activity) {
|
||||
@ -73,6 +88,8 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
}
|
||||
|
||||
if (activity is AppCompatActivity
|
||||
&& activity !is LaunchActivity
|
||||
&& activity !is LoginActivity
|
||||
&& activity !is SplashScreenActivity
|
||||
&& activity !is SkipActivity
|
||||
&& activity !is AuthorizationActivity
|
||||
|
||||
@ -45,7 +45,6 @@ import com.gh.gamecenter.login.user.LoginTag
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.gh.gamecenter.login.user.UserRepository
|
||||
import com.gh.gamecenter.login.utils.LoginHelper
|
||||
import com.gh.gamecenter.login.utils.QuickLoginHelper
|
||||
import com.gh.gamecenter.login.view.LoginActivity
|
||||
import com.gh.gamecenter.personalhome.border.AvatarBorderActivity
|
||||
import com.gh.gamecenter.setting.SettingBridge
|
||||
@ -130,12 +129,12 @@ class DefaultJsApi(
|
||||
|
||||
@JavascriptInterface
|
||||
fun login(msg: Any) {
|
||||
if (SPUtils.getBoolean(Constants.SP_HAS_GET_PHONE_INFO) || NetworkUtils.isOpenMobileData(context)) {
|
||||
QuickLoginHelper.startLogin(context, "浏览器")
|
||||
} else {
|
||||
// if (SPUtils.getBoolean(Constants.SP_HAS_GET_PHONE_INFO) || NetworkUtils.isOpenMobileData(context)) {
|
||||
// QuickLoginHelper.startLogin(context, "浏览器")
|
||||
// } else {
|
||||
val intent = LoginActivity.getIntent(context, "浏览器")
|
||||
context.startActivity(intent)
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
@ -220,7 +219,7 @@ class DefaultJsApi(
|
||||
runOnUiThread {
|
||||
// 若畅玩列表中安装了,优先启动畅玩游戏
|
||||
if (VHelper.isInstalled(packageName)) {
|
||||
if (!VHelper.showDialogIfVSpaceIsNeeded(context, "", "", "", "")) {
|
||||
VHelper.validateVSpaceBeforeAction(context, packageName, null) {
|
||||
VHelper.launch(context, packageName)
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -16,7 +16,7 @@ class ValidateVSpaceHandler : DownloadChainHandler() {
|
||||
}
|
||||
|
||||
if (asVGame) {
|
||||
VHelper.validateVSpaceBeforeAction(context, gameEntity) {
|
||||
VHelper.validateVSpaceBeforeAction(context,gameEntity.getUniquePackageName(), gameEntity) {
|
||||
closure.invoke()
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.gh.common.constant;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
@ -21,14 +22,18 @@ import com.gh.gamecenter.common.utils.EnvHelper;
|
||||
import com.gh.gamecenter.core.utils.GsonUtils;
|
||||
import com.gh.gamecenter.core.utils.SPUtils;
|
||||
import com.gh.gamecenter.core.utils.UrlFilterUtils;
|
||||
import com.gh.gamecenter.entity.AppEntity;
|
||||
import com.gh.gamecenter.entity.GameGuidePopupEntity;
|
||||
import com.gh.gamecenter.entity.NewApiSettingsEntity;
|
||||
import com.gh.gamecenter.entity.NewSettingsEntity;
|
||||
import com.gh.gamecenter.entity.VNewSetting;
|
||||
import com.gh.gamecenter.entity.VSetting;
|
||||
import com.gh.gamecenter.feature.entity.SettingsEntity;
|
||||
import com.gh.gamecenter.feature.entity.SimulatorEntity;
|
||||
import com.gh.gamecenter.feature.utils.ContentBlockedHelper;
|
||||
import com.gh.gamecenter.receiver.PackageChangeBroadcastReceiver;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.gh.gamecenter.retrofit.service.VApiService;
|
||||
import com.gh.vspace.VHelper;
|
||||
import com.halo.assistant.HaloApp;
|
||||
|
||||
@ -39,8 +44,12 @@ import org.json.JSONObject;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleSource;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import io.reactivex.subjects.BehaviorSubject;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
public class Config {
|
||||
@ -57,8 +66,7 @@ public class Config {
|
||||
public static final String WEIBO_APPKEY = BuildConfig.WEIBO_APPKEY;
|
||||
public static final String QUICK_LOGIN_APPID = BuildConfig.QUICK_LOGIN_APPID;
|
||||
public static final String QUICK_LOGIN_APPKEY = BuildConfig.QUICK_LOGIN_APPKEY;
|
||||
// http://www.ghzs666.com/article/${articleId}.html
|
||||
public static final String URL_ARTICLE = "http://www.ghzs666.com/article/"; // ghzs/ghzs666 统一
|
||||
public static final String URL_ARTICLE = "www.ghzs666.com/article/"; // ghzs/ghzs666 统一
|
||||
|
||||
private static final String SETTINGS_KEY = "settingsKey";
|
||||
|
||||
@ -69,6 +77,10 @@ public class Config {
|
||||
private static NewApiSettingsEntity.NightMode mNightModeSetting;
|
||||
private static SimulatorEntity mNewSimulatorEntity;
|
||||
private static VSetting mVSetting;
|
||||
private static VNewSetting mVNewSetting;
|
||||
|
||||
private static AppEntity mNew32UpdateEntity;
|
||||
public static BehaviorSubject<VNewSetting> vNewSettingSubject = BehaviorSubject.create();
|
||||
private static GameGuidePopupEntity mGameGuidePopupEntity;
|
||||
private static SharedPreferences mDefaultSharedPreferences;
|
||||
|
||||
@ -95,8 +107,7 @@ public class Config {
|
||||
getPreferences().edit().putString(SETTINGS_KEY, GsonUtils.toJson(settingsEntity)).apply();
|
||||
mSettingsEntity = settingsEntity;
|
||||
|
||||
// 加载完设置后刷新下
|
||||
PackageHelper.initList();
|
||||
PackageHelper.refreshList();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -197,6 +208,27 @@ public class Config {
|
||||
return mVSetting;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static VNewSetting getVNewSettingEntity() {
|
||||
if (mVNewSetting == null) {
|
||||
try {
|
||||
String json = SPUtils.getString(Constants.SP_V_NEW_SETTINGS);
|
||||
if (!TextUtils.isEmpty(json)) {
|
||||
mVNewSetting = GsonUtils.fromJson(json, VNewSetting.class);
|
||||
vNewSettingSubject.onNext(mVNewSetting);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return mVNewSetting;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static AppEntity getNew32UpdateEntity() {
|
||||
return mNew32UpdateEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求网络数据,尝试刷新畅玩相关配置
|
||||
*/
|
||||
@ -217,6 +249,36 @@ public class Config {
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public static void getNewSetting() {
|
||||
VApiService vApi = RetrofitManager.getInstance().getVApi();
|
||||
vApi.getNewSettings(BuildConfig.VERSION_NAME, Build.VERSION.SDK_INT).flatMap(new Function<VNewSetting, SingleSource<AppEntity>>() {
|
||||
@Override
|
||||
public SingleSource<AppEntity> apply(VNewSetting data) throws Exception {
|
||||
mVNewSetting = data;
|
||||
vNewSettingSubject.onNext(mVNewSetting);
|
||||
SPUtils.setString(Constants.SP_V_NEW_SETTINGS, GsonUtils.toJson(data));
|
||||
if (data.getVa() != null && data.getVa().getArch32() != null) {
|
||||
String versionNameByPackageName = PackageUtils.getVersionNameByPackageName(data.getVa().getArch32().getPackageName());
|
||||
return vApi.getNewPackageUpdate(
|
||||
BuildConfig.VERSION_NAME,
|
||||
versionNameByPackageName != null ? versionNameByPackageName : "",
|
||||
HaloApp.getInstance().getChannel()
|
||||
);
|
||||
}
|
||||
return Single.error(new IllegalStateException("VNewSetting entity is not expected"));
|
||||
}
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BiResponse<AppEntity>() {
|
||||
@Override
|
||||
public void onSuccess(AppEntity data) {
|
||||
mNew32UpdateEntity = data;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static GameGuidePopupEntity getGameGuidePopupEntity() {
|
||||
return mGameGuidePopupEntity;
|
||||
@ -271,6 +333,7 @@ public class Config {
|
||||
});
|
||||
|
||||
refreshVSettingEntity();
|
||||
getNewSetting();
|
||||
|
||||
RetrofitManager.getInstance()
|
||||
.getApi().getGameGuidePopup(Build.MANUFACTURER, Build.VERSION.RELEASE, Build.MODEL, channel, BuildConfig.VERSION_NAME)
|
||||
@ -333,8 +396,31 @@ public class Config {
|
||||
if (mNewApiSettingsEntity.getGameShieldContents() != null) {
|
||||
ContentBlockedHelper.INSTANCE.init(mNewApiSettingsEntity.getGameShieldContents());
|
||||
}
|
||||
|
||||
// 更新安装列表是否开启的配置
|
||||
// if (mNewApiSettingsEntity.getInstalledComplianceSwitch() != null) {
|
||||
// PackageHelper.INSTANCE.updateIsGetInstalledPackagesApiAgreedRequired(mNewApiSettingsEntity.getInstalledComplianceSwitch());
|
||||
// } else {
|
||||
// PackageHelper.INSTANCE.updateIsGetInstalledPackagesApiAgreedRequired(false);
|
||||
// }
|
||||
|
||||
// 更新包名监听是否开启
|
||||
if (mNewApiSettingsEntity.isPackageObserveEnable()) {
|
||||
observePackageChange(mNewApiSettingsEntity.getPackageObserveActions());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void observePackageChange(NewApiSettingsEntity.PackageObserveActions packageObserveActions) {
|
||||
PackageChangeBroadcastReceiver receiver = new PackageChangeBroadcastReceiver(packageObserveActions);
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
intentFilter.addAction(packageObserveActions.getAdd());
|
||||
intentFilter.addAction(packageObserveActions.getRem());
|
||||
intentFilter.addAction(packageObserveActions.getRep());
|
||||
intentFilter.addDataScheme("package");
|
||||
HaloApp.getInstance().registerReceiver(receiver, intentFilter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.common.util.LogUtils
|
||||
import com.gh.common.util.PackageHelper
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.R
|
||||
@ -59,7 +60,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
private val mDuration = 3000
|
||||
private var mDisposable: Disposable? = null
|
||||
private var mAdapter: PackageCheckAdapter? = null
|
||||
private var mAllInstalledPackages = PackageUtils.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||
private var mAllInstalledPackages = PackageHelper.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||
var gameEntity: GameEntity? = null
|
||||
var callBack: ConfirmListener? = null
|
||||
|
||||
@ -325,7 +326,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mAllInstalledPackages = PackageUtils.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||
mAllInstalledPackages = PackageHelper.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||
gameEntity?.packageDialog?.let {
|
||||
if (isAllPackageInstalled(mAllInstalledPackages, it)) {
|
||||
callBack?.onConfirm()
|
||||
@ -363,7 +364,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMainThread(busFour: EBPackage) {
|
||||
if (busFour.isInstalledOrUninstalled()) {
|
||||
mAllInstalledPackages = PackageUtils.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||
mAllInstalledPackages = PackageHelper.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||
mAdapter?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
@ -416,7 +417,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
return
|
||||
}
|
||||
|
||||
val allInstalledPackages = PackageUtils.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||
val allInstalledPackages = PackageHelper.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||
if (isAllPackageInstalled(allInstalledPackages, packageDialogEntity)) {
|
||||
callBack.onConfirm()
|
||||
return
|
||||
|
||||
@ -9,10 +9,12 @@ import androidx.fragment.app.FragmentActivity
|
||||
import com.gh.common.iinterface.ISuperiorChain
|
||||
import com.gh.common.util.CheckLoginUtils
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.gamecenter.SplashAdActivity
|
||||
import com.gh.gamecenter.SplashScreenActivity
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.entity.SimpleGameEntity
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.entity.DialogEntity
|
||||
import com.gh.gamecenter.feature.entity.WelcomeDialogEntity
|
||||
@ -42,12 +44,13 @@ object GlobalPriorityChainHelper : ISuperiorChain {
|
||||
return activity is FragmentActivity
|
||||
&& !activity.isFinishing
|
||||
&& activity !is SplashScreenActivity
|
||||
&& activity !is SplashAdActivity
|
||||
}
|
||||
|
||||
/**
|
||||
* 预启动所有的优先级弹窗管理链
|
||||
*/
|
||||
fun preStart() {
|
||||
fun preStart(withSpecialDelay: Boolean) {
|
||||
val launchRedirectHandler = LaunchRedirectHandler(-101)
|
||||
val updateDialogHandler = UpdateDialogHandler(-100)
|
||||
val privacyPolicyDialogHandler = PrivacyPolicyDialogHandler(-99)
|
||||
@ -64,8 +67,13 @@ object GlobalPriorityChainHelper : ISuperiorChain {
|
||||
|
||||
launchRedirectHandler.doPreProcess()
|
||||
updateDialogHandler.doPreProcess()
|
||||
requestOpeningDialogData(welcomeDialogHandler, privacyPolicyDialogHandler)
|
||||
requestReserveDialogData(reserveDialogHandler)
|
||||
|
||||
// 首次启动延迟 300ms,保证请求首次启动时已经获取到了 GID 、 OAID 等标记
|
||||
val requestDelay = if (withSpecialDelay) 300L else 0L
|
||||
AppExecutor.uiExecutor.executeWithDelay({
|
||||
requestOpeningDialogData(welcomeDialogHandler, privacyPolicyDialogHandler)
|
||||
requestReserveDialogData(reserveDialogHandler)
|
||||
}, requestDelay)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,6 +131,17 @@ object GlobalPriorityChainHelper : ISuperiorChain {
|
||||
mainChain.resume()
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加新的 handler 到优先级弹窗管理链 (插队!)
|
||||
*/
|
||||
fun queueNewHandler(handler: PriorityChainHandler) {
|
||||
if (mainChain.isHandlerQueueEmpty()) {
|
||||
observeLifecycle()
|
||||
}
|
||||
|
||||
mainChain.addHandler(handler)
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求首页启动弹窗相关的数据并执行相关 handler 的 preProcess
|
||||
*/
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
package com.gh.common.prioritychain
|
||||
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import com.gh.common.util.PackageHelper
|
||||
import com.gh.gamecenter.common.base.GlobalActivityManager
|
||||
|
||||
class RequestInstalledListPermissionHandler : PriorityChainHandler(-1000) {
|
||||
|
||||
init {
|
||||
updateStatus(STATUS_VALID)
|
||||
}
|
||||
|
||||
override fun onProcess(): Boolean {
|
||||
val currentActivity = GlobalActivityManager.currentActivity ?: return false
|
||||
|
||||
if (currentActivity !is FragmentActivity) return false
|
||||
|
||||
PackageHelper.showGetInstallAppsListDialogAndRequestPermissionIfNeeded(
|
||||
activity = currentActivity,
|
||||
ignorePermanentlyDenied = true
|
||||
) {
|
||||
processNext()
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
@ -8,6 +8,7 @@ import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.core.provider.IAppProvider
|
||||
import com.gh.gamecenter.core.provider.IFlavorProvider
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.va.host.HostUtils
|
||||
|
||||
@Route(path = RouteConsts.provider.app, name = "Application暴露服务")
|
||||
class AppProviderImpl : IAppProvider {
|
||||
@ -86,4 +87,6 @@ class AppProviderImpl : IAppProvider {
|
||||
override fun setSkippingThirdParty(isSkippingThirdParty: Boolean) {
|
||||
HaloApp.getInstance().isSkippingThirdParty = isSkippingThirdParty
|
||||
}
|
||||
|
||||
override fun getPluginVersion(): String = HostUtils.getPluginVersion()
|
||||
}
|
||||
@ -22,34 +22,6 @@ class DirectProviderImpl : IDirectProvider {
|
||||
DirectUtils.directToQqConversation(context, qq)
|
||||
}
|
||||
|
||||
override fun directToCommodityDetail(context: Context, commodityId: String) {
|
||||
DirectUtils.directToCommodityDetail(context, commodityId)
|
||||
}
|
||||
|
||||
override fun directToEnergyRecord(context: Context) {
|
||||
DirectUtils.directToEnergyRecord(context)
|
||||
}
|
||||
|
||||
override fun directToEnergyRulePage(context: Context) {
|
||||
DirectUtils.directToEnergyRulePage(context)
|
||||
}
|
||||
|
||||
override fun directToInviteFriends(context: Context) {
|
||||
DirectUtils.directToInviteFriends(context)
|
||||
}
|
||||
|
||||
override fun directToExchangeRulePage(context: Context) {
|
||||
DirectUtils.directToExchangeRulePage(context)
|
||||
}
|
||||
|
||||
override fun directToExchangeCommodityPage(context: Context) {
|
||||
DirectUtils.directToExchangeCommodityPage(context)
|
||||
}
|
||||
|
||||
override fun directToLotteryParadisePage(context: Context) {
|
||||
DirectUtils.directToLotteryParadisePage(context)
|
||||
}
|
||||
|
||||
override fun directDouyin(context: Context, userId: String) {
|
||||
DirectUtils.directDouyin(context, userId)
|
||||
}
|
||||
@ -97,26 +69,6 @@ class DirectProviderImpl : IDirectProvider {
|
||||
DirectUtils.directToAmway(context, fixedTopAmwayCommentId, entrance, path)
|
||||
}
|
||||
|
||||
override fun directToOrderCenter(context: Context) {
|
||||
DirectUtils.directToOrderCenter(context)
|
||||
}
|
||||
|
||||
override fun directToOrderDetail(context: Context, orderId: String) {
|
||||
DirectUtils.directToOrderDetail(context, orderId)
|
||||
}
|
||||
|
||||
override fun directToEnergyRecord(context: Context, position: Int) {
|
||||
DirectUtils.directToEnergyRecord(context, position)
|
||||
}
|
||||
|
||||
override fun directToMyPrizePage(context: Context) {
|
||||
DirectUtils.directToMyPrizePage(context)
|
||||
}
|
||||
|
||||
override fun directToWinOrderDetail(context: Context, orderId: String, activityId: String) {
|
||||
DirectUtils.directToWinOrderDetail(context, orderId, activityId)
|
||||
}
|
||||
|
||||
override fun directToQGame(context: Context) {
|
||||
return DirectUtils.directToQGameHome(context)
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.gh.common.provider
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageInfo
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.common.util.PackageHelper
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.core.provider.IPackageUtilsProvider
|
||||
@ -23,7 +24,7 @@ class PackageUtilsProviderImpl : IPackageUtilsProvider {
|
||||
}
|
||||
|
||||
override fun getInstalledPackages(context: Context, flag: Int): List<PackageInfo> {
|
||||
return PackageUtils.getInstalledPackages(context, flag)
|
||||
return PackageHelper.getInstalledPackages(context, flag)
|
||||
}
|
||||
|
||||
override fun getApkSignatureByPackageName(context: Context, packageName: String): Array<String> {
|
||||
@ -38,6 +39,10 @@ class PackageUtilsProviderImpl : IPackageUtilsProvider {
|
||||
return PackageUtils.isSignedByGh(context, packageName)
|
||||
}
|
||||
|
||||
override fun isInstalledWithLauncherIcon(context: Context, packageName: String): Boolean {
|
||||
return PackageUtils.isInstalled(context, packageName)
|
||||
}
|
||||
|
||||
override fun getInstalledTime(context: Context, packageName: String): Long {
|
||||
return PackageUtils.getInstalledTime(context, packageName)
|
||||
}
|
||||
|
||||
@ -166,162 +166,160 @@ class SimulatorDownloadManager private constructor() {
|
||||
this.gameName = gameName
|
||||
this.gameType = gameCategoryChinese
|
||||
|
||||
PermissionHelper.checkGetInstalledAppsListBeforeAction(context, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
val isInstalledNewSimulator =
|
||||
SimulatorGameManager.isNewSimulatorInstalled(HaloApp.getInstance().application)
|
||||
//当没有安装新版本模拟器时候 判断是否隐藏
|
||||
if (simulator?.active == false && !isInstalledNewSimulator) {
|
||||
showNoneEmulatorDialog(context)
|
||||
return
|
||||
}
|
||||
var isInstalled = PackageUtils.isInstalledFromAllPackage(
|
||||
context,
|
||||
simulator?.apk?.packageName
|
||||
)
|
||||
//模拟器管理界面还是用之前的逻辑
|
||||
if (isInstalledNewSimulator && location != SimulatorLocation.SIMULATOR_MANAGE) {
|
||||
isInstalled = isInstalledNewSimulator
|
||||
}
|
||||
// val versionFromInstalledApp = PackageUtils.getVersionNameByPackageName(simulator?.apk?.packageName)
|
||||
val shouldShowUpdate =
|
||||
PackageUtils.isInstalledApkMatchedMd5(simulator?.apk?.packageName, simulator?.apk?.md5)
|
||||
val showAlertTag = SPUtils.getString(SimulatorGameManager.SIMULATOR_UPDATE_SHOW_ALERT_TAG, "") //当天是否弹过
|
||||
val todayIsShow = showAlertTag == TimeUtils.getToday()
|
||||
downloadType = if (shouldShowUpdate && isInstalled) "update" else "download"
|
||||
if (downloadType == "update" && todayIsShow && location != SimulatorLocation.SIMULATOR_MANAGE) {
|
||||
return
|
||||
}
|
||||
if (downloadType == "download" && isInstalled) {
|
||||
return
|
||||
}
|
||||
val title = if (shouldShowUpdate && isInstalled) "更新模拟器" else "安装模拟器"
|
||||
val message =
|
||||
if (shouldShowUpdate && isInstalled) "检测到模拟器存在更高版本,是否前往更新" else "模拟器游戏需要先下载安装对应的模拟器,才可以运行"
|
||||
val positiveText =
|
||||
if (shouldShowUpdate && isInstalled) "更新(${simulator?.apk?.size})" else "下载(${simulator?.apk?.size})"
|
||||
val negativeText = if (shouldShowUpdate && isInstalled) "下次再说" else "取消"
|
||||
val trackableEntity = TrackableEntity(
|
||||
"模拟器下载",
|
||||
key = if (shouldShowUpdate && isInstalled) "更新弹窗" else "下载弹窗",
|
||||
logShowEvent = true
|
||||
)
|
||||
if (shouldShowUpdate && isInstalled) {
|
||||
NewFlatLogUtils.logSimulatorUpdateAlertShow()
|
||||
}
|
||||
if (shouldShowUpdate && isInstalled) {
|
||||
SensorsBridge.trackSimulatorUpdateDialogShow(
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
} else {
|
||||
SensorsBridge.trackSimulatorInstallDialogShow(
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
}
|
||||
DialogHelper.showDialog(
|
||||
context,
|
||||
title,
|
||||
message,
|
||||
positiveText,
|
||||
negativeText,
|
||||
trackMtaEvent = true,
|
||||
cancelClickCallback = {
|
||||
if (shouldShowUpdate && isInstalled) {
|
||||
cancelCallback?.invoke()
|
||||
NewFlatLogUtils.logSimulatorUpdateAlertClick("取消")
|
||||
MtaHelper.onEvent(trackableEntity.event, trackableEntity.key, "点击下次再说")
|
||||
SensorsBridge.trackSimulatorUpdateDialogClick(
|
||||
buttonName = negativeText,
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
} else {
|
||||
SensorsBridge.trackSimulatorInstallDialogClick(
|
||||
buttonName = negativeText,
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
}
|
||||
},
|
||||
confirmClickCallback = {
|
||||
showDownloadingDialog(context, simulator, gameId, gameName, gameCategoryChinese)
|
||||
NewFlatLogUtils.logSimulatorUpdateAlertClick("更新")
|
||||
MtaHelper.onEvent(
|
||||
trackableEntity.event,
|
||||
trackableEntity.key,
|
||||
if (shouldShowUpdate && isInstalled) "点击更新" else "点击下载"
|
||||
)
|
||||
if (shouldShowUpdate && isInstalled) {
|
||||
SensorsBridge.trackSimulatorUpdateDialogClick(
|
||||
buttonName = positiveText,
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
} else {
|
||||
SensorsBridge.trackSimulatorInstallDialogClick(
|
||||
buttonName = positiveText,
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
}
|
||||
},
|
||||
touchOutsideCallback = {
|
||||
if (shouldShowUpdate && isInstalled) {
|
||||
SensorsBridge.trackSimulatorUpdateDialogClick(
|
||||
buttonName = "关闭弹窗",
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
} else {
|
||||
SensorsBridge.trackSimulatorInstallDialogClick(
|
||||
buttonName = "关闭弹窗",
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
}
|
||||
},
|
||||
mtaEvent = trackableEntity.event, mtaKey = trackableEntity.key,
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
|
||||
)
|
||||
if (downloadType == "update" && location != SimulatorLocation.SIMULATOR_MANAGE) {
|
||||
SPUtils.setString(SimulatorGameManager.SIMULATOR_UPDATE_SHOW_ALERT_TAG, TimeUtils.getToday())
|
||||
}
|
||||
PermissionHelper.checkGetInstalledAppsListBeforeAction(context) { _ ->
|
||||
val isInstalledNewSimulator =
|
||||
SimulatorGameManager.isNewSimulatorInstalled(HaloApp.getInstance().application)
|
||||
//当没有安装新版本模拟器时候 判断是否隐藏
|
||||
if (simulator?.active == false && !isInstalledNewSimulator) {
|
||||
showNoneEmulatorDialog(context)
|
||||
return@checkGetInstalledAppsListBeforeAction
|
||||
}
|
||||
})
|
||||
var isInstalled = PackageUtils.isInstalledFromAllPackage(
|
||||
context,
|
||||
simulator?.apk?.packageName
|
||||
)
|
||||
//模拟器管理界面还是用之前的逻辑
|
||||
if (isInstalledNewSimulator && location != SimulatorLocation.SIMULATOR_MANAGE) {
|
||||
isInstalled = isInstalledNewSimulator
|
||||
}
|
||||
// val versionFromInstalledApp = PackageUtils.getVersionNameByPackageName(simulator?.apk?.packageName)
|
||||
val shouldShowUpdate =
|
||||
PackageUtils.isInstalledApkMatchedMd5(simulator?.apk?.packageName, simulator?.apk?.md5)
|
||||
val showAlertTag = SPUtils.getString(SimulatorGameManager.SIMULATOR_UPDATE_SHOW_ALERT_TAG, "") //当天是否弹过
|
||||
val todayIsShow = showAlertTag == TimeUtils.getToday()
|
||||
downloadType = if (shouldShowUpdate && isInstalled) "update" else "download"
|
||||
if (downloadType == "update" && todayIsShow && location != SimulatorLocation.SIMULATOR_MANAGE) {
|
||||
return@checkGetInstalledAppsListBeforeAction
|
||||
}
|
||||
if (downloadType == "download" && isInstalled) {
|
||||
return@checkGetInstalledAppsListBeforeAction
|
||||
}
|
||||
val title = if (shouldShowUpdate && isInstalled) "更新模拟器" else "安装模拟器"
|
||||
val message =
|
||||
if (shouldShowUpdate && isInstalled) "检测到模拟器存在更高版本,是否前往更新" else "模拟器游戏需要先下载安装对应的模拟器,才可以运行"
|
||||
val positiveText =
|
||||
if (shouldShowUpdate && isInstalled) "更新(${simulator?.apk?.size})" else "下载(${simulator?.apk?.size})"
|
||||
val negativeText = if (shouldShowUpdate && isInstalled) "下次再说" else "取消"
|
||||
val trackableEntity = TrackableEntity(
|
||||
"模拟器下载",
|
||||
key = if (shouldShowUpdate && isInstalled) "更新弹窗" else "下载弹窗",
|
||||
logShowEvent = true
|
||||
)
|
||||
if (shouldShowUpdate && isInstalled) {
|
||||
NewFlatLogUtils.logSimulatorUpdateAlertShow()
|
||||
}
|
||||
if (shouldShowUpdate && isInstalled) {
|
||||
SensorsBridge.trackSimulatorUpdateDialogShow(
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
} else {
|
||||
SensorsBridge.trackSimulatorInstallDialogShow(
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
}
|
||||
DialogHelper.showDialog(
|
||||
context,
|
||||
title,
|
||||
message,
|
||||
positiveText,
|
||||
negativeText,
|
||||
trackMtaEvent = true,
|
||||
cancelClickCallback = {
|
||||
if (shouldShowUpdate && isInstalled) {
|
||||
cancelCallback?.invoke()
|
||||
NewFlatLogUtils.logSimulatorUpdateAlertClick("取消")
|
||||
MtaHelper.onEvent(trackableEntity.event, trackableEntity.key, "点击下次再说")
|
||||
SensorsBridge.trackSimulatorUpdateDialogClick(
|
||||
buttonName = negativeText,
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
} else {
|
||||
SensorsBridge.trackSimulatorInstallDialogClick(
|
||||
buttonName = negativeText,
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
}
|
||||
},
|
||||
confirmClickCallback = {
|
||||
showDownloadingDialog(context, simulator, gameId, gameName, gameCategoryChinese)
|
||||
NewFlatLogUtils.logSimulatorUpdateAlertClick("更新")
|
||||
MtaHelper.onEvent(
|
||||
trackableEntity.event,
|
||||
trackableEntity.key,
|
||||
if (shouldShowUpdate && isInstalled) "点击更新" else "点击下载"
|
||||
)
|
||||
if (shouldShowUpdate && isInstalled) {
|
||||
SensorsBridge.trackSimulatorUpdateDialogClick(
|
||||
buttonName = positiveText,
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
} else {
|
||||
SensorsBridge.trackSimulatorInstallDialogClick(
|
||||
buttonName = positiveText,
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
}
|
||||
},
|
||||
touchOutsideCallback = {
|
||||
if (shouldShowUpdate && isInstalled) {
|
||||
SensorsBridge.trackSimulatorUpdateDialogClick(
|
||||
buttonName = "关闭弹窗",
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
} else {
|
||||
SensorsBridge.trackSimulatorInstallDialogClick(
|
||||
buttonName = "关闭弹窗",
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
}
|
||||
},
|
||||
mtaEvent = trackableEntity.event, mtaKey = trackableEntity.key,
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
|
||||
)
|
||||
if (downloadType == "update" && location != SimulatorLocation.SIMULATOR_MANAGE) {
|
||||
SPUtils.setString(SimulatorGameManager.SIMULATOR_UPDATE_SHOW_ALERT_TAG, TimeUtils.getToday())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun showDownloadingDialog(
|
||||
|
||||
@ -50,8 +50,6 @@ object ArchiveDownloadButtonHelper {
|
||||
}
|
||||
downloadBtn.setOnClickListener {
|
||||
when {
|
||||
// 检查是否已安装畅玩助手
|
||||
!VHelper.isVSpaceInstalled(context) -> showVSpaceTipDialog(context, gameEntity)
|
||||
// 检查是否已安装游戏
|
||||
!VHelper.isInstalled(packageName) -> {
|
||||
// 检查游戏是否在安装中
|
||||
|
||||
@ -1,17 +1,11 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts;
|
||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.login.utils.QuickLoginHelper;
|
||||
import com.gh.gamecenter.login.view.LoginActivity;
|
||||
import com.gh.gamecenter.common.utils.NetworkUtils;
|
||||
import com.gh.gamecenter.core.utils.SPUtils;
|
||||
import com.gh.gamecenter.login.user.UserManager;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
@ -28,15 +22,15 @@ public class CheckLoginUtils {
|
||||
LogUtils.login("dialog", null, entrance);
|
||||
LogUtils.login("activity", null, entrance);
|
||||
|
||||
if (SPUtils.getBoolean(Constants.SP_HAS_GET_PHONE_INFO) || NetworkUtils.isOpenMobileData(context)) {
|
||||
startQuickLogin(context, entrance);
|
||||
} else {
|
||||
// 有可能App未启动
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(EntranceConsts.KEY_ENTRANCE, entrance);
|
||||
bundle.putString(EntranceConsts.KEY_TO, LoginActivity.class.getName());
|
||||
EntranceUtils.jumpActivity(context, bundle);
|
||||
}
|
||||
// if (SPUtils.getBoolean(Constants.SP_HAS_GET_PHONE_INFO) || NetworkUtils.isOpenMobileData(context)) {
|
||||
// startQuickLogin(context, entrance);
|
||||
// } else {
|
||||
// 有可能App未启动
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(EntranceConsts.KEY_ENTRANCE, entrance);
|
||||
bundle.putString(EntranceConsts.KEY_TO, LoginActivity.class.getName());
|
||||
EntranceUtils.jumpActivity(context, bundle);
|
||||
// }
|
||||
} else {
|
||||
if (listener != null) {
|
||||
listener.onLogin();
|
||||
@ -44,16 +38,16 @@ public class CheckLoginUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private static void startQuickLogin(Context context, String entrance) {
|
||||
// 需要确保传入的 context 不为 application
|
||||
if (!(context instanceof Activity)) {
|
||||
context = CurrentActivityHolder.getCurrentActivity();
|
||||
}
|
||||
|
||||
if (context != null) {
|
||||
QuickLoginHelper.startLogin(context, entrance);
|
||||
}
|
||||
}
|
||||
// private static void startQuickLogin(Context context, String entrance) {
|
||||
// // 需要确保传入的 context 不为 application
|
||||
// if (!(context instanceof Activity)) {
|
||||
// context = CurrentActivityHolder.getCurrentActivity();
|
||||
// }
|
||||
//
|
||||
// if (context != null) {
|
||||
// QuickLoginHelper.startLogin(context, entrance);
|
||||
// }
|
||||
// }
|
||||
|
||||
public static void checkLogin(final Context context, Bundle nextToBundle, boolean isTriggerNextStep, String entrance, OnLoginListener listener) {
|
||||
if (!isLogin()) {
|
||||
|
||||
@ -14,12 +14,10 @@ import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.common.base.GlobalActivityManager;
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil;
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.core.AppExecutor;
|
||||
import com.gh.gamecenter.core.utils.GsonUtils;
|
||||
import com.gh.gamecenter.core.utils.MtaHelper;
|
||||
import com.gh.gamecenter.core.utils.SPUtils;
|
||||
import com.gh.gamecenter.core.utils.SentryHelper;
|
||||
import com.gh.gamecenter.login.entity.IdCardEntity;
|
||||
@ -32,8 +30,6 @@ import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.config.CommonDebug;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import io.sentry.Sentry;
|
||||
import io.sentry.android.core.SentryAndroid;
|
||||
@ -108,45 +104,51 @@ public class DataUtils {
|
||||
}
|
||||
|
||||
public static void getGid() {
|
||||
GidHelper.getInstance().registerDevice(HaloApp.getInstance().getApplication(), new GidCallback() {
|
||||
@Override
|
||||
public void onSuccess(String gid) {
|
||||
Utils.log("Gid", gid);
|
||||
PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().getApplication()).edit().putString(Constants.DEVICE_KEY, gid).apply();
|
||||
// 默认用 APP 级已存储的 GID 来使用,不使用外部 GID
|
||||
String savedGid = SPUtils.getString(Constants.GID);
|
||||
if (!TextUtils.isEmpty(savedGid)) {
|
||||
HaloApp.getInstance().setGid(savedGid);
|
||||
onGidReceived(savedGid);
|
||||
} else {
|
||||
GidHelper.getInstance().registerDevice(HaloApp.getInstance().getApplication(), new GidCallback() {
|
||||
@Override
|
||||
public void onSuccess(String gid) {
|
||||
Utils.log("Gid", gid);
|
||||
PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().getApplication()).edit().putString(Constants.DEVICE_KEY, gid).apply();
|
||||
|
||||
// 默认用 APP 级已存储的 GID 来使用,不使用外部 GID
|
||||
String savedGid = SPUtils.getString(Constants.GID);
|
||||
if (!TextUtils.isEmpty(savedGid)) {
|
||||
gid = savedGid;
|
||||
} else {
|
||||
SPUtils.setString(Constants.GID, gid);
|
||||
|
||||
onGidReceived(gid);
|
||||
}
|
||||
|
||||
HaloApp.getInstance().setGid(gid);
|
||||
|
||||
// 更新广告配置
|
||||
AdDelegateHelper.INSTANCE.requestAdConfig(false, "", null);
|
||||
|
||||
getDeviceCertification(gid);
|
||||
|
||||
// 避免初始化顺序问题导致 MetaUtil 一直持有空的 gid
|
||||
MetaUtil.INSTANCE.refreshMeta();
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(GhContentProvider.KEY_GID, gid);
|
||||
values.put(GhContentProvider.KEY_ANDROID_ID, MetaUtil.getBase64EncodedAndroidId());
|
||||
try {
|
||||
HaloApp.getInstance().getContentResolver().insert(Uri.parse("content://com.gh.gamecenter.provider/device"), values);
|
||||
} catch (Exception exception) {
|
||||
SentryHelper.INSTANCE.onEvent("DEVICE_INSERT_ERROR", "exception_digest", exception.getLocalizedMessage());
|
||||
exception.printStackTrace();
|
||||
@Override
|
||||
public void onFailure(String s) {
|
||||
// 更新广告配置
|
||||
AdDelegateHelper.INSTANCE.requestAdConfig(false, "", null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(String s) {
|
||||
// 更新广告配置
|
||||
AdDelegateHelper.INSTANCE.requestAdConfig(false, "", null);
|
||||
private static void onGidReceived(String gid) {
|
||||
HaloApp.getInstance().setGid(gid);
|
||||
// 更新广告配置
|
||||
AdDelegateHelper.INSTANCE.requestAdConfig(false, "", null);
|
||||
|
||||
getDeviceCertification(gid);
|
||||
|
||||
// 避免初始化顺序问题导致 MetaUtil 一直持有空的 gid
|
||||
MetaUtil.INSTANCE.refreshMeta();
|
||||
|
||||
AppExecutor.getIoExecutor().execute(() -> {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(GhContentProvider.KEY_GID, gid);
|
||||
values.put(GhContentProvider.KEY_ANDROID_ID, MetaUtil.getBase64EncodedAndroidId());
|
||||
try {
|
||||
HaloApp.getInstance().getContentResolver().insert(Uri.parse("content://com.gh.gamecenter.provider/device"), values);
|
||||
} catch (Exception exception) {
|
||||
SentryHelper.INSTANCE.onEvent("DEVICE_INSERT_ERROR", "exception_digest", exception.getLocalizedMessage());
|
||||
exception.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1625,211 +1625,6 @@ object DirectUtils {
|
||||
jumpActivityCompat(context, newBundle)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至商品详情
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToCommodityDetail(context: Context, commodityId: String) {
|
||||
var url: String = if (EnvHelper.isDevEnv) {
|
||||
Constants.COMMODITY_DETAIL_ADDRESS_DEV
|
||||
} else {
|
||||
Constants.COMMODITY_DETAIL_ADDRESS
|
||||
}
|
||||
|
||||
url = String.format(
|
||||
Locale.CHINA,
|
||||
"%s&shopid=%s×tamp=%d",
|
||||
url,
|
||||
commodityId,
|
||||
(Date().time / 1000 / 1000.toFloat()).roundToInt()
|
||||
)
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至光能记录(默认跳到光能记录第一个Tab)
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToEnergyRecord(context: Context) {
|
||||
directToEnergyRecord(context, 0)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToEnergyRecord(context: Context, position: Int) {
|
||||
var url: String = if (EnvHelper.isDevEnv) {
|
||||
Constants.ENERGY_RECORD_ADDRESS_DEV
|
||||
} else {
|
||||
Constants.ENERGY_RECORD_ADDRESS
|
||||
}
|
||||
|
||||
url = String.format(
|
||||
Locale.CHINA,
|
||||
"%s&position=%s×tamp=%d",
|
||||
url,
|
||||
position,
|
||||
(Date().time / 1000 / 1000.toFloat()).roundToInt()
|
||||
)
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至订单中心
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToOrderCenter(context: Context) {
|
||||
val url: String = if (EnvHelper.isDevEnv) {
|
||||
Constants.ORDER_CENTER_ADDRESS_DEV
|
||||
} else {
|
||||
Constants.ORDER_CENTER_ADDRESS
|
||||
}
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至订单详情
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToOrderDetail(context: Context, orderId: String) {
|
||||
var url: String = if (EnvHelper.isDevEnv) {
|
||||
Constants.ORDER_DETAIL_ADDRESS_DEV
|
||||
} else {
|
||||
Constants.ORDER_DETAIL_ADDRESS
|
||||
}
|
||||
|
||||
url = String.format(
|
||||
Locale.CHINA,
|
||||
"%s&order_id=%s×tamp=%d",
|
||||
url,
|
||||
orderId,
|
||||
(Date().time / 1000 / 1000.toFloat()).roundToInt()
|
||||
)
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至邀请好友
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToInviteFriends(context: Context) {
|
||||
val url: String = if (EnvHelper.isDevEnv) {
|
||||
Constants.INVITE_FRIENDS_ADDRESS_DEV
|
||||
} else {
|
||||
Constants.INVITE_FRIENDS_ADDRESS
|
||||
}
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至等级页面
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToLevelPage(context: Context) {
|
||||
var url: String = if (isPublishEnv()) {
|
||||
Constants.LEVEL_ADDRESS
|
||||
} else {
|
||||
Constants.LEVEL_ADDRESS_DEV
|
||||
}
|
||||
|
||||
url = String.format(Locale.CHINA, "%s?timestamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至兑换规则
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToExchangeRulePage(context: Context) {
|
||||
var url: String = if (isPublishEnv()) {
|
||||
Constants.EXCHANGE_RULE_ADDRESS
|
||||
} else {
|
||||
Constants.EXCHANGE_RULE_ADDRESS_DEV
|
||||
}
|
||||
|
||||
url = String.format(Locale.CHINA, "%s×tamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至光能规则
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToEnergyRulePage(context: Context) {
|
||||
var url: String = if (isPublishEnv()) {
|
||||
Constants.ENERGY_RULE_ADDRESS
|
||||
} else {
|
||||
Constants.ENERGY_RULE_ADDRESS_DEV
|
||||
}
|
||||
|
||||
url = String.format(Locale.CHINA, "%s×tamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至兑换商品
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToExchangeCommodityPage(context: Context) {
|
||||
var url: String = if (isPublishEnv()) {
|
||||
Constants.EXCHANGE_COMMODITY_ADDRESS
|
||||
} else {
|
||||
Constants.EXCHANGE_COMMODITY_ADDRESS_DEV
|
||||
}
|
||||
|
||||
url = String.format(Locale.CHINA, "%s×tamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至抽奖乐园
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToLotteryParadisePage(context: Context) {
|
||||
var url: String = if (isPublishEnv()) {
|
||||
Constants.LOTTERY_PARADISE_ADDRESS
|
||||
} else {
|
||||
Constants.LOTTERY_PARADISE_ADDRESS_DEV
|
||||
}
|
||||
|
||||
url = String.format(Locale.CHINA, "%s×tamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至我的奖品
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToMyPrizePage(context: Context) {
|
||||
var url: String = if (isPublishEnv()) {
|
||||
Constants.MY_PRIZE_ADDRESS
|
||||
} else {
|
||||
Constants.MY_PRIZE_ADDRESS_DEV
|
||||
}
|
||||
|
||||
url = String.format(Locale.CHINA, "%s×tamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至中奖订单详情
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToWinOrderDetail(context: Context, orderId: String, activityId: String) {
|
||||
var url: String = if (isPublishEnv()) {
|
||||
Constants.WIN_ORDER_DETAIL_ADDRESS
|
||||
} else {
|
||||
Constants.WIN_ORDER_DETAIL_ADDRESS_DEV
|
||||
}
|
||||
|
||||
url = String.format(
|
||||
Locale.CHINA,
|
||||
"%s&order_id=%s&activity_id=%s×tamp=%d",
|
||||
url,
|
||||
orderId,
|
||||
activityId,
|
||||
(Date().time / 1000 / 1000.toFloat()).roundToInt()
|
||||
)
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至地址信息
|
||||
|
||||
@ -508,11 +508,18 @@ object DownloadObserver {
|
||||
"space_schema_type",
|
||||
if (downloadEntity.packageName == VHelper.VSPACE_32BIT_PACKAGENAME) "32位" else "64位"
|
||||
)
|
||||
} else if(downloadEntity.gameId == Constants.HALO_FUN_NEW_32_GAME_ID) {
|
||||
SensorsBridge.trackEvent(
|
||||
"HaloFunDownloadDone",
|
||||
"space_schema_type",
|
||||
"32位(新)"
|
||||
)
|
||||
}
|
||||
|
||||
if (downloadEntity.gameId != Constants.GHZS_GAME_ID
|
||||
&& downloadEntity.getMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE) != Constants.SIMULATOR_DOWNLOAD
|
||||
&& downloadEntity.gameId != Constants.HALO_FUN_GAME_ID
|
||||
&& downloadEntity.gameId != Constants.HALO_FUN_NEW_32_GAME_ID
|
||||
) {
|
||||
val trackJson = downloadEntity.customPageTrackDataJson
|
||||
val kvs = if (!trackJson.isNullOrBlank()) {
|
||||
|
||||
@ -282,7 +282,7 @@ object GameActivityDownloadHelper {
|
||||
location: String,
|
||||
traceEvent: ExposureEvent
|
||||
) {
|
||||
VHelper.validateVSpaceBeforeAction(context, gameEntity) {
|
||||
VHelper.validateVSpaceBeforeAction(context,gameEntity.getUniquePackageName(), gameEntity) {
|
||||
GamePermissionDialogFragment.show((context as AppCompatActivity), gameEntity, gameEntity.info) {
|
||||
DialogUtils.checkDownload(
|
||||
context,
|
||||
|
||||
@ -35,8 +35,6 @@ object HomeBottomBarHelper {
|
||||
text = "游戏库",
|
||||
name = "游戏库",
|
||||
position = 2,
|
||||
iconSelect = "https://resource.ghzs.com/image/game/library/entrance/5e183202913fbd002c75f247.png",
|
||||
iconUnselect = "https://resource.ghzs.com/image/game/library/entrance/5e1831fd913fbd003024641e.png",
|
||||
animationCode = animationCode,
|
||||
default = false,
|
||||
display = Display()
|
||||
|
||||
@ -50,7 +50,7 @@ public class InstallUtils {
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg.what == INSTALL_WHAT && packageManager != null) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
List<PackageInfo> packageInfos = PackageUtils.getInstalledPackages(context, 0);
|
||||
List<PackageInfo> packageInfos = PackageHelper.INSTANCE.getInstalledPackages(context, 0);
|
||||
for (PackageInfo packageInfo : packageInfos) {
|
||||
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
list.add(packageInfo.packageName);
|
||||
|
||||
@ -768,7 +768,7 @@ public class LibaoUtils {
|
||||
}
|
||||
|
||||
public static boolean isAppInstalled(Context context, String packageName) {
|
||||
List<PackageInfo> pinfo = PackageUtils.getInstalledPackages(context, 0);
|
||||
List<PackageInfo> pinfo = PackageHelper.INSTANCE.getInstalledPackages(context, 0);
|
||||
if (pinfo != null) {
|
||||
for (int i = 0; i < pinfo.size(); i++) {
|
||||
String pn = pinfo.get(i).packageName;
|
||||
|
||||
@ -93,12 +93,13 @@ object NewFlatLogUtils {
|
||||
|
||||
// 畅玩助手更新弹窗展示事件
|
||||
@JvmStatic
|
||||
fun logHaloFunUpdateDialogShow(gameId: String, gameName: String, gameArchitecture: String) {
|
||||
fun logHaloFunUpdateDialogShow(gameId: String, gameName: String, gameArchitecture: String, targetVaVersion: String) {
|
||||
val json = json {
|
||||
KEY_EVENT to "halo_fun_update_dialog_show"
|
||||
"game_id" to gameId
|
||||
"game_name" to gameName
|
||||
"game_architecture" to gameArchitecture
|
||||
"target_va_version" to targetVaVersion
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json)
|
||||
@ -142,12 +143,13 @@ object NewFlatLogUtils {
|
||||
|
||||
// 畅玩助手更新弹窗点击事件
|
||||
@JvmStatic
|
||||
fun logHaloFunUpdateDialogClick(dialogType: String, buttonType: String, architecture: String) {
|
||||
fun logHaloFunUpdateDialogClick(dialogType: String, buttonType: String, architecture: String, targetVaVersion: String) {
|
||||
val json = json {
|
||||
KEY_EVENT to "halo_fun_update_dialog_click"
|
||||
"dialog_type" to dialogType
|
||||
KEY_BUTTON_TYPE to buttonType
|
||||
"architecture" to architecture
|
||||
"target_va_version" to targetVaVersion
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json)
|
||||
|
||||
161
app/src/main/java/com/gh/common/util/PackageChangeHelper.kt
Normal file
161
app/src/main/java/com/gh/common/util/PackageChangeHelper.kt
Normal file
@ -0,0 +1,161 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import androidx.lifecycle.DefaultLifecycleObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.download.PackageObserver
|
||||
import com.gh.gamecenter.common.utils.NewFlatLogUtils
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge
|
||||
import com.gh.gamecenter.eventbus.EBPackage
|
||||
import com.gh.gamecenter.manager.PackagesManager
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository
|
||||
import com.lightgame.utils.Utils
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
object PackageChangeHelper : DefaultLifecycleObserver {
|
||||
|
||||
private const val TAG = "PackageChangeHelper"
|
||||
|
||||
private const val INSTALL_PENDING = 1
|
||||
private const val UNINSTALL_PENDING = 2
|
||||
private const val UPDATE_PENDING = 3
|
||||
|
||||
// <包名,pending 类型,应用版本> Triple
|
||||
private var pendingPackagePair: Triple<String, Int, String>? = null
|
||||
private var pendingGhId: String ? = null
|
||||
|
||||
/**
|
||||
* 添加一个等待中,待确定是否已成功安装的应用
|
||||
*/
|
||||
fun addInstallPendingPackage(packageName: String) {
|
||||
val installData = PackagesManager.getInstalledData(packageName)
|
||||
|
||||
if (installData == null) {
|
||||
Utils.log(TAG, "添加了: $packageName 包名等待安装成功")
|
||||
pendingPackagePair = Triple(packageName, INSTALL_PENDING, "")
|
||||
} else {
|
||||
Utils.log(TAG, "添加了: $packageName 包名等待安装更新成功")
|
||||
|
||||
val ghId = PackageUtils.getGhId(packageName)
|
||||
|
||||
// 记录光环插件相关信息,用于安装成功后的处理
|
||||
if (ghId != null) {
|
||||
pendingGhId = ghId.toString()
|
||||
}
|
||||
|
||||
pendingPackagePair = Triple(packageName, UPDATE_PENDING, installData.version)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加一个等待中,待确定是否已成功卸载的应用
|
||||
*/
|
||||
fun addUninstallPendingPackage(packageName: String) {
|
||||
Utils.log(TAG, "添加了: $packageName 包名等待卸载成功")
|
||||
pendingPackagePair = Triple(packageName, UNINSTALL_PENDING, "")
|
||||
}
|
||||
|
||||
override fun onResume(owner: LifecycleOwner) {
|
||||
super.onResume(owner)
|
||||
|
||||
if (pendingPackagePair != null) {
|
||||
val packageName = pendingPackagePair?.first ?: return
|
||||
val isInstallPending = pendingPackagePair?.second == INSTALL_PENDING
|
||||
val isUninstallPending = pendingPackagePair?.second == UNINSTALL_PENDING
|
||||
val isUpdatePending = pendingPackagePair?.second == UPDATE_PENDING
|
||||
|
||||
val pendingVersion = pendingPackagePair?.third ?: ""
|
||||
|
||||
val installedVersionName = PackageUtils.getVersionNameByPackageName(packageName)
|
||||
val isInstalled = installedVersionName != null
|
||||
|
||||
if (isInstallPending && isInstalled) {
|
||||
pendingPackagePair = null
|
||||
pendingGhId = null
|
||||
|
||||
PackageRepository.addInstalledGame(packageName)
|
||||
|
||||
performInstallSuccessAction(packageName)
|
||||
} else if (isUninstallPending && !isInstalled) {
|
||||
pendingPackagePair = null
|
||||
pendingGhId = null
|
||||
|
||||
performUninstallSuccessAction(packageName)
|
||||
} else if (isUpdatePending) {
|
||||
val isUpdateValid = if (installedVersionName != pendingVersion) {
|
||||
true
|
||||
} else {
|
||||
!pendingGhId.isNullOrEmpty() && pendingGhId != PackageUtils.getGhId(packageName).toString()
|
||||
}
|
||||
|
||||
pendingPackagePair = null
|
||||
pendingGhId = null
|
||||
|
||||
if (isUpdateValid) {
|
||||
performUninstallSuccessAction(packageName)
|
||||
performInstallSuccessAction(packageName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun addInstall(packageName: String) {
|
||||
performInstallSuccessAction(packageName)
|
||||
}
|
||||
|
||||
fun addUpdate(packageName: String) {
|
||||
performUninstallSuccessAction(packageName)
|
||||
performInstallSuccessAction(packageName)
|
||||
}
|
||||
|
||||
/**
|
||||
* 对应包名安装成功后的操作,继承至 PackageChangeBroadcastObserver
|
||||
*/
|
||||
private fun performInstallSuccessAction(packageName: String, withLog: Boolean = true) {
|
||||
Utils.log(TAG, "安装了: $packageName 包名的程序")
|
||||
val downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshotByPackageName(packageName)
|
||||
val gameId = if (downloadEntity != null && downloadEntity.gameId != null) downloadEntity.gameId else ""
|
||||
val gameName = if (downloadEntity != null && downloadEntity.name != null) downloadEntity.name else ""
|
||||
|
||||
if (withLog) {
|
||||
NewFlatLogUtils.logGameInstallComplete(gameId, gameName)
|
||||
SensorsBridge.trackInstallGameFinish(gameId, gameName)
|
||||
}
|
||||
|
||||
InstallUtils.getInstance().removeInstall(packageName)
|
||||
PackageHelper.refreshLocalPackageList()
|
||||
|
||||
val versionName = PackageUtils.getVersionNameByPackageName(packageName)
|
||||
val installEb = EBPackage(EBPackage.TYPE_INSTALLED, packageName, versionName)
|
||||
|
||||
PackageObserver.onPackageChanged(installEb)
|
||||
EventBus.getDefault().post(installEb)
|
||||
}
|
||||
|
||||
fun addUninstall(packageName: String) {
|
||||
performUninstallSuccessAction(packageName)
|
||||
}
|
||||
|
||||
/**
|
||||
* 对应包名卸载成功后的操作,继承至 PackageChangeBroadcastObserver
|
||||
*/
|
||||
private fun performUninstallSuccessAction(packageName: String, withLog: Boolean = true) {
|
||||
Utils.log(TAG, "卸载了: $packageName 包名的程序")
|
||||
val install = PackagesManager.getInstalledData(packageName)
|
||||
val gameId = if (install?.id != null) install.id else ""
|
||||
val gameName = if (install?.name != null) install.name else ""
|
||||
|
||||
if (withLog) {
|
||||
NewFlatLogUtils.logGameUninstallComplete(gameId!!, gameName!!)
|
||||
SensorsBridge.trackUnloadGameFinish(gameId, gameName)
|
||||
}
|
||||
|
||||
InstallUtils.getInstance().removeUninstall(packageName)
|
||||
PackageHelper.refreshLocalPackageList()
|
||||
|
||||
val uninstallEb = EBPackage(EBPackage.TYPE_UNINSTALLED, packageName, "")
|
||||
PackageObserver.onPackageChanged(uninstallEb)
|
||||
EventBus.getDefault().post(uninstallEb)
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,24 +1,81 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.pm.ApplicationInfo
|
||||
import android.content.pm.PackageInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.pm.PermissionInfo
|
||||
import android.os.Build
|
||||
import android.provider.Settings
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.prioritychain.GlobalPriorityChainHelper
|
||||
import com.gh.common.prioritychain.RequestInstalledListPermissionHandler
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.common.utils.PermissionHelper
|
||||
import com.gh.gamecenter.common.utils.PermissionHelper.isGetInstalledListPermissionDisabled
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge
|
||||
import com.gh.gamecenter.core.runOnIoThread
|
||||
import com.gh.gamecenter.core.runOnUiThread
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.entity.WhitePackageListEntity
|
||||
import com.gh.gamecenter.feature.entity.SettingsEntity
|
||||
import com.gh.gamecenter.manager.PackagesManager
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.coroutines.*
|
||||
import java.io.BufferedReader
|
||||
import java.io.IOException
|
||||
import java.io.InputStreamReader
|
||||
import kotlin.collections.ArrayList
|
||||
import kotlin.collections.HashSet
|
||||
|
||||
object PackageHelper {
|
||||
|
||||
private const val TAG = "PackageHelper"
|
||||
|
||||
private const val SP_GET_INSTALLED_API_AGREED = "get_installed_api_agreed"
|
||||
|
||||
private const val UNKNOWN = -1
|
||||
private const val UNSUPPORTED = 0
|
||||
private const val SUPPORTED = 1
|
||||
|
||||
private const val ENABLED = 2
|
||||
private const val DISABLED = 3
|
||||
|
||||
private var lastInstalledPackageListTime = 0L
|
||||
private var cachedInstalledPackagesList: List<PackageInfo> = arrayListOf()
|
||||
|
||||
private var isGetInstalledPackagesApiAgreed = true // 用户是否已经同意使用已安装应用列表 API
|
||||
private var isGetInstalledPackagesApiAgreedRequired = DISABLED // 需要用户手动授权才获取已安装应用列表的功能的开关
|
||||
private var isGetInstalledPackagesPermissionSupported = UNKNOWN // 设备是否支持禁用获取已安装应用列表
|
||||
|
||||
// 评论黑名单包名列表,避免用户安装了 Xposed Installer 这样的工具,也能在包含该安装包的游戏详情页评论
|
||||
var commentPackageNameBlackList = arrayListOf<String>()
|
||||
private var _commentPackageNameBlackList = arrayListOf<String>()
|
||||
val commentPackageNameBlackList: ArrayList<String> = _commentPackageNameBlackList
|
||||
|
||||
// 关闭下载的包列表
|
||||
var downloadPackageNameBlackList = arrayListOf<String>()
|
||||
private var _downloadPackageNameBlackList = arrayListOf<String>()
|
||||
val downloadPackageNameBlackList: ArrayList<String> = _downloadPackageNameBlackList
|
||||
|
||||
// 本地已安装的包去掉关闭下载的包后的列表
|
||||
var validLocalPackageNameSet = hashSetOf<String>()
|
||||
private var _validLocalPackageNameSet = hashSetOf<String>()
|
||||
val validLocalPackageNameSet: HashSet<String> = _validLocalPackageNameSet
|
||||
|
||||
// 游戏包名匹配列表
|
||||
var relatedPackageList = arrayListOf<SettingsEntity.GameWithPackages>()
|
||||
private var _relatedPackageList = arrayListOf<SettingsEntity.GameWithPackages>()
|
||||
val relatedPackageList: ArrayList<SettingsEntity.GameWithPackages> = _relatedPackageList
|
||||
|
||||
// 接口控制的已安装应用列表获取开关状态 (UI 显示)
|
||||
private var _installedPackageApiSwitchStatusLiveData = MutableLiveData<Boolean>()
|
||||
val installedPackageApiSwitchStatusLiveData: LiveData<Boolean> = _installedPackageApiSwitchStatusLiveData
|
||||
|
||||
// 本地已安装包的列表
|
||||
var localPackageNameSet = hashSetOf<String>()
|
||||
@ -31,6 +88,22 @@ object PackageHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已安装的白名单列表(为了在没有已安装应用列表获取能力的时候也能正常判断更新、插件化)
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
fun getInstalledWhiteList() {
|
||||
RetrofitManager.getInstance().newApi.installWhitelist
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<WhitePackageListEntity>() {
|
||||
override fun onSuccess(data: WhitePackageListEntity) {
|
||||
data.data?.let {
|
||||
addInstalledButMissingPackages(it)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun refreshLocalPackageList() {
|
||||
localPackageNameSet = getAllPackageName(HaloApp.getInstance().application)
|
||||
@ -38,33 +111,26 @@ object PackageHelper {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun initList() {
|
||||
Config.getSettings()?.gameCommentBlackList?.let {
|
||||
commentPackageNameBlackList = ArrayList(it)
|
||||
}
|
||||
Config.getSettings()?.gameDownloadBlackList?.let {
|
||||
downloadPackageNameBlackList = ArrayList(it)
|
||||
}
|
||||
Config.getSettings()?.gamePackageMatch?.let {
|
||||
relatedPackageList = ArrayList(it)
|
||||
}
|
||||
fun refreshList() {
|
||||
Config.getSettings()?.gameCommentBlackList?.let { _commentPackageNameBlackList = ArrayList(it) }
|
||||
Config.getSettings()?.gameDownloadBlackList?.let { _downloadPackageNameBlackList = ArrayList(it) }
|
||||
Config.getSettings()?.gamePackageMatch?.let { _relatedPackageList = ArrayList(it) }
|
||||
|
||||
Config.getSettings()?.gameDownloadBlackList
|
||||
updateValidPackageNameList()
|
||||
}
|
||||
|
||||
private fun updateValidPackageNameList() {
|
||||
validLocalPackageNameSet =
|
||||
_validLocalPackageNameSet =
|
||||
localPackageNameSet.filterNot { p -> downloadPackageNameBlackList.contains(p) }.toHashSet()
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* 获取所有已安装的软件的包名、版本(非系统应用)
|
||||
*/
|
||||
private fun getAllPackageName(context: Context): HashSet<String> {
|
||||
val set = HashSet<String>()
|
||||
return try {
|
||||
val packageInfos = PackageUtils.getInstalledPackages(context, 0)
|
||||
val packageInfos = getInstalledPackages(context, 0)
|
||||
for (packageInfo in packageInfos) {
|
||||
if (packageInfo.applicationInfo.flags and ApplicationInfo.FLAG_SYSTEM == 0) {
|
||||
if (context.packageName != packageInfo.packageName) {
|
||||
@ -79,4 +145,357 @@ object PackageHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 弃用已安装列表缓存
|
||||
*/
|
||||
fun dumpInstalledListCache() {
|
||||
lastInstalledPackageListTime = 0
|
||||
}
|
||||
|
||||
/**
|
||||
* 在超时后,若后台没有开启获取已安装应用列表的功能,默认以接口不控制的方式获取已安装应用列表
|
||||
*/
|
||||
fun fallbackInstalledPackageApiSwitchAfterTimeout(timeout: Long) {
|
||||
CoroutineScope(SupervisorJob()).launch {
|
||||
delay(timeout)
|
||||
if (isGetInstalledPackagesApiAgreedRequired == UNKNOWN) {
|
||||
Utils.log(TAG, "后台没有开启获取已安装应用列表的功能,超时后默认以接口不控制的方式获取已安装应用列表")
|
||||
updateIsGetInstalledPackagesApiAgreedRequired(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新已安装应用列表获取开关状态
|
||||
*/
|
||||
fun updateIsGetInstalledPackagesApiAgreedRequired(isEnabled: Boolean) {
|
||||
// 若状态不为 unknown 或者用户已经同意使用了,无需再更新
|
||||
if (isGetInstalledPackagesApiAgreedRequired != UNKNOWN || isGetInstalledPackagesApiAgreed()) {
|
||||
Utils.log(TAG, "installedPackageApiSwitchStatus 不为 UNKNOWN,无需再更新")
|
||||
return
|
||||
}
|
||||
|
||||
if (isEnabled) {
|
||||
getInstalledWhiteList()
|
||||
_installedPackageApiSwitchStatusLiveData.postValue(true)
|
||||
isGetInstalledPackagesApiAgreedRequired = ENABLED
|
||||
} else {
|
||||
isGetInstalledPackagesApiAgreedRequired = DISABLED
|
||||
|
||||
if (isSupportGetInstalledAppsPermission(HaloApp.getInstance())) {
|
||||
GlobalPriorityChainHelper.queueNewHandler(RequestInstalledListPermissionHandler())
|
||||
} else {
|
||||
agreeOnGetInstalledPackagesApi()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户是否已经允许了调用获取已安装应用列表接口
|
||||
* 优先用内存的值,没有再从 SP 中获取并更新
|
||||
*/
|
||||
fun isGetInstalledPackagesApiAgreed(): Boolean {
|
||||
return isGetInstalledPackagesApiAgreed
|
||||
|| (SPUtils.getBoolean(SP_GET_INSTALLED_API_AGREED).also { isGetInstalledPackagesApiAgreed = it })
|
||||
}
|
||||
|
||||
fun isGetInstalledPackagesApiAgreedRequired(): Boolean {
|
||||
return isGetInstalledPackagesApiAgreedRequired == ENABLED
|
||||
}
|
||||
|
||||
/**
|
||||
* 同意使用已安装应用列表 API
|
||||
*/
|
||||
private fun agreeOnGetInstalledPackagesApi() {
|
||||
isGetInstalledPackagesApiAgreed = true
|
||||
SPUtils.setBoolean(SP_GET_INSTALLED_API_AGREED, true)
|
||||
|
||||
_installedPackageApiSwitchStatusLiveData.postValue(false)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已安装应用列表
|
||||
*/
|
||||
fun getInstalledPackages(context: Context?, flags: Int): List<PackageInfo> {
|
||||
Utils.log(TAG, "即将获取已安装应用列表")
|
||||
|
||||
// 用户未同意使用已安装应用列表 API,返回空列表
|
||||
if (!isGetInstalledPackagesApiAgreed()) {
|
||||
Utils.log(TAG, "用户未同意使用已安装应用列表 API,返回空列表")
|
||||
return cachedInstalledPackagesList
|
||||
}
|
||||
|
||||
// 简单 debounce 过于频繁的获取已安装应用列表调用
|
||||
if (System.currentTimeMillis() - lastInstalledPackageListTime < 3000 && cachedInstalledPackagesList.isNotEmpty()) {
|
||||
Utils.log(TAG, "使用了缓存的已安装应用列表")
|
||||
return cachedInstalledPackagesList
|
||||
}
|
||||
|
||||
var shouldGetNewInstalledPackagedList = false
|
||||
|
||||
// 当前设备是否支持限制获取已安装应用列表的功能
|
||||
if (isSupportGetInstalledAppsPermission(context!!)) {
|
||||
Utils.log(TAG, "当前设备支持限制获取已安装应用列表的功能")
|
||||
// 当前设备是否支持禁用了获取已安装应用列表
|
||||
if (!isGetInstalledListPermissionDisabled(context)) {
|
||||
Utils.log(TAG, "当前设备没有限制获取已安装应用列表的功能")
|
||||
shouldGetNewInstalledPackagedList = true
|
||||
} else {
|
||||
Utils.log(TAG, "当前设备已限制获取已安装应用列表的功能")
|
||||
}
|
||||
} else {
|
||||
Utils.log(TAG, "当前设备不支持限制获取已安装应用列表的功能")
|
||||
shouldGetNewInstalledPackagedList = true
|
||||
}
|
||||
|
||||
if (shouldGetNewInstalledPackagedList) {
|
||||
lastInstalledPackageListTime = System.currentTimeMillis()
|
||||
cachedInstalledPackagesList = getInstalledPackagesInternal(context, flags)
|
||||
}
|
||||
|
||||
return cachedInstalledPackagesList
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示获取已安装应用列表的对话框并请求权限
|
||||
*/
|
||||
fun showGetInstallAppsListDialogAndRequestPermissionIfNeeded(
|
||||
activity: FragmentActivity,
|
||||
ignorePermanentlyDenied: Boolean = false,
|
||||
resultClosure: (Boolean) -> Unit
|
||||
) {
|
||||
|
||||
val globalOnPermissionGrantedClosure = {
|
||||
agreeOnGetInstalledPackagesApi()
|
||||
// 进行包名初始化相关的操作
|
||||
PackageRepository.initData()
|
||||
refreshLocalPackageList()
|
||||
refreshList()
|
||||
}
|
||||
|
||||
if (isSupportGetInstalledAppsPermission(activity)) {
|
||||
// 若系统已经授予了获取应用列表的权限,直接进行授权成功回调
|
||||
if (!isGetInstalledListPermissionDisabled(activity)) {
|
||||
globalOnPermissionGrantedClosure.invoke()
|
||||
resultClosure.invoke(true)
|
||||
return
|
||||
}
|
||||
|
||||
PermissionHelper.showGetInstalledAppsListPermissionDialog(
|
||||
activity = activity,
|
||||
requestPermission = true,
|
||||
ignorePermanentlyDenied = ignorePermanentlyDenied
|
||||
) { isGranted ->
|
||||
if (isGranted) {
|
||||
SensorsBridge.trackInstalledListPermissionsResult("成功")
|
||||
globalOnPermissionGrantedClosure.invoke()
|
||||
resultClosure.invoke(true)
|
||||
|
||||
trackInstalledListAfterDelay()
|
||||
} else {
|
||||
resultClosure.invoke(false)
|
||||
SensorsBridge.trackInstalledListPermissionsResult("拒绝")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
val hintDialog = PermissionHelper.showGetInstalledAppsListPermissionDialog(
|
||||
activity = activity,
|
||||
requestPermission = false,
|
||||
) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
SensorsBridge.trackInstalledListPermissionsCustomDialogShow()
|
||||
|
||||
val noticeDialog = DialogHelper.showGuideDialog(
|
||||
context = activity,
|
||||
title = "权限申请",
|
||||
content = "是否允许“光环助手”获取已安装的应用信息",
|
||||
confirmText = "开启",
|
||||
cancelText = "拒绝",
|
||||
confirmClickCallback = {
|
||||
SensorsBridge.trackInstalledListPermissionsCustomClick("开启")
|
||||
globalOnPermissionGrantedClosure.invoke()
|
||||
resultClosure.invoke(true)
|
||||
|
||||
trackInstalledListAfterDelay()
|
||||
},
|
||||
cancelClickCallback = {
|
||||
resultClosure.invoke(false)
|
||||
SensorsBridge.trackInstalledListPermissionsCustomClick("拒绝")
|
||||
}
|
||||
)
|
||||
|
||||
noticeDialog?.setOnDismissListener {
|
||||
hintDialog?.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 延迟5秒后上报已安装应用列表
|
||||
*/
|
||||
private fun trackInstalledListAfterDelay() {
|
||||
CoroutineScope(SupervisorJob()).launch {
|
||||
delay(5000)
|
||||
SensorsBridge.trackNumberOfInstalledList(localPackageNameSet.size, localPackageNameSet)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否支持动态获取已安装应用列表权限
|
||||
*/
|
||||
fun isSupportGetInstalledAppsPermission(context: Context): Boolean {
|
||||
// 若存在缓存,直接返回缓存结果。
|
||||
if (isGetInstalledPackagesPermissionSupported != UNKNOWN) {
|
||||
return isGetInstalledPackagesPermissionSupported != UNSUPPORTED
|
||||
}
|
||||
|
||||
try {
|
||||
// 根据官方提供的方法来判定是否支持限制获取已安装应用列表
|
||||
val flag =
|
||||
Settings.Secure.getInt(context.contentResolver, "oem_installed_apps_runtime_permission_enable", 0)
|
||||
if (flag == 1) {
|
||||
isGetInstalledPackagesPermissionSupported = SUPPORTED
|
||||
return true
|
||||
}
|
||||
|
||||
// 部分未升级的手机没有上面配置项,有定义下面危险权限也认为是支持设备软件列表管控
|
||||
val packageManager = context.packageManager
|
||||
val permissionInfo = packageManager.getPermissionInfo("com.android.permission.GET_INSTALLED_APPS", 0)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
if (permissionInfo.protection == PermissionInfo.PROTECTION_DANGEROUS) {
|
||||
isGetInstalledPackagesPermissionSupported = SUPPORTED
|
||||
return true
|
||||
} else {
|
||||
isGetInstalledPackagesPermissionSupported = UNSUPPORTED
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
isGetInstalledPackagesPermissionSupported = UNSUPPORTED
|
||||
return false
|
||||
}
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
isGetInstalledPackagesPermissionSupported = UNSUPPORTED
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 确保指定包名的应用在已安装了的情况下能正常收录
|
||||
*/
|
||||
fun addInstalledButMissingPackages(packageNameSet: HashSet<String>) {
|
||||
Utils.log(TAG, "addInstalledButMissingPackages 检查已安装但未收录的应用")
|
||||
|
||||
val installedPackageNameSet: HashSet<String> = hashSetOf()
|
||||
|
||||
for (packageName in packageNameSet) {
|
||||
if (!PackagesManager.isInstalled(packageName)
|
||||
&& PackageUtils.getVersionNameByPackageName(packageName) != null
|
||||
) {
|
||||
installedPackageNameSet.add(packageName)
|
||||
}
|
||||
}
|
||||
|
||||
Utils.log(TAG, "addInstalledButMissingPackages 需要请求接口获取的包数量为 ${installedPackageNameSet.size}")
|
||||
|
||||
PackageRepository.addInstalledGames(
|
||||
pkgNameList = ArrayList(installedPackageNameSet),
|
||||
updateInstallStatus = true
|
||||
)
|
||||
}
|
||||
|
||||
fun refreshWrongInstallStatus(packageNameSet: MutableSet<String>) {
|
||||
runOnIoThread {
|
||||
Utils.log(TAG, "refreshWrongInstallStatus 检查安装状态异常的应用")
|
||||
|
||||
val installedButKeepingWrongStatusPackageNameSet: HashSet<String> = hashSetOf()
|
||||
val uninstalledButKeepingWrongStatusPackageNameSet: HashSet<String> = hashSetOf()
|
||||
val updatedButKeepingWrongStatusPackageNameSet: HashSet<String> = hashSetOf()
|
||||
|
||||
for (packageName in packageNameSet) {
|
||||
val installedVersionName = PackageUtils.getVersionNameByPackageName(packageName)
|
||||
|
||||
if (!PackagesManager.isInstalled(packageName)
|
||||
&& installedVersionName != null
|
||||
) {
|
||||
installedButKeepingWrongStatusPackageNameSet.add(packageName)
|
||||
} else if (PackagesManager.isInstalled(packageName)
|
||||
&& installedVersionName == null) {
|
||||
uninstalledButKeepingWrongStatusPackageNameSet.add(packageName)
|
||||
} else if (PackagesManager.isInstalled(packageName)
|
||||
&& installedVersionName != null
|
||||
&& !PackagesManager.isInstalledWithSpecificVersion(packageName, installedVersionName)) {
|
||||
updatedButKeepingWrongStatusPackageNameSet.add(packageName)
|
||||
}
|
||||
}
|
||||
|
||||
Utils.log(TAG, "refreshWrongInstallStatus 需要更新已安装状态的包数量为 ${installedButKeepingWrongStatusPackageNameSet.size}")
|
||||
Utils.log(TAG, "refreshWrongInstallStatus 需要更新已更新状态的包数量为 ${updatedButKeepingWrongStatusPackageNameSet.size}")
|
||||
Utils.log(TAG, "refreshWrongInstallStatus 需要移除已安装的包数量为 ${uninstalledButKeepingWrongStatusPackageNameSet.size}")
|
||||
|
||||
runOnUiThread {
|
||||
if (installedButKeepingWrongStatusPackageNameSet.isNotEmpty()) {
|
||||
for (packageName in installedButKeepingWrongStatusPackageNameSet) {
|
||||
PackageChangeHelper.addInstall(packageName)
|
||||
}
|
||||
}
|
||||
|
||||
if (uninstalledButKeepingWrongStatusPackageNameSet.isNotEmpty()) {
|
||||
for (packageName in uninstalledButKeepingWrongStatusPackageNameSet) {
|
||||
PackageChangeHelper.addUninstall(packageName)
|
||||
}
|
||||
}
|
||||
|
||||
if (updatedButKeepingWrongStatusPackageNameSet.isNotEmpty()) {
|
||||
for (packageName in updatedButKeepingWrongStatusPackageNameSet) {
|
||||
PackageChangeHelper.addUpdate(packageName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 在5.1系统手机使用PackageManager获取已安装应用容易发生Package manager has died异常
|
||||
* https://stackoverflow.com/questions/13235793/transactiontoolargeeception-when-trying-tÏo-get-a-list-of-applications-installed/30062632#30062632
|
||||
*/
|
||||
private fun getInstalledPackagesInternal(context: Context, flags: Int): List<PackageInfo> {
|
||||
Utils.log(TAG, "调用系统 API 获取已安装应用列表")
|
||||
|
||||
val pm = context.packageManager
|
||||
try {
|
||||
return pm.getInstalledPackages(flags)
|
||||
} catch (ignored: java.lang.Exception) {
|
||||
//we don't care why it didn't succeed. We'll do it using an alternative way instead
|
||||
}
|
||||
// use fallback:
|
||||
val process: Process
|
||||
val result: MutableList<PackageInfo> = java.util.ArrayList()
|
||||
var bufferedReader: BufferedReader? = null
|
||||
try {
|
||||
process = Runtime.getRuntime().exec("pm list packages")
|
||||
bufferedReader = BufferedReader(InputStreamReader(process.inputStream))
|
||||
var line: String
|
||||
while ((bufferedReader.readLine().also { line = it }) != null) {
|
||||
val packageName = line.substring(line.indexOf(':') + 1)
|
||||
val packageInfo = pm.getPackageInfo(packageName, flags)
|
||||
result.add(packageInfo)
|
||||
}
|
||||
process.waitFor()
|
||||
} catch (e: java.lang.Exception) {
|
||||
e.printStackTrace()
|
||||
if (e is InterruptedException) {
|
||||
Thread.currentThread().interrupt()
|
||||
}
|
||||
} finally {
|
||||
if (bufferedReader != null) try {
|
||||
bufferedReader.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
}
|
||||
@ -108,6 +108,12 @@ object PackageInstaller {
|
||||
return
|
||||
}
|
||||
|
||||
val packageName = downloadEntity?.packageName ?: PackageUtils.getPackageNameByPath(context, pkgPath)
|
||||
|
||||
packageName?.let {
|
||||
PackageChangeHelper.addInstallPendingPackage(packageName)
|
||||
}
|
||||
|
||||
try {
|
||||
// 判断是否需要使用浏览器来进行安装
|
||||
if (BrowserInstallHelper.isUseBrowserToInstallEnabled()
|
||||
@ -250,6 +256,8 @@ object PackageInstaller {
|
||||
fun uninstallForPackageName(context: Context, pkn: String?) {
|
||||
if (pkn.isNullOrEmpty()) return
|
||||
|
||||
PackageChangeHelper.addUninstallPendingPackage(pkn)
|
||||
|
||||
val uninstallIntent = Intent()
|
||||
uninstallIntent.action = Intent.ACTION_DELETE
|
||||
uninstallIntent.addCategory(Intent.CATEGORY_DEFAULT)
|
||||
|
||||
@ -7,14 +7,12 @@ import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.PermissionInfo;
|
||||
import android.content.pm.Signature;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@ -29,8 +27,6 @@ import com.gh.common.xapk.XapkInstaller;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.common.utils.PackageFlavorHelper;
|
||||
import com.gh.gamecenter.common.utils.PermissionHelper;
|
||||
import com.gh.gamecenter.core.utils.MD5Utils;
|
||||
import com.gh.gamecenter.core.utils.SentryHelper;
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity;
|
||||
@ -49,12 +45,10 @@ import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.security.cert.X509Certificate;
|
||||
@ -68,20 +62,14 @@ import java.util.zip.ZipFile;
|
||||
|
||||
public class PackageUtils {
|
||||
|
||||
private static long mLastInstalledPackageListTime = 0L;
|
||||
private static List<PackageInfo> mInstalledPackageList = null;
|
||||
|
||||
private static final String TAG = "PackageUtils";
|
||||
|
||||
// 设备是否支持禁用获取已安装应用列表。-1 代表支持情况未知,0 代表不支持, 1 代表支持
|
||||
private static int mIsSupportGetInstalledListPermission = -1;
|
||||
|
||||
public static String getInstallPackageInfoSourceDir(String packageName) {
|
||||
try {
|
||||
return HaloApp.getInstance().getApplication().getPackageManager().getPackageInfo(packageName,
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT).applicationInfo.sourceDir;
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
// do nothing
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -319,7 +307,7 @@ public class PackageUtils {
|
||||
return new String[]{null, null};
|
||||
}
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
// do nothing
|
||||
}
|
||||
return new String[]{null, null};
|
||||
}
|
||||
@ -599,7 +587,7 @@ public class PackageUtils {
|
||||
.getPackageInfo(packageName, 0);
|
||||
return packageInfo.firstInstallTime;
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
// do nothing
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -626,7 +614,7 @@ public class PackageUtils {
|
||||
return HaloApp.getInstance().getApplication().getPackageManager()
|
||||
.getPackageInfo(BuildConfig.APPLICATION_ID, 0).lastUpdateTime;
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
// do nothing
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -640,7 +628,7 @@ public class PackageUtils {
|
||||
return HaloApp.getInstance().getApplication().getPackageManager().getPackageInfo(packageName,
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT).versionName;
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
// do nothing
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -653,7 +641,7 @@ public class PackageUtils {
|
||||
return HaloApp.getInstance().getApplication().getPackageManager().getPackageInfo(packageName,
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT).versionCode;
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
// do nothing
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -667,7 +655,7 @@ public class PackageUtils {
|
||||
PackageManager packageManager = context.getApplicationContext().getPackageManager();
|
||||
return packageManager.getApplicationIcon(packageName);
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
// do nothing
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -677,7 +665,7 @@ public class PackageUtils {
|
||||
*/
|
||||
public static ArrayList<String> getAllPackageName(Context context) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
List<PackageInfo> packageInfos = getInstalledPackages(context, 0);
|
||||
List<PackageInfo> packageInfos = PackageHelper.INSTANCE.getInstalledPackages(context, 0);
|
||||
for (PackageInfo packageInfo : packageInfos) {
|
||||
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
if (!context.getPackageName().equals(packageInfo.packageName)) {
|
||||
@ -690,7 +678,7 @@ public class PackageUtils {
|
||||
|
||||
public static ArrayList<String> getAllPackageNameIncludeGh(Context context) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
List<PackageInfo> packageInfos = getInstalledPackages(context, 0);
|
||||
List<PackageInfo> packageInfos = PackageHelper.INSTANCE.getInstalledPackages(context, 0);
|
||||
for (PackageInfo packageInfo : packageInfos) {
|
||||
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
list.add(packageInfo.packageName);
|
||||
@ -704,11 +692,9 @@ public class PackageUtils {
|
||||
*/
|
||||
public static ArrayList<String> getAllPackageNameIncludeSystemApps(Context context) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
List<PackageInfo> packageInfos = getInstalledPackages(context, 0);
|
||||
List<PackageInfo> packageInfos = PackageHelper.INSTANCE.getInstalledPackages(context, 0);
|
||||
for (PackageInfo packageInfo : packageInfos) {
|
||||
if (!context.getPackageName().equals(packageInfo.packageName)) {
|
||||
list.add(packageInfo.packageName);
|
||||
}
|
||||
list.add(packageInfo.packageName);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@ -717,7 +703,7 @@ public class PackageUtils {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
try {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
List<PackageInfo> packageInfos = getInstalledPackages(context, 0);
|
||||
List<PackageInfo> packageInfos = PackageHelper.INSTANCE.getInstalledPackages(context, 0);
|
||||
for (PackageInfo packageInfo : packageInfos) {
|
||||
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
@ -758,7 +744,6 @@ public class PackageUtils {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 启动应用
|
||||
* 请使用 PackageLauncher.launchApp()
|
||||
@ -778,22 +763,6 @@ public class PackageUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 根据包名,获取软件名称
|
||||
*/
|
||||
public static String getNameByPackageName(Context context, String packageName) {
|
||||
try {
|
||||
PackageManager pm = context.getApplicationContext().getPackageManager();
|
||||
ApplicationInfo applicationInfo = pm.getApplicationInfo(
|
||||
packageName, 0);
|
||||
return applicationInfo.loadLabel(pm).toString();
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* todo 统一判断
|
||||
* <p>
|
||||
@ -912,8 +881,8 @@ public class PackageUtils {
|
||||
String packageName = context.getApplicationContext().getPackageName();
|
||||
for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) {
|
||||
// The name of the process that this object is associated with.
|
||||
if (appProcess.processName.equals(packageName) && appProcess.importance
|
||||
== ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
|
||||
if (appProcess.processName.equals(packageName)
|
||||
&& appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -924,132 +893,6 @@ public class PackageUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 弃用已安装列表缓存
|
||||
*/
|
||||
public static void dumpInstalledListCache() {
|
||||
mLastInstalledPackageListTime = 0;
|
||||
}
|
||||
|
||||
public static List<PackageInfo> getInstalledPackages(Context context, int flags) {
|
||||
Utils.log(TAG, "即将获取已安装应用列表");
|
||||
|
||||
// 简单 debounce 掉过于频繁的调用获取已安装列表调用
|
||||
if (System.currentTimeMillis() - mLastInstalledPackageListTime < 1000
|
||||
&& mInstalledPackageList != null
|
||||
&& mInstalledPackageList.size() > 0) {
|
||||
Utils.log(TAG, "使用了缓存的已安装应用列表");
|
||||
return new ArrayList<>(mInstalledPackageList);
|
||||
}
|
||||
|
||||
// 是否需要调用系统 API 获取最新的已安装应用列表
|
||||
boolean shouldGetNewInstalledPackagedList = false;
|
||||
|
||||
// 当前设备是否支持限制获取已安装应用列表的功能
|
||||
if (isSupportGetInstalledAppsPermission(context)) {
|
||||
Utils.log(TAG, "当前设备支持限制获取已安装应用列表的功能");
|
||||
// 当前设备是否支持禁用了获取已安装应用列表
|
||||
if (!PermissionHelper.isGetInstalledListPermissionDisabled(context)) {
|
||||
Utils.log(TAG, "当前设备没有限制获取已安装应用列表的功能");
|
||||
shouldGetNewInstalledPackagedList = true;
|
||||
} else {
|
||||
Utils.log(TAG, "当前设备已限制获取已安装应用列表的功能");
|
||||
}
|
||||
} else {
|
||||
Utils.log(TAG, "当前设备不支持限制获取已安装应用列表的功能");
|
||||
shouldGetNewInstalledPackagedList = true;
|
||||
}
|
||||
|
||||
if (shouldGetNewInstalledPackagedList) {
|
||||
mLastInstalledPackageListTime = System.currentTimeMillis();
|
||||
mInstalledPackageList = getInstalledPackagesInternal(context, flags);
|
||||
}
|
||||
|
||||
if (mInstalledPackageList == null) {
|
||||
mInstalledPackageList = new ArrayList<>();
|
||||
}
|
||||
|
||||
return mInstalledPackageList;
|
||||
}
|
||||
|
||||
public static boolean isSupportGetInstalledAppsPermission(Context context) {
|
||||
// 若存在缓存,直接返回缓存结果。为 0 代表不支持,为 1 代表支持
|
||||
if (mIsSupportGetInstalledListPermission != -1) {
|
||||
return mIsSupportGetInstalledListPermission != 0;
|
||||
}
|
||||
|
||||
try {
|
||||
// 根据官方提供的方法来判定是否支持限制获取已安装应用列表
|
||||
int flag = Settings.Secure.getInt(context.getContentResolver(), "oem_installed_apps_runtime_permission_enable", 0);
|
||||
if (flag == 1) {
|
||||
mIsSupportGetInstalledListPermission = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// 部分未升级的手机没有上面配置项,有定义下面危险权限也认为是支持设备软件列表管控
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
PermissionInfo permissionInfo = packageManager.getPermissionInfo("com.android.permission.GET_INSTALLED_APPS", 0);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
if (permissionInfo.getProtection() == PermissionInfo.PROTECTION_DANGEROUS) {
|
||||
mIsSupportGetInstalledListPermission = 1;
|
||||
return true;
|
||||
} else {
|
||||
mIsSupportGetInstalledListPermission = 0;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
mIsSupportGetInstalledListPermission = 0;
|
||||
return false;
|
||||
}
|
||||
} catch (NameNotFoundException e) {
|
||||
mIsSupportGetInstalledListPermission = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 在5.1系统手机使用PackageManager获取已安装应用容易发生Package manager has died异常
|
||||
* https://stackoverflow.com/questions/13235793/transactiontoolargeeception-when-trying-tÏo-get-a-list-of-applications-installed/30062632#30062632
|
||||
*/
|
||||
private static List<PackageInfo> getInstalledPackagesInternal(Context context, int flags) {
|
||||
Utils.log(TAG, "调用系统 API 获取已安装应用列表");
|
||||
|
||||
final PackageManager pm = context.getPackageManager();
|
||||
try {
|
||||
return pm.getInstalledPackages(flags);
|
||||
} catch (Exception ignored) {
|
||||
//we don't care why it didn't succeed. We'll do it using an alternative way instead
|
||||
}
|
||||
// use fallback:
|
||||
Process process;
|
||||
List<PackageInfo> result = new ArrayList<>();
|
||||
BufferedReader bufferedReader = null;
|
||||
try {
|
||||
process = Runtime.getRuntime().exec("pm list packages");
|
||||
bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
final String packageName = line.substring(line.indexOf(':') + 1);
|
||||
final PackageInfo packageInfo = pm.getPackageInfo(packageName, flags);
|
||||
result.add(packageInfo);
|
||||
}
|
||||
process.waitFor();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if (e instanceof InterruptedException) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
} finally {
|
||||
if (bufferedReader != null)
|
||||
try {
|
||||
bufferedReader.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String getWebviewPath(Context context) {
|
||||
final PackageInfo webViewPackageInfo = WebViewCompat.getCurrentWebViewPackage(context);
|
||||
return webViewPackageInfo != null ? webViewPackageInfo.applicationInfo.sourceDir : null;
|
||||
|
||||
@ -28,10 +28,10 @@ import org.json.JSONObject
|
||||
import java.io.File
|
||||
import java.net.URLEncoder
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
object BrowserInstallHelper {
|
||||
|
||||
// 随便选的 32321 居然在部分 vivo 手机上被占用,喷了
|
||||
private const val PORT = 40705
|
||||
private const val RESERVE_PORT = 40706
|
||||
|
||||
@ -40,15 +40,12 @@ object BrowserInstallHelper {
|
||||
private val mContext by lazy { HaloApp.getInstance().application }
|
||||
private var mUseReservePort = false
|
||||
|
||||
private val mAllInstalledPackageList: ArrayList<String> by lazy {
|
||||
PackageUtils.getAllPackageNameIncludeSystemApps(HaloApp.getInstance().applicationContext).apply {
|
||||
add(HaloApp.getInstance().applicationContext.packageName)
|
||||
}
|
||||
}
|
||||
private var mValidInstalledPackageList: ArrayList<String> = arrayListOf()
|
||||
private var mValidConditionMatchedCache: Boolean? = null
|
||||
|
||||
private fun getServer(port: Int): DownloadServer {
|
||||
val server = DownloadServer(port)
|
||||
for (packageName in mAllInstalledPackageList) {
|
||||
for (packageName in getAllInstalledPackageList()) {
|
||||
if (packageName.contains("com.freeme") || packageName.contains("com.zhuoyi")) {
|
||||
server.isBuggyDevice = true
|
||||
break
|
||||
@ -57,6 +54,23 @@ object BrowserInstallHelper {
|
||||
return server
|
||||
}
|
||||
|
||||
private fun getAllInstalledPackageList(): ArrayList<String> {
|
||||
when {
|
||||
mValidInstalledPackageList.isNotEmpty() -> {
|
||||
return mValidInstalledPackageList
|
||||
}
|
||||
|
||||
else -> {
|
||||
val allInstalledPackageList = PackageUtils.getAllPackageNameIncludeSystemApps(mContext)
|
||||
|
||||
if (allInstalledPackageList.isNotEmpty()) {
|
||||
mValidInstalledPackageList = allInstalledPackageList
|
||||
}
|
||||
return mValidInstalledPackageList
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun downloadFile(filePath: String) {
|
||||
if (!::mServer.isInitialized) mServer = if (mUseReservePort) getServer(RESERVE_PORT) else getServer(PORT)
|
||||
if (!mServer.isAlive && !startServer()) {
|
||||
@ -80,7 +94,7 @@ object BrowserInstallHelper {
|
||||
Base64.encodeToString(URLEncoder.encode(downloadUrl).trim().toByteArray(), Base64.NO_WRAP)
|
||||
DirectUtils.directToExternalBrowser(
|
||||
mContext,
|
||||
"https://down-and.ghzs.com/redirect?location=base64($encodedString)"
|
||||
"https://down-and.ghzs6.com/redirect?location=base64($encodedString)"
|
||||
)
|
||||
} else {
|
||||
DirectUtils.directToExternalBrowser(mContext, downloadUrl)
|
||||
@ -237,32 +251,43 @@ object BrowserInstallHelper {
|
||||
* 是否满足开启浏览器安装的条件
|
||||
*/
|
||||
private fun isConditionMatched(settingsEntity: NewSettingsEntity): Boolean {
|
||||
if (mValidConditionMatchedCache != null) {
|
||||
return mValidConditionMatchedCache!!
|
||||
}
|
||||
|
||||
val packageList = getAllInstalledPackageList()
|
||||
|
||||
if (packageList.isEmpty()) return false
|
||||
|
||||
settingsEntity.installModel?.whiteList?.let {
|
||||
for (packageName in it) {
|
||||
if (mAllInstalledPackageList.contains(packageName)) {
|
||||
return false
|
||||
if (packageList.contains(packageName)) {
|
||||
mValidConditionMatchedCache = false
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
settingsEntity.installModel?.packages?.let {
|
||||
for (packageName in it) {
|
||||
if (mAllInstalledPackageList.contains(packageName)) {
|
||||
return true
|
||||
if (packageList.contains(packageName)) {
|
||||
mValidConditionMatchedCache = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
// 匹配部分字符串即可
|
||||
settingsEntity.installModel?.regexPackages?.let {
|
||||
for (packageNamePieces in it) {
|
||||
for (installedPackageName in mAllInstalledPackageList) {
|
||||
for (installedPackageName in packageList) {
|
||||
if (installedPackageName.contains(packageNamePieces)) {
|
||||
return true
|
||||
mValidConditionMatchedCache = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
return mValidConditionMatchedCache ?: false
|
||||
}
|
||||
|
||||
fun onApkInstalled(path: String?) {
|
||||
|
||||
@ -98,7 +98,6 @@ import com.gh.gamecenter.feature.utils.PlatformUtils;
|
||||
import com.gh.gamecenter.home.custom.model.CustomPageShareRepository;
|
||||
import com.gh.gamecenter.home.skip.PackageSkipActivity;
|
||||
import com.gh.gamecenter.login.user.UserManager;
|
||||
import com.gh.gamecenter.login.utils.QuickLoginHelper;
|
||||
import com.gh.gamecenter.manager.DataCollectionManager;
|
||||
import com.gh.gamecenter.packagehelper.PackageViewModel;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
@ -137,6 +136,9 @@ import io.reactivex.SingleSource;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.HttpException;
|
||||
@ -282,6 +284,8 @@ public class MainActivity extends BaseActivity {
|
||||
Config.getGhzsSettings();
|
||||
} else if (Config.getVSettingEntity() == null) {
|
||||
Config.refreshVSettingEntity();
|
||||
} else if (Config.getVNewSettingEntity() == null) {
|
||||
Config.getNewSetting();
|
||||
}
|
||||
|
||||
// 耗时操作
|
||||
@ -319,8 +323,7 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
mMainWrapperViewModel.requestAllDialogData();
|
||||
|
||||
// TODO 去掉一键登录?
|
||||
QuickLoginHelper.getPhoneInfo();
|
||||
// QuickLoginHelper.getPhoneInfo();
|
||||
|
||||
// TODO 搞清楚为什么这里要获取微信相关配置
|
||||
WechatBindHelper.getWechatConfig(null);
|
||||
@ -558,7 +561,10 @@ public class MainActivity extends BaseActivity {
|
||||
} else {
|
||||
TextView jumpBtn = findViewById(R.id.jumpBtn);
|
||||
jumpBtn.setText(String.format(Locale.CHINA, "跳过 %d", COUNTDOWN_MAX_COUNT - mCountdownCount));
|
||||
mBaseHandler.sendEmptyMessageDelayed(COUNTDOWN_AD, 1000);
|
||||
Message newMsg = Message.obtain();
|
||||
newMsg.what = COUNTDOWN_AD;
|
||||
newMsg.obj = msg.obj;
|
||||
mBaseHandler.sendMessageDelayed(newMsg, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -737,14 +743,11 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
ToastUtils.showToast("游戏启动中,请稍后~");
|
||||
handler.postDelayed(() -> {
|
||||
VHelper.postOnInitialized(() -> {
|
||||
if (VHelper.isInstalled(gamePackageName)) {
|
||||
VHelper.launch(this, gamePackageName, false, true);
|
||||
} else {
|
||||
ToastUtils.showToast("应用已被卸载!");
|
||||
}
|
||||
return null;
|
||||
});
|
||||
if(VHelper.isInnerInstalled(gamePackageName)) {
|
||||
launchGame(gamePackageName).invoke();
|
||||
} else {
|
||||
VHelper.postOnInitialized(launchGame(gamePackageName));
|
||||
}
|
||||
}, 500);
|
||||
break;
|
||||
case KEY_MARKET_DETAILS:
|
||||
@ -762,6 +765,18 @@ public class MainActivity extends BaseActivity {
|
||||
}, 500);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private Function0<Unit> launchGame(String gamePackageName) {
|
||||
return () -> {
|
||||
if (!VHelper.isInnerInstalled(gamePackageName) && !VHelper.isInstalled(gamePackageName)) {
|
||||
ToastUtils.showToast("应用已被卸载!");
|
||||
} else {
|
||||
VHelper.launch(this, gamePackageName, false, true);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用跳转
|
||||
*/
|
||||
@ -929,6 +944,8 @@ public class MainActivity extends BaseActivity {
|
||||
Config.getGhzsSettings();
|
||||
} else if (Config.getVSettingEntity() == null) {
|
||||
Config.refreshVSettingEntity();
|
||||
} else if (Config.getVNewSettingEntity() == null) {
|
||||
Config.getNewSetting();
|
||||
}
|
||||
|
||||
mPackageViewModel.checkData();
|
||||
@ -939,8 +956,10 @@ public class MainActivity extends BaseActivity {
|
||||
// 接收登录和登出更新事件统计的 Meta
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEventMainThread(EBReuse reuse) {
|
||||
if (reuse.getType().equals(LOGIN_TAG) || reuse.getType().equals(LOGOUT_TAG)) {
|
||||
boolean isLoginEvent = reuse.getType().equals(LOGIN_TAG);
|
||||
if (isLoginEvent || reuse.getType().equals(LOGOUT_TAG)) {
|
||||
MetaUtil.INSTANCE.refreshMeta();
|
||||
VHelper.INSTANCE.updateAuthorizeInfo(isLoginEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -111,7 +111,7 @@ public class ShareCardActivity extends ToolBarActivity {
|
||||
|
||||
String qrBody;
|
||||
if (!TextUtils.isEmpty(newsId)) {
|
||||
qrBody = "http://www.ghzs666.com/article/" + newsId + ".html?source=appshare200";
|
||||
qrBody = "https://www.ghzs666.com/article/" + newsId + ".html?source=appshare200";
|
||||
} else {
|
||||
qrBody = "https://www.ghzs.com/?source=appshare200";
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ public class ShareCardPicActivity extends ToolBarActivity {
|
||||
|
||||
String qrBody;
|
||||
if (!TextUtils.isEmpty(newsId)) {
|
||||
qrBody = "http://www.ghzs666.com/article/" + newsId + ".html?source=appshare200";
|
||||
qrBody = "https://www.ghzs666.com/article/" + newsId + ".html?source=appshare200";
|
||||
} else {
|
||||
qrBody = "https://www.ghzs.com/?source=appshare200";
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.gh.gamecenter;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.ENTRANCE_BROWSER;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.ENTRANCE_PUSH;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_ANSWER;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_ARCHIVE_LOGIN;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_ARTICLE;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_CATEGORY;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_COLUMN;
|
||||
@ -21,6 +22,7 @@ import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_QQ_GAME;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_QQ_GROUP;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_QQ_QUN;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_QUESTION;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_RESTART_GAME;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_SUGGESTION;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_TOOLBOX;
|
||||
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_UPLOAD_VIDEO;
|
||||
@ -64,8 +66,10 @@ import com.gh.gamecenter.core.utils.ToastUtils;
|
||||
import com.gh.gamecenter.entity.SubjectRecommendEntity;
|
||||
import com.gh.gamecenter.entity.VideoLinkEntity;
|
||||
import com.gh.gamecenter.feature.utils.PlatformUtils;
|
||||
import com.gh.gamecenter.login.view.LoginActivity;
|
||||
import com.gh.gamecenter.video.detail.VideoDetailContainerViewModel;
|
||||
import com.gh.gamecenter.video.videomanager.VideoManagerActivity;
|
||||
import com.gh.vspace.VHelper;
|
||||
import com.gh.vspace.shortcut.OnCreateShortcutResult;
|
||||
import com.gh.vspace.shortcut.ShortcutManager;
|
||||
import com.gh.vspace.shortcut.ShortcutPermissionTipsDialog;
|
||||
@ -405,6 +409,27 @@ public class SkipActivity extends BaseActivity {
|
||||
} catch (JSONException ignored) {
|
||||
}
|
||||
break;
|
||||
case HOST_ARCHIVE_LOGIN:
|
||||
String gamePkg = uri.getQueryParameter(EntranceConsts.KEY_GAME_PKG);
|
||||
if(CheckLoginUtils.isLogin()) {
|
||||
VHelper.INSTANCE.updateAuthorizeInfo(true);
|
||||
} else {
|
||||
Bundle newBundle = new Bundle();
|
||||
newBundle.putString(EntranceConsts.KEY_TO, LoginActivity.class.getName());
|
||||
EntranceUtils.jumpActivity(this, null, newBundle, (resultCode, data) -> {
|
||||
if(CheckLoginUtils.isLogin()) {
|
||||
VHelper.INSTANCE.updateAuthorizeInfo(true);
|
||||
}
|
||||
VHelper.launch(this, gamePkg, false, false);
|
||||
finish();
|
||||
});
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case HOST_RESTART_GAME:
|
||||
String restartGamePkg = uri.getQueryParameter(EntranceConsts.KEY_GAME_PKG);
|
||||
VHelper.launch(this, restartGamePkg, false, true);
|
||||
break;
|
||||
default:
|
||||
EntranceUtils.jumpActivity(this, new Bundle()); // 跳转至首页
|
||||
return;
|
||||
|
||||
@ -197,7 +197,7 @@ class SplashScreenActivity : BaseActivity() {
|
||||
|
||||
// 尝试获取安装应用列表权限并启动首页(不在乎结果)
|
||||
private fun requestGetInstallListPermissionAndLaunchMainActivity() {
|
||||
if (PackageUtils.isSupportGetInstalledAppsPermission(this)
|
||||
if (PackageHelper.isSupportGetInstalledAppsPermission(this)
|
||||
&& PermissionHelper.isGetInstalledListPermissionDisabled(this)
|
||||
) {
|
||||
PermissionHelper.requestGetInstalledAppsListPermission(this, true) {
|
||||
|
||||
@ -18,6 +18,7 @@ import android.widget.TextView;
|
||||
import androidx.collection.ArrayMap;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.gh.common.util.PackageHelper;
|
||||
import com.gh.common.util.PackageInstaller;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
@ -188,7 +189,7 @@ public class CleanApkAdapter extends BaseRecyclerAdapter<KcSelectGameViewHolder>
|
||||
}
|
||||
|
||||
private int doType(String packageName) {
|
||||
List<PackageInfo> pakageinfos = PackageUtils.getInstalledPackages(mContext, 0);
|
||||
List<PackageInfo> pakageinfos = PackageHelper.INSTANCE.getInstalledPackages(mContext, 0);
|
||||
for (PackageInfo pi : pakageinfos) {
|
||||
if ((pi.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
String pi_packageName = pi.packageName;
|
||||
|
||||
@ -89,7 +89,7 @@ class AuthorizationActivity : ToolBarActivity() {
|
||||
}
|
||||
|
||||
private fun initData() {
|
||||
if (mToken.isNotEmpty()) return
|
||||
if (mToken.isNotEmpty() || isFinishing) return
|
||||
val loadingDialog = DialogUtils.showWaitDialog(this, "请稍后...")
|
||||
mViewModel.getAccessToken(listOf(mContent), {
|
||||
mToken = it
|
||||
|
||||
@ -21,6 +21,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.ad.AdDelegateHelper
|
||||
import com.gh.common.util.HomePluggableHelper
|
||||
import com.gh.common.util.NewFlatLogUtils
|
||||
import com.gh.common.util.PackageHelper
|
||||
import com.gh.common.util.PackageInstaller
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.DownloadManagerActivity
|
||||
@ -276,6 +277,12 @@ class DownloadFragment : BaseFragment_TabLayout() {
|
||||
if (mBinding.adGameItemContainer.isVisible) {
|
||||
DownloadManager.getInstance().addObserver(mDataWatcher)
|
||||
}
|
||||
|
||||
refreshInstallStatus()
|
||||
}
|
||||
|
||||
private fun refreshInstallStatus() {
|
||||
PackageHelper.refreshWrongInstallStatus(PackagesManager.getInstalledSet())
|
||||
}
|
||||
|
||||
override fun onParentActivityFinish() {
|
||||
|
||||
@ -10,8 +10,8 @@ import com.ethanhua.skeleton.ViewSkeletonScreen
|
||||
import com.gh.common.exposure.ExposureListener
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.common.util.DownloadItemUtils
|
||||
import com.gh.common.util.PackageHelper
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.MainActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.fragment.ToolbarFragment
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse
|
||||
@ -29,7 +29,6 @@ import com.gh.gamecenter.feature.entity.GameInstall
|
||||
import com.gh.gamecenter.manager.PackagesManager
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository
|
||||
import com.gh.gamecenter.packagehelper.PackageViewModel
|
||||
import com.gh.gamecenter.wrapper.MainWrapperFragment
|
||||
import com.lightgame.download.DataWatcher
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.download.DownloadStatus
|
||||
@ -147,15 +146,20 @@ class NewInstalledGameFragment : ToolbarFragment() {
|
||||
}
|
||||
|
||||
mBinding.run {
|
||||
if (PermissionHelper.isGetInstalledListPermissionDisabled(requireContext())) {
|
||||
val isGetInstalledListDisagreed = PackageHelper.isGetInstalledPackagesApiAgreedRequired()
|
||||
&& !PackageHelper.isGetInstalledPackagesApiAgreed()
|
||||
val isGetInstalledListPermissionDisabled = PermissionHelper.isGetInstalledListPermissionDisabled(requireContext())
|
||||
|
||||
if (isGetInstalledListDisagreed || isGetInstalledListPermissionDisabled) {
|
||||
reuseNoneData.reuseNoneDataIv.visibility = View.GONE
|
||||
reuseNoneData.reuseNoneDataTv.text = "开启应用列表权限"
|
||||
reuseNoneData.reuseNoneDataDescTv.text = " 及时获悉游戏最新的更新消息"
|
||||
reuseNoneData.reuseResetLoadTv.text = "去开启"
|
||||
reuseNoneData.reuseResetLoadTv.setOnClickListener {
|
||||
PermissionHelper.requestGetInstalledAppsListPermission(requireActivity()) {
|
||||
updateNoDataView()
|
||||
PackageRepository.initData()
|
||||
PackageHelper.showGetInstallAppsListDialogAndRequestPermissionIfNeeded(requireActivity()) { isGranted ->
|
||||
if (isGranted) {
|
||||
updateNoDataView()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -3,8 +3,8 @@ package com.gh.gamecenter.download
|
||||
import android.view.View
|
||||
import com.gh.common.exposure.ExposureListener
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.common.util.PackageHelper
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.MainActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.fragment.LazyFragment
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
@ -12,12 +12,10 @@ import com.gh.gamecenter.common.eventbus.EBReuse
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.common.view.FixLinearLayoutManager
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.core.utils.EmptyCallback
|
||||
import com.gh.gamecenter.databinding.FragmentGameUpdatableBinding
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository
|
||||
import com.gh.gamecenter.packagehelper.PackageViewModel
|
||||
import com.gh.gamecenter.wrapper.MainWrapperFragment
|
||||
import com.lightgame.download.DataWatcher
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
@ -40,7 +38,6 @@ class UpdatableGameFragment : LazyFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun getRealLayoutId() = R.layout.fragment_game_updatable
|
||||
override fun onRealLayoutInflated(inflatedView: View) {
|
||||
mBinding = FragmentGameUpdatableBinding.bind(inflatedView)
|
||||
@ -98,21 +95,21 @@ class UpdatableGameFragment : LazyFragment() {
|
||||
noDataContainer.reuseResetLoadTv.layoutParams = layoutParam
|
||||
noDataContainer.reuseResetLoadTv.visibility = View.VISIBLE
|
||||
noDataContainer.reuseNoneDataDescTv.visibility = View.VISIBLE
|
||||
if (PermissionHelper.isGetInstalledListPermissionDisabled(requireContext())) {
|
||||
|
||||
val isGetInstalledListDisagreed = !PackageHelper.isGetInstalledPackagesApiAgreed()
|
||||
val isGetInstalledListPermissionDisabled = PermissionHelper.isGetInstalledListPermissionDisabled(requireContext())
|
||||
|
||||
if (isGetInstalledListDisagreed || isGetInstalledListPermissionDisabled) {
|
||||
noDataContainer.reuseNoneDataIv.visibility = View.GONE
|
||||
noDataContainer.reuseNoneDataTv.text = "开启应用列表权限"
|
||||
noDataContainer.reuseNoneDataDescTv.text = "及时获悉游戏最新的更新消息"
|
||||
noDataContainer.reuseResetLoadTv.text = "去开启"
|
||||
noDataContainer.reuseResetLoadTv.setOnClickListener {
|
||||
PermissionHelper.requestGetInstalledAppsListPermission(
|
||||
requireActivity(),
|
||||
false,
|
||||
object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
updateNoDataView()
|
||||
PackageRepository.initData()
|
||||
}
|
||||
})
|
||||
PackageHelper.showGetInstallAppsListDialogAndRequestPermissionIfNeeded(requireActivity()) { isGranted ->
|
||||
if (isGranted) {
|
||||
updateNoDataView()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
noDataContainer.reuseNoneDataIv.visibility = View.VISIBLE
|
||||
|
||||
@ -34,7 +34,9 @@ class AppEntity(
|
||||
*/
|
||||
var alert: String? = null,
|
||||
// 关联64位更新
|
||||
var relation: AppEntity? = null
|
||||
var relation: AppEntity? = null,
|
||||
@SerializedName("_id")
|
||||
var id: String? = null
|
||||
) : Parcelable {
|
||||
fun isAlertEveryTime() = alert == "EVERY_TIME_OPEN"
|
||||
|
||||
|
||||
@ -11,6 +11,12 @@ class NewApiSettingsEntity(
|
||||
var startup: StartupAdEntity? = null,//启动文案广告
|
||||
@SerializedName("user_interested_game")
|
||||
var userInterestedGame: Boolean = false, //偏好设置状态开关
|
||||
@SerializedName("installed_compliance_switch")
|
||||
var installedComplianceSwitch: Boolean? = false, //安装合规开关
|
||||
@SerializedName("listen_switch")
|
||||
var isPackageObserveEnable: Boolean = false, // 安装包监听开关
|
||||
@SerializedName("listen_str")
|
||||
var packageObserveActions: PackageObserveActions? = null, // 安装包监听的三个 action
|
||||
var install: Install, // 安装相关的
|
||||
@SerializedName("game_shield_contents")
|
||||
var gameShieldContents: List<String>? = listOf(),//游戏屏蔽内容
|
||||
@ -46,4 +52,13 @@ class NewApiSettingsEntity(
|
||||
val type: String,
|
||||
val link: LinkEntity
|
||||
)
|
||||
|
||||
class PackageObserveActions(
|
||||
@SerializedName("ADD")
|
||||
val add: String,
|
||||
@SerializedName("REM")
|
||||
val rem: String,
|
||||
@SerializedName("REP")
|
||||
val rep: String
|
||||
)
|
||||
}
|
||||
42
app/src/main/java/com/gh/gamecenter/entity/VNewSetting.kt
Normal file
42
app/src/main/java/com/gh/gamecenter/entity/VNewSetting.kt
Normal file
@ -0,0 +1,42 @@
|
||||
package com.gh.gamecenter.entity
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
class VNewSetting {
|
||||
|
||||
@SerializedName("va")
|
||||
var va: Va? = null
|
||||
|
||||
@SerializedName("va_plugin")
|
||||
var vaPlugin: VaPlugin? = null
|
||||
|
||||
class Va(
|
||||
@SerializedName("32-bit")
|
||||
val arch32: VaArch? = null,
|
||||
)
|
||||
|
||||
class VaArch(
|
||||
val size: String,
|
||||
@SerializedName("package")
|
||||
val packageName: String,
|
||||
@SerializedName("version")
|
||||
val versionName: String,
|
||||
@SerializedName("version_code")
|
||||
val versionCode: Int,
|
||||
val url: String
|
||||
)
|
||||
|
||||
data class VaPlugin(
|
||||
@SerializedName("_id")
|
||||
val id: String?,
|
||||
@SerializedName("version_name")
|
||||
val versionName: String?,
|
||||
@SerializedName("change_log")
|
||||
var changeLog: String?,
|
||||
@SerializedName("url_32")
|
||||
val url32: String?,
|
||||
@SerializedName("url_64")
|
||||
val url64: String?,
|
||||
)
|
||||
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package com.gh.gamecenter.entity
|
||||
|
||||
class WhitePackageListEntity {
|
||||
var data: HashSet<String>? = null
|
||||
}
|
||||
@ -413,7 +413,7 @@ class ArticleItemVideoView @JvmOverloads constructor(context: Context, attrs: At
|
||||
val shareUrl = if (isPublishEnv()) {
|
||||
"https://m.ghzs666.com/video/${it.id}"
|
||||
} else {
|
||||
"https://resource.ghzs.com/page/video_play/video/video.html?video=${it.id}"
|
||||
"https://dev-and-static.ghzs66.com/page/video_play/video/video.html?video=${it.id}"
|
||||
}
|
||||
val additionalParams = AdditionalParamsEntity().apply {
|
||||
contentType = "视频帖"
|
||||
|
||||
@ -17,11 +17,9 @@ import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import com.gh.common.browse.BrowseTimer
|
||||
import com.gh.common.browse.withLifecycle
|
||||
import com.gh.common.util.NewFlatLogUtils
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.common.util.NewFlatLogUtils
|
||||
import com.gh.common.util.NewLogUtils
|
||||
import com.gh.common.util.ViewPagerFragmentHelper
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.TrackableDialog
|
||||
import com.gh.gamecenter.common.base.adapter.FragmentAdapter
|
||||
@ -74,7 +72,6 @@ class CommunityHomeFragment : LazyFragment() {
|
||||
private var mBottomTabId = ""
|
||||
|
||||
private val browseTimer = BrowseTimer()
|
||||
.withLifecycle(this)
|
||||
.withResult {
|
||||
SensorsBridge.trackCommunityBrowsingDuration(it / 1000.0)
|
||||
}
|
||||
@ -202,13 +199,14 @@ class CommunityHomeFragment : LazyFragment() {
|
||||
mBottomTabId = arguments?.getString(EntranceConsts.KEY_BOTTOM_TAB_ID, "") ?: ""
|
||||
}
|
||||
|
||||
override fun setUserVisibleHint(isVisibleToUser: Boolean) {
|
||||
super.setUserVisibleHint(isVisibleToUser)
|
||||
if (isVisibleToUser) {
|
||||
browseTimer.start()
|
||||
} else {
|
||||
browseTimer.stop()
|
||||
}
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
browseTimer.start()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
browseTimer.stop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
|
||||
@ -45,6 +45,12 @@ class UpdateDialogFragment : BaseDialogFragment() {
|
||||
private var mIsDisplayingDownloadingStyle = false // 是否正在显示更新中样式
|
||||
|
||||
private val mDataWatcher = object : DataWatcher() {
|
||||
override fun onDataInit(downloadEntity: DownloadEntity) {
|
||||
super.onDataInit(downloadEntity)
|
||||
|
||||
onDataChanged(downloadEntity)
|
||||
}
|
||||
|
||||
override fun onDataChanged(downloadEntity: DownloadEntity) {
|
||||
if (downloadEntity.name.contains("光环助手")) {
|
||||
if (mIsDisplayingDownloadingStyle) {
|
||||
@ -74,13 +80,11 @@ class UpdateDialogFragment : BaseDialogFragment() {
|
||||
return
|
||||
}
|
||||
|
||||
DownloadManager.getInstance().addObserver(mDataWatcher)
|
||||
|
||||
mUpdateEntity = arguments?.getParcelable(UPDATE_ENTITY)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
showUpdateHintStyle(requireContext(), mUpdateEntity!!)
|
||||
showUpdateHintStyle(requireContext(), mUpdateEntity!!, true)
|
||||
|
||||
return mBinding.root
|
||||
}
|
||||
@ -109,8 +113,14 @@ class UpdateDialogFragment : BaseDialogFragment() {
|
||||
mDismissCallback?.onCallback()
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
|
||||
DownloadManager.getInstance().addObserver(mDataWatcher)
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
|
||||
DownloadManager.getInstance().removeObserver(mDataWatcher)
|
||||
}
|
||||
@ -120,7 +130,9 @@ class UpdateDialogFragment : BaseDialogFragment() {
|
||||
* @param context 上下文
|
||||
* @param updateEntity 更新实体
|
||||
*/
|
||||
private fun showUpdateHintStyle(context: Context, updateEntity: AppEntity) {
|
||||
private fun showUpdateHintStyle(context: Context,
|
||||
updateEntity: AppEntity,
|
||||
invokeByViewCreated: Boolean) {
|
||||
mIsDisplayingDownloadingStyle = false
|
||||
|
||||
val updateHintBinding = mBinding.updateHintContainerView
|
||||
@ -200,12 +212,15 @@ class UpdateDialogFragment : BaseDialogFragment() {
|
||||
)
|
||||
}
|
||||
|
||||
SensorsBridge.trackVersionUpdateDialogShow(
|
||||
keyDialogReminderTime = mUpdateEntity?.alert,
|
||||
keyDialogClose = if (mUpdateEntity?.isForce == true) "关闭且强退" else "仅关闭"
|
||||
)
|
||||
if (invokeByViewCreated) {
|
||||
SensorsBridge.trackVersionUpdateDialogShow(
|
||||
keyDialogReminderTime = mUpdateEntity?.alert,
|
||||
keyDialogClose = if (mUpdateEntity?.isForce == true) "关闭且强退" else "仅关闭"
|
||||
)
|
||||
|
||||
DataLogUtils.uploadUpgradeLog(context, "notice") //上传更新通知弹窗数据
|
||||
}
|
||||
|
||||
DataLogUtils.uploadUpgradeLog(context, "notice") //上传更新通知弹窗数据
|
||||
}
|
||||
|
||||
/**
|
||||
@ -294,13 +309,8 @@ class UpdateDialogFragment : BaseDialogFragment() {
|
||||
|
||||
if (DownloadStatus.done == downloadEntity.status) {
|
||||
DownloadManager.getInstance().cancel(downloadEntity.url, false, true, false)
|
||||
try {
|
||||
dismiss()
|
||||
} catch (ignored: IllegalArgumentException) {
|
||||
// do nothing
|
||||
}
|
||||
if (updateEntity.isForce) {
|
||||
AppExecutor.uiExecutor.executeWithDelay({ UpdateHelper.exitApp() }, 1000L)
|
||||
tryWithDefaultCatch {
|
||||
showUpdateHintStyle(requireContext(), updateEntity, false)
|
||||
}
|
||||
} else if (DownloadStatus.neterror == downloadEntity.status) {
|
||||
ToastUtils.toast("网络错误,请稍后重试")
|
||||
|
||||
@ -798,6 +798,8 @@ class GameCollectionDetailFragment :
|
||||
}
|
||||
}, 2000)
|
||||
}
|
||||
|
||||
mListViewModel.refreshPackageStatus()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
||||
@ -10,6 +10,7 @@ import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.gh.common.filter.RegionSettingHelper
|
||||
import com.gh.common.util.ErrorHelper
|
||||
import com.gh.common.util.PackageHelper
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.baselist.LoadStatus
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
@ -64,6 +65,8 @@ open class GameCollectionDetailViewModel(
|
||||
var videoIsMuted = SPUtils.getBoolean(Constants.SP_VIDEO_PLAY_MUTE, true)
|
||||
var isPostFirstOver = false
|
||||
|
||||
private var packageNameSet = hashSetOf<String>()
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun getGameCollectionDetail() {
|
||||
mApi.getGameCollectionDetail(gameCollectionId)
|
||||
@ -128,10 +131,17 @@ open class GameCollectionDetailViewModel(
|
||||
add(mResultLiveData.value!![i])
|
||||
}
|
||||
} else {
|
||||
packageNameSet = hashSetOf()
|
||||
|
||||
games?.forEach {
|
||||
it.isAdData = adIconActive
|
||||
add(CommentItemData(game = it))
|
||||
it.getApk().forEach { apk ->
|
||||
packageNameSet.add(apk.packageName)
|
||||
}
|
||||
}
|
||||
|
||||
refreshPackageStatus()
|
||||
}
|
||||
}
|
||||
|
||||
@ -158,6 +168,12 @@ open class GameCollectionDetailViewModel(
|
||||
override fun getHandleTopCommentCondition(index: Int) =
|
||||
!isHandleTopComment && gameCollectionDetail != null && topCommentId.isNotBlank() && index == 0
|
||||
|
||||
fun refreshPackageStatus() {
|
||||
if (packageNameSet.isNotEmpty()) {
|
||||
PackageHelper.refreshWrongInstallStatus(packageNameSet)
|
||||
}
|
||||
}
|
||||
|
||||
fun followingCommand(userId: String, isFollow: Boolean) {
|
||||
val observable = if (isFollow) {
|
||||
RetrofitManager.getInstance().api.postFollowing(userId)
|
||||
|
||||
@ -2399,6 +2399,8 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
|
||||
|
||||
DownloadManager.getInstance().addObserver(dataWatcher)
|
||||
controlInstallHint()
|
||||
|
||||
mViewModel.refreshWrongInstallStatus()
|
||||
}
|
||||
|
||||
override fun onFragmentPause() {
|
||||
|
||||
@ -14,8 +14,8 @@ import com.gh.common.history.HistoryHelper
|
||||
import com.gh.common.util.CheckLoginUtils
|
||||
import com.gh.gamecenter.feature.utils.ConcernUtils
|
||||
import com.gh.common.util.LibaoUtils
|
||||
import com.gh.common.util.PackageHelper
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.livedata.NonStickyMutableLiveData
|
||||
import com.gh.gamecenter.common.mvvm.Resource
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
@ -184,6 +184,7 @@ class GameDetailViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
refreshWrongInstallStatus()
|
||||
filterGameTags(data)
|
||||
filterBlockedContent(data)
|
||||
replaceWithMirrorInfoIfNeeded(data)
|
||||
@ -256,6 +257,14 @@ class GameDetailViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
fun refreshWrongInstallStatus() {
|
||||
val packageNameSet = hashSetOf<String>()
|
||||
game?.getApk()?.forEach {
|
||||
packageNameSet.add(it.packageName)
|
||||
}
|
||||
PackageHelper.refreshWrongInstallStatus(packageNameSet)
|
||||
}
|
||||
|
||||
private fun replaceWithMirrorInfoIfNeeded(data: NewGameDetailEntity) {
|
||||
// 获取镜像相关数据,不存在时不替换
|
||||
val mirrorData = getMirrorData(data) ?: return
|
||||
|
||||
@ -282,10 +282,10 @@ class RatingEditActivity : ToolBarActivity(), KeyboardHeightObserver {
|
||||
}
|
||||
}
|
||||
mBinding.mWebView.addJavascriptObject(DefaultJsApi(this), null)
|
||||
val url = if ("internal" == BuildConfig.FLAVOR) {
|
||||
"https://resource.ghzs.com/page/comment_tag_editor_dev/index.html?timestamp=${System.currentTimeMillis()}"
|
||||
val url = if (PackageFlavorHelper.IS_TEST_FLAVOR) {
|
||||
"https://dev-and-static.ghzs66.com/page/comment_tag_editor/index.html?timestamp=${System.currentTimeMillis()}"
|
||||
} else {
|
||||
"https://resource.ghzs.com/page/comment_tag_editor/index.html?timestamp=${System.currentTimeMillis()}"
|
||||
"https://and-static.ghzs66.com/page/comment_tag_editor/index.html?timestamp=${System.currentTimeMillis()}"
|
||||
}
|
||||
mBinding.mWebView.loadUrl(url)
|
||||
}
|
||||
|
||||
@ -168,10 +168,8 @@ class CustomHomeItemGameTestV2ViewHolder(
|
||||
} else {
|
||||
RIGHT_TEXT_MORE
|
||||
}
|
||||
if (tvRight.text.isBlank()) {
|
||||
tvRight.text = rightText
|
||||
}
|
||||
|
||||
tvRight.text = rightText
|
||||
tvRight.setOnClickListener {
|
||||
if (data.rightTop.text == ALL) {
|
||||
NewFlatLogUtils.logGameTestV2MoreClick(rightText, "自定义页面")
|
||||
|
||||
@ -7,6 +7,7 @@ import com.gh.gamecenter.feature.entity.GameInstall
|
||||
import com.gh.gamecenter.entity.GameUpdateEntity
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
import kotlin.collections.HashSet
|
||||
|
||||
/**
|
||||
* todo 整理部分与[PackageUtils]冲突的方法
|
||||
@ -15,14 +16,13 @@ object PackagesManager {
|
||||
|
||||
// 存在网络延迟
|
||||
private var mUpdateAndPluginList = ArrayList<GameUpdateEntity>()
|
||||
private val mInstalledList = ArrayList<GameInstall>()
|
||||
private var mInstalledList = ArrayList<GameInstall>()
|
||||
|
||||
// 实时更新(已安装到本地的包名列表,不包括畅玩游戏)
|
||||
private val mInstalledPkgList = Collections.synchronizedList(ArrayList<String>())
|
||||
private var mInstalledPkgSet = HashSet<String>()
|
||||
|
||||
fun initInstallPkgList(list: List<String>) {
|
||||
mInstalledPkgList.clear()
|
||||
mInstalledPkgList.addAll(list)
|
||||
fun initInstallPkgSet(set: Set<String>) {
|
||||
mInstalledPkgSet = HashSet(set)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,8 +41,7 @@ object PackagesManager {
|
||||
* @param list 已安装列表数据
|
||||
*/
|
||||
fun initGameInstall(list: ArrayList<GameInstall>) {
|
||||
mInstalledList.clear()
|
||||
mInstalledList.addAll(list)
|
||||
mInstalledList = ArrayList(list)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,9 +85,11 @@ object PackagesManager {
|
||||
return false
|
||||
}
|
||||
|
||||
return mInstalledPkgList.contains(packageName)
|
||||
return mInstalledPkgSet.contains(packageName)
|
||||
}
|
||||
|
||||
fun getInstalledSet(): MutableSet<String> = HashSet(mInstalledPkgSet)
|
||||
|
||||
/**
|
||||
* 根据包名版本号判断是否已安装相应版本的应用
|
||||
*
|
||||
|
||||
@ -1,12 +1,14 @@
|
||||
package com.gh.gamecenter.packagehelper
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.common.utils.toRequestBody
|
||||
import com.gh.gamecenter.common.utils.tryWithDefaultCatch
|
||||
import com.gh.gamecenter.entity.PackageFilter
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.room.AppDatabase
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
object PackageFilterManager {
|
||||
@ -77,11 +79,20 @@ object PackageFilterManager {
|
||||
if (appendOnly) {
|
||||
mPendingPackageNameSet.addAll(packageList)
|
||||
} else {
|
||||
if (exception is retrofit2.HttpException && exception.code() == 403) {
|
||||
// 403 代表 key 过期,需要重新获取
|
||||
callbackClosure?.invoke(arrayListOf())
|
||||
return
|
||||
}
|
||||
|
||||
// 接口访问失败时从数据库读取上一次缓存的已安装收录列表进行更新
|
||||
val packageEntityList =
|
||||
AppDatabase.getInstance().packageFilterDao().getAllPackageName()
|
||||
for (packageEntity in packageEntityList) {
|
||||
mValidPackageNameSet.add(packageEntity.packageName)
|
||||
// 依然为已安装状态才加入到有效包名列表中
|
||||
if (PackageUtils.isInstalled(HaloApp.getInstance(), packageEntity.packageName)) {
|
||||
mValidPackageNameSet.add(packageEntity.packageName)
|
||||
}
|
||||
}
|
||||
|
||||
callbackClosure?.invoke(ArrayList(mValidPackageNameSet))
|
||||
|
||||
@ -16,23 +16,27 @@ import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.common.retrofit.ObservableUtil
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.common.utils.secondOrNull
|
||||
import com.gh.gamecenter.common.utils.toArrayList
|
||||
import com.gh.gamecenter.common.utils.tryCatchInRelease
|
||||
import com.gh.gamecenter.core.runOnIoThread
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.entity.*
|
||||
import com.gh.gamecenter.eventbus.EBPackage
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.entity.GameInstall
|
||||
import com.gh.gamecenter.livedata.Event
|
||||
import com.gh.gamecenter.manager.PackagesManager
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.vspace.VHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import java.util.*
|
||||
import kotlin.collections.HashSet
|
||||
|
||||
/**
|
||||
* 该类存储的是已安装的所有游戏(助手后台已收录的)和所有更新(包括插件化)数据
|
||||
@ -54,10 +58,12 @@ object PackageRepository {
|
||||
private const val LAST_UPLOAD_APPLIST_TIME = "last_upload_applist_time"
|
||||
private const val PAGE_SIZE = 50
|
||||
|
||||
private val mInstalledPkgList = Collections.synchronizedList(ArrayList<String>())
|
||||
private val mInstalledPkgSet = Collections.synchronizedSet(HashSet<String>())
|
||||
|
||||
@Volatile
|
||||
private var mIsInitialisingData = false
|
||||
var installedPkgRefreshed = false
|
||||
var vaPkgRefreshed = false
|
||||
|
||||
val gameUpdateLiveData = MutableLiveData<List<GameUpdateEntity>>()
|
||||
val gameInstalledLiveData = MutableLiveData<List<GameInstall>>()
|
||||
@ -82,11 +88,14 @@ object PackageRepository {
|
||||
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 (mInstalledPkgList.isNotEmpty()) mInstalledPkgList.clear()
|
||||
if (mInstalledPkgSet.isNotEmpty()) mInstalledPkgSet.clear()
|
||||
|
||||
val list = PackageUtils.getAllPackageName(mApplication)
|
||||
|
||||
@ -95,13 +104,38 @@ object PackageRepository {
|
||||
initFilterPackage(list) { filteredList ->
|
||||
mIsInitialisingData = false
|
||||
|
||||
mInstalledPkgList.addAll(filteredList)
|
||||
mInstalledPkgSet.addAll(filteredList)
|
||||
notifyInstallPkgData()
|
||||
|
||||
loadInstalledGameDigestAndNotifyData(filteredList)
|
||||
loadInstalledGameDigestAndNotifyData(filteredList) {
|
||||
installedPkgRefreshed = true
|
||||
mIsInitialisingData = !(installedPkgRefreshed && vaPkgRefreshed)
|
||||
}
|
||||
}
|
||||
|
||||
loadGhzsUpdate()
|
||||
|
||||
// 畅玩游戏更新
|
||||
var allGames = VHelper.getAllVGameSnapshots()
|
||||
if (allGames.isNullOrEmpty()) {
|
||||
VHelper.refreshVGameSnapshot()
|
||||
allGames = VHelper.getAllVGameSnapshots()
|
||||
}
|
||||
val allGamePkgNames = allGames.map { it.packageName }.toArrayList()
|
||||
if (allGamePkgNames.isNotEmpty()) {
|
||||
notifyInstallPkgData()
|
||||
updateFilterPackage(allGamePkgNames) {
|
||||
Utils.log("xxx", "PackageRepository::filteredList::${allGamePkgNames}")
|
||||
loadInstalledGameDigestAndNotifyData(
|
||||
filteredList = allGamePkgNames,
|
||||
onWorkerThreadOnly = false,
|
||||
isVGame = true
|
||||
) {
|
||||
vaPkgRefreshed = true
|
||||
mIsInitialisingData = !(installedPkgRefreshed && vaPkgRefreshed)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,7 +168,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<AppEntity>() {
|
||||
@ -203,12 +238,15 @@ object PackageRepository {
|
||||
* @param filteredList 已安装的游戏包名集合 (仅已收录部分)
|
||||
* @param onWorkerThreadOnly 是否在工作线程执行
|
||||
* @param isVGame 包名列表是否为畅玩游戏
|
||||
* @param updateInstallStatus 更新安装状态 (通过 EventBus 来进行)
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
private fun loadInstalledGameDigestAndNotifyData(
|
||||
filteredList: ArrayList<String>,
|
||||
onWorkerThreadOnly: Boolean = false,
|
||||
isVGame: Boolean = false,
|
||||
updateInstallStatus: Boolean = false,
|
||||
loadFinishCallback: (() -> Unit)? = null
|
||||
) {
|
||||
var isNotifyUpdate = false
|
||||
val maxPageCount = (filteredList.size / PAGE_SIZE) + 1
|
||||
@ -217,6 +255,7 @@ object PackageRepository {
|
||||
val latch = ObservableUtil.latch(maxPageCount, {
|
||||
if (isNotifyUpdate || gameUpdateLiveData.value == null) notifyGameUpdateData()
|
||||
notifyGameInstallData()
|
||||
loadFinishCallback?.invoke()
|
||||
}, Any())
|
||||
|
||||
while (++page <= maxPageCount) {
|
||||
@ -243,9 +282,7 @@ object PackageRepository {
|
||||
|
||||
for (game in validGames) {
|
||||
if (gh_id == null || gh_id == game.id) {
|
||||
gameInstalled.add(
|
||||
GameInstall.transformGameInstall(game, pkgName, isVGame)
|
||||
)
|
||||
gameInstalled.add(GameInstall.transformGameInstall(game, pkgName, isVGame))
|
||||
mInstalledGameList.add(game)
|
||||
val isCanPluggable = checkGamePlugin(game, pkgName)
|
||||
val isCanUpdate = checkGameUpdate(game, isVGame)
|
||||
@ -253,6 +290,10 @@ object PackageRepository {
|
||||
if (!isNotifyUpdate && isCanUpdate || isCanPluggable) {
|
||||
isNotifyUpdate = true
|
||||
}
|
||||
|
||||
if (updateInstallStatus) {
|
||||
EventBus.getDefault().post(EBPackage(EBPackage.TYPE_INSTALLED, pkgName, game.getApk().firstOrNull()?.version))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -400,14 +441,18 @@ object PackageRepository {
|
||||
* 新增已安装的游戏
|
||||
* @param pkgName 已安装的游戏包名
|
||||
*/
|
||||
fun addInstalledGame(pkgName: String) {
|
||||
mInstalledPkgList.add(pkgName)
|
||||
fun addInstalledGame(pkgName: String, updateInstallStatus: Boolean = false) {
|
||||
mInstalledPkgSet.add(pkgName)
|
||||
notifyInstallPkgData()
|
||||
|
||||
val list = arrayListOf(pkgName)
|
||||
|
||||
updateFilterPackage(list) {
|
||||
loadInstalledGameDigestAndNotifyData(list, true)
|
||||
loadInstalledGameDigestAndNotifyData(
|
||||
filteredList = list,
|
||||
onWorkerThreadOnly = true,
|
||||
updateInstallStatus = updateInstallStatus
|
||||
)
|
||||
}
|
||||
changeRecentVaPlayed()
|
||||
}
|
||||
@ -415,18 +460,29 @@ object PackageRepository {
|
||||
/**
|
||||
* 批量新增已安装的游戏数量
|
||||
* @param pkgNameList 数组列表
|
||||
* @param isVGame 是否为畅玩游戏
|
||||
* @param updateInstallStatus 是否更新安装状态
|
||||
*/
|
||||
fun addInstalledGames(pkgNameList: ArrayList<String>, isVGame: Boolean = false) {
|
||||
fun addInstalledGames(pkgNameList: ArrayList<String>,
|
||||
isVGame: Boolean = false,
|
||||
updateInstallStatus: Boolean = false,
|
||||
) {
|
||||
// 畅玩游戏不添加至本地的已安装包名列表中
|
||||
if (!isVGame) {
|
||||
mInstalledPkgList.addAll(pkgNameList)
|
||||
mInstalledPkgSet.addAll(pkgNameList)
|
||||
} else {
|
||||
changeRecentVaPlayed()
|
||||
}
|
||||
notifyInstallPkgData()
|
||||
|
||||
updateFilterPackage(pkgNameList) {
|
||||
loadInstalledGameDigestAndNotifyData(pkgNameList, true, isVGame)
|
||||
loadInstalledGameDigestAndNotifyData(
|
||||
filteredList = pkgNameList,
|
||||
onWorkerThreadOnly = true,
|
||||
isVGame = isVGame,
|
||||
updateInstallStatus = updateInstallStatus
|
||||
)
|
||||
}
|
||||
changeRecentVaPlayed()
|
||||
}
|
||||
|
||||
/**
|
||||
@ -435,9 +491,8 @@ object PackageRepository {
|
||||
* @param isVGame 是否来自于畅玩游戏
|
||||
*/
|
||||
fun addUninstalledGame(pkgName: String, isVGame: Boolean) {
|
||||
// TODO 检查为什么会有两个相同的包名添加到 mInstalledPkgList 里
|
||||
if (!isVGame && mInstalledPkgList.isNotEmpty()) {
|
||||
mInstalledPkgList.removeAll { it == pkgName }
|
||||
if (!isVGame && mInstalledPkgSet.isNotEmpty()) {
|
||||
mInstalledPkgSet.remove(pkgName)
|
||||
}
|
||||
// 尝试从临时的当前版本列表里移除已卸载的条目
|
||||
tryCatchInRelease {
|
||||
@ -493,7 +548,14 @@ object PackageRepository {
|
||||
}
|
||||
|
||||
private fun notifyInstallPkgData() {
|
||||
PackagesManager.initInstallPkgList(mInstalledPkgList)
|
||||
val pkgSet = hashSetOf<String>()
|
||||
|
||||
val iterator = mInstalledPkgSet.iterator()
|
||||
while (iterator.hasNext()) {
|
||||
pkgSet.add(iterator.next())
|
||||
}
|
||||
|
||||
PackagesManager.initInstallPkgSet(pkgSet)
|
||||
}
|
||||
|
||||
}
|
||||
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ import com.gh.gamecenter.room.AppDatabase
|
||||
import com.gh.gamecenter.setting.SettingBridge
|
||||
import com.gh.gamecenter.wrapper.MainWrapperFragment
|
||||
import com.gh.gamecenter.wrapper.MainWrapperViewModel
|
||||
import com.gh.vspace.IExternalGamesUsage
|
||||
import com.gh.vspace.ITestCase
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.jakewharton.rxbinding2.view.RxView
|
||||
@ -695,7 +695,11 @@ class HaloPersonalFragment : BaseLazyFragment() {
|
||||
(try {
|
||||
Class.forName("com.gh.vspace.ExternalGameUsage")?.newInstance()
|
||||
} catch (e: Exception) {
|
||||
} as? IExternalGamesUsage)?.addInstallExternalGameButton(mStubBinding.otherItems)
|
||||
} as? ITestCase)?.apply {
|
||||
addInstallExternalGameButton(mStubBinding.otherItems)
|
||||
addInstallPluginButton(mStubBinding.otherItems)
|
||||
addInstallPlugin32Button(mStubBinding.otherItems)
|
||||
}
|
||||
}
|
||||
|
||||
mStubBinding.settingItem.run {
|
||||
|
||||
@ -90,9 +90,6 @@ class UserHomeFragment : ToolbarFragment() {
|
||||
getUserInfo()
|
||||
getBadgeList()
|
||||
getUserPlayedGameCount()
|
||||
if (PackageFlavorHelper.IS_TEST_FLAVOR) {
|
||||
getUserLevel()
|
||||
}
|
||||
}
|
||||
|
||||
mHomeBinding?.container?.setZoomView(mHomeBinding?.userBackgroundContainer)
|
||||
@ -167,38 +164,12 @@ class UserHomeFragment : ToolbarFragment() {
|
||||
if (mUserHomeViewModel.userId == UserManager.getInstance().userId) {
|
||||
mUserHomeViewModel.availableBadges()
|
||||
}
|
||||
|
||||
|
||||
// if (mUserHomeViewModel.userId == UserManager.getInstance().userId) {
|
||||
// mUserHomeViewModel.availableBadges()
|
||||
// } else {
|
||||
// mHomeBinding?.userBadgeTips?.visibility = View.VISIBLE
|
||||
// if (it.isNotEmpty()) {
|
||||
// mHomeBinding?.userBadge?.visibility = View.VISIBLE
|
||||
// updateUserBadge(it)
|
||||
// } else {
|
||||
// mHomeBinding?.userBadge?.visibility = View.GONE
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
mUserHomeViewModel.availableBadgeCount.observeNonNull(this) {
|
||||
mHomeBinding?.badgeTips?.visibility = if (it > 0) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
// mUserHomeViewModel.availableBadgeCount.observeNonNull(this) {
|
||||
// mHomeBinding?.viewBadgeMessageTip?.visibleIf(it > 0)
|
||||
// if (mUserHomeViewModel.badges.value?.isEmpty() == true && it > 0) {
|
||||
// mHomeBinding?.userBadgeList?.visibility = View.INVISIBLE
|
||||
// mHomeBinding?.userBadgeTips?.visibility = View.VISIBLE
|
||||
// mHomeBinding?.userBadgeTips?.text = "有${it}枚徽章可领取"
|
||||
// } else if (mUserHomeViewModel.badges.value?.isEmpty() == false) {
|
||||
// mHomeBinding?.userBadgeList?.visibility = View.VISIBLE
|
||||
// mHomeBinding?.userBadgeTips?.visibility = View.GONE
|
||||
// updateUserBadge(mUserHomeViewModel.badges.value!!)
|
||||
// }
|
||||
// }
|
||||
|
||||
mUserHomeViewModel.networkError.observeNonNull(this) {
|
||||
mHomeBinding?.container?.visibility = View.GONE
|
||||
mHomeBinding?.reuseNoConnection?.root?.visibility = View.VISIBLE
|
||||
@ -214,28 +185,10 @@ class UserHomeFragment : ToolbarFragment() {
|
||||
mPlayGameCount = it
|
||||
})
|
||||
|
||||
mUserHomeViewModel.level.observeNonNull(this) {
|
||||
mHomeBinding?.run {
|
||||
levelContainer.visibility = View.VISIBLE
|
||||
levelContainer.setOnClickListener {
|
||||
if (mUserHomeViewModel.userId == UserManager.getInstance().userId) {
|
||||
IntegralLogHelper.run {
|
||||
log("click_grade_label", LOCATION)
|
||||
log("view_grade", "等级中心页")
|
||||
}
|
||||
DirectUtils.directToLevelPage(requireContext())
|
||||
}
|
||||
}
|
||||
val levelNum = if (it > 9) 9 else it
|
||||
levelTv.text = "Lv$levelNum "
|
||||
}
|
||||
}
|
||||
|
||||
mMessageUnreadViewModel.liveData.observeNonNull(this) {
|
||||
updateUnreadInfo(it)
|
||||
}
|
||||
|
||||
|
||||
mUserViewModel.editObsUserinfo.observeNonNull(this) {
|
||||
it.data?.let { updatedUserInfo ->
|
||||
if (mUserHomeViewModel.userId == UserManager.getInstance().userId) {
|
||||
@ -542,7 +495,6 @@ class UserHomeFragment : ToolbarFragment() {
|
||||
|
||||
// 跳转更换背景页
|
||||
userChangeBgBtn.setOnClickListener {
|
||||
IntegralLogHelper.log("click_change _background", LOCATION)
|
||||
SPUtils.setBoolean(Constants.SP_HAS_CLICK_CHANGE_BG, false)
|
||||
changeBgTips.visibility = View.GONE
|
||||
startActivity(PersonalityBackgroundActivity.getIntent(requireContext()))
|
||||
|
||||
@ -33,7 +33,6 @@ class UserHomeViewModel(application: Application, var userId: String) : AndroidV
|
||||
var availableBadge = MutableLiveData<BadgeEntity>()
|
||||
var availableBadgeCount = MutableLiveData<Int>()
|
||||
var playGamesCount = MutableLiveData<Int>()
|
||||
var level = MutableLiveData<Int>()
|
||||
|
||||
fun getUserInfo() {
|
||||
RetrofitManager.getInstance()
|
||||
@ -133,19 +132,6 @@ class UserHomeViewModel(application: Application, var userId: String) : AndroidV
|
||||
})
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun getUserLevel() {
|
||||
RetrofitManager.getInstance()
|
||||
.api.getUserLevels(userId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<JsonObject>() {
|
||||
override fun onSuccess(data: JsonObject) {
|
||||
level.postValue(data["level"].asInt)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun postReport(reason: String, desc: String) {
|
||||
val requestMap = hashMapOf<String, String>()
|
||||
|
||||
@ -56,13 +56,13 @@ object ArticleDetailWebCacheManager {
|
||||
}
|
||||
|
||||
val cacheUrlList = mutableListOf(
|
||||
"https://static-web.ghzs.com/website-static/lib/polyfill.min.js",
|
||||
"https://and-static.ghzs.com/web/dplayer/DPlayer.min.js"
|
||||
"https://and-static.ghzs66.com/web/website-static/lib/polyfill.min.js",
|
||||
"https://and-static.ghzs66.com/web/dplayer/DPlayer.min.js"
|
||||
)
|
||||
|
||||
if (!EnvHelper.isDevEnv) {
|
||||
cacheUrlList.add("https://resource.ghzs.com/js/halo.js")
|
||||
cacheUrlList.add("https://resource.ghzs.com/css/halo.css")
|
||||
cacheUrlList.add("https://and-static.ghzs66.com/web/js/halo.js")
|
||||
cacheUrlList.add("https://and-static.ghzs66.com/web/css/halo.css")
|
||||
}
|
||||
|
||||
val okHttpClient = OkHttpClient.Builder()
|
||||
@ -73,7 +73,7 @@ object ArticleDetailWebCacheManager {
|
||||
|
||||
val retrofit = Retrofit.Builder()
|
||||
.client(okHttpClient)
|
||||
.baseUrl("https://resource.ghzs.com")
|
||||
.baseUrl("https://and-static.ghzs66.com")
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||
.build()
|
||||
|
||||
@ -27,7 +27,7 @@ class EditorInsertEntity(
|
||||
entity.type = "answer"
|
||||
entity.title = answer.questions.title?.eliminateDoubleQuote()
|
||||
entity.brief = answer.brief?.eliminateDoubleQuote()
|
||||
entity.icon = "http://static-web.ghzs.com/website-static/images/icon_new_reply.png"
|
||||
entity.icon = "https://and-static.ghzs66.com/web/website-static/images/icon_new_reply.png"
|
||||
return entity
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ class EditorInsertEntity(
|
||||
entity.type = "community_article"
|
||||
entity.title = article.title.eliminateDoubleQuote()
|
||||
entity.brief = article.brief.eliminateDoubleQuote()
|
||||
entity.icon = "http://static-web.ghzs.com/website-static/images/icon_new_article.png"
|
||||
entity.icon = "https://and-static.ghzs66.com/web/website-static/images/icon_new_article.png"
|
||||
return entity
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ class EditorInsertEntity(
|
||||
entity.type = "game_collection"
|
||||
entity.title = game.title
|
||||
entity.brief = game.intro
|
||||
entity.icon = "https://static-web.ghzs.com/website-static/images/icon_game_collection.png"
|
||||
entity.icon = "https://and-static.ghzs66.com/web/website-static/images/icon_game_collection.png"
|
||||
return entity
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ class EditorInsertEntity(
|
||||
entity.type = "video"
|
||||
entity.title = video.title
|
||||
entity.brief = video.des
|
||||
entity.icon = "https://static-web.ghzs.com/website-static/images/icon_video.png"
|
||||
entity.icon = "https://and-static.ghzs66.com/web/website-static/images/icon_video.png"
|
||||
return entity
|
||||
}
|
||||
}
|
||||
|
||||
@ -408,7 +408,7 @@ class ForumTopVideoView @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
shareUrl = if (isPublishEnv()) {
|
||||
"https://m.ghzs666.com/video/${it.id}"
|
||||
} else {
|
||||
"https://resource.ghzs.com/page/video_play/video/video.html?video=${it.id}"
|
||||
"https://dev-and-static.ghzs66.com/page/video_play/video/video.html?video=${it.id}"
|
||||
},
|
||||
shareIcon = it.poster,
|
||||
shareTitle = it.title,
|
||||
|
||||
@ -16,11 +16,11 @@ import com.gh.gamecenter.common.utils.NewFlatLogUtils;
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge;
|
||||
import com.gh.gamecenter.core.AppExecutor;
|
||||
import com.gh.gamecenter.core.utils.SPUtils;
|
||||
import com.gh.gamecenter.entity.NewApiSettingsEntity;
|
||||
import com.gh.gamecenter.eventbus.EBPackage;
|
||||
import com.gh.gamecenter.feature.entity.GameInstall;
|
||||
import com.gh.gamecenter.install.InstallService;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.gh.ndownload.NDownloadService;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.utils.Utils;
|
||||
@ -29,21 +29,26 @@ import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
/**
|
||||
* 监听应用安装和卸载的广播
|
||||
*
|
||||
* @author LGT 黄壮华
|
||||
* 监听安装包变更
|
||||
*/
|
||||
public class InstallAndUninstallReceiver extends BroadcastReceiver {
|
||||
public class PackageChangeBroadcastReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final String TAG = "PackageChangeBroadcastReceiver";
|
||||
|
||||
private static final String webviewPackageName = "com.google.android.webview";
|
||||
|
||||
private final NewApiSettingsEntity.PackageObserveActions mActions;
|
||||
|
||||
public PackageChangeBroadcastReceiver(NewApiSettingsEntity.PackageObserveActions actions) {
|
||||
mActions = actions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
PackageUtils.dumpInstalledListCache();
|
||||
PackageHelper.INSTANCE.dumpInstalledListCache();
|
||||
ExtensionsKt.doOnMainProcessOnly(() -> {
|
||||
Utils.log("InstallAndUninstallReceiver:: onReceive->" + intent.getAction() + "==" + intent.getDataString());
|
||||
Utils.log(TAG, "onReceive->" + intent.getAction() + "==" + intent.getDataString());
|
||||
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.TIRAMISU
|
||||
&& Build.MANUFACTURER.toLowerCase(Locale.CHINA).contains("xiaomi")) {
|
||||
@ -53,10 +58,10 @@ public class InstallAndUninstallReceiver extends BroadcastReceiver {
|
||||
}
|
||||
|
||||
// 接收安装广播
|
||||
if (intent.getAction().equals(Intent.ACTION_PACKAGE_ADDED)) {
|
||||
if (intent.getAction().equals(mActions.getAdd())) {
|
||||
String packageName = intent.getDataString();
|
||||
packageName = packageName.substring(packageName.indexOf(":") + 1);
|
||||
Utils.log("安装了:" + packageName + "包名的程序");
|
||||
Utils.log(TAG, "安装了:" + packageName + "包名的程序");
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshotByPackageName(packageName);
|
||||
String gameId = downloadEntity != null && downloadEntity.getGameId() != null ? downloadEntity.getGameId() : "";
|
||||
String gameName = downloadEntity != null && downloadEntity.getName() != null ? downloadEntity.getName() : "";
|
||||
@ -84,10 +89,10 @@ public class InstallAndUninstallReceiver extends BroadcastReceiver {
|
||||
}
|
||||
|
||||
// 接收卸载广播
|
||||
if (intent.getAction().equals(Intent.ACTION_PACKAGE_REMOVED)) {
|
||||
if (intent.getAction().equals(mActions.getRem())) {
|
||||
String packageName = intent.getDataString();
|
||||
packageName = packageName.substring(packageName.indexOf(":") + 1);
|
||||
Utils.log("卸载了:" + packageName + "包名的程序");
|
||||
Utils.log(TAG, "卸载了:" + packageName + "包名的程序");
|
||||
GameInstall install = PackagesManager.getInstalledData(packageName);
|
||||
String gameId = install != null && install.getId() != null ? install.getId() : "";
|
||||
String gameName = install != null && install.getName() != null ? install.getName() : "";
|
||||
@ -107,10 +112,10 @@ public class InstallAndUninstallReceiver extends BroadcastReceiver {
|
||||
}
|
||||
|
||||
// 接收替换广播
|
||||
if (intent.getAction().equals(Intent.ACTION_PACKAGE_REPLACED)) {
|
||||
if (intent.getAction().equals(mActions.getRep())) {
|
||||
String packageName = intent.getData().getSchemeSpecificPart();
|
||||
packageName = packageName.substring(packageName.indexOf(":") + 1);
|
||||
Utils.log("替换了:" + packageName + "包名的程序");
|
||||
Utils.log(TAG, "替换了:" + packageName + "包名的程序");
|
||||
String versionName = PackageUtils.getVersionNameByPackageName(packageName);
|
||||
|
||||
EBPackage updateEb = new EBPackage(EBPackage.TYPE_REPLACED, packageName, versionName);
|
||||
@ -93,6 +93,7 @@ import com.gh.gamecenter.entity.VideoDraftEntity;
|
||||
import com.gh.gamecenter.entity.VideoEntity;
|
||||
import com.gh.gamecenter.entity.VideoTagEntity;
|
||||
import com.gh.gamecenter.entity.VoteEntity;
|
||||
import com.gh.gamecenter.entity.WhitePackageListEntity;
|
||||
import com.gh.gamecenter.feature.entity.AnswerEntity;
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity;
|
||||
import com.gh.gamecenter.feature.entity.ArticleDraftEntity;
|
||||
@ -784,6 +785,9 @@ public interface ApiService {
|
||||
@Query("systemVersion") int systemVersion,
|
||||
@Query("ghVersion") String ghVersion);
|
||||
|
||||
@GET("/settings/game_installed/whitelist")
|
||||
Single<WhitePackageListEntity> getInstallWhitelist();
|
||||
|
||||
/**
|
||||
* 给一个回答新增评论
|
||||
*/
|
||||
@ -2287,12 +2291,6 @@ public interface ApiService {
|
||||
@POST("users/{user_id}:report")
|
||||
Single<ResponseBody> reportUser(@Path("user_id") String userId, @Body RequestBody body);
|
||||
|
||||
/**
|
||||
* 获取用户等级
|
||||
*/
|
||||
@GET("users/{user_id}/levels")
|
||||
Single<JsonObject> getUserLevels(@Path("user_id") String userId);
|
||||
|
||||
/**
|
||||
* 获取新分类2.0侧边栏
|
||||
*/
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
package com.gh.gamecenter.retrofit.service
|
||||
|
||||
import com.gh.gamecenter.entity.AppEntity
|
||||
import com.gh.gamecenter.entity.VNewSetting
|
||||
import com.gh.gamecenter.entity.VSetting
|
||||
import io.reactivex.Single
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Header
|
||||
import retrofit2.http.Query
|
||||
|
||||
interface VApiService {
|
||||
@ -24,4 +26,16 @@ interface VApiService {
|
||||
@GET("setting")
|
||||
fun getSettings(@Query("version") version: String?, @Query("android") androidSdkVersion: Int): Single<VSetting>
|
||||
|
||||
@GET("new/setting")
|
||||
fun getNewSettings(
|
||||
@Query("version") version: String?,
|
||||
@Query("android") androidSdkVersion: Int,
|
||||
): Single<VNewSetting>
|
||||
|
||||
@GET("new/upgrade")
|
||||
fun getNewPackageUpdate(
|
||||
@Query("version") version: String?,
|
||||
@Query("va_version") vaVersion: String?,
|
||||
@Query("channel") channel: String,
|
||||
): Single<AppEntity>
|
||||
}
|
||||
@ -148,6 +148,8 @@ class SearchGameIndexFragment : ListFragment<GameEntity, SearchGameResultViewMod
|
||||
super.onResume()
|
||||
|
||||
DownloadManager.getInstance().addObserver(dataWatcher)
|
||||
|
||||
mListViewModel.refreshWrongInstallStatus()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
||||
@ -331,6 +331,8 @@ open class SearchGameResultFragment : ListFragment<GameEntity, SearchGameResultV
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
DownloadManager.getInstance().addObserver(dataWatcher)
|
||||
|
||||
mListViewModel.refreshWrongInstallStatus()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
||||
@ -6,6 +6,7 @@ import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.gh.ad.AdDelegateHelper
|
||||
import com.gh.common.filter.RegionSettingHelper
|
||||
import com.gh.common.util.PackageHelper
|
||||
import com.gh.gamecenter.SearchActivity
|
||||
import com.gh.gamecenter.common.base.GlobalActivityManager
|
||||
import com.gh.gamecenter.common.baselist.ListViewModel
|
||||
@ -45,6 +46,8 @@ class SearchGameResultViewModel(
|
||||
private var mAdPositionSet: HashSet<Int>? = null
|
||||
private val mAdGameMap = ConcurrentHashMap<String, List<GameEntity>>()
|
||||
|
||||
private var mPackageNameSet = hashSetOf<String>()
|
||||
|
||||
fun updateSearchKeyWithType(searchKey: String, searchType: String) {
|
||||
mSearchKey = searchKey
|
||||
mSearchType = searchType
|
||||
@ -67,6 +70,18 @@ class SearchGameResultViewModel(
|
||||
SearchItemData(game = game, isFirst = index == 0)
|
||||
}
|
||||
)
|
||||
|
||||
mPackageNameSet = hashSetOf()
|
||||
|
||||
// 添加所有出现的游戏包名
|
||||
list.forEach {
|
||||
it.getApk().forEach { apk ->
|
||||
mPackageNameSet.add(apk.packageName)
|
||||
}
|
||||
}
|
||||
|
||||
refreshWrongInstallStatus()
|
||||
|
||||
repository.getSearchSubject(mSearchKey, mPage)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -167,6 +182,12 @@ class SearchGameResultViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
fun refreshWrongInstallStatus() {
|
||||
if (mPackageNameSet.isNotEmpty()) {
|
||||
PackageHelper.refreshWrongInstallStatus(mPackageNameSet)
|
||||
}
|
||||
}
|
||||
|
||||
private fun decorateListWithThirdPartyAdOnly(
|
||||
decoratedItemDataList: ArrayList<SearchItemData>,
|
||||
thirdPartyAdList: List<AdConfig>,
|
||||
|
||||
@ -5,8 +5,8 @@ import android.app.Application
|
||||
import android.content.pm.PackageManager
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.simulator.SimulatorGameManager
|
||||
import com.gh.common.util.PackageHelper
|
||||
import com.gh.gamecenter.common.utils.NetworkUtils
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.gamecenter.common.baselist.ListViewModel
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity
|
||||
import com.gh.gamecenter.feature.entity.SimulatorEntity
|
||||
@ -56,7 +56,7 @@ class SimulatorManagementViewModel(application: Application) :
|
||||
return Single.create<List<SimulatorEntity>> { emitter ->
|
||||
val simulatorEntityList = ArrayList<SimulatorEntity>()
|
||||
val allInstalledPackages =
|
||||
PackageUtils.getInstalledPackages(HaloApp.getInstance().application, PackageManager.GET_ACTIVITIES)
|
||||
PackageHelper.getInstalledPackages(HaloApp.getInstance().application, PackageManager.GET_ACTIVITIES)
|
||||
allInstalledPackages.forEach {
|
||||
if (it.packageName.contains("com.gh")) {
|
||||
val activityInfo =
|
||||
|
||||
@ -358,7 +358,7 @@ class DetailPlayerView @JvmOverloads constructor(context: Context, attrs: Attrib
|
||||
mBinding.censoringContainer.setOnClickListener {
|
||||
DirectUtils.directToWebView(
|
||||
context,
|
||||
"https://resource.ghzs.com/page/video_rule/video_rule.html",
|
||||
context.getString(R.string.upload_protocol_url),
|
||||
mEntrance
|
||||
)
|
||||
}
|
||||
|
||||
@ -3,12 +3,15 @@ package com.gh.gamecenter.wrapper
|
||||
import android.graphics.PorterDuff
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
import androidx.annotation.ColorRes
|
||||
import androidx.constraintlayout.widget.ConstraintSet
|
||||
import androidx.core.text.color
|
||||
import androidx.core.view.doOnNextLayout
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||
import com.gh.common.util.PackageHelper
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.ShellActivity
|
||||
import com.gh.gamecenter.common.base.fragment.ToolbarFragment
|
||||
@ -77,6 +80,15 @@ class MainWrapperFragment : BaseBottomTabFragment<PieceBottomTabBinding>(), OnBa
|
||||
mViewModel?.realNameInfoUpdateLiveData?.observe(viewLifecycleOwner) {
|
||||
updateRealNameErrorContainer()
|
||||
}
|
||||
|
||||
PackageHelper.installedPackageApiSwitchStatusLiveData.observe(viewLifecycleOwner) {
|
||||
if (it) {
|
||||
showInstallApiHintView(mBinding)
|
||||
SensorsBridge.trackInstalledListPermissionsDialogShow()
|
||||
} else {
|
||||
mBinding.installApiContainer.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setCurrentItem(page: Int) {
|
||||
@ -255,6 +267,39 @@ class MainWrapperFragment : BaseBottomTabFragment<PieceBottomTabBinding>(), OnBa
|
||||
}
|
||||
}
|
||||
|
||||
private fun showInstallApiHintView(binding: FragmentMainBinding) {
|
||||
val contentText = SpannableStringBuilder()
|
||||
.color(R.color.text_theme.toColor(requireContext())) { append("您未授予已安装列表权限,可能") }
|
||||
.color(R.color.secondary_red.toColor(requireContext())) { append("导致无法安装及更新") }
|
||||
.color(R.color.text_theme.toColor(requireContext())) { append("建议开启权限!") }
|
||||
|
||||
binding.installApiContainer.visibility = View.VISIBLE
|
||||
binding.installApiContainer.setOnClickListener {
|
||||
// do nothing
|
||||
}
|
||||
binding.installApiCloseIv.enlargeTouchArea()
|
||||
binding.installApiContentTv.text = contentText
|
||||
binding.installApiCloseIv.setOnClickListener {
|
||||
binding.installApiContainer.visibility = View.GONE
|
||||
SensorsBridge.trackInstalledListPermissionsClick("关闭")
|
||||
}
|
||||
binding.installApiBtn.setOnClickListener {
|
||||
SensorsBridge.trackInstalledListPermissionsClick("去开启")
|
||||
|
||||
val callbackClosure: (Boolean) -> Unit = { isGranted ->
|
||||
if (isGranted) {
|
||||
binding.installApiContainer.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
PackageHelper.showGetInstallAppsListDialogAndRequestPermissionIfNeeded(
|
||||
activity = requireActivity(),
|
||||
ignorePermanentlyDenied = false,
|
||||
resultClosure = callbackClosure
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDarkModeChanged() {
|
||||
super.onDarkModeChanged()
|
||||
changeBottomTabStyle(mBinding.viewPager.currentItem)
|
||||
|
||||
@ -211,7 +211,7 @@ class MainWrapperRepository {
|
||||
// 如果有优先级更高的选中 tab id,则将优先级更高的选中 tab 设置为 default
|
||||
if (mHighPrioritySelectedTopTabId.isNotEmpty() && mHighPrioritySelectedNavId == multiTabNav?.id) {
|
||||
val selectedTab = multiTabNav.linkMultiTabNav.firstOrNull {
|
||||
it.link?.link == mHighPrioritySelectedTopTabId
|
||||
it.id == mHighPrioritySelectedTopTabId
|
||||
}
|
||||
|
||||
// 将优先级更高的选中 tab 设置为 default
|
||||
@ -225,7 +225,7 @@ class MainWrapperRepository {
|
||||
|
||||
defaultCustomPageId =
|
||||
multiTabNav?.linkMultiTabNav?.find { it.link?.type == ViewPagerFragmentHelper.TYPE_CUSTOM_PAGE && it.default }?.link?.link ?: ""
|
||||
multiTabNavLiveData.postValue(multiTabNav)
|
||||
multiTabNavLiveData.value = multiTabNav
|
||||
}
|
||||
|
||||
companion object : SingletonHolder<MainWrapperRepository>({ MainWrapperRepository() })
|
||||
|
||||
@ -13,6 +13,7 @@ import android.widget.ImageView
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import androidx.core.view.doOnLayout
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import com.gh.common.constant.Config
|
||||
@ -402,7 +403,9 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar
|
||||
val selectTab = it.getContentWithHandled()
|
||||
if (selectTab is MainSelectedEvent.SelectedTab) {
|
||||
if (selectTab.topTabIndex != -1) {
|
||||
mViewPager?.setCurrentItem(selectTab.topTabIndex, false)
|
||||
mViewPager?.doOnLayout {
|
||||
mViewPager?.setCurrentItem(selectTab.topTabIndex, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,8 +4,10 @@ import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public interface IExternalGamesUsage {
|
||||
public interface ITestCase {
|
||||
|
||||
void addInstallExternalGameButton(@NonNull ViewGroup viewParent);
|
||||
|
||||
void addInstallPluginButton(@NonNull ViewGroup viewParent);
|
||||
void addInstallPlugin32Button(@NonNull ViewGroup viewParent);
|
||||
}
|
||||
@ -2,8 +2,11 @@ package com.gh.vspace
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.database.sqlite.SQLiteDiskIOException
|
||||
import android.os.*
|
||||
import androidx.annotation.WorkerThread
|
||||
import com.blankj.utilcode.util.LogUtils
|
||||
import com.gh.download.simple.DownloadMessageHandler
|
||||
import com.gh.download.simple.SimpleDownloadManager
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
@ -22,7 +25,11 @@ import com.lg.download.DownloadStatus
|
||||
import com.lg.download.httpclient.DefaultHttpClient
|
||||
import com.lg.ndownload.DownloadConfigBuilder
|
||||
import com.lg.vspace.VirtualAppManager
|
||||
import com.lg.vspace.archive.data.Const
|
||||
import com.lg.vspace.archive.ui.ArchiveManager
|
||||
import com.lg.vspace.archive.ui.interfaces.ArchiveProgressPageListener
|
||||
import com.lightgame.utils.Utils
|
||||
import com.lody.virtual.client.core.VirtualCore
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.ResponseBody
|
||||
import java.io.File
|
||||
@ -43,6 +50,31 @@ object VArchiveHelper {
|
||||
// 本地存档存放的位置
|
||||
val archivePath by lazy { HaloApp.getInstance().filesDir.absolutePath + File.separator }
|
||||
|
||||
private var messenger: Messenger? = null
|
||||
private val handler = object : Handler(Looper.getMainLooper()) {
|
||||
override fun handleMessage(msg: Message) {
|
||||
when (msg.what) {
|
||||
Const.MSG_USE_ARCHIVE -> {
|
||||
msg.data?.let {
|
||||
onApplyGameArchiveFinished(
|
||||
packageName = it.getString(Const.EXTRA_PACKAGE_NAME, ""),
|
||||
isSuccess = it.getBoolean(Const.EXTRA_IS_SUCCESS, false)
|
||||
)
|
||||
}
|
||||
}
|
||||
Const.MSG_GENERATE_ARCHIVE -> {
|
||||
msg.data?.let {
|
||||
onSaveGameArchiveFinished(
|
||||
packageName = it.getString(Const.EXTRA_PACKAGE_NAME, ""),
|
||||
isSuccess = it.getBoolean(Const.EXTRA_IS_SUCCESS, false)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
messenger = null
|
||||
}
|
||||
}
|
||||
|
||||
fun init() {
|
||||
DownloadMessageHandler.registerGlobalStatusChangedListener { simpleDownloadEntity, downloadStatus ->
|
||||
when (downloadStatus) {
|
||||
@ -162,8 +194,26 @@ object VArchiveHelper {
|
||||
mSaveArchiveListener = saveArchiveListener
|
||||
// 记录最近一次创建的存档文件
|
||||
mLatestArchiveFile = archiveFile
|
||||
val intent = VirtualAppManager.getGenerateArchiveIntent(context, config, packageName, archiveFile)
|
||||
context.startActivity(intent)
|
||||
if (VHelper.isLegacyInstalled(packageName)) {
|
||||
val intent = VirtualAppManager.getGenerateArchiveIntent(context, config, packageName, archiveFile)
|
||||
context.startActivity(intent)
|
||||
} else {
|
||||
if (VirtualCore.get().isRunInExtProcess(packageName)) {
|
||||
val intent = VirtualAppManager.getGenerateArchiveIntent(context, config, packageName, archiveFile)
|
||||
prepareExtIntent(intent)
|
||||
context.startActivity(intent)
|
||||
} else {
|
||||
ArchiveManager.generatePackage(context, packageName, config, archiveFile,
|
||||
object : ArchiveProgressPageListener {
|
||||
override fun onCancel() {
|
||||
}
|
||||
|
||||
override fun completed(isSuccess: Boolean) {
|
||||
onSaveGameArchiveFinished(packageName, isSuccess)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -179,8 +229,43 @@ object VArchiveHelper {
|
||||
applyArchiveListener: ((String, Boolean) -> Unit)? = null
|
||||
) {
|
||||
mApplyArchiveListener = applyArchiveListener
|
||||
val intent = VirtualAppManager.getUseArchiveIntent(context, packageName, config, archiveFile)
|
||||
context.startActivity(intent)
|
||||
if (VHelper.isLegacyInstalled(packageName)) {
|
||||
val intent = VirtualAppManager.getUseArchiveIntent(context, packageName, config, archiveFile)
|
||||
context.startActivity(intent)
|
||||
} else {
|
||||
if (VirtualCore.get().isRunInExtProcess(packageName)) {
|
||||
val intent = VirtualAppManager.getUseArchiveIntent(context, packageName, config, archiveFile)
|
||||
prepareExtIntent(intent)
|
||||
context.startActivity(intent)
|
||||
} else {
|
||||
ArchiveManager.useArchive(context, packageName, archiveFile, config,
|
||||
object : ArchiveProgressPageListener {
|
||||
override fun onCancel() {
|
||||
}
|
||||
|
||||
override fun completed(isSuccess: Boolean) {
|
||||
LogUtils.d("存档使用 completed : $isSuccess")
|
||||
if (applyArchiveListener != null) {
|
||||
applyArchiveListener(packageName, isSuccess)
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun prepareExtIntent(intent: Intent) {
|
||||
intent.setClassName(
|
||||
com.lg.vspace.BuildConfig.EXT_PACKAGE_NAME,
|
||||
"com.lg.vspace.addon.launcher.RemoteGuideActivity"
|
||||
)
|
||||
intent.putExtra("callback", Bundle().also {
|
||||
messenger = Messenger(handler)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
it.putBinder("messenger", messenger!!.binder)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
307
app/src/main/java/com/gh/vspace/VSpace32NewDialogFragment.kt
Normal file
307
app/src/main/java/com/gh/vspace/VSpace32NewDialogFragment.kt
Normal file
@ -0,0 +1,307 @@
|
||||
package com.gh.vspace
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import com.gh.common.exposure.ExposureUtils
|
||||
import com.gh.common.exposure.ExposureUtils.DownloadType.DOWNLOAD
|
||||
import com.gh.common.exposure.ExposureUtils.DownloadType.UPDATE
|
||||
import com.gh.common.util.*
|
||||
import com.gh.common.util.NewFlatLogUtils
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.fragment.BaseDraggableDialogFragment
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.databinding.DialogVspace32NewBinding
|
||||
import com.gh.gamecenter.entity.AppEntity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.view.DownloadButton
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.DataWatcher
|
||||
import com.lightgame.download.DownloadConfig
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.download.DownloadStatus.*
|
||||
import com.lightgame.utils.AppManager
|
||||
import java.io.File
|
||||
|
||||
class VSpace32NewDialogFragment : BaseDraggableDialogFragment() {
|
||||
|
||||
private var mAppEntity: AppEntity? = null
|
||||
private var mGameId: String = ""
|
||||
private var mGameName: String = ""
|
||||
private val mDownloadUrl by lazy { mAppEntity?.url ?: "" }
|
||||
private val mBinding by lazy { DialogVspace32NewBinding.inflate(layoutInflater) }
|
||||
private var mIsLogInstallShow = false
|
||||
private var mIsLogAutoInstallClick = false
|
||||
private var mIsClickDownloadThisTime = false // 是否本次弹出Dialog点击的下载按钮
|
||||
private val mDataWatcher = object : DataWatcher() {
|
||||
override fun onDataChanged(downloadEntity: DownloadEntity) {
|
||||
if (downloadEntity.url == mDownloadUrl && isAdded) {
|
||||
updateDownloadButton(downloadEntity)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDataInit(downloadEntity: DownloadEntity) {
|
||||
onDataChanged(downloadEntity)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getRootView(): View = mBinding.root
|
||||
override fun getDragCloseView(): View = mBinding.dragClose
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
mAppEntity = arguments?.get(KEY_APP_ENTITY_32) as AppEntity
|
||||
mGameId = arguments?.getString(EntranceConsts.KEY_GAME_ID) ?: ""
|
||||
mGameName = arguments?.getString(EntranceConsts.KEY_GAME_NAME) ?: ""
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
return mBinding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
val mViewModel = viewModelProvider<VSpaceDialogFragment.VSpaceDialogViewModel>()
|
||||
mViewModel.packageLiveData.observe(this) {
|
||||
if (it.packageName == VHelper.VSPACE_32BIT_NEW_PACKAGENAME) {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
|
||||
val downloadSnapshot = DownloadManager.getInstance()
|
||||
.getDownloadEntitySnapshotByPackageName(VHelper.VSPACE_32BIT_NEW_PACKAGENAME)
|
||||
mBinding.downloadBtn.text = if (downloadSnapshot?.status == done) "安装" else "下载"
|
||||
mBinding.downloadBtn.buttonStyle = DownloadButton.ButtonStyle.NORMAL
|
||||
mBinding.descTv.text = "《$mGameName》需安装完整的畅玩服务组件,安装后即可给您带来急速的畅玩体验~"
|
||||
mBinding.privacyPolicyTv.setOnClickListener {
|
||||
NewFlatLogUtils.logHaloFunEvent("halo_fun_download_dialog_privacy_click")
|
||||
DirectUtils.directToWebView(requireContext(), Constants.SMOOTH_GAME_PRIVACY_POLICY_ADDRESS)
|
||||
}
|
||||
|
||||
if (downloadSnapshot?.status == done) {
|
||||
NewFlatLogUtils.logHaloFunEvent("halo_fun_32_install_tip_dialog_show")
|
||||
SensorsBridge.trackEvent("HaloFunExpandInstallDialogShow")
|
||||
mIsLogInstallShow = true
|
||||
} else {
|
||||
NewFlatLogUtils.logHaloFun32DialogEvent("halo_fun_32_download_tip_dialog_show", mGameId, mGameName)
|
||||
SensorsBridge.trackEvent("HaloFunExpandDownloadDialogShow", "game_id", mGameId, "game_name", mGameName)
|
||||
}
|
||||
|
||||
mBinding.downloadBtn.setOnClickListener {
|
||||
if (downloadSnapshot?.status == done) {
|
||||
if (!File(downloadSnapshot.path).exists()) {
|
||||
ToastUtils.toast("畅玩组件已损坏,即将重新下载")
|
||||
DownloadManager.getInstance().cancel(downloadSnapshot.url)
|
||||
DownloadManager.getInstance().add(downloadSnapshot)
|
||||
} else {
|
||||
PackageInstaller.install(requireContext(), downloadSnapshot)
|
||||
NewFlatLogUtils.logHaloFunEvent("halo_fun_32_install_tip_dialog_click")
|
||||
SensorsBridge.trackEvent("HaloFunExpandInstallButtonClick")
|
||||
}
|
||||
} else {
|
||||
val downloadEntity = DownloadEntity()
|
||||
|
||||
val name = "畅玩游戏助手V" + mAppEntity?.version
|
||||
val downloadId = PackageInstaller.createDownloadId(name)
|
||||
|
||||
downloadEntity.url = mDownloadUrl
|
||||
downloadEntity.name = name
|
||||
downloadEntity.platform = "官方版"
|
||||
downloadEntity.gameId = Constants.HALO_FUN_NEW_32_GAME_ID
|
||||
downloadEntity.path = PackageInstaller.getDownloadPathWithId(downloadId, "apk")
|
||||
downloadEntity.packageName = VHelper.VSPACE_32BIT_NEW_PACKAGENAME
|
||||
downloadEntity.addMetaExtra(DownloadConfig.KEY_PROGRESS_CALLBACK_INTERVAL, "200")
|
||||
|
||||
val gameEntity = GameEntity(downloadEntity.gameId, downloadEntity.name)
|
||||
gameEntity.gameVersion = mAppEntity?.version ?: ""
|
||||
|
||||
// 确定下载类型
|
||||
val downloadType =
|
||||
if (arguments?.getBoolean(VSpaceDialogFragment.KEY_IS_UPDATE) == true) UPDATE else DOWNLOAD
|
||||
|
||||
downloadEntity.exposureTrace = ExposureUtils.logADownloadExposureEvent(
|
||||
gameEntity,
|
||||
downloadEntity.platform,
|
||||
null,
|
||||
downloadType
|
||||
).toJson()
|
||||
|
||||
mIsClickDownloadThisTime = true
|
||||
|
||||
AppExecutor.uiExecutor.executeWithDelay({
|
||||
DownloadManager.getInstance().cancel(mDownloadUrl)
|
||||
DownloadManager.getInstance().add(downloadEntity)
|
||||
}, 200)
|
||||
|
||||
DataCollectionUtils.uploadDownload(HaloApp.getInstance(), downloadEntity, "开始")
|
||||
NewFlatLogUtils.logHaloFun32DialogEvent("halo_fun_32_download_tip_dialog_click", mGameId, mGameName)
|
||||
SensorsBridge.trackEvent("HaloFunExpandDownloadDialogDownloadClick")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
DownloadManager.getInstance().addObserver(mDataWatcher)
|
||||
|
||||
// 上面监听安装包名变化的 LiveData 监听有可能被冲掉了
|
||||
// 手动再检查一下安装状态,避免出现已安装但是没有 dismiss 弹窗的问题
|
||||
if (PackageUtils.isInstalledFromAllPackage(requireContext(), VHelper.VSPACE_32BIT_NEW_PACKAGENAME)) {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
DownloadManager.getInstance().removeObserver(mDataWatcher)
|
||||
}
|
||||
|
||||
private fun updateDownloadButton(downloadEntity: DownloadEntity) {
|
||||
val downloadBtn = mBinding.downloadBtn
|
||||
downloadBtn.progress = (downloadEntity.progress * 10).toInt()
|
||||
when (downloadEntity.status) {
|
||||
downloading -> {
|
||||
downloadBtn.setText(R.string.pause)
|
||||
downloadBtn.progress = (downloadEntity.percent * 10).toInt()
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
|
||||
downloadBtn.setOnClickListener {
|
||||
DownloadManager.getInstance().pause(mDownloadUrl)
|
||||
}
|
||||
}
|
||||
|
||||
pause -> {
|
||||
downloadBtn.setText(R.string.resume)
|
||||
downloadBtn.setOnClickListener {
|
||||
DownloadManager.getInstance().resume(downloadEntity, true)
|
||||
}
|
||||
}
|
||||
|
||||
overflow,
|
||||
timeout,
|
||||
neterror,
|
||||
diskisfull,
|
||||
waiting,
|
||||
subscribe -> {
|
||||
downloadBtn.setText(R.string.waiting)
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
|
||||
downloadBtn.setOnClickListener {
|
||||
DownloadManager.getInstance().resume(downloadEntity, false)
|
||||
}
|
||||
}
|
||||
|
||||
done -> {
|
||||
downloadBtn.setText(R.string.install)
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.INSTALL_NORMAL
|
||||
|
||||
if (!mIsLogInstallShow) {
|
||||
NewFlatLogUtils.logHaloFunEvent("halo_fun_32_install_tip_dialog_show")
|
||||
NewFlatLogUtils.logHaloFunInstallTipDialogShow("32位")
|
||||
SensorsBridge.trackEvent("HaloFunExpandInstallDialogShow")
|
||||
mIsLogInstallShow = true
|
||||
}
|
||||
|
||||
val isVSpace32DownloadOnly =
|
||||
downloadEntity.getMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE) == Constants.VSPACE_32_DOWNLOAD_ONLY
|
||||
val isAutoInstall = SPUtils.getBoolean(Constants.SP_AUTO_INSTALL, true)
|
||||
if (!isVSpace32DownloadOnly && isAutoInstall && !mIsLogAutoInstallClick && mIsClickDownloadThisTime) {
|
||||
NewFlatLogUtils.logHaloFunEvent("halo_fun_32_install_tip_dialog_click")
|
||||
SensorsBridge.trackEvent("HaloFunExpandInstallButtonClick")
|
||||
mIsLogAutoInstallClick = true
|
||||
}
|
||||
|
||||
downloadBtn.setOnClickListener {
|
||||
if (!File(downloadEntity.path).exists()) {
|
||||
ToastUtils.toast("畅玩组件已损坏,即将重新下载")
|
||||
DownloadManager.getInstance().cancel(downloadEntity.url)
|
||||
DownloadManager.getInstance().add(downloadEntity)
|
||||
} else {
|
||||
PackageInstaller.install(requireContext(), downloadEntity)
|
||||
NewFlatLogUtils.logHaloFunEvent("halo_fun_32_install_tip_dialog_click")
|
||||
SensorsBridge.trackEvent("HaloFunExpandInstallButtonClick")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cancel,
|
||||
hijack,
|
||||
notfound,
|
||||
uncertificated,
|
||||
unqualified -> {
|
||||
downloadBtn.text = "下载"
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.NORMAL
|
||||
downloadBtn.setOnClickListener {
|
||||
DownloadManager.getInstance().resume(downloadEntity, true)
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val KEY_APP_ENTITY_32 = "app_entity_32"
|
||||
|
||||
@JvmStatic
|
||||
fun showDownloadDialog(
|
||||
context: Context?,
|
||||
appEntity32: AppEntity,
|
||||
gameId: String = "",
|
||||
gameName: String = ""
|
||||
) {
|
||||
val fragmentActivity: FragmentActivity = if (context is FragmentActivity) {
|
||||
context
|
||||
} else {
|
||||
val currentActivity = AppManager.getInstance().currentActivity()
|
||||
if (currentActivity is FragmentActivity) {
|
||||
currentActivity
|
||||
} else {
|
||||
throw IllegalStateException("current activity context must be FragmentActivity")
|
||||
}
|
||||
}
|
||||
|
||||
// 防止重复弹出
|
||||
if (hasDialogDisplayedInCurrentActivity(fragmentActivity)) return
|
||||
|
||||
val downloadDialog = VSpace32NewDialogFragment().apply {
|
||||
arguments = Bundle().apply {
|
||||
putParcelable(KEY_APP_ENTITY_32, appEntity32)
|
||||
putString(EntranceConsts.KEY_GAME_ID, gameId)
|
||||
putString(EntranceConsts.KEY_GAME_NAME, gameName)
|
||||
}
|
||||
}
|
||||
downloadDialog.show(
|
||||
fragmentActivity.supportFragmentManager,
|
||||
VSpace32NewDialogFragment::class.java.name
|
||||
)
|
||||
}
|
||||
|
||||
private fun hasDialogDisplayedInCurrentActivity(fragmentActivity: FragmentActivity): Boolean {
|
||||
val fragments: List<Fragment> = fragmentActivity.supportFragmentManager.fragments
|
||||
fragments.forEach { fragment ->
|
||||
if (fragment is VSpace32NewDialogFragment) return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,303 @@
|
||||
package com.gh.vspace
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import com.gh.common.exposure.ExposureUtils
|
||||
import com.gh.common.exposure.ExposureUtils.DownloadType.DOWNLOAD
|
||||
import com.gh.common.exposure.ExposureUtils.DownloadType.UPDATE
|
||||
import com.gh.common.util.DataCollectionUtils
|
||||
import com.gh.common.util.NewFlatLogUtils
|
||||
import com.gh.common.util.PackageInstaller
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.gamecenter.feature.view.DownloadButton
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.databinding.DialogVspaceUpdate32NewBinding
|
||||
import com.gh.gamecenter.entity.AppEntity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.DataWatcher
|
||||
import com.lightgame.download.DownloadConfig
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.download.DownloadStatus.*
|
||||
import com.lightgame.utils.AppManager
|
||||
import java.io.File
|
||||
|
||||
class VSpaceUpdate32NewDialogFragment : BaseDialogFragment() {
|
||||
|
||||
private var mAppEntity: AppEntity? = null
|
||||
private var mGameId: String = ""
|
||||
private var mGameName: String = ""
|
||||
private val mDownloadUrl by lazy { mAppEntity?.url ?: "" }
|
||||
private val mBinding by lazy { DialogVspaceUpdate32NewBinding.inflate(layoutInflater) }
|
||||
private val mDataWatcher = object : DataWatcher() {
|
||||
override fun onDataChanged(downloadEntity: DownloadEntity) {
|
||||
if (downloadEntity.url == mDownloadUrl && isAdded) {
|
||||
updateDownloadButton(downloadEntity)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDataInit(downloadEntity: DownloadEntity) {
|
||||
onDataChanged(downloadEntity)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
mAppEntity = arguments?.get(KEY_APP_ENTITY_32) as AppEntity
|
||||
mGameId = arguments?.getString(EntranceConsts.KEY_GAME_ID) ?: ""
|
||||
mGameName = arguments?.getString(EntranceConsts.KEY_GAME_NAME) ?: ""
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
return mBinding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
val mViewModel = viewModelProvider<VSpaceDialogFragment.VSpaceDialogViewModel>()
|
||||
mViewModel.packageLiveData.observe(this) {
|
||||
if (it.packageName == VHelper.VSPACE_32BIT_NEW_PACKAGENAME) {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
|
||||
val downloadSnapshot = DownloadManager.getInstance()
|
||||
.getDownloadEntitySnapshotByPackageName(VHelper.VSPACE_32BIT_NEW_PACKAGENAME)
|
||||
mBinding.downloadBtn.text = if (downloadSnapshot?.status == done) "安装" else "下载"
|
||||
mBinding.downloadBtn.buttonStyle = DownloadButton.ButtonStyle.NORMAL
|
||||
mBinding.contentTv.text = "《$mGameName》需安装完整的畅玩服务组件,安装后即可给您带来急速的畅玩体验~"
|
||||
|
||||
mBinding.downloadBtn.setOnClickListener {
|
||||
NewFlatLogUtils.logHaloFun32DialogEvent("halo_fun_32_update_tip_dialog_click", mGameId, mGameName)
|
||||
if (downloadSnapshot?.status == done) {
|
||||
if (!File(downloadSnapshot.path).exists()) {
|
||||
ToastUtils.toast("畅玩组件已损坏,即将重新下载")
|
||||
DownloadManager.getInstance().cancel(downloadSnapshot.url)
|
||||
DownloadManager.getInstance().add(downloadSnapshot)
|
||||
} else {
|
||||
PackageInstaller.install(requireContext(), downloadSnapshot)
|
||||
}
|
||||
} else {
|
||||
val downloadEntity = DownloadEntity()
|
||||
|
||||
val name = "畅玩游戏助手V" + mAppEntity?.version
|
||||
val downloadId = PackageInstaller.createDownloadId(name)
|
||||
|
||||
downloadEntity.url = mDownloadUrl
|
||||
downloadEntity.name = name
|
||||
downloadEntity.platform = "官方版"
|
||||
downloadEntity.gameId = Constants.HALO_FUN_NEW_32_GAME_ID
|
||||
downloadEntity.path = PackageInstaller.getDownloadPathWithId(downloadId, "apk")
|
||||
downloadEntity.packageName = VHelper.VSPACE_32BIT_NEW_PACKAGENAME
|
||||
downloadEntity.addMetaExtra(DownloadConfig.KEY_PROGRESS_CALLBACK_INTERVAL, "200")
|
||||
|
||||
val gameEntity = GameEntity(downloadEntity.gameId, downloadEntity.name)
|
||||
gameEntity.gameVersion = mAppEntity?.version ?: ""
|
||||
|
||||
// 确定下载类型
|
||||
val downloadType =
|
||||
if (arguments?.getBoolean(VSpaceDialogFragment.KEY_IS_UPDATE) == true) UPDATE else DOWNLOAD
|
||||
|
||||
downloadEntity.exposureTrace = ExposureUtils.logADownloadExposureEvent(
|
||||
gameEntity,
|
||||
downloadEntity.platform,
|
||||
null,
|
||||
downloadType
|
||||
).toJson()
|
||||
|
||||
AppExecutor.uiExecutor.executeWithDelay({
|
||||
DownloadManager.getInstance().cancel(mDownloadUrl)
|
||||
DownloadManager.getInstance().add(downloadEntity)
|
||||
}, 200)
|
||||
|
||||
DataCollectionUtils.uploadDownload(HaloApp.getInstance(), downloadEntity, "开始")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
DownloadManager.getInstance().addObserver(mDataWatcher)
|
||||
|
||||
// 上面监听安装包名变化的 LiveData 监听有可能被冲掉了
|
||||
// 手动再检查一下安装状态,避免出现已安装但是没有 dismiss 弹窗的问题
|
||||
if (PackageUtils.isInstalledFromAllPackage(requireContext(), VHelper.VSPACE_32BIT_NEW_PACKAGENAME)
|
||||
&& mAppEntity?.version == PackageUtils.getVersionNameByPackageName(VHelper.VSPACE_32BIT_NEW_PACKAGENAME)
|
||||
) {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
DownloadManager.getInstance().removeObserver(mDataWatcher)
|
||||
}
|
||||
|
||||
private fun updateDownloadButton(downloadEntity: DownloadEntity) {
|
||||
val downloadBtn = mBinding.downloadBtn
|
||||
downloadBtn.progress = (downloadEntity.progress * 10).toInt()
|
||||
when (downloadEntity.status) {
|
||||
downloading -> {
|
||||
downloadBtn.setText(R.string.pause)
|
||||
downloadBtn.progress = (downloadEntity.percent * 10).toInt()
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
|
||||
downloadBtn.setOnClickListener {
|
||||
DownloadManager.getInstance().pause(mDownloadUrl)
|
||||
NewFlatLogUtils.logHaloFun32DialogEvent("halo_fun_32_update_tip_dialog_click", mGameId, mGameName)
|
||||
}
|
||||
}
|
||||
|
||||
pause -> {
|
||||
downloadBtn.setText(R.string.resume)
|
||||
downloadBtn.setOnClickListener {
|
||||
DownloadManager.getInstance().resume(downloadEntity, true)
|
||||
NewFlatLogUtils.logHaloFun32DialogEvent("halo_fun_32_update_tip_dialog_click", mGameId, mGameName)
|
||||
}
|
||||
}
|
||||
|
||||
overflow,
|
||||
timeout,
|
||||
neterror,
|
||||
diskisfull,
|
||||
waiting,
|
||||
subscribe -> {
|
||||
downloadBtn.setText(R.string.waiting)
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
|
||||
downloadBtn.setOnClickListener {
|
||||
DownloadManager.getInstance().resume(downloadEntity, false)
|
||||
NewFlatLogUtils.logHaloFun32DialogEvent("halo_fun_32_update_tip_dialog_click", mGameId, mGameName)
|
||||
}
|
||||
}
|
||||
|
||||
done -> {
|
||||
downloadBtn.setText(R.string.install)
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.INSTALL_NORMAL
|
||||
|
||||
downloadBtn.setOnClickListener {
|
||||
if (!File(downloadEntity.path).exists()) {
|
||||
ToastUtils.toast("畅玩组件已损坏,即将重新下载")
|
||||
DownloadManager.getInstance().cancel(downloadEntity.url)
|
||||
DownloadManager.getInstance().add(downloadEntity)
|
||||
} else {
|
||||
PackageInstaller.install(requireContext(), downloadEntity)
|
||||
NewFlatLogUtils.logHaloFun32DialogEvent(
|
||||
"halo_fun_32_update_tip_dialog_click",
|
||||
mGameId,
|
||||
mGameName
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cancel,
|
||||
hijack,
|
||||
notfound,
|
||||
uncertificated,
|
||||
unqualified -> {
|
||||
downloadBtn.text = "下载"
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.NORMAL
|
||||
downloadBtn.setOnClickListener {
|
||||
DownloadManager.getInstance().resume(downloadEntity, true)
|
||||
NewFlatLogUtils.logHaloFun32DialogEvent("halo_fun_32_update_tip_dialog_click", mGameId, mGameName)
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val KEY_APP_ENTITY_32 = "app_entity_32"
|
||||
const val KEY_AUTO_DOWNLOAD = "auto_download"
|
||||
const val KEY_IS_UPDATE = "is_update"
|
||||
|
||||
@JvmStatic
|
||||
fun showDownloadDialog(
|
||||
context: Context?,
|
||||
appEntity32: AppEntity,
|
||||
autoDownload: Boolean = false,
|
||||
isUpdate: Boolean = false,
|
||||
gameId: String = "",
|
||||
gameName: String = ""
|
||||
) {
|
||||
val fragmentActivity: FragmentActivity = if (context is FragmentActivity) {
|
||||
context
|
||||
} else {
|
||||
val currentActivity = AppManager.getInstance().currentActivity()
|
||||
if (currentActivity is FragmentActivity) {
|
||||
currentActivity
|
||||
} else {
|
||||
throw IllegalStateException("current activity context must be FragmentActivity")
|
||||
}
|
||||
}
|
||||
|
||||
// 防止重复弹出
|
||||
if (hasDialogDisplayedInCurrentActivity(fragmentActivity)) return
|
||||
|
||||
NewFlatLogUtils.logHaloFun32DialogEvent("halo_fun_32_update_tip_dialog_show", gameId, gameName)
|
||||
|
||||
val downloadDialog = VSpaceUpdate32NewDialogFragment().apply {
|
||||
arguments = Bundle().apply {
|
||||
putParcelable(KEY_APP_ENTITY_32, appEntity32)
|
||||
putString(EntranceConsts.KEY_GAME_ID, gameId)
|
||||
putString(EntranceConsts.KEY_GAME_NAME, gameName)
|
||||
putBoolean(KEY_AUTO_DOWNLOAD, autoDownload)
|
||||
putBoolean(KEY_IS_UPDATE, isUpdate)
|
||||
}
|
||||
}
|
||||
downloadDialog.show(
|
||||
fragmentActivity.supportFragmentManager,
|
||||
VSpaceUpdate32NewDialogFragment::class.java.name
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun showDownloadDialog(
|
||||
context: Context?,
|
||||
appEntity32: AppEntity,
|
||||
gameEntity: GameEntity?,
|
||||
autoDownload: Boolean = false,
|
||||
isUpdate: Boolean = false
|
||||
) {
|
||||
showDownloadDialog(
|
||||
context,
|
||||
appEntity32,
|
||||
autoDownload,
|
||||
isUpdate,
|
||||
gameEntity?.id ?: "",
|
||||
gameEntity?.name ?: ""
|
||||
)
|
||||
}
|
||||
|
||||
private fun hasDialogDisplayedInCurrentActivity(fragmentActivity: FragmentActivity): Boolean {
|
||||
val fragments: List<Fragment> = fragmentActivity.supportFragmentManager.fragments
|
||||
fragments.forEach { fragment ->
|
||||
if (fragment is VSpaceUpdate32NewDialogFragment) return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -320,7 +320,7 @@ class GAppsDownloadDialogFragment : BaseBottomDialogFragment<DialogGappsDownload
|
||||
|
||||
context?.let {
|
||||
mIsInstalling = true
|
||||
VHelper.batchInstall(it, installFileMap)
|
||||
VHelper.batchInstall(it, installFileMap, mTriggerPackageName)
|
||||
}
|
||||
|
||||
runOnUiThread {
|
||||
|
||||
@ -20,6 +20,7 @@ import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.vspace.VHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lg.core.BuildConfig
|
||||
import com.lg.vspace.VirtualAppManager
|
||||
import com.muugi.shortcut.core.Executor
|
||||
import com.muugi.shortcut.core.Shortcut
|
||||
@ -89,8 +90,8 @@ class ShortcutManager private constructor() {
|
||||
* 知道游戏id和包名,创建桌面图标
|
||||
*/
|
||||
fun tryCreateShortCut(context: Context, gameId: String, gamePkg: String, result: OnCreateShortcutResult) {
|
||||
VHelper.postOnInitialized {
|
||||
val downloadEntity = VHelper.getVDownloadEntitySnapshot(gameId, gamePkg)
|
||||
val downloadEntity = VHelper.getVDownloadEntitySnapshot(gameId, gamePkg)
|
||||
val createShortcutLambda = {
|
||||
runOnUiThread {
|
||||
if (downloadEntity == null) {
|
||||
result.failed()
|
||||
@ -100,6 +101,11 @@ class ShortcutManager private constructor() {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (VHelper.isInnerInstalled(gamePkg)) {
|
||||
createShortcutLambda.invoke()
|
||||
} else {
|
||||
VHelper.postOnInitialized(createShortcutLambda)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -185,25 +191,7 @@ class ShortcutManager private constructor() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取游戏快捷方式跳转Intent
|
||||
* 直接启动游戏
|
||||
*/
|
||||
private fun getIntent(gameEntity: GameEntity): Intent {
|
||||
val intent = mDelegateManager.getStartGameIntent(
|
||||
gameEntity.getUniquePackageName(),
|
||||
gameEntity.id,
|
||||
gameEntity.name ?: "unknown",
|
||||
gameEntity.icon ?: "",
|
||||
MetaUtil.getBase64EncodedAndroidId(),
|
||||
HaloApp.getInstance().gid,
|
||||
com.gh.gamecenter.BuildConfig.VERSION_NAME,
|
||||
HaloApp.getInstance().channel,
|
||||
"", ""
|
||||
)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
return intent
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取游戏快捷方式跳转Intent
|
||||
|
||||
@ -3,7 +3,6 @@ package com.halo.assistant;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.net.ConnectivityManager;
|
||||
@ -39,14 +38,15 @@ import com.gh.common.util.DownloadNotificationHelper;
|
||||
import com.gh.common.util.DownloadObserver;
|
||||
import com.gh.common.util.LogUtils;
|
||||
import com.gh.common.util.LunchType;
|
||||
import com.gh.common.util.PackageChangeHelper;
|
||||
import com.gh.common.util.PackageHelper;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.SignatureRepository;
|
||||
import com.gh.common.videolog.VideoRecordUtils;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.download.simple.DownloadMessageHandler;
|
||||
import com.gh.download.simple.SimpleDownloadDatabase;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.Injection;
|
||||
import com.gh.gamecenter.common.constant.Config;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.constant.RouteConsts;
|
||||
@ -73,7 +73,6 @@ import com.gh.gamecenter.packagehelper.PackageRepository;
|
||||
import com.gh.gamecenter.provider.FlavorProviderImp;
|
||||
import com.gh.gamecenter.receiver.ActivitySkipReceiver;
|
||||
import com.gh.gamecenter.receiver.DownloadReceiver;
|
||||
import com.gh.gamecenter.receiver.InstallAndUninstallReceiver;
|
||||
import com.gh.gamecenter.receiver.InstallReceiver;
|
||||
import com.gh.gamecenter.receiver.NetworkStateReceiver;
|
||||
import com.gh.gamecenter.wrapper.MainWrapperRepository;
|
||||
@ -81,8 +80,13 @@ import com.gh.vspace.VHelper;
|
||||
import com.github.piasy.biv.BigImageViewer;
|
||||
import com.github.piasy.biv.loader.fresco.FrescoImageLoader;
|
||||
import com.lg.ndownload.DownloadCore;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.download.DownloadStatus;
|
||||
import com.lg.ndownload.DownloadDbManager;
|
||||
import com.lg.vspace.VaApp;
|
||||
import com.lightgame.utils.Utils;
|
||||
import com.llew.huawei.verifier.LoadedApkHuaWei;
|
||||
import com.lody.virtual.client.core.VirtualCore;
|
||||
import com.shuyu.gsyvideoplayer.cache.CacheFactory;
|
||||
import com.shuyu.gsyvideoplayer.player.PlayerFactory;
|
||||
|
||||
@ -120,7 +124,7 @@ public class HaloApp extends MultiDexApplication {
|
||||
|
||||
public boolean isSkippingThirdParty = false; // 应用是否处于跳转第三方Activity状态
|
||||
private List<String> webViewAbiList;
|
||||
private IFlavorProvider mFlavorProvider = new FlavorProviderImp();
|
||||
private final IFlavorProvider mFlavorProvider = new FlavorProviderImp();
|
||||
private final ServiceLoader<IApplication> mApplicationList = ServiceLoader.load(IApplication.class, this.getClass().getClassLoader());
|
||||
private LunchType mLaunchType = null;
|
||||
|
||||
@ -208,6 +212,7 @@ public class HaloApp extends MultiDexApplication {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
VaApp.get().onCreate(this);
|
||||
initArouter();
|
||||
|
||||
mInstance = this;
|
||||
@ -331,6 +336,9 @@ public class HaloApp extends MultiDexApplication {
|
||||
// 获取 settings 配置
|
||||
com.gh.common.constant.Config.getGhzsSettings();
|
||||
|
||||
// 5 秒获取后台配置的获取应用列表限制接口结果超时后,回落到关闭状态
|
||||
// PackageHelper.INSTANCE.fallbackInstalledPackageApiSwitchAfterTimeout(5000L);
|
||||
|
||||
String localTemporaryDeviceId = SPUtils.getString(Constants.SP_TEMPORARY_DEVICE_ID);
|
||||
if (!TextUtils.isEmpty(localTemporaryDeviceId)) {
|
||||
HaloApp.getInstance().setLocalTemporaryDeviceId(localTemporaryDeviceId);
|
||||
@ -340,7 +348,7 @@ public class HaloApp extends MultiDexApplication {
|
||||
// 必须放在外面,否则不能及时刷新用户数据
|
||||
UserRepository.getInstance().getLoginUserInfo();
|
||||
|
||||
GlobalPriorityChainHelper.INSTANCE.preStart();
|
||||
GlobalPriorityChainHelper.INSTANCE.preStart(isNewForThisVersion);
|
||||
|
||||
MainWrapperRepository.Companion.getInstance().getDataUnion();
|
||||
|
||||
@ -351,7 +359,7 @@ public class HaloApp extends MultiDexApplication {
|
||||
|
||||
PackageRepository.initData();
|
||||
PackageHelper.refreshLocalPackageList();
|
||||
PackageHelper.initList();
|
||||
PackageHelper.refreshList();
|
||||
|
||||
initReceiver();
|
||||
initPackageChangesReceiver();
|
||||
@ -367,6 +375,9 @@ public class HaloApp extends MultiDexApplication {
|
||||
// 初始化畅玩相关数据
|
||||
retrieveVGameInfoIfNeeded();
|
||||
|
||||
// 移除已安装但还在本地数据库中的包(避免因为没有监听到安装结果导致安装包没有删除的问题)
|
||||
removeInstalledButRemainedPackages();
|
||||
|
||||
// 开发环境不要强制捕获相关异常,这些异常通常是需要处理的
|
||||
if (!BuildConfig.DEBUG) {
|
||||
RxJavaPlugins.setErrorHandler(throwable -> {
|
||||
@ -376,6 +387,7 @@ public class HaloApp extends MultiDexApplication {
|
||||
});
|
||||
}
|
||||
}, delay);
|
||||
VaApp.get().startSensorLogService();
|
||||
}
|
||||
|
||||
private void initArouter() {
|
||||
@ -497,13 +509,7 @@ public class HaloApp extends MultiDexApplication {
|
||||
}
|
||||
|
||||
private void initPackageChangesReceiver() {
|
||||
InstallAndUninstallReceiver receiver = new InstallAndUninstallReceiver();
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
|
||||
intentFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
|
||||
intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
|
||||
intentFilter.addDataScheme("package");
|
||||
this.registerReceiver(receiver, intentFilter);
|
||||
ProcessLifecycleOwner.get().getLifecycle().addObserver(PackageChangeHelper.INSTANCE);
|
||||
}
|
||||
|
||||
private void initConnectivityChangesReceiver() {
|
||||
@ -526,6 +532,7 @@ public class HaloApp extends MultiDexApplication {
|
||||
LoadedApkHuaWei.hookHuaWeiVerifier(this);
|
||||
|
||||
DownloadMessageHandler.INSTANCE.init(SimpleDownloadDatabase.getInstance().downloadDao());
|
||||
VHelper.INSTANCE.preparePluginUpdate();
|
||||
});
|
||||
}
|
||||
|
||||
@ -575,6 +582,32 @@ public class HaloApp extends MultiDexApplication {
|
||||
VHelper.init(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除已安装但还在本地数据库中的包
|
||||
*/
|
||||
private void removeInstalledButRemainedPackages() {
|
||||
AppExecutor.getIoExecutor().execute(() -> {
|
||||
for (DownloadEntity downloadEntity : DownloadManager.getInstance().getAllDownloadEntity()) {
|
||||
if (downloadEntity.getStatus() != DownloadStatus.done) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
String versionName = downloadEntity.getVersionName();
|
||||
String packageName = downloadEntity.getPackageName();
|
||||
// 这里暴力删除会影响畅玩游戏快速安装功能,但先不管了
|
||||
if (versionName != null
|
||||
&& packageName != null
|
||||
&& versionName.equals(PackageUtils.getVersionNameByPackageName(packageName))) {
|
||||
DownloadManager.getInstance().cancel(downloadEntity.getUrl());
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
// 不在乎删除的结果,尝试即可
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isReinstallTheSameVersion() {
|
||||
return mIsReinstallTheSameVersion;
|
||||
}
|
||||
@ -608,15 +641,10 @@ public class HaloApp extends MultiDexApplication {
|
||||
return mFlavorProvider;
|
||||
}
|
||||
|
||||
// @NonNull
|
||||
// @Override
|
||||
// public Configuration getWorkManagerConfiguration() {
|
||||
// return new Configuration.Builder().build();
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
super.attachBaseContext(base);
|
||||
VaApp.get().attachBaseContext(this, base);
|
||||
for (IApplication application : mApplicationList) {
|
||||
application.attachBaseContext();
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ class RealNameInfoFragment : ToolbarFragment() {
|
||||
) {
|
||||
DirectUtils.directToWebView(
|
||||
requireContext(),
|
||||
"https://resource.ghzs.com/page/privacy_policies/Identity_information.html",
|
||||
"https://and-static.ghzs66.com/page/privacy_policies/Identity_information.html",
|
||||
"(实名认证)"
|
||||
)
|
||||
}
|
||||
|
||||
@ -153,7 +153,7 @@ class UserInfoFragment : ToolbarFragment() {
|
||||
MtaHelper.onEvent("个人主页详情", "个人中心", "账号安全指南")
|
||||
DirectUtils.directToWebView(
|
||||
requireContext(),
|
||||
"https://resource.ghzs.com/page/guide_page/safety_guide.html",
|
||||
"https://and-static.ghzs66.com/page/guide_page/safety_guide.html",
|
||||
"(个人中心)"
|
||||
)
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 668 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_install_api_close.png
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/ic_install_api_close.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 341 B |
13
app/src/main/res/drawable/ic_auxiliary_arrow_down_12.xml
Normal file
13
app/src/main/res/drawable/ic_auxiliary_arrow_down_12.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="12dp"
|
||||
android:height="6dp"
|
||||
android:viewportWidth="12"
|
||||
android:viewportHeight="6">
|
||||
<path
|
||||
android:strokeWidth="1"
|
||||
android:pathData="M10,1L6,5L2,1"
|
||||
android:strokeLineJoin="round"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="@color/text_neutral"
|
||||
android:strokeLineCap="round"/>
|
||||
</vector>
|
||||
13
app/src/main/res/drawable/ic_auxiliary_arrow_down_8.xml
Normal file
13
app/src/main/res/drawable/ic_auxiliary_arrow_down_8.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="8dp"
|
||||
android:height="6dp"
|
||||
android:viewportWidth="8"
|
||||
android:viewportHeight="6">
|
||||
<path
|
||||
android:strokeWidth="1"
|
||||
android:pathData="M7,1.5L4,4.5L1,1.5"
|
||||
android:strokeLineJoin="round"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="@color/text_neutral"
|
||||
android:strokeLineCap="round"/>
|
||||
</vector>
|
||||
13
app/src/main/res/drawable/ic_auxiliary_arrow_right_12.xml
Normal file
13
app/src/main/res/drawable/ic_auxiliary_arrow_right_12.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="6dp"
|
||||
android:height="12dp"
|
||||
android:viewportWidth="6"
|
||||
android:viewportHeight="12">
|
||||
<path
|
||||
android:strokeWidth="1"
|
||||
android:pathData="M1,2L5,6L1,10"
|
||||
android:strokeLineJoin="round"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="@color/text_neutral"
|
||||
android:strokeLineCap="round"/>
|
||||
</vector>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user