From cbabfe72f775ddba1eb86105bfce1db52ae1f6db Mon Sep 17 00:00:00 2001 From: chenjuntao Date: Wed, 15 Feb 2023 10:37:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=80=90=E5=85=89=E7=8E=AF=E5=8A=A9?= =?UTF-8?q?=E6=89=8B=E3=80=91=E5=A4=9A=E7=BA=BF=E7=A8=8B=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=95=B0=E6=8D=AE=E5=9F=8B=E7=82=B9=E8=A1=A5?= =?UTF-8?q?=E5=85=85-0214=E6=B5=8B=E8=AF=95=20https://jira.shanqu.cc/brows?= =?UTF-8?q?e/GHZS-1247?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gh/download/DownloadDataHelper.kt | 44 ++++++++++--------- .../download/simple/DownloadMessageHandler.kt | 8 ++++ ndownload | 2 +- 3 files changed, 33 insertions(+), 21 deletions(-) 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