Skip to content

Commit b00eaeb

Browse files
hui.zhaohui.zhao
authored andcommitted
#Deprecated#
Changed <leakCanary debug="true" /> to <leakCanary /> and LeakConfig.debug is deprecated
1 parent e9ad0d9 commit b00eaeb

File tree

9 files changed

+72
-30
lines changed

9 files changed

+72
-30
lines changed

android-godeye-sample/src/main/assets/android-godeye-config/install.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<cpu intervalMillis="2000" />
33
<battery />
44
<fps intervalMillis="2000" />
5-
<leakCanary debug="true" />
5+
<leakCanary />
66
<heap intervalMillis="2000" />
77
<pss intervalMillis="2000" />
88
<ram intervalMillis="2000" />

android-godeye-toolboxes/android-godeye-leakcanary/src/main/java/cn/hikyson/android/godeye/leakcanary/GodEyePluginLeakCanary.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void run() {
3030
LeakCanary.INSTANCE.showLeakDisplayActivityLauncherIcon(false);
3131
LeakCanary.setConfig(new LeakCanary.Config().newBuilder()
3232
.requestWriteExternalStoragePermission(false)
33-
.dumpHeap(leakModule.config().debug())
33+
.dumpHeap(true)
3434
.onHeapAnalyzedListener(new OnHeapAnalyzedListener() {
3535
@Override
3636
public void onHeapAnalyzed(@NotNull HeapAnalysis heapAnalysis) {

android-godeye/src/main/java/cn/hikyson/godeye/core/GodEyeConfig.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,7 @@ public static GodEyeConfig fromInputStream(InputStream is) {
112112
// leak
113113
element = getFirstElementByTagInRoot(root, "leakCanary");
114114
if (element != null) {
115-
final String debug = element.getAttribute("debug");
116-
LeakConfig leakConfig = new LeakConfig();
117-
if (!TextUtils.isEmpty(debug)) {
118-
leakConfig.debug = Boolean.parseBoolean(debug);
119-
} else {
120-
leakConfig.debug = true;
121-
}
122-
builder.withLeakConfig(leakConfig);
115+
builder.withLeakConfig(new LeakConfig());
123116
}
124117
// heap
125118
element = getFirstElementByTagInRoot(root, "heap");

android-godeye/src/main/java/cn/hikyson/godeye/core/internal/modules/leakdetector/LeakConfig.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
@Keep
1010
public class LeakConfig implements Serializable {
1111
// if you want leak module work in production,set debug false
12+
/**
13+
* @deprecated
14+
*/
15+
@Deprecated
1216
public boolean debug;
1317
/**
1418
* @deprecated
@@ -31,13 +35,20 @@ public LeakConfig(boolean debug, boolean debugNotification, String leakRefInfoPr
3135
}
3236

3337
public LeakConfig() {
34-
this.debug = true;
3538
}
3639

40+
/**
41+
* @deprecated
42+
*/
43+
@Deprecated
3744
public LeakConfig(boolean debug) {
3845
this.debug = debug;
3946
}
4047

48+
/**
49+
* @deprecated
50+
*/
51+
@Deprecated
4152
public boolean debug() {
4253
return debug;
4354
}
@@ -63,8 +74,6 @@ public String leakRefInfoProvider() {
6374

6475
@Override
6576
public String toString() {
66-
return "LeakConfig{" +
67-
"debug=" + debug +
68-
'}';
77+
return "LeakConfig{}";
6978
}
7079
}

android-godeye/src/main/java/cn/hikyson/godeye/core/internal/modules/memory/MemoryUtil.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ public static HeapInfo getAppHeapInfo() {
3434
return heapInfo;
3535
}
3636

37-
/**
38-
* get native heap
39-
*
40-
* @return
41-
*/
42-
public static NativeHeapInfo getAppNativeHeap() {
43-
NativeHeapInfo nativeHeapInfo = new NativeHeapInfo();
44-
45-
nativeHeapInfo.heapSizeKb = Debug.getNativeHeapSize() / 1024;
46-
nativeHeapInfo.heapAllocatedKb = Debug.getNativeHeapAllocatedSize() / 1024;
47-
nativeHeapInfo.heapFreeSizeKb = Debug.getNativeHeapFreeSize() / 1024;
48-
return nativeHeapInfo;
49-
}
37+
// /**
38+
// * get native heap
39+
// *
40+
// * @return
41+
// */
42+
// public static NativeHeapInfo getAppNativeHeap() {
43+
// NativeHeapInfo nativeHeapInfo = new NativeHeapInfo();
44+
//
45+
// nativeHeapInfo.heapSizeKb = Debug.getNativeHeapSize() / 1024;
46+
// nativeHeapInfo.heapAllocatedKb = Debug.getNativeHeapAllocatedSize() / 1024;
47+
// nativeHeapInfo.heapFreeSizeKb = Debug.getNativeHeapFreeSize() / 1024;
48+
// return nativeHeapInfo;
49+
// }
5050

5151
/**
5252
* 获取应用实际占用RAM

android-godeye/src/test/java/cn/hikyson/godeye/core/GodEyeConfigTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ private void assertConfig(GodEyeConfig config) {
185185
assertEquals(2000, config.getFpsConfig().intervalMillis());
186186
assertEquals(2000, config.getHeapConfig().intervalMillis());
187187
assertEquals("cn.hikyson.godeye.core.internal.modules.imagecanary.DefaultImageCanaryConfigProvider", config.getImageCanaryConfig().getImageCanaryConfigProvider());
188-
assertEquals(true, config.getLeakConfig().debug());
189188
assertEquals(10, config.getMethodCanaryConfig().lowCostMethodThresholdMillis());
190189
assertEquals(300, config.getMethodCanaryConfig().maxMethodCountSingleThreadByCost());
191190
assertEquals(JsonUtil.toJson(new NetworkConfig()), JsonUtil.toJson(config.getNetworkConfig()));
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package cn.hikyson.godeye.core.internal.modules.memory;
2+
3+
import android.os.Build;
4+
5+
import org.junit.Assert;
6+
import org.junit.Test;
7+
import org.junit.runner.RunWith;
8+
import org.robolectric.RobolectricTestRunner;
9+
import org.robolectric.annotation.Config;
10+
11+
import cn.hikyson.godeye.core.GodEye;
12+
import cn.hikyson.godeye.core.helper.RoboTestApplication;
13+
14+
@RunWith(RobolectricTestRunner.class)
15+
@Config(sdk = Build.VERSION_CODES.LOLLIPOP, application = RoboTestApplication.class)
16+
public class MemoryUtilTest {
17+
18+
@Test
19+
public void getAppHeapInfo() {
20+
HeapInfo heapInfo = MemoryUtil.getAppHeapInfo();
21+
Assert.assertTrue(heapInfo.allocatedKb > 0);
22+
Assert.assertTrue(heapInfo.freeMemKb > 0);
23+
Assert.assertTrue(heapInfo.maxMemKb > 0);
24+
}
25+
26+
@Test
27+
public void getAppPssInfo() {
28+
try {
29+
PssInfo pssInfo = MemoryUtil.getAppPssInfo(GodEye.instance().getApplication());
30+
} catch (NullPointerException ignore) {
31+
} catch (Throwable e) {
32+
Assert.fail();
33+
}
34+
}
35+
36+
@Test
37+
public void getRamInfo() {
38+
RamInfo ramInfo = MemoryUtil.getRamInfo(GodEye.instance().getApplication());
39+
Assert.assertNotNull(ramInfo);
40+
}
41+
}

android-godeye/src/test/resources/install.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<cpu intervalMillis="2000" />
33
<battery />
44
<fps intervalMillis="2000" />
5-
<leakCanary debug="true" />
5+
<leakCanary />
66
<heap intervalMillis="2000" />
77
<pss intervalMillis="2000" />
88
<ram intervalMillis="2000" />

android-godeye/src/test/resources/install2.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<cpu intervalMillis="4000" />
33
<battery />
44
<fps intervalMillis="4000" />
5-
<leakCanary debug="true" />
5+
<leakCanary />
66
<heap intervalMillis="4000" />
77
<pss intervalMillis="4000" />
88
<ram intervalMillis="4000" />

0 commit comments

Comments
 (0)