[dev_arch_opt_3.0][merge]合并2.13.2分支代码

This commit is contained in:
renwj
2023-01-29 17:58:41 +08:00
parent 2a9111c996
commit 7ae3e13fab
68 changed files with 3446 additions and 963 deletions

View File

@@ -70,45 +70,6 @@ public class MogoApplication extends MainMoGoApplication {
}
@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 +83,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

@@ -168,4 +168,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
}
}