Skip to content

Commit

Permalink
Feat/provicy (#140)
Browse files Browse the repository at this point in the history
* add multiprocess api.
update require pids logic : when disableDataCollect just judge isMainProcess

* OaidLibraryModule
update oaid sdk to 1.1.0 & add oaid config

* add oaid config

* update jar_mashelper sh

* update oaidcerthelper

* update growingio annotation test

* update process test
  • Loading branch information
cpacm authored Jan 21, 2022
1 parent 1e19d4f commit cbf2abe
Show file tree
Hide file tree
Showing 33 changed files with 639 additions and 202 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ GrowingIO Autotracker
**GrowingIO Autotracker** 具备自动采集基本的用户行为事件,比如访问和行为数据等。目前支持代码埋点、无埋点、可视化圈选、数据监测等功能。

## 集成文档
敬请期待……

[SDK 3.0 集成文档](https://growingio.github.io/growingio-sdk-docs/)

## License
```
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ buildscript {
]

releaseConfiguration = [
releaseVersion : "3.3.3",
releaseVersionCode: 30303,
releaseVersion : "3.3.4",
releaseVersionCode: 30304,
]

versions = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.Application;
import android.content.Context;
import android.os.Build;
import android.os.Process;
import android.os.StrictMode;
import android.support.multidex.MultiDexApplication;
import android.util.Log;
import android.webkit.WebView;

Expand All @@ -38,7 +38,7 @@

import java.util.List;

public class DemoApplication extends MultiDexApplication {
public class DemoApplication extends Application {
private static final String TAG = "DemoApplication";

private static boolean sIsAutotracker = true;
Expand Down Expand Up @@ -87,9 +87,11 @@ public void onViewInitFinished(boolean b) {
.setUploadExceptionEnabled(false)
.setDebugEnabled(true)
.setDataCollectionEnabled(true)
//.setRequireAppProcessesEnabled(true)
.setExcludeEvent(EventExcludeFilter.of(EventExcludeFilter.REENGAGE))
.setIgnoreField(FieldIgnoreFilter.of(FieldIgnoreFilter.FIELD_IGNORE_ALL))
.setPreloadComponent(new OaidLibraryGioModule());
//.addConfiguration(oaidConfig)
.addPreloadComponent(new OaidLibraryGioModule());
}

enableStrictMode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ protected void onCreate(Bundle savedInstanceState) {
Log.e(TAG, "onCreate: ");
Intent intent = getIntent();
Log.e(TAG, "onCreate: intent.getData() = " + intent.getData());

super.onCreate(savedInstanceState);
new LoadTask().execute();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ internal class ConfigurationGenerator(
val coreConfiguration = processEnv.elementUtils.getTypeElement(GIO_DEFAULT_CONFIGURATION)
?: throw IllegalStateException("Do you have import this class:$GIO_DEFAULT_CONFIGURATION?")
val generatedCodePackageName = appModule.enclosingElement.toString()
val generateClass = ClassName.get(generatedCodePackageName,configName)
val generateClass = ClassName.get(generatedCodePackageName, configName)
val coreConfigurationClass = ClassName.get(coreConfiguration)
val configBuilder = TypeSpec.classBuilder(configName)
.addJavadoc(
Expand Down Expand Up @@ -127,7 +127,7 @@ internal class ConfigurationGenerator(
.addMethod(generateConstructor(coreConfigurationClass, gioConfigs))//构造方法
.addMethod(generateCore(coreConfigurationClass))
.addMethod(generateGetConfigModules(mapOfConfigAndClass))
.addMethod(generateAddConfiguration(configurableClass))
.addMethod(generateAddConfiguration(generateClass, configurableClass))
.addMethod(generateGetConfiguration())

methodMap.clear()
Expand All @@ -137,7 +137,7 @@ internal class ConfigurationGenerator(
for (method in methods) {
processUtils.debugLog("${method.returnType} ${method.simpleName}(${method.parameters}){}")
val isCore = config == GIO_DEFAULT_CONFIGURATION
overriding(generateClass,configType, method, isCore)?.let {
overriding(generateClass, configType, method, isCore)?.let {
configBuilder.addMethod(it)
}
}
Expand Down Expand Up @@ -209,13 +209,15 @@ internal class ConfigurationGenerator(
return modulesMethod.build()
}

private fun generateAddConfiguration(config: ClassName): MethodSpec {
private fun generateAddConfiguration(generateClass: ClassName, config: ClassName): MethodSpec {
val addMethod = MethodSpec.methodBuilder("addConfiguration")
.addParameter(config, "config")
.addModifiers(Modifier.PUBLIC)
.beginControlFlow("if (config != null)")
.addStatement("MODULE_CONFIGURATIONS.put(config.getClass(), config)")
.endControlFlow()
.returns(generateClass)
.addStatement("return this")
return addMethod.build()
}

Expand All @@ -239,15 +241,15 @@ internal class ConfigurationGenerator(
}

private fun overriding(
generateClass:ClassName,
generateClass: ClassName,
config: TypeElement,
method: ExecutableElement,
isCore: Boolean = false
): MethodSpec? {
val enclosingClass = method.enclosingElement
require(!enclosingClass.modifiers.contains(Modifier.ABSTRACT)) { "Cannot transform method on abstract class $enclosingClass" }
var modifiers = method.modifiers
if (modifiers.contains(Modifier.PRIVATE)) {
if (modifiers.contains(Modifier.PRIVATE) || modifiers.contains(Modifier.PROTECTED)) {
processUtils.debugLog("cannot transform method with modifiers: $modifiers")
return null
}
Expand Down Expand Up @@ -276,6 +278,9 @@ internal class ConfigurationGenerator(
for (thrownType in method.thrownTypes) {
methodBuilder.addException(TypeName.get(thrownType))
}
for (annotationMirror in method.annotationMirrors) {
methodBuilder.addAnnotation(AnnotationSpec.get(annotationMirror))
}

// getConfiguration(CrashConfig.class).setDNS(dns);
val stateSb = StringBuilder()
Expand Down Expand Up @@ -312,11 +317,9 @@ internal class ConfigurationGenerator(
methodBuilder.returns(generateClass)
methodBuilder.addStatement(stateSb.toString(), ClassName.get(config))
methodBuilder.addStatement("return this")

} else {
methodBuilder.returns(TypeName.get(method.returnType))
methodBuilder.addStatement("return $stateSb", ClassName.get(config))

}
} else {
methodBuilder.returns(TypeName.get(method.returnType))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ class EmptyAppModuleTest : CompilationProvider {
assertThat(compilation!!).generatedSourceFile(TestUtil.subpackage("TestTrackConfiguration"))
.hasSourceEquivalentTo(forResource("TestTrackConfiguration.java"))


// .hasSourceEquivalentTo(forResource("GeneratedGioModuleImpl.java"))
}

private fun forResource(name: String): JavaFileObject {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,21 @@
import com.growingio.android.sdk.Configurable;

public class EmptyConfig implements Configurable {

private String testValue;

@Deprecated
public EmptyConfig setTestValue(String testValue) {
this.testValue = testValue;
return this;
}

protected EmptyConfig replaceTestValue(String testValue) {
this.testValue = testValue;
return this;
}

public String getTestValue() {
return testValue;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ public HashMap<Class<? extends Configurable>, Configurable> getConfigModules() {
return MODULE_CONFIGURATIONS;
}

public void addConfiguration(Configurable config) {
public TestTrackConfiguration addConfiguration(Configurable config) {
if (config != null) {
MODULE_CONFIGURATIONS.put(config.getClass(), config);
}
return this;
}

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -149,4 +150,14 @@ public final TestTrackConfiguration setOaidEnabled(boolean enabled) {
core().setOaidEnabled(enabled);
return this;
}

@Deprecated
public final TestTrackConfiguration setTestValue(String testValue) {
getConfiguration(EmptyConfig.class).setTestValue(testValue);
return this;
}

public final String getTestValue() {
return getConfiguration(EmptyConfig.class).getTestValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ public class ClassRewriter {
"android/arch/",
"com/google/",
"javax/",
// "com/squareup/",
"io/rectivex/rxjava",
// "org/apache",
"org/jetbrains/kotlin",

// "com/squareup/",
// "org/apache",
};


Expand Down
3 changes: 2 additions & 1 deletion growingio-tools/oaid/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
/build
/resources/classes
4 changes: 3 additions & 1 deletion growingio-tools/oaid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ dependencies {
testImplementation libraries.test.androidx_core
testImplementation libraries.test.robolectric
testImplementation libraries.androidx.appcompat
testImplementation files('resources/oaid_sdk_1.0.25.jar')
testImplementation files('resources/oaid_sdk_1.1.0.jar')

compileOnly files('resources/oaid_sdk_1.1.0.jar')
//compileOnly files('resources/oaid_sdk_1.0.26.jar')
implementation files('libs/msa_helper.jar')
implementation project(':growingio-tracker-core')
implementation project(":growingio-annotation")
Expand Down
Binary file modified growingio-tools/oaid/libs/msa_helper.jar
Binary file not shown.
Loading

0 comments on commit cbf2abe

Please sign in to comment.