Skip to content

Commit

Permalink
Release 3.2.13
Browse files Browse the repository at this point in the history
  • Loading branch information
weiqiangliu committed Oct 21, 2020
1 parent 63653ef commit 9663400
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 5 deletions.
2 changes: 1 addition & 1 deletion plugin/ext.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project.ext {
pluginVersion = '3.2.12'
pluginVersion = '3.2.13'
Properties properties = new Properties()
if (project.file('local.properties').exists()) {
properties.load(project.file('local.properties').newDataInputStream())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@ class ClassNameAnalytics {
boolean isSensorsDataUtils = false
boolean isSALog = false
def methodCells = new ArrayList<SensorsAnalyticsMethodCell>()
boolean isAppWebViewInterface = false

ClassNameAnalytics(String className) {
this.className = className
isSensorsDataAPI = (className == 'com.sensorsdata.analytics.android.sdk.SensorsDataAPI')
isSensorsDataUtils = (className == 'com.sensorsdata.analytics.android.sdk.util.SensorsDataUtils')
isSALog = (className == 'com.sensorsdata.analytics.android.sdk.SALog')
isAppWebViewInterface = (className == 'com.sensorsdata.analytics.android.sdk.AppWebViewInterface')
}

boolean isSDKFile() {
return isSALog || isSensorsDataAPI || isSensorsDataUtils
return isSALog || isSensorsDataAPI || isSensorsDataUtils || isAppWebViewInterface
}

boolean isLeanback() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,18 +193,21 @@ class SensorsAnalyticsClassVisitor extends ClassVisitor {
//访问权限是public并且非静态
boolean pubAndNoStaticAccess
ArrayList<Integer> localIds
boolean shouldAddUCJS = false

@Override
void visitEnd() {
super.visitEnd()

if (isHasTracked) {
if (transformHelper.extension.lambdaEnabled && mLambdaMethodCells.containsKey(nameDesc)) {
mLambdaMethodCells.remove(nameDesc)
}
visitAnnotation("Lcom/sensorsdata/analytics/android/sdk/SensorsDataInstrumented;", false)
Logger.info("Hooked method: ${name}${desc}\n")
}
if (shouldAddUCJS) {
visitAnnotation("Lcom/uc/webview/export/JavascriptInterface;", true)
}
}

@Override
Expand Down Expand Up @@ -278,6 +281,12 @@ class SensorsAnalyticsClassVisitor extends ClassVisitor {
methodVisitor.visitVarInsn(ILOAD, 2)
methodVisitor.visitVarInsn(ISTORE, secondLocalId)
localIds.add(secondLocalId)
} else if (nameDesc == "onCheckedChanged(Landroid/widget/CompoundButton;Z)V" && pubAndNoStaticAccess) {
localIds = new ArrayList<>()
int firstLocalId = newLocal(Type.getObjectType("android/widget/CompoundButton"))
methodVisitor.visitVarInsn(ALOAD, 1)
methodVisitor.visitVarInsn(ASTORE, firstLocalId)
localIds.add(firstLocalId)
} else if (nameDesc == "onClick(Landroid/content/DialogInterface;I)V" && pubAndNoStaticAccess) {
localIds = new ArrayList<>()
int firstLocalId = newLocal(Type.getObjectType("android/content/DialogInterface"))
Expand Down Expand Up @@ -521,6 +530,16 @@ class SensorsAnalyticsClassVisitor extends ClassVisitor {
isHasTracked = true
return
}
} else if (mInterfaces.contains('android/widget/CompoundButton$OnCheckedChangeListener')
&& nameDesc == 'onCheckedChanged(Landroid/widget/CompoundButton;Z)V') {
SensorsAnalyticsMethodCell sensorsAnalyticsMethodCell = SensorsAnalyticsHookConfig.INTERFACE_METHODS
.get('android/widget/CompoundButton$OnCheckedChangeListeneronCheckedChanged(Landroid/widget/CompoundButton;Z)V')
if (sensorsAnalyticsMethodCell != null) {
methodVisitor.visitVarInsn(ALOAD, localIds.get(0))
methodVisitor.visitMethodInsn(INVOKESTATIC, SensorsAnalyticsHookConfig.SENSORS_ANALYTICS_API, sensorsAnalyticsMethodCell.agentName, sensorsAnalyticsMethodCell.agentDesc, false)
isHasTracked = true
return
}
} else if (mInterfaces.contains('android/content/DialogInterface$OnClickListener')
&& nameDesc == 'onClick(Landroid/content/DialogInterface;I)V') {
SensorsAnalyticsMethodCell sensorsAnalyticsMethodCell = SensorsAnalyticsHookConfig.INTERFACE_METHODS
Expand Down Expand Up @@ -641,6 +660,8 @@ class SensorsAnalyticsClassVisitor extends ClassVisitor {
}
}
}
} else if (classNameAnalytics.isAppWebViewInterface && transformHelper.extension.addUCJavaScriptInterface && s == "Landroid/webkit/JavascriptInterface;") {
shouldAddUCJS = true
}

return super.visitAnnotation(s, b)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class SensorsAnalyticsExtension {
public boolean useInclude = false
public boolean lambdaEnabled = true
public boolean autoHandleWebView = true
public boolean addUCJavaScriptInterface = false
public boolean lambdaParamOptimize = false

public ArrayList<String> exclude = []
Expand Down Expand Up @@ -64,6 +65,7 @@ class SensorsAnalyticsExtension {
"\tdisableJar=" + disableJar + "\n" +
"\tuseInclude=" + useInclude + "\n" +
"\tautoHandleWebView=" + autoHandleWebView + "\n" +
"\taddUCJavaScriptInterface=" + addUCJavaScriptInterface + "\n" +
"\tlambdaParamOptimize=" + lambdaParamOptimize + "\n" +
"\tlambdaEnabled=" + lambdaEnabled + "\n" +
"\texclude=[" + excludeBuilder.toString() + "]" + "\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ class SensorsAnalyticsHookConfig {
'(Landroid/view/View;)V',
1, 1,
[Opcodes.ALOAD]))
SAMPLING_LAMBDA_METHODS.add(new SensorsAnalyticsMethodCell(
'onClick',
'(Landroid/view/View;)V',
'Landroid/view/View$OnClickListener;',
'trackViewOnClick',
'(Landroid/view/View;)V',
1, 1,
[Opcodes.ALOAD]))
addLambdaMethod(new SensorsAnalyticsMethodCell(
'onCheckedChanged',
'(Landroid/widget/CompoundButton;Z)V',
Expand All @@ -323,6 +331,14 @@ class SensorsAnalyticsHookConfig {
'(Landroid/widget/RadioGroup;I)V',
1, 2,
[Opcodes.ALOAD, Opcodes.ILOAD]))
SAMPLING_LAMBDA_METHODS.add(new SensorsAnalyticsMethodCell(
'onCheckedChanged',
'(Landroid/widget/RadioGroup;I)V',
'Landroid/widget/RadioGroup$OnCheckedChangeListener;',
'trackRadioGroup',
'(Landroid/widget/RadioGroup;I)V',
1, 2,
[Opcodes.ALOAD, Opcodes.ILOAD]))
addLambdaMethod(new SensorsAnalyticsMethodCell(
'onClick',
'(Landroid/content/DialogInterface;I)V',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import java.util.jar.JarOutputStream

class SensorsAnalyticsTransform extends Transform {
private SensorsAnalyticsTransformHelper transformHelper
public static final String VERSION = "3.2.12"
public static final String VERSION = "3.2.13"
public static final String MIN_SDK_VERSION = "4.3.2"
private WaitableExecutor waitableExecutor
private URLClassLoader urlClassLoader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class SensorsAnalyticsTransformHelper {
classNameAnalytics.methodCells.addAll(methodCellList)
}
}
if (classNameAnalytics.methodCells.size() > 0 || classNameAnalytics.isSensorsDataAPI) {
if (classNameAnalytics.methodCells.size() > 0 || classNameAnalytics.isSensorsDataAPI || (classNameAnalytics.isAppWebViewInterface && extension.addUCJavaScriptInterface)) {
classNameAnalytics.isShouldModify = true
}
} else if (!classNameAnalytics.isAndroidGenerated()) {
Expand Down

0 comments on commit 9663400

Please sign in to comment.