Skip to content

Commit c489b8f

Browse files
author
weiqiangliu
committed
Release 3.3.1
1 parent 053b941 commit c489b8f

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

plugin/ext.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project.ext {
2-
pluginVersion = '3.3.0'
2+
pluginVersion = '3.3.1'
33
Properties properties = new Properties()
44
if (project.file('local.properties').exists()) {
55
properties.load(project.file('local.properties').newDataInputStream())

plugin/src/main/groovy/com/sensorsdata/analytics/android/plugin/SensorsAnalyticsTransform.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import java.util.jar.JarOutputStream
4545

4646
class SensorsAnalyticsTransform extends Transform {
4747
private SensorsAnalyticsTransformHelper transformHelper
48-
public static final String VERSION = "3.3.0"
48+
public static final String VERSION = "3.3.1"
4949
public static final String MIN_SDK_VERSION = "4.3.2"
5050
private WaitableExecutor waitableExecutor
5151
private URLClassLoader urlClassLoader

plugin/src/main/groovy/com/sensorsdata/analytics/android/plugin/SensorsAnalyticsWebViewMethodVisitor.groovy

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.sensorsdata.analytics.android.plugin
1818

1919

20+
import org.objectweb.asm.Label
2021
import org.objectweb.asm.MethodVisitor
2122
import org.objectweb.asm.Opcodes
2223
import org.objectweb.asm.Type
@@ -89,13 +90,18 @@ class SensorsAnalyticsWebViewMethodVisitor extends AdviceAdapter implements Opco
8990
loadLocal(tmp)
9091
}
9192
super.visitMethodInsn(opcode, owner, name, desc, itf)
92-
//将局部变量表中的数据压入操作数栈中触发我们需要插入的方法
93-
positionList.reverseEach { tmp ->
94-
loadLocal(tmp)
93+
//处理 Dcloud 中 WebView 的写法,缩小范围为 AdaWebView
94+
if (isDCloud(owner, className)) {
95+
hookDCloud(positionList, name, desc)
96+
} else {
97+
//将局部变量表中的数据压入操作数栈中触发我们需要插入的方法
98+
positionList.reverseEach { tmp ->
99+
loadLocal(tmp)
100+
}
101+
desc = reStructureDesc(desc)
102+
//为保持新 SDK 使用旧版插件问题,会使用新 SDK loadUrl + 2 后缀的方法
103+
mv.visitMethodInsn(INVOKESTATIC, SensorsAnalyticsHookConfig.SENSORS_ANALYTICS_API, name + "2", desc, false)
95104
}
96-
desc = reStructureDesc(desc)
97-
//为保持新 SDK 使用旧版插件问题,会使用新 SDK loadUrl + 2 后缀的方法
98-
mv.visitMethodInsn(INVOKESTATIC, SensorsAnalyticsHookConfig.SENSORS_ANALYTICS_API, name + "2", desc, false)
99105
return
100106
}
101107
}
@@ -105,6 +111,30 @@ class SensorsAnalyticsWebViewMethodVisitor extends AdviceAdapter implements Opco
105111
super.visitMethodInsn(opcode, owner, name, desc, itf)
106112
}
107113

114+
private boolean isDCloud(String owner, String className) {
115+
return owner == "io/dcloud/common/adapter/ui/webview/DCWebView" && className.contains("AdaWebview")
116+
}
117+
118+
private void hookDCloud(List<Integer> positionList, String name, String desc) {
119+
boolean isCask = false
120+
int tmpPosition = positionList.last()
121+
loadLocal(tmpPosition)
122+
mv.visitTypeInsn(INSTANCEOF, "android/view/View")
123+
Label label = new Label()
124+
mv.visitJumpInsn(IFEQ, label)
125+
positionList.reverseEach { tmp ->
126+
loadLocal(tmp)
127+
if (!isCask) {
128+
isCask = true
129+
mv.visitTypeInsn(CHECKCAST, "android/view/View")
130+
}
131+
}
132+
desc = reStructureDesc(desc)
133+
//为保持新 SDK 使用旧版插件问题,会使用新 SDK loadUrl + 2 后缀的方法
134+
mv.visitMethodInsn(INVOKESTATIC, SensorsAnalyticsHookConfig.SENSORS_ANALYTICS_API, name + "2", desc, false)
135+
mv.visitLabel(label)
136+
}
137+
108138
/**
109139
* 判断方法的 owner 是否是 WebView 的子类
110140
*
@@ -116,6 +146,9 @@ class SensorsAnalyticsWebViewMethodVisitor extends AdviceAdapter implements Opco
116146
if (OWNER_WHITE_SET.contains(owner)) {
117147
return true
118148
}
149+
if (isDCloud(owner, className)) {
150+
return true
151+
}
119152
Class ownerClass = transformHelper.urlClassLoader.loadClass(owner.replace("/", "."))
120153
if (x5WebViewStatus == X5WebViewStatus.FOUND && isPreviousX5WebView) {
121154
if (checkX5WebView(ownerClass, owner)) {

0 commit comments

Comments
 (0)