Skip to content

Commit

Permalink
1. 修改leak canary
Browse files Browse the repository at this point in the history
2. 更新readme
  • Loading branch information
hui.zhao committed Dec 9, 2017
1 parent 1af058a commit bd3d5b3
Show file tree
Hide file tree
Showing 7 changed files with 320 additions and 203 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright [Kyson]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
78 changes: 42 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,81 +10,83 @@
</p>
<br />

> Android开发者在性能检测方面的工具一直比较匮乏,仅有的一些工具,比如Android Device Monitor,使用起来也有些繁琐,使用起来对开发者有一定的要求。而线上的App监控更无从谈起。所以需要有一个系统能够提供Debug和Release阶段全方位的监控,更深入地了解对App运行时的状态。
> Android developer lack of monitoring of performance data,especially in production environment. so we need "AndroidGodEye".
## 概览
## Overview

AndroidGodEye是一个可以在PC浏览器中实时监控Android数据指标(比如性能指标,但是不局限于性能)的工具。
AndroidGodEye is a performance monitor tool for Android , but not limited to performance data.

系统分为四部分:
It is divided into 3 parts:

1. Core 核心部分,提供所有模块
2. Debug Debug部分,提供Debug阶段开发者面板
4. Toolbox 快速接入工具集,给开发者提供各种便捷接入的工具
1. Core provide all performance modules and produce performance datas.
2. Debug Monitor provide a panel to show these performance datas.
3. Toolbox make developers easy to use this library.

目前,AndroidGodEye提供了11种监控模块,比如cpu、内存、卡顿、内存泄漏等等,并且提供了Debug阶段的Monitor看板实时展示这
些数据。而且提供了api供开发者在release阶段进行数据上报。
Currently, AndroidGodEye prodive 11 modules, such as cpu, heap, block, leak memory and so on.

## 快速开始
## Quickstart

### STEP1
### Step1

引入依赖,使用gradle
In your build.gradle:

```
dependencies {
compile 'cn.hikyson.godeye:godeye-core:1.0-SNAPSHOT'
compile 'cn.hikyson.godeye:godeye-monitor:1.0-SNAPSHOT'
compile 'cn.hikyson.godeye:godeye-monitor-no-op:1.0-SNAPSHOT'
compile 'cn.hikyson.godeye:godeye-toolbox:1.0-SNAPSHOT'
implementation 'cn.hikyson.godeye:godeye-core:VERSION_NAME'
debugImplementation 'cn.hikyson.godeye:godeye-monitor:VERSION_NAME'
releaseImplementation 'cn.hikyson.godeye:godeye-monitor-no-op:VERSION_NAME'
implementation 'cn.hikyson.godeye:godeye-toolbox:VERSION_NAME'
}
```

### STEP2
> You can find VERSION_NAME in the github release.
模块安装,GodEye类是AndroidGodEye的核心类,所有模块由它提供。
### Step2

在应用入口安装所有模块:
Install modules , GodEye class is entrance for this step, all module is provided by it.

```java
GodEye.instance().installAll(getApplication());
```

> 安装完之后相应的模块就开始输出数据了
> if you don't need all modules , you can install separately yourself:`GodEye.instance().cpu().install()`
> Note that network and startup module don't need install and uninstall.
> When install finished, GodEye begin produce performance data, generally you can call consume of modules to get these datas, for example:
> `GodEye.instance().cpu().consume().subscribe(new GodEyeDisposableObserver<CpuInfo>("cpu", this))`
> Just like we will mention later,Debug Monitor is one of all consumers.
在不需要的时候可以卸载所有模块:
Uninstall modules when you don't need it:

```java
GodEye.instance().uninstallAll(getApplication());
GodEye.instance().uninstallAll();
```

> 开发者也可以根据自己的需求安装模块,注意:network和startup模块不需要安装和卸载,leak detector不需要卸载
### Step3

### STEP3
Install debug monitor,GodEyeMonitor class is entrance for this step.

Debug面板安装,GodEyeMonitor类是AndroidGodEye的Debug监控面板的主要类,用来开始或者停止Debug面板的监控。

开始监控:
Consume data produced by GodEye modules:

```java
GodEyeMonitor.work(context)
```

结束监控:
Stop it:

```java
GodEyeMonitor.shutDown()
```

### STEP4
### Step4

完成!开始使用:
You're good to go!

手机与pc连接同一网段,在pc浏览器中访问 手机ip+端口 即可看到Debug面板!
Make sure your android device and pc are on the same network segment, and open browser on pc,
open `device ip + port`, now enjoy it!

> 端口默认是5390,也可以在`GodEyeMonitor.work(context)`中指定,一般在开发者在调用`GodEyeMonitor.work(context)`之后可以看到日志输出 'Open AndroidGodEye dashboard ...' 中包含了访问地址。
> Default port is 5390, you can find ip in logcat output after call `GodEyeMonitor.work(context)`, log is like:'Open AndroidGodEye dashboard [ http://10.32.240.21:5390" ] in your browser...'.
## Debug开发者面板
## Debug Monitor

###### Click ↓ to preview
<p>
Expand All @@ -93,15 +95,19 @@ GodEyeMonitor.shutDown()
</a>
</p>

### 基本信息展示
### Part1:Basic info

![android_godeye_part1](ART/android_godeye_part1.png)

### 内存泄漏展示
### Part2:Leak Memory Detector

![android_godeye_part5](ART/android_godeye_part5.png)

## 关于我
## License

AndroidGodEye under Apache2.0.

## About Me

