Skip to content

Commit 4f57e34

Browse files
hui.zhaohui.zhao
authored andcommitted
升级godeye
多进程测试
1 parent 233f70f commit 4f57e34

File tree

6 files changed

+141
-28
lines changed

6 files changed

+141
-28
lines changed

app/build.gradle

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,14 @@ dependencies {
5050
implementation "cn.hikyson.godeye:godeye-okhttp:${VERSION_NAME}"
5151
// Extra module, help to monitor crash/ANR
5252
implementation "cn.hikyson.godeye:godeye-xcrash:${VERSION_NAME}"
53+
implementation "cn.hikyson.godeye:godeye-leakcanary:${VERSION_NAME}"
5354
}
5455

5556
apply plugin: 'cn.hikyson.methodcanary.plugin'
5657

5758
AndroidGodEye {
58-
enableMethodTracer = true
59-
enableLifecycleTracer = true
60-
instrumentationRuleFilePath = 'AndroidGodEye-MethodCanary.js'
61-
instrumentationRuleIncludeClassNamePrefix = null
59+
enableMethodTracer true
60+
enableLifecycleTracer true
61+
instrumentationRuleFilePath 'AndroidGodEye-MethodCanary.js'
62+
instrumentationRuleIncludeClassNamePrefix(['cn/hikyson/godeyedemo'])
6263
}

app/src/main/AndroidManifest.xml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="cn.hikyson.godeyedemo">
4-
5-
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
3+
xmlns:tools="http://schemas.android.com/tools"
4+
package="cn.hikyson.godeyedemo">
65

76
<application
87
android:name=".MyApp"
@@ -12,13 +11,27 @@
1211
android:supportsRtl="true">
1312
<activity android:name=".MainActivity">
1413
<intent-filter>
15-
<action android:name="android.intent.action.MAIN"/>
14+
<action android:name="android.intent.action.MAIN" />
1615

17-
<category android:name="android.intent.category.LAUNCHER"/>
16+
<category android:name="android.intent.category.LAUNCHER" />
1817
</intent-filter>
1918
</activity>
20-
<activity android:name=".LeakActivity">
21-
</activity>
19+
20+
<activity android:name=".LeakActivity"></activity>
21+
22+
<service
23+
android:name=".MyIntentService"
24+
android:exported="false"
25+
android:process=":test"></service>
26+
27+
<service
28+
android:name="cn.hikyson.godeye.core.internal.notification.LocalNotificationListenerService"
29+
android:enabled="true"
30+
android:exported="false"
31+
android:process="cn.hikyson.godeyedemo"
32+
tools:replace="android:process" />
2233
</application>
2334

35+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
36+
2437
</manifest>
Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
<config>
2-
<appSize delayMillis="0" />
3-
<battery />
42
<cpu intervalMillis="2000" />
5-
<crash immediate="false" />
3+
<battery />
64
<fps intervalMillis="2000" />
5+
<leakCanary />
76
<heap intervalMillis="2000" />
8-
<imageCanary
9-
imageCanaryConfigProvider="cn.hikyson.godeye.core.internal.modules.imagecanary.DefaultImageCanaryConfigProvider" />
10-
<leakMemory debug="true" debugNotification="true"
11-
leakRefInfoProvider="cn.hikyson.godeye.core.internal.modules.leakdetector.DefaultLeakRefInfoProvider" />
12-
<methodCanary lowCostMethodThresholdMillis="10" maxMethodCountSingleThreadByCost="300" />
13-
<network />
14-
<pageload
15-
pageInfoProvider="cn.hikyson.godeye.core.internal.modules.pageload.DefaultPageInfoProvider" />
167
<pss intervalMillis="2000" />
178
<ram intervalMillis="2000" />
18-
<sm debugNotification="true" dumpIntervalMillis="1000" longBlockThresholdMillis="500"
19-
shortBlockThresholdMillis="500" />
9+
<network />
10+
<sm dumpIntervalMillis="1000" longBlockThresholdMillis="500" shortBlockThresholdMillis="500" />
2011
<startup />
12+
<traffic intervalMillis="2000" sampleMillis="1000" />
13+
<crash immediate="false" />
2114
<thread intervalMillis="3000"
2215
threadFilter="cn.hikyson.godeye.core.internal.modules.thread.ExcludeSystemThreadFilter"
2316
threadTagger="cn.hikyson.godeye.core.internal.modules.thread.DefaultThreadTagger" />
24-
<traffic intervalMillis="2000" sampleMillis="1000" />
17+
<pageload
18+
pageInfoProvider="cn.hikyson.godeye.core.internal.modules.pageload.DefaultPageInfoProvider" />
19+
<methodCanary lowCostMethodThresholdMillis="10" maxMethodCountSingleThreadByCost="300" />
20+
<appSize delayMillis="0" />
2521
<viewCanary maxDepth="10" />
22+
<imageCanary
23+
imageCanaryConfigProvider="cn.hikyson.godeye.core.internal.modules.imagecanary.DefaultImageCanaryConfigProvider" />
2624
</config>

app/src/main/java/cn/hikyson/godeyedemo/MyApp.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import cn.hikyson.godeye.monitor.modules.appinfo.AppInfoLabel;
1717
import okhttp3.OkHttpClient;
1818

