Compare commits
92 Commits
pack/test-
...
feat/bypas
| Author | SHA1 | Date | |
|---|---|---|---|
| 9cc2e733c9 | |||
| 638bf86d1e | |||
| 158c46f210 | |||
| a28ef7d20b | |||
| bae20a4e7d | |||
| cbba9c09b5 | |||
| 3c877ada98 | |||
| 9b95e01d33 | |||
| 567576fc04 | |||
| 1b7913a00e | |||
| 05e2719e1c | |||
| 8ed10c411a | |||
| f9f4bb84b4 | |||
| 44a2e616ab | |||
| fffd3ef789 | |||
| d53782b8de | |||
| b16c5d723b | |||
| 1dfd636283 | |||
| 65feed01f4 | |||
| 2a596bd2a0 | |||
| 16c4f1016c | |||
| 1ced82c1f6 | |||
| 078c9204af | |||
| 68818b3409 | |||
| 7d4aa34d12 | |||
| 2a27e0f467 | |||
| 54ee8a9c69 | |||
| 2b44efd6b3 | |||
| d62c8beb30 | |||
| 155ec08280 | |||
| d46aa81dbe | |||
| 51c0bf27cf | |||
| 43eb4c88c9 | |||
| 06b2d2b416 | |||
| af7580a6a6 | |||
| 1e4375ec8a | |||
| 195247a5c3 | |||
| dd65bc8bc2 | |||
| 196e719358 | |||
| b1c267b179 | |||
| a2679c8dbd | |||
| c9e1816be0 | |||
| a1f0455d5a | |||
| 5b3f4b6104 | |||
| fe4e9d9d3b | |||
| dd051b4d13 | |||
| e7f756555c | |||
| 9488837e9e | |||
| b8c4f1403b | |||
| b88698c2a3 | |||
| c897d5ad0f | |||
| 037f453a75 | |||
| ad3a3c1341 | |||
| ba320f7740 | |||
| f3dbc0b779 | |||
| 0c518ac40e | |||
| ccc0140bba | |||
| bf57118900 | |||
| b80a14f2b1 | |||
| 1450064640 | |||
| 90e19d5099 | |||
| 383124dc36 | |||
| 6d6ce2613a | |||
| 8569264b82 | |||
| 59667abf09 | |||
| 5201637326 | |||
| 417c41c8a0 | |||
| b651ef8617 | |||
| af67894d4e | |||
| 76e17eddd7 | |||
| f8c9c41eb0 | |||
| 40ac173389 | |||
| c6bc7ca6cc | |||
| f01e08aec9 | |||
| faddf5d7b6 | |||
| 81cf2f0ddc | |||
| 198561d15a | |||
| 1e721b699c | |||
| 8f48dfd347 | |||
| bc811a2882 | |||
| bdccbc4c28 | |||
| bfd986fdfd | |||
| a2bd5e01e0 | |||
| 844d227f19 | |||
| 8b1f92e9c4 | |||
| f5834d440b | |||
| f982bf6478 | |||
| 33d7afec71 | |||
| 37ef50f323 | |||
| 4c6acdee3a | |||
| 6beb060e63 | |||
| d11ccba0b7 |
@ -71,7 +71,7 @@ android_build:
|
||||
exit_codes: 137
|
||||
only:
|
||||
- dev
|
||||
- feat/GHZSCY-5250
|
||||
- release
|
||||
|
||||
# 代码检查
|
||||
sonarqube_analysis:
|
||||
@ -152,4 +152,4 @@ oss-upload&send-email:
|
||||
- /usr/local/bin/python /ci-android-mail-jira-comment.py
|
||||
only:
|
||||
- dev
|
||||
- feat/GHZSCY-5250
|
||||
- release
|
||||
@ -126,6 +126,10 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
exclude 'META-INF/gradle/incremental.annotation.processors'
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
debuggable true
|
||||
@ -357,7 +361,9 @@ dependencies {
|
||||
|
||||
implementation "com.lg:easyfloat:${easyFloat}"
|
||||
|
||||
implementation "com.lg:apksig:${apksig}"
|
||||
implementation ("com.lg:apksig:${apksig}") {
|
||||
exclude group: 'com.google.protobuf'
|
||||
}
|
||||
|
||||
implementation "com.lg:gid:${gid}"
|
||||
|
||||
@ -401,7 +407,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 +415,13 @@ 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) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
// 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'
|
||||
// }
|
||||
}
|
||||
|
||||
File propFile = file('sign.properties')
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
<!-- 允许应用程序快捷方式 -->
|
||||
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
|
||||
<!-- 应用安装相关 -->
|
||||
<uses-permission android:name="com.android.permission.GET_INSTALLED_APPS" />
|
||||
<!-- <uses-permission android:name="com.android.permission.GET_INSTALLED_APPS" />-->
|
||||
|
||||
<!-- 前台服务权限-->
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
|
||||
@ -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
|
||||
|
||||
/**
|
||||
* 是否需要显示下载管理广告
|
||||
|
||||
@ -45,6 +45,14 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
}
|
||||
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) {
|
||||
@ -84,10 +92,6 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
}
|
||||
|
||||
XapkInstaller.updateCurrentInstallStatus()
|
||||
|
||||
// 清除桌面角标
|
||||
val pushProvider = ARouter.getInstance().build(RouteConsts.provider.push).navigation() as? IPushProvider
|
||||
pushProvider?.cleanBadgeNumber(activity.applicationContext)
|
||||
}
|
||||
|
||||
override fun onActivityPaused(activity: Activity) {
|
||||
|
||||
@ -34,7 +34,10 @@ import com.gh.gamecenter.common.view.dsbridge.CompletionHandler
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.runOnIoThread
|
||||
import com.gh.gamecenter.core.runOnUiThread
|
||||
import com.gh.gamecenter.core.utils.*
|
||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.entity.SensorsEvent
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus
|
||||
import com.gh.gamecenter.eventbus.EBPackage
|
||||
@ -69,7 +72,7 @@ class DefaultJsApi(
|
||||
private var mFragment: Fragment? = null,
|
||||
private var mBbsId: String? = "",
|
||||
private var mOriginUrl: String? = "",
|
||||
private val mForumName: String? = ""
|
||||
private val mForumName: String? = "",
|
||||
) {
|
||||
|
||||
companion object {
|
||||
@ -89,6 +92,11 @@ class DefaultJsApi(
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun isEnableForceDark(msg: Any): Boolean {
|
||||
return DarkModeUtils.isWebViewForceDarkEnabled
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun isGhzs(msg: Any): String {
|
||||
return "true"
|
||||
|
||||
@ -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;
|
||||
@ -28,6 +29,7 @@ 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.vspace.VHelper;
|
||||
import com.halo.assistant.HaloApp;
|
||||
@ -331,8 +333,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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import com.aliyun.sls.android.producer.Log
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.common.loghub.LoghubHelper
|
||||
import com.gh.gamecenter.common.loghub.TLogHubHelper
|
||||
import com.gh.gamecenter.common.utils.FixedSizeLinkedHashSet
|
||||
import com.gh.gamecenter.common.utils.toJson
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.lightgame.utils.Utils
|
||||
import com.volcengine.model.tls.LogItem
|
||||
|
||||
/**
|
||||
* A handful tool for committing logs to aliyun loghub.
|
||||
@ -78,19 +78,20 @@ object ExposureManager {
|
||||
|
||||
private fun uploadExposures(eventSet: HashSet<ExposureEvent>, forced: Boolean) {
|
||||
eventSet.forEach {
|
||||
LoghubHelper.uploadLog(buildLog(it), LOG_STORE, forced)
|
||||
TLogHubHelper.sendLog(buildLog(it), LOG_STORE)
|
||||
// LoghubHelper.uploadLog(buildLog(it), LOG_STORE, forced)
|
||||
// it.recycle()
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildLog(event: ExposureEvent) = Log().apply {
|
||||
putContent("id", event.id)
|
||||
putContent("payload", event.payload.toJson())
|
||||
putContent("event", event.event.toString())
|
||||
putContent("source", eliminateMultipleBrackets(event.source.toJson()))
|
||||
putContent("meta", event.meta.toJson())
|
||||
putContent("real_millisecond", event.timeInMillisecond.toString())
|
||||
putContent(
|
||||
private fun buildLog(event: ExposureEvent) = LogItem(System.currentTimeMillis()).apply {
|
||||
addContent("__id", event.id)
|
||||
addContent("payload", event.payload.toJson())
|
||||
addContent("event", event.event.toString())
|
||||
addContent("source", eliminateMultipleBrackets(event.source.toJson()))
|
||||
addContent("meta", event.meta.toJson())
|
||||
addContent("real_millisecond", event.timeInMillisecond.toString())
|
||||
addContent(
|
||||
"e-traces", if (event.eTrace != null) {
|
||||
eliminateMultipleBrackets(event.eTrace?.toJson() ?: "")
|
||||
} else ""
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
@ -32,5 +32,6 @@ class BuildConfigImpl : IBuildConfigProvider {
|
||||
override fun getVApiHost(): String = BuildConfig.VAPI_HOST
|
||||
|
||||
override fun getVDevApiHost(): String = BuildConfig.DEV_VAPI_HOST
|
||||
|
||||
override fun getLogProducerProject(): String = BuildConfig.LOG_HUB_PROJECT
|
||||
}
|
||||
@ -1,17 +1,14 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts;
|
||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil;
|
||||
import com.gh.gamecenter.common.utils.NetworkUtils;
|
||||
import com.gh.gamecenter.feature.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.NewsDetailEntity;
|
||||
import com.gh.gamecenter.feature.utils.PlatformUtils;
|
||||
import com.gh.gamecenter.manager.DataCollectionManager;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -32,7 +29,7 @@ public class DataCollectionUtils {
|
||||
map.put("type", android.os.Build.MODEL);
|
||||
map.put("system", android.os.Build.VERSION.SDK_INT + "=" + android.os.Build.VERSION.RELEASE);
|
||||
// WIFI实时
|
||||
DataCollectionManager.onEvent(context, "error", map, NetworkUtils.isWifiConnected(context));
|
||||
DataCollectionManager.onEvent(context, "error", map, true);
|
||||
}
|
||||
|
||||
// 上传下载数据(开始、完成)
|
||||
|
||||
@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1988,7 +1988,7 @@ object DirectUtils {
|
||||
val qGameProvider = ARouter
|
||||
.getInstance()
|
||||
.build(RouteConsts.provider.qGame)
|
||||
.navigation() as IQGameProvider<*>
|
||||
.navigation() as IQGameProvider
|
||||
qGameProvider.setLoginInfo(activity, userId, userName, userToken)
|
||||
qGameProvider.launchGame(activity, qqGameId) { _, _ ->
|
||||
RetrofitManager
|
||||
|
||||
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,5 +1,6 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.pm.ApplicationInfo
|
||||
import android.content.pm.PackageInfo
|
||||
@ -7,15 +8,29 @@ 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 java.io.BufferedReader
|
||||
import java.io.IOException
|
||||
import java.io.InputStreamReader
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.coroutines.*
|
||||
import kotlin.collections.ArrayList
|
||||
import kotlin.collections.HashSet
|
||||
|
||||
@ -29,10 +44,15 @@ object PackageHelper {
|
||||
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 installedPackageList: List<PackageInfo> = arrayListOf()
|
||||
private var isGetInstalledPackagesApiAgreed = false
|
||||
private var isGetInstalledListPermissionSupported = UNKNOWN // 设备是否支持禁用获取已安装应用列表。-1 代表支持情况未知,0 代表不支持, 1 代表支持
|
||||
private var cachedInstalledPackagesList: List<PackageInfo> = arrayListOf()
|
||||
|
||||
private var isGetInstalledPackagesApiAgreed = true // 用户是否已经同意使用已安装应用列表 API
|
||||
private var isGetInstalledPackagesApiAgreedRequired = DISABLED // 需要用户手动授权才获取已安装应用列表的功能的开关
|
||||
private var isGetInstalledPackagesPermissionSupported = UNKNOWN // 设备是否支持禁用获取已安装应用列表
|
||||
|
||||
// 评论黑名单包名列表,避免用户安装了 Xposed Installer 这样的工具,也能在包含该安装包的游戏详情页评论
|
||||
private var _commentPackageNameBlackList = arrayListOf<String>()
|
||||
@ -50,6 +70,10 @@ object PackageHelper {
|
||||
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>()
|
||||
get() {
|
||||
@ -61,6 +85,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)
|
||||
@ -109,6 +149,44 @@ object PackageHelper {
|
||||
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 中获取并更新
|
||||
@ -118,12 +196,18 @@ object PackageHelper {
|
||||
|| (SPUtils.getBoolean(SP_GET_INSTALLED_API_AGREED).also { isGetInstalledPackagesApiAgreed = it })
|
||||
}
|
||||
|
||||
fun isGetInstalledPackagesApiAgreedRequired(): Boolean {
|
||||
return isGetInstalledPackagesApiAgreedRequired == ENABLED
|
||||
}
|
||||
|
||||
/**
|
||||
* 同意使用已安装应用列表 API
|
||||
*/
|
||||
fun agreeOnGetInstalledPackagesApi() {
|
||||
private fun agreeOnGetInstalledPackagesApi() {
|
||||
isGetInstalledPackagesApiAgreed = true
|
||||
SPUtils.setBoolean(SP_GET_INSTALLED_API_AGREED, true)
|
||||
|
||||
_installedPackageApiSwitchStatusLiveData.postValue(false)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -132,18 +216,16 @@ object PackageHelper {
|
||||
fun getInstalledPackages(context: Context?, flags: Int): List<PackageInfo> {
|
||||
Utils.log(TAG, "即将获取已安装应用列表")
|
||||
|
||||
// Utils.log(TAG, "即将获取已安装应用列表" + Thread.currentThread().getStackTrace().contentToString().replace( ',', '\n' ))
|
||||
|
||||
// 用户未同意使用已安装应用列表 API,返回空列表
|
||||
if (!isGetInstalledPackagesApiAgreed()) {
|
||||
Utils.log(TAG, "用户未同意使用已安装应用列表 API,返回空列表")
|
||||
return installedPackageList
|
||||
return cachedInstalledPackagesList
|
||||
}
|
||||
|
||||
// 简单 debounce 过于频繁的获取已安装应用列表调用
|
||||
if (System.currentTimeMillis() - lastInstalledPackageListTime < 3000 && installedPackageList.isNotEmpty()) {
|
||||
if (System.currentTimeMillis() - lastInstalledPackageListTime < 20000 && cachedInstalledPackagesList.isNotEmpty()) {
|
||||
Utils.log(TAG, "使用了缓存的已安装应用列表")
|
||||
return installedPackageList
|
||||
return cachedInstalledPackagesList
|
||||
}
|
||||
|
||||
var shouldGetNewInstalledPackagedList = false
|
||||
@ -165,19 +247,107 @@ object PackageHelper {
|
||||
|
||||
if (shouldGetNewInstalledPackagedList) {
|
||||
lastInstalledPackageListTime = System.currentTimeMillis()
|
||||
installedPackageList = getInstalledPackagesInternal(context, flags)
|
||||
cachedInstalledPackagesList = getInstalledPackagesInternal(context, flags)
|
||||
}
|
||||
|
||||
return installedPackageList
|
||||
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 {
|
||||
return false
|
||||
|
||||
// 若存在缓存,直接返回缓存结果。
|
||||
if (isGetInstalledListPermissionSupported != UNKNOWN) {
|
||||
return isGetInstalledListPermissionSupported != UNSUPPORTED
|
||||
if (isGetInstalledPackagesPermissionSupported != UNKNOWN) {
|
||||
return isGetInstalledPackagesPermissionSupported != UNSUPPORTED
|
||||
}
|
||||
|
||||
try {
|
||||
@ -185,7 +355,7 @@ object PackageHelper {
|
||||
val flag =
|
||||
Settings.Secure.getInt(context.contentResolver, "oem_installed_apps_runtime_permission_enable", 0)
|
||||
if (flag == 1) {
|
||||
isGetInstalledListPermissionSupported = SUPPORTED
|
||||
isGetInstalledPackagesPermissionSupported = SUPPORTED
|
||||
return true
|
||||
}
|
||||
|
||||
@ -194,22 +364,97 @@ object PackageHelper {
|
||||
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) {
|
||||
isGetInstalledListPermissionSupported = SUPPORTED
|
||||
isGetInstalledPackagesPermissionSupported = SUPPORTED
|
||||
return true
|
||||
} else {
|
||||
isGetInstalledListPermissionSupported = UNSUPPORTED
|
||||
isGetInstalledPackagesPermissionSupported = UNSUPPORTED
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
isGetInstalledListPermissionSupported = UNSUPPORTED
|
||||
isGetInstalledPackagesPermissionSupported = UNSUPPORTED
|
||||
return false
|
||||
}
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
isGetInstalledListPermissionSupported = UNSUPPORTED
|
||||
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
|
||||
@ -219,37 +464,42 @@ object PackageHelper {
|
||||
|
||||
val pm = context.packageManager
|
||||
try {
|
||||
return pm.getInstalledPackages(flags)
|
||||
return getInstalledPackageAlternative(context)
|
||||
// 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 arrayListOf()
|
||||
}
|
||||
|
||||
private fun getInstalledPackageAlternative(context: Context): ArrayList<PackageInfo> {
|
||||
val packageManager = context.getPackageManager()
|
||||
val packageList = arrayListOf<PackageInfo>()
|
||||
var packagesArray: Array<String>? = null
|
||||
var uid = android.os.Process.FIRST_APPLICATION_UID
|
||||
|
||||
while (uid <= android.os.Process.LAST_APPLICATION_UID) {
|
||||
packagesArray = packageManager.getPackagesForUid(uid)
|
||||
if (packagesArray != null && packagesArray.isNotEmpty()) {
|
||||
Utils.log("fuck me $uid")
|
||||
|
||||
for (packageName in packagesArray) {
|
||||
try {
|
||||
val packageInfo = packageManager.getPackageInfo(packageName, 0)
|
||||
if (packageInfo == null) {
|
||||
break
|
||||
}
|
||||
|
||||
packageList.add(packageInfo)
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
uid++
|
||||
}
|
||||
return result
|
||||
|
||||
return packageList
|
||||
}
|
||||
|
||||
}
|
||||
@ -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,7 +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.PermissionHelper;
|
||||
import com.gh.gamecenter.core.utils.MD5Utils;
|
||||
import com.gh.gamecenter.core.utils.SentryHelper;
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity;
|
||||
@ -48,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;
|
||||
@ -74,7 +69,7 @@ public class PackageUtils {
|
||||
return HaloApp.getInstance().getApplication().getPackageManager().getPackageInfo(packageName,
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT).applicationInfo.sourceDir;
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
// do nothing
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -312,7 +307,7 @@ public class PackageUtils {
|
||||
return new String[]{null, null};
|
||||
}
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
// do nothing
|
||||
}
|
||||
return new String[]{null, null};
|
||||
}
|
||||
@ -592,7 +587,7 @@ public class PackageUtils {
|
||||
.getPackageInfo(packageName, 0);
|
||||
return packageInfo.firstInstallTime;
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
// do nothing
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -619,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;
|
||||
@ -633,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;
|
||||
}
|
||||
@ -646,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;
|
||||
}
|
||||
@ -660,7 +655,7 @@ public class PackageUtils {
|
||||
PackageManager packageManager = context.getApplicationContext().getPackageManager();
|
||||
return packageManager.getApplicationIcon(packageName);
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
// do nothing
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -10,8 +10,8 @@ import com.gh.gamecenter.common.exposure.meta.MetaUtil
|
||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil.getMeta
|
||||
import com.gh.gamecenter.common.loghub.LoghubUtils
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.utils.SentryHelper
|
||||
import com.gh.ndownload.NDataChanger
|
||||
import com.gh.ndownload.NDownloadBridge
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.DownloadConfig
|
||||
import com.lightgame.download.DownloadEntity
|
||||
@ -124,6 +124,7 @@ object DownloadDataHelper {
|
||||
val payloadObject = JSONObject()
|
||||
payloadObject.put("host", downloadEntity.meta[DownloadEntity.DOWNLOAD_HOST_KEY] ?: "unknown")
|
||||
payloadObject.put("path", downloadEntity.meta[DownloadEntity.DOWNLOAD_PATH_KEY] ?: "unknown")
|
||||
payloadObject.put("redirected_host_list", downloadEntity.meta[NDownloadBridge.REDIRECTED_HOST_LIST] ?: "unknown")
|
||||
payloadObject.put("game_id", downloadEntity.gameId)
|
||||
payloadObject.put("gameName", downloadEntity.name)
|
||||
payloadObject.put("platform", downloadEntity.platform)
|
||||
@ -212,6 +213,7 @@ object DownloadDataHelper {
|
||||
|
||||
payloadObject.put("host", downloadEntity.meta[DownloadEntity.DOWNLOAD_HOST_KEY] ?: "unknown")
|
||||
payloadObject.put("path", downloadEntity.meta[DownloadEntity.DOWNLOAD_PATH_KEY] ?: "unknown")
|
||||
payloadObject.put("redirected_host_list", downloadEntity.meta[NDownloadBridge.REDIRECTED_HOST_LIST] ?: "unknown")
|
||||
payloadObject.put("game_id", downloadEntity.gameId)
|
||||
payloadObject.put("gameName", downloadEntity.name)
|
||||
payloadObject.put("platform", downloadEntity.platform)
|
||||
@ -251,6 +253,7 @@ object DownloadDataHelper {
|
||||
|
||||
payloadObject.put("host", downloadEntity.meta[DownloadEntity.DOWNLOAD_HOST_KEY] ?: "unknown")
|
||||
payloadObject.put("path", downloadEntity.meta[DownloadEntity.DOWNLOAD_PATH_KEY] ?: "unknown")
|
||||
payloadObject.put("redirected_host_list", downloadEntity.meta[NDownloadBridge.REDIRECTED_HOST_LIST] ?: "unknown")
|
||||
payloadObject.put("game_id", downloadEntity.gameId)
|
||||
payloadObject.put("gameName", downloadEntity.name)
|
||||
payloadObject.put("platform", downloadEntity.platform)
|
||||
@ -315,6 +318,7 @@ object DownloadDataHelper {
|
||||
|
||||
payloadObject.put("host", downloadEntity.meta[DownloadEntity.DOWNLOAD_HOST_KEY] ?: "unknown")
|
||||
payloadObject.put("path", downloadEntity.meta[DownloadEntity.DOWNLOAD_PATH_KEY] ?: "unknown")
|
||||
payloadObject.put("redirected_host_list", downloadEntity.meta[NDownloadBridge.REDIRECTED_HOST_LIST] ?: "unknown")
|
||||
payloadObject.put("game_id", downloadEntity.gameId)
|
||||
payloadObject.put("gameName", downloadEntity.name)
|
||||
payloadObject.put("platform", downloadEntity.platform)
|
||||
@ -357,6 +361,7 @@ object DownloadDataHelper {
|
||||
sheet = JSONObject()
|
||||
sheet.put("host", downloadEntity.meta[DownloadEntity.DOWNLOAD_HOST_KEY] ?: "unknown")
|
||||
sheet.put("path", downloadEntity.meta[DownloadEntity.DOWNLOAD_PATH_KEY] ?: "unknown")
|
||||
sheet.put("redirected_host_list", downloadEntity.meta[NDownloadBridge.REDIRECTED_HOST_LIST] ?: "unknown")
|
||||
sheet.put("game_id", downloadEntity.gameId)
|
||||
sheet.put("platform", downloadEntity.platform)
|
||||
sheet.put("package", downloadEntity.packageName)
|
||||
@ -376,6 +381,7 @@ object DownloadDataHelper {
|
||||
"path",
|
||||
downloadEntity.meta[DownloadEntity.DOWNLOAD_PATH_KEY] ?: "unknown"
|
||||
) // 初始化记录的 path 为空
|
||||
sheet.put("redirected_host_list", downloadEntity.meta[NDownloadBridge.REDIRECTED_HOST_LIST] ?: "unknown")
|
||||
sheet.put("total_size", downloadEntity.size / 1024 / 1024) // 初始化记录的 total_size 有可能为0
|
||||
sheet.put("progress_size", downloadEntity.progress / 1024 - progressSize)
|
||||
sheet.put("current_progress_size", downloadEntity.progress / 1024)
|
||||
|
||||
@ -22,7 +22,6 @@ import com.gh.gamecenter.core.AppExecutor;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.feature.entity.TagStyleEntity;
|
||||
import com.gh.gamecenter.feature.entity.CustomPageTrackData;
|
||||
import com.gh.gamecenter.feature.entity.TagStyleEntity;
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent;
|
||||
import com.gh.common.exposure.ExposureUtils;
|
||||
import com.gh.common.history.HistoryHelper;
|
||||
@ -34,16 +33,10 @@ import com.gh.common.util.LunchType;
|
||||
import com.gh.common.util.PackageInstaller;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.common.base.GlobalActivityManager;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil;
|
||||
import com.gh.gamecenter.common.utils.DeviceUtils;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.common.utils.FileUtils;
|
||||
import com.gh.gamecenter.common.utils.NetworkUtils;
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge;
|
||||
import com.gh.gamecenter.core.AppExecutor;
|
||||
import com.gh.gamecenter.core.utils.AppDebugConfig;
|
||||
import com.gh.gamecenter.core.utils.GsonUtils;
|
||||
import com.gh.gamecenter.core.utils.PageSwitchDataHelper;
|
||||
import com.gh.gamecenter.core.utils.SPUtils;
|
||||
@ -55,7 +48,6 @@ import com.gh.gamecenter.eventbus.EBDownloadStatus;
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity;
|
||||
import com.gh.gamecenter.feature.entity.GameEntity;
|
||||
import com.gh.gamecenter.feature.entity.PluginLocation;
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent;
|
||||
import com.gh.gamecenter.login.user.UserManager;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository;
|
||||
@ -64,7 +56,6 @@ import com.gh.ndownload.NDownloadBridge;
|
||||
import com.gh.ndownload.NDownloadService;
|
||||
import com.gh.vspace.VHelper;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.download.ConnectionUtils;
|
||||
import com.lightgame.download.DataWatcher;
|
||||
import com.lightgame.download.DownloadConfig;
|
||||
import com.lightgame.download.DownloadDao;
|
||||
@ -179,9 +170,6 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
|
||||
mUpdateMarks = SPUtils.getStringSet(UPDATE_IS_READ_MARK);
|
||||
|
||||
// 只有下载模块需要这坨东西,因此移动到这里初始化
|
||||
ConnectionUtils.initHttpsUrlConnection(mContext);
|
||||
|
||||
updateDownloadMetaMap();
|
||||
|
||||
lastTimeMap = new ArrayMap<>();
|
||||
|
||||
@ -10,6 +10,9 @@ import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
import com.gh.gamecenter.entity.SubjectRecommendEntity
|
||||
import com.gh.gamecenter.game.GameFragment
|
||||
|
||||
/**
|
||||
* 板块
|
||||
*/
|
||||
class BlockActivity : DownloadToolbarActivity() {
|
||||
|
||||
companion object {
|
||||
|
||||
@ -14,6 +14,7 @@ import com.halo.assistant.fragment.ApkCleanerFragment;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/1/24.
|
||||
* 清理安装包
|
||||
*/
|
||||
@Route(path = RouteConsts.activity.cleanApkActivity)
|
||||
public class CleanApkActivity extends ToolBarActivity {
|
||||
|
||||
@ -16,6 +16,7 @@ import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by khy on 18/07/17.
|
||||
* 我的收藏
|
||||
*/
|
||||
public class CollectionActivity extends ToolBarActivity {
|
||||
@Override
|
||||
|
||||
@ -23,6 +23,9 @@ import java.lang.ref.SoftReference;
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
/**
|
||||
* 裁剪图片
|
||||
*/
|
||||
public class CropImageActivity extends ToolBarActivity {
|
||||
|
||||
protected CropImageCustom mCropImageCustom;
|
||||
|
||||
@ -24,7 +24,7 @@ import com.halo.assistant.HaloApp
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/3/24.
|
||||
* 游戏详情适配器
|
||||
* 游戏详情页
|
||||
*/
|
||||
class GameDetailActivity : DownloadToolbarActivity() {
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@ import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by khy on 2016/12/12.
|
||||
* 礼包中心
|
||||
*/
|
||||
@Deprecated
|
||||
public class LibaoActivity extends ToolBarActivity {
|
||||
|
||||
@ -285,9 +285,6 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
// 耗时操作
|
||||
AppExecutor.getIoExecutor().execute(() -> {
|
||||
// 上传数据
|
||||
DataCollectionManager.getInstance().upload();
|
||||
|
||||
// 初始化PlatformUtils
|
||||
PlatformUtils.getInstance(getApplicationContext());
|
||||
|
||||
@ -556,7 +553,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -877,13 +877,6 @@ public class MainActivity extends BaseActivity {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
// 上传数据
|
||||
DataCollectionManager.getInstance().statClickData();
|
||||
super.finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(@NotNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
@ -29,6 +29,9 @@ import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
* 游戏搜索页
|
||||
*/
|
||||
open class SearchActivity : BaseActivity() {
|
||||
|
||||
lateinit var searchEt: EditText
|
||||
|
||||
@ -48,6 +48,7 @@ import io.reactivex.functions.Consumer;
|
||||
|
||||
/**
|
||||
* Created by khy on 2016/11/7.
|
||||
* 分享卡片
|
||||
*/
|
||||
public class ShareCardPicActivity extends ToolBarActivity {
|
||||
|
||||
|
||||
@ -21,6 +21,7 @@ import com.tencent.tauth.Tencent;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/2/6.
|
||||
* 分享光环
|
||||
*/
|
||||
public class ShareGhActivity extends ToolBarActivity {
|
||||
|
||||
|
||||
@ -167,10 +167,10 @@ class SplashScreenActivity : BaseActivity() {
|
||||
if (isMalfunctioningHonorDevice) {
|
||||
showHonorNotification()
|
||||
mBaseHandler.postDelayed({
|
||||
requestGetInstallListPermissionAndLaunchMainActivity()
|
||||
launchMainActivity()
|
||||
}, 100L)
|
||||
} else {
|
||||
requestGetInstallListPermissionAndLaunchMainActivity()
|
||||
launchMainActivity()
|
||||
}
|
||||
} else {
|
||||
DialogUtils.showPrivacyPolicyDisallowDialog(this) {
|
||||
@ -197,7 +197,15 @@ class SplashScreenActivity : BaseActivity() {
|
||||
|
||||
// 尝试获取安装应用列表权限并启动首页(不在乎结果)
|
||||
private fun requestGetInstallListPermissionAndLaunchMainActivity() {
|
||||
launchMainActivity()
|
||||
if (PackageHelper.isSupportGetInstalledAppsPermission(this)
|
||||
&& PermissionHelper.isGetInstalledListPermissionDisabled(this)
|
||||
) {
|
||||
PermissionHelper.requestGetInstalledAppsListPermission(this, true) {
|
||||
launchMainActivity()
|
||||
}
|
||||
} else {
|
||||
launchMainActivity()
|
||||
}
|
||||
}
|
||||
|
||||
// 删除更新后的光环助手包
|
||||
|
||||
@ -7,6 +7,9 @@ import com.gh.gamecenter.common.base.activity.ToolBarActivity
|
||||
import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
import com.halo.assistant.fragment.user.UserInfoFragment
|
||||
|
||||
/**
|
||||
* 编辑资料
|
||||
*/
|
||||
class UserInfoActivity : ToolBarActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
@ -8,6 +8,9 @@ import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.login.user.UserViewModel
|
||||
import com.halo.assistant.fragment.user.UserInfoEditFragment
|
||||
|
||||
/**
|
||||
* 修改个人信息
|
||||
*/
|
||||
class UserInfoEditActivity : ToolBarActivity() {
|
||||
companion object {
|
||||
fun getIntent(context: Context, editType: String): Intent {
|
||||
|
||||
@ -8,6 +8,7 @@ import com.halo.assistant.fragment.user.SelectRegionFragment;
|
||||
|
||||
/**
|
||||
* Created by khy on 25/09/17.
|
||||
* 选择地区
|
||||
*/
|
||||
public class UserRegionActivity extends ToolBarActivity {
|
||||
|
||||
|
||||
@ -15,7 +15,9 @@ import com.gh.gamecenter.common.utils.viewModelProvider
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.databinding.ActivityAuthorizationBinding
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.gh.gamecenter.login.view.LoginActivity
|
||||
import com.gh.vspace.VHelper
|
||||
import com.lightgame.utils.Utils
|
||||
|
||||
/**
|
||||
* @author : liujiarui
|
||||
@ -162,9 +164,12 @@ class AuthorizationActivity : ToolBarActivity() {
|
||||
|
||||
private fun checkLogin(block: () -> Unit) {
|
||||
//判断光环是否登陆
|
||||
CheckLoginUtils.checkLogin(this, "光环助手授权登陆") {
|
||||
if (CheckLoginUtils.isLogin()) {
|
||||
initData()
|
||||
block()
|
||||
} else {
|
||||
Utils.toast(this, "需要登录")
|
||||
startActivity(LoginActivity.getIntent(this, "光环助手授权登陆"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,9 @@ import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
|
||||
/**
|
||||
* 新分类2.0
|
||||
*/
|
||||
class CategoryV2Activity : DownloadToolbarActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
@ -41,6 +41,9 @@ import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* 云存档管理
|
||||
*/
|
||||
class CloudArchiveManagerActivity : BaseActivity_TabLayout(), ArchiveLimitSelectedListener {
|
||||
|
||||
private lateinit var mBinding: ActivityCloudArchiveManagerBinding
|
||||
|
||||
@ -1,120 +0,0 @@
|
||||
package com.gh.gamecenter.db;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.gh.gamecenter.db.info.DataCollectionInfo;
|
||||
import com.j256.ormlite.dao.Dao;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
// TODO 这个数据库其实没有用了,上传到 loghub 已经有相关的逻辑处理,有空删掉它
|
||||
public class DataCollectionDao {
|
||||
|
||||
private DatabaseHelper helper;
|
||||
private Dao<DataCollectionInfo, String> dao;
|
||||
|
||||
public DataCollectionDao(Context context) {
|
||||
try {
|
||||
helper = DatabaseHelper.getHelper(context);
|
||||
dao = helper.getDao(DataCollectionInfo.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找一个数据
|
||||
*/
|
||||
public List<DataCollectionInfo> findByType(String type) {
|
||||
try {
|
||||
return dao.queryForEq("type", type);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加一个数据
|
||||
*/
|
||||
public void add(DataCollectionInfo entity) {
|
||||
try {
|
||||
dao.create(entity);
|
||||
} catch (Exception e) {
|
||||
// java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase:
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除一个数据
|
||||
*/
|
||||
public void delete(String id) {
|
||||
try {
|
||||
dao.deleteById(id);
|
||||
} catch (Exception e) {
|
||||
// java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase:
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除一组数据
|
||||
*/
|
||||
public void delete(List<String> ids) {
|
||||
try {
|
||||
dao.deleteIds(ids);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id获取某一个数据
|
||||
*/
|
||||
public DataCollectionInfo find(String id) {
|
||||
try {
|
||||
return dao.queryForId(id);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有的数据
|
||||
*/
|
||||
public List<DataCollectionInfo> getAll() {
|
||||
try {
|
||||
return dao.queryForAll();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取点击数据
|
||||
*/
|
||||
public List<DataCollectionInfo> getClickData() {
|
||||
try {
|
||||
return dao.queryForEq("type", "click-item");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
*/
|
||||
public void update(DataCollectionInfo entity) {
|
||||
try {
|
||||
dao.update(entity);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -5,9 +5,7 @@ import android.database.sqlite.SQLiteDatabase;
|
||||
|
||||
import androidx.collection.ArrayMap;
|
||||
|
||||
import com.gh.gamecenter.db.info.DataCollectionInfo;
|
||||
import com.gh.gamecenter.db.info.GameTrendsInfo;
|
||||
import com.gh.gamecenter.db.info.PackageInfo;
|
||||
import com.gh.gamecenter.db.info.SearchHistoryInfo;
|
||||
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
|
||||
import com.j256.ormlite.dao.Dao;
|
||||
@ -52,8 +50,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||
try {
|
||||
Utils.log("DatabaseHelper onCreate");
|
||||
TableUtils.createTable(connectionSource, SearchHistoryInfo.class);
|
||||
TableUtils.createTable(connectionSource, DataCollectionInfo.class);
|
||||
TableUtils.createTable(connectionSource, PackageInfo.class);
|
||||
TableUtils.createTable(connectionSource, GameTrendsInfo.class);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
@ -65,8 +61,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||
try {
|
||||
Utils.log("DatabaseHelper onUpgrade");
|
||||
TableUtils.dropTable(connectionSource, SearchHistoryInfo.class, true);
|
||||
TableUtils.dropTable(connectionSource, DataCollectionInfo.class, true);
|
||||
TableUtils.dropTable(connectionSource, PackageInfo.class, true);
|
||||
TableUtils.dropTable(connectionSource, GameTrendsInfo.class, true);
|
||||
onCreate(database, connectionSource);
|
||||
} catch (SQLException e) {
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
package com.gh.gamecenter.db.info;
|
||||
|
||||
import com.j256.ormlite.field.DatabaseField;
|
||||
import com.j256.ormlite.table.DatabaseTable;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@DatabaseTable(tableName = "tb_datacollection")
|
||||
public class DataCollectionInfo implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3196892351397147390L;
|
||||
|
||||
@DatabaseField(id = true, columnName = "id")
|
||||
private String id;
|
||||
|
||||
@DatabaseField(columnName = "type")
|
||||
private String type;
|
||||
|
||||
@DatabaseField(columnName = "data")
|
||||
private String data;
|
||||
|
||||
public DataCollectionInfo() {
|
||||
|
||||
}
|
||||
|
||||
public DataCollectionInfo(String id, String type, String data) {
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DataCollectionEntity [id=" + id + ", type=" + type + ", data="
|
||||
+ data + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,42 +0,0 @@
|
||||
package com.gh.gamecenter.db.info;
|
||||
|
||||
import com.j256.ormlite.field.DatabaseField;
|
||||
import com.j256.ormlite.table.DatabaseTable;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@DatabaseTable(tableName = "tb_package")
|
||||
public class PackageInfo implements Serializable {
|
||||
|
||||
@DatabaseField(id = true, columnName = "packageName")
|
||||
private String packageName;
|
||||
|
||||
@DatabaseField(columnName = "time")
|
||||
private long time;
|
||||
|
||||
public PackageInfo() {
|
||||
|
||||
}
|
||||
|
||||
public PackageInfo(String packageName, long time) {
|
||||
this.packageName = packageName;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
}
|
||||
@ -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.showGetInstalledAppsListPermissionDialogAndRequestPermission(requireActivity()) {
|
||||
updateNoDataView()
|
||||
PackageRepository.initData()
|
||||
PackageHelper.showGetInstallAppsListDialogAndRequestPermissionIfNeeded(requireActivity()) { isGranted ->
|
||||
if (isGranted) {
|
||||
updateNoDataView()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -3,6 +3,7 @@ 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.R
|
||||
import com.gh.gamecenter.common.base.fragment.LazyFragment
|
||||
@ -94,18 +95,19 @@ 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.showGetInstalledAppsListPermissionDialogAndRequestPermission(
|
||||
requireActivity()
|
||||
) { isGranted ->
|
||||
PackageHelper.showGetInstallAppsListDialogAndRequestPermissionIfNeeded(requireActivity()) { isGranted ->
|
||||
if (isGranted) {
|
||||
updateNoDataView()
|
||||
PackageRepository.initData()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
)
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package com.gh.gamecenter.entity
|
||||
|
||||
class WhitePackageListEntity {
|
||||
var data: HashSet<String>? = null
|
||||
}
|
||||
@ -10,6 +10,9 @@ import com.gh.gamecenter.common.base.activity.BaseActivity
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
|
||||
/**
|
||||
* 论坛详情
|
||||
*/
|
||||
class ForumDetailActivity : BaseActivity() {
|
||||
|
||||
private var mContainerFragment: Fragment? = null
|
||||
|
||||
@ -8,6 +8,9 @@ import com.gh.gamecenter.common.base.activity.BaseActivity
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts.IS_DETAIL_PAGE
|
||||
import com.gh.gamecenter.video.detail.HomeVideoFragment
|
||||
|
||||
/**
|
||||
* 社区首页
|
||||
*/
|
||||
class CommunityActivity : BaseActivity() {
|
||||
|
||||
override fun getLayoutId(): Int = R.layout.activity_community
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -9,6 +9,9 @@ import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
|
||||
/**
|
||||
* 关注论坛/热门论坛/综合论坛
|
||||
*/
|
||||
class ForumListActivity : ToolBarActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
@ -12,6 +12,9 @@ import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.entity.ApplyModeratorStatusEntity
|
||||
|
||||
/**
|
||||
* 版主申请
|
||||
*/
|
||||
class ApplyModeratorActivity : ToolBarActivity() {
|
||||
companion object {
|
||||
fun getIntent(context: Context, bbsId: String, status: ApplyModeratorStatusEntity): Intent {
|
||||
|
||||
@ -8,6 +8,9 @@ import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
|
||||
/**
|
||||
* 版主列表
|
||||
*/
|
||||
class ModeratorListActivity : ToolBarActivity() {
|
||||
|
||||
companion object {
|
||||
|
||||
@ -20,6 +20,9 @@ import com.gh.gamecenter.forum.detail.ForumDetailFragment
|
||||
import com.gh.gamecenter.search.SearchDefaultFragment
|
||||
import com.lightgame.utils.Util_System_Keyboard
|
||||
|
||||
/**
|
||||
* 论坛搜索
|
||||
*/
|
||||
class ForumOrUserSearchActivity : SearchActivity() {
|
||||
|
||||
private var mBbsId = ""
|
||||
|
||||
@ -9,6 +9,9 @@ import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.exposure.ExposureSource
|
||||
import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
|
||||
/**
|
||||
* 通用内容合集详情
|
||||
*/
|
||||
class CommonCollectionDetailActivity : ToolBarActivity() {
|
||||
|
||||
override fun provideNormalIntent(): Intent {
|
||||
|
||||
@ -9,6 +9,9 @@ import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.exposure.ExposureSource
|
||||
import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
|
||||
/**
|
||||
* 旧 通用内容合集详情
|
||||
*/
|
||||
class CustomCommonCollectionDetailActivity : ToolBarActivity() {
|
||||
|
||||
override fun provideNormalIntent(): Intent {
|
||||
|
||||
@ -15,13 +15,15 @@ import com.gh.gamecenter.core.utils.StringUtils
|
||||
import com.gh.gamecenter.entity.SubjectEntity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.subjectTypeToComponentStyle
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter
|
||||
import com.lightgame.download.DownloadEntity
|
||||
|
||||
class GameHorizontalAdapter(
|
||||
context: Context,
|
||||
private var mSubjectEntity: SubjectEntity,
|
||||
private var type: GameHorizontalListType = GameHorizontalListType.SubjectHorizontalType
|
||||
private var type: GameHorizontalListType = GameHorizontalListType.SubjectHorizontalType,
|
||||
private val trackColumnClick: Boolean = true
|
||||
) : BaseRecyclerAdapter<GameHorizontalItemViewHolder>(context) {
|
||||
|
||||
var gameName = ""
|
||||
@ -55,7 +57,7 @@ class GameHorizontalAdapter(
|
||||
val size = mSubjectEntity.data!!.size - getIndex()
|
||||
return if (type == GameHorizontalListType.GameDetailHorizontalType) {
|
||||
size
|
||||
} else if (type == GameHorizontalListType.QGameSubjectHorizontalType){
|
||||
} else if (type == GameHorizontalListType.QGameSubjectHorizontalType) {
|
||||
mSubjectEntity.data!!.size
|
||||
} else {
|
||||
when {
|
||||
@ -109,8 +111,8 @@ class GameHorizontalAdapter(
|
||||
DataCollectionUtils.uploadClick(mContext, path, "游戏详情", gameEntity.name)
|
||||
NewLogUtils.logGameDetailPopularClick(gameName, gameId, "game", gameEntity.name ?: "")
|
||||
SensorsBridge.trackGameDetailPagePopularClick(
|
||||
gameId = gameName,
|
||||
gameName = gameId,
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
pageName = GlobalActivityManager.getCurrentPageEntity().pageName,
|
||||
pageId = GlobalActivityManager.getCurrentPageEntity().pageId,
|
||||
pageBusinessId = GlobalActivityManager.getCurrentPageEntity().pageBusinessId,
|
||||
@ -123,14 +125,15 @@ class GameHorizontalAdapter(
|
||||
clickGameName = gameEntity.name ?: "",
|
||||
clickGameId = gameEntity.id
|
||||
)
|
||||
if (!gameEntity.isQQMiniGame()) {
|
||||
if (!gameEntity.isQQMiniGame() && trackColumnClick) {
|
||||
SensorsBridge.trackColumnClick(
|
||||
location = "游戏详情",
|
||||
gameName = gameName,
|
||||
gameId = gameId,
|
||||
gameColumnName = mSubjectEntity.name ?: "",
|
||||
gameColumnId = mSubjectEntity.id ?: "",
|
||||
text = "游戏"
|
||||
text = "游戏",
|
||||
columnPattern = subjectTypeToComponentStyle[mSubjectEntity.type] ?: ""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,9 @@ import com.gh.gamecenter.common.base.activity.ToolBarActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
|
||||
/**
|
||||
* 选择游戏-添加游戏
|
||||
*/
|
||||
class AddGamesActivity : ToolBarActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
@ -7,6 +7,9 @@ import com.gh.gamecenter.common.base.activity.ToolBarActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
|
||||
/**
|
||||
* 选择游戏
|
||||
*/
|
||||
class ChooseGamesActivity : ToolBarActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
@ -10,6 +10,9 @@ import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.common.exposure.ExposureSource
|
||||
|
||||
/**
|
||||
* 游戏单详情
|
||||
*/
|
||||
class GameCollectionDetailActivity : ToolBarActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -9,6 +9,9 @@ import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.entity.GamesCollectionDetailEntity
|
||||
|
||||
/**
|
||||
* 游戏单详情-封面页
|
||||
*/
|
||||
class GameCollectionPosterActivity : ToolBarActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
@ -4,6 +4,9 @@ import android.os.Bundle
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity
|
||||
|
||||
/**
|
||||
* 游戏单热榜
|
||||
*/
|
||||
class GameCollectionHotListActivity : BaseActivity() {
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.activity_amway
|
||||
|
||||
@ -8,6 +8,9 @@ import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
import com.gh.gamecenter.entity.GameCollectionListEntity
|
||||
|
||||
/**
|
||||
* 游戏单合集详情
|
||||
*/
|
||||
class GameCollectionListDetailActivity : ToolBarActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
@ -7,6 +7,9 @@ import com.gh.gamecenter.common.base.activity.ToolBarActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
|
||||
/**
|
||||
* 我的游戏单
|
||||
*/
|
||||
class MyGameCollectionActivity : ToolBarActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
@ -37,6 +37,9 @@ import com.zhihu.matisse.internal.utils.PathUtils
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.json.JSONObject
|
||||
|
||||
/**
|
||||
* 创建/编辑游戏单
|
||||
*/
|
||||
class GameCollectionEditActivity : ToolBarActivity() {
|
||||
|
||||
private lateinit var mMenuPost: MenuItem
|
||||
|
||||
@ -5,6 +5,9 @@ import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
|
||||
/**
|
||||
* 游戏单广场
|
||||
*/
|
||||
class GameCollectionSquareActivity : BaseActivity() {
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.activity_amway
|
||||
|
||||
@ -8,6 +8,9 @@ import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
import com.gh.gamecenter.entity.TagInfoEntity
|
||||
|
||||
/**
|
||||
* 游戏单选择标签
|
||||
*/
|
||||
class GameCollectionTagSelectActivity : ToolBarActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
@ -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
|
||||
|
||||
@ -302,7 +302,7 @@ class DescAdapter(
|
||||
|
||||
galleryRv.layoutManager = LinearLayoutManager(mContext, RecyclerView.HORIZONTAL, false)
|
||||
subjectAdapter =
|
||||
GameHorizontalAdapter(mContext, subjectEntity, GameHorizontalListType.GameDetailHorizontalType)
|
||||
GameHorizontalAdapter(mContext, subjectEntity, GameHorizontalListType.GameDetailHorizontalType, false)
|
||||
subjectAdapter.gameName = mGameName
|
||||
subjectAdapter.game = mViewModel.game
|
||||
subjectAdapter.gameId = mViewModel.gameId ?: ""
|
||||
|
||||
@ -35,6 +35,9 @@ import org.greenrobot.eventbus.ThreadMode
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* 开服日历表
|
||||
*/
|
||||
class ServersCalendarActivity : ToolBarActivity() {
|
||||
private lateinit var mBinding: ActivityServersCalendarBinding
|
||||
private lateinit var mViewModel: ServersCalendarViewModel
|
||||
|
||||
@ -129,7 +129,7 @@ class ServersCalendarDetailNoDataDialog : BottomSheetDialogFragment() {
|
||||
HelpAndFeedbackBridge.startSuggestionActivity(
|
||||
it.context,
|
||||
SuggestType.GAME,
|
||||
"service"
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,9 @@ import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity_TabLayout
|
||||
import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
|
||||
/**
|
||||
* 开服订阅
|
||||
*/
|
||||
class ServersCalendarManagementActivity : BaseActivity_TabLayout() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
@ -9,6 +9,9 @@ import com.gh.gamecenter.common.base.activity.BaseActivity
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
/**
|
||||
* 历史版本
|
||||
*/
|
||||
class HistoryApkListActivity : ToolBarActivity() {
|
||||
|
||||
companion object {
|
||||
|
||||
@ -11,6 +11,7 @@ import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
/**
|
||||
* 我的游戏评论
|
||||
*/
|
||||
@Deprecated("已废弃")
|
||||
class MyRatingActivity : ToolBarActivity() {
|
||||
|
||||
companion object {
|
||||
|
||||
@ -45,6 +45,9 @@ import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import kotlin.math.abs
|
||||
|
||||
/**
|
||||
* 评价详情
|
||||
*/
|
||||
@Route(path = RouteConsts.activity.ratingReplyActivity)
|
||||
class RatingReplyActivity : ListActivity<RatingReplyEntity, RatingReplyViewModel>(),
|
||||
KeyboardHeightObserver {
|
||||
|
||||
@ -50,6 +50,9 @@ import okhttp3.RequestBody
|
||||
import org.json.JSONObject
|
||||
import retrofit2.HttpException
|
||||
|
||||
/**
|
||||
* 评论游戏/修改游戏评论
|
||||
*/
|
||||
class RatingEditActivity : ToolBarActivity(), KeyboardHeightObserver {
|
||||
|
||||
private var mPostDialog: WaitingDialogFragment? = null
|
||||
|
||||
@ -19,6 +19,9 @@ import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.Single
|
||||
|
||||
/**
|
||||
* 评论修改历史
|
||||
*/
|
||||
class CommentLogsActivity : ListActivity<RatingComment, NormalListViewModel<RatingComment>>() {
|
||||
|
||||
private var mAdapter: CommentLogsAdapter? = null
|
||||
|
||||
@ -9,6 +9,9 @@ import com.gh.gamecenter.common.base.activity.ToolBarActivity
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
|
||||
/**
|
||||
* 浏览记录
|
||||
*/
|
||||
class HistoryActivity : ToolBarActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
@ -116,8 +116,8 @@ class CustomGameHorizontalAdapter(
|
||||
DataCollectionUtils.uploadClick(context, path, "游戏详情", gameEntity.name)
|
||||
NewLogUtils.logGameDetailPopularClick(gameName, gameId, "game", gameEntity.name ?: "")
|
||||
SensorsBridge.trackGameDetailPagePopularClick(
|
||||
gameId = gameName,
|
||||
gameName = gameId,
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
pageName = GlobalActivityManager.getCurrentPageEntity().pageName,
|
||||
pageId = GlobalActivityManager.getCurrentPageEntity().pageId,
|
||||
pageBusinessId = GlobalActivityManager.getCurrentPageEntity().pageBusinessId,
|
||||
|
||||
@ -175,7 +175,7 @@ abstract class CustomPageItem(
|
||||
val subjectTypeToComponentStyle by lazy {
|
||||
hashMapOf(
|
||||
COMPONENTS_GAME_SUBJECT_TYPE_DOUBLE_CARD to "双列卡片",
|
||||
COMPONENTS_GAME_SUBJECT_TYPE_GAME_VIDEO_HORIZONTAL_SLIDE to "视频横屏滚动",
|
||||
COMPONENTS_GAME_SUBJECT_TYPE_GAME_VIDEO_HORIZONTAL_SLIDE to "视频横屏滑动",
|
||||
COMPONENTS_GAME_SUBJECT_TYPE_GAME_VERTICAL to "长列表式",
|
||||
COMPONENTS_SUBJECT_TYPE_GAME_VERTICAL_SLIDE to "滑动列表",
|
||||
COMPONENTS_SUBJECT_TYPE_GAME_HORIZONTAL to "图标矩阵",
|
||||
|
||||
@ -233,14 +233,14 @@ class CustomPageRepository private constructor(
|
||||
|
||||
var isAdded = false
|
||||
if (gameSubject != null && !gameSubject.data.isNullOrEmpty()) {
|
||||
// 替换游戏
|
||||
substituteGameIfNeeded(gameSubject)
|
||||
|
||||
// 记录已显示的游戏 id
|
||||
for (game in gameSubject.data!!) {
|
||||
displayingGameIdSet.add(game.id)
|
||||
}
|
||||
|
||||
// 替换游戏
|
||||
substituteGameIfNeeded(gameSubject)
|
||||
|
||||
if (gameSubject.tag == "update") {
|
||||
// 优先显示更新标签
|
||||
gameSubject.data?.forEach {
|
||||
|
||||
@ -4,14 +4,22 @@ import com.gh.gamecenter.common.entity.LinkEntity
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.entity.PageLocation
|
||||
import com.gh.gamecenter.home.custom.model.CustomGameItem
|
||||
import com.gh.gamecenter.home.custom.model.CustomPageItem
|
||||
import com.gh.gamecenter.home.custom.model.CustomSplitSubjectItem
|
||||
import com.gh.gamecenter.home.custom.model.CustomSubjectItem
|
||||
|
||||
class SubjectTracker(private val pageLocation: PageLocation) {
|
||||
|
||||
fun trackColumnClick(item: CustomPageItem, game: GameEntity?, text: String, buttonType: String = "", link: LinkEntity? = null) {
|
||||
fun trackColumnClick(
|
||||
item: CustomPageItem,
|
||||
game: GameEntity?,
|
||||
text: String,
|
||||
buttonType: String = "",
|
||||
link: LinkEntity? = null
|
||||
) {
|
||||
val subject = when {
|
||||
item is CustomGameItem -> item.linkColumn
|
||||
item is CustomSubjectItem -> item.data
|
||||
item is CustomSplitSubjectItem -> item.data
|
||||
else -> null
|
||||
@ -40,6 +48,7 @@ class SubjectTracker(private val pageLocation: PageLocation) {
|
||||
|
||||
fun trackQQGameClick(item: CustomPageItem, game: GameEntity) {
|
||||
val subject = when {
|
||||
item is CustomGameItem -> item.linkColumn
|
||||
item is CustomSubjectItem -> item.data
|
||||
item is CustomSplitSubjectItem -> item.data
|
||||
else -> null
|
||||
|
||||
@ -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, "自定义页面")
|
||||
|
||||
@ -47,7 +47,7 @@ class CustomHomeSlideListItemViewHolder(val binding: HomeSlideListItemCustomBind
|
||||
GameItemViewHolder.initGameSubtitleAndAdLabel(it, binding.includeGame.gameSubtitleTv)
|
||||
}
|
||||
|
||||
if (homeSlide.image != binding.slideBackground.tag) {
|
||||
if (homeSlide.image != binding.slideBackground.getTag(ImageUtils.TAG_BOUNDED_URL)) {
|
||||
binding.bottomGradient.visibility = View.GONE
|
||||
}
|
||||
binding.slideBackground.setTag(ImageUtils.TAG_TARGET_WIDTH, mImageWith)
|
||||
|
||||
@ -53,7 +53,7 @@ class CustomHomeSubSlideListItemViewHolder(val binding: HomeSubSlideListItemCust
|
||||
val startColor = Color.HSVToColor(colorHSV)
|
||||
val endColor = ColorUtils.setAlphaComponent(startColor, 0)
|
||||
|
||||
if (homeSlide.image != binding.slideBackground.tag) {
|
||||
if (homeSlide.image != binding.slideBackground.getTag(ImageUtils.TAG_BOUNDED_URL)) {
|
||||
binding.slideMask.visibility = View.GONE
|
||||
}
|
||||
binding.slideMask.background = GradientDrawable().apply {
|
||||
|
||||
@ -8,6 +8,9 @@ import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
/**
|
||||
* 外部跳转展示页
|
||||
*/
|
||||
class PackageSkipActivity : BaseActivity() {
|
||||
|
||||
override fun getLayoutId(): Int = R.layout.activity_amway
|
||||
|
||||
@ -47,7 +47,7 @@ class HomeSlideListItemViewHolder(val binding: HomeSlideListItemBinding) : BaseR
|
||||
GameItemViewHolder.initGameSubtitleAndAdLabel(it, binding.includeGame.gameSubtitleTv)
|
||||
}
|
||||
|
||||
if (homeSlide.image != binding.slideBackground.tag) {
|
||||
if (homeSlide.image != binding.slideBackground.getTag(ImageUtils.TAG_BOUNDED_URL)) {
|
||||
binding.bottomGradient.visibility = View.GONE
|
||||
}
|
||||
binding.slideBackground.setTag(ImageUtils.TAG_TARGET_WIDTH, mImageWith)
|
||||
|
||||
@ -53,7 +53,7 @@ class HomeSubSlideListItemViewHolder(val binding: HomeSubSlideListItemBinding) :
|
||||
val startColor = Color.HSVToColor(colorHSV)
|
||||
val endColor = ColorUtils.setAlphaComponent(startColor, 0)
|
||||
|
||||
if (homeSlide.image != binding.slideBackground.tag) {
|
||||
if (homeSlide.image != binding.slideBackground.getTag(ImageUtils.TAG_BOUNDED_URL)) {
|
||||
binding.slideMask.visibility = View.GONE
|
||||
}
|
||||
binding.slideMask.background = GradientDrawable().apply {
|
||||
|
||||
@ -19,6 +19,7 @@ import kotlin.Pair;
|
||||
|
||||
/**
|
||||
* Created by khy on 2016/12/13.
|
||||
* 礼包详情
|
||||
*/
|
||||
@Route(path = RouteConsts.activity.libaoDetailActivity)
|
||||
public class LibaoDetailActivity extends ToolBarActivity {
|
||||
|
||||
@ -8,41 +8,26 @@ import com.gh.gamecenter.common.loghub.LoghubUtils;
|
||||
import com.gh.gamecenter.common.utils.Installation;
|
||||
import com.gh.common.util.LogUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.gamecenter.db.DataCollectionDao;
|
||||
import com.gh.gamecenter.db.info.DataCollectionInfo;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DataCollectionManager {
|
||||
|
||||
private Context mContext;
|
||||
private DataCollectionDao dao;
|
||||
private boolean isUploading;
|
||||
|
||||
private DataCollectionManager() {
|
||||
mContext = HaloApp.getInstance().getApplicationContext();
|
||||
dao = new DataCollectionDao(mContext);
|
||||
isUploading = false;
|
||||
}
|
||||
|
||||
public static void onEvent(Context context, String type, Map<String, Object> map, boolean isUpload) {
|
||||
AppExecutor.getIoExecutor().execute(() -> {
|
||||
map.put("createdOn", Utils.getTime(context));
|
||||
if (isUpload) {
|
||||
DataCollectionManager.getInstance().realTimeUpload(type, map);
|
||||
} else {
|
||||
onEvent(type, new JSONObject(map).toString(), false);
|
||||
}
|
||||
DataCollectionManager.getInstance().realTimeUpload(type, map);
|
||||
});
|
||||
}
|
||||
|
||||
@ -75,145 +60,10 @@ public class DataCollectionManager {
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
public static void onEvent(String type, String data, boolean isUpload) {
|
||||
String id = UUID.randomUUID().toString().replace("-", "");
|
||||
DataCollectionInfo entity = new DataCollectionInfo();
|
||||
entity.setId(id);
|
||||
entity.setType(type);
|
||||
entity.setData(data);
|
||||
onEvent(entity, isUpload);
|
||||
}
|
||||
|
||||
// 添加事件
|
||||
public static void onEvent(DataCollectionInfo entity, boolean isUpload) {
|
||||
DataCollectionManager.getInstance().add(entity, isUpload);
|
||||
}
|
||||
|
||||
// 把事件加入列表
|
||||
public void add(DataCollectionInfo entity, boolean isUpload) {
|
||||
// 加入列表
|
||||
dao.add(entity);
|
||||
|
||||
// 检查列表数目是否满足条件
|
||||
if (isUpload) {
|
||||
List<DataCollectionInfo> list = dao.getAll();
|
||||
if (list != null && list.size() >= 20) {
|
||||
try {
|
||||
upload(list);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// todo 上传数据,不是很明白这种存数据库取出来删除再存进去再取出来再删是什么操作?也没时间改了~
|
||||
private void upload(List<DataCollectionInfo> list) throws JSONException {
|
||||
if (isUploading) {
|
||||
return;
|
||||
}
|
||||
isUploading = true;
|
||||
String version = PackageUtils.getGhVersionName();
|
||||
String user = Installation.getUUID(mContext);
|
||||
String channel = HaloApp.getInstance().getChannel();
|
||||
for (DataCollectionInfo dataCollectionInfo : list) {
|
||||
if (!"click-item".equals(dataCollectionInfo.getType())) {
|
||||
JSONObject dataObject = new JSONObject(dataCollectionInfo.getData());
|
||||
JSONArray jsonArray = dataObject.getJSONArray("data");
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
jsonObject.put("version", version);
|
||||
jsonObject.put("resu", user);
|
||||
jsonObject.put("jnfj", MetaUtil.getBase64EncodedIMEI());
|
||||
jsonObject.put("channel", channel);
|
||||
|
||||
JSONObject jsonWrapper = new JSONObject();
|
||||
jsonWrapper.put("topic", dataCollectionInfo.getType());
|
||||
jsonWrapper.put("content", jsonObject.toString());
|
||||
jsonWrapper.put("time", Utils.getTime(HaloApp.getInstance().getApplication()));
|
||||
LoghubUtils.log(jsonWrapper, "collection", true);
|
||||
}
|
||||
}
|
||||
dao.delete(dataCollectionInfo.getId());
|
||||
}
|
||||
isUploading = false;
|
||||
}
|
||||
|
||||
public static void upsert(Context context, String type, Map<String, Object> map) {
|
||||
map.put("createdOn", Utils.getTime(context));
|
||||
String id = UUID.randomUUID().toString().replace("-", "");
|
||||
DataCollectionInfo entity = new DataCollectionInfo();
|
||||
entity.setId(id);
|
||||
entity.setType(type);
|
||||
entity.setData(new JSONObject(map).toString());
|
||||
DataCollectionManager.getInstance().upsert(entity, type);
|
||||
}
|
||||
|
||||
public void upsert(DataCollectionInfo entity, String type) {
|
||||
List<DataCollectionInfo> list = dao.findByType(type);
|
||||
if (list == null || list.isEmpty()) {
|
||||
dao.add(entity);
|
||||
} else {
|
||||
entity.setId(list.get(0).getId());
|
||||
dao.update(entity);
|
||||
if (list.size() > 1) {
|
||||
List<String> ids = new ArrayList<>();
|
||||
for (int i = 1, size = list.size(); i < size; i++) {
|
||||
ids.add(list.get(i).getId());
|
||||
}
|
||||
dao.delete(ids);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 上传数据
|
||||
public void upload() {
|
||||
statClickData();
|
||||
List<DataCollectionInfo> list = dao.getAll();
|
||||
if (list != null && !list.isEmpty()) {
|
||||
try {
|
||||
upload(list);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 统计点击数据
|
||||
*/
|
||||
public void statClickData() {
|
||||
AppExecutor.getIoExecutor().execute(() -> {
|
||||
List<DataCollectionInfo> list = dao.getClickData();
|
||||
if (list != null && !list.isEmpty()) {
|
||||
List<String> ids = new ArrayList<>();
|
||||
List<Object> data = new ArrayList<>();
|
||||
try {
|
||||
DataCollectionInfo dataCollectionEntity;
|
||||
for (int i = 0, size = list.size(); i < size; i++) {
|
||||
dataCollectionEntity = list.get(i);
|
||||
ids.add(dataCollectionEntity.getId());
|
||||
data.add(new JSONObject(dataCollectionEntity.getData()));
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("data", data);
|
||||
onEvent(mContext, "click", map);
|
||||
dao.delete(ids);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void onEvent(Context context, String type, Map<String, Object> map) {
|
||||
AppExecutor.getIoExecutor().execute(() -> {
|
||||
map.put("createdOn", Utils.getTime(context));
|
||||
if ("news".equals(type) || "download".equals(type) || "search".equals(type)) {
|
||||
DataCollectionManager.getInstance().realTimeUpload(type, map);
|
||||
return;
|
||||
}
|
||||
onEvent(type, new JSONObject(map).toString(), true);
|
||||
DataCollectionManager.getInstance().realTimeUpload(type, map);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
/**
|
||||
* 根据包名版本号判断是否已安装相应版本的应用
|
||||
*
|
||||
|
||||
@ -22,6 +22,9 @@ import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.databinding.PopupMyGameGuideBinding
|
||||
import com.gh.gamecenter.gamecollection.publish.GameCollectionEditActivity
|
||||
|
||||
/**
|
||||
* 我的游戏
|
||||
*/
|
||||
class MyGameActivity : BaseActivity_TabLayout() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
@ -9,6 +9,9 @@ import com.gh.gamecenter.common.base.activity.ToolBarActivity
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
|
||||
/**
|
||||
* 我的发布
|
||||
*/
|
||||
class MyPostActivity : ToolBarActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
@ -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))
|
||||
|
||||
@ -20,9 +20,9 @@ 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
|
||||
@ -30,9 +30,11 @@ 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,7 +56,7 @@ 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
|
||||
@ -86,7 +88,7 @@ object PackageRepository {
|
||||
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,7 +97,7 @@ object PackageRepository {
|
||||
initFilterPackage(list) { filteredList ->
|
||||
mIsInitialisingData = false
|
||||
|
||||
mInstalledPkgList.addAll(filteredList)
|
||||
mInstalledPkgSet.addAll(filteredList)
|
||||
notifyInstallPkgData()
|
||||
|
||||
loadInstalledGameDigestAndNotifyData(filteredList)
|
||||
@ -203,12 +205,14 @@ 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
|
||||
) {
|
||||
var isNotifyUpdate = false
|
||||
val maxPageCount = (filteredList.size / PAGE_SIZE) + 1
|
||||
@ -243,9 +247,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 +255,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 +406,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 +425,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 +456,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 +513,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)
|
||||
}
|
||||
|
||||
}
|
||||
@ -7,6 +7,9 @@ import com.gh.gamecenter.common.base.activity.ToolBarActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
|
||||
/**
|
||||
* 收货信息
|
||||
*/
|
||||
class DeliveryInfoActivity : ToolBarActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
@ -10,6 +10,9 @@ import com.gh.gamecenter.common.base.activity.BaseActivity
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
|
||||
/**
|
||||
* 个人主页
|
||||
*/
|
||||
class UserHomeActivity : ToolBarActivity() {
|
||||
|
||||
override fun provideNormalIntent(): Intent {
|
||||
|
||||
@ -18,6 +18,9 @@ import com.gh.gamecenter.databinding.ActivityBackgroundClipBinding
|
||||
import java.io.File
|
||||
import java.lang.ref.SoftReference
|
||||
|
||||
/**
|
||||
* 裁剪背景
|
||||
*/
|
||||
class BackgroundClipActivity : BaseActivity() {
|
||||
|
||||
private lateinit var mBinding: ActivityBackgroundClipBinding
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user