diff --git a/app/src/main/java/com/gh/download/DownloadDataHelper.kt b/app/src/main/java/com/gh/download/DownloadDataHelper.kt index 37e205ed3e..79b3c0c07b 100644 --- a/app/src/main/java/com/gh/download/DownloadDataHelper.kt +++ b/app/src/main/java/com/gh/download/DownloadDataHelper.kt @@ -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) } diff --git a/app/src/main/java/com/gh/download/simple/DownloadMessageHandler.kt b/app/src/main/java/com/gh/download/simple/DownloadMessageHandler.kt index 05c343861f..c4ba87f885 100644 --- a/app/src/main/java/com/gh/download/simple/DownloadMessageHandler.kt +++ b/app/src/main/java/com/gh/download/simple/DownloadMessageHandler.kt @@ -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) { diff --git a/ndownload b/ndownload index 33f9a358ad..54cb6c0c32 160000 --- a/ndownload +++ b/ndownload @@ -1 +1 @@ -Subproject commit 33f9a358ad17fbce880f71107b550593409a8ec4 +Subproject commit 54cb6c0c32c89dd3b5827750a916fb43a70e6942