Merge branch 'dev_minibus-d_230425_3.2.0' into merge320tomaster
This commit is contained in:
188
app/build.gradle
188
app/build.gradle
@@ -4,130 +4,18 @@ import groovy.json.JsonSlurper
|
||||
import java.text.SimpleDateFormat
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'com.alibaba.arouter'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
apply plugin: 'android-aspectjx'
|
||||
apply plugin: 'bugly'
|
||||
|
||||
def isReleaseBuild = isReleaseBuild()
|
||||
//apply ByteX宿主
|
||||
if (!isAndroidTestBuild()) {
|
||||
apply plugin: 'bytex'
|
||||
ByteX {
|
||||
enable true
|
||||
enableInDebug true
|
||||
logLevel "DEBUG"
|
||||
}
|
||||
}
|
||||
|
||||
if (!isAndroidTestBuild()) {
|
||||
apply plugin: 'bytex.notsticky.service'
|
||||
}
|
||||
|
||||
if (!isAndroidTestBuild()) {
|
||||
apply plugin: 'chain.log.hook'
|
||||
hooklog {
|
||||
enableTraceToServer false
|
||||
enableLoggerToLocal false
|
||||
}
|
||||
|
||||
apply plugin: 'biz.config.hook'
|
||||
}
|
||||
|
||||
if (!isAndroidTestBuild()) {
|
||||
apply plugin: 'apm-plugin'
|
||||
}
|
||||
|
||||
if (!isAndroidTestBuild()) {
|
||||
apply plugin: 'bytex.threadOpt'
|
||||
thread_opt {
|
||||
enable false
|
||||
enableInDebug false
|
||||
logLevel "DEBUG"
|
||||
}
|
||||
}
|
||||
|
||||
if (!isAndroidTestBuild()) {
|
||||
apply plugin: 'LancetX'
|
||||
LancetX {
|
||||
enable true
|
||||
enableInDebug true
|
||||
|
||||
weaveGroup {
|
||||
anr_fix {
|
||||
enable true
|
||||
}
|
||||
crash_fix {
|
||||
enable true
|
||||
}
|
||||
memory_leak {
|
||||
enable true
|
||||
}
|
||||
textview_opt {
|
||||
enable true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if (!isAndroidTestBuild()) {
|
||||
// /**
|
||||
// * 方便使用systrace工具,在工程侧打点,便于分析工程侧性能问题
|
||||
// */
|
||||
// apply plugin: 'bytex.systrace'
|
||||
// systrace {
|
||||
// /**
|
||||
// * 交付时要关闭,会有性能损耗
|
||||
// */
|
||||
// enable false
|
||||
// enableInDebug false
|
||||
// /**
|
||||
// * - 是否使用[Trace.beginAsyncSection(String, int)/Trace.endAsyncSection(String, int)]进行打点
|
||||
// * - 默认使用[Trace.beginSection(String)/Trace.endSection()]进行打点
|
||||
// */
|
||||
// isTraceAsync false
|
||||
// /**
|
||||
// * - 是否在运行时只针对主线程打点,其它线程不打
|
||||
// */
|
||||
// isOnlyMainThread false
|
||||
//
|
||||
// /**
|
||||
// * - 是否忽略对类的静态构造方法打点
|
||||
// * - 默认不忽略
|
||||
// */
|
||||
// isIgnoreClinitMethod false
|
||||
//
|
||||
// /**
|
||||
// * - 是否忽略对类中的简单方法打点
|
||||
// * 简单方法定义:
|
||||
// * - 空方法
|
||||
// * - get/set 方法
|
||||
// * - 单独的方法,方法体内没有调用其它方法
|
||||
// * - 默认不忽略
|
||||
// */
|
||||
// isIgnoreSampleMethod false
|
||||
//
|
||||
// /**
|
||||
// * - 针对特定类集合,配置打点白名单,在此集合中的类中的所有方法不打点
|
||||
// * - 支持正则表达式
|
||||
// */
|
||||
// whiteListForClass = []
|
||||
//
|
||||
// /**
|
||||
// * - 针对特定包名集合,配置打点白名单,所有类以此包名为前缀的类不打点
|
||||
// * - 支持正则表达式
|
||||
// */
|
||||
// whiteListForPackage = []
|
||||
// }
|
||||
//}
|
||||
apply from: rootProject.file('gradle/bytex/bytex.gradle')
|
||||
|
||||
bugly {
|
||||
appId = 'ac71228f85' // 注册时分配的App ID
|
||||
appKey = '3c736249-d6be-4066-b577-b7a6dc975cf7' // 注册时分配的App Key
|
||||
}
|
||||
|
||||
Properties properties = new Properties();
|
||||
Properties properties = new Properties()
|
||||
properties.load(project.rootProject.file("gradle.properties").newDataInputStream())
|
||||
|
||||
android {
|
||||
@@ -153,6 +41,7 @@ android {
|
||||
exclude 'META-INF/proguard/coroutines.pro'
|
||||
exclude 'META-INF/*'
|
||||
exclude "/lib/armeabi-v7a/*.so"
|
||||
pickFirst 'lib/arm64-v8a/libc++_shared.so'
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
@@ -198,11 +87,12 @@ android {
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility 1.8
|
||||
targetCompatibility 1.8
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
checkReleaseBuilds false
|
||||
abortOnError false
|
||||
}
|
||||
|
||||
@@ -249,7 +139,11 @@ android {
|
||||
buildConfigField 'String', 'URLs', "\"${readFileToJson("dali").replace("\"", "\\\"")}\""
|
||||
buildConfigField 'String', 'tempConfig', "\"${readFileToJsonTemp("dali").replace("\"", "\\\"")}\""
|
||||
}
|
||||
|
||||
saas {
|
||||
dimension "project"
|
||||
buildConfigField 'String', 'URLs', "\"${readFileToJson("saas").replace("\"", "\\\"")}\""
|
||||
buildConfigField 'String', 'tempConfig', "\"${readFileToJsonTemp("saas").replace("\"", "\\\"")}\""
|
||||
}
|
||||
// 配置网络环境,QA、线上、演示
|
||||
qa {
|
||||
dimension "env"
|
||||
@@ -301,11 +195,6 @@ repositories {
|
||||
}
|
||||
}
|
||||
|
||||
aspectjx {
|
||||
include "com.mogo.eagle.core.function.chat"
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
||||
implementation rootProject.ext.dependencies.androidxappcompat
|
||||
@@ -317,6 +206,7 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.android_start_up
|
||||
implementation rootProject.ext.dependencies.lancetx_runtime
|
||||
implementation rootProject.ext.dependencies.mogocustommap
|
||||
|
||||
implementation project(':core:function-impl:mogo-core-function-startup')
|
||||
implementation project(':core:function-impl:mogo-core-function-devatools')
|
||||
implementation project(':core:function-impl:mogo-core-function-datacenter')
|
||||
@@ -324,6 +214,7 @@ dependencies {
|
||||
implementation project(':core:function-impl:mogo-core-function-hmi')
|
||||
implementation project(':core:function-impl:mogo-core-function-map')
|
||||
implementation project(':core:function-impl:mogo-core-function-chat')
|
||||
implementation project(':core:function-impl:mogo-core-function-patch')
|
||||
implementation project(':foudations:mogo-commons')
|
||||
implementation project(':core:mogo-core-function-call')
|
||||
implementation project(':core:mogo-core-utils')
|
||||
@@ -342,37 +233,9 @@ dependencies {
|
||||
androidTestImplementation rootProject.ext.dependencies.androidx_runner
|
||||
androidTestImplementation rootProject.ext.dependencies.androidx_espresso_core
|
||||
androidTestImplementation rootProject.ext.dependencies.localbroadcastmanager
|
||||
|
||||
// if (isAndroidTestBuild()) {
|
||||
// implementation "com.mogo.thread.opt:lib:${THREAD_OPT_VERSION}"
|
||||
// }
|
||||
androidTestImplementation rootProject.ext.dependencies.downloader
|
||||
}
|
||||
|
||||
if (!isAndroidTestBuild()) {
|
||||
ApmPlugin {
|
||||
// 是否进行插桩
|
||||
enable true
|
||||
// 是否在Debug包插桩,默认不插桩
|
||||
enableInDebug true
|
||||
// DEBUG("DEBUG"), INFO("INFO"), WARN("WARN"), ERROR("ERROR");
|
||||
// INFO 级别Log会汇总所有被插桩处理的类供查看,路径 app/build/ByteX/ApmPlugin
|
||||
logLevel "DEBUG"
|
||||
// 启动分析开关:监控App启动耗时,需要同时开启pageLoadSwitch
|
||||
startSwitch = true
|
||||
// 页面响应开关:监控Activity的生命周期耗时
|
||||
pageLoadSwitch = true
|
||||
// 网络监控开关:监控okhttp3的网络请求
|
||||
okHttp3Switch = false
|
||||
// 白名单下的包进行插桩,需要填写要插装类所在的包名,支持前缀配置
|
||||
whiteList = [
|
||||
"com.mogo"
|
||||
]
|
||||
// 黑名单包下类不进行插桩,可以配置包名和类名,没有可以填空
|
||||
blackList = [
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
android.applicationVariants.all { variant ->
|
||||
def buildTime = new Date().format("yyyyMMdd", TimeZone.getTimeZone("GMT+08:00"))
|
||||
@@ -427,26 +290,7 @@ static def getBuildTime() {
|
||||
return "\"${buildTime}\""
|
||||
}
|
||||
|
||||
|
||||
boolean isAndroidTestBuild() {
|
||||
for (String s : gradle.startParameter.taskNames) {
|
||||
if (s.contains("AndroidTest")) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
boolean isReleaseBuild() {
|
||||
for (String s : gradle.startParameter.taskNames) {
|
||||
if (s.contains("Release") | s.contains("release")) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Object readFileToJson(env){
|
||||
Object readFileToJson(env) {
|
||||
try {
|
||||
// 加载config.json 文件
|
||||
File file = new File("${rootDir}/app/config/urlConfig.json")
|
||||
@@ -476,7 +320,7 @@ def variantName() {
|
||||
|
||||
if (taskName.contains("Yantai")) {
|
||||
project.dependencies.add('implementation', project.project(':tts:tts-iflytek'))
|
||||
}else if (taskName.contains("Mogo")) {
|
||||
}else if (taskName.contains("Mogo") || taskName.contains("Saas")) {
|
||||
project.dependencies.add('implementation', project.project(':tts:tts-pad'))
|
||||
}else if (taskName.contains("Dali")) {
|
||||
project.dependencies.add('implementation', project.project(':tts:tts-pad'))
|
||||
|
||||
@@ -196,5 +196,87 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"saas": {
|
||||
"shuttlepassenger": {
|
||||
"ads": [
|
||||
{
|
||||
"path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg",
|
||||
"type": 0,
|
||||
"cacheImgPath": "",
|
||||
"title": "1"
|
||||
},
|
||||
{
|
||||
"path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png",
|
||||
"type": 0,
|
||||
"cacheImgPath": "",
|
||||
"title": "2"
|
||||
},
|
||||
{
|
||||
"path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357557335/3.mp4",
|
||||
"type": 1,
|
||||
"cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png",
|
||||
"title": "3"
|
||||
},
|
||||
{
|
||||
"path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg",
|
||||
"type": 0,
|
||||
"cacheImgPath": "",
|
||||
"title": "4"
|
||||
},
|
||||
{
|
||||
"path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v",
|
||||
"type": 0,
|
||||
"cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg",
|
||||
"title": "5"
|
||||
},
|
||||
{
|
||||
"path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676358660379/6.m4v",
|
||||
"type": 1,
|
||||
"cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg",
|
||||
"title": "6"
|
||||
},
|
||||
{
|
||||
"path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360154589/7.jpg",
|
||||
"type": 0,
|
||||
"cacheImgPath": "",
|
||||
"title": "7"
|
||||
},
|
||||
{
|
||||
"path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360185500/8.jpg",
|
||||
"type": 0,
|
||||
"cacheImgPath": "",
|
||||
"title": "8"
|
||||
},
|
||||
{
|
||||
"path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png",
|
||||
"type": 0,
|
||||
"cacheImgPath": "",
|
||||
"title": "9"
|
||||
},
|
||||
{
|
||||
"path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4",
|
||||
"type": 1,
|
||||
"cacheImgPath": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png",
|
||||
"title": "10"
|
||||
}
|
||||
]
|
||||
},
|
||||
"shuttlepassengerm2": {
|
||||
"ads": [
|
||||
{
|
||||
"path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681716116231/6923474a99a1983c9a0410ad3357888d.mov",
|
||||
"type": 1,
|
||||
"cacheImgPath": "",
|
||||
"title": "1"
|
||||
},
|
||||
{
|
||||
"path": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681716116231/6923474a99a1983c9a0410ad3357888d.mov",
|
||||
"type": 1,
|
||||
"cacheImgPath": "",
|
||||
"title": "2"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
"socket_tech_url": "https://och-a.zhidaozhixing.com/arch/",
|
||||
"eagle_mis_url": "http://eagle-mis-a.zhidaozhixing.com/",
|
||||
"eagle_dns_url": "http://eagle-dns-a.zhidaozhixing.com/",
|
||||
"bind_driver_qr_url": "https://tech.zhidaohulian.com?pipe=asafety&sn=%1$s",
|
||||
"bind_driver_qr_url": "https://och-mini-eh.zhidaozhixing.com?pipe=ehsafety&sn=%1$s",
|
||||
"chart_socket_url":"wss://acp-eh.zhidaozhixing.com/ws"
|
||||
},
|
||||
"online": {
|
||||
@@ -85,7 +85,7 @@
|
||||
"socket_tech_url": "https://och-a.zhidaozhixing.com/arch/",
|
||||
"eagle_mis_url": "http://eagle-mis-a.zhidaozhixing.com/",
|
||||
"eagle_dns_url": "http://eagle-dns-a.zhidaozhixing.com/",
|
||||
"bind_driver_qr_url": "https://tech.zhidaohulian.com?pipe=asafety&sn=%1$s",
|
||||
"bind_driver_qr_url": "https://och-mini-yt.zhidaozhixing.com?pipe=ytsafety&sn=%1$s",
|
||||
"chart_socket_url":""
|
||||
},
|
||||
"online": {
|
||||
@@ -112,5 +112,40 @@
|
||||
"bind_driver_qr_url": "https://tech.zhidaohulian.com?pipe=ytsafety&sn=%1$s",
|
||||
"chart_socket_url":""
|
||||
}
|
||||
},
|
||||
"saas": {
|
||||
"qa": {
|
||||
"och_url": "https://och-a.zhidaozhixing.com",
|
||||
"shuttle_url": "https://och-a.zhidaozhixing.com",
|
||||
"passport_url": "https://och-a.zhidaozhixing.com/arch/passport/",
|
||||
"socket_base_url": "https://och-a.zhidaozhixing.com/arch/push/",
|
||||
"socket_tech_url": "https://och-a.zhidaozhixing.com/arch/",
|
||||
"eagle_mis_url": "http://eagle-mis-a.zhidaozhixing.com/",
|
||||
"eagle_dns_url": "http://eagle-dns-a.zhidaozhixing.com/",
|
||||
"bind_driver_qr_url": "https://tech.zhidaohulian.com?pipe=asafety&sn=%1$s",
|
||||
"chart_socket_url":""
|
||||
},
|
||||
"online": {
|
||||
"och_url": "https://tech.zhidaohulian.com",
|
||||
"shuttle_url": "https://mogogo-driver.zhidaozhixing.com",
|
||||
"passport_url": "https://mogogo-driver.zhidaozhixing.com/arch/passport/",
|
||||
"socket_base_url": "https://mogogo-driver.zhidaozhixing.com/arch/push/",
|
||||
"socket_tech_url": "https://mogogo-driver.zhidaozhixing.com/arch/",
|
||||
"eagle_mis_url": "https://mogogo.zhidaozhixing.com/",
|
||||
"eagle_dns_url": "https://mogogo.zhidaozhixing.com/",
|
||||
"bind_driver_qr_url": "https://tech.zhidaohulian.com?pipe=asafety&sn=%1$s",
|
||||
"chart_socket_url":""
|
||||
},
|
||||
"demo": {
|
||||
"och_url": "http://tech-dev.zhidaohulian.com",
|
||||
"shuttle_url": "https://mogogo-driver.zhidaozhixing.com",
|
||||
"passport_url": "https://mogogo-driver.zhidaozhixing.com/arch/passport/",
|
||||
"socket_base_url": "https://mogogo-driver.zhidaozhixing.com/arch/push/",
|
||||
"socket_tech_url": "https://mogogo-driver.zhidaozhixing.com/arch/",
|
||||
"eagle_mis_url": "https://mogogo.zhidaozhixing.com/",
|
||||
"eagle_dns_url": "https://mogogo.zhidaozhixing.com/",
|
||||
"bind_driver_qr_url": "",
|
||||
"chart_socket_url":""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
16
app/matrixTrace/blackMethodList.txt
Normal file
16
app/matrixTrace/blackMethodList.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
[package]
|
||||
-keeppackage com/mogo/thread/ext/
|
||||
-keeppackage com/mogo/launcher
|
||||
-keeppackage com/rousetime/android_startup/
|
||||
-keeppackage com/mogo/systrace/
|
||||
-keeppackage com/bytedance/boost_multidex/
|
||||
-keeppackage io/netty/
|
||||
-keeppackage com/elegant/log/
|
||||
-keeppackage org/slf4j/
|
||||
-keeppackage kotlin/
|
||||
-keepclass com.mogo.eagle.core.function.main.MainMoGoApplication
|
||||
-keepclass com.mogo.commons.AbsMogoApplication
|
||||
-keepclass com.bytedance.apm.agent.v2.instrumentation.AppAgent
|
||||
-keepclass androidx.core.app.CoreComponentFactory
|
||||
-keepclass com.mogo.eagle.core.utilcode.util.ProcessUtils
|
||||
-keepclass com.mogo.eagle.core.utilcode.mogo.AppLaunchTimeUtils
|
||||
@@ -50,5 +50,16 @@
|
||||
"driver": ["ochM1"],
|
||||
"passenger": ["ochM1"]
|
||||
}
|
||||
},
|
||||
"saas": {
|
||||
"shuttle" :{
|
||||
"driver": ["ochJL","ochM2"],
|
||||
"passenger": ["ochJL","ochM2"]
|
||||
},
|
||||
"bus" :{
|
||||
"driver": ["ochJL"],
|
||||
"driverpassenger": ["ochJL"],
|
||||
"passenger": ["ochJL"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ project.android.variantFilter { variant ->
|
||||
def vehicleContain = true
|
||||
roleValue.each{vehicleValue->
|
||||
if (names.contains(vehicleValue)) {
|
||||
println "need $names"
|
||||
//println "need $names"
|
||||
vehicleContain = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
apply from: "./script/utils.gradle"
|
||||
// 网约车服务:仅小巴车、出租车渠道用
|
||||
project.dependencies {
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
@@ -14,7 +15,46 @@ project.dependencies {
|
||||
// fMultiDisplayOchTaxiImplementation(rootProject.ext.dependencies.mogoochtaxi)
|
||||
|
||||
} else {
|
||||
fPadLenovoImplementation (project(':OCH:mogo-och-noop'))
|
||||
|
||||
if (isCurrentDriver("noop")) {
|
||||
noopImplementation(project(':OCH:mogo-och-noop'))
|
||||
} else if (isCurrentDriver("bus")) {
|
||||
implementation project.project(':OCH:mogo-och-bus')
|
||||
} else if (isCurrentPassenger("bus")) {
|
||||
implementation project.project(':OCH:mogo-och-bus-passenger')
|
||||
} else if (isCurrentDriver("charter")) {
|
||||
implementation project.project(':OCH:mogo-och-charter')
|
||||
} else if (isCurrentPassenger("charter")) {
|
||||
implementation project.project(':OCH:mogo-och-charter-passenger')
|
||||
} else if (isCurrentDriver("shuttle")) {
|
||||
implementation project(':OCH:mogo-och-shuttle')
|
||||
} else if (isCurrentPassenger("shuttle")) {
|
||||
implementation project.project(':OCH:mogo-och-shuttle-passenger')
|
||||
} else if (isCurrentDriver("sweeperCloud")) {
|
||||
implementation project.project(':OCH:sweeper:sweeper-cloud')
|
||||
} else if (isCurrentDriver("sweeperOperate")) {
|
||||
implementation project.project(':OCH:sweeper:sweeper')
|
||||
} else if (isCurrentDriver("taxi")) {
|
||||
implementation project.project(':OCH:mogo-och-taxi')
|
||||
} else if (isCurrentPassenger("taxi")) {
|
||||
implementation project.project(':OCH:mogo-och-taxi-passenger')
|
||||
} else {
|
||||
noopImplementation(project(':OCH:mogo-och-noop'))
|
||||
implementation project.project(':OCH:mogo-och-bus')
|
||||
implementation project.project(':OCH:mogo-och-bus-passenger')
|
||||
implementation project.project(':OCH:mogo-och-charter')
|
||||
implementation project.project(':OCH:mogo-och-charter-passenger')
|
||||
implementation project.project(':OCH:mogo-och-shuttle')
|
||||
implementation project.project(':OCH:mogo-och-shuttle-passenger')
|
||||
implementation project.project(':OCH:sweeper:sweeper-cloud')
|
||||
implementation project.project(':OCH:sweeper:sweeper')
|
||||
implementation project.project(':OCH:mogo-och-taxi')
|
||||
implementation project.project(':OCH:mogo-och-taxi-passenger')
|
||||
}
|
||||
|
||||
if(isCurrentFlavors("sweeperCloud")){
|
||||
project.dependencies.add('implementation', project.project(':OCH:sweeper:sweeper-cloud'))
|
||||
}
|
||||
|
||||
// 多屏幕-Bus司机端
|
||||
// fMultiDisplayOchBusImplementation (project(':OCH:mogo-och-bus'))
|
||||
|
||||
@@ -19,18 +19,16 @@ project.android.productFlavors {
|
||||
// ②连接的工控机IP地址
|
||||
buildConfigField 'String', 'ADAS_CONNECT_IP', "\"192.168.8.102\""
|
||||
|
||||
// ③是否需要重写状态栏
|
||||
buildConfigField 'boolean', 'IS_REPLACE_STATUSVIEW', 'false'
|
||||
if (isCurrentDriver("bus")) {
|
||||
// ③是否需要重写状态栏
|
||||
buildConfigField 'boolean', 'IS_REPLACE_STATUSVIEW', 'false'
|
||||
} else if (isCurrentPassenger("bus")) {
|
||||
// ③是否需要重写状态栏
|
||||
buildConfigField 'boolean', 'IS_REPLACE_STATUSVIEW', 'true'
|
||||
}
|
||||
|
||||
// ④构建 是否支持多屏异显异交互
|
||||
buildConfigField 'boolean', 'IS_MULTI_DISPLAY', 'false'
|
||||
|
||||
if(isCurrentDriver("bus")){
|
||||
project.dependencies.add('implementation', project.project(':OCH:mogo-och-bus'))
|
||||
}
|
||||
if(isCurrentPassenger("bus")){
|
||||
project.dependencies.add('implementation', project.project(':OCH:mogo-och-bus-passenger'))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
apply from: "./script/utils.gradle"
|
||||
|
||||
|
||||
project.android.productFlavors {
|
||||
// 包车业务
|
||||
@@ -24,12 +24,11 @@ project.android.productFlavors {
|
||||
if(isCurrentDriver("charter")){
|
||||
// ③是否需要重写状态栏
|
||||
buildConfigField 'boolean', 'IS_REPLACE_STATUSVIEW', 'false'
|
||||
project.dependencies.add('implementation', project.project(':OCH:mogo-och-charter'))
|
||||
}
|
||||
if(isCurrentPassenger("charter")){
|
||||
}else if(isCurrentPassenger("charter")){
|
||||
// ③是否需要重写状态栏
|
||||
buildConfigField 'boolean', 'IS_REPLACE_STATUSVIEW', 'true'
|
||||
project.dependencies.add('implementation', project.project(':OCH:mogo-och-charter-passenger'))
|
||||
}else {
|
||||
buildConfigField 'boolean', 'IS_REPLACE_STATUSVIEW', 'true'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,10 +23,5 @@ project.android.productFlavors {
|
||||
|
||||
// ④构建 是否支持多屏异显异交互
|
||||
buildConfigField 'boolean', 'IS_MULTI_DISPLAY', 'false'
|
||||
|
||||
if(isCurrentDriver("noop")){
|
||||
project.dependencies.add('implementation', project.project(':OCH:mogo-och-noop'))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -23,26 +23,28 @@ project.android.productFlavors {
|
||||
buildConfigField 'boolean', 'IS_REPLACE_STATUSVIEW', 'false'
|
||||
// ④构建 是否支持多屏异显异交互
|
||||
buildConfigField 'boolean', 'IS_MULTI_DISPLAY', 'false'
|
||||
project.dependencies.add('implementation', project.project(':OCH:mogo-och-shuttle'))
|
||||
manifestPlaceholders.put("SCREEN_ORIENTATION", "landscape")
|
||||
}
|
||||
if (isCurrentPassenger("shuttle")) {
|
||||
if(isM2()){
|
||||
} else if (isCurrentPassenger("shuttle")) {
|
||||
if (isM2()) {
|
||||
// ③是否需要重写状态栏
|
||||
buildConfigField 'boolean', 'IS_REPLACE_STATUSVIEW', 'true'
|
||||
// ④构建 是否支持多屏异显异交互
|
||||
buildConfigField 'boolean', 'IS_MULTI_DISPLAY', 'false'
|
||||
manifestPlaceholders.put("SCREEN_ORIENTATION", "portrait")
|
||||
}
|
||||
if(isJL()){
|
||||
if (isJL()) {
|
||||
// ③是否需要重写状态栏
|
||||
buildConfigField 'boolean', 'IS_REPLACE_STATUSVIEW', 'false'
|
||||
buildConfigField 'boolean', 'IS_REPLACE_STATUSVIEW', 'true'
|
||||
// ④构建 是否支持多屏异显异交互
|
||||
buildConfigField 'boolean', 'IS_MULTI_DISPLAY', 'true'
|
||||
manifestPlaceholders.put("SCREEN_ORIENTATION", "landscape")
|
||||
}
|
||||
|
||||
project.dependencies.add('implementation', project.project(':OCH:mogo-och-shuttle-passenger'))
|
||||
} else {
|
||||
// ③是否需要重写状态栏
|
||||
buildConfigField 'boolean', 'IS_REPLACE_STATUSVIEW', 'true'
|
||||
// ④构建 是否支持多屏异显异交互
|
||||
buildConfigField 'boolean', 'IS_MULTI_DISPLAY', 'true'
|
||||
manifestPlaceholders.put("SCREEN_ORIENTATION", "landscape")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,10 +23,5 @@ project.android.productFlavors {
|
||||
|
||||
// ④构建 是否支持多屏异显异交互
|
||||
buildConfigField 'boolean', 'IS_MULTI_DISPLAY', 'false'
|
||||
|
||||
|
||||
if(isCurrentFlavors("sweeperOperate")){
|
||||
project.dependencies.add('implementation', project.project(':OCH:sweeper:sweeper'))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,14 +21,13 @@ project.android.productFlavors {
|
||||
buildConfigField 'boolean', 'IS_MULTI_DISPLAY', 'false'
|
||||
|
||||
if (isCurrentDriver("taxi")) {
|
||||
project.dependencies.add('implementation', project.project(':OCH:mogo-och-taxi'))
|
||||
// 在启动的时候把Task给清空
|
||||
manifestPlaceholders.put("ACTIVITY_ROOT", true)
|
||||
}
|
||||
if (isCurrentPassenger("taxi")) {
|
||||
project.dependencies.add('implementation', project.project(':OCH:mogo-och-taxi-passenger'))
|
||||
}else if (isCurrentPassenger("taxi")) {
|
||||
// 在启动的时候把Task给清空
|
||||
manifestPlaceholders.put("ACTIVITY_ROOT", false)
|
||||
}else {
|
||||
manifestPlaceholders.put("ACTIVITY_ROOT", false)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,9 +25,6 @@ project.android.productFlavors {
|
||||
// ②车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0
|
||||
buildConfigField 'int', 'CAR_MACHINE_TYPE', '2'
|
||||
|
||||
// ③是否需要实时上报坐标
|
||||
buildConfigField 'boolean', 'IS_NEED_UPLOAD_COORDINATES_IN_TIME', 'true'
|
||||
|
||||
// ④GPS数据提供源: 0-Android系统,1-工控机,2-OBU
|
||||
buildConfigField 'int', 'GPS_PROVIDER', "1"
|
||||
|
||||
|
||||
@@ -25,9 +25,6 @@ project.android.productFlavors {
|
||||
// ②车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0
|
||||
buildConfigField 'int', 'CAR_MACHINE_TYPE', '2'
|
||||
|
||||
// ③是否需要实时上报坐标
|
||||
buildConfigField 'boolean', 'IS_NEED_UPLOAD_COORDINATES_IN_TIME', 'true'
|
||||
|
||||
// ④GPS数据提供源: 0-Android系统,1-工控机,2-OBU
|
||||
buildConfigField 'int', 'GPS_PROVIDER', "1"
|
||||
|
||||
|
||||
@@ -24,8 +24,6 @@ project.android.productFlavors {
|
||||
// ②车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0
|
||||
buildConfigField 'int', 'CAR_MACHINE_TYPE', '2'
|
||||
|
||||
// ③是否需要实时上报坐标
|
||||
buildConfigField 'boolean', 'IS_NEED_UPLOAD_COORDINATES_IN_TIME', 'true'
|
||||
// ④GPS数据提供源: 0-Android系统,1-工控机,2-OBU
|
||||
buildConfigField 'int', 'GPS_PROVIDER', "1"
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ project.android.productFlavors {
|
||||
ochJL {
|
||||
dimension "vehicle"
|
||||
matchingFallbacks = ['jinlvvan']
|
||||
missingDimensionStrategy "vehicle", "jinlvvan", "m2", "jinlvvan"
|
||||
|
||||
// 配置AndroidManifest.xml中用到的参数
|
||||
manifestPlaceholders = [
|
||||
|
||||
@@ -4,6 +4,8 @@ project.android.productFlavors {
|
||||
// 金旅M1车
|
||||
ochM1 {
|
||||
dimension "vehicle"
|
||||
matchingFallbacks = ['driverm1']
|
||||
missingDimensionStrategy "vehicle", "driverm1","m2", "jinlvvan"
|
||||
|
||||
// 配置AndroidManifest.xml中用到的参数
|
||||
manifestPlaceholders = [
|
||||
@@ -19,12 +21,5 @@ project.android.productFlavors {
|
||||
// ③不能启动自驾的档位
|
||||
buildConfigField 'boolean', 'IS_CAR_MODEL_CHANGE', 'false'
|
||||
|
||||
if(isDriver()){
|
||||
matchingFallbacks = ['driverm1']
|
||||
}
|
||||
if(isPassenger()){
|
||||
matchingFallbacks = ['m1']
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,7 @@ project.android.productFlavors {
|
||||
dimension "vehicle"
|
||||
// 和 och/mogo-och-bus-passenger 的flavors的m2对应
|
||||
matchingFallbacks = ['m2']
|
||||
|
||||
|
||||
missingDimensionStrategy "vehicle", "m2", "jinlvvan", 'driverm1'
|
||||
//高德地图鉴权信息
|
||||
manifestPlaceholders = [
|
||||
CHANNEL_VALUE_TAIL: "M2",
|
||||
|
||||
BIN
app/src/androidTest/assets/HelloActivity.zip
Normal file
BIN
app/src/androidTest/assets/HelloActivity.zip
Normal file
Binary file not shown.
@@ -0,0 +1,88 @@
|
||||
//package com.mogo.functions.test
|
||||
//
|
||||
//import android.util.*
|
||||
//import androidx.test.core.app.*
|
||||
//import androidx.test.ext.junit.runners.*
|
||||
//import androidx.test.filters.*
|
||||
//import androidx.test.platform.app.InstrumentationRegistry
|
||||
//import com.mogo.eagle.core.function.hmi.ui.*
|
||||
//import com.mogo.eagle.core.function.main.*
|
||||
//import com.mogo.eagle.core.utilcode.util.*
|
||||
//import kotlinx.coroutines.*
|
||||
//import org.junit.*
|
||||
//import org.junit.runner.*
|
||||
//import java.util.concurrent.*
|
||||
//import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
//import kotlin.Result
|
||||
//
|
||||
//@RunWith(AndroidJUnit4::class)
|
||||
//@LargeTest
|
||||
//class ApkInstallerTest {
|
||||
//
|
||||
//
|
||||
// lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
//
|
||||
// @Before
|
||||
// fun before() {
|
||||
// launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testInstall(): Unit = runBlocking {
|
||||
// Log.d("RWJ", "wait fragment show ...")
|
||||
// val f = ensureMoGoHmiFragmentShow()
|
||||
// Log.d("RWJ", "fragment showed, delay 10s ...")
|
||||
// delay(10000)
|
||||
//
|
||||
// Log.d("RWJ", "10s end, start install ...")
|
||||
// val context = InstrumentationRegistry.getInstrumentation().context
|
||||
// ApkInstaller.installApp(f.requireContext(), context.assets.open("190000013.apk")) { code, msg ->
|
||||
// Log.d("RWJ", "code: $code, msg: $msg")
|
||||
// }
|
||||
// Log.d("RWJ", "开始延时10分钟....")
|
||||
// delay(TimeUnit.MINUTES.toMillis(10))
|
||||
// Log.d("RWJ", "延时10分钟结束....")
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// fun testInstall2(): Unit = runBlocking {
|
||||
// Log.d("RWJ", "wait fragment show ...")
|
||||
// val f = ensureMoGoHmiFragmentShow()
|
||||
// Log.d("RWJ", "fragment showed, delay 10s ...")
|
||||
// delay(10000)
|
||||
//
|
||||
// Log.d("RWJ", "10s end, start install ...")
|
||||
// val context = InstrumentationRegistry.getInstrumentation().context
|
||||
// ApkInstaller.installApp(f.requireContext(), context.assets.open("HelloActivity.zip")) { code, msg ->
|
||||
// Log.d("RWJ", "code: $code, msg: $msg")
|
||||
// }
|
||||
// Log.d("RWJ", "开始延时10分钟....")
|
||||
// delay(TimeUnit.MINUTES.toMillis(10))
|
||||
// Log.d("RWJ", "延时10分钟结束....")
|
||||
// }
|
||||
//
|
||||
// private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiFragment = suspendCancellableCoroutine {
|
||||
// launch.onActivity { itx ->
|
||||
// val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
// executor.scheduleAtFixedRate({
|
||||
// var find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiFragment } as? MoGoHmiFragment
|
||||
// while (find == null) {
|
||||
// find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiFragment } as? MoGoHmiFragment
|
||||
// }
|
||||
// while (!find.isResumed) {
|
||||
// Thread.sleep(500)
|
||||
// }
|
||||
// it.resumeWith(Result.success(find))
|
||||
// try {
|
||||
// Thread.sleep(500)
|
||||
// executor.shutdownNow()
|
||||
// } catch (e: Throwable) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// }, 50, 500, MILLISECONDS)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -1,148 +1,148 @@
|
||||
package com.mogo.functions.test
|
||||
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
|
||||
import com.mogo.eagle.core.function.hmi.ui.MoGoHmiProvider
|
||||
import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.*
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import record_cache.RecordPanelOuterClass
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.random.Random
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class AutoPilotBadCaseTest {
|
||||
|
||||
private lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
|
||||
@Before
|
||||
fun launch() {
|
||||
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
}
|
||||
|
||||
@ExperimentalCoroutinesApi
|
||||
@Test
|
||||
fun showBadCaseEntrance1(): Unit = runBlocking(Dispatchers.Main) {
|
||||
ensureMoGoHmiFragmentShow()
|
||||
delay(TimeUnit.MILLISECONDS.toSeconds(30))
|
||||
var index = 0
|
||||
(1 until 50)
|
||||
.map { it }
|
||||
.asFlow()
|
||||
.onEach {
|
||||
delay(TimeUnit.SECONDS.toMillis(5))
|
||||
val builder = RecordPanelOuterClass.RecordPanel.newBuilder()
|
||||
builder.also {
|
||||
it.diskFree = (100 + index).toLong()
|
||||
it.duration = 60.0.toFloat()
|
||||
it.filename = "/user/general/record_$index.log"
|
||||
it.id = 10 + index
|
||||
it.key = index.toLong()
|
||||
it.stat = 100
|
||||
it.type = 1
|
||||
it.timestamp = SimpleDateFormat("yyyyMMddHHmmss").format(Date())
|
||||
index++
|
||||
}
|
||||
// CallerDevaToolsManager.onReceiveBadCaseRecord(builder.build())
|
||||
}
|
||||
.flowOn(Dispatchers.Default)
|
||||
.collect()
|
||||
delay(TimeUnit.HOURS.toMillis(2))
|
||||
}
|
||||
|
||||
|
||||
@ExperimentalCoroutinesApi
|
||||
@Test
|
||||
fun showBadCaseEntrance2(): Unit = runBlocking(Dispatchers.Main) {
|
||||
ensureMoGoHmiFragmentShow()
|
||||
var index = 0
|
||||
(1 until 50)
|
||||
.map { it }
|
||||
.asFlow()
|
||||
.onEach {
|
||||
if (index in 1..4) {
|
||||
delay(TimeUnit.SECONDS.toMillis(15))
|
||||
} else {
|
||||
delay(Random(20).nextLong())
|
||||
}
|
||||
val builder = RecordPanelOuterClass.RecordPanel.newBuilder()
|
||||
builder.also {
|
||||
it.diskFree = (100 + index).toLong()
|
||||
it.duration = 60.0.toFloat()
|
||||
it.filename = "/user/general/record_$index.log"
|
||||
it.id = 10 + index
|
||||
it.key = index.toLong()
|
||||
it.stat = 100
|
||||
it.type = 1
|
||||
it.timestamp = SimpleDateFormat("yyyyMMddHHmmss").format(Date())
|
||||
index++
|
||||
}
|
||||
// CallerDevaToolsManager.onReceiveBadCaseRecord(builder.build())
|
||||
}
|
||||
.flowOn(Dispatchers.Default)
|
||||
.collect()
|
||||
delay(TimeUnit.HOURS.toMillis(2))
|
||||
}
|
||||
|
||||
@ExperimentalCoroutinesApi
|
||||
@Test
|
||||
fun showBadCaseEntrance3(): Unit = runBlocking(Dispatchers.Main) {
|
||||
var index = 0
|
||||
(1 until 50)
|
||||
.map { it }
|
||||
.asFlow()
|
||||
.onEach {
|
||||
delay(TimeUnit.SECONDS.toMillis(20))
|
||||
val builder = RecordPanelOuterClass.RecordPanel.newBuilder()
|
||||
builder.also {
|
||||
it.diskFree = (100 + index).toLong()
|
||||
it.duration = 60.0.toFloat()
|
||||
it.filename = "/user/general/record_$index.log"
|
||||
it.id = 10 + index
|
||||
it.key = index.toLong()
|
||||
it.stat = 100
|
||||
it.type = 1
|
||||
it.timestamp = SimpleDateFormat("yyyyMMddHHmmss").format(Date())
|
||||
index++
|
||||
}
|
||||
// CallerDevaToolsManager.onReceiveBadCaseRecord(builder.build())
|
||||
}
|
||||
.flowOn(Dispatchers.Default)
|
||||
.collect()
|
||||
delay(TimeUnit.HOURS.toMillis(2))
|
||||
}
|
||||
|
||||
private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiProvider = suspendCancellableCoroutine {
|
||||
launch.onActivity { itx ->
|
||||
val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
executor.scheduleAtFixedRate({
|
||||
var find =
|
||||
itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
while (find == null) {
|
||||
find =
|
||||
itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
|
||||
}
|
||||
while (!find.isResumed) {
|
||||
Thread.sleep(500)
|
||||
}
|
||||
it.resumeWith(Result.success(find))
|
||||
try {
|
||||
Thread.sleep(500)
|
||||
executor.shutdownNow()
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}, 50, 500, TimeUnit.MILLISECONDS)
|
||||
}
|
||||
}
|
||||
}
|
||||
//package com.mogo.functions.test
|
||||
//
|
||||
//import androidx.test.core.app.ActivityScenario
|
||||
//import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
//import androidx.test.filters.LargeTest
|
||||
//import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
|
||||
//import com.mogo.eagle.core.function.hmi.ui.MoGoHmiProvider
|
||||
//import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
//import kotlinx.coroutines.*
|
||||
//import kotlinx.coroutines.flow.*
|
||||
//import org.junit.Before
|
||||
//import org.junit.Test
|
||||
//import org.junit.runner.RunWith
|
||||
//import record_cache.RecordPanelOuterClass
|
||||
//import java.text.SimpleDateFormat
|
||||
//import java.util.*
|
||||
//import java.util.concurrent.Executors
|
||||
//import java.util.concurrent.TimeUnit
|
||||
//import kotlin.random.Random
|
||||
//
|
||||
//@RunWith(AndroidJUnit4::class)
|
||||
//@LargeTest
|
||||
//class AutoPilotBadCaseTest {
|
||||
//
|
||||
// private lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
//
|
||||
// @Before
|
||||
// fun launch() {
|
||||
// launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
// }
|
||||
//
|
||||
// @ExperimentalCoroutinesApi
|
||||
// @Test
|
||||
// fun showBadCaseEntrance1(): Unit = runBlocking(Dispatchers.Main) {
|
||||
// ensureMoGoHmiFragmentShow()
|
||||
// delay(TimeUnit.MILLISECONDS.toSeconds(30))
|
||||
// var index = 0
|
||||
// (1 until 50)
|
||||
// .map { it }
|
||||
// .asFlow()
|
||||
// .onEach {
|
||||
// delay(TimeUnit.SECONDS.toMillis(5))
|
||||
// val builder = RecordPanelOuterClass.RecordPanel.newBuilder()
|
||||
// builder.also {
|
||||
// it.diskFree = (100 + index).toLong()
|
||||
// it.duration = 60.0.toFloat()
|
||||
// it.filename = "/user/general/record_$index.log"
|
||||
// it.id = 10 + index
|
||||
// it.key = index.toLong()
|
||||
// it.stat = 100
|
||||
// it.type = 1
|
||||
// it.timestamp = SimpleDateFormat("yyyyMMddHHmmss").format(Date())
|
||||
// index++
|
||||
// }
|
||||
// // CallerDevaToolsManager.onReceiveBadCaseRecord(builder.build())
|
||||
// }
|
||||
// .flowOn(Dispatchers.Default)
|
||||
// .collect()
|
||||
// delay(TimeUnit.HOURS.toMillis(2))
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @ExperimentalCoroutinesApi
|
||||
// @Test
|
||||
// fun showBadCaseEntrance2(): Unit = runBlocking(Dispatchers.Main) {
|
||||
// ensureMoGoHmiFragmentShow()
|
||||
// var index = 0
|
||||
// (1 until 50)
|
||||
// .map { it }
|
||||
// .asFlow()
|
||||
// .onEach {
|
||||
// if (index in 1..4) {
|
||||
// delay(TimeUnit.SECONDS.toMillis(15))
|
||||
// } else {
|
||||
// delay(Random(20).nextLong())
|
||||
// }
|
||||
// val builder = RecordPanelOuterClass.RecordPanel.newBuilder()
|
||||
// builder.also {
|
||||
// it.diskFree = (100 + index).toLong()
|
||||
// it.duration = 60.0.toFloat()
|
||||
// it.filename = "/user/general/record_$index.log"
|
||||
// it.id = 10 + index
|
||||
// it.key = index.toLong()
|
||||
// it.stat = 100
|
||||
// it.type = 1
|
||||
// it.timestamp = SimpleDateFormat("yyyyMMddHHmmss").format(Date())
|
||||
// index++
|
||||
// }
|
||||
// // CallerDevaToolsManager.onReceiveBadCaseRecord(builder.build())
|
||||
// }
|
||||
// .flowOn(Dispatchers.Default)
|
||||
// .collect()
|
||||
// delay(TimeUnit.HOURS.toMillis(2))
|
||||
// }
|
||||
//
|
||||
// @ExperimentalCoroutinesApi
|
||||
// @Test
|
||||
// fun showBadCaseEntrance3(): Unit = runBlocking(Dispatchers.Main) {
|
||||
// var index = 0
|
||||
// (1 until 50)
|
||||
// .map { it }
|
||||
// .asFlow()
|
||||
// .onEach {
|
||||
// delay(TimeUnit.SECONDS.toMillis(20))
|
||||
// val builder = RecordPanelOuterClass.RecordPanel.newBuilder()
|
||||
// builder.also {
|
||||
// it.diskFree = (100 + index).toLong()
|
||||
// it.duration = 60.0.toFloat()
|
||||
// it.filename = "/user/general/record_$index.log"
|
||||
// it.id = 10 + index
|
||||
// it.key = index.toLong()
|
||||
// it.stat = 100
|
||||
// it.type = 1
|
||||
// it.timestamp = SimpleDateFormat("yyyyMMddHHmmss").format(Date())
|
||||
// index++
|
||||
// }
|
||||
// // CallerDevaToolsManager.onReceiveBadCaseRecord(builder.build())
|
||||
// }
|
||||
// .flowOn(Dispatchers.Default)
|
||||
// .collect()
|
||||
// delay(TimeUnit.HOURS.toMillis(2))
|
||||
// }
|
||||
//
|
||||
// private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiProvider = suspendCancellableCoroutine {
|
||||
// launch.onActivity { itx ->
|
||||
// val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
// executor.scheduleAtFixedRate({
|
||||
// var find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
// while (find == null) {
|
||||
// find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
//
|
||||
// }
|
||||
// while (!find.isResumed) {
|
||||
// Thread.sleep(500)
|
||||
// }
|
||||
// it.resumeWith(Result.success(find))
|
||||
// try {
|
||||
// Thread.sleep(500)
|
||||
// executor.shutdownNow()
|
||||
// } catch (e: Throwable) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// }, 50, 500, TimeUnit.MILLISECONDS)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.mogo.functions.test
|
||||
|
||||
import android.util.*
|
||||
import androidx.test.core.app.*
|
||||
import androidx.test.ext.junit.runners.*
|
||||
import androidx.test.filters.*
|
||||
import androidx.test.platform.app.*
|
||||
import com.mogo.core.download.*
|
||||
import com.mogo.eagle.core.function.main.*
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.*
|
||||
import org.junit.*
|
||||
import org.junit.runner.*
|
||||
import java.io.*
|
||||
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class DownloaderTest {
|
||||
|
||||
lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
const val TAG = "DownloaderTest"
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDownload() = runBlocking {
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
Downloader.init(appContext)
|
||||
Downloader.download(
|
||||
"https://scm-1255510688.cos.ap-beijing.myqcloud.com/test/com.mogo.launcher.f/2.9.0.1002/IntelligentPilot_v2.9.0.1002_20220725_[fPadLenovoOchBus-launcher-qa]_debug.apk",
|
||||
File(appContext.getExternalFilesDir(null), "/apks/2.apk").absolutePath)
|
||||
.flowOn(Dispatchers.IO)
|
||||
.collect {
|
||||
when(it) {
|
||||
is DownloadStart -> Log.d(TAG, "下载开始: ${it.downloadUrl}")
|
||||
is DownloadFailed -> Log.d(TAG, "---error: ${it.msg}: ${it.downloadUrl}")
|
||||
is DownloadSuccess -> Log.d(TAG, "下载成功: ${it.path}, 文件存在?:${File(it.path).exists()}")
|
||||
is Downloading -> Log.d(TAG, "下载进度: ${it.downloaded}/${it.total}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,57 +1,57 @@
|
||||
package com.mogo.functions.test
|
||||
|
||||
import androidx.lifecycle.coroutineScope
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class KotlinCoroutineSchedulersTest {
|
||||
|
||||
lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testKotlinCoroutineSchedulersIo() = runBlocking {
|
||||
launch.onActivity {
|
||||
it.lifecycle.coroutineScope.launchWhenCreated {
|
||||
repeat(10) {
|
||||
withContext(Dispatchers.IO) {
|
||||
assert(Thread.currentThread().name.startsWith("io-pool-"))
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(1))
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(20))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testKotlinCoroutineSchedulersCpu() = runBlocking {
|
||||
launch.onActivity {
|
||||
it.lifecycle.coroutineScope.launchWhenCreated {
|
||||
repeat(10) {
|
||||
withContext(Dispatchers.Default) {
|
||||
assert(Thread.currentThread().name.startsWith("cpu-pool-"))
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(1))
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(20))
|
||||
}
|
||||
}
|
||||
//package com.mogo.functions.test
|
||||
//
|
||||
//import androidx.lifecycle.coroutineScope
|
||||
//import androidx.test.core.app.ActivityScenario
|
||||
//import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
//import androidx.test.filters.LargeTest
|
||||
//import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
//import kotlinx.coroutines.Dispatchers
|
||||
//import kotlinx.coroutines.delay
|
||||
//import kotlinx.coroutines.runBlocking
|
||||
//import kotlinx.coroutines.withContext
|
||||
//import org.junit.Before
|
||||
//import org.junit.Test
|
||||
//import org.junit.runner.RunWith
|
||||
//import java.util.concurrent.TimeUnit
|
||||
//
|
||||
//@RunWith(AndroidJUnit4::class)
|
||||
//@LargeTest
|
||||
//class KotlinCoroutineSchedulersTest {
|
||||
//
|
||||
// lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
//
|
||||
// @Before
|
||||
// fun before() {
|
||||
// launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testKotlinCoroutineSchedulersIo() = runBlocking {
|
||||
// launch.onActivity {
|
||||
// it.lifecycle.coroutineScope.launchWhenCreated {
|
||||
// repeat(10) {
|
||||
// withContext(Dispatchers.IO) {
|
||||
// assert(Thread.currentThread().name.startsWith("io-pool-"))
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(1))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(20))
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testKotlinCoroutineSchedulersCpu() = runBlocking {
|
||||
// launch.onActivity {
|
||||
// it.lifecycle.coroutineScope.launchWhenCreated {
|
||||
// repeat(10) {
|
||||
// withContext(Dispatchers.Default) {
|
||||
// assert(Thread.currentThread().name.startsWith("cpu-pool-"))
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(1))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(20))
|
||||
// }
|
||||
//}
|
||||
@@ -1,62 +1,62 @@
|
||||
package com.mogo.functions.test
|
||||
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapDataCollectorManager
|
||||
import com.mogo.eagle.core.function.hmi.ui.MoGoHmiProvider
|
||||
import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class MapDataCollectTest {
|
||||
|
||||
lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testTaskSent() = runBlocking {
|
||||
ensureMoGoHmiFragmentShow()
|
||||
delay(TimeUnit.SECONDS.toMillis(3))
|
||||
CallerMapDataCollectorManager.setIsInit()
|
||||
delay(TimeUnit.HOURS.toMillis(1))
|
||||
}
|
||||
private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiProvider = suspendCancellableCoroutine {
|
||||
launch.onActivity { itx ->
|
||||
val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
executor.scheduleAtFixedRate({
|
||||
var find =
|
||||
itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
while (find == null) {
|
||||
find =
|
||||
itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
|
||||
}
|
||||
while (!find.isResumed) {
|
||||
Thread.sleep(500)
|
||||
}
|
||||
it.resumeWith(Result.success(find))
|
||||
try {
|
||||
Thread.sleep(500)
|
||||
executor.shutdownNow()
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}, 50, 500, MILLISECONDS)
|
||||
}
|
||||
}
|
||||
}
|
||||
//package com.mogo.functions.test
|
||||
//
|
||||
//import androidx.annotation.VisibleForTesting
|
||||
//import androidx.test.core.app.ActivityScenario
|
||||
//import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
//import androidx.test.filters.LargeTest
|
||||
//import com.mogo.eagle.core.function.call.map.CallerMapDataCollectorManager
|
||||
//import com.mogo.eagle.core.function.hmi.ui.MoGoHmiProvider
|
||||
//import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
//import kotlinx.coroutines.delay
|
||||
//import kotlinx.coroutines.runBlocking
|
||||
//import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
//import org.junit.Before
|
||||
//import org.junit.Test
|
||||
//import org.junit.runner.RunWith
|
||||
//import java.util.concurrent.Executors
|
||||
//import java.util.concurrent.TimeUnit
|
||||
//import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
//
|
||||
//@RunWith(AndroidJUnit4::class)
|
||||
//@LargeTest
|
||||
//class MapDataCollectTest {
|
||||
//
|
||||
// lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
//
|
||||
// @Before
|
||||
// fun before() {
|
||||
// launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testTaskSent() = runBlocking {
|
||||
// ensureMoGoHmiFragmentShow()
|
||||
// delay(TimeUnit.SECONDS.toMillis(3))
|
||||
// CallerMapDataCollectorManager.setIsInit()
|
||||
// delay(TimeUnit.HOURS.toMillis(1))
|
||||
// }
|
||||
// private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiProvider = suspendCancellableCoroutine {
|
||||
// launch.onActivity { itx ->
|
||||
// val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
// executor.scheduleAtFixedRate({
|
||||
// var find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
// while (find == null) {
|
||||
// find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
//
|
||||
// }
|
||||
// while (!find.isResumed) {
|
||||
// Thread.sleep(500)
|
||||
// }
|
||||
// it.resumeWith(Result.success(find))
|
||||
// try {
|
||||
// Thread.sleep(500)
|
||||
// executor.shutdownNow()
|
||||
// } catch (e: Throwable) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// }, 50, 500, MILLISECONDS)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,89 @@
|
||||
//package com.mogo.functions.test
|
||||
//
|
||||
//import androidx.test.core.app.*
|
||||
//import androidx.test.ext.junit.runners.*
|
||||
//import androidx.test.filters.*
|
||||
//import com.mogo.eagle.core.function.hmi.ui.*
|
||||
//import com.mogo.eagle.core.function.main.*
|
||||
//import com.mogo.launcher.patch.*
|
||||
//import com.mogo.launcher.patch.utils.*
|
||||
//import kotlinx.coroutines.*
|
||||
//import org.junit.*
|
||||
//import org.junit.runner.*
|
||||
//import java.io.*
|
||||
//import java.util.concurrent.*
|
||||
//import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
//import kotlin.Result
|
||||
//
|
||||
//@RunWith(AndroidJUnit4::class)
|
||||
//@LargeTest
|
||||
//class PatchUtilsTest {
|
||||
//
|
||||
//
|
||||
// lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
//
|
||||
// @Before
|
||||
// fun before() {
|
||||
// launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// fun testGeneratePatchAndMergeThenInstall() = runBlocking {
|
||||
// val f = ensureMoGoHmiFragmentShow()
|
||||
// withContext(Dispatchers.Default) {
|
||||
//
|
||||
//
|
||||
// val context = f.context ?: return@withContext
|
||||
// val oldApkPath = context.let {
|
||||
// it.packageManager.getPackageInfo(it.packageName, 0)?.applicationInfo?.sourceDir
|
||||
// } ?: return@withContext
|
||||
//
|
||||
// val oldApk = File(oldApkPath)
|
||||
// if (!oldApk.exists()) {
|
||||
// throw AssertionError("old apk file is not exist.")
|
||||
// }
|
||||
// val oldApkTemp = File(context.getExternalFilesDir(null), "patches/old.apk")
|
||||
// if (oldApkTemp.exists()) {
|
||||
// oldApkTemp.delete()
|
||||
// }
|
||||
// oldApkTemp.parentFile?.takeIf { !it.exists() }?.also { it.mkdirs() }
|
||||
//
|
||||
// oldApk.copyTo(oldApkTemp)
|
||||
// val patch = File(context.getExternalFilesDir(null), "patches/patch.zip")
|
||||
// if (!patch.exists()) {
|
||||
// throw AssertionError("patch file is not exist.")
|
||||
// }
|
||||
// val newApk = File(context.getExternalFilesDir(null), "patches/new.apk")
|
||||
//// PatchUtils.applyPatch(context, File(oldApkPath), patch, newApk)
|
||||
//// PatchUtils.install(context, newApk)
|
||||
// }
|
||||
// delay(TimeUnit.MINUTES.toMillis(1))
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiFragment = suspendCancellableCoroutine {
|
||||
// launch.onActivity { itx ->
|
||||
// val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
// executor.scheduleAtFixedRate({
|
||||
// var find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiFragment } as? MoGoHmiFragment
|
||||
// while (find == null) {
|
||||
// find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiFragment } as? MoGoHmiFragment
|
||||
// }
|
||||
// while (!find.isResumed) {
|
||||
// Thread.sleep(500)
|
||||
// }
|
||||
// it.resumeWith(Result.success(find))
|
||||
// try {
|
||||
// Thread.sleep(500)
|
||||
// executor.shutdownNow()
|
||||
// } catch (e: Throwable) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// }, 50, 500, MILLISECONDS)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -1,426 +1,426 @@
|
||||
package com.mogo.functions.test
|
||||
|
||||
import android.animation.Animator
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import android.view.animation.OvershootInterpolator
|
||||
import android.widget.PopupWindow
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
|
||||
import com.mogo.eagle.core.function.hmi.notification.WarningFloat
|
||||
import com.mogo.eagle.core.function.hmi.notification.anim.DefaultAnimator
|
||||
import com.mogo.eagle.core.data.enums.SidePattern
|
||||
import com.mogo.eagle.core.function.hmi.ui.*
|
||||
import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
import com.mogo.eagle.core.utilcode.kotlin.shape
|
||||
import com.mogo.eagle.core.utilcode.reminder.Reminder
|
||||
import com.mogo.eagle.core.utilcode.reminder.api.impl.ActivityReminder
|
||||
import com.mogo.eagle.core.utilcode.reminder.api.impl.PopupWindowReminder
|
||||
import com.mogo.eagle.core.utilcode.reminder.api.impl.ViewReminder
|
||||
import com.mogo.eagle.core.utilcode.util.AppStateManager
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.*
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.lang.Integer.min
|
||||
import java.util.concurrent.*
|
||||
import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class ReminderTest {
|
||||
|
||||
lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testViewReminderNotOverride() = runBlocking(Dispatchers.Main) {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenResumed {
|
||||
for (i in 1..10) {
|
||||
val reminder = WindowManagerViewUnOverrideReminder(View(it).also { itx -> itx.background = shape(solid = color(i)) }, 300, 300)
|
||||
Reminder.enqueue(it, reminder)
|
||||
delay(TimeUnit.SECONDS.toMillis(3))
|
||||
reminder.hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
return@runBlocking
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testShowWarningV2x() = runBlocking {
|
||||
val f = ensureMoGoHmiFragmentShow()
|
||||
|
||||
delay(5000)
|
||||
(1 until 20).map {
|
||||
it
|
||||
}.asFlow()
|
||||
.onEach {
|
||||
f.showWarningV2X("10006", "test", "测试$it", "$it", null, true, 5000)
|
||||
}
|
||||
.flowOn(Dispatchers.Default)
|
||||
.collect()
|
||||
delay(3000000)
|
||||
}
|
||||
|
||||
private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiProvider = suspendCancellableCoroutine {
|
||||
launch.onActivity { itx ->
|
||||
val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
executor.scheduleAtFixedRate({
|
||||
var find =
|
||||
itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
while (find == null) {
|
||||
find =
|
||||
itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
}
|
||||
while (!find.isResumed) {
|
||||
Thread.sleep(500)
|
||||
}
|
||||
it.resumeWith(Result.success(find))
|
||||
try {
|
||||
Thread.sleep(500)
|
||||
executor.shutdownNow()
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}, 50, 500, MILLISECONDS)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testViewReminderOverride() = runBlocking(Dispatchers.Main) {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenCreated {
|
||||
for (i in 1..10) {
|
||||
val reminder = WindowManagerViewOverrideReminder(View(it).also { itx -> itx.background = shape(solid = color(i)) }, 300, 300)
|
||||
Reminder.enqueue(it, reminder)
|
||||
delay(TimeUnit.SECONDS.toMillis(3))
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
return@runBlocking
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testViewReminderWhenActivityDestroyed() = runBlocking(Dispatchers.Main) {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenCreated {
|
||||
for (i in 1..10) {
|
||||
val reminder = WindowManagerViewOverrideReminder(View(it).also { itx -> itx.background = shape(solid = color(i)) }, 300, 300)
|
||||
Reminder.enqueue(it, reminder)
|
||||
delay(TimeUnit.SECONDS.toMillis(3))
|
||||
|
||||
if (i == 8) {
|
||||
it.finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWarningFloat() = runBlocking(Dispatchers.Main) {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenCreated {
|
||||
for (i in 1..10) {
|
||||
val v = View(it).also {
|
||||
it.background = shape(solid = color(i))
|
||||
it.layoutParams = WindowManager.LayoutParams().also { itx ->
|
||||
itx.width = 300
|
||||
itx.height = 400
|
||||
}
|
||||
}
|
||||
val builder = WarningFloat.with(it).setTag("test${i}").setLayout(v).setSidePattern(SidePattern.RESULT_TOP).setCountDownTime(TimeUnit.SECONDS.toMillis(10)).setGravity(Gravity.CENTER_HORIZONTAL, offsetY = 110).setImmersionStatusBar(true).addWarningStatusListener(object :
|
||||
IMoGoWarningStatusListener {
|
||||
override fun onShow() {
|
||||
|
||||
}
|
||||
}).setAnimator(object : DefaultAnimator() {
|
||||
override fun enterAnim(view: View, params: WindowManager.LayoutParams, windowManager: WindowManager, sidePattern: SidePattern): Animator? = super.enterAnim(view, params, windowManager, sidePattern)?.apply {
|
||||
interpolator = OvershootInterpolator()
|
||||
}
|
||||
|
||||
override fun exitAnim(view: View, params: WindowManager.LayoutParams, windowManager: WindowManager, sidePattern: SidePattern): Animator? = super.exitAnim(view, params, windowManager, sidePattern)?.setDuration(200)
|
||||
})
|
||||
Reminder.enqueue(it, WarningFloatReminder(builder))
|
||||
delay(TimeUnit.SECONDS.toMillis(3))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun testActivityReminder() = runBlocking(Dispatchers.Main) {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenResumed {
|
||||
for (i in 1..10) {
|
||||
val reminder = ActivityNameReminder(it, "com.mogo.launcher.TestActivity")
|
||||
Reminder.enqueue(it, reminder)
|
||||
delay(TimeUnit.SECONDS.toMillis(6))
|
||||
reminder.hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testActivityReminderOverride() = runBlocking(Dispatchers.Main) {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenResumed {
|
||||
for (i in 1..10) {
|
||||
val reminder = ActivityNameOverrideReminder(it, "com.mogo.launcher.TestActivity")
|
||||
Reminder.enqueue(it, reminder)
|
||||
delay(TimeUnit.SECONDS.toMillis(6))
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun testPopupWindowReminder() = runBlocking {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenResumed {
|
||||
for (i in 1..10) {
|
||||
|
||||
val reminder = TestPopupWindowReminder(it.findViewById(android.R.id.content), PopupWindow(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT).also { itx ->
|
||||
itx.contentView = View(it).also {
|
||||
xx -> xx.background = shape(solid = color(i))
|
||||
xx.layoutParams = ViewGroup.LayoutParams(300, 400)
|
||||
}
|
||||
})
|
||||
Reminder.enqueue(it, reminder)
|
||||
delay(TimeUnit.SECONDS.toMillis(3))
|
||||
reminder.hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPopupWindowReminderOverride() = runBlocking {
|
||||
launch.onActivity {
|
||||
it.lifecycleScope.launchWhenResumed {
|
||||
for (i in 1..10) {
|
||||
|
||||
val reminder = TestPopupWindowReminderOverride(it.findViewById(android.R.id.content), PopupWindow(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT).also { itx ->
|
||||
itx.contentView = View(it).also {
|
||||
xx -> xx.background = shape(solid = color(i))
|
||||
xx.layoutParams = ViewGroup.LayoutParams(300, 400)
|
||||
}
|
||||
})
|
||||
Reminder.enqueue(it, reminder)
|
||||
delay(TimeUnit.SECONDS.toMillis(3))
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(100))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWarningFloatForProject() = runBlocking {
|
||||
//package com.mogo.functions.test
|
||||
//
|
||||
//import android.animation.Animator
|
||||
//import android.app.Activity
|
||||
//import android.content.Context
|
||||
//import android.content.Intent
|
||||
//import android.graphics.Color
|
||||
//import android.view.Gravity
|
||||
//import android.view.View
|
||||
//import android.view.ViewGroup
|
||||
//import android.view.WindowManager
|
||||
//import android.view.animation.OvershootInterpolator
|
||||
//import android.widget.PopupWindow
|
||||
//import androidx.core.view.ViewCompat
|
||||
//import androidx.lifecycle.lifecycleScope
|
||||
//import androidx.test.core.app.ActivityScenario
|
||||
//import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
//import androidx.test.filters.LargeTest
|
||||
//import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
|
||||
//import com.mogo.eagle.core.function.hmi.notification.WarningFloat
|
||||
//import com.mogo.eagle.core.function.hmi.notification.anim.DefaultAnimator
|
||||
//import com.mogo.eagle.core.data.enums.SidePattern
|
||||
//import com.mogo.eagle.core.function.hmi.ui.*
|
||||
//import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
//import com.mogo.eagle.core.utilcode.kotlin.shape
|
||||
//import com.mogo.eagle.core.utilcode.reminder.Reminder
|
||||
//import com.mogo.eagle.core.utilcode.reminder.api.impl.ActivityReminder
|
||||
//import com.mogo.eagle.core.utilcode.reminder.api.impl.PopupWindowReminder
|
||||
//import com.mogo.eagle.core.utilcode.reminder.api.impl.ViewReminder
|
||||
//import com.mogo.eagle.core.utilcode.util.AppStateManager
|
||||
//import kotlinx.coroutines.*
|
||||
//import kotlinx.coroutines.flow.*
|
||||
//import org.junit.Before
|
||||
//import org.junit.Test
|
||||
//import org.junit.runner.RunWith
|
||||
//import java.lang.Integer.min
|
||||
//import java.util.concurrent.*
|
||||
//import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
//
|
||||
//
|
||||
//@RunWith(AndroidJUnit4::class)
|
||||
//@LargeTest
|
||||
//class ReminderTest {
|
||||
//
|
||||
// lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
//
|
||||
// @Before
|
||||
// fun before() {
|
||||
// launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testViewReminderNotOverride() = runBlocking(Dispatchers.Main) {
|
||||
// launch.onActivity {
|
||||
// it.lifecycleScope.launchWhenResumed {
|
||||
// for (i in 1..10) {
|
||||
// val notificationView = V2XNotificationView(it)
|
||||
// notificationView.setWarningIcon(EventTypeEnum.getWarningIcon("10003"))
|
||||
// notificationView.setWarningContent("XXXXXX${i}")
|
||||
// WarningFloat.with(it)
|
||||
// .setTag("tag")
|
||||
// .setLayout(notificationView)
|
||||
// .setSidePattern(SidePattern.RESULT_TOP)
|
||||
// .setCountDownTime(5000)
|
||||
// .setGravity(Gravity.CENTER_HORIZONTAL, offsetY = 110)
|
||||
// .setImmersionStatusBar(true)
|
||||
// .addWarningStatusListener(object : IMoGoWarningStatusListener {
|
||||
// override fun onShow() {
|
||||
// }
|
||||
// })
|
||||
// .setAnimator(object : DefaultAnimator() {
|
||||
// override fun enterAnim(
|
||||
// view: View,
|
||||
// params: WindowManager.LayoutParams,
|
||||
// windowManager: WindowManager,
|
||||
// sidePattern: SidePattern
|
||||
// ): Animator? =
|
||||
// super.enterAnim(view, params, windowManager, sidePattern)?.apply {
|
||||
// interpolator = OvershootInterpolator()
|
||||
// }
|
||||
//
|
||||
// override fun exitAnim(
|
||||
// view: View,
|
||||
// params: WindowManager.LayoutParams,
|
||||
// windowManager: WindowManager,
|
||||
// sidePattern: SidePattern
|
||||
// ): Animator? =
|
||||
// super.exitAnim(view, params, windowManager, sidePattern)?.setDuration(200)
|
||||
// })
|
||||
// .show()
|
||||
// delay(2000)
|
||||
// val reminder = WindowManagerViewUnOverrideReminder(View(it).also { itx -> itx.background = shape(solid = color(i)) }, 300, 300)
|
||||
// Reminder.enqueue(it, reminder)
|
||||
// delay(TimeUnit.SECONDS.toMillis(3))
|
||||
// reminder.hide()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(100))
|
||||
}
|
||||
|
||||
|
||||
class WarningFloatReminder(private val builder: WarningFloat.Builder) : ViewReminder(builder.config.layoutView!!) {
|
||||
|
||||
override fun show() {
|
||||
builder.show()
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
WarningFloat.dismiss(builder.config.floatTag, false)
|
||||
}
|
||||
|
||||
override fun isOverride(): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class WindowManagerViewUnOverrideReminder(private val content: View, private val width: Int, private val height: Int) : ViewReminder(content) {
|
||||
|
||||
private val wm by lazy {
|
||||
content.context.getSystemService(Activity.WINDOW_SERVICE) as WindowManager
|
||||
}
|
||||
|
||||
private var isAdd = false
|
||||
|
||||
override fun show() {
|
||||
if (!isAdd) {
|
||||
val params = WindowManager.LayoutParams().also {
|
||||
it.width = width
|
||||
it.height = height
|
||||
}
|
||||
params.gravity = Gravity.CENTER
|
||||
wm.addView(content, params)
|
||||
isAdd = true
|
||||
}
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
if (isAdd && ViewCompat.isAttachedToWindow(content)) {
|
||||
wm.removeView(content)
|
||||
isAdd = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class WindowManagerViewOverrideReminder(private val content: View, private val width: Int, private val height: Int) : ViewReminder(content) {
|
||||
|
||||
private val wm by lazy {
|
||||
content.context.getSystemService(Activity.WINDOW_SERVICE) as WindowManager
|
||||
}
|
||||
|
||||
private var isAdd = false
|
||||
|
||||
override fun show() {
|
||||
if (!isAdd) {
|
||||
val params = WindowManager.LayoutParams().also {
|
||||
it.width = width
|
||||
it.height = height
|
||||
}
|
||||
params.gravity = Gravity.CENTER
|
||||
wm.addView(content, params)
|
||||
isAdd = true
|
||||
}
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
if (isAdd && ViewCompat.isAttachedToWindow(content)) {
|
||||
wm.removeView(content)
|
||||
isAdd = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun isOverride(): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ActivityNameReminder(private val context: Context, private val className: String): ActivityReminder(className) {
|
||||
|
||||
override fun show() {
|
||||
Intent(context, Class.forName(className)).also {
|
||||
context.startActivity(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
AppStateManager.currentActivity()?.takeIf { it.javaClass.name == className }?.finish()
|
||||
}
|
||||
}
|
||||
|
||||
class ActivityNameOverrideReminder(private val context: Context, private val className: String): ActivityReminder(className) {
|
||||
|
||||
override fun show() {
|
||||
Intent(context, Class.forName(className)).also {
|
||||
context.startActivity(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
AppStateManager.currentActivity()?.takeIf { it.javaClass.name == className }?.finish()
|
||||
}
|
||||
|
||||
override fun isOverride(): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
class TestPopupWindowReminder(private val anchor: View, override val popupWindow: PopupWindow): PopupWindowReminder(popupWindow) {
|
||||
|
||||
override fun show() {
|
||||
popupWindow.showAtLocation(anchor, Gravity.CENTER, 0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
class TestPopupWindowReminderOverride(private val anchor: View, override val popupWindow: PopupWindow): PopupWindowReminder(popupWindow) {
|
||||
|
||||
override fun show() {
|
||||
popupWindow.showAtLocation(anchor, Gravity.CENTER, 0, 0)
|
||||
}
|
||||
|
||||
override fun isOverride(): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
private fun color(index: Int): Int {
|
||||
if (index > 10) {
|
||||
return Color.BLACK
|
||||
}
|
||||
val alpha = min(255, 255 - index * 20)
|
||||
return Color.argb(alpha, Color.red(Color.RED), Color.green(Color.RED), Color.blue(Color.RED))
|
||||
}
|
||||
}
|
||||
// return@runBlocking
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testShowWarningV2x() = runBlocking {
|
||||
// val f = ensureMoGoHmiFragmentShow()
|
||||
//
|
||||
// delay(5000)
|
||||
// (1 until 20).map {
|
||||
// it
|
||||
// }.asFlow()
|
||||
// .onEach {
|
||||
// f.showWarningV2X("10006", "test", "测试$it", "$it", null, true, 5000)
|
||||
// }
|
||||
// .flowOn(Dispatchers.Default)
|
||||
// .collect()
|
||||
// delay(3000000)
|
||||
// }
|
||||
//
|
||||
// private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiProvider = suspendCancellableCoroutine {
|
||||
// launch.onActivity { itx ->
|
||||
// val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
// executor.scheduleAtFixedRate({
|
||||
// var find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
// while (find == null) {
|
||||
// find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
// }
|
||||
// while (!find.isResumed) {
|
||||
// Thread.sleep(500)
|
||||
// }
|
||||
// it.resumeWith(Result.success(find))
|
||||
// try {
|
||||
// Thread.sleep(500)
|
||||
// executor.shutdownNow()
|
||||
// } catch (e: Throwable) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// }, 50, 500, MILLISECONDS)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testViewReminderOverride() = runBlocking(Dispatchers.Main) {
|
||||
// launch.onActivity {
|
||||
// it.lifecycleScope.launchWhenCreated {
|
||||
// for (i in 1..10) {
|
||||
// val reminder = WindowManagerViewOverrideReminder(View(it).also { itx -> itx.background = shape(solid = color(i)) }, 300, 300)
|
||||
// Reminder.enqueue(it, reminder)
|
||||
// delay(TimeUnit.SECONDS.toMillis(3))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(100))
|
||||
// return@runBlocking
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testViewReminderWhenActivityDestroyed() = runBlocking(Dispatchers.Main) {
|
||||
// launch.onActivity {
|
||||
// it.lifecycleScope.launchWhenCreated {
|
||||
// for (i in 1..10) {
|
||||
// val reminder = WindowManagerViewOverrideReminder(View(it).also { itx -> itx.background = shape(solid = color(i)) }, 300, 300)
|
||||
// Reminder.enqueue(it, reminder)
|
||||
// delay(TimeUnit.SECONDS.toMillis(3))
|
||||
//
|
||||
// if (i == 8) {
|
||||
// it.finish()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(100))
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testWarningFloat() = runBlocking(Dispatchers.Main) {
|
||||
// launch.onActivity {
|
||||
// it.lifecycleScope.launchWhenCreated {
|
||||
// for (i in 1..10) {
|
||||
// val v = View(it).also {
|
||||
// it.background = shape(solid = color(i))
|
||||
// it.layoutParams = WindowManager.LayoutParams().also { itx ->
|
||||
// itx.width = 300
|
||||
// itx.height = 400
|
||||
// }
|
||||
// }
|
||||
// val builder = WarningFloat.with(it).setTag("test${i}").setLayout(v).setSidePattern(SidePattern.RESULT_TOP).setCountDownTime(TimeUnit.SECONDS.toMillis(10)).setGravity(Gravity.CENTER_HORIZONTAL, offsetY = 110).setImmersionStatusBar(true).addWarningStatusListener(object :
|
||||
// IMoGoWarningStatusListener {
|
||||
// override fun onShow() {
|
||||
//
|
||||
// }
|
||||
// }).setAnimator(object : DefaultAnimator() {
|
||||
// override fun enterAnim(view: View, params: WindowManager.LayoutParams, windowManager: WindowManager, sidePattern: SidePattern): Animator? = super.enterAnim(view, params, windowManager, sidePattern)?.apply {
|
||||
// interpolator = OvershootInterpolator()
|
||||
// }
|
||||
//
|
||||
// override fun exitAnim(view: View, params: WindowManager.LayoutParams, windowManager: WindowManager, sidePattern: SidePattern): Animator? = super.exitAnim(view, params, windowManager, sidePattern)?.setDuration(200)
|
||||
// })
|
||||
// Reminder.enqueue(it, WarningFloatReminder(builder))
|
||||
// delay(TimeUnit.SECONDS.toMillis(3))
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(100))
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// fun testActivityReminder() = runBlocking(Dispatchers.Main) {
|
||||
// launch.onActivity {
|
||||
// it.lifecycleScope.launchWhenResumed {
|
||||
// for (i in 1..10) {
|
||||
// val reminder = ActivityNameReminder(it, "com.mogo.launcher.TestActivity")
|
||||
// Reminder.enqueue(it, reminder)
|
||||
// delay(TimeUnit.SECONDS.toMillis(6))
|
||||
// reminder.hide()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(100))
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testActivityReminderOverride() = runBlocking(Dispatchers.Main) {
|
||||
// launch.onActivity {
|
||||
// it.lifecycleScope.launchWhenResumed {
|
||||
// for (i in 1..10) {
|
||||
// val reminder = ActivityNameOverrideReminder(it, "com.mogo.launcher.TestActivity")
|
||||
// Reminder.enqueue(it, reminder)
|
||||
// delay(TimeUnit.SECONDS.toMillis(6))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(100))
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// fun testPopupWindowReminder() = runBlocking {
|
||||
// launch.onActivity {
|
||||
// it.lifecycleScope.launchWhenResumed {
|
||||
// for (i in 1..10) {
|
||||
//
|
||||
// val reminder = TestPopupWindowReminder(it.findViewById(android.R.id.content), PopupWindow(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT).also { itx ->
|
||||
// itx.contentView = View(it).also {
|
||||
// xx -> xx.background = shape(solid = color(i))
|
||||
// xx.layoutParams = ViewGroup.LayoutParams(300, 400)
|
||||
// }
|
||||
// })
|
||||
// Reminder.enqueue(it, reminder)
|
||||
// delay(TimeUnit.SECONDS.toMillis(3))
|
||||
// reminder.hide()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(100))
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testPopupWindowReminderOverride() = runBlocking {
|
||||
// launch.onActivity {
|
||||
// it.lifecycleScope.launchWhenResumed {
|
||||
// for (i in 1..10) {
|
||||
//
|
||||
// val reminder = TestPopupWindowReminderOverride(it.findViewById(android.R.id.content), PopupWindow(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT).also { itx ->
|
||||
// itx.contentView = View(it).also {
|
||||
// xx -> xx.background = shape(solid = color(i))
|
||||
// xx.layoutParams = ViewGroup.LayoutParams(300, 400)
|
||||
// }
|
||||
// })
|
||||
// Reminder.enqueue(it, reminder)
|
||||
// delay(TimeUnit.SECONDS.toMillis(3))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(100))
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testWarningFloatForProject() = runBlocking {
|
||||
//// launch.onActivity {
|
||||
//// it.lifecycleScope.launchWhenResumed {
|
||||
//// for (i in 1..10) {
|
||||
//// val notificationView = V2XNotificationView(it)
|
||||
//// notificationView.setWarningIcon(EventTypeEnum.getWarningIcon("10003"))
|
||||
//// notificationView.setWarningContent("XXXXXX${i}")
|
||||
//// WarningFloat.with(it)
|
||||
//// .setTag("tag")
|
||||
//// .setLayout(notificationView)
|
||||
//// .setSidePattern(SidePattern.RESULT_TOP)
|
||||
//// .setCountDownTime(5000)
|
||||
//// .setGravity(Gravity.CENTER_HORIZONTAL, offsetY = 110)
|
||||
//// .setImmersionStatusBar(true)
|
||||
//// .addWarningStatusListener(object : IMoGoWarningStatusListener {
|
||||
//// override fun onShow() {
|
||||
//// }
|
||||
//// })
|
||||
//// .setAnimator(object : DefaultAnimator() {
|
||||
//// override fun enterAnim(
|
||||
//// view: View,
|
||||
//// params: WindowManager.LayoutParams,
|
||||
//// windowManager: WindowManager,
|
||||
//// sidePattern: SidePattern
|
||||
//// ): Animator? =
|
||||
//// super.enterAnim(view, params, windowManager, sidePattern)?.apply {
|
||||
//// interpolator = OvershootInterpolator()
|
||||
//// }
|
||||
////
|
||||
//// override fun exitAnim(
|
||||
//// view: View,
|
||||
//// params: WindowManager.LayoutParams,
|
||||
//// windowManager: WindowManager,
|
||||
//// sidePattern: SidePattern
|
||||
//// ): Animator? =
|
||||
//// super.exitAnim(view, params, windowManager, sidePattern)?.setDuration(200)
|
||||
//// })
|
||||
//// .show()
|
||||
//// delay(2000)
|
||||
//// }
|
||||
//// }
|
||||
//// }
|
||||
//// delay(TimeUnit.SECONDS.toMillis(100))
|
||||
// }
|
||||
//
|
||||
//
|
||||
// class WarningFloatReminder(private val builder: WarningFloat.Builder) : ViewReminder(builder.config.layoutView!!) {
|
||||
//
|
||||
// override fun show() {
|
||||
// builder.show()
|
||||
// }
|
||||
//
|
||||
// override fun hide() {
|
||||
// WarningFloat.dismiss(builder.config.floatTag, false)
|
||||
// }
|
||||
//
|
||||
// override fun isOverride(): Boolean {
|
||||
// return true
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// class WindowManagerViewUnOverrideReminder(private val content: View, private val width: Int, private val height: Int) : ViewReminder(content) {
|
||||
//
|
||||
// private val wm by lazy {
|
||||
// content.context.getSystemService(Activity.WINDOW_SERVICE) as WindowManager
|
||||
// }
|
||||
//
|
||||
// private var isAdd = false
|
||||
//
|
||||
// override fun show() {
|
||||
// if (!isAdd) {
|
||||
// val params = WindowManager.LayoutParams().also {
|
||||
// it.width = width
|
||||
// it.height = height
|
||||
// }
|
||||
// params.gravity = Gravity.CENTER
|
||||
// wm.addView(content, params)
|
||||
// isAdd = true
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun hide() {
|
||||
// if (isAdd && ViewCompat.isAttachedToWindow(content)) {
|
||||
// wm.removeView(content)
|
||||
// isAdd = false
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// class WindowManagerViewOverrideReminder(private val content: View, private val width: Int, private val height: Int) : ViewReminder(content) {
|
||||
//
|
||||
// private val wm by lazy {
|
||||
// content.context.getSystemService(Activity.WINDOW_SERVICE) as WindowManager
|
||||
// }
|
||||
//
|
||||
// private var isAdd = false
|
||||
//
|
||||
// override fun show() {
|
||||
// if (!isAdd) {
|
||||
// val params = WindowManager.LayoutParams().also {
|
||||
// it.width = width
|
||||
// it.height = height
|
||||
// }
|
||||
// params.gravity = Gravity.CENTER
|
||||
// wm.addView(content, params)
|
||||
// isAdd = true
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun hide() {
|
||||
// if (isAdd && ViewCompat.isAttachedToWindow(content)) {
|
||||
// wm.removeView(content)
|
||||
// isAdd = false
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun isOverride(): Boolean {
|
||||
// return true
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// class ActivityNameReminder(private val context: Context, private val className: String): ActivityReminder(className) {
|
||||
//
|
||||
// override fun show() {
|
||||
// Intent(context, Class.forName(className)).also {
|
||||
// context.startActivity(it)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun hide() {
|
||||
// AppStateManager.currentActivity()?.takeIf { it.javaClass.name == className }?.finish()
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class ActivityNameOverrideReminder(private val context: Context, private val className: String): ActivityReminder(className) {
|
||||
//
|
||||
// override fun show() {
|
||||
// Intent(context, Class.forName(className)).also {
|
||||
// context.startActivity(it)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun hide() {
|
||||
// AppStateManager.currentActivity()?.takeIf { it.javaClass.name == className }?.finish()
|
||||
// }
|
||||
//
|
||||
// override fun isOverride(): Boolean {
|
||||
// return true
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class TestPopupWindowReminder(private val anchor: View, override val popupWindow: PopupWindow): PopupWindowReminder(popupWindow) {
|
||||
//
|
||||
// override fun show() {
|
||||
// popupWindow.showAtLocation(anchor, Gravity.CENTER, 0, 0)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class TestPopupWindowReminderOverride(private val anchor: View, override val popupWindow: PopupWindow): PopupWindowReminder(popupWindow) {
|
||||
//
|
||||
// override fun show() {
|
||||
// popupWindow.showAtLocation(anchor, Gravity.CENTER, 0, 0)
|
||||
// }
|
||||
//
|
||||
// override fun isOverride(): Boolean {
|
||||
// return true
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private fun color(index: Int): Int {
|
||||
// if (index > 10) {
|
||||
// return Color.BLACK
|
||||
// }
|
||||
// val alpha = min(255, 255 - index * 20)
|
||||
// return Color.argb(alpha, Color.red(Color.RED), Color.green(Color.RED), Color.blue(Color.RED))
|
||||
// }
|
||||
//}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,54 +1,54 @@
|
||||
package com.mogo.functions.test
|
||||
|
||||
import android.os.Debug
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
import io.reactivex.Flowable
|
||||
import io.reactivex.plugins.RxJavaPlugins
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class RxJavaBackPressureTest {
|
||||
|
||||
lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
RxJavaPlugins.setErrorHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIntervalBackPressure() = runBlocking(Dispatchers.Default) {
|
||||
val subscription = Flowable.interval(50, MILLISECONDS).doOnNext {
|
||||
}.subscribeOn(Schedulers.computation()).observeOn(Schedulers.io()).subscribe {
|
||||
Thread.sleep(2000)
|
||||
}
|
||||
repeat(10) {
|
||||
delay(TimeUnit.SECONDS.toMillis(5))
|
||||
try {
|
||||
Debug.dumpHprofData(Date().toFileName())
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
}
|
||||
delay(TimeUnit.HOURS.toMillis(1))
|
||||
subscription.dispose()
|
||||
}
|
||||
|
||||
private fun Date.toFileName(): String = SimpleDateFormat("yyyyMMdd_HH_mm_ss", Locale.getDefault()).format(this) + ".hprof"
|
||||
}
|
||||
//package com.mogo.functions.test
|
||||
//
|
||||
//import android.os.Debug
|
||||
//import androidx.test.core.app.ActivityScenario
|
||||
//import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
//import androidx.test.filters.LargeTest
|
||||
//import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
//import io.reactivex.Flowable
|
||||
//import io.reactivex.plugins.RxJavaPlugins
|
||||
//import io.reactivex.schedulers.Schedulers
|
||||
//import kotlinx.coroutines.Dispatchers
|
||||
//import kotlinx.coroutines.delay
|
||||
//import kotlinx.coroutines.runBlocking
|
||||
//import org.junit.Before
|
||||
//import org.junit.Test
|
||||
//import org.junit.runner.RunWith
|
||||
//import java.text.SimpleDateFormat
|
||||
//import java.util.*
|
||||
//import java.util.concurrent.TimeUnit
|
||||
//import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
//
|
||||
//@RunWith(AndroidJUnit4::class)
|
||||
//@LargeTest
|
||||
//class RxJavaBackPressureTest {
|
||||
//
|
||||
// lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
//
|
||||
// @Before
|
||||
// fun before() {
|
||||
// launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
// RxJavaPlugins.setErrorHandler {
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testIntervalBackPressure() = runBlocking(Dispatchers.Default) {
|
||||
// val subscription = Flowable.interval(50, MILLISECONDS).doOnNext {
|
||||
// }.subscribeOn(Schedulers.computation()).observeOn(Schedulers.io()).subscribe {
|
||||
// Thread.sleep(2000)
|
||||
// }
|
||||
// repeat(10) {
|
||||
// delay(TimeUnit.SECONDS.toMillis(5))
|
||||
// try {
|
||||
// Debug.dumpHprofData(Date().toFileName())
|
||||
// } catch (t: Throwable) {
|
||||
// t.printStackTrace()
|
||||
// }
|
||||
// }
|
||||
// delay(TimeUnit.HOURS.toMillis(1))
|
||||
// subscription.dispose()
|
||||
// }
|
||||
//
|
||||
// private fun Date.toFileName(): String = SimpleDateFormat("yyyyMMdd_HH_mm_ss", Locale.getDefault()).format(this) + ".hprof"
|
||||
//}
|
||||
@@ -1,76 +1,76 @@
|
||||
package com.mogo.functions.test
|
||||
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.ObservableOnSubscribe
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.util.concurrent.TimeUnit.SECONDS
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class RxJavaSchedulersTest {
|
||||
|
||||
lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRxJavaIoSchedulers() = runBlocking {
|
||||
val list = mutableListOf<Int>()
|
||||
for (i in 1..10) {
|
||||
list += i
|
||||
}
|
||||
val result = Observable.fromIterable(list)
|
||||
.doOnNext {
|
||||
assert(Thread.currentThread().name.startsWith("io-pool-"))
|
||||
}
|
||||
.subscribeOn(Schedulers.io())
|
||||
.reduce(0) { adder, toAdd ->
|
||||
val sum = adder + toAdd
|
||||
sum
|
||||
}
|
||||
.blockingGet()
|
||||
assert(result == 55)
|
||||
|
||||
delay(SECONDS.toMillis(20))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRxJavaCpuSchedulers() = runBlocking {
|
||||
val result = Observable.create(ObservableOnSubscribe<Int> { emitter ->
|
||||
for (i in 1..10) {
|
||||
emitter.onNext(i)
|
||||
}
|
||||
assert(Thread.currentThread().name.startsWith("cpu-pool-"))
|
||||
emitter.onComplete()
|
||||
}).reduce(0) { adder, toAdd ->
|
||||
adder + toAdd
|
||||
}.subscribeOn(Schedulers.computation()).blockingGet()
|
||||
assert(result == 55)
|
||||
delay(SECONDS.toMillis(20))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRxJavaIntervalSchedulers() = runBlocking {
|
||||
var counter = 0
|
||||
Observable.intervalRange(0, 10, 1, 1 ,SECONDS)
|
||||
.doOnNext {
|
||||
counter ++
|
||||
}
|
||||
.subscribe()
|
||||
delay(SECONDS.toMillis(20))
|
||||
assert(counter == 10)
|
||||
}
|
||||
|
||||
}
|
||||
//package com.mogo.functions.test
|
||||
//
|
||||
//import androidx.test.core.app.ActivityScenario
|
||||
//import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
//import androidx.test.filters.LargeTest
|
||||
//import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
//import io.reactivex.Observable
|
||||
//import io.reactivex.ObservableOnSubscribe
|
||||
//import io.reactivex.schedulers.Schedulers
|
||||
//import kotlinx.coroutines.delay
|
||||
//import kotlinx.coroutines.runBlocking
|
||||
//import org.junit.Before
|
||||
//import org.junit.Test
|
||||
//import org.junit.runner.RunWith
|
||||
//import java.util.concurrent.TimeUnit.SECONDS
|
||||
//
|
||||
//@RunWith(AndroidJUnit4::class)
|
||||
//@LargeTest
|
||||
//class RxJavaSchedulersTest {
|
||||
//
|
||||
// lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
//
|
||||
// @Before
|
||||
// fun before() {
|
||||
// launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testRxJavaIoSchedulers() = runBlocking {
|
||||
// val list = mutableListOf<Int>()
|
||||
// for (i in 1..10) {
|
||||
// list += i
|
||||
// }
|
||||
// val result = Observable.fromIterable(list)
|
||||
// .doOnNext {
|
||||
// assert(Thread.currentThread().name.startsWith("io-pool-"))
|
||||
// }
|
||||
// .subscribeOn(Schedulers.io())
|
||||
// .reduce(0) { adder, toAdd ->
|
||||
// val sum = adder + toAdd
|
||||
// sum
|
||||
// }
|
||||
// .blockingGet()
|
||||
// assert(result == 55)
|
||||
//
|
||||
// delay(SECONDS.toMillis(20))
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testRxJavaCpuSchedulers() = runBlocking {
|
||||
// val result = Observable.create(ObservableOnSubscribe<Int> { emitter ->
|
||||
// for (i in 1..10) {
|
||||
// emitter.onNext(i)
|
||||
// }
|
||||
// assert(Thread.currentThread().name.startsWith("cpu-pool-"))
|
||||
// emitter.onComplete()
|
||||
// }).reduce(0) { adder, toAdd ->
|
||||
// adder + toAdd
|
||||
// }.subscribeOn(Schedulers.computation()).blockingGet()
|
||||
// assert(result == 55)
|
||||
// delay(SECONDS.toMillis(20))
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testRxJavaIntervalSchedulers() = runBlocking {
|
||||
// var counter = 0
|
||||
// Observable.intervalRange(0, 10, 1, 1 ,SECONDS)
|
||||
// .doOnNext {
|
||||
// counter ++
|
||||
// }
|
||||
// .subscribe()
|
||||
// delay(SECONDS.toMillis(20))
|
||||
// assert(counter == 10)
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -1,71 +1,71 @@
|
||||
package com.mogo.functions.test
|
||||
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import com.mogo.eagle.core.function.hmi.ui.MoGoHmiProvider
|
||||
import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class TipToastLeakTest {
|
||||
|
||||
|
||||
lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test() = runBlocking(Dispatchers.Main) {
|
||||
val f = ensureMoGoHmiFragmentShow()
|
||||
var index = 0
|
||||
while (index < 50) {
|
||||
delay(TimeUnit.SECONDS.toMillis(4))
|
||||
TipToast.shortTip("toast-> $index" )
|
||||
index ++
|
||||
}
|
||||
delay(TimeUnit.SECONDS.toMillis(1))
|
||||
f.activity?.finish()
|
||||
delay(TimeUnit.SECONDS.toMillis(2))
|
||||
}
|
||||
|
||||
private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiProvider = suspendCancellableCoroutine {
|
||||
launch.onActivity { itx ->
|
||||
val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
executor.scheduleAtFixedRate({
|
||||
var find =
|
||||
itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
while (find == null) {
|
||||
find =
|
||||
itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
|
||||
}
|
||||
while (!find.isResumed) {
|
||||
Thread.sleep(500)
|
||||
}
|
||||
it.resumeWith(Result.success(find))
|
||||
try {
|
||||
Thread.sleep(500)
|
||||
executor.shutdownNow()
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}, 50, 500, MILLISECONDS)
|
||||
}
|
||||
}
|
||||
}
|
||||
//package com.mogo.functions.test
|
||||
//
|
||||
//import androidx.test.core.app.ActivityScenario
|
||||
//import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
//import androidx.test.filters.LargeTest
|
||||
//import com.mogo.eagle.core.function.hmi.ui.MoGoHmiProvider
|
||||
//import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
//import com.mogo.eagle.core.utilcode.mogo.toast.TipToast
|
||||
//import kotlinx.coroutines.Dispatchers
|
||||
//import kotlinx.coroutines.delay
|
||||
//import kotlinx.coroutines.runBlocking
|
||||
//import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
//import org.junit.Before
|
||||
//import org.junit.Test
|
||||
//import org.junit.runner.RunWith
|
||||
//import java.util.concurrent.Executors
|
||||
//import java.util.concurrent.TimeUnit
|
||||
//import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
//
|
||||
//@RunWith(AndroidJUnit4::class)
|
||||
//@LargeTest
|
||||
//class TipToastLeakTest {
|
||||
//
|
||||
//
|
||||
// lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
//
|
||||
// @Before
|
||||
// fun before() {
|
||||
// launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun test() = runBlocking(Dispatchers.Main) {
|
||||
// val f = ensureMoGoHmiFragmentShow()
|
||||
// var index = 0
|
||||
// while (index < 50) {
|
||||
// delay(TimeUnit.SECONDS.toMillis(4))
|
||||
// TipToast.shortTip("toast-> $index" )
|
||||
// index ++
|
||||
// }
|
||||
// delay(TimeUnit.SECONDS.toMillis(1))
|
||||
// f.activity?.finish()
|
||||
// delay(TimeUnit.SECONDS.toMillis(2))
|
||||
// }
|
||||
//
|
||||
// private suspend fun ensureMoGoHmiFragmentShow(): MoGoHmiProvider = suspendCancellableCoroutine {
|
||||
// launch.onActivity { itx ->
|
||||
// val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
// executor.scheduleAtFixedRate({
|
||||
// var find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
// while (find == null) {
|
||||
// find =
|
||||
// itx.supportFragmentManager.fragments.find { it is MoGoHmiProvider } as? MoGoHmiProvider
|
||||
//
|
||||
// }
|
||||
// while (!find.isResumed) {
|
||||
// Thread.sleep(500)
|
||||
// }
|
||||
// it.resumeWith(Result.success(find))
|
||||
// try {
|
||||
// Thread.sleep(500)
|
||||
// executor.shutdownNow()
|
||||
// } catch (e: Throwable) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// }, 50, 500, MILLISECONDS)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -12,8 +12,9 @@
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_shell_name"
|
||||
android:largeHeap="true"
|
||||
android:resizeableActivity="false"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:resizeableActivity="false"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme.App"
|
||||
android:usesCleartextTraffic="true"
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package com.mogo.launcher.lancet
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.*
|
||||
import android.view.View
|
||||
import androidx.annotation.*
|
||||
import com.knightboost.lancet.api.*
|
||||
import com.knightboost.lancet.api.Scope.ALL
|
||||
import com.knightboost.lancet.api.annotations.*
|
||||
import com.knightboost.lancet.api.annotations.Weaver
|
||||
import com.mogo.eagle.core.utilcode.util.*
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.Runnable
|
||||
|
||||
@Keep
|
||||
@@ -12,60 +17,72 @@ import kotlinx.coroutines.Runnable
|
||||
@Group("anr_fix")
|
||||
class ANRFix {
|
||||
|
||||
@Insert
|
||||
@TargetClass("com.zhidao.cosupload.service.UploadService")
|
||||
@TargetMethod(methodName = "addUploadPaths")
|
||||
private fun fixAddUploadPathsANR() {
|
||||
ThreadUtils.getIoPool().execute(ANRFixTask(This.get(), "addUploadPaths"))
|
||||
}
|
||||
companion object {
|
||||
|
||||
@Insert
|
||||
@TargetClass("com.zhidao.cosupload.service.UploadService")
|
||||
@TargetMethod(methodName = "upload")
|
||||
private fun fixUploadANR(@ClassOf("com.zhidao.cosupload.model.CacheUploadIdData") data: Any?) {
|
||||
ThreadUtils.getIoPool().execute(ANRFixTask2(This.get(), "upload", data))
|
||||
}
|
||||
|
||||
@Insert
|
||||
@TargetClass("com.zhidao.cosupload.manager.CosUploadManagerImpl")
|
||||
@TargetMethod(methodName = "upload")
|
||||
private fun fixCosUploadManagerImplANR(productLine: String?, paths: List<String>?, eventId: String?, @ClassOf("com.zhidao.cosupload.DbPriorityConfig") config: Any?) {
|
||||
ThreadUtils.getIoPool().execute(ANRFixTask3(This.get(), "upload", productLine, paths, eventId, config))
|
||||
}
|
||||
}
|
||||
|
||||
class ANRFixTask(private val delegate: Any, private val methodName: String): Runnable {
|
||||
|
||||
override fun run() {
|
||||
delegate.javaClass.declaredMethods.find {
|
||||
it.name != methodName && it.name.contains(methodName)
|
||||
}?.also {
|
||||
it.isAccessible = true
|
||||
it.invoke(delegate)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ANRFixTask2(private val delegate: Any, private val methodName: String, private val p: Any?): Runnable {
|
||||
|
||||
override fun run() {
|
||||
delegate.javaClass.declaredMethods.find {
|
||||
it.name != methodName && it.name.contains(methodName)
|
||||
}?.also {
|
||||
it.isAccessible = true
|
||||
it.invoke(delegate, p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ANRFixTask3(private val delegate: Any, private val methodName: String,private val productLine: String?, private val paths: List<String>?, private val eventId: String?, private val config: Any?): Runnable {
|
||||
|
||||
override fun run() {
|
||||
delegate.javaClass.declaredMethods.find {
|
||||
it.name != methodName && it.name.contains(methodName)
|
||||
}?.also {
|
||||
it.isAccessible = true
|
||||
it.invoke(delegate, productLine, paths, eventId, config)
|
||||
}
|
||||
// @JvmStatic
|
||||
// @TargetClass(value = "android.os.Handler", scope = ALL)
|
||||
// @TargetMethod(methodName = "post")
|
||||
// @ReplaceInvoke
|
||||
// fun handlerPostProxy(handler: Handler, action: Runnable): Boolean {
|
||||
// if (Looper.getMainLooper() != handler.looper) {
|
||||
// return handler.post(action)
|
||||
// }
|
||||
// val what = ObjectHashCodeUtils.getHashCodeIfNeed(action)
|
||||
// handler.removeMessages(what)
|
||||
// val msg = Message.obtain(handler, action)
|
||||
// msg.what = what
|
||||
// return handler.sendMessage(msg)
|
||||
// }
|
||||
//
|
||||
// @JvmStatic
|
||||
// @TargetClass(value = "android.os.Handler", scope = ALL)
|
||||
// @TargetMethod(methodName = "postDelayed")
|
||||
// @ReplaceInvoke
|
||||
// fun handlerPostDelayProxy(handler: Handler, action: Runnable, delayMillis: Long): Boolean {
|
||||
// if (Looper.getMainLooper() != handler.looper) {
|
||||
// return handler.postDelayed(action, delayMillis)
|
||||
// }
|
||||
// val what = ObjectHashCodeUtils.getHashCodeIfNeed(action)
|
||||
// handler.removeMessages(what)
|
||||
// val msg = Message.obtain(handler, action)
|
||||
// msg.what = what
|
||||
// return handler.sendMessageDelayed(msg, delayMillis)
|
||||
// }
|
||||
//
|
||||
// @JvmStatic
|
||||
// @TargetClass(value = "android.app.Activity", scope = ALL)
|
||||
// @TargetMethod(methodName = "post")
|
||||
// @ReplaceInvoke
|
||||
// fun runOnUiThreadOfActivityProxy(activity: Activity, action: Runnable) {
|
||||
// if (Looper.myLooper() != Looper.getMainLooper()) {
|
||||
// UiThreadHandler.post(action)
|
||||
// } else {
|
||||
// activity.runOnUiThread(action)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @JvmStatic
|
||||
// @TargetClass(value = "android.view.View", scope = ALL)
|
||||
// @TargetMethod(methodName = "post")
|
||||
// @ReplaceInvoke
|
||||
// fun postOfViewProxy(view: View, action: Runnable): Boolean {
|
||||
// return if (Looper.myLooper() != Looper.getMainLooper()) {
|
||||
// UiThreadHandler.post(action)
|
||||
// } else {
|
||||
// view.post(action)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @JvmStatic
|
||||
// @TargetClass(value = "android.view.View", scope = ALL)
|
||||
// @TargetMethod(methodName = "postDelayed")
|
||||
// @ReplaceInvoke
|
||||
// fun postDelayedOfViewProxy(view: View, action: Runnable, delayMillis: Long): Boolean {
|
||||
// return if (Looper.myLooper() != Looper.getMainLooper()) {
|
||||
// UiThreadHandler.postDelayed(action, delayMillis)
|
||||
// } else {
|
||||
// view.postDelayed(action, delayMillis)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ import java.util.concurrent.ConcurrentHashMap
|
||||
@Group("memory_leak")
|
||||
class MemoryLeakFix {
|
||||
|
||||
@NameRegex("(com\\.mogo|com\\.zhidao|com\\.elegant|com\\.zhidaoauto|com\\.zhjt).*")
|
||||
@NameRegex("(com\\.zhidao|com\\.elegant|com\\.zhidaoauto|com\\.zhjt|com\\.mogo(?!(\\.thread\\.ext|\\.launcher\\.lancet))).*")
|
||||
@Insert(mayCreateSuper = true)
|
||||
@ImplementedInterface("java.lang.Runnable", scope = LEAF)
|
||||
@TargetMethod(methodName = "run")
|
||||
|
||||
@@ -13,7 +13,7 @@ import com.knightboost.lancet.api.annotations.Weaver;
|
||||
|
||||
@Weaver
|
||||
@Group("textview_opt")
|
||||
public class TextViewSetTextOpt {
|
||||
public class TextViewOpt {
|
||||
|
||||
@NameRegex("(com\\.mogo|com\\.zhidao|com\\.elegant|com\\.zhidaoauto|com\\.zhjt).*")
|
||||
@TargetClass(value = "android.widget.TextView",scope = Scope.ALL)
|
||||
@@ -33,7 +33,7 @@ public class TextViewSetTextOpt {
|
||||
return;
|
||||
}
|
||||
CharSequence old = view.getText();
|
||||
if (old != null && !old.equals(text)) {
|
||||
if (old == null || !old.equals(text)) {
|
||||
view.setText(text);
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,8 @@ object ConfigStartUp {
|
||||
// 临时配置json
|
||||
FunctionBuildConfig.tempConfig = BuildConfig.tempConfig
|
||||
|
||||
//是否支持Patch升级
|
||||
FunctionBuildConfig.isSupportPatchUpgrade = BuildConfig.IS_SUPPORT_PATCH_UPGRADE
|
||||
// // 这里影响当前Activity的身份信息,多进程先保持与原来一样,主进程为司机端,:passenger 进程为乘客端 TODO 暂时不启用,仅做洱海交付,独立乘客屏+宣传视频
|
||||
// if (ProcessUtils.getCurrentProcessName().contains(":passenger")) {
|
||||
// if (AppIdentityModeUtils.isBus(BuildConfig.APP_IDENTITY_MODE)) {
|
||||
@@ -93,12 +95,12 @@ object ConfigStartUp {
|
||||
if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) {
|
||||
HdMapBuildConfig.currentCarVrIconRes = R.raw.chuzuche
|
||||
} else if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) {
|
||||
HdMapBuildConfig.currentCarVrIconRes = R.raw.xiaobache
|
||||
HdMapBuildConfig.currentCarVrIconRes = R.raw.xiaoba
|
||||
} else if (AppIdentityModeUtils.isSweeper(FunctionBuildConfig.appIdentityMode)) {
|
||||
HdMapBuildConfig.currentCarVrIconRes = R.raw.huanwei
|
||||
}
|
||||
if (AppIdentityModeUtils.isJL(FunctionBuildConfig.appIdentityMode)){
|
||||
HdMapBuildConfig.currentCarVrIconRes = R.raw.xiaobache
|
||||
HdMapBuildConfig.currentCarVrIconRes = R.raw.xiaoba
|
||||
}
|
||||
if (AppIdentityModeUtils.isM1(FunctionBuildConfig.appIdentityMode)){
|
||||
HdMapBuildConfig.currentCarVrIconRes = R.raw.m1
|
||||
@@ -149,7 +151,13 @@ object ConfigStartUp {
|
||||
HDTypes.GUARDBAR.type,
|
||||
HDTypes.TRAFFIC_DEVICE.type,
|
||||
HDTypes.CABLE.type,
|
||||
HDTypes.SIGNAL_LINE.type
|
||||
HDTypes.SIGNAL_LINE.type,
|
||||
HDTypes.building.type,
|
||||
HDTypes.streetLight.type,
|
||||
HDTypes.area.type,
|
||||
HDTypes.regional.type,
|
||||
HDTypes.geometricLinear.type,
|
||||
HDTypes.geometricSurface.type
|
||||
)
|
||||
)
|
||||
// .setZoom( 20 )
|
||||
@@ -171,6 +179,7 @@ object ConfigStartUp {
|
||||
// shuttle m2 车需要偏移
|
||||
if (AppIdentityModeUtils.isM2(FunctionBuildConfig.appIdentityMode)) {
|
||||
mapParams.setCarPosition(-0.5f)
|
||||
mapParams.setDefaultPerspective(MapParams.MAP_STYLE_VR_ERHAI_B2)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user