From 5180d3b6f93313ef85130a6bc16f7249b4e37b3e Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Tue, 10 Jan 2023 19:25:21 +0800 Subject: [PATCH 1/4] =?UTF-8?q?[v2.13.2][Fix]=E8=A7=A3=E5=86=B3Room?= =?UTF-8?q?=E5=B4=A9=E6=BA=83=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/function/main/MainMoGoApplication.java | 16 +++++++++------- .../eagle/core/function/msgbox/DataManager.kt | 2 ++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java index 889febb1a4..a080bc6d00 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java @@ -65,21 +65,23 @@ public abstract class MainMoGoApplication extends AbsMogoApplication { } start = System.currentTimeMillis(); connectAmiIp(); - initOverviewDb(); // Crash 日志收集 initCrashConfig(); initLogConfig(); initTipToast(); initModules(); - if (DebugConfig.isDebug()) { - initKoom(); - } //查询是否有版本的更新 queryAppUpgrade(); - clearMessageBoxTable(); - checkMonitorDb(); + if (ProcessUtils.isMainProcess(this)) { + initOverviewDb(); + if (DebugConfig.isDebug()) { + initKoom(); + } + clearMessageBoxTable(); + checkMonitorDb(); + CallerMsgBoxManager.INSTANCE.queryAllMessages(this); + } upgradeProgressListener(); - CallerMsgBoxManager.INSTANCE.queryAllMessages(this); } @Override diff --git a/core/function-impl/mogo-core-function-msgbox/src/main/java/com/mogo/eagle/core/function/msgbox/DataManager.kt b/core/function-impl/mogo-core-function-msgbox/src/main/java/com/mogo/eagle/core/function/msgbox/DataManager.kt index ae02bbd2d8..1b614ace1f 100644 --- a/core/function-impl/mogo-core-function-msgbox/src/main/java/com/mogo/eagle/core/function/msgbox/DataManager.kt +++ b/core/function-impl/mogo-core-function-msgbox/src/main/java/com/mogo/eagle/core/function/msgbox/DataManager.kt @@ -12,6 +12,7 @@ import com.mogo.eagle.core.utilcode.kotlin.lifeCycleScope import com.mogo.eagle.core.utilcode.util.GsonUtils import com.mogo.eagle.core.utilcode.util.Utils import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlinx.coroutines.withContext @@ -156,6 +157,7 @@ object DataManager { } private suspend fun getCacheMessages(context: Context): List = withContext(Dispatchers.IO) { + delay(2000) return@withContext MsgBoxDb.getDb(context) .monitorDao() .getAllCachedMessages() From 3ecbad547292c75ec389420b19a466d8ad8090b6 Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Wed, 11 Jan 2023 15:44:34 +0800 Subject: [PATCH 2/4] =?UTF-8?q?[2.13.2][fix]=E8=A7=A3=E5=86=B3=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E5=B4=A9=E6=BA=83=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../function/main/MainMoGoApplication.java | 43 ++++++++++++------- .../eagle/core/function/msgbox/DataManager.kt | 7 ++- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java index a080bc6d00..569f02f2d8 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java @@ -106,23 +106,27 @@ public abstract class MainMoGoApplication extends AbsMogoApplication { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date currDate = new Date(System.currentTimeMillis()); String currTimeStr = format.format(currDate); - if (lastLaunchTimeStr != null && !lastLaunchTimeStr.isEmpty()) { - boolean isSameDay = currTimeStr.equals(lastLaunchTimeStr); - // 超过一天需要清除消息盒子中的数据,并把时间戳存入SP - if (!isSameDay) { + try { + if (lastLaunchTimeStr != null && !lastLaunchTimeStr.isEmpty()) { + boolean isSameDay = currTimeStr.equals(lastLaunchTimeStr); + // 超过一天需要清除消息盒子中的数据,并把时间戳存入SP + if (!isSameDay) { + File file = this.getDatabasePath(MsgBoxDb.INTERNAL_DB_NAME); + if (file != null && file.exists()) { + this.deleteDatabase(MsgBoxDb.INTERNAL_DB_NAME); + } + SPUtils.getInstance().put("last_launch", currTimeStr); + } + } else { + // 首次使用App或中途仅删除sp文件 File file = this.getDatabasePath(MsgBoxDb.INTERNAL_DB_NAME); if (file != null && file.exists()) { this.deleteDatabase(MsgBoxDb.INTERNAL_DB_NAME); } SPUtils.getInstance().put("last_launch", currTimeStr); } - } else { - // 首次使用App或中途仅删除sp文件 - File file = this.getDatabasePath(MsgBoxDb.INTERNAL_DB_NAME); - if (file != null && file.exists()) { - this.deleteDatabase(MsgBoxDb.INTERNAL_DB_NAME); - } - SPUtils.getInstance().put("last_launch", currTimeStr); + } catch (Exception e) { + CallerLogger.INSTANCE.e(TAG, e.getMessage()); } }).start(); } @@ -130,11 +134,18 @@ public abstract class MainMoGoApplication extends AbsMogoApplication { private void checkMonitorDb() { new Thread(() -> { long limitId = 50001; - List cpuList = MonitorDb.getDb(this).monitorDao().getAllCPUById(limitId); - List memList = MonitorDb.getDb(this).monitorDao().getAllMemById(limitId); - // 大于5w条清除 - if (cpuList.size() > 0 || memList.size() > 0) { - this.deleteDatabase(MonitorDb.INTERNAL_DB_NAME); + File file = this.getDatabasePath(MonitorDb.INTERNAL_DB_NAME); + try { + if (file != null && file.exists()) { + List cpuList = MonitorDb.getDb(this).monitorDao().getAllCPUById(limitId); + List memList = MonitorDb.getDb(this).monitorDao().getAllMemById(limitId); + // 大于5w条清除 + if (cpuList.size() > 0 || memList.size() > 0) { + this.deleteDatabase(MonitorDb.INTERNAL_DB_NAME); + } + } + } catch (Exception e) { + CallerLogger.INSTANCE.e(TAG, e.getMessage()); } }).start(); } diff --git a/core/function-impl/mogo-core-function-msgbox/src/main/java/com/mogo/eagle/core/function/msgbox/DataManager.kt b/core/function-impl/mogo-core-function-msgbox/src/main/java/com/mogo/eagle/core/function/msgbox/DataManager.kt index 1b614ace1f..c394ba105c 100644 --- a/core/function-impl/mogo-core-function-msgbox/src/main/java/com/mogo/eagle/core/function/msgbox/DataManager.kt +++ b/core/function-impl/mogo-core-function-msgbox/src/main/java/com/mogo/eagle/core/function/msgbox/DataManager.kt @@ -9,6 +9,7 @@ import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxListenerManager import com.mogo.eagle.core.function.msgbox.db.MsgBoxDb import com.mogo.eagle.core.function.msgbox.db.MsgBoxInfo import com.mogo.eagle.core.utilcode.kotlin.lifeCycleScope +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.util.GsonUtils import com.mogo.eagle.core.utilcode.util.Utils import kotlinx.coroutines.Dispatchers @@ -140,7 +141,11 @@ object DataManager { fun queryAllMessages(context: Context) { scope.launch { initCache() - getCacheMessages(context) + try { + getCacheMessages(context) + } catch (e: Exception) { + CallerLogger.e("DataManager", e.message) + } } } From 6dde7380b8ea2b0d4e35ee6d406ed959c0de6189 Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Wed, 11 Jan 2023 16:43:04 +0800 Subject: [PATCH 3/4] =?UTF-8?q?[2.13.2][Opt]=E6=9F=A5=E8=AF=A2=E6=80=A7?= =?UTF-8?q?=E8=83=BD=E7=9B=91=E6=8E=A7=E7=9A=84=E6=97=B6=E6=9C=BA=E5=90=8E?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/function/main/MainActivity.java | 24 +++++++++++++++++++ .../function/main/MainMoGoApplication.java | 23 ------------------ 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainActivity.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainActivity.java index bf1fc63be2..337e4aacf0 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainActivity.java +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainActivity.java @@ -63,9 +63,13 @@ import com.mogo.map.uicontroller.IMogoMapUIController; import com.rousetime.android_startup.StartupManager; import com.rousetime.android_startup.model.LoggerLevel; import com.rousetime.android_startup.model.StartupConfig; +import com.zhjt.mogo_core_function_devatools.monitor.db.CpuInfo; +import com.zhjt.mogo_core_function_devatools.monitor.db.MemInfo; +import com.zhjt.mogo_core_function_devatools.monitor.db.MonitorDb; import com.zhjt.service.chain.ChainLog; import com.zhjt.service.chain.TracingConstants; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -271,6 +275,7 @@ public class MainActivity extends MvpActivity implement // 启动Native内存泄漏监测 startLeakMonitor(); } + checkMonitorDb(); } /** @@ -309,6 +314,25 @@ public class MainActivity extends MvpActivity implement LeakMonitor.INSTANCE.start(); } + private void checkMonitorDb() { + new Thread(() -> { + long limitId = 50001; + File file = this.getDatabasePath(MonitorDb.INTERNAL_DB_NAME); + try { + if (file != null && file.exists()) { + List cpuList = MonitorDb.getDb(this).monitorDao().getAllCPUById(limitId); + List memList = MonitorDb.getDb(this).monitorDao().getAllMemById(limitId); + // 大于5w条清除 + if (cpuList.size() > 0 || memList.size() > 0) { + this.deleteDatabase(MonitorDb.INTERNAL_DB_NAME); + } + } + } catch (Exception e) { + CallerLogger.INSTANCE.e(TAG, e.getMessage()); + } + }).start(); + } + @ChainLog( linkChainLog = CHAIN_LINK_LOG_NATIVE_LEAK, linkCode = CHAIN_LINK_LEAK, diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java index 569f02f2d8..ab789ac15b 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java @@ -39,9 +39,6 @@ import com.mogo.eagle.core.utilcode.util.ProcessUtils; import com.mogo.eagle.core.utilcode.util.SPUtils; import com.mogo.map.MapApiPath; import com.zhidao.support.obu.ami.AmiClientManager; -import com.zhjt.mogo_core_function_devatools.monitor.db.CpuInfo; -import com.zhjt.mogo_core_function_devatools.monitor.db.MemInfo; -import com.zhjt.mogo_core_function_devatools.monitor.db.MonitorDb; import java.io.File; import java.lang.reflect.Field; @@ -78,7 +75,6 @@ public abstract class MainMoGoApplication extends AbsMogoApplication { initKoom(); } clearMessageBoxTable(); - checkMonitorDb(); CallerMsgBoxManager.INSTANCE.queryAllMessages(this); } upgradeProgressListener(); @@ -131,25 +127,6 @@ public abstract class MainMoGoApplication extends AbsMogoApplication { }).start(); } - private void checkMonitorDb() { - new Thread(() -> { - long limitId = 50001; - File file = this.getDatabasePath(MonitorDb.INTERNAL_DB_NAME); - try { - if (file != null && file.exists()) { - List cpuList = MonitorDb.getDb(this).monitorDao().getAllCPUById(limitId); - List memList = MonitorDb.getDb(this).monitorDao().getAllMemById(limitId); - // 大于5w条清除 - if (cpuList.size() > 0 || memList.size() > 0) { - this.deleteDatabase(MonitorDb.INTERNAL_DB_NAME); - } - } - } catch (Exception e) { - CallerLogger.INSTANCE.e(TAG, e.getMessage()); - } - }).start(); - } - private void upgradeProgressListener() { final NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setSmallIcon(R.mipmap.icon1001); From 8b80f5fbde76cc0d7a82c2e77f56dfcad73e871a Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Thu, 12 Jan 2023 19:54:45 +0800 Subject: [PATCH 4/4] =?UTF-8?q?[2.13.2][fix]=E8=A7=A3=E5=86=B3=E5=A4=9A?= =?UTF-8?q?=E6=9D=A1V2X=E4=BA=8B=E4=BB=B6=E5=8F=AA=E4=B8=80=E6=9D=A1?= =?UTF-8?q?=E5=85=A5=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/mogo/eagle/core/data/msgbox/V2XMsg.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/msgbox/V2XMsg.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/msgbox/V2XMsg.kt index 26a9e8e811..374c545563 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/msgbox/V2XMsg.kt +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/msgbox/V2XMsg.kt @@ -2,4 +2,12 @@ package com.mogo.eagle.core.data.msgbox import java.io.Serializable -data class V2XMsg(var type: String = "", var content: String? = "", var tts: String? = ""): Serializable \ No newline at end of file +data class V2XMsg(var type: String = "", var content: String? = "", var tts: String? = ""): Serializable { + + // 临时解决该问题:V2XMsg->json作为主键,如果主键一样数据条目不会新增 + private var timeStamp: Long = 0 + + init { + timeStamp = System.currentTimeMillis() + } +} \ No newline at end of file