From b9f863383e4ac753b9c78aaf593617b5608e4bba Mon Sep 17 00:00:00 2001 From: renwj Date: Fri, 6 Jan 2023 17:21:12 +0800 Subject: [PATCH] =?UTF-8?q?[2.13.2]=E5=BC=80=E5=90=AF=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 16 +++++----- .../com/mogo/launcher/stageone/APMStartup.kt | 2 +- .../mogo/launcher/stageone/ARouterStartUp.kt | 4 +++ .../mogo/launcher/stageone/ConfigStartUp.kt | 4 +++ .../mogo/launcher/stageone/HttpDnsStartUp.kt | 4 +-- .../launcher/stageone/ThreadOptStartup.kt | 32 +++++++++++++++++++ build.gradle | 2 +- gradle.properties | 2 +- 8 files changed, 53 insertions(+), 13 deletions(-) create mode 100644 app/src/main/java/com/mogo/launcher/stageone/ThreadOptStartup.kt diff --git a/app/build.gradle b/app/build.gradle index 726a2d8cef..02e2bede7f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -36,14 +36,14 @@ if (!isAndroidTestBuild()) { apply plugin: 'apm-plugin' } -//if (!isAndroidTestBuild()) { -// apply plugin: 'bytex.threadOpt' -// thread_opt { -// enable !isReleaseBuild -// enableInDebug !isReleaseBuild -// logLevel "DEBUG" -// } -//} +if (!isAndroidTestBuild()) { + apply plugin: 'bytex.threadOpt' + thread_opt { + enable !isReleaseBuild + enableInDebug !isReleaseBuild + logLevel "DEBUG" + } +} if (!isAndroidTestBuild()) { apply plugin: 'LancetX' diff --git a/app/src/main/java/com/mogo/launcher/stageone/APMStartup.kt b/app/src/main/java/com/mogo/launcher/stageone/APMStartup.kt index b593f616ba..b3a3d8345a 100644 --- a/app/src/main/java/com/mogo/launcher/stageone/APMStartup.kt +++ b/app/src/main/java/com/mogo/launcher/stageone/APMStartup.kt @@ -24,6 +24,6 @@ class APMStartup : AndroidStartup() { } override fun dependenciesByName(): List { - return listOf("com.mogo.launcher.stageone.ARouterStartUp") + return listOf("com.mogo.launcher.stageone.ARouterStartUp", "com.mogo.launcher.stageone.ThreadOptStartup") } } \ No newline at end of file diff --git a/app/src/main/java/com/mogo/launcher/stageone/ARouterStartUp.kt b/app/src/main/java/com/mogo/launcher/stageone/ARouterStartUp.kt index 1cab03977a..15c913da9b 100644 --- a/app/src/main/java/com/mogo/launcher/stageone/ARouterStartUp.kt +++ b/app/src/main/java/com/mogo/launcher/stageone/ARouterStartUp.kt @@ -31,4 +31,8 @@ class ARouterStartUp : AndroidStartup() { } override fun waitOnMainThread() = false + + override fun dependenciesByName(): List? { + return listOf("com.mogo.launcher.stageone.ThreadOptStartup") + } } \ No newline at end of file diff --git a/app/src/main/java/com/mogo/launcher/stageone/ConfigStartUp.kt b/app/src/main/java/com/mogo/launcher/stageone/ConfigStartUp.kt index 71babd15d0..4c151ffa25 100644 --- a/app/src/main/java/com/mogo/launcher/stageone/ConfigStartUp.kt +++ b/app/src/main/java/com/mogo/launcher/stageone/ConfigStartUp.kt @@ -105,4 +105,8 @@ class ConfigStartUp : AndroidStartup() { } } + + override fun dependenciesByName(): List { + return listOf("com.mogo.launcher.stageone.ThreadOptStartup") + } } \ No newline at end of file diff --git a/app/src/main/java/com/mogo/launcher/stageone/HttpDnsStartUp.kt b/app/src/main/java/com/mogo/launcher/stageone/HttpDnsStartUp.kt index 794e9ef28b..dd5ef2f13b 100644 --- a/app/src/main/java/com/mogo/launcher/stageone/HttpDnsStartUp.kt +++ b/app/src/main/java/com/mogo/launcher/stageone/HttpDnsStartUp.kt @@ -70,7 +70,8 @@ class HttpDnsStartUp : AndroidStartup() { override fun dependenciesByName(): List { return listOf( "com.mogo.launcher.stageone.APMStartup", - "com.mogo.launcher.stageone.ConfigStartUp" + "com.mogo.launcher.stageone.ConfigStartUp", + "com.mogo.launcher.stageone.ThreadOptStartup" ) } @@ -367,5 +368,4 @@ class HttpDnsStartUp : AndroidStartup() { MogoAiCloudSocketManager.getInstance(context) .init(context, DebugConfig.getSocketAppId(), lat, lon) } - } \ No newline at end of file diff --git a/app/src/main/java/com/mogo/launcher/stageone/ThreadOptStartup.kt b/app/src/main/java/com/mogo/launcher/stageone/ThreadOptStartup.kt new file mode 100644 index 0000000000..4f86a8f3ff --- /dev/null +++ b/app/src/main/java/com/mogo/launcher/stageone/ThreadOptStartup.kt @@ -0,0 +1,32 @@ +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() { + + 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) + .build())*/) + return true + } + + override fun callCreateOnMainThread(): Boolean { + return true + } + + override fun waitOnMainThread(): Boolean { + return true + } +} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 81379d1baa..0eb109a8a4 100644 --- a/build.gradle +++ b/build.gradle @@ -34,7 +34,7 @@ buildscript { classpath "com.mogo.cloud:hook:${HOOK_LOG_VERSION}" classpath "com.mogo.cloud:bizconfig:${BIZCONFIG_VERSION}" classpath 'com.volcengine:apm_insight_plugin:1.4.1' -// classpath "com.mogo.thread.opt:plg:${THREAD_OPT_VERSION}" + classpath "com.mogo.thread.opt:plg:${THREAD_OPT_VERSION}" classpath 'com.mogo.cloud:systrace:1.0.1' classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.18' classpath 'com.mogo.sticky:service:1.0.8' diff --git a/gradle.properties b/gradle.properties index e36cf509ed..6b7dbc5b19 100644 --- a/gradle.properties +++ b/gradle.properties @@ -175,4 +175,4 @@ ADAS_DATA_LIB_CHILD_VERSION=.0 # 线程优化版本 -THREAD_OPT_VERSION=3.0.2 +THREAD_OPT_VERSION=4.0.0