Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
DoraemonKit
提交
43fdb08e
D
DoraemonKit
项目概览
DiDi
/
DoraemonKit
12 个月 前同步成功
通知
166
Star
19623
Fork
3062
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DoraemonKit
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
43fdb08e
编写于
5月 13, 2021
作者:
金
金台
提交者:
GitHub
5月 13, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #812 from WizzXu/master
Android : 1.添加cpu,内存,FPS回调 2.添加网络扩展拦截器,可以自定义拦截器操作
上级
29ee665a
96df92b6
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
210 addition
and
11 deletion
+210
-11
Android/java/app/src/debug/java/com/didichuxing/doraemondemo/App.kt
...va/app/src/debug/java/com/didichuxing/doraemondemo/App.kt
+22
-1
Android/java/doraemonkit-no-op/src/main/java/com/didichuxing/doraemonkit/DoKit.kt
...-no-op/src/main/java/com/didichuxing/doraemonkit/DoKit.kt
+16
-0
Android/java/doraemonkit-no-op/src/main/java/com/didichuxing/doraemonkit/DoraemonKit.kt
.../src/main/java/com/didichuxing/doraemonkit/DoraemonKit.kt
+16
-0
Android/java/doraemonkit-no-op/src/main/java/com/didichuxing/doraemonkit/kit/network/okhttp/interceptor/DokitExtInterceptor.kt
...kit/kit/network/okhttp/interceptor/DokitExtInterceptor.kt
+27
-0
Android/java/doraemonkit-no-op/src/main/java/com/didichuxing/doraemonkit/kit/performance/PerformanceValueListener.kt
...g/doraemonkit/kit/performance/PerformanceValueListener.kt
+12
-0
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/DoKit.kt
...monkit/src/main/java/com/didichuxing/doraemonkit/DoKit.kt
+19
-1
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/DoKitReal.kt
...it/src/main/java/com/didichuxing/doraemonkit/DoKitReal.kt
+17
-0
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/DoraemonKit.kt
.../src/main/java/com/didichuxing/doraemonkit/DoraemonKit.kt
+18
-1
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/aop/OkHttpHook.java
...main/java/com/didichuxing/doraemonkit/aop/OkHttpHook.java
+3
-5
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/aop/urlconnection/HttpUrlConnectionProxyUtil.java
...emonkit/aop/urlconnection/HttpUrlConnectionProxyUtil.java
+4
-1
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/network/okhttp/interceptor/DokitExtInterceptor.kt
...kit/kit/network/okhttp/interceptor/DokitExtInterceptor.kt
+27
-0
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/performance/PerformanceDataManager.java
...g/doraemonkit/kit/performance/PerformanceDataManager.java
+17
-2
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/performance/PerformanceValueListener.kt
...g/doraemonkit/kit/performance/PerformanceValueListener.kt
+12
-0
未找到文件。
Android/java/app/src/debug/java/com/didichuxing/doraemondemo/App.kt
浏览文件 @
43fdb08e
...
...
@@ -14,10 +14,14 @@ import com.didichuxing.doraemondemo.dokit.TestSimpleDokitFragmentKit
import
com.didichuxing.doraemonkit.DoKit
import
com.didichuxing.doraemonkit.kit.AbstractKit
import
com.didichuxing.doraemonkit.kit.core.MCInterceptor
import
com.didichuxing.doraemonkit.kit.network.okhttp.interceptor.DokitExtInterceptor
import
com.didichuxing.doraemonkit.kit.performance.PerformanceValueListener
import
com.facebook.drawee.backends.pipeline.Fresco
import
com.facebook.imagepipeline.core.ImagePipelineConfig
import
com.lzy.okgo.OkGo
import
okhttp3.Interceptor
import
okhttp3.OkHttpClient
import
okhttp3.Response
/**
* @author jint
...
...
@@ -36,7 +40,6 @@ class App : Application() {
//是否显示入口icon
// DoraemonKit.setAwaysShowMainIcon(false);
val
kits
:
MutableList
<
AbstractKit
>
=
ArrayList
()
kits
.
add
(
DemoKit
())
kits
.
add
(
TestSimpleDokitFloatViewKit
())
...
...
@@ -106,6 +109,24 @@ class App : Application() {
return
false
}
})
.
setNetExtInterceptor
(
object
:
DokitExtInterceptor
.
DokitExtInterceptorProxy
{
override
fun
intercept
(
chain
:
Interceptor
.
Chain
):
Response
{
//LogUtils.e(DokitExtInterceptor.TAG, chain.request().url().toString())
return
chain
.
proceed
(
chain
.
request
())
}
})
.
setPerformanceValueListener
(
object
:
PerformanceValueListener
{
override
fun
onGetMemory
(
value
:
Float
)
{
}
override
fun
onGetCPU
(
value
:
Float
)
{
}
override
fun
onGetFPS
(
value
:
Float
)
{
}
})
.
build
()
...
...
Android/java/doraemonkit-no-op/src/main/java/com/didichuxing/doraemonkit/DoKit.kt
浏览文件 @
43fdb08e
...
...
@@ -3,6 +3,8 @@ package com.didichuxing.doraemonkit
import
android.app.Application
import
com.didichuxing.doraemonkit.kit.AbstractKit
import
com.didichuxing.doraemonkit.kit.core.MCInterceptor
import
com.didichuxing.doraemonkit.kit.network.okhttp.interceptor.DokitExtInterceptor
import
com.didichuxing.doraemonkit.kit.performance.PerformanceValueListener
import
com.didichuxing.doraemonkit.kit.webdoor.WebDoorManager
import
java.lang.NullPointerException
...
...
@@ -131,6 +133,20 @@ public class DoKit {
return
this
}
/**
* 设置扩展网络拦截器的代理对象
*/
fun
setNetExtInterceptor
(
extInterceptorProxy
:
DokitExtInterceptor
.
DokitExtInterceptorProxy
):
Builder
{
return
this
}
/**
* 设置CPU、内存、FPS每次采集后的回调
*/
fun
setPerformanceValueListener
(
performanceValueListener
:
PerformanceValueListener
):
Builder
{
return
this
}
fun
build
()
{
}
}
...
...
Android/java/doraemonkit-no-op/src/main/java/com/didichuxing/doraemonkit/DoraemonKit.kt
浏览文件 @
43fdb08e
...
...
@@ -3,6 +3,8 @@ package com.didichuxing.doraemonkit
import
android.app.Application
import
com.didichuxing.doraemonkit.kit.AbstractKit
import
com.didichuxing.doraemonkit.kit.core.MCInterceptor
import
com.didichuxing.doraemonkit.kit.network.okhttp.interceptor.DokitExtInterceptor
import
com.didichuxing.doraemonkit.kit.performance.PerformanceValueListener
import
com.didichuxing.doraemonkit.kit.webdoor.WebDoorManager
/**
...
...
@@ -109,4 +111,18 @@ object DoraemonKit {
@JvmStatic
fun
setMCIntercept
(
interceptor
:
MCInterceptor
)
{
}
/**
* 设置扩展网络拦截器的代理对象
*/
@JvmStatic
fun
setNetExtInterceptor
(
extInterceptorProxy
:
DokitExtInterceptor
.
DokitExtInterceptorProxy
){
}
/**
* 设置CPU、内存、FPS每次采集后的回调
*/
@JvmStatic
fun
setPerformanceValueListener
(
performanceValueListener
:
PerformanceValueListener
){
}
}
\ No newline at end of file
Android/java/doraemonkit-no-op/src/main/java/com/didichuxing/doraemonkit/kit/network/okhttp/interceptor/DokitExtInterceptor.kt
0 → 100644
浏览文件 @
43fdb08e
package
com.didichuxing.doraemonkit.kit.network.okhttp.interceptor
import
okhttp3.Interceptor
import
okhttp3.Response
import
java.io.IOException
/**
* Author: xuweiyu
* Date: 5/11/21
* Email: wizz.xu@outlook.com
* Description: Dokit 扩展网络拦截器
*/
class
DokitExtInterceptor
:
Interceptor
{
@Throws
(
IOException
::
class
)
override
fun
intercept
(
chain
:
Interceptor
.
Chain
):
Response
{
return
chain
.
proceed
(
chain
.
request
())
}
interface
DokitExtInterceptorProxy
{
fun
intercept
(
chain
:
Interceptor
.
Chain
):
Response
}
companion
object
{
const
val
TAG
=
"DokitExtInterceptor"
var
dokitExtInterceptorProxy
:
DokitExtInterceptorProxy
?
=
null
}
}
\ No newline at end of file
Android/java/doraemonkit-no-op/src/main/java/com/didichuxing/doraemonkit/kit/performance/PerformanceValueListener.kt
0 → 100644
浏览文件 @
43fdb08e
package
com.didichuxing.doraemonkit.kit.performance
/**
* Author: xuweiyu
* Date: 5/12/21
* Email: wizz.xu@outlook.com
* Description: cpu 内存 FPS 的回调监听
*/
interface
PerformanceValueListener
{
fun
onGetMemory
(
value
:
Float
)
fun
onGetCPU
(
value
:
Float
)
fun
onGetFPS
(
value
:
Float
)
}
\ No newline at end of file
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/DoKit.kt
浏览文件 @
43fdb08e
...
...
@@ -3,8 +3,9 @@ package com.didichuxing.doraemonkit
import
android.app.Application
import
com.didichuxing.doraemonkit.kit.AbstractKit
import
com.didichuxing.doraemonkit.kit.core.MCInterceptor
import
com.didichuxing.doraemonkit.kit.network.okhttp.interceptor.DokitExtInterceptor
import
com.didichuxing.doraemonkit.kit.performance.PerformanceValueListener
import
com.didichuxing.doraemonkit.kit.webdoor.WebDoorManager
import
java.lang.NullPointerException
/**
* ================================================
...
...
@@ -153,6 +154,23 @@ public class DoKit {
return
this
}
/**
* 设置扩展网络拦截器的代理对象
*/
fun
setNetExtInterceptor
(
extInterceptorProxy
:
DokitExtInterceptor
.
DokitExtInterceptorProxy
):
Builder
{
DoKitReal
.
setNetExtInterceptor
(
extInterceptorProxy
)
return
this
}
/**
* 设置CPU、内存、FPS每次采集后的回调
*/
fun
setPerformanceValueListener
(
performanceValueListener
:
PerformanceValueListener
):
Builder
{
DoKitReal
.
setPerformanceValueListener
(
performanceValueListener
)
return
this
}
fun
build
()
{
DoKitReal
.
install
(
app
,
mapKits
,
listKits
,
productId
)
}
...
...
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/DoKitReal.kt
浏览文件 @
43fdb08e
...
...
@@ -17,6 +17,9 @@ import com.didichuxing.doraemonkit.kit.gpsmock.ServiceHookManager
import
com.didichuxing.doraemonkit.kit.health.AppHealthInfoUtil
import
com.didichuxing.doraemonkit.kit.health.model.AppHealthInfo.DataBean.BigFileBean
import
com.didichuxing.doraemonkit.kit.network.NetworkManager
import
com.didichuxing.doraemonkit.kit.network.okhttp.interceptor.DokitExtInterceptor
import
com.didichuxing.doraemonkit.kit.performance.PerformanceDataManager
import
com.didichuxing.doraemonkit.kit.performance.PerformanceValueListener
import
com.didichuxing.doraemonkit.kit.timecounter.instrumentation.HandlerHooker
import
com.didichuxing.doraemonkit.kit.toolpanel.KitWrapItem
import
com.didichuxing.doraemonkit.kit.toolpanel.ToolPanelUtil
...
...
@@ -503,4 +506,18 @@ object DoKitReal {
DoKitConstant
.
MC_INTERCEPT
=
interceptor
}
/**
* 设置扩展网络拦截器的代理对象
*/
fun
setNetExtInterceptor
(
extInterceptorProxy
:
DokitExtInterceptor
.
DokitExtInterceptorProxy
){
DokitExtInterceptor
.
dokitExtInterceptorProxy
=
extInterceptorProxy
}
/**
* 设置CPU、内存、FPS每次采集后的回调
*/
fun
setPerformanceValueListener
(
performanceValueListener
:
PerformanceValueListener
)
{
PerformanceDataManager
.
getInstance
().
setPerformanceValueListener
(
performanceValueListener
)
}
}
\ No newline at end of file
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/DoraemonKit.kt
浏览文件 @
43fdb08e
package
com.didichuxing.doraemonkit
import
android.app.Application
import
android.util.Log
import
com.didichuxing.doraemonkit.kit.AbstractKit
import
com.didichuxing.doraemonkit.kit.core.MCInterceptor
import
com.didichuxing.doraemonkit.kit.network.okhttp.interceptor.DokitExtInterceptor
import
com.didichuxing.doraemonkit.kit.performance.PerformanceValueListener
import
com.didichuxing.doraemonkit.kit.webdoor.WebDoorManager.WebDoorCallback
/**
...
...
@@ -159,5 +160,21 @@ object DoraemonKit {
DoKitReal
.
setMCWSPort
(
port
)
}
/**
* 设置扩展网络拦截器的代理对象
*/
@JvmStatic
fun
setNetExtInterceptor
(
extInterceptorProxy
:
DokitExtInterceptor
.
DokitExtInterceptorProxy
){
DoKitReal
.
setNetExtInterceptor
(
extInterceptorProxy
)
}
/**
* 设置CPU、内存、FPS每次采集后的回调
*/
@JvmStatic
fun
setPerformanceValueListener
(
performanceValueListener
:
PerformanceValueListener
){
DoKitReal
.
setPerformanceValueListener
(
performanceValueListener
)
}
}
\ No newline at end of file
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/aop/OkHttpHook.java
浏览文件 @
43fdb08e
package
com.didichuxing.doraemonkit.aop
;
import
android.util.Log
;
import
com.didichuxing.doraemonkit.kit.network.okhttp.interceptor.AbsDoKitInterceptor
;
import
com.didichuxing.doraemonkit.kit.network.okhttp.interceptor.DokitCapInterceptor
;
import
com.didichuxing.doraemonkit.kit.network.okhttp.interceptor.Dokit
WeakNetwork
Interceptor
;
import
com.didichuxing.doraemonkit.kit.network.okhttp.interceptor.Dokit
Ext
Interceptor
;
import
com.didichuxing.doraemonkit.kit.network.okhttp.interceptor.DokitLargePicInterceptor
;
import
com.didichuxing.doraemonkit.kit.network.okhttp.interceptor.DokitMockInterceptor
;
import
com.didichuxing.doraemonkit.kit.network.okhttp.interceptor.DokitWeakNetworkInterceptor
;
import
com.didichuxing.doraemonkit.util.ReflectUtils
;
import
java.util.ArrayList
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
okhttp3.Interceptor
;
...
...
@@ -52,6 +49,7 @@ public class OkHttpHook {
interceptors
.
add
(
new
DokitMockInterceptor
());
interceptors
.
add
(
new
DokitLargePicInterceptor
());
interceptors
.
add
(
new
DokitCapInterceptor
());
interceptors
.
add
(
new
DokitExtInterceptor
());
networkInterceptors
.
add
(
new
DokitWeakNetworkInterceptor
());
//需要用反射重新赋值 因为源码中创建了一个不可变的list
ReflectUtils
.
reflect
(
client
).
field
(
"interceptors"
,
interceptors
);
...
...
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/aop/urlconnection/HttpUrlConnectionProxyUtil.java
浏览文件 @
43fdb08e
...
...
@@ -3,6 +3,7 @@ package com.didichuxing.doraemonkit.aop.urlconnection;
import
android.net.Uri
;
import
com.didichuxing.doraemonkit.kit.network.okhttp.interceptor.DokitCapInterceptor
;
import
com.didichuxing.doraemonkit.kit.network.okhttp.interceptor.DokitExtInterceptor
;
import
com.didichuxing.doraemonkit.kit.network.okhttp.interceptor.DokitWeakNetworkInterceptor
;
import
com.didichuxing.doraemonkit.kit.network.okhttp.interceptor.DokitLargePicInterceptor
;
import
com.didichuxing.doraemonkit.kit.network.okhttp.interceptor.DokitMockInterceptor
;
...
...
@@ -94,7 +95,9 @@ public class HttpUrlConnectionProxyUtil {
//添加dokit拦截器
.
addInterceptor
(
new
DokitCapInterceptor
())
//添加弱网 拦截器
.
addNetworkInterceptor
(
new
DokitWeakNetworkInterceptor
());
.
addNetworkInterceptor
(
new
DokitWeakNetworkInterceptor
())
// 添加扩展拦截器
.
addInterceptor
(
new
DokitExtInterceptor
());
}
/**
...
...
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/network/okhttp/interceptor/DokitExtInterceptor.kt
0 → 100644
浏览文件 @
43fdb08e
package
com.didichuxing.doraemonkit.kit.network.okhttp.interceptor
import
okhttp3.Interceptor
import
okhttp3.Response
import
java.io.IOException
/**
* Author: xuweiyu
* Date: 5/11/21
* Email: wizz.xu@outlook.com
* Description: Dokit 扩展网络拦截器
*/
class
DokitExtInterceptor
:
AbsDoKitInterceptor
()
{
@Throws
(
IOException
::
class
)
override
fun
intercept
(
chain
:
Interceptor
.
Chain
):
Response
{
return
dokitExtInterceptorProxy
?.
intercept
(
chain
)
?:
chain
.
proceed
(
chain
.
request
())
}
interface
DokitExtInterceptorProxy
{
fun
intercept
(
chain
:
Interceptor
.
Chain
):
Response
}
companion
object
{
const
val
TAG
=
"DokitExtInterceptor"
var
dokitExtInterceptorProxy
:
DokitExtInterceptorProxy
?
=
null
}
}
\ No newline at end of file
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/performance/PerformanceDataManager.java
浏览文件 @
43fdb08e
...
...
@@ -57,6 +57,10 @@ public class PerformanceDataManager {
private
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
/**
* 外部可以设置cpu 内存 fps的监听回调
*/
private
PerformanceValueListener
performanceValueListener
=
null
;
//private int mLastSkippedFrames;
/**
...
...
@@ -98,11 +102,13 @@ public class PerformanceDataManager {
private
void
executeCpuData
()
{
if
(
mAboveAndroidO
)
{
mLastCpuRate
=
getCpuDataForO
();
writeCpuDataIntoFile
();
}
else
{
mLastCpuRate
=
getCPUData
();
writeCpuDataIntoFile
();
}
if
(
performanceValueListener
!=
null
){
performanceValueListener
.
onGetCPU
(
mLastCpuRate
);
}
writeCpuDataIntoFile
();
}
/**
...
...
@@ -110,6 +116,9 @@ public class PerformanceDataManager {
*/
private
void
executeMemoryData
()
{
mLastMemoryRate
=
getMemoryData
();
if
(
performanceValueListener
!=
null
){
performanceValueListener
.
onGetMemory
(
mLastMemoryRate
);
}
writeMemoryDataIntoFile
();
}
...
...
@@ -495,6 +504,9 @@ public class PerformanceDataManager {
}
//保存fps数据
if
(
AppUtils
.
isAppForeground
())
{
if
(
performanceValueListener
!=
null
){
performanceValueListener
.
onGetFPS
(
mLastFrameRate
);
}
writeFpsDataIntoFile
();
}
totalFramesPerSecond
=
0
;
...
...
@@ -601,5 +613,8 @@ public class PerformanceDataManager {
}
public
void
setPerformanceValueListener
(
PerformanceValueListener
performanceValueListener
)
{
this
.
performanceValueListener
=
performanceValueListener
;
}
}
Android/java/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/performance/PerformanceValueListener.kt
0 → 100644
浏览文件 @
43fdb08e
package
com.didichuxing.doraemonkit.kit.performance
/**
* Author: xuweiyu
* Date: 5/12/21
* Email: wizz.xu@outlook.com
* Description: cpu 内存 FPS 的回调监听
*/
interface
PerformanceValueListener
{
fun
onGetMemory
(
value
:
Float
)
fun
onGetCPU
(
value
:
Float
)
fun
onGetFPS
(
value
:
Float
)
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录