Merge branch 'dev_robotaxi-d_231031_6.2.0' of gitlab.zhidaoauto.com:SCA/L4HA/AndroidApp/MoGoEagleEye into dev_robotaxi-d_231031_6.2.0

This commit is contained in:
aibingbing
2023-11-21 18:07:20 +08:00
4 changed files with 56 additions and 35 deletions

View File

@@ -43,6 +43,8 @@ internal class AccessSyntheticUtils {
private val fields = ConcurrentHashMap<String, WeakReference<Any>>()
private val observers = ConcurrentSet<String>()
// true: 代表要执行原来的run方法体
// false: 代表不执行原来的run方法体
@JvmStatic
fun isTargetAlive(obj: Any): Boolean {
try {
@@ -118,9 +120,7 @@ internal class AccessSyntheticUtils {
}
ret
} ?: true
} catch (t: Throwable) {
t.printStackTrace()
}
} catch (ignore: Throwable) { }
return true
}

View File

@@ -72,11 +72,11 @@ class HandlerHookerImpl : IHandlerHooker {
}
override fun onPostAtTime(handler: Handler, action: Runnable, token: Any?, uptimeMillis: Long) {
checkIfNeed(handler)?.insert(Msg.acquire(handler, action = action, obj = token, delay = uptimeMillis - SystemClock.uptimeMillis()))
checkIfNeed(handler)?.insert(Msg.acquire(handler, action = action, obj = token, enqueue = uptimeMillis))
}
override fun onPostAtTime(handler: Handler, action: Runnable, uptimeMillis: Long) {
checkIfNeed(handler)?.insert(Msg.acquire(handler, action = action, delay = uptimeMillis - SystemClock.uptimeMillis()))
checkIfNeed(handler)?.insert(Msg.acquire(handler, action = action, enqueue = uptimeMillis))
}
override fun onPostDelayed(handler: Handler, action: Runnable, token: Any?, delayMillis: Long) {
@@ -93,7 +93,7 @@ class HandlerHookerImpl : IHandlerHooker {
}
override fun onSendEmptyMessageAtTime(handler: Handler, what: Int, uptimeMillis: Long) {
checkIfNeed(handler)?.insert(Msg.acquire(handler, what = what, delay = uptimeMillis - SystemClock.uptimeMillis()))
checkIfNeed(handler)?.insert(Msg.acquire(handler, what = what, enqueue = uptimeMillis))
}
override fun onSendEmptyMessageDelayed(handler: Handler, what: Int, delayMillis: Long) {
@@ -109,7 +109,7 @@ class HandlerHookerImpl : IHandlerHooker {
}
override fun onSendMessageAtTime(handler: Handler, msg: Message, uptimeMillis: Long) {
checkIfNeed(handler)?.insert(Msg.acquire(handler, msg = msg, delay = uptimeMillis - SystemClock.uptimeMillis()))
checkIfNeed(handler)?.insert(Msg.acquire(handler, msg = msg, enqueue = uptimeMillis))
}
override fun onSendMessageDelayed(handler: Handler, msg: Message, delayMillis: Long) {

View File

@@ -40,19 +40,14 @@ public class HookInvokerImpl implements IHookInvoker {
private final long dumpStackThreshold = 20; // dump堆栈阈值
private volatile boolean isCanDump = false; // 是否可以Dump堆栈加此标记位是防止应用启动过程中由于dump主线程堆栈导致启动耗时
// 切记: 请勿在此方法中调用其它模块类中的api,可能会出现StackOverFlowException
@Override
public void i(Type type, Object caller,String methodName, Object... objects) {
startTime.set(SystemClock.elapsedRealtime());
boolean isMainThread = false;
if (mainLooper == Looper.myLooper()) {
isMainThread = true;
if (type == Type.SYNCHRONIZED_LOCK) {
handleSynchronizedLock(Looper.myLooper() == mainLooper, caller, methodName, objects);
}
}
boolean isMainThread = mainLooper == Looper.myLooper();
handleSynchronizedLock(isMainThread, caller, methodName, objects);
if (!getProviderRequested && provider == null && mainLooper != Looper.myLooper() && ARouterUtils.isInit.get()) {
getProviderRequested = true;
new Thread(() -> {
@@ -128,7 +123,7 @@ public class HookInvokerImpl implements IHookInvoker {
}
builder.append("#").append(cost);
if (cost >= dumpStackThreshold) {
if (cost >= dumpStackThreshold && isCanDump) {
builder.append("\n");
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
for (StackTraceElement trace: stackTrace) {
@@ -144,29 +139,48 @@ public class HookInvokerImpl implements IHookInvoker {
private void handleActivity(Activity caller, String methodName) {
if ("onCreate".equals(methodName)) {
IMoGoBlockProvider block = CallerDevaToolsManager.INSTANCE.block();
if (block != null && block.hasInit()) {
block.monitor(caller.getWindow());
try {
IMoGoBlockProvider block = CallerDevaToolsManager.INSTANCE.block();
if (block != null && block.hasInit()) {
block.monitor(caller.getWindow());
}
} catch (Throwable t) {
t.printStackTrace();
}
}
if ("onResume".equals(methodName)) {
IMoGoBlockProvider block = CallerDevaToolsManager.INSTANCE.block();
if (block != null && block.hasInit()) {
block.resume(caller.getWindow());
try {
IMoGoBlockProvider block = CallerDevaToolsManager.INSTANCE.block();
if (block != null && block.hasInit()) {
block.resume(caller.getWindow());
}
} catch (Throwable t) {
t.printStackTrace();
}
if (!isCanDump) {
isCanDump = true;
}
}
if ("onPause".equals(methodName)) {
IMoGoBlockProvider block = CallerDevaToolsManager.INSTANCE.block();
if (block != null && block.hasInit()) {
block.pause(caller.getWindow());
try {
IMoGoBlockProvider block = CallerDevaToolsManager.INSTANCE.block();
if (block != null && block.hasInit()) {
block.pause(caller.getWindow());
}
} catch (Throwable t) {
t.printStackTrace();
}
}
if ("onDestroy".equals(methodName)) {
IMoGoBlockProvider block = CallerDevaToolsManager.INSTANCE.block();
if (block != null && block.hasInit()) {
block.pop(caller.getWindow());
if ("onStop".equals(methodName)) {
try {
IMoGoBlockProvider block = CallerDevaToolsManager.INSTANCE.block();
if (block != null && block.hasInit()) {
block.pop(caller.getWindow());
}
} catch (Throwable t) {
t.printStackTrace();
}
}
}
@@ -216,16 +230,14 @@ public class HookInvokerImpl implements IHookInvoker {
builder.append(")");
}
builder.append("#").append(elapsedTime);
Object monitor = this.monitor.get();
if (monitor != null) {
builder.append("#").append(monitor);
builder.append("#").append("monitor->").append(monitor.getClass().getName()).append("@").append(monitor.hashCode());
}
if (holderDesc != null) {
builder.append("#").append(holderDesc);
builder.append("#").append("holder->").append(holderDesc);
}
if (elapsedTime >= dumpStackThreshold) {
if (elapsedTime >= dumpStackThreshold && isCanDump) {
builder.append("\n");
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
for (StackTraceElement trace: stackTrace) {

View File

@@ -3,6 +3,7 @@ package com.zhjt.mogo_core_function_devatools.badcase.repository.net
import android.util.Log
import com.mogo.commons.constants.HostConst
import com.mogo.eagle.core.data.BaseResponse
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_DEVA
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.network.MoGoRetrofitFactory
@@ -61,7 +62,15 @@ internal class BadCaseNetModel {
null
}
private fun getNetWorkApi(baseUrl: String ="http://eagle-qa.zhidaozhixing.com"): BadCaseApi{
private fun getHost(): String{
return if(FunctionBuildConfig.urlJson.eagleMisUrl.isEmpty()){
"http://eagle-qa.zhidaozhixing.com"
}else{
"http://eagle-mis-a.zhidaozhixing.com/"
}
}
private fun getNetWorkApi(baseUrl: String =getHost()): BadCaseApi{
return MoGoRetrofitFactory.getInstanceNoCallAdapter(baseUrl)
.create(BadCaseApi::class.java)
}