19+
import static cn.hikyson.godeye.core.utils.ProcessUtils.isMainProcess;
20+
1921
/**
2022
* Created by kysonchao on 2018/1/29.
2123
*/
@@ -26,7 +28,6 @@ public class MyApp extends Application {
2628
public void onCreate() {
2729
super.onCreate();
2830
if (isMainProcess(this)) {
29-
GodEye.instance().init(this);
3031
GodEye.instance().install(GodEyeConfig.fromAssets("android-godeye-config/install.config"));
3132
GodEyeMonitor.injectAppInfoConext(new GodEyeMonitor.AppInfoConext() {
3233
@Override
@@ -43,6 +44,7 @@ public List<AppInfoLabel> getAppInfo() {
4344
GodEyeMonitor.work(this);
4445
}
4546
sApplicationStartTime = System.currentTimeMillis();
47+
MyIntentService.startActionBaz(this, "", "");
4648
}
4749

4850
private static OkHttpClient sOkHttpClient;
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
package cn.hikyson.godeyedemo;
2+
3+
import android.app.IntentService;
4+
import android.content.Intent;
5+
import android.content.Context;
6+
7+
import cn.hikyson.godeye.core.utils.ThreadUtil;
8+
9+
/**
10+
* An {@link IntentService} subclass for handling asynchronous task requests in
11+
* a service on a separate handler thread.
12+
* <p>
13+
* TODO: Customize class - update intent actions, extra parameters and static
14+
* helper methods.
15+
*/
16+
public class MyIntentService extends IntentService {
17+
// TODO: Rename actions, choose action names that describe tasks that this
18+
// IntentService can perform, e.g. ACTION_FETCH_NEW_ITEMS
19+
private static final String ACTION_FOO = "cn.hikyson.godeyedemo.action.FOO";
20+
private static final String ACTION_BAZ = "cn.hikyson.godeyedemo.action.BAZ";
21+
22+
// TODO: Rename parameters
23+
private static final String EXTRA_PARAM1 = "cn.hikyson.godeyedemo.extra.PARAM1";
24+
private static final String EXTRA_PARAM2 = "cn.hikyson.godeyedemo.extra.PARAM2";
25+
26+
public MyIntentService() {
27+
super("MyIntentService");
28+
}
29+
30+
/**
31+
* Starts this service to perform action Foo with the given parameters. If
32+
* the service is already performing a task this action will be queued.
33+
*
34+
* @see IntentService
35+
*/
36+
// TODO: Customize helper method
37+
public static void startActionFoo(Context context, String param1, String param2) {
38+
Intent intent = new Intent(context, MyIntentService.class);
39+
intent.setAction(ACTION_FOO);
40+
intent.putExtra(EXTRA_PARAM1, param1);
41+
intent.putExtra(EXTRA_PARAM2, param2);
42+
context.startService(intent);
43+
}
44+
45+
/**
46+
* Starts this service to perform action Baz with the given parameters. If
47+
* the service is already performing a task this action will be queued.
48+
*
49+
* @see IntentService
50+
*/
51+
// TODO: Customize helper method
52+
public static void startActionBaz(Context context, String param1, String param2) {
53+
Intent intent = new Intent(context, MyIntentService.class);
54+
intent.setAction(ACTION_BAZ);
55+
intent.putExtra(EXTRA_PARAM1, param1);
56+
intent.putExtra(EXTRA_PARAM2, param2);
57+
context.startService(intent);
58+
}
59+
60+
@Override
61+
protected void onHandleIntent(Intent intent) {
62+
if (intent != null) {
63+
final String action = intent.getAction();
64+
if (ACTION_FOO.equals(action)) {
65+
final String param1 = intent.getStringExtra(EXTRA_PARAM1);
66+
final String param2 = intent.getStringExtra(EXTRA_PARAM2);
67+
try {
68+
handleActionFoo(param1, param2);
69+
} catch (InterruptedException e) {
70+
e.printStackTrace();
71+
}
72+
} else if (ACTION_BAZ.equals(action)) {
73+
final String param1 = intent.getStringExtra(EXTRA_PARAM1);
74+
final String param2 = intent.getStringExtra(EXTRA_PARAM2);
75+
try {
76+
handleActionBaz(param1, param2);
77+
} catch (InterruptedException e) {
78+
e.printStackTrace();
79+
}
80+
}
81+
}
82+
}
83+
84+
/**
85+
* Handle action Foo in the provided background thread with the provided
86+
* parameters.
87+
*/
88+
private void handleActionFoo(String param1, String param2) throws InterruptedException {
89+
Thread.sleep(100000);
90+
}
91+
92+
/**
93+
* Handle action Baz in the provided background thread with the provided
94+
* parameters.
95+
*/
96+
private void handleActionBaz(String param1, String param2) throws InterruptedException {
97+
Thread.sleep(100000);
98+
}
99+
}

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ org.gradle.jvmargs=-Xmx1536m
1818
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1919
# org.gradle.parallel=true
2020

21-
VERSION_NAME=3.2.2
22-
METHOD_CANARY_VERSION_NAME=0.15.2
21+
VERSION_NAME=3.3.1
22+
METHOD_CANARY_VERSION_NAME=0.15.4
2323
USE_ALIYUN_REPO=false

0 commit comments

Comments
 (0)