[dev_arch_opt_3.0] 优化UiThreadHandler和ThreadUtils切换主线程的逻辑,避免主线程消息队列过多,造成卡顿
This commit is contained in:
@@ -11,6 +11,7 @@ import androidx.lifecycle.*
|
||||
import androidx.lifecycle.Lifecycle.Event
|
||||
import androidx.lifecycle.Lifecycle.Event.ON_DESTROY
|
||||
import com.knightboost.lancet.api.*
|
||||
import com.knightboost.lancet.api.Scope.LEAF
|
||||
import com.knightboost.lancet.api.annotations.*
|
||||
import com.knightboost.lancet.api.annotations.Weaver
|
||||
import com.mogo.eagle.core.utilcode.kotlin.*
|
||||
@@ -24,8 +25,9 @@ import java.util.concurrent.ConcurrentHashMap
|
||||
@Group("memory_leak")
|
||||
class MemoryLeakFix {
|
||||
|
||||
@Insert
|
||||
@ImplementedInterface("java.lang.Runnable")
|
||||
@NameRegex("(com\\.mogo|com\\.zhidao|com\\.elegant|com\\.zhidaoauto|com\\.zhjt).*")
|
||||
@Insert(mayCreateSuper = true)
|
||||
@ImplementedInterface("java.lang.Runnable", scope = LEAF)
|
||||
@TargetMethod(methodName = "run")
|
||||
fun runProxy() {
|
||||
if (AccessSyntheticUtils.isTargetAlive(This.get())) {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.mogo.launcher.lancet;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
import com.knightboost.lancet.api.Scope;
|
||||
import com.knightboost.lancet.api.annotations.Group;
|
||||
import com.knightboost.lancet.api.annotations.ImplementedInterface;
|
||||
import com.knightboost.lancet.api.annotations.NameRegex;
|
||||
import com.knightboost.lancet.api.annotations.ReplaceInvoke;
|
||||
import com.knightboost.lancet.api.annotations.TargetMethod;
|
||||
import com.knightboost.lancet.api.annotations.Weaver;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Weaver
|
||||
@Group("object_hashcode")
|
||||
@Keep
|
||||
public class ObjectHashCodeProxy {
|
||||
|
||||
public static final ConcurrentHashMap<String, Integer> hashCodes = new ConcurrentHashMap<>();
|
||||
|
||||
@NameRegex("(com\\.mogo\\.eagle\\.core\\.utilcode\\.util\\.ThreadUtils|com\\.mogo\\.eagle\\.core\\.utilcode\\.util\\.UiThreadHandler)")
|
||||
@ImplementedInterface(value = "java.lang.Object",scope = Scope.SELF)
|
||||
@TargetMethod(methodName = "hashCode")
|
||||
@ReplaceInvoke
|
||||
public static int hashCodeProxy(Object r) {
|
||||
Class<?> clazz = r.getClass();
|
||||
String className = clazz.getName();
|
||||
if (hashCodes.containsKey(className)) {
|
||||
Integer value = hashCodes.get(className);
|
||||
if (value != null) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
int hashCode = System.identityHashCode(r);
|
||||
hashCodes.put(className, hashCode);
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user