Compare commits

...

13 Commits

Author SHA1 Message Date
0c807922d6 chore: 版本更新至 5.32.5 2023-11-29 16:51:00 +08:00
d7f5b573c6 Merge branch 'hotfix/v5.32.4-994/provider_conflict' into 'release'
fix: 移除穿山甲广告 tools 依赖

See merge request halo/android/assistant-android!1463
2023-11-29 16:50:04 +08:00
f9d624b077 fix: 移除穿山甲广告 tools 依赖 2023-11-29 16:48:42 +08:00
a22fa59975 Merge branch 'hotfix/v5.32.4-994/get_app_list_crash' into 'release'
fix: 获取应用列表时偶发的空指针异常 https://sentry.shanqu.cc/organizations/lightgame/issues/343985/?project=22

See merge request halo/android/assistant-android!1460
2023-11-27 10:15:41 +08:00
e68ad6489a fix: 获取应用列表时偶发的空指针异常 https://sentry.shanqu.cc/organizations/lightgame/issues/343985/?project=22 2023-11-27 10:06:09 +08:00
ccd3a98799 Merge branch 'hotfix/v5.32.4-994/deadsystem-crash' into 'release'
fix: catch 部分 DeadSystemException 异常

See merge request halo/android/assistant-android!1458
2023-11-24 11:45:28 +08:00
96026ef9fa fix: catch 部分 DeadSystemException 异常 2023-11-24 11:31:56 +08:00
777e05733c chore: 版本更新至 5.32.4
Signed-off-by: chenjuntao <chenjuntao@ghzhushou.com>
2023-11-23 15:41:58 +08:00
cbf6f34a9c Merge branch 'hotfix/v5.32.3-993/replace_fragment_crash' into 'release'
fix: 修复底部第四个Tab重复创建Fragment的问题,捕获替换Fragment出现的异常

See merge request halo/android/assistant-android!1455
2023-11-22 13:40:11 +08:00
23c0f12ed3 fix: 修复底部第四个Tab重复创建Fragment的问题,捕获替换Fragment出现的异常 2023-11-22 11:55:19 +08:00
da91dcab59 chore: 版本更新至 5.32.3
Signed-off-by: chenjuntao <chenjuntao@ghzhushou.com>
2023-11-21 17:07:32 +08:00
ee846bc620 Merge branch 'feat/GHZS-4303' into 'release'
feat: 广告回传参数补充 https://jira.shanqu.cc/browse/GHZS-4303

See merge request halo/android/assistant-android!1453
2023-11-21 17:06:22 +08:00
aa3db9330e feat: 广告回传参数补充 https://jira.shanqu.cc/browse/GHZS-4303
Signed-off-by: chenjuntao <chenjuntao@ghzhushou.com>
2023-11-21 16:52:08 +08:00
11 changed files with 142 additions and 136 deletions

View File

