Skip to content

Commit 36bd1e3

Browse files
authored
Merge pull request #578 from Tencent/dev
v0.9.0
2 parents 7092f24 + 3c00210 commit 36bd1e3

File tree

134 files changed

+2868
-3019
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+2868
-3019
lines changed

README.md

Lines changed: 68 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![Matrix-icon](assets/img/readme/header.png)
22

3-
[![license](http://img.shields.io/badge/license-BSD3-brightgreen.svg?style=flat)](https://github.com/Tencent/matrix/blob/master/LICENSE)[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Tencent/matrix/pulls)[![WeChat Approved](https://img.shields.io/badge/Wechat%20Approved-0.8.0-red.svg)](https://github.com/Tencent/matrix/wiki)
3+
[![license](http://img.shields.io/badge/license-BSD3-brightgreen.svg?style=flat)](https://github.com/Tencent/matrix/blob/master/LICENSE)[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Tencent/matrix/pulls)[![WeChat Approved](https://img.shields.io/badge/Wechat%20Approved-0.9.0-red.svg)](https://github.com/Tencent/matrix/wiki)
44

55
(中文版本请参看[这里](#matrix_cn))
66

@@ -136,6 +136,11 @@ At this point, Matrix has been integrated into the app and is beginning to colle
136136

137137
Detect the file IO issues, including performance of file IO and closeable leak
138138

139+
- **Battery Canary:**
140+
141+
App thread activities monitor (Background watch & foreground loop watch), Sonsor usage monitor (WakeLock/Alarm/Gps/Wifi/Bluetooth), Background network activities (Wifi/Mobile) monitor.
142+
143+
139144
## Features
140145
#### APK Checker
141146

@@ -168,12 +173,17 @@ At this point, Matrix has been integrated into the app and is beginning to colle
168173
- **More feature.** Including performance of file IO and closeable leak.
169174
- **Compatible with Android P.**
170175

176+
#### Battery Canary
177+
- **Easy-to-use.** Use out of box (unit tests as example).
178+
- **More feature.** Flexible extending with base and utils APIs.
179+
180+
171181
## Getting Started
172182
***The JCenter repository will stop service on February 1, 2022. So we uploaded Matrix(since 0.8.0) to the MavenCentral repository.***
173183

174184
1. Configure `MATRIX_VERSION` in gradle.properties.
175185
``` gradle
176-
MATRIX_VERSION=0.8.0
186+
MATRIX_VERSION=0.9.0
177187
```
178188

179189
2. Add `matrix-gradle-plugin` in your build.gradle:
@@ -194,6 +204,7 @@ At this point, Matrix has been integrated into the app and is beginning to colle
194204
implementation group: "com.tencent.matrix", name: "matrix-resource-canary-common", version: MATRIX_VERSION, changing: true
195205
implementation group: "com.tencent.matrix", name: "matrix-io-canary", version: MATRIX_VERSION, changing: true
196206
implementation group: "com.tencent.matrix", name: "matrix-sqlite-lint-android-sdk", version: MATRIX_VERSION, changing: true
207+
implementation group: "com.tencent.matrix", name: "matrix-battery-canary", version: MATRIX_VERSION, changing: true
197208
}
198209
199210
apply plugin: 'com.tencent.matrix-plugin'
@@ -288,15 +299,34 @@ Matrix gradle plugin could work with Android Gradle Plugin 3.5.0/4.0.0/4.1.0 cur
288299
For more Matrix configurations, look at the [sample](https://github.com/Tencent/matrix/tree/dev/samples/sample-android).
289300

290301
Note:
291-
You can get more about Matrix output at the wiki [The output of Matrix](https://github.com/Tencent/matrix/wiki/Matrix-Android--data-format);
302+
1. Since Matrix for Android has migrated to AndroidX since v0.9.0. You may need to add 'android.useAndroidX=true' flag to gradle.properties
303+
2. You can get more about Matrix output at the wiki [The output of Matrix](https://github.com/Tencent/matrix/wiki/Matrix-Android--data-format);
304+
305+
306+
#### Battery Canary Usage
307+
308+
Init BatteryCanary as the following codes:
309+
```java
310+
BatteryMonitorConfig config = new BatteryMonitorConfig.Builder()
311+
.enable(JiffiesMonitorFeature.class)
312+
.enableStatPidProc(true)
313+
.greyJiffiesTime(30 * 1000L)
314+
.setCallback(new BatteryMonitorCallback.BatteryPrinter())
315+
.build();
316+
317+
BatteryMonitorPlugin plugin = new BatteryMonitorPlugin(config);
318+
```
319+
320+
For detail usage, please reference showcase tests at `com.tencent.matrix.batterycanary.ApisTest` or `sample.tencent.matrix.battery.BatteryCanaryInitHelper`.
321+
292322

293323
#### APK Checker Usage
294324

295-
APK Checker can run independently in Jar ([matrix-apk-canary-0.8.0.jar](https://repo.maven.apache.org/maven2/com/tencent/matrix/matrix-apk-canary/0.8.0/matrix-apk-canary-0.8.0.jar)) mode, usage:
325+
APK Checker can run independently in Jar ([matrix-apk-canary-0.9.0.jar](https://repo.maven.apache.org/maven2/com/tencent/matrix/matrix-apk-canary/0.9.0/matrix-apk-canary-0.9.0.jar)) mode, usage:
296326

297327

298328
```shell
299-
java -jar matrix-apk-canary-0.8.0.jar
329+
java -jar matrix-apk-canary-0.9.0.jar
300330
Usages:
301331
--config CONFIG-FILE-PATH
302332
or
@@ -355,7 +385,7 @@ Matrix is under the BSD license. See the [LICENSE](https://github.com/Tencent/Ma
355385
356386
# <a name="matrix_cn">Matrix</a>
357387
![Matrix-icon](assets/img/readme/header.png)
358-
[![license](http://img.shields.io/badge/license-BSD3-brightgreen.svg?style=flat)](https://github.com/Tencent/matrix/blob/master/LICENSE)[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Tencent/matrix/pulls) [![WeChat Approved](https://img.shields.io/badge/Wechat%20Approved-0.8.0-red.svg)](https://github.com/Tencent/matrix/wiki)
388+
[![license](http://img.shields.io/badge/license-BSD3-brightgreen.svg?style=flat)](https://github.com/Tencent/matrix/blob/master/LICENSE)[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Tencent/matrix/pulls) [![WeChat Approved](https://img.shields.io/badge/Wechat%20Approved-0.9.0-red.svg)](https://github.com/Tencent/matrix/wiki)
359389
360390
**Matrix** 是一款微信研发并日常使用的应用性能接入框架,支持iOS, macOS和Android。
361391
Matrix 通过接入各种性能监控方案,对性能监控项的异常数据进行采集和分析,输出相应的问题分析、定位与优化建议,从而帮助开发者开发出更高质量的应用。
@@ -472,6 +502,8 @@ Matrix-android 当前监控范围包括:应用安装包大小,帧率变化
472502
按官方最佳实践自动化检测 SQLite 语句的使用质量
473503
- IO Canary:
474504
检测文件 IO 问题,包括:文件 IO 监控和 Closeable Leak 监控
505+
- Battery Canary:
506+
监控 App 活跃线程(待机状态 & 前台 Loop 监控)、ASM 调用 (WakeLock/Alarm/Gps/Wifi/Bluetooth 等传感器)、 后台流量 (Wifi/移动网络)等 Battery Historian 统计 App 耗电的数据
475507

476508
## 特性
477509

@@ -508,12 +540,18 @@ Matrix-android 当前监控范围包括:应用安装包大小,帧率变化
508540
- 性能、泄漏全面监控,对 IO 质量心中有数
509541
- 兼容到 Android P
510542

543+
#### Battery Canary
544+
545+
- 接入简单,开箱即用
546+
- 预留 Base 类和 Utility 工具以便扩展监控特性
547+
548+
511549
## 使用方法
512550
***由于 JCenter 服务将于 2022 年 2 月 1 日下线,我们已将 Matrix 新版本(>= 0.8.0) maven repo 发布至 MavenCentral。***
513551

514552
1. 在你项目根目录下的 gradle.properties 中配置要依赖的 Matrix 版本号,如:
515553
``` gradle
516-
MATRIX_VERSION=0.8.0
554+
MATRIX_VERSION=0.9.0
517555
```
518556

519557
2. 在你项目根目录下的 build.gradle 文件添加 Matrix 依赖,如:
@@ -533,6 +571,7 @@ Matrix-android 当前监控范围包括:应用安装包大小,帧率变化
533571
implementation group: "com.tencent.matrix", name: "matrix-resource-canary-common", version: MATRIX_VERSION, changing: true
534572
implementation group: "com.tencent.matrix", name: "matrix-io-canary", version: MATRIX_VERSION, changing: true
535573
implementation group: "com.tencent.matrix", name: "matrix-sqlite-lint-android-sdk", version: MATRIX_VERSION, changing: true
574+
implementation group: "com.tencent.matrix", name: "matrix-battery-canary", version: MATRIX_VERSION, changing: true
536575
}
537576
538577
apply plugin: 'com.tencent.matrix-plugin'
@@ -626,14 +665,33 @@ Matrix-android 当前监控范围包括:应用安装包大小,帧率变化
626665
至此,Matrix就已成功集成到你的项目中,并且开始收集和分析性能相关异常数据,如仍有疑问,请查看 [示例](https://github.com/Tencent/Matrix/tree/dev/samples/sample-android/).
627666
628667
PS:
629-
Matrix 分析后的输出字段的含义请查看 [Matrix 输出内容的含义解析](https://github.com/Tencent/matrix/wiki/Matrix-Android--data-format)
668+
1. 从 v0.9.0 开始,Matrix for Android 迁移到了 AndroidX. 你可能需要添加 'android.useAndroidX=true' 标志到 gradle.properties 文件里。
669+
2. Matrix 分析后的输出字段的含义请查看 [Matrix 输出内容的含义解析](https://github.com/Tencent/matrix/wiki/Matrix-Android--data-format)
670+
671+
672+
#### Battery Canary Usage
673+
674+
相关初始化代码如下:
675+
```java
676+
BatteryMonitorConfig config = new BatteryMonitorConfig.Builder()
677+
.enable(JiffiesMonitorFeature.class)
678+
.enableStatPidProc(true)
679+
.greyJiffiesTime(30 * 1000L)
680+
.setCallback(new BatteryMonitorCallback.BatteryPrinter())
681+
.build();
682+
683+
BatteryMonitorPlugin plugin = new BatteryMonitorPlugin(config);
684+
```
685+
686+
具体使用方式,请参考单元测试里相关用例的代码: `com.tencent.matrix.batterycanary.ApisTest` 或 `sample.tencent.matrix.battery.BatteryCanaryInitHelper`.
687+
630688
631689
#### APK Checker
632690
633-
APK Check 以独立的 jar 包提供 ([matrix-apk-canary-0.8.0.jar](https://repo.maven.apache.org/maven2/com/tencent/matrix/matrix-apk-canary/0.8.0/matrix-apk-canary-0.8.0.jar)),你可以运行:
691+
APK Check 以独立的 jar 包提供 ([matrix-apk-canary-0.9.0.jar](https://repo.maven.apache.org/maven2/com/tencent/matrix/matrix-apk-canary/0.9.0/matrix-apk-canary-0.9.0.jar)),你可以运行:
634692
635693
```cmd
636-
java -jar matrix-apk-canary-0.8.0.jar
694+
java -jar matrix-apk-canary-0.9.0.jar
637695
```
638696
639697
查看 Usages 来使用它。

matrix/matrix-android/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,5 @@ task generateVersionTxt() {
104104
file.write(rootProject.ext.VERSION_NAME)
105105
}
106106
}
107+
108+
//apply from: file("gradle/bintray-to-maven-central.gradle")

matrix/matrix-android/checkstyle_suppressions.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@
77
<suppressions>
88
<suppress files=".*[/\\]src[/\\]test[/\\].*" checks="Javadoc.*"/>
99
<suppress files=".*RequestBuilder.java" checks="NoClone"/>
10+
<suppress files=".*[/\\]src[/\\]androidTest[/\\].*" checks="[a-zA-Z0-9]*"/>
11+
<suppress files=".*[/\\]src[/\\]test[/\\].*" checks="[a-zA-Z0-9]*"/>
1012
</suppressions>

matrix/matrix-android/gradle.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryErro
1515
#Tue Jun 20 10:24:33 CST 2017
1616

1717

18-
VERSION_NAME_PREFIX=0.8.1
18+
VERSION_NAME_PREFIX=0.9.0
1919
VERSION_NAME_SUFFIX=
2020
## two options: Internal (for wechat), External (for public repo)
21-
PUBLISH_CHANNEL=Internal
21+
PUBLISH_CHANNEL=Internal
22+
android.useAndroidX=true

0 commit comments

Comments
 (0)