- Github: [Kyson](https://github.com/Kyson)
- Weibo: [hikyson](https://weibo.com/hikyson)
Expand Down
126 changes: 126 additions & 0 deletions README_zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<p align="center">
<img src="ART/android_god_eye_logo.png" width="256" height="256" />
</p>

<h1 align="center">AndroidGodEye</h1>
<p align="center">
<a href="https://travis-ci.org/Kyson/AndroidGodEye" target="_blank"><img src="https://travis-ci.org/Kyson/AndroidGodEye.svg?branch=master"></img></a>
<a href="https://jitpack.io/#Kyson/AndroidGodEye" target="_blank"><img src="https://jitpack.io/v/Kyson/AndroidGodEye.svg"></img></a>

</p>
<br />

> Android开发者在性能检测方面的工具一直比较匮乏,仅有的一些工具,比如Android Device Monitor,使用起来也有些繁琐,使用起来对开发者有一定的要求。而线上的App监控更无从谈起。所以需要有一个系统能够提供Debug和Release阶段全方位的监控,更深入地了解对App运行时的状态。
## 概览

AndroidGodEye是一个可以在PC浏览器中实时监控Android数据指标(比如性能指标,但是不局限于性能)的工具。

系统分为三部分:

1. Core 核心部分,提供所有模块
2. Debug Monitor部分,提供Debug阶段开发者面板
3. Toolbox 快速接入工具集,给开发者提供各种便捷接入的工具

目前,AndroidGodEye提供了11种监控模块,比如cpu、内存、卡顿、内存泄漏等等,并且提供了Debug阶段的Monitor看板实时展示这
些数据。而且提供了api供开发者在release阶段进行数据上报。

## 快速开始

### STEP1

引入依赖,使用gradle

```
dependencies {
implementation 'cn.hikyson.godeye:godeye-core:VERSION_NAME'
debugImplementation 'cn.hikyson.godeye:godeye-monitor:VERSION_NAME'
releaseImplementation 'cn.hikyson.godeye:godeye-monitor-no-op:VERSION_NAME'
implementation 'cn.hikyson.godeye:godeye-toolbox:VERSION_NAME'
}
```

> VERSION_NAME可以看github的release名称
### STEP2

模块安装,GodEye类是AndroidGodEye的核心类,所有模块由它提供。

在应用入口安装所有模块:

```java
GodEye.instance().installAll(getApplication());
```

> 如果不想要所有的模块,你也可以自己安装想要的模块,比如`GodEye.instance().cpu().install()`
> 安装完之后相应的模块就开始输出数据了,一般来说可以使用模块的consume方法进行消费,比如cpu模块:
> `GodEye.instance().cpu().consume().subscribe(new GodEyeDisposableObserver<CpuInfo>("cpu", this))`
> Debug Monitor也是通过消费这些数据进行展示,当然,你可以自己消费数据进行展示或者上报。
在不需要的时候可以卸载所有模块:

```java
GodEye.instance().uninstallAll();
```

> 开发者也可以根据自己的需求安装模块,注意:network和startup模块不需要安装和卸载.
### STEP3

Debug面板安装,GodEyeMonitor类是AndroidGodEye的Debug监控面板的主要类,用来开始或者停止Debug面板的监控。

开始消费GodEye各个模块数据并输出到Debug面板:

```java
GodEyeMonitor.work(context)
```

结束消费,关闭Debug面板:

```java
GodEyeMonitor.shutDown()
```

### STEP4

完成!开始使用:

手机与pc连接同一网段,在pc浏览器中访问 手机ip+端口 即可看到Debug面板!

> 端口默认是5390,也可以在`GodEyeMonitor.work(context)`中指定,一般在开发者在调用`GodEyeMonitor.work(context)`之后可以看到日志输出 'Open AndroidGodEye dashboard ...' 中包含了访问地址。
## Debug开发者面板

###### 点击下面预览↓
<p>
<a href="https://player.youku.com/embed/XMzIwMTgyOTI5Mg==">
<img border="0" src="ART/android_god_eye_play.png" width="128" height="128" />
</a>
</p>

### 基本信息展示

![android_godeye_part1](ART/android_godeye_part1.png)

### 内存泄漏展示

![android_godeye_part5](ART/android_godeye_part5.png)

## 许可协议

AndroidGodEye使用 Apache2.0 许可协议。

## 关于我

- Github: [Kyson](https://github.com/Kyson)
- Weibo: [hikyson](https://weibo.com/hikyson)
- Blog: [tech.hikyson.cn](https://tech.hikyson.cn/)









Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
*/
public class LeakDetector extends ProduceableConsumer<LeakQueue.LeakMemoryInfo> implements Install<LeakContext> {

private boolean mInstalled;

private LeakDetector() {
}

Expand All @@ -48,10 +46,7 @@ public synchronized void install(LeakContext config) {
if (PermissionChecker.checkSelfPermission(config.application(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PermissionChecker.PERMISSION_GRANTED) {
throw new IllegalStateException("install leak need permission:" + Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
if (mInstalled) {
return;
}
mInstalled = true;
uninstall();
mLeakDirectoryProvider = new DefaultLeakDirectoryProvider(application);
try {
clearLeaks();
Expand All @@ -75,7 +70,9 @@ public void d(Throwable throwable, String s, Object... objects) {

@Override
public synchronized void uninstall() {
throw new UnsupportedOperationException("leak detector can not uninstall!");
mLeakDirectoryProvider = null;
LeakCanary.uninstall();
L.d("LeakCanary uninstalled");
}

private LeakDirectoryProvider mLeakDirectoryProvider;
Expand Down
Loading

0 comments on commit bd3d5b3

Please sign in to comment.