Merge branch 'dev_arch_opt_3.0' into dev_robobus-m1-p-app-module_1.0.0_230112_1.0.0

# Conflicts:
#	app/src/main/java/com/mogo/launcher/stageone/ConfigStartUp.kt
This commit is contained in:
yangyakun
2023-01-30 15:12:39 +08:00
126 changed files with 5436 additions and 1643 deletions

File diff suppressed because one or more lines are too long

View File

@@ -13,6 +13,7 @@ import com.mogo.launcher.stageone.APMStartup;
import com.mogo.launcher.stageone.ARouterStartUp;
import com.mogo.launcher.stageone.ConfigStartUp;
import com.mogo.launcher.stageone.HttpDnsStartUp;
import com.mogo.launcher.stageone.ThreadOptStartup;
import com.rousetime.android_startup.StartupListener;
import com.rousetime.android_startup.StartupManager;
import com.rousetime.android_startup.model.LoggerLevel;
@@ -63,52 +64,13 @@ public class MogoApplication extends MainMoGoApplication {
.addStartup(new APMStartup())
.addStartup(new ConfigStartUp())
.addStartup(new ARouterStartUp())
.addStartup(new ThreadOptStartup())
.setConfig(config)
.build(this)
.start()
.await();
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
// ThreadConfig.Builder builder = new ThreadConfig.Builder().listener(new ThreadConfig.TaskExecuteListener() {
// @Override
// public boolean isEnabled() {
// return true; // 如果返回true会有后续的回调如果返回false, 不会有后续的回调
// }
//
// @Override
// public void onExecutorBefore(@NonNull Runnable runnable, @NonNull ThreadConfig.TaskType type) {
// //每个任务执行前回调
//// if (type == ThreadConfig.TaskType.HandlerThread) {
////
////
//// }
// }
//
// @Override
// public void onExecutorAfter(@NonNull Runnable runnable, @NonNull ThreadConfig.TaskType type) {
// //每个任务执行后回调
// }
//
// /**
// * @param core 线程池的核心数
// * @param max 线程池的最大线程数
// * @param active 线程池正在活跃的任务数
// * @param completed 线程池已完成的任务数
// */
// @Override
// public void onExecutorStateChanged(@NonNull ThreadPoolExecutor pool, int core, int max, int active, long completed) {
// //线程池在执行过程,状态变化回调
// //Log.d("POOL", "core:" + core + ";max:" + max + ";active:" + active + ";completed:" + completed);
// }
// });
// builder.loggable(false);
// ThreadManager.INSTANCE.init(builder);
}
@Override
protected void initCrashConfig() {
CrashSystem crashSystem = CrashSystem.getInstance(this);
@@ -122,4 +84,4 @@ public class MogoApplication extends MainMoGoApplication {
super.initLogConfig();
Logger.init(BuildConfig.DEBUG ? LogLevel.DEBUG : LogLevel.OFF);
}
}
}

View File

@@ -0,0 +1,32 @@
package com.mogo.launcher.lancet
import android.content.ComponentName
import android.content.Intent
import androidx.annotation.*
import com.knightboost.lancet.api.Origin
import com.knightboost.lancet.api.Scope.ALL
import com.knightboost.lancet.api.Scope.LEAF
import com.knightboost.lancet.api.annotations.*
@Keep
@Weaver
@Group("crash_fix")
class CrashFix {
/**
* 修正Android8.0及之后后台启动Service引起的崩溃
* java.lang.IllegalStateException: Not allowed to start service Intent {
* act=com.zhidao.cosupload.service.UPLOAD_ACTION cmp=com.mogo.launcher.f/com.zhidao.cosupload.service.UploadService }: app is in background uid UidRecord{6443b7b u0a404 LAST bg:+1m15s362ms idle change:idle procs:1 seq(0,0,0)}
*/
@Insert(mayCreateSuper = true)
@TargetClass("android.content.Context", scope = LEAF)
@TargetMethod(methodName = "startService")
fun fixStartServiceCrash(intent: Intent): ComponentName? {
return try {
Origin.call() as ComponentName?
} catch (t: Throwable) {
t.printStackTrace()
null
}
}
}

