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 f357943f1f..306963ffdb 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 @@ -105,23 +105,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(); } @@ -129,11 +133,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 d874b560b7..4e0cb392df 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 @@ -8,6 +8,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 @@ -139,7 +140,11 @@ object DataManager { fun queryAllMessages(context: Context) { scope.launch { initCache() - getCacheMessages(context) + try { + getCacheMessages(context) + } catch (e: Exception) { + CallerLogger.e("DataManager", e.message) + } } }