@ -5,6 +5,7 @@ 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;
@ -54,7 +55,7 @@ public class DataCollectionUtils {
map.put("location", downloadEntity.getLocation());
map.put(EntranceConsts.KEY_ENTRANCE, downloadEntity.getEntrance());
map.put("installed", downloadEntity.getInstalled());
map.put("network", NetworkUtils.getConnectedType(context));
map.put("network", MetaUtil.getMeta().getNetwork());
DataCollectionManager.onEvent(context, "download", map);
}
@ -118,7 +119,7 @@ public class DataCollectionUtils {
map.put("key", args[0]);
map.put("game_id", args[3]);
map.put("game_name", args[4]);
map.put("netword", NetworkUtils.getConnectedType(context));
map.put("netword", MetaUtil.getMeta().getNetwork());
map.put("type", "search");
map.put("device_type", android.os.Build.MODEL);
map.put("device_system", android.os.Build.VERSION.SDK_INT + "=" + android.os.Build.VERSION.RELEASE);
@ -136,7 +137,7 @@ public class DataCollectionUtils {
map.put("key", args[0]);
map.put("game_id", args[3]);
map.put("game_name", args[4]);
map.put("netword", NetworkUtils.getConnectedType(context));
map.put("netword", MetaUtil.getMeta().getNetwork());
map.put("type", "click");
map.put("device_type", android.os.Build.MODEL);
map.put("device_system", android.os.Build.VERSION.SDK_INT + "=" + android.os.Build.VERSION.RELEASE);

View File

@ -62,60 +62,60 @@ object DownloadNotificationHelper {
} else {
intent.action = ACTION_DOWNLOAD
}
val pendingIntent = PendingIntent.getBroadcast(
HaloApp.getInstance().application,
downloadNotificationId,
intent,
PendingIntent.FLAG_UPDATE_CURRENT
)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel =
NotificationChannel(DOWNLOAD_CHANNEL_ID, DOWNLOAD_CHANNEL_ID, NotificationManager.IMPORTANCE_LOW)
notificationManager.createNotificationChannel(channel)
}
val whenTime = 1000 * 60 * (System.currentTimeMillis() / 1000 / 60)
val builder = NotificationCompat.Builder(HaloApp.getInstance().application, DOWNLOAD_CHANNEL_ID)
.setContentTitle(entity.name)
.setSmallIcon(getNotificationIcon())
.setContentIntent(pendingIntent)
.setGroup(DOWNLOAD_GROUP_KEY)
.setWhen(whenTime)
if (xapkStatus == XapkUnzipStatus.FAILURE.name) {
builder.setContentText("" + entity.name + "》解压失败,点击查看详情~")
} else {
when (entity.status) {
DownloadStatus.downloading -> builder.setContentText(
String.format(
"%s(剩%s)",
SpeedUtils.getSpeed(entity.speed),
SpeedUtils.getRemainTime(entity.size, entity.progress, entity.speed * 1024)
)
)
DownloadStatus.done -> builder.setContentText("下载完成,点击立即安装")
DownloadStatus.waiting -> builder.setContentText("等待中")
DownloadStatus.subscribe,
DownloadStatus.timeout,
DownloadStatus.diskisfull,
DownloadStatus.diskioerror,
DownloadStatus.neterror -> builder.setContentText("已暂停连接WiFi自动下载")
else -> builder.setContentText("暂停中")
}
builder.setProgress(PROGRESS_MAX, entity.percent.toInt(), false)
}
when (entity.status) {
DownloadStatus.done -> {
builder.setSortKey("A")
builder.setOngoing(true) // 垃圾华为 sortKey 不起效 priority 也不起效,要将下载完成任务的通知置顶只能设置为 ongoing喷了
}
DownloadStatus.downloading -> builder.setSortKey("B")
else -> builder.setSortKey("C")
}
tryCatchInRelease {
val pendingIntent = PendingIntent.getBroadcast(
HaloApp.getInstance().application,
downloadNotificationId,
intent,
PendingIntent.FLAG_UPDATE_CURRENT
)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel =
NotificationChannel(DOWNLOAD_CHANNEL_ID, DOWNLOAD_CHANNEL_ID, NotificationManager.IMPORTANCE_LOW)
notificationManager.createNotificationChannel(channel)
}
val whenTime = 1000 * 60 * (System.currentTimeMillis() / 1000 / 60)
val builder = NotificationCompat.Builder(HaloApp.getInstance().application, DOWNLOAD_CHANNEL_ID)
.setContentTitle(entity.name)
.setSmallIcon(getNotificationIcon())
.setContentIntent(pendingIntent)
.setGroup(DOWNLOAD_GROUP_KEY)
.setWhen(whenTime)
if (xapkStatus == XapkUnzipStatus.FAILURE.name) {
builder.setContentText("" + entity.name + "》解压失败,点击查看详情~")
} else {
when (entity.status) {
DownloadStatus.downloading -> builder.setContentText(
String.format(
"%s(剩%s)",
SpeedUtils.getSpeed(entity.speed),
SpeedUtils.getRemainTime(entity.size, entity.progress, entity.speed * 1024)
)
)
DownloadStatus.done -> builder.setContentText("下载完成,点击立即安装")
DownloadStatus.waiting -> builder.setContentText("等待中")
DownloadStatus.subscribe,
DownloadStatus.timeout,
DownloadStatus.diskisfull,
DownloadStatus.diskioerror,
DownloadStatus.neterror -> builder.setContentText("已暂停连接WiFi自动下载")
else -> builder.setContentText("暂停中")
}
builder.setProgress(PROGRESS_MAX, entity.percent.toInt(), false)
}
when (entity.status) {
DownloadStatus.done -> {
builder.setSortKey("A")
builder.setOngoing(true) // 垃圾华为 sortKey 不起效 priority 也不起效,要将下载完成任务的通知置顶只能设置为 ongoing喷了
}
DownloadStatus.downloading -> builder.setSortKey("B")
else -> builder.setSortKey("C")
}
val notification = builder.build() // 可能会抛出异常
notification.flags = notification.flags or Notification.FLAG_NO_CLEAR
if (xapkStatus == XapkUnzipStatus.FAILURE.name) {

View File

@ -728,6 +728,13 @@ public class PackageUtils {
for (PackageInfo packageInfo : packageInfos) {
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
JSONObject jsonObject = new JSONObject();
// 这里的 pm.getApplicationLabel 有极小机率会返回 null 值 (明明方法标示了返回值 nonnull
// Attempt to invoke interface method 'java.lang.String java.lang.CharSequence.toString()' on a null object reference
// 所以要是为空就 continue忽略掉它
if (pm.getApplicationLabel(packageInfo.applicationInfo) == null) {
continue;
}
jsonObject.put("name", pm.getApplicationLabel(packageInfo.applicationInfo).toString());
jsonObject.put("package", packageInfo.packageName);
jsonObject.put("version", packageInfo.versionName);

View File

@ -45,6 +45,7 @@ import com.gh.gamecenter.common.syncpage.SyncPageRepository
import com.gh.gamecenter.common.tracker.TrackerLogger
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.core.utils.SentryHelper
import com.gh.gamecenter.databinding.FragmentMainBinding
import com.gh.gamecenter.discovery.DiscoveryFragment
import com.gh.gamecenter.entity.HomeDataEntity
@ -96,6 +97,8 @@ class MainWrapperFragment : BaseFragment_ViewPager_Checkable(), OnBackPressedLis
private val mPriorityChain by lazy { PriorityChain() }
private var mVideoNavBarEntity: SubjectRecommendEntity? = null
override fun getLayoutId(): Int = 0
override fun getInflatedLayout() = mBinding.root
override fun getCheckableGroupId(): Int = R.id.lightgame_tab_container
@ -182,20 +185,40 @@ class MainWrapperFragment : BaseFragment_ViewPager_Checkable(), OnBackPressedLis
}
else -> {
val homeArgs = Bundle()
putFragmentBundle(entity, homeArgs, false)
mFourthFragment = HomeToolbarWrapperFragment()
mFourthFragment!!.arguments = homeArgs
mFourthFragment
// 新页面与旧页面类型不同或链接不同时才进行替换
if (mFourthFragment !is HomeToolbarWrapperFragment || mVideoNavBarEntity?.type != entity.type || mVideoNavBarEntity?.link != entity.link) {
val homeArgs = Bundle()
putFragmentBundle(entity, homeArgs, false)
mFourthFragment = HomeToolbarWrapperFragment()
mFourthFragment!!.arguments = homeArgs
mFourthFragment
} else {
null
}
}
}
if (fourthFragment != null) {
if (mFragmentsList.size > 3) {
// 替换第4个Fragment
(mAdapter as MainFragmentPagerAdapter).replaceFragment(3, fourthFragment)
try {
(mAdapter as MainFragmentPagerAdapter).replaceFragment(3, fourthFragment)
} catch (e: Exception) {
SentryHelper.onEvent(
"REPLACE_FRAGMENT_CRASH",
"new_fragment_type",
entity.type,
"old_fragment_type",
mVideoNavBarEntity?.type,
"new_link",
entity.link,
"old_link",
mVideoNavBarEntity?.link
)
}
} else {
fragments.add(fourthFragment)
}
mVideoNavBarEntity = entity
}
}

View File

@ -10,6 +10,7 @@ import com.gh.common.repository.ReservationRepository;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.common.constant.Constants;
import com.gh.gamecenter.common.eventbus.EBNetworkState;
import com.gh.gamecenter.common.exposure.meta.MetaUtil;
import com.gh.gamecenter.common.utils.ExtensionsKt;
import com.gh.gamecenter.common.utils.NetworkUtils;
import com.halo.assistant.HaloApp;
@ -23,6 +24,7 @@ public class NetworkStateReceiver extends BroadcastReceiver {
// 网络变更这里会被主进程和推送进程分别调用,这里只对主进程响应,
// 奇怪,初次注册监听就会有回调,会导致部分接口短时间内触发两次调用
ExtensionsKt.doOnMainProcessOnly(context, () -> {
MetaUtil.updateCachedNetwork();
if (NetworkUtils.isNetworkConnected(context)) {
AdDelegateHelper.INSTANCE.requestAdConfig(true, "", null);
RegionSettingHelper.getRegionSetting();

View File

@ -1,5 +1,6 @@
package com.gh.ndownload
import android.os.Build
import android.text.TextUtils
import com.lg.download.httpclient.DefaultHttpClient
import com.lightgame.download.HttpDnsManager
@ -24,6 +25,7 @@ class NHttpClient : DefaultHttpClient() {
HttpDnsManager.metaMap[HttpDnsManager.ANDROID_SDK_VERSION]
)
mConnection.setRequestProperty(HttpDnsManager.REFERER, HttpDnsManager.DEFAULT_REFERER)
mConnection.setRequestProperty("androidmodel", Build.MODEL)
val isEmulator = meta?.get("is_emulator")
val isForcedRealName = meta?.get("force_real_name")

View File

@ -7,8 +7,8 @@ ext {
targetSdkVersion = 28
// application info (每个大版本之间的 versionCode 增加 20)
versionCode = 992
versionName = "5.32.2"
versionCode = 995
versionName = "5.32.5"
applicationId = "com.gh.gamecenter"
// AndroidX

View File

@ -55,5 +55,4 @@ dependencies {
exclude group: 'androidx.swiperefreshlayout'
}
implementation "com.pangle.ad:oppo:$csjVersion"
implementation "com.pangle.ad:oppo_tools:$csjVersion"
}

View File

@ -14,7 +14,7 @@ data class Meta(
val dia: String? = "",
val android_sdk: Int? = -1,
val android_version: String? = "",
val network: String? = "",
var network: String? = "",
val os: String? = "",
val gid: String? = "",
val oaid: String? = "",

View File

@ -6,6 +6,7 @@ import android.content.Context
import android.content.pm.PackageManager
import android.net.ConnectivityManager
import android.os.Build
import android.os.DeadObjectException
import android.provider.Settings
import android.telephony.TelephonyManager
import android.text.TextUtils
@ -56,6 +57,7 @@ object MetaUtil {
)
}
@JvmStatic
fun getMeta(): Meta {
if (m == null) {
refreshMeta()
@ -199,39 +201,52 @@ object MetaUtil {
return Build.VERSION.RELEASE
}
/**
* 更新通用 meta 里缓存的 network 字段
*/
@JvmStatic
fun updateCachedNetwork() {
m?.network = getNetwork()
}
fun getNetwork(): String? {
// 有一定机率在 getActiveNetworkInfo 时触发 DeadSystemException所以这里进行简单 try catch
try {
if (application.checkCallingOrSelfPermission(Manifest.permission.ACCESS_NETWORK_STATE) != PackageManager.PERMISSION_GRANTED)
return "unknown"
if (application.checkCallingOrSelfPermission(Manifest.permission.ACCESS_NETWORK_STATE) != PackageManager.PERMISSION_GRANTED)
return "unknown"
val activeNetwork =
(application.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager).activeNetworkInfo
?: return "unknown"
val activeNetwork =
(application.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager).activeNetworkInfo
?: return "unknown"
return when (activeNetwork.type) {
ConnectivityManager.TYPE_WIFI -> "WIFI"
ConnectivityManager.TYPE_WIMAX -> "WIMAX"
ConnectivityManager.TYPE_MOBILE -> {
val telephonyManager = application.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
if (telephonyManager.simState != TelephonyManager.SIM_STATE_READY) return "unknown"
when (telephonyManager.networkType) {
// Unknown
TelephonyManager.NETWORK_TYPE_UNKNOWN -> "unknown"
// Cellular Data2G
TelephonyManager.NETWORK_TYPE_EDGE, TelephonyManager.NETWORK_TYPE_GPRS, TelephonyManager.NETWORK_TYPE_CDMA,
TelephonyManager.NETWORK_TYPE_IDEN, TelephonyManager.NETWORK_TYPE_1xRTT -> "2G"
// Cellular Data3G
TelephonyManager.NETWORK_TYPE_UMTS, TelephonyManager.NETWORK_TYPE_HSDPA, TelephonyManager.NETWORK_TYPE_HSPA,
TelephonyManager.NETWORK_TYPE_HSPAP, TelephonyManager.NETWORK_TYPE_HSUPA, TelephonyManager.NETWORK_TYPE_EVDO_0,
TelephonyManager.NETWORK_TYPE_EVDO_A, TelephonyManager.NETWORK_TYPE_EVDO_B -> "3G"
// Cellular Data4G
TelephonyManager.NETWORK_TYPE_LTE -> "4G"
TelephonyManager.NETWORK_TYPE_NR -> "5G"
else -> "unknown"
return when (activeNetwork.type) {
ConnectivityManager.TYPE_WIFI -> "WIFI"
ConnectivityManager.TYPE_WIMAX -> "WIMAX"
ConnectivityManager.TYPE_MOBILE -> {
val telephonyManager = application.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
if (telephonyManager.simState != TelephonyManager.SIM_STATE_READY) return "unknown"
when (telephonyManager.networkType) {
// Unknown
TelephonyManager.NETWORK_TYPE_UNKNOWN -> "unknown"
// Cellular Data2G
TelephonyManager.NETWORK_TYPE_EDGE, TelephonyManager.NETWORK_TYPE_GPRS, TelephonyManager.NETWORK_TYPE_CDMA,
TelephonyManager.NETWORK_TYPE_IDEN, TelephonyManager.NETWORK_TYPE_1xRTT -> "2G"
// Cellular Data3G
TelephonyManager.NETWORK_TYPE_UMTS, TelephonyManager.NETWORK_TYPE_HSDPA, TelephonyManager.NETWORK_TYPE_HSPA,
TelephonyManager.NETWORK_TYPE_HSPAP, TelephonyManager.NETWORK_TYPE_HSUPA, TelephonyManager.NETWORK_TYPE_EVDO_0,
TelephonyManager.NETWORK_TYPE_EVDO_A, TelephonyManager.NETWORK_TYPE_EVDO_B -> "3G"
// Cellular Data4G
TelephonyManager.NETWORK_TYPE_LTE -> "4G"
TelephonyManager.NETWORK_TYPE_NR -> "5G"
else -> "unknown"
}
}
else -> "unknown"
}
else -> "unknown"
} catch (e: DeadObjectException) {
e.printStackTrace()
return "unknown"
}
}

View File

@ -93,49 +93,6 @@ public class NetworkUtils {
return quickLoginHelper.isOpenMobileData(context);
}
/**
* 获取当前网络连接的类型信息
*
* @param context 上下文
* @return 当前网络连接的类型信息
*/
public static String getConnectedType(Context context) {
if (context != null) {
context = context.getApplicationContext();
ConnectivityManager mConnectivityManager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mNetworkInfo = mConnectivityManager
.getActiveNetworkInfo();
if (mNetworkInfo != null && mNetworkInfo.isAvailable()) {
switch (mNetworkInfo.getType()) {
case ConnectivityManager.TYPE_BLUETOOTH:
return "BLUETOOTH";
case ConnectivityManager.TYPE_DUMMY:
return "DUMMY";
case ConnectivityManager.TYPE_ETHERNET:
return "ETHERNET";
case ConnectivityManager.TYPE_MOBILE:
return "MOBILE";
case ConnectivityManager.TYPE_MOBILE_DUN:
return "MOBILE_DUN";
case ConnectivityManager.TYPE_MOBILE_HIPRI:
return "MOBILE_HIPRI";
case ConnectivityManager.TYPE_MOBILE_MMS:
return "MOBILE_MMS";
case ConnectivityManager.TYPE_MOBILE_SUPL:
return "MOBILE_SUPL";
case ConnectivityManager.TYPE_WIFI:
return "WIFI";
case ConnectivityManager.TYPE_WIMAX:
return "WIMAX";
default:
break;
}
}
}
return "NONE";
}
/**
* 获取当前移动网络连接的类型信息(当连接的网络是移动网络时使用)
*