From 24a319952310b3aedafe5ba09b351e86572c7098 Mon Sep 17 00:00:00 2001 From: "hui.zhao" Date: Thu, 23 Nov 2017 21:27:13 +0800 Subject: [PATCH] Init --- .idea/misc.xml | 102 +++++++++ .idea/modules.xml | 13 ++ .idea/runConfigurations.xml | 12 ++ android-godeye-monitor-no-op/.gitignore | 1 + android-godeye-monitor-no-op/build.gradle | 34 +++ .../proguard-rules.pro | 21 ++ .../godeye/ExampleInstrumentedTest.java | 26 +++ .../src/main/AndroidManifest.xml | 2 + .../src/main/res/values/strings.xml | 3 + .../cn/hikyson/godeye/ExampleUnitTest.java | 17 ++ android-godeye-monitor/.gitignore | 1 + android-godeye-monitor/build.gradle | 34 +++ android-godeye-monitor/proguard-rules.pro | 21 ++ .../godeye/ExampleInstrumentedTest.java | 26 +++ .../src/main/AndroidManifest.xml | 2 + .../cn/hikyson/godeye/monitor/Engine.java | 8 + .../java/cn/hikyson/godeye/monitor/Pipe.java | 8 + .../src/main/res/values/strings.xml | 3 + .../cn/hikyson/godeye/ExampleUnitTest.java | 17 ++ android-godeye-sample/.gitignore | 1 + android-godeye-sample/build.gradle | 29 +++ android-godeye-sample/proguard-rules.pro | 21 ++ .../godeye/ExampleInstrumentedTest.java | 26 +++ .../src/main/AndroidManifest.xml | 24 +++ .../android/godeye/sample/LeakActivity.java | 29 +++ .../android/godeye/sample/MainActivity.java | 199 ++++++++++++++++++ .../drawable-v24/ic_launcher_foreground.xml | 34 +++ .../res/drawable/ic_launcher_background.xml | 171 +++++++++++++++ .../src/main/res/layout/activity_leak.xml | 19 ++ .../src/main/res/layout/activity_main.xml | 99 +++++++++ .../res/mipmap-anydpi-v26/ic_launcher.xml | 5 + .../mipmap-anydpi-v26/ic_launcher_round.xml | 5 + .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3056 bytes .../res/mipmap-hdpi/ic_launcher_round.png | Bin 0 -> 5024 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2096 bytes .../res/mipmap-mdpi/ic_launcher_round.png | Bin 0 -> 2858 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4569 bytes .../res/mipmap-xhdpi/ic_launcher_round.png | Bin 0 -> 7098 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 6464 bytes .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin 0 -> 10676 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 9250 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 0 -> 15523 bytes .../src/main/res/values/colors.xml | 6 + .../src/main/res/values/strings.xml | 3 + .../src/main/res/values/styles.xml | 8 + .../android/godeye/ExampleUnitTest.java | 17 ++ android-godeye-toolbox/.gitignore | 1 + android-godeye-toolbox/README.md | 4 + android-godeye-toolbox/build.gradle | 34 +++ android-godeye-toolbox/proguard-rules.pro | 21 ++ .../ExampleInstrumentedTest.java | 26 +++ .../src/main/AndroidManifest.xml | 2 + .../src/main/res/values/strings.xml | 3 + .../ExampleUnitTest.java | 17 ++ android-godeye/.gitignore | 1 + android-godeye/build.gradle | 38 ++++ android-godeye/proguard-rules.pro | 21 ++ .../godeye/ExampleInstrumentedTest.java | 25 +++ android-godeye/src/main/AndroidManifest.xml | 17 ++ .../java/cn/hikyson/godeye/BlockEngine.java | 24 +++ .../java/cn/hikyson/godeye/CpuEngine.java | 32 +++ .../main/java/cn/hikyson/godeye/Engine2.java | 22 ++ .../main/java/cn/hikyson/godeye/GodEye.java | 21 ++ .../java/cn/hikyson/godeye/RequestEngine.java | 25 +++ .../cn/hikyson/godeye/internal/Consumer.java | 12 ++ .../cn/hikyson/godeye/internal/Install.java | 14 ++ .../cn/hikyson/godeye/internal/Interval.java | 8 + .../cn/hikyson/godeye/internal/Module.java | 23 ++ .../godeye/internal/ProduceableConsumer.java | 30 +++ .../cn/hikyson/godeye/internal/Producer.java | 9 + .../godeye/internal/SnapshotEngine.java | 10 + .../godeye/internal/engines/Enginee.java | 10 + .../internal/modules/battery/Battery.java | 55 +++++ .../internal/modules/battery/BatteryInfo.java | 105 +++++++++ .../godeye/internal/modules/cpu/Cpu.java | 68 ++++++ .../godeye/internal/modules/cpu/CpuInfo.java | 57 +++++ .../internal/modules/cpu/CpuSnapshot.java | 96 +++++++++ .../godeye/internal/modules/fps/Fps.java | 65 ++++++ .../godeye/internal/modules/fps/FpsInfo.java | 22 ++ .../modules/leakdetector/LeakDetector.java | 105 +++++++++ .../leakdetector/LeakOutputReceiver.java | 103 +++++++++ .../modules/leakdetector/LeakQueue.java | 152 +++++++++++++ .../godeye/internal/modules/memory/Heap.java | 35 +++ .../internal/modules/memory/HeapInfo.java | 19 ++ .../godeye/internal/modules/memory/Pss.java | 51 +++++ .../internal/modules/memory/PssInfo.java | 22 ++ .../godeye/internal/modules/memory/Ram.java | 87 ++++++++ .../internal/modules/memory/RamInfo.java | 25 +++ .../internal/modules/network/Network.java | 33 +++ .../modules/network/RequestBaseInfo.java | 28 +++ .../godeye/internal/modules/sm/BlockInfo.java | 45 ++++ .../godeye/internal/modules/sm/Sm.java | 98 +++++++++ .../modules/sm/core/AbstractSampler.java | 62 ++++++ .../modules/sm/core/BlockInterceptor.java | 31 +++ .../internal/modules/sm/core/CpuSampler.java | 195 +++++++++++++++++ .../modules/sm/core/HandlerThreadFactory.java | 42 ++++ .../modules/sm/core/LongBlockInfo.java | 81 +++++++ .../modules/sm/core/LooperMonitor.java | 84 ++++++++ .../internal/modules/sm/core/MemoryInfo.java | 29 +++ .../modules/sm/core/ShortBlockInfo.java | 19 ++ .../internal/modules/sm/core/SmConfig.java | 34 +++ .../internal/modules/sm/core/SmCore.java | 154 ++++++++++++++ .../modules/sm/core/StackSampler.java | 58 +++++ .../internal/modules/startup/Startup.java | 33 +++ .../internal/modules/startup/StartupInfo.java | 28 +++ .../internal/modules/traffic/Traffic.java | 49 +++++ .../internal/modules/traffic/TrafficInfo.java | 34 +++ .../modules/traffic/TrafficSnapshot.java | 33 +++ .../cn/hikyson/godeye/utils/DeviceUtils.java | 49 +++++ .../cn/hikyson/godeye/utils/FileUtil.java | 35 +++ .../java/cn/hikyson/godeye/utils/IoUtil.java | 24 +++ .../main/java/cn/hikyson/godeye/utils/L.java | 77 +++++++ .../cn/hikyson/godeye/utils/ProcessUtils.java | 74 +++++++ .../hikyson/godeye/utils/StacktraceUtil.java | 46 ++++ .../src/main/res/values/strings.xml | 3 + .../cn/hikyson/godeye/ExampleUnitTest.java | 17 ++ build.gradle | 32 +++ gradle.properties | 17 ++ gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 53636 bytes gradle/wrapper/gradle-wrapper.properties | 6 + gradlew | 160 ++++++++++++++ gradlew.bat | 90 ++++++++ settings.gradle | 1 + 123 files changed, 4365 insertions(+) create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/runConfigurations.xml create mode 100644 android-godeye-monitor-no-op/.gitignore create mode 100644 android-godeye-monitor-no-op/build.gradle create mode 100644 android-godeye-monitor-no-op/proguard-rules.pro create mode 100644 android-godeye-monitor-no-op/src/androidTest/java/cn/hikyson/godeye/ExampleInstrumentedTest.java create mode 100644 android-godeye-monitor-no-op/src/main/AndroidManifest.xml create mode 100644 android-godeye-monitor-no-op/src/main/res/values/strings.xml create mode 100644 android-godeye-monitor-no-op/src/test/java/cn/hikyson/godeye/ExampleUnitTest.java create mode 100644 android-godeye-monitor/.gitignore create mode 100644 android-godeye-monitor/build.gradle create mode 100644 android-godeye-monitor/proguard-rules.pro create mode 100644 android-godeye-monitor/src/androidTest/java/cn/hikyson/godeye/ExampleInstrumentedTest.java create mode 100644 android-godeye-monitor/src/main/AndroidManifest.xml create mode 100644 android-godeye-monitor/src/main/java/cn/hikyson/godeye/monitor/Engine.java create mode 100644 android-godeye-monitor/src/main/java/cn/hikyson/godeye/monitor/Pipe.java create mode 100644 android-godeye-monitor/src/main/res/values/strings.xml create mode 100644 android-godeye-monitor/src/test/java/cn/hikyson/godeye/ExampleUnitTest.java create mode 100644 android-godeye-sample/.gitignore create mode 100644 android-godeye-sample/build.gradle create mode 100644 android-godeye-sample/proguard-rules.pro create mode 100644 android-godeye-sample/src/androidTest/java/cn/hikyson/android/godeye/ExampleInstrumentedTest.java create mode 100644 android-godeye-sample/src/main/AndroidManifest.xml create mode 100644 android-godeye-sample/src/main/java/cn/hikyson/android/godeye/sample/LeakActivity.java create mode 100644 android-godeye-sample/src/main/java/cn/hikyson/android/godeye/sample/MainActivity.java create mode 100644 android-godeye-sample/src/main/res/drawable-v24/ic_launcher_foreground.xml create mode 100644 android-godeye-sample/src/main/res/drawable/ic_launcher_background.xml create mode 100644 android-godeye-sample/src/main/res/layout/activity_leak.xml create mode 100644 android-godeye-sample/src/main/res/layout/activity_main.xml create mode 100644 android-godeye-sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 android-godeye-sample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 android-godeye-sample/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 android-godeye-sample/src/main/res/mipmap-hdpi/ic_launcher_round.png create mode 100644 android-godeye-sample/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 android-godeye-sample/src/main/res/mipmap-mdpi/ic_launcher_round.png create mode 100644 android-godeye-sample/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 android-godeye-sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png create mode 100644 android-godeye-sample/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 android-godeye-sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png create mode 100644 android-godeye-sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 android-godeye-sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png create mode 100644 android-godeye-sample/src/main/res/values/colors.xml create mode 100644 android-godeye-sample/src/main/res/values/strings.xml create mode 100644 android-godeye-sample/src/main/res/values/styles.xml create mode 100644 android-godeye-sample/src/test/java/cn/hikyson/android/godeye/ExampleUnitTest.java create mode 100644 android-godeye-toolbox/.gitignore create mode 100644 android-godeye-toolbox/README.md create mode 100644 android-godeye-toolbox/build.gradle create mode 100644 android-godeye-toolbox/proguard-rules.pro create mode 100644 android-godeye-toolbox/src/androidTest/java/cn/hikyson/android_godeye_toolbox/ExampleInstrumentedTest.java create mode 100644 android-godeye-toolbox/src/main/AndroidManifest.xml create mode 100644 android-godeye-toolbox/src/main/res/values/strings.xml create mode 100644 android-godeye-toolbox/src/test/java/cn/hikyson/android_godeye_toolbox/ExampleUnitTest.java create mode 100644 android-godeye/.gitignore create mode 100644 android-godeye/build.gradle create mode 100644 android-godeye/proguard-rules.pro create mode 100644 android-godeye/src/androidTest/java/cn/hikyson/godeye/ExampleInstrumentedTest.java create mode 100644 android-godeye/src/main/AndroidManifest.xml create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/BlockEngine.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/CpuEngine.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/Engine2.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/GodEye.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/RequestEngine.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/Consumer.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/Install.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/Interval.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/Module.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/ProduceableConsumer.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/Producer.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/SnapshotEngine.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/engines/Enginee.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/battery/Battery.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/battery/BatteryInfo.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/cpu/Cpu.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/cpu/CpuInfo.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/cpu/CpuSnapshot.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/fps/Fps.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/fps/FpsInfo.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/leakdetector/LeakDetector.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/leakdetector/LeakOutputReceiver.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/leakdetector/LeakQueue.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/memory/Heap.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/memory/HeapInfo.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/memory/Pss.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/memory/PssInfo.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/memory/Ram.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/memory/RamInfo.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/network/Network.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/network/RequestBaseInfo.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/sm/BlockInfo.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/sm/Sm.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/sm/core/AbstractSampler.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/sm/core/BlockInterceptor.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/sm/core/CpuSampler.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/sm/core/HandlerThreadFactory.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/sm/core/LongBlockInfo.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/sm/core/LooperMonitor.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/sm/core/MemoryInfo.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/sm/core/ShortBlockInfo.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/sm/core/SmConfig.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/sm/core/SmCore.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/sm/core/StackSampler.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/startup/Startup.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/startup/StartupInfo.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/traffic/Traffic.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/traffic/TrafficInfo.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/internal/modules/traffic/TrafficSnapshot.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/utils/DeviceUtils.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/utils/FileUtil.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/utils/IoUtil.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/utils/L.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/utils/ProcessUtils.java create mode 100644 android-godeye/src/main/java/cn/hikyson/godeye/utils/StacktraceUtil.java create mode 100644 android-godeye/src/main/res/values/strings.xml create mode 100644 android-godeye/src/test/java/cn/hikyson/godeye/ExampleUnitTest.java create mode 100644 build.gradle create mode 100644 gradle.properties create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100755 gradlew create mode 100644 gradlew.bat create mode 100644 settings.gradle diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..4ffd5bd8 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..e2c42dcd --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 00000000..7f68460d --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/android-godeye-monitor-no-op/.gitignore b/android-godeye-monitor-no-op/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/android-godeye-monitor-no-op/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android-godeye-monitor-no-op/build.gradle b/android-godeye-monitor-no-op/build.gradle new file mode 100644 index 00000000..998a86fb --- /dev/null +++ b/android-godeye-monitor-no-op/build.gradle @@ -0,0 +1,34 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion 26 + + + + defaultConfig { + minSdkVersion 16 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + + implementation 'com.android.support:appcompat-v7:26.1.0' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.1' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' +} diff --git a/android-godeye-monitor-no-op/proguard-rules.pro b/android-godeye-monitor-no-op/proguard-rules.pro new file mode 100644 index 00000000..f1b42451 --- /dev/null +++ b/android-godeye-monitor-no-op/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/android-godeye-monitor-no-op/src/androidTest/java/cn/hikyson/godeye/ExampleInstrumentedTest.java b/android-godeye-monitor-no-op/src/androidTest/java/cn/hikyson/godeye/ExampleInstrumentedTest.java new file mode 100644 index 00000000..76a7788b --- /dev/null +++ b/android-godeye-monitor-no-op/src/androidTest/java/cn/hikyson/godeye/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package cn.hikyson.godeye; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("cn.hikyson.android_godeye_monitor_no_op.test", appContext.getPackageName()); + } +} diff --git a/android-godeye-monitor-no-op/src/main/AndroidManifest.xml b/android-godeye-monitor-no-op/src/main/AndroidManifest.xml new file mode 100644 index 00000000..6f215f47 --- /dev/null +++ b/android-godeye-monitor-no-op/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + diff --git a/android-godeye-monitor-no-op/src/main/res/values/strings.xml b/android-godeye-monitor-no-op/src/main/res/values/strings.xml new file mode 100644 index 00000000..2046ca90 --- /dev/null +++ b/android-godeye-monitor-no-op/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + android-godeye-monitor-no-op + diff --git a/android-godeye-monitor-no-op/src/test/java/cn/hikyson/godeye/ExampleUnitTest.java b/android-godeye-monitor-no-op/src/test/java/cn/hikyson/godeye/ExampleUnitTest.java new file mode 100644 index 00000000..1e87e81d --- /dev/null +++ b/android-godeye-monitor-no-op/src/test/java/cn/hikyson/godeye/ExampleUnitTest.java @@ -0,0 +1,17 @@ +package cn.hikyson.godeye; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() throws Exception { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file diff --git a/android-godeye-monitor/.gitignore b/android-godeye-monitor/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/android-godeye-monitor/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android-godeye-monitor/build.gradle b/android-godeye-monitor/build.gradle new file mode 100644 index 00000000..64b64910 --- /dev/null +++ b/android-godeye-monitor/build.gradle @@ -0,0 +1,34 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion 26 + + + + defaultConfig { + minSdkVersion 16 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + +} + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation 'com.android.support:appcompat-v7:26.1.0' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.1' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' + implementation project(':android-godeye') +} diff --git a/android-godeye-monitor/proguard-rules.pro b/android-godeye-monitor/proguard-rules.pro new file mode 100644 index 00000000..f1b42451 --- /dev/null +++ b/android-godeye-monitor/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/android-godeye-monitor/src/androidTest/java/cn/hikyson/godeye/ExampleInstrumentedTest.java b/android-godeye-monitor/src/androidTest/java/cn/hikyson/godeye/ExampleInstrumentedTest.java new file mode 100644 index 00000000..27bbd55d --- /dev/null +++ b/android-godeye-monitor/src/androidTest/java/cn/hikyson/godeye/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package cn.hikyson.godeye; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("cn.hikyson.android_godeye_monitor.test", appContext.getPackageName()); + } +} diff --git a/android-godeye-monitor/src/main/AndroidManifest.xml b/android-godeye-monitor/src/main/AndroidManifest.xml new file mode 100644 index 00000000..6f215f47 --- /dev/null +++ b/android-godeye-monitor/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + diff --git a/android-godeye-monitor/src/main/java/cn/hikyson/godeye/monitor/Engine.java b/android-godeye-monitor/src/main/java/cn/hikyson/godeye/monitor/Engine.java new file mode 100644 index 00000000..42359565 --- /dev/null +++ b/android-godeye-monitor/src/main/java/cn/hikyson/godeye/monitor/Engine.java @@ -0,0 +1,8 @@ +package cn.hikyson.godeye.monitor; + +/** + * monitor数据引擎,用于驱动生产各项数据 + * Created by kysonchao on 2017/11/21. + */ +public class Engine { +} diff --git a/android-godeye-monitor/src/main/java/cn/hikyson/godeye/monitor/Pipe.java b/android-godeye-monitor/src/main/java/cn/hikyson/godeye/monitor/Pipe.java new file mode 100644 index 00000000..c2057062 --- /dev/null +++ b/android-godeye-monitor/src/main/java/cn/hikyson/godeye/monitor/Pipe.java @@ -0,0 +1,8 @@ +package cn.hikyson.godeye.monitor; + +/** + * 数据管道,用于将引擎生产的数据输送到monitor + * Created by kysonchao on 2017/11/21. + */ +public class Pipe { +} diff --git a/android-godeye-monitor/src/main/res/values/strings.xml b/android-godeye-monitor/src/main/res/values/strings.xml new file mode 100644 index 00000000..a298cf68 --- /dev/null +++ b/android-godeye-monitor/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + android-godeye-monitor + diff --git a/android-godeye-monitor/src/test/java/cn/hikyson/godeye/ExampleUnitTest.java b/android-godeye-monitor/src/test/java/cn/hikyson/godeye/ExampleUnitTest.java new file mode 100644 index 00000000..1e87e81d --- /dev/null +++ b/android-godeye-monitor/src/test/java/cn/hikyson/godeye/ExampleUnitTest.java @@ -0,0 +1,17 @@ +package cn.hikyson.godeye; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() throws Exception { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file diff --git a/android-godeye-sample/.gitignore b/android-godeye-sample/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/android-godeye-sample/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android-godeye-sample/build.gradle b/android-godeye-sample/build.gradle new file mode 100644 index 00000000..ce5758d9 --- /dev/null +++ b/android-godeye-sample/build.gradle @@ -0,0 +1,29 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "cn.hikyson.androidgodeye.sample" + minSdkVersion 16 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation 'com.android.support.constraint:constraint-layout:1.0.2' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.1' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' + implementation project(':android-godeye-monitor') + implementation project(':android-godeye') +} diff --git a/android-godeye-sample/proguard-rules.pro b/android-godeye-sample/proguard-rules.pro new file mode 100644 index 00000000..f1b42451 --- /dev/null +++ b/android-godeye-sample/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/android-godeye-sample/src/androidTest/java/cn/hikyson/android/godeye/ExampleInstrumentedTest.java b/android-godeye-sample/src/androidTest/java/cn/hikyson/android/godeye/ExampleInstrumentedTest.java new file mode 100644 index 00000000..4ff09021 --- /dev/null +++ b/android-godeye-sample/src/androidTest/java/cn/hikyson/android/godeye/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package cn.hikyson.android.godeye; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("cn.hikyson.androidgodeye.sample", appContext.getPackageName()); + } +} diff --git a/android-godeye-sample/src/main/AndroidManifest.xml b/android-godeye-sample/src/main/AndroidManifest.xml new file mode 100644 index 00000000..4f96931c --- /dev/null +++ b/android-godeye-sample/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android-godeye-sample/src/main/java/cn/hikyson/android/godeye/sample/LeakActivity.java b/android-godeye-sample/src/main/java/cn/hikyson/android/godeye/sample/LeakActivity.java new file mode 100644 index 00000000..34164dae --- /dev/null +++ b/android-godeye-sample/src/main/java/cn/hikyson/android/godeye/sample/LeakActivity.java @@ -0,0 +1,29 @@ +package cn.hikyson.android.godeye.sample; + +import android.app.Activity; +import android.os.Bundle; +import android.view.View; + +import cn.hikyson.android.godeye.R; + +public class LeakActivity extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_leak); + } + + public void leak(View view) { + new Thread(new Runnable() { + @Override + public void run() { + try { + Thread.sleep(30000); + } catch (InterruptedException e) { + } + } + }).start(); + } + +} diff --git a/android-godeye-sample/src/main/java/cn/hikyson/android/godeye/sample/MainActivity.java b/android-godeye-sample/src/main/java/cn/hikyson/android/godeye/sample/MainActivity.java new file mode 100644 index 00000000..11177415 --- /dev/null +++ b/android-godeye-sample/src/main/java/cn/hikyson/android/godeye/sample/MainActivity.java @@ -0,0 +1,199 @@ +package cn.hikyson.android.godeye.sample; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.EditText; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import javax.net.ssl.HttpsURLConnection; + +import cn.hikyson.android.godeye.R; +import cn.hikyson.godeye.internal.modules.battery.Battery; +import cn.hikyson.godeye.internal.modules.battery.BatteryInfo; +import cn.hikyson.godeye.internal.modules.cpu.Cpu; +import cn.hikyson.godeye.internal.modules.cpu.CpuInfo; +import cn.hikyson.godeye.internal.modules.fps.Fps; +import cn.hikyson.godeye.internal.modules.fps.FpsInfo; +import cn.hikyson.godeye.internal.modules.leakdetector.LeakDetector; +import cn.hikyson.godeye.internal.modules.leakdetector.LeakQueue; +import cn.hikyson.godeye.internal.modules.network.Network; +import cn.hikyson.godeye.internal.modules.network.RequestBaseInfo; +import cn.hikyson.godeye.internal.modules.sm.BlockInfo; +import cn.hikyson.godeye.internal.modules.sm.Sm; +import cn.hikyson.godeye.internal.modules.sm.core.SmConfig; +import cn.hikyson.godeye.internal.modules.traffic.Traffic; +import cn.hikyson.godeye.internal.modules.traffic.TrafficInfo; +import io.reactivex.Observable; +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.functions.Consumer; +import io.reactivex.observers.DisposableObserver; +import io.reactivex.schedulers.Schedulers; + +public class MainActivity extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + } + + public void testCpu(View view) { + new Cpu(1000).stream(this).observeOn(Schedulers.io()).subscribeOn(AndroidSchedulers.mainThread()).subscribe(new DisposableObserver() { + @Override + public void onNext(CpuInfo cpuInfo) { + Log.d("kyson", String.valueOf(cpuInfo)); + } + + @Override + public void onError(Throwable e) { + Log.d("kyson", "onError:" + String.valueOf(e)); + } + + @Override + public void onComplete() { + Log.d("kyson", "onComplete"); + } + }); + } + + public void testBattery(View view) { + new Battery().stream(this).observeOn(Schedulers.io()).subscribeOn(AndroidSchedulers.mainThread()).subscribe(new DisposableObserver() { + @Override + public void onNext(BatteryInfo batteryInfo) { + Log.d("kyson", String.valueOf(batteryInfo)); + } + + @Override + public void onError(Throwable e) { + Log.d("kyson", "onError:" + String.valueOf(e)); + } + + @Override + public void onComplete() { + Log.d("kyson", "onComplete"); + } + }); + } + + public void installSM(View view) { + Sm.instance().install(MainActivity.this, new SmConfig()); + } + + public void uninstallSM(View view) { + Sm.instance().uninstall(MainActivity.this); + } + + public void blockWatch(View view) { + Observable observable = Sm.instance().consume(MainActivity.this); + observable.subscribe(new Consumer() { + @Override + public void accept(BlockInfo blockInfo) throws Exception { + Log.d("kyson", String.valueOf(blockInfo)); + } + }); + } + + public void block(View view) { + try { + EditText editText = findViewById(R.id.activity_main_block_et); + final long blockTime = Long.parseLong(String.valueOf(editText.getText())); + Thread.sleep(blockTime); + } catch (Throwable e) { + } + } + + private Network network; + + public void network(View view) { + if (network == null) { + network = new Network(); + } + RequestBaseInfo requestBaseInfo = new RequestBaseInfo(1000, 2000, 12312, "http://www.trip.com"); + network.produce(requestBaseInfo); + network.consume(MainActivity.this).subscribe(new Consumer() { + @Override + public void accept(RequestBaseInfo requestBaseInfo) throws Exception { + Log.d("kyson", String.valueOf(requestBaseInfo)); + } + }); + } + + public void jumpToLeak(View view) { + Intent intent = new Intent(MainActivity.this, LeakActivity.class); + startActivity(intent); + } + + public void installLeak(View view) { + LeakDetector.instance().install(MainActivity.this, getApplication()); + LeakDetector.instance().consume(MainActivity.this).subscribe(new Consumer() { + @Override + public void accept(LeakQueue.LeakMemoryInfo leakMemoryInfo) throws Exception { + Log.d("kyson", String.valueOf(leakMemoryInfo)); + } + }); + } + + public void testFps(View view) { + new Fps().stream(MainActivity.this).subscribe(new Consumer() { + @Override + public void accept(FpsInfo fpsInfo) throws Exception { + Log.d("kyson", String.valueOf(fpsInfo)); + } + }); + } + + + public void testTraffic(View view) { + new Traffic(1000).stream(MainActivity.this).subscribe(new Consumer() { + @Override + public void accept(TrafficInfo trafficInfo) throws Exception { + Log.d("kyson", "traffic:" + String.valueOf(trafficInfo)); + } + }); + } + + + public void testRequest(View view) { + ExecutorService service = Executors.newSingleThreadExecutor(); + for (int i = 0; i < 100; i++) { + service.submit(new Runnable() { + @Override + public void run() { + request(); + } + }); + } + } + + private String request() { + try { + URL url = new URL("https://www.trip.com/"); + //打开连接 + HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection(); + if (200 == urlConnection.getResponseCode()) { + //得到输入流 + InputStream is = urlConnection.getInputStream(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + byte[] buffer = new byte[1024]; + int len = 0; + while (-1 != (len = is.read(buffer))) { + baos.write(buffer, 0, len); + baos.flush(); + } + return baos.toString("utf-8"); + } + } catch (IOException e) { + e.printStackTrace(); + } + return ""; + } +} diff --git a/android-godeye-sample/src/main/res/drawable-v24/ic_launcher_foreground.xml b/android-godeye-sample/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 00000000..c3903edf --- /dev/null +++ b/android-godeye-sample/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/android-godeye-sample/src/main/res/drawable/ic_launcher_background.xml b/android-godeye-sample/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 00000000..5713f34a --- /dev/null +++ b/android-godeye-sample/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android-godeye-sample/src/main/res/layout/activity_leak.xml b/android-godeye-sample/src/main/res/layout/activity_leak.xml new file mode 100644 index 00000000..6894e529 --- /dev/null +++ b/android-godeye-sample/src/main/res/layout/activity_leak.xml @@ -0,0 +1,19 @@ + + + +