Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【DoKit&北大开源实践】-【DoKit For Web】- FPS帧率实时显示 #1135

Open
wants to merge 27 commits into
base: didi/master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fa94237
feat:增加no-op接口
RealOnlyone Sep 26, 2022
14b2461
Merge pull request #1100 from didi/didi/master
RealOnlyone Jan 9, 2023
5500b50
feat: 升级booster版本到:4.13.0
RealOnlyone Feb 7, 2023
92e38c2
fix(iOS): concurrent inputStream callback falied (#1105)
yFeii Feb 9, 2023
fa19e19
Merge pull request #1112 from didi/release/3.7.11
RealOnlyone Mar 13, 2023
5ac76b2
feat(android): dokit plugin 改造
RealOnlyone Mar 22, 2023
af0047e
Merge tag 'android_dokit_v3.7.0.301' into feature/plugin
RealOnlyone Mar 22, 2023
0b921d0
feat(android): dokit plugin 改造优化
RealOnlyone Mar 23, 2023
84bdfce
feat(android): dokit mc 插件拦截处理
RealOnlyone Mar 27, 2023
e159dc9
feat(android): 升级版本 3.7.13-kotlin-13
RealOnlyone Mar 28, 2023
621ab1d
feat(android):优化插件配置
RealOnlyone Mar 28, 2023
c4d72db
feat(android):优化插件配置 升级版本 3.7.14-kotlin-13
RealOnlyone Mar 28, 2023
bee4004
bug(android):处理高德地图导航显示导航信息异常
RealOnlyone Mar 29, 2023
d4f0919
feat(android): 升级版本 3.7.14.6-kotlin-13
RealOnlyone Mar 29, 2023
3ac48eb
feat(web): 修改版本信息
AdamCaoQAQ Dec 6, 2021
d3c59e2
web_0.0.3-alpha.3
AdamCaoQAQ Dec 6, 2021
19a480c
feat: 修改部分一机多控逻辑
AdamCaoQAQ Apr 20, 2023
cccaf93
feat(android): 位置模拟支持更新速度
RealOnlyone Apr 20, 2023
61f3092
feat(web): playground 自动刷新
AdamCaoQAQ Apr 21, 2023
5becdc9
Merge pull request #1123 from didi/feature/dev-web
AdamCaoQAQ Apr 21, 2023
320f3e3
feat(android): 更多页面接口请求修改为https
RealOnlyone May 19, 2023
c519148
feat(android): 发布版本 3.7.14.9-kotlin-13
RealOnlyone May 30, 2023
4c0754f
Merge pull request #1131 from didi/dev
RealOnlyone May 30, 2023
43d0981
Update README.md
bbssyyuui Jun 28, 2023
d8482d5
add(components):fps
coucouish Jun 28, 2023
10ccc4d
add(components):fps
coucouish Jun 28, 2023
0c5ceb0
【DoKit&北大开源实践】-【DoKit For Web】- FPS帧率实时显示
coucouish Jun 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions Android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,22 @@ android {

//dokit 扩展

//dokitExt {
// //通用设置
// comm {
// //地图经纬度开关
// gpsSwitch true
// //网络开关
// networkSwitch true
// //大图开关
// bigImgSwitch true
// //webView js 抓包
// webViewSwitch true
// }

dokit {
gpsEnable true
bigImageEnable true
webView {
network true
dokitWeb true
vConsole true
}
gps {
didi true
baidu true
}
}

//dokit {
//
// slowMethod {
// //调用栈模式配置
Expand Down
2 changes: 0 additions & 2 deletions Android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
<uses-permission
android:name="android.permission.READ_FRAME_BUFFER"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" /> <!-- tencent Android Q新增权限,允许应用在后台发起定位,如应用target为Q,请添加此权限 -->
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> <!-- tencent 如果设置了target >= 28 如果需要启动后台定位则必须声明这个权限 -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <!-- 用于进行网络定位 -->
Expand Down
2 changes: 1 addition & 1 deletion Android/app/src/main/res/values-en-rUS/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<resources>
<string name="app_name">DoKitDemo</string>
<string name="app_name">DoKit</string>
<string name="app_build_types">BuildType</string>
<string name="app_btn_jump">Jump Other Activity</string>
<string name="app_btn_mc">MC</string>
Expand Down
2 changes: 1 addition & 1 deletion Android/app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<resources>
<string name="app_name">DoKitDemo</string>
<string name="app_name">DoKit</string>
<string name="app_build_types">当前编译环境</string>
<string name="app_btn_jump">跳转其他Activity</string>
<string name="app_btn_mc">一机多控</string>
Expand Down
2 changes: 1 addition & 1 deletion Android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<resources>
<string name="app_name">DoKitDemo</string>
<string name="app_name">DoKit</string>
<string name="dk_kit_demo">demo</string>
<string name="dk_titlebar_back">&#060;</string>
<string name="app_build_types">当前编译环境</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fun MethodNode.isEmptyMethod(): Boolean {

fun MethodNode.isMainMethod(className: String): Boolean {
if (this.name == "main" && this.desc == "([Ljava/lang/String;)V") {
// "====isMainMethod====$className ${this.name} ${this.desc} ${this.access}".println()
"====isMainMethod====$className ${this.name} ${this.desc} ${this.access}".println()
return true
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.didichuxing.doraemonkit.plugin

import com.didichuxing.doraemonkit.plugin.extension.CommExt
import com.didichuxing.doraemonkit.plugin.extension.DoKitExt
import com.didichuxing.doraemonkit.plugin.extension.SlowMethodExt
import org.gradle.api.Project
import com.didichuxing.doraemonkit.plugin.extension.DoKitExtension
import com.didichuxing.doraemonkit.plugin.extension.SlowMethodExtension
import com.didichuxing.doraemonkit.plugin.thirdlib.ThirdLibInfo

/**
* ================================================
Expand All @@ -16,20 +15,11 @@ import org.gradle.api.Project
*/
object DoKitExtUtil {

/**
* 是否包含dokitx-rpc模块
*/
var HAS_DOKIT_RPC_MODULE = false
//private var mApplicationId: String = ""

var HAS_DOKIT_TCP_HOOK_DJ = false

var DOKIT_GPS_MOCK_INCLUDE = false

/**
* 三方库版本信息
*/
// val THIRD_LIB_INFOS = mutableMapOf<String, ThirdLibInfo>()

val THIRD_LIB_INFOS = mutableListOf<ThirdLibInfo>()

Expand Down Expand Up @@ -64,7 +54,7 @@ object DoKitExtUtil {
/**
* 慢函数策略 默认为函数调用栈策略
*/
var SLOW_METHOD_STRATEGY = SlowMethodExt.STRATEGY_STACK
var SLOW_METHOD_STRATEGY = SlowMethodExtension.STRATEGY_STACK

private val applications: MutableSet<String> = mutableSetOf()

Expand All @@ -73,9 +63,8 @@ object DoKitExtUtil {
*/
private var appPackageName: String = ""

var commExt = CommExt()
private set
val slowMethodExt = SlowMethodExt()

val slowMethodExt = SlowMethodExtension()


fun dokitPluginSwitchOpen(): Boolean {
Expand All @@ -97,9 +86,8 @@ object DoKitExtUtil {
* @param dokitEx dokitExtension
* @param appExtension appExtension
*/
fun init(dokitEx: DoKitExt) {
fun init(dokitEx: DoKitExtension) {
//设置普通的配置
commExt = dokitEx.comm
//slowMethodExt.strategy = dokitEx.slowMethod.strategy
//slowMethodExt.methodSwitch = dokitEx.slowMethod.methodSwitch
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,56 @@ package com.didichuxing.doraemonkit.plugin

import com.android.build.gradle.AppExtension
import com.android.build.gradle.LibraryExtension
import com.didichuxing.doraemonkit.plugin.extension.DoKitExt
import com.didichuxing.doraemonkit.plugin.extension.SlowMethodExt
import com.didichuxing.doraemonkit.plugin.extension.DoKitExtension
import com.didichuxing.doraemonkit.plugin.extension.SlowMethodExtension
import com.didichuxing.doraemonkit.plugin.processor.DoKitPluginConfigProcessor
import com.didichuxing.doraemonkit.plugin.stack_method.MethodStackNodeUtil
import com.didichuxing.doraemonkit.plugin.thirdlib.ThirdLibVariantProcessor
import com.didichuxing.doraemonkit.plugin.transform.*
import com.didiglobal.booster.gradle.GTE_V3_4
import com.didiglobal.booster.gradle.dependencies
import com.didiglobal.booster.gradle.getAndroid
import com.didiglobal.booster.gradle.getProperty
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.result.ResolvedArtifactResult


/**
* when 也可以用来取代 if-else if链。
* 如果不提供参数,所有的分支条件都是简单的布尔表达式,而当一个分支的条件为真时则执行该分支:
*/

/**
* 作用域函数:let、run、with、apply 以及 also
* 它们的唯一目的是在对象的上下文中执行代码块
* 由于作用域函数本质上都非常相似,因此了解它们之间的区别很重要。每个作用域函数之间有两个主要区别:
* 引用上下文对象的方式:
* 作为 lambda 表达式的接收者(this)或者作为 lambda 表达式的参数(it)
* run、with 以及 apply 通过关键字 this 引用上下文对象
* let 及 also 将上下文对象作为 lambda 表达式参数
*
* 返回值:
* apply 及 also 返回上下文对象。
* let、run 及 with 返回 lambda 表达式结果.
*/
/**
* 函数 对象引用 返回值 是否是扩展函数
* let it Lambda 表达式结果 是
* run this Lambda 表达式结果 是
* run - Lambda 表达式结果 不是:调用无需上下文对象
* with this Lambda 表达式结果 不是:把上下文对象当做参数
* apply this 上下文对象 是
* also it 上下文对象 是
*/

/**
*对一个非空(non-null)对象执行 lambda 表达式:let
*将表达式作为变量引入为局部作用域中:let
*对象配置:apply
*对象配置并且计算结果:run
*在需要表达式的地方运行语句:非扩展的 run
*附加效果:also
*一个对象的一组函数调用:with
*/

/**
* ================================================
Expand All @@ -23,58 +61,26 @@ import org.gradle.api.artifacts.result.ResolvedArtifactResult
* 描 述:
* 修订历史:
* ================================================
*
* DoKit 插件入口
*/

class DoKitPlugin : Plugin<Project> {
override fun apply(project: Project) {
//创建指定扩展 并将project 传入构造函数
val doKitExt = project.extensions.create("dokitExt", DoKitExt::class.java)
val doKit = project.extensions.create("dokit", DoKitExtension::class.java)
"dokit plugin apply ${doKit}".println()

project.gradle.addListener(DoKitTransformTaskExecutionListener(project))

//println("project.plugins===>${project.plugins}")
/**
* when 也可以用来取代 if-else if链。
* 如果不提供参数,所有的分支条件都是简单的布尔表达式,而当一个分支的条件为真时则执行该分支:
*/

/**
* 作用域函数:let、run、with、apply 以及 also
* 它们的唯一目的是在对象的上下文中执行代码块
* 由于作用域函数本质上都非常相似,因此了解它们之间的区别很重要。每个作用域函数之间有两个主要区别:
* 引用上下文对象的方式:
* 作为 lambda 表达式的接收者(this)或者作为 lambda 表达式的参数(it)
* run、with 以及 apply 通过关键字 this 引用上下文对象
* let 及 also 将上下文对象作为 lambda 表达式参数
*
* 返回值:
* apply 及 also 返回上下文对象。
* let、run 及 with 返回 lambda 表达式结果.
*/
/**
* 函数 对象引用 返回值 是否是扩展函数
* let it Lambda 表达式结果 是
* run this Lambda 表达式结果 是
* run - Lambda 表达式结果 不是:调用无需上下文对象
* with this Lambda 表达式结果 不是:把上下文对象当做参数
* apply this 上下文对象 是
* also it 上下文对象 是
*/

/**
*对一个非空(non-null)对象执行 lambda 表达式:let
*将表达式作为变量引入为局部作用域中:let
*对象配置:apply
*对象配置并且计算结果:run
*在需要表达式的地方运行语句:非扩展的 run
*附加效果:also
*一个对象的一组函数调用:with
*/

when {
project.plugins.hasPlugin("com.android.application") || project.plugins.hasPlugin("com.android.dynamic-feature") -> {
if (!isReleaseTask(project)) {
project.getAndroid<AppExtension>().let { androidExt ->
val pluginSwitch = project.getProperty("DOKIT_PLUGIN_SWITCH", true)
val logSwitch = project.getProperty("DOKIT_LOG_SWITCH", false)

val slowMethodSwitch = project.getProperty("DOKIT_METHOD_SWITCH", false)
val slowMethodStrategy = project.getProperty("DOKIT_METHOD_STRATEGY", 0)
val methodStackLevel = project.getProperty("DOKIT_METHOD_STACK_LEVEL", 5)
Expand All @@ -94,7 +100,7 @@ class DoKitPlugin : Plugin<Project> {
if (DoKitExtUtil.DOKIT_PLUGIN_SWITCH) {
//注册transform
androidExt.registerTransform(commNewInstance(project))
if (slowMethodSwitch && slowMethodStrategy == SlowMethodExt.STRATEGY_STACK) {
if (slowMethodSwitch && slowMethodStrategy == SlowMethodExtension.STRATEGY_STACK) {
MethodStackNodeUtil.METHOD_STACK_KEYS.add(0, mutableSetOf<String>())
val methodStackRange = 1 until methodStackLevel
if (methodStackLevel > 1) {
Expand All @@ -111,14 +117,6 @@ class DoKitPlugin : Plugin<Project> {
}
}

//项目评估完毕回调
// project.afterEvaluate { project ->
// "===afterEvaluate===".println()
// androidExt.applicationVariants.forEach { variant ->
// DoKitPluginConfigProcessor(project).process(variant)
// }
// }

/**
* 所有项目的build.gradle执行完毕
* wiki:https://juejin.im/post/6844903607679057934
Expand All @@ -127,6 +125,7 @@ class DoKitPlugin : Plugin<Project> {
project.gradle.projectsEvaluated {
"===projectsEvaluated===".println()
androidExt.applicationVariants.forEach { variant ->
ThirdLibVariantProcessor(project).process(variant)
DoKitPluginConfigProcessor(project).process(variant)
}

Expand All @@ -136,6 +135,7 @@ class DoKitPlugin : Plugin<Project> {
//task依赖关系图建立完毕
project.gradle.taskGraph.whenReady {
"===taskGraph.whenReady===".println()
"dokit config :: ${doKit}".println()
}

}
Expand All @@ -152,6 +152,7 @@ class DoKitPlugin : Plugin<Project> {
}
project.afterEvaluate {
libraryExt.libraryVariants.forEach { variant ->
ThirdLibVariantProcessor(project).process(variant)
DoKitPluginConfigProcessor(project).process(variant)
}
}
Expand All @@ -168,8 +169,8 @@ class DoKitPlugin : Plugin<Project> {
}

private fun commNewInstance(project: Project): DoKitBaseTransform = when {
GTE_V3_4 -> DoKitCommTransformV34(project)
else -> DoKitCommTransform(project)
GTE_V3_4 -> DoKitCommonTransformV34(project)
else -> DoKitCommonTransform(project)
}

private fun dependNewInstance(project: Project, index: Int): DoKitBaseTransform = when {
Expand All @@ -178,4 +179,4 @@ class DoKitPlugin : Plugin<Project> {
}


}
}
Loading