Skip to content

Commit 566e35f

Browse files
author
dengshiwei
committed
Release 3.2.3
1 parent ce7a6fd commit 566e35f

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ buildscript {
1818
dependencies {
1919
classpath 'com.android.tools.build:gradle:3.2.0'
2020
//添加 android-gradle-plugin 依赖
21-
       classpath 'com.sensorsdata.analytics.android:android-gradle-plugin2:3.1.4'
21+
       classpath 'com.sensorsdata.analytics.android:android-gradle-plugin2:3.2.3'
2222
}
2323
}
2424
@@ -38,7 +38,7 @@ apply plugin: 'com.sensorsdata.analytics.android'
3838
3939
dependencies {
4040
//添加 Sensors Analytics SDK 依赖
41-
  compile 'com.sensorsdata.analytics.android:SensorsAnalyticsSDK:3.2.4'
41+
  compile 'com.sensorsdata.analytics.android:SensorsAnalyticsSDK:4.0.7'
4242
}
4343
```
4444

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.2.2'
2+
pluginVersion = '3.2.3'
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/SensorsAnalyticsClassVisitor.groovy

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,16 @@ class SensorsAnalyticsClassVisitor extends ClassVisitor {
255255
methodVisitor.visitVarInsn(ALOAD, 2)
256256
methodVisitor.visitVarInsn(ASTORE, localId)
257257
localIds.add(localId)
258+
} else if (nameDesc == "onCheckedChanged(Landroid/widget/RadioGroup;I)V" && pubAndNoStaticAccess) {
259+
localIds = new ArrayList<>()
260+
int firstLocalId = newLocal(Type.getObjectType("android/widget/RadioGroup"))
261+
methodVisitor.visitVarInsn(ALOAD, 1)
262+
methodVisitor.visitVarInsn(ASTORE, firstLocalId)
263+
localIds.add(firstLocalId)
264+
int secondLocalId = newLocal(Type.INT_TYPE)
265+
methodVisitor.visitVarInsn(ILOAD, 2)
266+
methodVisitor.visitVarInsn(ISTORE, secondLocalId)
267+
localIds.add(secondLocalId)
258268
}
259269
if (transformHelper.isHookOnMethodEnter) {
260270
handleCode()
@@ -422,6 +432,17 @@ class SensorsAnalyticsClassVisitor extends ClassVisitor {
422432
methodVisitor.visitMethodInsn(INVOKESTATIC, SensorsAnalyticsHookConfig.SENSORS_ANALYTICS_API, "trackListView", "(Landroid/widget/AdapterView;Landroid/view/View;I)V", false)
423433
isHasTracked = true
424434
return
435+
} else if (mInterfaces.contains('android/widget/RadioGroup$OnCheckedChangeListener')
436+
&& nameDesc == 'onCheckedChanged(Landroid/widget/RadioGroup;I)V') {
437+
SensorsAnalyticsMethodCell sensorsAnalyticsMethodCell = SensorsAnalyticsHookConfig.INTERFACE_METHODS
438+
.get('android/widget/RadioGroup$OnCheckedChangeListeneronCheckedChanged(Landroid/widget/RadioGroup;I)V')
439+
if (sensorsAnalyticsMethodCell != null) {
440+
methodVisitor.visitVarInsn(ALOAD, localIds.get(0))
441+
methodVisitor.visitVarInsn(ILOAD, localIds.get(1))
442+
methodVisitor.visitMethodInsn(INVOKESTATIC, SensorsAnalyticsHookConfig.SENSORS_ANALYTICS_API, sensorsAnalyticsMethodCell.agentName, sensorsAnalyticsMethodCell.agentDesc, false)
443+
isHasTracked = true
444+
return
445+
}
425446
} else {
426447
for (interfaceName in mInterfaces) {
427448
SensorsAnalyticsMethodCell sensorsAnalyticsMethodCell = SensorsAnalyticsHookConfig.INTERFACE_METHODS.get(interfaceName + nameDesc)

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ import java.util.concurrent.Callable
4141
import java.util.jar.JarEntry
4242
import java.util.jar.JarFile
4343
import java.util.jar.JarOutputStream
44+
import java.util.zip.ZipEntry
4445

4546
class SensorsAnalyticsTransform extends Transform {
4647
private SensorsAnalyticsTransformHelper transformHelper
47-
public static final String VERSION = "3.2.2"
48+
public static final String VERSION = "3.2.3"
4849
public static final String MIN_SDK_VERSION = "4.0.7"
4950
private WaitableExecutor waitableExecutor
5051
private URLClassLoader urlClassLoader
@@ -250,8 +251,14 @@ class SensorsAnalyticsTransform extends Transform {
250251
}
251252

252253
void forEachJar(boolean isIncremental, JarInput jarInput, TransformOutputProvider outputProvider, Context context) {
254+
String destName = jarInput.file.name
255+
//截取文件路径的 md5 值重命名输出文件,因为可能同名,会覆盖
256+
def hexName = DigestUtils.md5Hex(jarInput.file.absolutePath).substring(0, 8)
257+
if (destName.endsWith(".jar")) {
258+
destName = destName.substring(0, destName.length() - 4)
259+
}
253260
//获得输出文件
254-
File destFile = outputProvider.getContentLocation(jarInput.name, jarInput.contentTypes, jarInput.scopes, Format.JAR)
261+
File destFile = outputProvider.getContentLocation(destName + "_" + hexName, jarInput.contentTypes, jarInput.scopes, Format.JAR)
255262
if (isIncremental) {
256263
Status status = jarInput.getStatus()
257264
switch (status) {

0 commit comments

Comments
 (0)