Merge branch 'master' into dev_arch_opt_3.0

# Conflicts:
#	core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java
This commit is contained in:
donghongyu
2023-01-16 11:43:46 +08:00
4 changed files with 85 additions and 31 deletions

View File

@@ -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<MainView, MainPresenter> implement
// 启动Native内存泄漏监测
startLeakMonitor();
}
checkMonitorDb();
}
private void startLeakMonitor() {
@@ -290,6 +295,25 @@ public class MainActivity extends MvpActivity<MainView, MainPresenter> 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<CpuInfo> cpuList = MonitorDb.getDb(this).monitorDao().getAllCPUById(limitId);
List<MemInfo> 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,

View File

@@ -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<CpuInfo> cpuList = MonitorDb.getDb(this).monitorDao().getAllCPUById(limitId);
List<MemInfo> 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 模块