Merge branch 'dev_robotaxi-d-app-module_251_220125_2.5.1' of gitlab.zhidaoauto.com:zhjt/AndroidApp/MoGoEagleEye into dev_robotaxi-d-app-module_251_220125_2.5.1
# Conflicts: # settings.gradle
This commit is contained in:
@@ -0,0 +1,145 @@
|
||||
package com.mogo.functions.test
|
||||
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import com.mogo.eagle.core.data.autopilot.AutoPilotRecordResult
|
||||
import com.mogo.eagle.core.function.hmi.ui.MoGoHmiFragment
|
||||
import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.*
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.random.Random
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class AutoPilotBadCaseTest {
|
||||
|
||||
lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
|
||||
@Before
|
||||
fun launch() {
|
||||
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
}
|
||||
|
||||
@ExperimentalCoroutinesApi @Test
|
||||
fun showBadCaseEntrance1(): Unit = runBlocking(Dispatchers.Main) {
|
||||
val f = ensureMoGoHmiFragmentShow()
|
||||
var index = 0
|
||||
(1 until 50)
|
||||
.map { it }
|
||||
.asFlow()
|
||||
.onEach {
|
||||
delay(TimeUnit.SECONDS.toMillis(5))
|
||||
f.onAutopilotRecordResult(AutoPilotRecordResult().also {
|
||||
it.diskFree = 100 + index
|
||||
it.duration = 60.0
|
||||
it.fileName = "/user/general/record_$index.log"
|
||||
it.id = 10 + index
|
||||
it.key = "yyy_$index"
|
||||
it.stat = 100
|
||||
it.type = 1
|
||||
it.timestamp = SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(Date())
|
||||
index++
|
||||
})
|
||||
}
|
||||
.flowOn(Dispatchers.Default)
|
||||
.collect()
|
||||
delay(TimeUnit.HOURS.toMillis(2))
|
||||
}
|
||||
|
||||
|
||||
@ExperimentalCoroutinesApi @Test
|
||||
fun showBadCaseEntrance2():Unit = runBlocking(Dispatchers.Main) {
|
||||
val f = ensureMoGoHmiFragmentShow()
|
||||
var index = 0
|
||||
(1 until 50)
|
||||
.map { it }
|
||||
.asFlow()
|
||||
.onEach {
|
||||
if (index in 1..4) {
|
||||
delay(TimeUnit.SECONDS.toMillis(15))
|
||||
} else {
|
||||
delay(Random(20).nextLong())
|
||||
}
|
||||
f.onAutopilotRecordResult(AutoPilotRecordResult().also {
|
||||
it.diskFree = 100 + index
|
||||
it.duration = 60.0
|
||||
it.fileName = "/user/general/record_$index.log"
|
||||
it.id = 10 + index
|
||||
it.key = "yyy_$index"
|
||||
it.stat = 100
|
||||
it.type = 1
|
||||
it.timestamp = SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(Date())
|
||||
index++
|
||||
})
|
||||
|
||||
if (index == 5) {
|
||||
f.lifecycleScope.cancel()
|
||||
}
|
||||
|
||||
}
|
||||
.flowOn(Dispatchers.Default)
|
||||
.collect()
|
||||
delay(TimeUnit.HOURS.toMillis(2))
|
||||
}
|
||||
|
||||
@ExperimentalCoroutinesApi @Test
|
||||
fun showBadCaseEntrance3(): Unit = runBlocking(Dispatchers.Main) {
|
||||
val f = ensureMoGoHmiFragmentShow()
|
||||
var index = 0
|
||||
(1 until 50)
|
||||
.map { it }
|
||||
.asFlow()
|
||||
.onEach {
|
||||
delay(TimeUnit.SECONDS.toMillis(20))
|
||||
f.onAutopilotRecordResult(AutoPilotRecordResult().also {
|
||||
it.diskFree = 100 + index
|
||||
it.duration = 60.0
|
||||
it.fileName = "/user/general/record_$index.log"
|
||||
it.id = 10 + index
|
||||
it.key = "yyy_$index"
|
||||
it.stat = 100
|
||||
it.type = 1
|
||||
it.timestamp = SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(Date())
|
||||
index++
|
||||
})
|
||||
}
|
||||
.flowOn(Dispatchers.Default)
|
||||
.collect()
|
||||
delay(TimeUnit.HOURS.toMillis(2))
|
||||
}
|
||||
|
||||
|
||||
private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiFragment = suspendCancellableCoroutine {
|
||||
launch.onActivity { itx ->
|
||||
val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
executor.scheduleAtFixedRate({
|
||||
var find =
|
||||
itx.supportFragmentManager.fragments.find { it is MoGoHmiFragment } as? MoGoHmiFragment
|
||||
while (find == null) {
|
||||
find =
|
||||
itx.supportFragmentManager.fragments.find { it is MoGoHmiFragment } as? MoGoHmiFragment
|
||||
|
||||
}
|
||||
while (!find.isResumed) {
|
||||
Thread.sleep(500)
|
||||
}
|
||||
it.resumeWith(Result.success(find))
|
||||
try {
|
||||
Thread.sleep(500)
|
||||
executor.shutdownNow()
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}, 50, 500, TimeUnit.MILLISECONDS)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,16 @@
|
||||
package com.mogo.launcher;
|
||||
|
||||
import com.apm.insight.AttachUserData;
|
||||
import com.apm.insight.CrashType;
|
||||
import com.apm.insight.MonitorCrash;
|
||||
import com.apm.insight.log.VLog;
|
||||
import com.auto.zhidao.logsdk.CrashSystem;
|
||||
import com.bytedance.apm.insight.ApmInsight;
|
||||
import com.bytedance.apm.insight.ApmInsightInitConfig;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.data.app.AppConfigInfo;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.config.HdMapBuildConfig;
|
||||
import com.mogo.eagle.core.data.config.HmiBuildConfig;
|
||||
import com.mogo.eagle.core.function.main.MainMoGoApplication;
|
||||
import com.mogo.module.v2x.utils.ObuConfig;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.LogLevel;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
import com.mogo.test.crashreport.CrashReportConstants;
|
||||
import com.mogo.utils.AppUtils;
|
||||
import com.mogo.utils.CommonUtils;
|
||||
import com.mogo.utils.logger.LogLevel;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.storage.SharedPrefsMgr;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -32,14 +19,12 @@ import java.util.Map;
|
||||
* Launcher application
|
||||
*/
|
||||
public class MogoApplication extends MainMoGoApplication {
|
||||
private static final String BYTEAMP_APPID = "302368";
|
||||
|
||||
@Override
|
||||
protected void initCrashConfig() {
|
||||
CrashSystem crashSystem = CrashSystem.getInstance(this);
|
||||
crashSystem.init();
|
||||
initCrash();
|
||||
initApmInsight();
|
||||
|
||||
//设置debug模式,日志不上传
|
||||
crashSystem.setDebug(BuildConfig.DEBUG);
|
||||
}
|
||||
@@ -50,91 +35,6 @@ public class MogoApplication extends MainMoGoApplication {
|
||||
Logger.init(BuildConfig.DEBUG ? LogLevel.DEBUG : LogLevel.OFF);
|
||||
}
|
||||
|
||||
private void initCrash() {
|
||||
|
||||
MonitorCrash crash = MonitorCrash.init(this, BYTEAMP_APPID, CommonUtils.getVersionCode(this), CommonUtils.getVersionName(this))
|
||||
.setCustomDataCallback(new AttachUserData() {
|
||||
@Override
|
||||
public Map<? extends String, ? extends String> getUserData(CrashType type) {
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
// map.put("app_custom", "app_value");
|
||||
//SN
|
||||
map.put("serial", MoGoAiCloudClientConfig.getInstance().getSn());
|
||||
//地图版本
|
||||
String mapSDKVersion = AppUtils.getCustomMapSDKVersion(getApplicationContext());
|
||||
map.put("MAP_SDK_VERSION", mapSDKVersion);
|
||||
return map;
|
||||
}
|
||||
});
|
||||
crash.config().setChannel("eagle");
|
||||
// crash.config().setDeviceId("did");//可选,可以设置自定义did,不设置会使用内部默认的
|
||||
// crash.setReportUrl("www.xxx.com"); // 私有化部署:私有化部署才配置上报地址
|
||||
// crash.addTags("key", "value"); // 自定义筛选tag, 按需添加、可多次覆盖
|
||||
}
|
||||
|
||||
/**
|
||||
* ApmInsight性能监控初始化
|
||||
*/
|
||||
private void initApmInsight() {
|
||||
|
||||
ApmInsightInitConfig.Builder builder = ApmInsightInitConfig.builder();
|
||||
//设置分配的appid
|
||||
builder.aid(BYTEAMP_APPID);
|
||||
//是否开启卡顿功能
|
||||
builder.blockDetect(true);
|
||||
//是否开启严重卡顿功能
|
||||
builder.seriousBlockDetect(true);
|
||||
//是否开启流畅性和丢帧
|
||||
builder.fpsMonitor(true);
|
||||
//控制是否打开WebVeiw监控
|
||||
builder.enableWebViewMonitor(true);
|
||||
//控制是否打开内存监控
|
||||
builder.memoryMonitor(true);
|
||||
//控制是否打开电量监控
|
||||
builder.batteryMonitor(true);
|
||||
//是否打印日志,注:线上release版本要配置为false
|
||||
builder.debugMode(true);
|
||||
//支持用户自定义user_id把平台数据和自己用户关联起来,可以不配置
|
||||
// builder.userId("user_id");
|
||||
//私有化部署:配置数据上报的域名 (私有化部署才需要配置,内部有默认域名),测试支持设置http://www.xxx.com 默认是https协议
|
||||
// builder.defaultReportDomain("www.xxx.com");
|
||||
//设置渠道。1.3.16版本增加接口
|
||||
builder.channel("local");
|
||||
//打开自定义日志回捞能力,1.4.1版本新增接口
|
||||
builder.enableLogRecovery(true);
|
||||
//设置数据和Rangers Applog数据打通,设备标识did必填。1.3.16版本增加接口
|
||||
// builder.setDynamicParams(new IDynamicParams() {
|
||||
// @Override
|
||||
// public String getUserUniqueID() {
|
||||
// //可选。依赖AppLog可以通过AppLog.getUserUniqueID()获取,否则可以返回null。
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getAbSdkVersion() {
|
||||
// //可选。如果依赖AppLog可以通过AppLog.getAbSdkVersion()获取,否则可以返回null。
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getSsid() {
|
||||
// //可选。依赖AppLog可以通过AppLog.getSsid()获取,否则可以返回null。
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getDid() {
|
||||
// //1.4.0版本及以上,可选,其他版本必填。设备的唯一标识,如果依赖AppLog可以通过 AppLog.getDid() 获取,也可以自己生成。
|
||||
// return AppLog.getDid();
|
||||
// }
|
||||
// });
|
||||
ApmInsight.getInstance().init(this, builder.build());
|
||||
|
||||
//初始化自定日志,配置自定义日志最大占用磁盘,内部一般配置20,代表最大20M磁盘占用。1.4.1版本开始存在这个api
|
||||
VLog.init(this, 20);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initCloudClientConfig() {
|
||||
// todo 使用旧Socket链路 true = 旧链路,false = 新链路
|
||||
@@ -165,7 +65,6 @@ public class MogoApplication extends MainMoGoApplication {
|
||||
AppConfigInfo.INSTANCE.setWorkingBranchName(BuildConfig.WORKING_BRANCH_NAME);
|
||||
AppConfigInfo.INSTANCE.setWorkingBranchHash(BuildConfig.WORKING_BRANCH_HASH);
|
||||
|
||||
ObuConfig.useObuLocation = false;
|
||||
// 使用与渠道配置一样的gps提供者提供的数据,app/productFlavors/fPadLenovo.gradle GPS_PROVIDER 0-Android系统,1-工控机,2-OBU
|
||||
FunctionBuildConfig.gpsProvider = BuildConfig.GPS_PROVIDER;
|
||||
// 配置BuglyAppID
|
||||
|
||||
Reference in New Issue
Block a user