This commit is contained in:
zhongchao
2021-11-05 22:59:09 +08:00
parent a4938ccd8c
commit 6c094debd8
96 changed files with 671 additions and 3266 deletions

View File

@@ -1,30 +0,0 @@
package com.mogo.chat.aspect
import org.aspectj.lang.ProceedingJoinPoint
import org.aspectj.lang.annotation.Around
import org.aspectj.lang.annotation.Aspect
import org.aspectj.lang.annotation.Pointcut
import java.util.concurrent.TimeUnit
@Aspect
class ExceptionAspectj : BaseAspectj() {
@Pointcut("execution(* com.tencent.sharp.jni.TraeAudioManager\$2.run(..))")
fun gmeTrack() {
}
@Around("gmeTrack()")
fun logExecute(joinPoint: ProceedingJoinPoint) {
try {
enterMethod(joinPoint)
val startNanos = System.nanoTime()
val result = joinPoint.proceed()
val stopNanos = System.nanoTime()
val lengthMill = TimeUnit.NANOSECONDS.toMillis(stopNanos - startNanos)
exitMethod(joinPoint, result, lengthMill)
} catch (e: Exception) {
e.printStackTrace()
}
}
}

View File

@@ -1,14 +0,0 @@
package com.mogo.chat.aspect;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({TYPE, METHOD, CONSTRUCTOR})
@Retention(RUNTIME)
public @interface PushMsg {
}

View File

@@ -1,63 +0,0 @@
package com.mogo.chat.aspect
import android.util.Log
import android.view.View
import com.mogo.chat.constant.PUSH_MSG_AGREE_ENTER
import com.mogo.chat.constant.PUSH_MSG_HANG_UP
import com.mogo.chat.model.bean.Message
import com.mogo.chat.util.isDoubleClick
import com.mogo.chat.util.sp.recordCallTime
import com.mogo.chat.util.trackHangUp
import org.aspectj.lang.JoinPoint
import org.aspectj.lang.annotation.Aspect
import org.aspectj.lang.annotation.Before
import org.aspectj.lang.annotation.Pointcut
@Aspect
class TrackAspectj {
companion object {
const val TAG = "TrackAspectj"
}
@Pointcut("execution(* android.view.View.OnClickListener.onClick(..))")
fun trackOnClick() {
}
@Before("trackOnClick()")
fun trackClick(joinPoint: JoinPoint) {
val view = joinPoint.args[0] as View
if (isDoubleClick(view.id)) {
Log.i("trackClick", "重复点击,已过滤")
return
}
}
@Pointcut("within(@com.mogo.chat.aspect.PushMsg *)")
fun withinPushClass() {
}
@Pointcut("execution(!synthetic * *(..))&& withinPushClass()")
fun methodInsidePushType() {
}
@Pointcut("execution(@com.mogo.chat.aspect.PushMsg * *(..))|| methodInsidePushType()")
fun pushMethod() {
}
@Before("pushMethod()")
fun trackPushMsg(joinPoint: JoinPoint) {
val msg = joinPoint.args[0] as Message
when (msg.status) {
PUSH_MSG_AGREE_ENTER -> {
recordCallTime()
}
PUSH_MSG_HANG_UP -> {
trackHangUp(msg.type)
}
}
}
}