From 2c90f5ca6fb4539a5084a2309332402890d99883 Mon Sep 17 00:00:00 2001 From: renwj Date: Wed, 18 Jan 2023 11:00:20 +0800 Subject: [PATCH 1/4] =?UTF-8?q?[2.13.2]=E7=A7=BB=E9=99=A4=E6=97=A0?= =?UTF-8?q?=E7=94=A8=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mogo/launcher/MogoApplication.java | 43 ------------------- 1 file changed, 43 deletions(-) diff --git a/app/src/main/java/com/mogo/launcher/MogoApplication.java b/app/src/main/java/com/mogo/launcher/MogoApplication.java index 547e5c243f..8f87eca0de 100644 --- a/app/src/main/java/com/mogo/launcher/MogoApplication.java +++ b/app/src/main/java/com/mogo/launcher/MogoApplication.java @@ -1,14 +1,10 @@ package com.mogo.launcher; import com.mogo.eagle.core.function.main.MainMoGoApplication; -import android.content.Context; - import com.mogo.eagle.core.utilcode.mogo.logger.LogLevel; import com.mogo.eagle.core.utilcode.mogo.logger.Logger; import com.mogo.launcher.crash.CrashSystem; -import java.util.concurrent.ThreadPoolExecutor; - /** * @author congtaowang * @since 2019-12-18 @@ -17,45 +13,6 @@ import java.util.concurrent.ThreadPoolExecutor; */ 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); From 784d97b8db63318518cdf1eb88abf9ffb70cefc0 Mon Sep 17 00:00:00 2001 From: renwj Date: Wed, 18 Jan 2023 15:05:34 +0800 Subject: [PATCH 2/4] =?UTF-8?q?[2.13.2]=E4=BF=AE=E6=AD=A3Android8.0?= =?UTF-8?q?=E5=8F=8A=E4=BB=A5=E5=90=8E,=E5=90=8E=E5=8F=B0=E5=BC=80?= =?UTF-8?q?=E5=90=AFService=E5=BC=95=E8=B5=B7=E7=9A=84=E5=B4=A9=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 7 ++-- .../com/mogo/launcher/MogoApplication.java | 30 +---------------- .../java/com/mogo/launcher/lancet/CrashFix.kt | 32 +++++++++++++++++++ 3 files changed, 36 insertions(+), 33 deletions(-) create mode 100644 app/src/main/java/com/mogo/launcher/lancet/CrashFix.kt diff --git a/app/build.gradle b/app/build.gradle index 0b5f1cb500..9470c7c56c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -52,13 +52,12 @@ if (!isAndroidTestBuild()) { enableInDebug true weaveGroup { - leak_canary_crash_fix { - enable !isReleaseBuild - } - anr_fix { enable true } + crash_fix { + enable true + } } } } diff --git a/app/src/main/java/com/mogo/launcher/MogoApplication.java b/app/src/main/java/com/mogo/launcher/MogoApplication.java index 8f87eca0de..c0ce3cb4d2 100644 --- a/app/src/main/java/com/mogo/launcher/MogoApplication.java +++ b/app/src/main/java/com/mogo/launcher/MogoApplication.java @@ -1,29 +1 @@ -package com.mogo.launcher; - -import com.mogo.eagle.core.function.main.MainMoGoApplication; -import com.mogo.eagle.core.utilcode.mogo.logger.LogLevel; -import com.mogo.eagle.core.utilcode.mogo.logger.Logger; -import com.mogo.launcher.crash.CrashSystem; - -/** - * @author congtaowang - * @since 2019-12-18 - *

- * Launcher application - */ -public class MogoApplication extends MainMoGoApplication { - - @Override - protected void initCrashConfig() { - CrashSystem crashSystem = CrashSystem.getInstance(this); - crashSystem.init(); - //设置debug模式,日志不上传 - crashSystem.setDebug(BuildConfig.DEBUG); - } - - @Override - protected void initLogConfig() { - super.initLogConfig(); - Logger.init(BuildConfig.DEBUG ? LogLevel.DEBUG : LogLevel.OFF); - } -} +package com.mogo.launcher; import com.mogo.eagle.core.function.main.MainMoGoApplication; import com.mogo.eagle.core.utilcode.mogo.logger.LogLevel; import com.mogo.eagle.core.utilcode.mogo.logger.Logger; import com.mogo.launcher.crash.CrashSystem; /** * @author congtaowang * @since 2019-12-18 *

* Launcher application */ public class MogoApplication extends MainMoGoApplication { @Override protected void initCrashConfig() { CrashSystem crashSystem = CrashSystem.getInstance(this); crashSystem.init(); //设置debug模式,日志不上传 crashSystem.setDebug(BuildConfig.DEBUG); } @Override protected void initLogConfig() { super.initLogConfig(); Logger.init(BuildConfig.DEBUG ? LogLevel.DEBUG : LogLevel.OFF); } } \ No newline at end of file diff --git a/app/src/main/java/com/mogo/launcher/lancet/CrashFix.kt b/app/src/main/java/com/mogo/launcher/lancet/CrashFix.kt new file mode 100644 index 0000000000..09ae7d1c42 --- /dev/null +++ b/app/src/main/java/com/mogo/launcher/lancet/CrashFix.kt @@ -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 + } + } +} \ No newline at end of file From 24e8ca5adcceeedd06f0457119089a3445b53066 Mon Sep 17 00:00:00 2001 From: renwj Date: Sat, 28 Jan 2023 15:31:59 +0800 Subject: [PATCH 3/4] =?UTF-8?q?[2.13.2]=E4=BC=98=E5=8C=96MarkerManager?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../function/v2x/events/marker/MarkerManager.kt | 17 +++++++---------- .../scenario/scene/airoad/AiRoadMarker.kt | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/marker/MarkerManager.kt b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/marker/MarkerManager.kt index 01387ee060..032df3a43f 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/marker/MarkerManager.kt +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/marker/MarkerManager.kt @@ -96,43 +96,39 @@ object MarkerManager { } val currentLocation = carLoc.get() val lastLocation = if (marker.coordinateType == 0) lastCarLocation.get() else lastGpsLocation.get() - - if (marker.coordinateType == 0) { - lastCarLocation.set(currentLocation) - } else { - lastGpsLocation.set(currentLocation) - } if (currentLocation != null && lastLocation != null) { val delta = CoordinateUtils.calculateLineDistance(currentLocation.longitude, currentLocation.latitude, lastLocation.longitude, lastLocation.latitude) - Log.d(TAG, "--- checkTask --- 4 ---:delta:$delta") + Log.d(TAG, "--- checkTask --- 4 ---:delta:$delta, id:${marker.id}") var elapsed = elapsedDistances[marker] if (elapsed == null) { elapsed = delta.toDouble() } else { elapsed += delta } - Log.d(TAG, "--- checkTask --- 5 ---:delta:$delta, elapsed:${elapsed}") + Log.d(TAG, "--- checkTask --- 5 ---:delta:$delta, elapsed:${elapsed}, id: ${marker.id}") if (elapsed >= 200) { var removeMarkerError = false marker.markers?.forEach { try { + Log.e(TAG, "--- checkTask --- remove marker: $it, id: ${marker.id}") it.setVisible(false) it.destroy() } catch (t: Throwable) { t.printStackTrace() removeMarkerError = true - Log.e(TAG, "--- checkTask --- remove marker error:${t.message}") + Log.e(TAG, "--- checkTask --- remove marker error:${t.message}, id: ${marker.id}") } } var removeLineError = false marker.lines?.forEach { try { it.isVisible = false + Log.e(TAG, "--- checkTask --- remove line : $it, id:${marker.id}") it.destroy() } catch (t: Throwable) { t.printStackTrace() removeLineError = true - Log.e(TAG, "--- checkTask --- remove line error:${t.message}") + Log.e(TAG, "--- checkTask --- remove line error:${t.message}, id: ${marker.id}") } } if (!removeLineError && !removeMarkerError) { @@ -186,6 +182,7 @@ object MarkerManager { fun addMarker(marker: MarkerWrapper) { + Log.d(TAG, "=== addMarker ====: $marker") synchronized(showedMarkers) { showedMarkers.offer(marker) } diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt index dfbf16bf89..06bc9193de 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt @@ -144,8 +144,8 @@ class AiRoadMarker { if (line != null) { wrapper.addLine(line) } - MarkerManager.addMarker(wrapper) } + MarkerManager.addMarker(wrapper) } private fun removeLine() { From 2c27af28a3e8706cba7f079f49e4bb13c6c8ef49 Mon Sep 17 00:00:00 2001 From: renwj Date: Sat, 28 Jan 2023 15:49:49 +0800 Subject: [PATCH 4/4] =?UTF-8?q?[2.13.2]=E5=BC=BA=E5=88=B6=E5=BC=80?= =?UTF-8?q?=E5=90=AF=E7=BA=BF=E7=A8=8B=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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 9470c7c56c..98bc4c30e6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -39,8 +39,8 @@ if (!isAndroidTestBuild()) { if (!isAndroidTestBuild()) { apply plugin: 'bytex.threadOpt' thread_opt { - enable !isReleaseBuild - enableInDebug !isReleaseBuild + enable true + enableInDebug true logLevel "DEBUG" } }