View File

@@ -22,6 +22,6 @@ class APMStartup : AndroidStartup<Boolean?>() {
}
override fun dependenciesByName(): List<String> {
return listOf("com.mogo.launcher.stageone.ARouterStartUp", "com.mogo.launcher.stageone.ConfigStartUp")
return listOf("com.mogo.launcher.stageone.ARouterStartUp", "com.mogo.launcher.stageone.ThreadOptStartup")
}
}

View File

@@ -31,4 +31,8 @@ class ARouterStartUp : AndroidStartup<String>() {
}
override fun waitOnMainThread() = false
override fun dependenciesByName(): List<String>? {
return listOf("com.mogo.launcher.stageone.ThreadOptStartup")
}
}

View File

@@ -93,18 +93,9 @@ class ConfigStartUp : AndroidStartup<Boolean>() {
// 配置BuglyAppIDMoGoEagleEye
CrashReportConstants.buglyAppID = "ac71228f85"
if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode) ||
AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)
|| AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) {
//控制HMI展示元素 将不用手动调用setXXXXXViewVisibility
HmiBuildConfig.isShowAutopilotStatusView = false
HmiBuildConfig.isShowPerspectiveSwitchView = false
}
if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) {
HdMapBuildConfig.currentCarVrIconRes = R.raw.chuzuche
} else if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)
|| AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) {
} else if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) {
HdMapBuildConfig.currentCarVrIconRes = R.raw.xiaobache
// HmiBuildConfig.isShowBrakeLightView = false
// HmiBuildConfig.isShowTurnLightView = false
@@ -113,23 +104,14 @@ class ConfigStartUp : AndroidStartup<Boolean>() {
}
if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)
|| AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) {
//是否显示 红绿等
HmiBuildConfig.isShowTrafficLightView = false
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) {
//是否显示 限速UI
HmiBuildConfig.isShowLimitingVelocityView = false
//是否显示 路侧监控
HmiBuildConfig.isShowCameraView = false
//白天模式
FunctionBuildConfig.skinMode = 1
} else if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) {
//是否显示 红绿等
HmiBuildConfig.isShowTrafficLightView = false
//是否显示 限速UI
HmiBuildConfig.isShowLimitingVelocityView = false
//是否显示 路侧监控
HmiBuildConfig.isShowCameraView = false
}
}
@@ -171,4 +153,8 @@ class ConfigStartUp : AndroidStartup<Boolean>() {
MapAutoApi.init(context, mapParams)
}
override fun dependenciesByName(): List<String> {
return listOf("com.mogo.launcher.stageone.ThreadOptStartup")
}
}

View File

@@ -70,7 +70,8 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
override fun dependenciesByName(): List<String> {
return listOf(
"com.mogo.launcher.stageone.APMStartup"
"com.mogo.launcher.stageone.APMStartup",
"com.mogo.launcher.stageone.ThreadOptStartup"
)
}
@@ -377,5 +378,4 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
MogoAiCloudSocketManager.getInstance(context)
.init(context, DebugConfig.getSocketAppId(), lat, lon)
}
}

View File

@@ -0,0 +1,33 @@
package com.mogo.launcher.stageone
import android.content.*
import com.mogo.thread.ext.core.*
import com.mogo.thread.ext.core.config.*
import com.rousetime.android_startup.*
import java.io.*
import java.text.SimpleDateFormat
import java.util.*
import java.util.concurrent.TimeUnit.SECONDS
class ThreadOptStartup: AndroidStartup<Boolean>() {
override fun create(context: Context): Boolean {
ThreadManager
.init(ThreadConfig.Builder()
.maxKeepAliveTime(5, SECONDS)
/*.dump(DumpConfig.Builder()
.dumpLogFilePath(File(context.getExternalFilesDir(null), "thread_dump_log_${ SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.ROOT).format(Date()) }.txt").absolutePath)
.dumpPeriod(5, SECONDS)
.threadRunThreshold(10, SECONDS)
.build())*/)
return true
}
override fun callCreateOnMainThread(): Boolean {
return true
}
override fun waitOnMainThread(): Boolean {
return true
}
}