fix: 【光环助手】多线程下载相关数据埋点补充-0214测试 https://jira.shanqu.cc/browse/GHZS-1247

This commit is contained in:
chenjuntao
2023-02-15 10:37:11 +08:00
parent f21368c761
commit cbabfe72f7
3 changed files with 33 additions and 21 deletions

View File

@ -2,17 +2,16 @@ package com.gh.download
import android.content.pm.PackageInfo
import android.text.TextUtils
import com.gh.common.util.PackageUtils
import com.gh.common.xapk.XapkInstaller
import com.gh.gamecenter.common.constant.Constants
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.common.util.*
import com.gh.common.xapk.XapkInstaller
import com.gh.gamecenter.BuildConfig
import com.gh.gamecenter.common.utils.DeviceUtils
import com.gh.gamecenter.common.utils.getExtension
import com.gh.gamecenter.common.utils.getMetaExtra
import com.gh.gamecenter.common.utils.isSimulatorGame
import com.gh.gamecenter.common.utils.DeviceUtils
import com.halo.assistant.HaloApp
import com.lightgame.download.DataChanger
import com.lightgame.download.DownloadConfig
@ -23,6 +22,8 @@ import org.json.JSONArray
import org.json.JSONObject
object DownloadDataHelper {
private const val TAG = "DownloadDataHelper"
private const val DOWNLOAD_SPEED_TIME = "download_speed_time"
private const val DOWNLOAD_SPEED_SIZE = "download_speed_size"
@ -58,7 +59,11 @@ object DownloadDataHelper {
}
} else if (status == DownloadStatus.waiting) {
"暂停下载-等待中"
} else if (status == DownloadStatus.subscribe || status == DownloadStatus.neterror || status == DownloadStatus.timeout) {
} else if (status == DownloadStatus.subscribe
|| status == DownloadStatus.neterror
|| status == DownloadStatus.timeout
|| status == DownloadStatus.diskisfull
) {
"暂停下载-连上WiFi自动下载"
} else if (status == DownloadStatus.done) {
if (downloadEntity.isSimulatorGame()) {
@ -126,9 +131,8 @@ object DownloadDataHelper {
} catch (e: Exception) {
e.printStackTrace()
}
if (BuildConfig.DEBUG) {
Utils.log("LogUtils->$jsonObject")
}
Utils.log(TAG, "$jsonObject")
LoghubUtils.log(jsonObject, "download_debug", false)
}
@ -205,13 +209,13 @@ object DownloadDataHelper {
payloadObject.put("package", downloadEntity.packageName)
payloadObject.put("filename", getFileName(downloadEntity))
payloadObject.put("launch_ms", startupTime)
payloadObject.put("parallel", downloadEntity.meta[DOWNLOAD_THREAD_SIZE]?.toInt() ?: 0)
jsonObject.put("payload", payloadObject)
} catch (e: Exception) {
e.printStackTrace()
}
if (BuildConfig.DEBUG) {
Utils.log("LogUtils->$jsonObject")
}
Utils.log(TAG, "$jsonObject")
LoghubUtils.log(jsonObject, "download_debug", false)
}
@ -266,9 +270,8 @@ object DownloadDataHelper {
} catch (e: Exception) {
e.printStackTrace()
}
if (BuildConfig.DEBUG) {
Utils.log("LogUtils->$jsonObject")
}
Utils.log(TAG, "$jsonObject")
LoghubUtils.log(jsonObject, "download_debug", false)
}
@ -294,13 +297,15 @@ object DownloadDataHelper {
payloadObject.put("filename", getFileName(downloadEntity))
payloadObject.put("speed_progress", JSONArray(averageSpeedList))
payloadObject.put("is_finished", downloadEntity.status == DownloadStatus.done)
payloadObject.put("completed_size", downloadEntity.progress / 1024 / 1024)
payloadObject.put("parallel", downloadEntity.meta[DOWNLOAD_THREAD_SIZE]?.toInt() ?: 0)
payloadObject.put("task_num", DataChanger.downloadingTasks.size)
jsonObject.put("payload", payloadObject)
} catch (e: Exception) {
e.printStackTrace()
}
if (BuildConfig.DEBUG) {
Utils.log("LogUtils->$jsonObject")
}
Utils.log(TAG, "$jsonObject")
LoghubUtils.log(jsonObject, "download_debug", false)
}
@ -366,9 +371,8 @@ object DownloadDataHelper {
} catch (e: Exception) {
e.printStackTrace()
}
if (BuildConfig.DEBUG) {
Utils.log("LogUtils->$jsonObject")
}
Utils.log(TAG, "$jsonObject")
mDownloadHeartbeatList.clear()
LoghubUtils.log(jsonObject, "download_debug", false)
}

View File

@ -83,6 +83,10 @@ object DownloadMessageHandler : InnerDownloadListener {
}
}
override fun onDownloadComplete(id: String?, elapsedTime: Long) {
// do nothing
}
/**
* 重定向中的回调
* @param id 下载 id
@ -210,6 +214,10 @@ object DownloadMessageHandler : InnerDownloadListener {
updateDownloadList()
}
override fun onReadyToDownload(id: String?, actualThreadSize: Int) {
// do nothing
}
fun registerListener(id: String, listener: DownloadListener) {
var listenerList = mListenerMap[id]
if (listenerList == null) {