├── .gitignore ├── .idea ├── .gitignore ├── compiler.xml ├── jarRepositories.xml ├── kotlinScripting.xml └── misc.xml ├── LICENSE ├── README.md ├── build.gradle.kts ├── gradle.properties ├── gradle ├── jitpack.gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── keystore ├── sample-sdk ├── network-sdk-demo │ ├── .gitignore │ ├── build.gradle.kts │ ├── consumer-rules.pro │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── kronos │ │ │ └── startup │ │ │ └── sample │ │ │ └── network │ │ │ └── ExampleInstrumentedTest.kt │ │ ├── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── kronos │ │ │ └── startup │ │ │ └── sample │ │ │ └── network │ │ │ └── NetworkSdkTask.kt │ │ └── test │ │ └── java │ │ └── com │ │ └── kronos │ │ └── startup │ │ └── sample │ │ └── network │ │ └── ExampleUnitTest.kt └── report-sdk-demo │ ├── .gitignore │ ├── build.gradle.kts │ ├── consumer-rules.pro │ ├── proguard-rules.pro │ └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── kronos │ │ └── startup │ │ └── sample │ │ └── report │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ └── java │ │ └── com │ │ └── kronos │ │ └── startup │ │ └── sample │ │ └── report │ │ ├── ReportSdkTask.kt │ │ └── di │ │ └── ReportInitDelegate.kt │ └── test │ └── java │ └── com │ └── kronos │ └── startup │ └── sample │ └── report │ └── ExampleUnitTest.kt ├── sample ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── kronos │ │ └── android │ │ └── startup │ │ └── sample │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── kotlin │ │ └── com │ │ │ └── kronos │ │ │ └── android │ │ │ └── startup │ │ │ └── sample │ │ │ ├── MainActivity.kt │ │ │ ├── SampleApplication.kt │ │ │ ├── SampleTaskNameProvider.kt │ │ │ ├── WebActivity.kt │ │ │ ├── di │ │ │ └── AppModule.kt │ │ │ └── task │ │ │ ├── MyAnchorTask.kt │ │ │ ├── TaskBuilder.kt │ │ │ ├── generate │ │ │ ├── SampleGenerate1Task.kt │ │ │ ├── SampleGenerate2Task.kt │ │ │ └── SimplePrivacyGenerateTask.kt │ │ │ ├── ksp │ │ │ ├── AsyncTask1.kt │ │ │ ├── SimpleTask1.kt │ │ │ ├── SimpleTask2.kt │ │ │ └── SimpleTask3.kt │ │ │ └── utils │ │ │ └── ToastHelper.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── values-night │ │ └── themes.xml │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── themes.xml │ └── test │ └── java │ └── com │ └── kronos │ └── android │ └── startup │ └── sample │ └── ExampleUnitTest.kt ├── settings.gradle.kts ├── startup-annotation ├── .gitignore ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ └── kotlin │ └── com │ └── kronos │ └── startup │ ├── TaskNameProvider.kt │ └── annotation │ ├── Lifecycle.kt │ ├── Process.kt │ ├── StartupGroup.kt │ ├── Step.kt │ └── startup │ ├── Async.kt │ ├── Await.kt │ ├── DependOn.kt │ ├── MustAfter.kt │ └── Startup.kt ├── startup-dag-view ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── kronos │ │ └── startup │ │ └── dag │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── kronos │ │ │ └── startup │ │ │ └── dag │ │ │ ├── DividerItemDecoration.kt │ │ │ ├── StartupDagInstallProvider.kt │ │ │ ├── StartupDagPathActivity.kt │ │ │ ├── StartupMainDebugActivity.kt │ │ │ ├── StartupTaskDurationActivity.kt │ │ │ ├── StartupTimeLineActivity.kt │ │ │ ├── adapter │ │ │ ├── EachThreadAdapter.kt │ │ │ ├── HeaderAdapter.kt │ │ │ ├── TaskViewAdapter.kt │ │ │ └── TimeLineAdapter.kt │ │ │ ├── data │ │ │ └── ThreadTaskData.kt │ │ │ ├── repo │ │ │ └── TaskDurationRepo.kt │ │ │ ├── sql │ │ │ ├── PathTypeConvert.kt │ │ │ ├── StartTaskInfo.kt │ │ │ ├── StartupDao.kt │ │ │ ├── StartupDataTransform.kt │ │ │ ├── StartupDatabase.kt │ │ │ ├── StartupDatabaseHelper.kt │ │ │ └── StartupPathInfo.kt │ │ │ ├── utils │ │ │ ├── ConcatAdapterDsl.kt │ │ │ ├── DateExtensions.kt │ │ │ ├── DimenUtils.kt │ │ │ ├── MainThreadExecutor.kt │ │ │ └── TaskClassifyExtensions.kt │ │ │ └── widget │ │ │ ├── CustomizeScrollView.kt │ │ │ └── ViewExtensions.kt │ └── res │ │ ├── layout │ │ ├── startup_activity_dag_path.xml │ │ ├── startup_activity_dag_time_line.xml │ │ ├── startup_activity_main_debug.xml │ │ ├── startup_activity_task_duration.xml │ │ ├── startup_recycler_view_header.xml │ │ ├── startup_recycler_view_task_duration.xml │ │ ├── startup_recycler_view_thread_name.xml │ │ ├── startup_recycler_view_thread_task.xml │ │ └── startup_recycler_view_time_line.xml │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── kronos │ └── startup │ └── dag │ └── ExampleUnitTest.kt ├── startup-ksp-compiler ├── .gitignore ├── build.gradle.kts └── src │ └── main │ ├── java │ └── com │ │ └── kronos │ │ └── startup │ │ └── ksp │ │ └── compiler │ │ ├── KotlinPoetExe.kt │ │ ├── KspUtils.kt │ │ ├── StartupProcessor.kt │ │ ├── group │ │ ├── GenerateProcGroupKt.kt │ │ └── TaskBuilder.kt │ │ ├── stage │ │ └── StageGenerateKt.kt │ │ ├── task │ │ ├── GenerateTaskKt.kt │ │ └── StartupTaskBuilder.kt │ │ └── utils │ │ ├── CollectionsExtensions.kt │ │ └── StringExtensions.kt │ └── resources │ └── META-INF │ └── services │ └── com.google.devtools.ksp.processing.SymbolProcessorProvider └── startup ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src ├── androidTest └── java │ └── com │ └── kronos │ └── android_startup │ └── ExampleInstrumentedTest.kt ├── main ├── AndroidManifest.xml ├── java │ └── com │ │ └── kronos │ │ └── lib │ │ └── startup │ │ ├── AnchorTaskWrap.kt │ │ ├── SimpleStartupTask.kt │ │ ├── StartUpDsl.kt │ │ ├── Startup.kt │ │ ├── StartupAwaitTask.kt │ │ ├── StartupConfig.kt │ │ ├── StartupDispatcher.kt │ │ ├── StartupTask.kt │ │ ├── StartupTaskGroup.kt │ │ ├── StartupTaskManager.kt │ │ ├── StartupTracker.kt │ │ ├── TaskBuilder.kt │ │ ├── TaskRunner.kt │ │ ├── data │ │ └── StartupTaskData.kt │ │ ├── generate │ │ └── GenerateStartupTask.kt │ │ ├── logger │ │ └── KLogger.kt │ │ ├── step │ │ ├── StepStartupPack.kt │ │ └── StepTaskBuilder.kt │ │ ├── thread │ │ └── StartUpThreadFactory.kt │ │ └── utils │ │ ├── CollectionsExtensions.kt │ │ └── ProcessUtils.kt └── res │ └── values │ └── strings.xml └── test └── java └── com └── kronos └── android_startup └── ExampleUnitTest.kt /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.aar 4 | *.ap_ 5 | *.aab 6 | 7 | # Files for the ART/Dalvik VM 8 | *.dex 9 | 10 | # Java class files 11 | *.class 12 | 13 | # Generated files 14 | bin/ 15 | gen/ 16 | out/ 17 | # Uncomment the following line in case you need and you don't have the release build type files in your app 18 | # release/ 19 | 20 | # Gradle files 21 | .gradle/ 22 | build/ 23 | 24 | # Local configuration file (sdk path, etc) 25 | local.properties 26 | 27 | # Proguard folder generated by Eclipse 28 | proguard/ 29 | 30 | # Log Files 31 | *.log 32 | 33 | # Android Studio Navigation editor temp files 34 | .navigation/ 35 | 36 | # Android Studio captures folder 37 | captures/ 38 | 39 | # IntelliJ 40 | *.iml 41 | .idea/workspace.xml 42 | .idea/tasks.xml 43 | .idea/gradle.xml 44 | .idea/assetWizardSettings.xml 45 | .idea/dictionaries 46 | .idea/libraries 47 | # Android Studio 3 in .gitignore file. 48 | .idea/caches 49 | .idea/modules.xml 50 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you 51 | .idea/navEditor.xml 52 | 53 | # Keystore files 54 | # Uncomment the following lines if you do not want to check your keystore files in. 55 | #*.jks 56 | #*.keystore 57 | 58 | # External native build folder generated in Android Studio 2.2 and later 59 | .externalNativeBuild 60 | .cxx/ 61 | 62 | # Google Services (e.g. APIs or Firebase) 63 | # google-services.json 64 | 65 | # Freeline 66 | freeline.py 67 | freeline/ 68 | freeline_project_description.json 69 | 70 | # fastlane 71 | fastlane/report.xml 72 | fastlane/Preview.html 73 | fastlane/screenshots 74 | fastlane/test_output 75 | fastlane/readme.md 76 | 77 | # Version control 78 | vcs.xml 79 | 80 | # lint 81 | lint/intermediates/ 82 | lint/generated/ 83 | lint/outputs/ 84 | lint/tmp/ 85 | # lint/reports/ 86 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | 29 | 30 | 34 | 35 | 39 | 40 | -------------------------------------------------------------------------------- /.idea/kotlinScripting.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 2147483647 6 | true 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | extra["kotlin_version"] = "1.5.30" 4 | 5 | repositories { 6 | maven { setUrl("https://maven.aliyun.com/repository/central/") } 7 | google() 8 | } 9 | dependencies { 10 | classpath("com.android.tools.build:gradle:7.1.0") 11 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30") 12 | // NOTE: Do not place your application dependencies here; they belong 13 | // in the individual module build.gradle files 14 | } 15 | } 16 | 17 | 18 | allprojects { 19 | repositories { 20 | maven { setUrl("https://maven.aliyun.com/repository/central/") } 21 | google() 22 | } 23 | configurations.all { 24 | resolutionStrategy.dependencySubstitution.all { 25 | if (requested is ModuleComponentSelector) { 26 | val moduleRequested = requested as ModuleComponentSelector 27 | val p = rootProject.allprojects.find { p -> 28 | (p.group == moduleRequested.group && p.name == moduleRequested.module) 29 | } 30 | if (p != null) { 31 | useTarget(project(p.path), "selected local project") 32 | } 33 | 34 | } 35 | } 36 | } 37 | 38 | // 项目内如果想要引用到生成的代码 使用下列方式 39 | afterEvaluate { 40 | extensions.findByType(org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension::class) 41 | ?.apply { 42 | sourceSets.forEach { 43 | it.kotlin.srcDir("build/generated/ksp") 44 | } 45 | } 46 | } 47 | 48 | group = "com.kronos.startup" 49 | } 50 | 51 | 52 | // 耗时统计kt化 53 | class TimingsListener : TaskExecutionListener, BuildListener { 54 | private var startTime: Long = 0L 55 | private var timings = linkedMapOf() 56 | 57 | 58 | override fun beforeExecute(task: Task) { 59 | startTime = System.nanoTime() 60 | } 61 | 62 | override fun afterExecute(task: Task, state: TaskState) { 63 | val ms = TimeUnit.MILLISECONDS.convert(System.nanoTime() - startTime, TimeUnit.NANOSECONDS) 64 | task.path 65 | timings[task.path] = ms 66 | project.logger.warn("${task.path} took ${ms}ms") 67 | } 68 | 69 | override fun buildFinished(result: BuildResult) { 70 | project.logger.warn("Task timings:") 71 | timings.forEach { 72 | if (it.value >= 50) { 73 | project.logger.warn("${it.key} cos ms ${it.value}\n") 74 | } 75 | } 76 | } 77 | 78 | 79 | override fun settingsEvaluated(settings: Settings) { 80 | } 81 | 82 | override fun projectsLoaded(gradle: Gradle) { 83 | 84 | } 85 | 86 | override fun projectsEvaluated(gradle: Gradle) { 87 | 88 | } 89 | 90 | } 91 | 92 | gradle.addListener(TimingsListener()) 93 | 94 | /* 95 | task clean(type: Delete) { 96 | delete rootProject.buildDir 97 | }*/ 98 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official -------------------------------------------------------------------------------- /gradle/jitpack.gradle: -------------------------------------------------------------------------------- 1 | 2 | tasks.withType(Javadoc) { 3 | options.addStringOption('Xdoclint:none', '-quiet') 4 | options.addStringOption('encoding', 'UTF-8') 5 | options.addStringOption('charSet', 'UTF-8') 6 | } 7 | 8 | task sourcesJar(type: Jar) { 9 | from android.sourceSets.main.java.srcDirs 10 | classifier = 'sources' 11 | } 12 | 13 | task javadoc(type: Javadoc) { 14 | source = android.sourceSets.main.java.srcDirs 15 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 16 | } 17 | 18 | task javadocJar(type: Jar, dependsOn: javadoc) { 19 | classifier = 'javadoc' 20 | from javadoc.destinationDir 21 | } 22 | 23 | artifacts { 24 | archives javadocJar 25 | archives sourcesJar 26 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Leifzhang/AndroidStartup/883e2be9c1c6b19714fa74c803bd517fad081944/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Nov 26 10:43:25 CST 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Leifzhang/AndroidStartup/883e2be9c1c6b19714fa74c803bd517fad081944/keystore -------------------------------------------------------------------------------- /sample-sdk/network-sdk-demo/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /sample-sdk/network-sdk-demo/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.library") 3 | id("org.jetbrains.kotlin.android") 4 | id("com.google.devtools.ksp") 5 | } 6 | 7 | android { 8 | compileSdk = 32 9 | 10 | defaultConfig { 11 | minSdk = 21 12 | targetSdk = 32 13 | 14 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" 15 | consumerProguardFiles("consumer-rules.pro") 16 | } 17 | 18 | buildTypes { 19 | release { 20 | isMinifyEnabled = false 21 | proguardFiles( 22 | getDefaultProguardFile("proguard-android-optimize.txt"), 23 | "proguard-rules.pro" 24 | ) 25 | } 26 | } 27 | compileOptions { 28 | sourceCompatibility = JavaVersion.VERSION_1_8 29 | targetCompatibility = JavaVersion.VERSION_1_8 30 | } 31 | kotlinOptions { 32 | jvmTarget = "1.8" 33 | } 34 | } 35 | 36 | dependencies { 37 | implementation(project(":startup")) 38 | implementation(project(":startup-annotation")) 39 | ksp(project(":startup-ksp-compiler")) 40 | implementation("androidx.core:core-ktx:1.7.0") 41 | implementation("androidx.appcompat:appcompat:1.3.0") 42 | implementation("com.google.android.material:material:1.4.0") 43 | testImplementation("junit:junit:4.13.2") 44 | androidTestImplementation("androidx.test.ext:junit:1.1.3") 45 | androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") 46 | } 47 | ksp { 48 | arg("MODULE_NAME", project.name) 49 | } -------------------------------------------------------------------------------- /sample-sdk/network-sdk-demo/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Leifzhang/AndroidStartup/883e2be9c1c6b19714fa74c803bd517fad081944/sample-sdk/network-sdk-demo/consumer-rules.pro -------------------------------------------------------------------------------- /sample-sdk/network-sdk-demo/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /sample-sdk/network-sdk-demo/src/androidTest/java/com/kronos/startup/sample/network/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.startup.sample.network 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.kronos.startup.sample.sdk1.test", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /sample-sdk/network-sdk-demo/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /sample-sdk/network-sdk-demo/src/main/java/com/kronos/startup/sample/network/NetworkSdkTask.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.startup.sample.network 2 | 3 | import android.content.Context 4 | import android.util.Log 5 | import com.kronos.lib.startup.TaskRunner 6 | import com.kronos.startup.annotation.Process 7 | import com.kronos.startup.annotation.startup.Async 8 | import com.kronos.startup.annotation.startup.Await 9 | import com.kronos.startup.annotation.startup.Startup 10 | 11 | /** 12 | * 13 | * @Author LiABao 14 | * @Since 2021/12/31 15 | * 16 | */ 17 | @Async 18 | @Await 19 | @Startup(strategy = Process.MAIN) 20 | class NetworkSdkTask : TaskRunner { 21 | 22 | override fun run(context: Context) { 23 | info("NetworkSdkTask") 24 | } 25 | 26 | } 27 | 28 | fun info(info: String) { 29 | val threadName = Thread.currentThread().name 30 | Log.i(TAG, "[threadName:$threadName] $info") 31 | } 32 | 33 | 34 | const val TAG = "START-DSL—TEST" -------------------------------------------------------------------------------- /sample-sdk/network-sdk-demo/src/test/java/com/kronos/startup/sample/network/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.startup.sample.network 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /sample-sdk/report-sdk-demo/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /sample-sdk/report-sdk-demo/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.library") 3 | id("org.jetbrains.kotlin.android") 4 | id("kotlin-kapt") 5 | id("com.google.devtools.ksp") 6 | } 7 | 8 | android { 9 | compileSdk = 32 10 | 11 | defaultConfig { 12 | minSdk = 21 13 | targetSdk = 32 14 | 15 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" 16 | consumerProguardFiles("consumer-rules.pro") 17 | } 18 | 19 | buildTypes { 20 | release { 21 | isMinifyEnabled = false 22 | proguardFiles( 23 | getDefaultProguardFile("proguard-android-optimize.txt"), 24 | "proguard-rules.pro" 25 | ) 26 | } 27 | } 28 | compileOptions { 29 | sourceCompatibility = JavaVersion.VERSION_1_8 30 | targetCompatibility = JavaVersion.VERSION_1_8 31 | } 32 | kotlinOptions { 33 | jvmTarget = "1.8" 34 | } 35 | } 36 | 37 | dependencies { 38 | 39 | implementation(project(":network-sdk-demo")) 40 | 41 | 42 | implementation(project(":startup")) 43 | implementation(project(":startup-annotation")) 44 | ksp(project(":startup-ksp-compiler")) 45 | 46 | implementation("io.insert-koin:koin-android:3.1.5") 47 | 48 | implementation("androidx.core:core-ktx:1.7.0") 49 | implementation("androidx.appcompat:appcompat:1.3.0") 50 | implementation("com.google.android.material:material:1.4.0") 51 | testImplementation("junit:junit:4.13.2") 52 | androidTestImplementation("androidx.test.ext:junit:1.1.3") 53 | androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") 54 | } 55 | ksp { 56 | arg("MODULE_NAME", project.name) 57 | } -------------------------------------------------------------------------------- /sample-sdk/report-sdk-demo/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Leifzhang/AndroidStartup/883e2be9c1c6b19714fa74c803bd517fad081944/sample-sdk/report-sdk-demo/consumer-rules.pro -------------------------------------------------------------------------------- /sample-sdk/report-sdk-demo/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /sample-sdk/report-sdk-demo/src/androidTest/java/com/kronos/startup/sample/report/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.startup.sample.report 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.kronos.startup.sample.report.test", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /sample-sdk/report-sdk-demo/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /sample-sdk/report-sdk-demo/src/main/java/com/kronos/startup/sample/report/ReportSdkTask.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.startup.sample.report 2 | 3 | import android.content.Context 4 | import android.util.Log 5 | import com.kronos.lib.startup.NetworkSdkTaskProvider 6 | import com.kronos.lib.startup.TaskRunner 7 | import com.kronos.startup.annotation.startup.Async 8 | import com.kronos.startup.annotation.startup.Await 9 | import com.kronos.startup.annotation.startup.DependOn 10 | import com.kronos.startup.annotation.startup.Startup 11 | import com.kronos.startup.sample.report.di.ReportInitDelegate 12 | import org.koin.core.component.KoinComponent 13 | import org.koin.core.component.inject 14 | 15 | /** 16 | * 17 | * @Author LiABao 18 | * @Since 2021/12/31 19 | * 20 | */ 21 | @Async 22 | @Await 23 | @DependOn(dependOn = [NetworkSdkTaskProvider::class]) 24 | @Startup 25 | class ReportSdkTask : KoinComponent, TaskRunner { 26 | 27 | private val initDelegate: ReportInitDelegate by inject() 28 | 29 | override fun run(context: Context) { 30 | info("ReportSdkTask appName is:${initDelegate.getAppName()}") 31 | } 32 | 33 | } 34 | 35 | fun info(info: String) { 36 | val threadName = Thread.currentThread().name 37 | Log.i(TAG, "[threadName:$threadName] $info") 38 | } 39 | 40 | 41 | const val TAG = "ReportSdkTask" -------------------------------------------------------------------------------- /sample-sdk/report-sdk-demo/src/main/java/com/kronos/startup/sample/report/di/ReportInitDelegate.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.startup.sample.report.di 2 | 3 | /** 4 | * 5 | * @Author LiABao 6 | * @Since 2022/2/4 7 | * 8 | */ 9 | interface ReportInitDelegate { 10 | 11 | fun getAppName(): String 12 | } -------------------------------------------------------------------------------- /sample-sdk/report-sdk-demo/src/test/java/com/kronos/startup/sample/report/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.startup.sample.report 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id('kotlin-android') 4 | id("com.google.devtools.ksp") 5 | } 6 | 7 | android { 8 | compileSdk = 32 9 | 10 | defaultConfig { 11 | applicationId "com.kronos.android.startup.sample" 12 | minSdkVersion 21 13 | targetSdkVersion 32 14 | versionCode 1 15 | versionName "1.0" 16 | 17 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 18 | } 19 | 20 | buildTypes { 21 | release { 22 | minifyEnabled false 23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 24 | } 25 | } 26 | compileOptions { 27 | sourceCompatibility JavaVersion.VERSION_11 28 | targetCompatibility JavaVersion.VERSION_11 29 | } 30 | kotlinOptions { 31 | jvmTarget = '1.8' 32 | } 33 | buildFeatures { 34 | viewBinding = true 35 | } 36 | } 37 | 38 | dependencies { 39 | 40 | implementation(project(":network-sdk-demo")) 41 | implementation(project(":report-sdk-demo")) 42 | 43 | implementation "io.insert-koin:koin-android:3.1.5" 44 | 45 | implementation 'androidx.core:core-ktx:1.6.0' 46 | implementation 'androidx.appcompat:appcompat:1.4.0' 47 | implementation 'com.google.android.material:material:1.4.0' 48 | implementation 'androidx.constraintlayout:constraintlayout:2.1.0' 49 | implementation("io.insert-koin:koin-android:3.1.5") 50 | /* implementation('com.github.kirich1409:viewbindingpropertydelegate-noreflection:1.5.2') { 51 | transitive = false 52 | }*/ 53 | implementation project(':startup') 54 | debugImplementation project(':startup-dag-view') 55 | implementation project(':startup-annotation') 56 | ksp project(":startup-ksp-compiler") 57 | testImplementation 'junit:junit:4.+' 58 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 59 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 60 | 61 | } -------------------------------------------------------------------------------- /sample/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /sample/src/androidTest/java/com/kronos/android/startup/sample/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.android.startup.sample 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.kronos.android.startup.sample", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 13 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/com/kronos/android/startup/sample/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.android.startup.sample 2 | 3 | import android.app.Activity 4 | import android.content.Context 5 | import android.content.Intent 6 | import android.os.Bundle 7 | import android.widget.TextView 8 | import androidx.appcompat.app.AppCompatActivity 9 | 10 | class MainActivity : AppCompatActivity() { 11 | 12 | override fun onCreate(savedInstanceState: Bundle?) { 13 | super.onCreate(savedInstanceState) 14 | setContentView(R.layout.activity_main) 15 | val textView = findViewById(R.id.textView) 16 | textView.text = "MainActivity" 17 | textView.postDelayed({ 18 | startWebActivity() 19 | }, 1000) 20 | } 21 | } 22 | 23 | 24 | fun Context.startWebActivity() { 25 | val intent = Intent(this, WebActivity::class.java) 26 | if (this !is Activity) { 27 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) 28 | } 29 | startActivity(intent) 30 | } 31 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/com/kronos/android/startup/sample/SampleApplication.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.android.startup.sample 2 | 3 | import android.app.Application 4 | import android.content.Context 5 | import com.kronos.android.startup.sample.di.appModule 6 | import com.kronos.android.startup.sample.task.createStartup 7 | import com.kronos.lib.startup.StartupConfig 8 | import com.kronos.lib.startup.startUp 9 | import com.kronos.lib.startup.step.ApplicationStepBuilder 10 | import com.kronos.lib.startup.step.NetworkSdkDemoStepBuilder 11 | import com.kronos.lib.startup.step.ReportSdkDemoStepBuilder 12 | import com.kronos.lib.startup.step.StepStartupPack 13 | import com.kronos.startup.annotation.Lifecycle 14 | import org.koin.core.context.startKoin 15 | 16 | /** 17 | * 18 | * @Author LiABao 19 | * @Since 2021/11/26 20 | * 21 | */ 22 | class SampleApplication : Application() { 23 | 24 | override fun attachBaseContext(base: Context?) { 25 | super.attachBaseContext(base) 26 | startKoin { 27 | modules(listOf(appModule)) 28 | } 29 | StepStartupPack.onApplicationAttach { 30 | add(ApplicationStepBuilder()) 31 | add(NetworkSdkDemoStepBuilder()) 32 | add(ReportSdkDemoStepBuilder()) 33 | } 34 | startUp(this) { 35 | StepStartupPack.getTaskGroup(Lifecycle.AttachApplication)?.forEach { 36 | addProcTaskGroup(it) 37 | } 38 | } 39 | } 40 | 41 | override fun onCreate() { 42 | super.onCreate() 43 | StartupConfig.debugMode = true 44 | createStartup().apply { 45 | StepStartupPack.getTaskGroup(Lifecycle.OnApplicationCrate)?.forEach { 46 | addProcTaskGroup(it) 47 | } 48 | }.build().start() 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/com/kronos/android/startup/sample/SampleTaskNameProvider.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.android.startup.sample 2 | 3 | import com.kronos.startup.TaskNameProvider 4 | 5 | /** 6 | * 7 | * @Author LiABao 8 | * @Since 2021/12/31 9 | * 10 | */ 11 | sealed class SampleTaskNameProvider : TaskNameProvider 12 | 13 | object AsyncTask1Provider : SampleTaskNameProvider() 14 | 15 | object SimpleTask1Provider : SampleTaskNameProvider() 16 | 17 | object SimpleTask2Provider : SampleTaskNameProvider() 18 | 19 | object SimpleTask3Provider : SampleTaskNameProvider() 20 | 21 | object MyAnchorTaskProvider : SampleTaskNameProvider() 22 | 23 | 24 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/com/kronos/android/startup/sample/WebActivity.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.android.startup.sample 2 | 3 | import android.os.Bundle 4 | import android.widget.TextView 5 | import androidx.appcompat.app.AppCompatActivity 6 | import com.kronos.lib.startup.startUp 7 | import com.kronos.lib.startup.step.StepStartupPack 8 | import com.kronos.startup.annotation.Lifecycle 9 | 10 | /** 11 | * 12 | * @Author LiABao 13 | * @Since 2021/12/9 14 | * 15 | */ 16 | class WebActivity : AppCompatActivity() { 17 | override fun onCreate(savedInstanceState: Bundle?) { 18 | super.onCreate(savedInstanceState) 19 | setContentView(R.layout.activity_main) 20 | findViewById(R.id.textView).text = "WebActivity" 21 | startUp(this.application) { 22 | StepStartupPack.getTaskGroup(Lifecycle.AfterUserPrivacy)?.forEach { 23 | addProcTaskGroup(it) 24 | } 25 | }.build().start() 26 | } 27 | } -------------------------------------------------------------------------------- /sample/src/main/kotlin/com/kronos/android/startup/sample/di/AppModule.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.android.startup.sample.di 2 | 3 | import com.kronos.startup.sample.report.di.ReportInitDelegate 4 | import org.koin.dsl.module 5 | 6 | /** 7 | * 8 | * @Author LiABao 9 | * @Since 2022/2/4 10 | * 11 | */ 12 | val appModule = module { 13 | single { 14 | ReportInitDelegateImp() 15 | } 16 | } 17 | 18 | private class ReportInitDelegateImp : ReportInitDelegate { 19 | override fun getAppName(): String { 20 | return "123444556" 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /sample/src/main/kotlin/com/kronos/android/startup/sample/task/MyAnchorTask.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.android.startup.sample.task 2 | 3 | import android.content.Context 4 | import com.kronos.android.startup.sample.AsyncTask1Provider 5 | import com.kronos.android.startup.sample.MyAnchorTaskProvider 6 | import com.kronos.lib.startup.SimpleStartupTask 7 | import com.kronos.startup.TaskNameProvider 8 | 9 | /** 10 | * 11 | * @Author LiABao 12 | * @Since 2021/11/26 13 | * 14 | */ 15 | class MyAnchorTask : SimpleStartupTask() { 16 | override val taskNameProvider: TaskNameProvider 17 | get() = MyAnchorTaskProvider 18 | 19 | override fun run(context: Context) { 20 | info("MyAnchorTask") 21 | } 22 | 23 | init { 24 | dependOn(AsyncTask1Provider) 25 | } 26 | } -------------------------------------------------------------------------------- /sample/src/main/kotlin/com/kronos/android/startup/sample/task/TaskBuilder.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.android.startup.sample.task 2 | 3 | import android.app.Application 4 | import android.util.Log 5 | import com.kronos.lib.startup.* 6 | import java.lang.Thread.sleep 7 | 8 | /** 9 | * 10 | * @Author LiABao 11 | * @Since 2021/11/26 12 | * 13 | */ 14 | fun Application.createStartup(): Startup.Builder = run { 15 | startUp(this) { 16 | addTask { 17 | simpleTask("taskA") { 18 | info("taskA") 19 | } 20 | } 21 | addTask { 22 | simpleTask("taskB") { 23 | info("taskB") 24 | } 25 | } 26 | addTask { 27 | simpleTask("taskC") { 28 | info("taskC") 29 | } 30 | } 31 | addTask { 32 | simpleTaskBuilder("taskD") { 33 | info("taskD") 34 | }.apply { 35 | dependOn("taskC") 36 | }.build() 37 | } 38 | buildAnchorTask { 39 | MyAnchorTask() 40 | } 41 | addTask { 42 | asyncTask("asyncTaskA", { 43 | info("asyncTaskA") 44 | }, { 45 | dependOn("asyncTaskD") 46 | }) 47 | } 48 | mustAfterAnchor { 49 | asyncTask("asyncTaskB", { 50 | info("asyncTaskB") 51 | }, { 52 | dependOn("asyncTaskA") 53 | await = true 54 | }) 55 | } 56 | mustAfterAnchor { 57 | asyncTaskBuilder("asyncTaskC") { 58 | info("asyncTaskC") 59 | sleep(1000) 60 | }.apply { 61 | await = true 62 | dependOn("asyncTaskE") 63 | }.build() 64 | } 65 | mustAfterAnchor { 66 | asyncTask("asyncTaskD") { 67 | info("asyncTaskD") 68 | sleep(1000) 69 | } 70 | } 71 | mustAfterAnchor { 72 | asyncTask("asyncTaskE") { 73 | info("asyncTaskE") 74 | sleep(10000) 75 | } 76 | } 77 | addTaskGroup { taskGroup() } 78 | } 79 | } 80 | 81 | // 启动任务组 82 | fun taskGroup(): StartupTaskGroup { 83 | return startupTaskGroup { 84 | add(simpleTask("group_1") { 85 | info("group_1") 86 | }) 87 | add(simpleTask("group_2") { 88 | info("group_2") 89 | }) 90 | } 91 | } 92 | 93 | fun info(info: String) { 94 | val threadName = Thread.currentThread().name 95 | Log.i(TAG, "[threadName:$threadName] $info") 96 | } 97 | 98 | const val TAG = "START-DSL—TEST" -------------------------------------------------------------------------------- /sample/src/main/kotlin/com/kronos/android/startup/sample/task/generate/SampleGenerate1Task.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.android.startup.sample.task.generate 2 | 3 | import android.content.Context 4 | import com.kronos.android.startup.sample.AsyncTask1Provider 5 | import com.kronos.android.startup.sample.SimpleTask2Provider 6 | import com.kronos.android.startup.sample.task.info 7 | import com.kronos.lib.startup.TaskRunner 8 | import com.kronos.startup.annotation.Lifecycle 9 | import com.kronos.startup.annotation.Process 10 | import com.kronos.startup.annotation.Step 11 | import com.kronos.startup.annotation.startup.Async 12 | import com.kronos.startup.annotation.startup.Await 13 | import com.kronos.startup.annotation.startup.DependOn 14 | import com.kronos.startup.annotation.startup.Startup 15 | 16 | /** 17 | * 18 | * @Author LiABao 19 | * @Since 2021/12/31 20 | * 21 | */ 22 | @Async 23 | @Await 24 | @DependOn( 25 | dependOn = [AsyncTask1Provider::class, SimpleTask2Provider::class], 26 | dependOnTag = ["taskB"] 27 | ) 28 | @Startup(strategy = Process.MAIN) 29 | @Step(Lifecycle.AttachApplication) 30 | class SampleGenerate1Task : TaskRunner { 31 | 32 | override fun run(context: Context) { 33 | info("MyAnchorTask") 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /sample/src/main/kotlin/com/kronos/android/startup/sample/task/generate/SampleGenerate2Task.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.android.startup.sample.task.generate 2 | 3 | import android.content.Context 4 | import com.kronos.android.startup.sample.task.info 5 | import com.kronos.lib.startup.SampleGenerate1TaskProvider 6 | import com.kronos.lib.startup.TaskRunner 7 | import com.kronos.startup.annotation.Process 8 | import com.kronos.startup.annotation.startup.DependOn 9 | import com.kronos.startup.annotation.startup.MustAfter 10 | import com.kronos.startup.annotation.startup.Startup 11 | 12 | /** 13 | * 14 | * @Author LiABao 15 | * @Since 2022/1/12 16 | * 17 | */ 18 | @DependOn( 19 | dependOn = [SampleGenerate1TaskProvider::class] 20 | ) 21 | @Startup(strategy = Process.OTHER, processName = ["web"]) 22 | @MustAfter 23 | class SampleGenerate2Task : TaskRunner { 24 | 25 | override fun run(context: Context) { 26 | info("SampleGenerate2Task") 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /sample/src/main/kotlin/com/kronos/android/startup/sample/task/generate/SimplePrivacyGenerateTask.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.android.startup.sample.task.generate 2 | 3 | import android.content.Context 4 | import com.kronos.android.startup.sample.task.info 5 | import com.kronos.android.startup.sample.task.utils.toast 6 | import com.kronos.lib.startup.TaskRunner 7 | import com.kronos.startup.annotation.Lifecycle 8 | import com.kronos.startup.annotation.Step 9 | import com.kronos.startup.annotation.startup.Startup 10 | 11 | /** 12 | * 13 | * @Author LiABao 14 | * @Since 2022/1/25 15 | * 16 | */ 17 | @Startup 18 | @Step(Lifecycle.AfterUserPrivacy) 19 | class SimplePrivacyGenerateTask : TaskRunner { 20 | 21 | override fun run(context: Context) { 22 | info("SimplePrivacyGenerateTask") 23 | "完成用户隐私协议".toast(context) 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /sample/src/main/kotlin/com/kronos/android/startup/sample/task/ksp/AsyncTask1.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.android.startup.sample.task.ksp 2 | 3 | import android.content.Context 4 | import com.kronos.android.startup.sample.AsyncTask1Provider 5 | import com.kronos.android.startup.sample.task.info 6 | import com.kronos.lib.startup.SimpleStartupTask 7 | import com.kronos.startup.TaskNameProvider 8 | import com.kronos.startup.annotation.Lifecycle 9 | import com.kronos.startup.annotation.Step 10 | import com.kronos.startup.annotation.StartupGroup 11 | 12 | /** 13 | * 14 | * @Author LiABao 15 | * @Since 2021/11/26 16 | * 17 | */ 18 | @StartupGroup 19 | @Step(Lifecycle.AfterUserPrivacy) 20 | class AsyncTask1 : SimpleStartupTask() { 21 | 22 | override fun mainThread(): Boolean { 23 | return false 24 | } 25 | 26 | override fun await(): Boolean { 27 | return true 28 | } 29 | 30 | override fun run(context: Context) { 31 | info("AsyncTask1") 32 | } 33 | 34 | override val taskNameProvider: TaskNameProvider 35 | get() = AsyncTask1Provider 36 | } -------------------------------------------------------------------------------- /sample/src/main/kotlin/com/kronos/android/startup/sample/task/ksp/SimpleTask1.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.android.startup.sample.task.ksp 2 | 3 | import android.content.Context 4 | import com.kronos.android.startup.sample.SimpleTask1Provider 5 | import com.kronos.android.startup.sample.task.info 6 | import com.kronos.lib.startup.SimpleStartupTask 7 | import com.kronos.startup.TaskNameProvider 8 | import com.kronos.startup.annotation.StartupGroup 9 | 10 | /** 11 | * 12 | * @Author LiABao 13 | * @Since 2021/11/26 14 | * 15 | */ 16 | @StartupGroup 17 | class SimpleTask1 : SimpleStartupTask() { 18 | override val taskNameProvider: TaskNameProvider 19 | get() = SimpleTask1Provider 20 | 21 | override fun run(context: Context) { 22 | info("AsyncTask1") 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /sample/src/main/kotlin/com/kronos/android/startup/sample/task/ksp/SimpleTask2.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.android.startup.sample.task.ksp 2 | 3 | import android.content.Context 4 | import com.kronos.android.startup.sample.SimpleTask2Provider 5 | import com.kronos.android.startup.sample.task.info 6 | import com.kronos.lib.startup.SimpleStartupTask 7 | import com.kronos.startup.TaskNameProvider 8 | import com.kronos.startup.annotation.Process 9 | import com.kronos.startup.annotation.StartupGroup 10 | import com.kronos.startup.annotation.startup.MustAfter 11 | 12 | /** 13 | * 14 | * @Author LiABao 15 | * @Since 2021/12/9 16 | * 17 | */ 18 | @StartupGroup(strategy = Process.MAIN) 19 | @MustAfter 20 | class SimpleTask2 : SimpleStartupTask() { 21 | 22 | override val taskNameProvider: TaskNameProvider 23 | get() = SimpleTask2Provider 24 | 25 | override fun run(context: Context) { 26 | info("SimpleTask2") 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /sample/src/main/kotlin/com/kronos/android/startup/sample/task/ksp/SimpleTask3.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.android.startup.sample.task.ksp 2 | 3 | import android.content.Context 4 | import com.kronos.android.startup.sample.SimpleTask3Provider 5 | import com.kronos.android.startup.sample.task.info 6 | import com.kronos.lib.startup.SimpleStartupTask 7 | import com.kronos.startup.TaskNameProvider 8 | import com.kronos.startup.annotation.Process 9 | import com.kronos.startup.annotation.StartupGroup 10 | 11 | /** 12 | * 13 | * @Author LiABao 14 | * @Since 2021/12/9 15 | * 16 | */ 17 | @StartupGroup(strategy = Process.OTHER, processName = ["web"]) 18 | class SimpleTask3 : SimpleStartupTask() { 19 | override val taskNameProvider: TaskNameProvider 20 | get() = SimpleTask3Provider 21 | 22 | override fun run(context: Context) { 23 | info("SimpleTask3") 24 | } 25 | } -------------------------------------------------------------------------------- /sample/src/main/kotlin/com/kronos/android/startup/sample/task/utils/ToastHelper.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.android.startup.sample.task.utils 2 | 3 | import android.content.Context 4 | import android.widget.Toast 5 | 6 | /** 7 | * 8 | * @Author LiABao 9 | * @Since 2022/1/25 10 | * 11 | */ 12 | 13 | fun String.toast(context: Context) { 14 | Toast.makeText(context, this, Toast.LENGTH_SHORT).show() 15 | } -------------------------------------------------------------------------------- /sample/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 18 | 19 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Leifzhang/AndroidStartup/883e2be9c1c6b19714fa74c803bd517fad081944/sample/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Leifzhang/AndroidStartup/883e2be9c1c6b19714fa74c803bd517fad081944/sample/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Leifzhang/AndroidStartup/883e2be9c1c6b19714fa74c803bd517fad081944/sample/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Leifzhang/AndroidStartup/883e2be9c1c6b19714fa74c803bd517fad081944/sample/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Leifzhang/AndroidStartup/883e2be9c1c6b19714fa74c803bd517fad081944/sample/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Leifzhang/AndroidStartup/883e2be9c1c6b19714fa74c803bd517fad081944/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Leifzhang/AndroidStartup/883e2be9c1c6b19714fa74c803bd517fad081944/sample/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Leifzhang/AndroidStartup/883e2be9c1c6b19714fa74c803bd517fad081944/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Leifzhang/AndroidStartup/883e2be9c1c6b19714fa74c803bd517fad081944/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Leifzhang/AndroidStartup/883e2be9c1c6b19714fa74c803bd517fad081944/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /sample/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /sample/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | sample 3 | 4 | true 5 | -------------------------------------------------------------------------------- /sample/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /sample/src/test/java/com/kronos/android/startup/sample/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.android.startup.sample 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | 3 | repositories { 4 | google() 5 | maven { setUrl("https://maven.aliyun.com/repository/central/") } 6 | gradlePluginPortal() 7 | maven { setUrl("https://dl.bintray.com/kotlin/kotlin-eap") } 8 | } 9 | 10 | plugins { 11 | id("com.google.devtools.ksp") version ("1.5.30-1.0.0") apply (false) 12 | 13 | } 14 | } 15 | 16 | include(":startup") 17 | include(":sample") 18 | include(":startup-annotation") 19 | include(":startup-ksp-compiler") 20 | include(":startup-dag-view") 21 | 22 | 23 | include(":network-sdk-demo") 24 | project(":network-sdk-demo").projectDir = file("./sample-sdk/network-sdk-demo") 25 | include(":report-sdk-demo") 26 | project(":report-sdk-demo").projectDir = file("./sample-sdk/report-sdk-demo") 27 | -------------------------------------------------------------------------------- /startup-annotation/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /startup-annotation/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java-library' 3 | id 'kotlin' 4 | id("maven-publish") 5 | } 6 | -------------------------------------------------------------------------------- /startup-annotation/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /startup-annotation/src/main/kotlin/com/kronos/startup/TaskNameProvider.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.startup 2 | 3 | /** 4 | * 5 | * @Author LiABao 6 | * @Since 2021/12/31 7 | * 8 | */ 9 | 10 | interface TaskNameProvider 11 | 12 | -------------------------------------------------------------------------------- /startup-annotation/src/main/kotlin/com/kronos/startup/annotation/Lifecycle.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.startup.annotation 2 | 3 | /** 4 | * 5 | * @Author LiABao 6 | * @Since 2022/1/19 7 | * 8 | */ 9 | enum class Lifecycle(val value: String) { 10 | AttachApplication("AttachApplication"), OnApplicationCrate("OnApplicationCrate"), 11 | AfterUserPrivacy("AfterUserPrivacy") 12 | } 13 | 14 | 15 | fun String?.nameToLifeCycle(): Lifecycle { 16 | if (this == null) { 17 | return Lifecycle.OnApplicationCrate 18 | } 19 | var lastIndex = lastIndexOf(".") + 1 20 | if (lastIndex <= 0) { 21 | lastIndex = 0 22 | } 23 | val value = when (substring(lastIndex)) { 24 | "AttachApplication" -> { 25 | Lifecycle.AttachApplication 26 | } 27 | "OnApplicationCrate" -> { 28 | Lifecycle.OnApplicationCrate 29 | } 30 | "AfterUserPrivacy" -> { 31 | Lifecycle.AfterUserPrivacy 32 | } 33 | else -> { 34 | Lifecycle.OnApplicationCrate 35 | } 36 | } 37 | return value 38 | } 39 | -------------------------------------------------------------------------------- /startup-annotation/src/main/kotlin/com/kronos/startup/annotation/Process.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.startup.annotation 2 | 3 | /** 4 | * 5 | * @Author LiABao 6 | * @Since 2021/12/8 7 | * 8 | */ 9 | enum class Process(val value: Int) { 10 | ALL(0), MAIN(1), OTHER(2) 11 | } -------------------------------------------------------------------------------- /startup-annotation/src/main/kotlin/com/kronos/startup/annotation/StartupGroup.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.startup.annotation 2 | 3 | 4 | @Target( 5 | AnnotationTarget.ANNOTATION_CLASS, 6 | AnnotationTarget.CLASS 7 | ) 8 | @Retention 9 | annotation class StartupGroup( 10 | val strategy: Process = Process.ALL, 11 | val processName: Array = [] 12 | ) -------------------------------------------------------------------------------- /startup-annotation/src/main/kotlin/com/kronos/startup/annotation/Step.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.startup.annotation 2 | 3 | /** 4 | * @Author LiABao 5 | * @Since 2022/1/19 6 | */ 7 | @Target( 8 | AnnotationTarget.ANNOTATION_CLASS, 9 | AnnotationTarget.CLASS 10 | ) 11 | @Retention 12 | annotation class Step(val lifecycle: Lifecycle = Lifecycle.OnApplicationCrate) -------------------------------------------------------------------------------- /startup-annotation/src/main/kotlin/com/kronos/startup/annotation/startup/Async.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.startup.annotation.startup 2 | 3 | /** 4 | * 5 | * @Author LiABao 6 | * @Since 2022/1/11 7 | * 8 | */ 9 | @Target( 10 | AnnotationTarget.ANNOTATION_CLASS, 11 | AnnotationTarget.CLASS 12 | ) 13 | @Retention 14 | annotation class Async 15 | -------------------------------------------------------------------------------- /startup-annotation/src/main/kotlin/com/kronos/startup/annotation/startup/Await.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.startup.annotation.startup 2 | 3 | /** 4 | * 5 | * @Author LiABao 6 | * @Since 2022/1/11 7 | * 8 | */ 9 | @Target( 10 | AnnotationTarget.ANNOTATION_CLASS, 11 | AnnotationTarget.CLASS 12 | ) 13 | @Retention 14 | annotation class Await 15 | -------------------------------------------------------------------------------- /startup-annotation/src/main/kotlin/com/kronos/startup/annotation/startup/DependOn.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.startup.annotation.startup 2 | 3 | import com.kronos.startup.TaskNameProvider 4 | import kotlin.reflect.KClass 5 | 6 | /** 7 | * 8 | * @Author LiABao 9 | * @Since 2022/1/12 10 | * 11 | */ 12 | 13 | @Target( 14 | AnnotationTarget.ANNOTATION_CLASS, 15 | AnnotationTarget.CLASS 16 | ) 17 | @Retention 18 | annotation class DependOn( 19 | val dependOn: Array>, 20 | val dependOnTag: Array = [] 21 | ) -------------------------------------------------------------------------------- /startup-annotation/src/main/kotlin/com/kronos/startup/annotation/startup/MustAfter.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.startup.annotation.startup 2 | 3 | /** 4 | * 5 | * @Author LiABao 6 | * @Since 2022/1/13 7 | * 8 | */ 9 | @Target( 10 | AnnotationTarget.ANNOTATION_CLASS, 11 | AnnotationTarget.CLASS 12 | ) 13 | @Retention 14 | annotation class MustAfter -------------------------------------------------------------------------------- /startup-annotation/src/main/kotlin/com/kronos/startup/annotation/startup/Startup.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.startup.annotation.startup 2 | 3 | import com.kronos.startup.annotation.Process 4 | 5 | /** 6 | * 7 | * @Author LiABao 8 | * @Since 2021/12/31 9 | * 10 | */ 11 | @Target( 12 | AnnotationTarget.ANNOTATION_CLASS, 13 | AnnotationTarget.CLASS 14 | ) 15 | @Retention 16 | annotation class Startup( 17 | val strategy: Process = Process.ALL, 18 | val processName: Array = [] 19 | ) 20 | 21 | -------------------------------------------------------------------------------- /startup-dag-view/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /startup-dag-view/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | id 'kotlin-android' 4 | id 'kotlin-kapt' 5 | id("maven-publish") 6 | } 7 | 8 | android { 9 | compileSdk 32 10 | 11 | defaultConfig { 12 | minSdk 21 13 | targetSdk 32 14 | 15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 16 | consumerProguardFiles "consumer-rules.pro" 17 | } 18 | 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | compileOptions { 26 | sourceCompatibility JavaVersion.VERSION_11 27 | targetCompatibility JavaVersion.VERSION_11 28 | } 29 | kotlinOptions { 30 | jvmTarget = '1.8' 31 | } 32 | } 33 | 34 | dependencies { 35 | implementation 'androidx.core:core-ktx:1.6.0' 36 | implementation 'androidx.appcompat:appcompat:1.3.1' 37 | implementation("androidx.recyclerview:recyclerview:1.2.1") 38 | testImplementation 'junit:junit:4.+' 39 | implementation project(':startup') 40 | def roomVersion = "2.2.5" 41 | implementation "androidx.room:room-ktx:$roomVersion" 42 | kapt "androidx.room:room-compiler:$roomVersion" 43 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 44 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 45 | } -------------------------------------------------------------------------------- /startup-dag-view/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Leifzhang/AndroidStartup/883e2be9c1c6b19714fa74c803bd517fad081944/startup-dag-view/consumer-rules.pro -------------------------------------------------------------------------------- /startup-dag-view/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /startup-dag-view/src/androidTest/java/com/kronos/startup/dag/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.startup.dag 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.kronos.startup.dag.test", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /startup-dag-view/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 16 | 17 | -------------------------------------------------------------------------------- /startup-dag-view/src/main/java/com/kronos/startup/dag/DividerItemDecoration.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.startup.dag 2 | 3 | import android.graphics.Canvas 4 | import android.graphics.Rect 5 | import android.graphics.drawable.ColorDrawable 6 | import android.graphics.drawable.Drawable 7 | import android.view.View 8 | import android.widget.LinearLayout 9 | import androidx.annotation.ColorInt 10 | import androidx.recyclerview.widget.RecyclerView 11 | import kotlin.math.roundToInt 12 | 13 | /** 14 | * @Author LiABao 15 | * @Since 2021/1/14 16 | */ 17 | class DividerItemDecoration @JvmOverloads constructor(orientation: Int = LinearLayout.VERTICAL) : RecyclerView.ItemDecoration() { 18 | /** 19 | * @return the [Drawable] for this divider. 20 | */ 21 | var drawable: Drawable? = null 22 | private set 23 | private var isHiddenBottom = true 24 | 25 | fun setHiddenBottom(hiddenBottom: Boolean) { 26 | isHiddenBottom = hiddenBottom 27 | } 28 | 29 | /** 30 | * Current orientation. Either [.HORIZONTAL] or [.VERTICAL]. 31 | */ 32 | private var mOrientation = 0 33 | private val mBounds = Rect() 34 | private var mDividerHeight = 1 35 | 36 | /** 37 | * Sets the orientation for this divider. This should be called if 38 | * [RecyclerView.LayoutManager] changes orientation. 39 | * 40 | * @param orientation [.HORIZONTAL] or [.VERTICAL] 41 | */ 42 | fun setOrientation(orientation: Int) { 43 | require(!(orientation != HORIZONTAL && orientation != VERTICAL)) { "Invalid orientation. It should be either HORIZONTAL or VERTICAL" } 44 | mOrientation = orientation 45 | } 46 | 47 | /** 48 | * Sets the [Drawable] for this divider. 49 | * 50 | * @param drawable Drawable that should be used as a divider. 51 | */ 52 | fun setDrawable(drawable: Drawable) { 53 | requireNotNull(drawable) { "Drawable cannot be null." } 54 | this.drawable = drawable 55 | } 56 | 57 | fun setColorDrawable(@ColorInt color: Int, height: Int) { 58 | drawable = ColorDrawable(color) 59 | drawable?.setBounds(0, 0, 0, height) 60 | mDividerHeight = height 61 | } 62 | 63 | override fun onDraw(c: Canvas, parent: RecyclerView, state: RecyclerView.State) { 64 | if (parent.layoutManager == null || drawable == null) { 65 | return 66 | } 67 | if (mOrientation == VERTICAL) { 68 | drawVertical(c, parent, state) 69 | } else { 70 | drawHorizontal(c, parent, state) 71 | } 72 | } 73 | 74 | private fun drawVertical(canvas: Canvas, parent: RecyclerView, state: RecyclerView.State) { 75 | canvas.save() 76 | val left: Int 77 | val right: Int 78 | if (parent.clipToPadding) { 79 | left = parent.paddingLeft 80 | right = parent.width - parent.paddingRight 81 | canvas.clipRect(left, parent.paddingTop, right, 82 | parent.height - parent.paddingBottom) 83 | } else { 84 | left = 0 85 | right = parent.width 86 | } 87 | val childCount = parent.childCount 88 | val lastPosition = state.itemCount - 1 89 | for (i in 0 until childCount) { 90 | val child = parent.getChildAt(i) 91 | val childRealPosition = parent.getChildAdapterPosition(child) 92 | if (childRealPosition < lastPosition || !isHiddenBottom) { 93 | parent.getDecoratedBoundsWithMargins(child, mBounds) 94 | val bottom = mBounds.bottom + child.translationY.roundToInt() 95 | val top = bottom - mDividerHeight 96 | drawable?.setBounds(left, top, right, bottom) 97 | drawable?.draw(canvas) 98 | } 99 | } 100 | canvas.restore() 101 | } 102 | 103 | private fun drawHorizontal(canvas: Canvas, parent: RecyclerView, state: RecyclerView.State) { 104 | canvas.save() 105 | val top: Int 106 | val bottom: Int 107 | if (parent.clipToPadding) { 108 | top = parent.paddingTop 109 | bottom = parent.height - parent.paddingBottom 110 | canvas.clipRect(parent.paddingLeft, top, 111 | parent.width - parent.paddingRight, bottom) 112 | } else { 113 | top = 0 114 | bottom = parent.height 115 | } 116 | val childCount = parent.childCount 117 | val lastPosition = state.itemCount - 1 118 | for (i in 0 until childCount) { 119 | val child = parent.getChildAt(i) 120 | val childRealPosition = parent.getChildAdapterPosition(child) 121 | if (childRealPosition < lastPosition || !isHiddenBottom) { 122 | parent.layoutManager?.getDecoratedBoundsWithMargins(child, mBounds) 123 | val right = mBounds.right + child.translationX.roundToInt() 124 | val left = right - mDividerHeight 125 | drawable?.setBounds(left, top, right, bottom) 126 | drawable?.draw(canvas) 127 | } 128 | } 129 | canvas.restore() 130 | } 131 | 132 | override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, 133 | state: RecyclerView.State) { 134 | if (drawable == null) { 135 | outRect[0, 0, 0] = 0 136 | return 137 | } 138 | if (mOrientation == VERTICAL) { 139 | outRect[0, 0, 0] = mDividerHeight 140 | } else { 141 | outRect[0, 0, mDividerHeight] = 0 142 | } 143 | } 144 | 145 | companion object { 146 | const val HORIZONTAL = LinearLayout.HORIZONTAL 147 | const val VERTICAL = LinearLayout.VERTICAL 148 | } 149 | 150 | /** 151 | * Creates a divider [RecyclerView.ItemDecoration] that can be used with a 152 | * [LinearLayoutManager]. 153 | * 154 | * @param orientation Divider orientation. Should be [.HORIZONTAL] or [.VERTICAL]. 155 | */ 156 | init { 157 | setOrientation(orientation) 158 | } 159 | } -------------------------------------------------------------------------------- /startup-dag-view/src/main/java/com/kronos/startup/dag/StartupDagInstallProvider.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.startup.dag 2 | 3 | import android.content.ContentProvider 4 | import android.content.ContentValues 5 | import android.database.Cursor 6 | import android.net.Uri 7 | import com.kronos.lib.startup.StartupConfig 8 | import com.kronos.lib.startup.data.StartupTaskData 9 | import com.kronos.startup.dag.sql.StartupDatabaseHelper 10 | import com.kronos.startup.dag.sql.getPath 11 | import com.kronos.startup.dag.sql.onTaskAdd 12 | import com.kronos.startup.dag.sql.transform 13 | import com.kronos.startup.dag.utils.getDateFormat 14 | import com.kronos.startup.dag.utils.getVersionCode 15 | import com.kronos.startup.dag.utils.postUI 16 | import kotlin.concurrent.thread 17 | 18 | /** 19 | * 20 | * @Author LiABao 21 | * @Since 2021/11/29 22 | * 23 | */ 24 | class StartupDagInstallProvider : ContentProvider() { 25 | 26 | override fun onCreate(): Boolean { 27 | context?.let { StartupDatabaseHelper.init(it) } 28 | versionCode = context.getVersionCode() 29 | StartupConfig.onStartupFinishedListener = { 30 | thread { 31 | val dao = StartupDatabaseHelper.databaseInstance.startupDao() 32 | var data = dao.getStartupPathInfo(formatKey) 33 | if (data == null) { 34 | data = this.transform(formatKey) 35 | dao.insertInfo(data) 36 | } else { 37 | val path = getPath() 38 | data.dagPath?.addAll(path) 39 | data.updateHashCode() 40 | dao.updateInfo(data) 41 | } 42 | startupList.addAll(this) 43 | this.onTaskAdd() 44 | postUI { 45 | context?.startDagMainActivity() 46 | } 47 | } 48 | } 49 | return true 50 | } 51 | 52 | override fun query( 53 | uri: Uri, 54 | projection: Array?, 55 | selection: String?, 56 | selectionArgs: Array?, 57 | sortOrder: String? 58 | ): Cursor? { 59 | return null 60 | } 61 | 62 | override fun getType(uri: Uri): String? { 63 | return null 64 | } 65 | 66 | override fun insert(uri: Uri, values: ContentValues?): Uri? { 67 | return null 68 | } 69 | 70 | override fun delete(uri: Uri, selection: String?, selectionArgs: Array?): Int { 71 | return 0 72 | } 73 | 74 | override fun update( 75 | uri: Uri, 76 | values: ContentValues?, 77 | selection: String?, 78 | selectionArgs: Array? 79 | ): Int { 80 | return 0 81 | } 82 | 83 | companion object { 84 | val formatKey by lazy { getDateFormat() } 85 | var versionCode = 0L 86 | internal val startupList = mutableListOf() 87 | } 88 | } -------------------------------------------------------------------------------- /startup-dag-view/src/main/java/com/kronos/startup/dag/StartupDagPathActivity.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.startup.dag 2 | 3 | import android.app.Activity 4 | import android.content.Context 5 | import android.content.Intent 6 | import android.os.Bundle 7 | import android.widget.TextView 8 | import androidx.appcompat.app.AppCompatActivity 9 | import com.kronos.startup.dag.sql.StartupDatabaseHelper 10 | import com.kronos.startup.dag.sql.StartupPathDataInfo 11 | import com.kronos.startup.dag.utils.getSimpleName 12 | import com.kronos.startup.dag.utils.postUI 13 | import kotlin.concurrent.thread 14 | 15 | /** 16 | * 17 | * @Author LiABao 18 | * @Since 2021/12/30 19 | * 20 | */ 21 | class StartupDagPathActivity : AppCompatActivity(R.layout.startup_activity_dag_path) { 22 | private lateinit var textView: TextView 23 | private lateinit var lastDagView: TextView 24 | 25 | override fun onCreate(savedInstanceState: Bundle?) { 26 | super.onCreate(savedInstanceState) 27 | textView = findViewById(R.id.currentDag) 28 | lastDagView = findViewById(R.id.lastDag) 29 | thread { 30 | val dao = StartupDatabaseHelper.databaseInstance.startupDao() 31 | val data = dao.getStartupPathInfo(StartupDagInstallProvider.formatKey) 32 | data?.apply { 33 | val oldDag = dao.selectNotSame(pathHashCode) 34 | postUI { 35 | lastDagView.text = oldDag?.dagPath.text() 36 | textView.text = this.dagPath.text() 37 | } 38 | } 39 | } 40 | 41 | } 42 | } 43 | 44 | 45 | fun Context.startDagPathActivity() { 46 | val intent = Intent(this, StartupDagPathActivity::class.java) 47 | if (this !is Activity) { 48 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) 49 | } 50 | startActivity(intent) 51 | } 52 | 53 | fun MutableList?.text(): String { 54 | val stringBuilder = StringBuilder() 55 | this?.forEach { 56 | stringBuilder.append("threadName:${it.name?.getSimpleName()} isMain:${it.mainThread}") 57 | .append("\r\n") 58 | } 59 | return stringBuilder.toString() 60 | } -------------------------------------------------------------------------------- /startup-dag-view/src/main/java/com/kronos/startup/dag/StartupMainDebugActivity.kt: -------------------------------------------------------------------------------- 1 | package com.kronos.startup.dag 2 | 3 | import android.app.Activity 4 | import android.content.Context 5 | import android.content.Intent 6 | import android.os.Bundle 7 | import android.widget.Button 8 | import androidx.appcompat.app.AppCompatActivity 9 | 10 | /** 11 | * 12 | * @Author LiABao 13 | * @Since 2021/12/31 14 | * 15 | */ 16 | class StartupMainDebugActivity : AppCompatActivity(R.layout.startup_activity_main_debug) { 17 | override fun onCreate(savedInstanceState: Bundle?) { 18 | super.onCreate(savedInstanceState) 19 | findViewById