diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/msgbox/DataManager.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/msgbox/DataManager.kt index ae02bbd2d8..c394ba105c 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/msgbox/DataManager.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/msgbox/DataManager.kt @@ -9,9 +9,11 @@ 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 +import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlinx.coroutines.withContext @@ -139,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) + } } } @@ -156,6 +162,7 @@ object DataManager { } private suspend fun getCacheMessages(context: Context): List = withContext(Dispatchers.IO) { + delay(2000) return@withContext MsgBoxDb.getDb(context) .monitorDao() .getAllCachedMessages() 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 a52ea391c3..a2356977c8 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 @@ -60,9 +60,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; @@ -264,6 +268,7 @@ public class MainActivity extends MvpActivity implement // 启动Native内存泄漏监测 startLeakMonitor(); } + checkMonitorDb(); } private void startLeakMonitor() { @@ -290,6 +295,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 26b4aa6fb3..47c710972e 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 @@ -35,6 +35,8 @@ import com.mogo.eagle.core.utilcode.util.SPUtils; 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.mogo.map.MapApiPath; +import com.zhidao.support.obu.ami.AmiClientManager; import java.io.File; import java.lang.reflect.Field; @@ -57,19 +59,23 @@ public abstract class MainMoGoApplication extends AbsMogoApplication { return; } start = System.currentTimeMillis(); - initOverviewDb(); + connectAmiIp(); // Crash 日志收集 initCrashConfig(); initLogConfig(); initTipToast(); initModules(); - if (DebugConfig.isDebug()) { - initKoom(); + //查询是否有版本的更新 + queryAppUpgrade(); + if (ProcessUtils.isMainProcess(this)) { + initOverviewDb(); + if (DebugConfig.isDebug()) { + initKoom(); + } + clearMessageBoxTable(); + CallerMsgBoxManager.INSTANCE.queryAllMessages(this); } - clearMessageBoxTable(); - checkMonitorDb(); upgradeProgressListener(); - CallerMsgBoxManager.INSTANCE.queryAllMessages(this); } @Override @@ -78,6 +84,15 @@ public abstract class MainMoGoApplication extends AbsMogoApplication { return true; } + private void queryAppUpgrade() { + UiThreadHandler.postDelayed(new Runnable() { + @Override + public void run() { + CallerBindingcarManager.getBindingcarProvider().queryAppUpgrade(); + } + },9000); + } + @SuppressLint("SimpleDateFormat") private void clearMessageBoxTable() { new Thread(() -> { @@ -85,35 +100,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); - } - }).start(); - } - - 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); + } catch (Exception e) { + CallerLogger.INSTANCE.e(TAG, e.getMessage()); } }).start(); } @@ -195,6 +202,14 @@ public abstract class MainMoGoApplication extends AbsMogoApplication { OverviewDb.Companion.getDb(this); } + /** + * 连接ami + */ + private void connectAmiIp() { + String ipAddress = SharedPrefsMgr.getInstance(AbsMogoApplication.getApp().getBaseContext()).getString(MoGoConfig.OBU_IP, "192.168.1.199"); + AmiClientManager.getInstance().setObuIp(ipAddress); + } + private void initModules() { CallerLogger.INSTANCE.d(M_HMI + TAG, "initModules"); // OBU 模块 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