[Opt3.0]新增StartUp模块并调整启动顺序

This commit is contained in:
chenfufeng
2023-01-31 11:39:36 +08:00
parent fa04cc6f0b
commit dcc98b078b
35 changed files with 437 additions and 240 deletions

View File

@@ -1,28 +1,12 @@
package com.mogo.launcher;
import android.content.Context;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
import com.mogo.eagle.core.function.call.startup.CallerStartUpManager;
import com.mogo.eagle.core.function.main.MainMoGoApplication;
import com.mogo.eagle.core.utilcode.mogo.logger.LogLevel;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.eagle.core.utilcode.util.ProcessUtils;
import com.mogo.launcher.crash.CrashSystem;
import com.mogo.launcher.stageone.APMStartup;
import com.mogo.launcher.stageone.ARouterStartUp;
import com.mogo.launcher.stageone.ConfigStartUp;
import com.mogo.launcher.stageone.HttpDnsStartUp;
import com.mogo.launcher.stageone.ThreadOptStartup;
import com.rousetime.android_startup.StartupListener;
import com.rousetime.android_startup.StartupManager;
import com.rousetime.android_startup.model.LoggerLevel;
import com.rousetime.android_startup.model.StartupConfig;
import com.zhidaoauto.map.sdk.open.HDTypes;
import com.zhidaoauto.map.sdk.open.MapAutoApi;
import com.zhidaoauto.map.sdk.open.MapParams;
import org.greenrobot.eventbus.EventBus;
import com.mogo.launcher.startup.ARouterStartUp;
import com.mogo.launcher.startup.ConfigStartUp;
/**
* @author congtaowang
@@ -34,43 +18,12 @@ public class MogoApplication extends MainMoGoApplication {
@Override
public void onCreate() {
startUpInStage1();
ARouterStartUp.init(this);
ConfigStartUp.init(this);
CallerStartUpManager.initStageOne();
super.onCreate();
}
private final StartupListener startupListener = (l, costTimesModels) -> EventBus.getDefault().postSticky(costTimesModels);
/**
* 第一阶段初始化
*/
public void startUpInStage1() {
StartupConfig config = null;
if (DebugConfig.isDebug()) {
config = new StartupConfig.Builder()
.setLoggerLevel(LoggerLevel.DEBUG)
.setOpenStatistics(true)
.setListener(startupListener)
.build();
} else {
config = new StartupConfig.Builder()
.setLoggerLevel(LoggerLevel.NONE)
.setOpenStatistics(false)
.setAwaitTimeout(10000L)
.setListener(startupListener)
.build();
}
new StartupManager.Builder()
.addStartup(new HttpDnsStartUp())
.addStartup(new APMStartup())
.addStartup(new ConfigStartUp())
.addStartup(new ARouterStartUp())
.addStartup(new ThreadOptStartup())
.setConfig(config)
.build(this)
.start()
.await();
}
@Override
protected void initCrashConfig() {
CrashSystem crashSystem = CrashSystem.getInstance(this);

View File

@@ -1,27 +0,0 @@
package com.mogo.launcher.stageone
import android.content.Context
import com.rousetime.android_startup.AndroidStartup
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.test.crashreport.upgrade.UpgradeReportConstants
import com.mogo.test.crashreport.CrashReportConstants
class APMStartup : AndroidStartup<Boolean?>() {
override fun create(context: Context): Boolean? {
// apm
ARouter.getInstance().build(CrashReportConstants.PATH).navigation()
return true
}
override fun callCreateOnMainThread(): Boolean {
return true
}
override fun waitOnMainThread(): Boolean {
return false
}
override fun dependenciesByName(): List<String> {
return listOf("com.mogo.launcher.stageone.ARouterStartUp","com.mogo.launcher.stageone.ConfigStartUp")
}
}

View File

@@ -1,382 +0,0 @@
package com.mogo.launcher.stageone
import android.content.Context
import com.mogo.aicloud.services.httpdns.HttpDnsConst
import com.mogo.aicloud.services.httpdns.IMogoHttpDns
import com.mogo.aicloud.services.httpdns.MogoHttpDnsHandler
import com.mogo.aicloud.services.locationinfo.MogoLocationInfoServices
import com.mogo.aicloud.services.socket.IMogoLifecycleListener
import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager
import com.mogo.cloud.httpdns.MogoHttpDnsConfig
import com.mogo.cloud.httpdns.bean.HttpDnsSimpleLocation
import com.mogo.cloud.httpdns.listener.IHttpDnsCurrentLocation
import com.mogo.cloud.httpdns.listener.OnAddressChangedListener
import com.mogo.cloud.passport.IMoGoTokenCallback
import com.mogo.cloud.passport.MoGoAiCloudClient
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.commons.AbsMogoApplication
import com.mogo.commons.constants.HostConst
import com.mogo.commons.constants.SharedPrefsConstants
import com.mogo.commons.debug.DebugConfig
import com.mogo.commons.module.status.MogoStatusManager
import com.mogo.commons.network.NetConfigUtils
import com.mogo.commons.network.Utils
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_CLOUD_CONNECT_FAIL
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_CLOUD_CONNECT_LOST
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_CLOUD_CONNECT_SUCCESS
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_HTTP_DNS_CHANGED
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_CLOUD
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_CONNECT_STATUS
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.autopilot.*
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener
import com.mogo.eagle.core.function.call.analytics.AnalyticsManager
import com.mogo.eagle.core.function.call.autopilot.*
import com.mogo.eagle.core.function.call.cloud.CallerCloudListenerManager
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
import com.mogo.eagle.core.utilcode.util.AppUtils
import com.mogo.eagle.core.utilcode.util.ProcessUtils
import com.mogo.eagle.core.utilcode.util.ThreadPoolService
import com.mogo.eagle.core.utilcode.util.TimeUtils
import com.rousetime.android_startup.AndroidStartup
import com.zhjt.mogo_core_function_devatools.env.EnvChangeManager
import com.zhjt.service.chain.ChainLog
import com.zhjt.service.chain.TracingConstants.Endpoint.Companion.PAD
import mogo.telematics.pad.MessagePad.GnssInfo
class HttpDnsStartUp : AndroidStartup<Boolean>() {
private val TAG = "MogoApplication"
// 配置云服务API
private val clientConfig by lazy {
MoGoAiCloudClientConfig.getInstance()
}
// 缓存IP地址
private var cacheIp: String? = null
private lateinit var mogoHttpDns: IMogoHttpDns
private var context: Context? = null
private var gotToken = false
override fun callCreateOnMainThread() = true
override fun waitOnMainThread() = false
override fun dependenciesByName(): List<String> {
return listOf(
"com.mogo.launcher.stageone.APMStartup"
)
}
override fun create(context: Context): Boolean {
this.context = context
// TODO 需要与,陈扶风,确认为啥要限制仅在主进程
// if (ProcessUtils.isMainProcess(context)) {
initGDLoc()
initHttpDns()
// }
return true
}
private fun initGDLoc() {
CallerMapUIServiceManager.getGDLocationServer(context!!)?.start()
}
/**
* 初始化 HttpDNS ,这里会通过一个接口获取所有鹰眼中使用的微服务域名以及端口号
* 后续的网络请求会通过 HttpDnsInterceptor 进行拦截替换
*/
private fun initHttpDns() {
mogoHttpDns = MogoHttpDnsHandler.getHttpDnsApi()
preparePassportEnvironment()
}
private fun preparePassportEnvironment() {
// 设置网络环境HTTP_DNS_ENV_QA、HTTP_DNS_ENV_RELEASE、HTTP_DNS_ENV_DEV
when (DebugConfig.getNetMode()) {
DebugConfig.NET_MODE_DEV -> clientConfig.netMode = MogoHttpDnsConfig.HTTP_DNS_ENV_DEV
DebugConfig.NET_MODE_QA -> clientConfig.netMode = MogoHttpDnsConfig.HTTP_DNS_ENV_QA
DebugConfig.NET_MODE_DEMO -> clientConfig.netMode = MogoHttpDnsConfig.HTTP_DNS_ENV_DEMO
else -> clientConfig.netMode = MogoHttpDnsConfig.HTTP_DNS_ENV_RELEASE
}
// 设置是否是第三APP登录
clientConfig.isThirdLogin =
DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_SELF_INNOVATE
// 设置是否输出日志
clientConfig.isShowDebugLog = true
// 使用中台长链接
clientConfig.isUseOriginSocket = true
// 设置是否输出网络日志
clientConfig.isShowNetDebugLog = false
// 设置是否是直播推流的主播
clientConfig.isAnchor = true
when (DebugConfig.getCarMachineType()) {
DebugConfig.CAR_MACHINE_TYPE_BYD -> clientConfig.thirdPartyAppKey = "bydauto"
DebugConfig.CAR_MACHINE_TYPE_LENOVO -> clientConfig.thirdPartyAppKey = "pfieouqg"
else -> clientConfig.thirdPartyAppKey = "wbvpzgar"
}
// 设置应用服务AppId 长链、鉴权
if (DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE) {
clientConfig.serviceAppId = "com_mogo_launcher"
} else {
clientConfig.serviceAppId = "com.mogo.launcher"
}
// 设置AI云平台分配给三方应用的签名密钥需要从AI云平台申请
// 设置车机设备的唯一标识(这些表识必须是通过后台录入的设备)
// TODO 现在这块逻辑因为网约车业务那后台的限制,还没有更换,条件成熟后替换为 DeviceIdUtils.getWidevineIDWithMd5(context)
// 这里影响当前Activity的身份信息多进程先保持与原来一样主进程为司机端:passenger 进程为乘客端
if (ProcessUtils.getCurrentProcessName().contains(":passenger")) {
clientConfig.thirdPartyDeviceId = Utils.getDevicesId() + "_passenger"
} else {
clientConfig.thirdPartyDeviceId = Utils.getDevicesId()
}
// 设置循环检测间隔时间每隔2小时loop一次httpDnsConfig
clientConfig.loopCheckDelay = (60 * 60 * 2 * 1000).toLong()
//设置长链接的secretKey //todo 通过SHA1和包名找中台服务生成后续包名分渠道,需要做对应操作
clientConfig.secretKey = "YMj2VFDFxJ3Q4gNoZceJ"
clientConfig.iHttpDnsCurrentLocation = object : IHttpDnsCurrentLocation {
override fun getCurrentLocation(): HttpDnsSimpleLocation {
val envConfig = EnvChangeManager.getEnvConfig()
if (envConfig != null) {
return HttpDnsSimpleLocation(envConfig.cityCode, envConfig.lat, envConfig.lon)
}
var mogoLocation: MogoLocation? = null
val locationClient = CallerMapLocationListenerManager.getCurrentLocation()
if (locationClient != null) {
mogoLocation = locationClient
}
val httpDnsSimpleLocation =
if (mogoLocation != null && mogoLocation.latitude != 0.0 && mogoLocation.longitude != 0.0) {
if (mogoLocation.cityCode.isNullOrEmpty()
&& !CallerMapUIServiceManager.getGDLocationServer(context!!)?.lastCityCode.isNullOrEmpty()
) {
HttpDnsSimpleLocation(
CallerMapUIServiceManager.getGDLocationServer(context!!)?.lastCityCode
?: "010",
mogoLocation.latitude,
mogoLocation.longitude
)
} else {
HttpDnsSimpleLocation(
mogoLocation.cityCode,
mogoLocation.latitude,
mogoLocation.longitude
)
}
} else {
val ciyCode =
SharedPrefsMgr.getInstance(
AbsMogoApplication.getApp()
)
.getString(SharedPrefsConstants.LOCATION_CITY_CODE)
val latitude =
SharedPrefsMgr.getInstance(
AbsMogoApplication.getApp()
)
.getString(SharedPrefsConstants.LOCATION_LATITUDE)
val longitude =
SharedPrefsMgr.getInstance(
AbsMogoApplication.getApp()
)
.getString(SharedPrefsConstants.LOCATION_LONGITUDE)
try {
HttpDnsSimpleLocation(
ciyCode, latitude.toDouble(), longitude.toDouble()
)
} catch (e: NumberFormatException) {
// e.printStackTrace();
HttpDnsSimpleLocation("010", 1.0, 1.0)
}
}
return httpDnsSimpleLocation
}
}
initAiCloudSDK()
}
private fun initAiCloudSDK() {
// 初始化SDK可以设置状态回调来监听
MoGoAiCloudClient.getInstance().init(context, clientConfig).addTokenCallbacks(
object : IMoGoTokenCallback {
override fun onTokenGot(token: String, sn: String) {
clientConfig.token = token
// 由于存在token过期问题在更新后会回调至此处增加二次判定
if (!gotToken) {
CallerLogger.d(
SceneConstant.M_MAIN + TAG,
"onTokenGot token : $token , sn :$sn"
)
CallerCloudListenerManager.invokeCloudTokenGot(token, sn)
// 异步初始化NetConfig
asyncInit()
// HttpDns ttl回调 --- socketTTL
// registerSocketHttpDnsTTL()
startSocketService()
// 开启每5s/次定位上报
uploadLocPerFiveSecond()
gotToken = true
}
}
override fun onError(code: Int, msg: String) {
CallerLogger.d(
SceneConstant.M_MAIN + TAG,
"初始化MogoAiCloudSdk failed ,reason : $msg , 未能开启长链服务和初始化Modules服务"
)
}
}
)
}
/**
* 异步初始化
*/
private fun asyncInit() {
ThreadPoolService.execute {
//初始化网络配置
NetConfigUtils.init()
// 初始化埋点
AnalyticsManager.init(context, DebugConfig.isDebug())
// 加入启动统计
val mStartParams: HashMap<String, Any> = HashMap()
mStartParams["start_time"] = TimeUtils.getNowMills()
mStartParams["app_version"] = AppUtils.getAppVersionName()
mStartParams["app_flavor"] = DebugConfig.getProductFlavor();
mStartParams["app_identity_mode"] = FunctionBuildConfig.appIdentityMode
AnalyticsManager.track("app_start_time", mStartParams)
}
}
/**
* 请求获取最新的 DNS 微服务 域名信息
*/
private fun registerSocketHttpDnsTTL() {
mogoHttpDns.addressChangedListener(object : OnAddressChangedListener {
@ChainLog(
linkChainLog = CHAIN_LINK_LOG_CONNECT_STATUS,
linkCode = CHAIN_LINK_CLOUD,
endpoint = PAD,
nodeAliasCode = CHAIN_ALIAS_CODE_HTTP_DNS_CHANGED,
paramIndexes = [0, 1],
clientPkFileName = "sn"
)
override fun onAddressChanged(cityCode: String, address: Map<String, String>?) {
val dnsCacheIp = mogoHttpDns.getCachedHttpDnsIps(
HostConst.SOCKET_CENTER_DOMAIN,
HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_HTTP
) ?: return
if (dnsCacheIp != cacheIp) {
CallerLogger.d(
SceneConstant.M_MAIN + TAG,
"获取缓存Dns IP : $dnsCacheIp , 原缓存 IP $cacheIp"
)
cacheIp = dnsCacheIp
}
}
})
}
/**
* 上传自车位置信息到云端
*/
private fun uploadLocPerFiveSecond() {
if (DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_SELF_INNOVATE) {
context?.let {
MogoLocationInfoServices.getInstance().init(it)
MogoLocationInfoServices.getInstance().start()
CallerChassisLocationGCJ20ListenerManager.addListener(
TAG,
object : IMoGoChassisLocationGCJ02Listener {
override fun onChassisLocationGCJ02(gnssInfo: GnssInfo?) {
CallerMapLocationListenerManager.getCurrentLocation()?.let { loc ->
MogoLocationInfoServices.getInstance().provideLocation(loc)
}
}
},
)
}
}
}
private fun startSocketService() {
CallerLogger.d(SceneConstant.M_MAIN + TAG, "startSocketService")
val location = CallerMapLocationListenerManager.getCurrentLocation()
// 关闭长链服务
MogoAiCloudSocketManager.getInstance(context).destroy()
MogoAiCloudSocketManager.getInstance(context)
.registerLifecycleListener(10020, object : IMogoLifecycleListener {
@ChainLog(
linkChainLog = CHAIN_LINK_LOG_CONNECT_STATUS,
linkCode = CHAIN_LINK_CLOUD,
endpoint = PAD,
nodeAliasCode = CHAIN_ALIAS_CODE_CLOUD_CONNECT_FAIL,
paramIndexes = [-1],
clientPkFileName = "sn"
)
override fun onConnectFailure() {
CallerLogger.d(SceneConstant.M_MAIN + TAG, "socket-onConnectFailure")
MogoStatusManager.getInstance().setCloudSocketMode(TAG, false)
}
@ChainLog(
linkChainLog = CHAIN_LINK_LOG_CONNECT_STATUS,
linkCode = CHAIN_LINK_CLOUD,
endpoint = PAD,
nodeAliasCode = CHAIN_ALIAS_CODE_CLOUD_CONNECT_SUCCESS,
paramIndexes = [-1],
clientPkFileName = "sn"
)
override fun onConnectSuccess() {
CallerLogger.d(SceneConstant.M_MAIN + TAG, "socket-onConnectSuccess")
MogoStatusManager.getInstance().setCloudSocketMode(TAG, true)
}
@ChainLog(
linkChainLog = CHAIN_LINK_LOG_CONNECT_STATUS,
linkCode = CHAIN_LINK_CLOUD,
endpoint = PAD,
nodeAliasCode = CHAIN_ALIAS_CODE_CLOUD_CONNECT_LOST,
paramIndexes = [-1],
clientPkFileName = "sn"
)
override fun onConnectLost() {
CallerLogger.d(SceneConstant.M_MAIN + TAG, "socket-onConnectLost")
MogoStatusManager.getInstance().setCloudSocketMode(TAG, false)
}
@ChainLog(
linkChainLog = CHAIN_LINK_LOG_CONNECT_STATUS,
linkCode = CHAIN_LINK_CLOUD,
endpoint = PAD,
nodeAliasCode = CHAIN_ALIAS_CODE_CLOUD_CONNECT_LOST,
paramIndexes = [0, 1],
clientPkFileName = "sn"
)
override fun onError(code: String, msg: String?) {
CallerLogger.d(
SceneConstant.M_MAIN + TAG,
"socket-onError code : $code , msg : $msg"
)
}
})
// 开启Socket长链服务
val lat =
location?.latitude ?: CallerMapUIServiceManager.getGDLocationServer(context!!)!!.lastLat
val lon = location?.longitude
?: CallerMapUIServiceManager.getGDLocationServer(context!!)!!.lastLon
MogoAiCloudSocketManager.getInstance(context)
.init(context, DebugConfig.getSocketAppId(), lat, lon)
}
}

View File

@@ -1,43 +0,0 @@
package com.mogo.launcher.stageone
import com.mogo.launcher.BuildConfig
import com.rousetime.android_startup.StartupListener
import com.rousetime.android_startup.model.CostTimesModel
import com.rousetime.android_startup.model.LoggerLevel
import com.rousetime.android_startup.model.StartupConfig
import com.rousetime.android_startup.provider.StartupProviderConfig
import org.greenrobot.eventbus.EventBus
class MogoStartupProviderConfig: StartupProviderConfig {
private val startupListener by lazy {
object : StartupListener {
override fun onCompleted(
totalMainThreadCostTime: Long,
costTimesModels: List<CostTimesModel>
) {
EventBus.getDefault().postSticky(costTimesModels)
}
}
}
override fun getConfig(): StartupConfig {
return when {
BuildConfig.DEBUG -> {
StartupConfig.Builder()
.setLoggerLevel(LoggerLevel.DEBUG)
.setOpenStatistics(true)
.setListener(startupListener)
.build()
}
else -> {
StartupConfig.Builder()
.setLoggerLevel(LoggerLevel.NONE)
.setOpenStatistics(false)
.setAwaitTimeout(10000L)
.setListener(startupListener)
.build()
}
}
}
}

View File

@@ -1,33 +0,0 @@
package com.mogo.launcher.stageone
import android.content.*
import com.mogo.thread.ext.core.*
import com.mogo.thread.ext.core.config.*
import com.rousetime.android_startup.*
import java.io.*
import java.text.SimpleDateFormat
import java.util.*
import java.util.concurrent.TimeUnit.SECONDS
class ThreadOptStartup: AndroidStartup<Boolean>() {
override fun create(context: Context): Boolean {
ThreadManager
.init(ThreadConfig.Builder()
.maxKeepAliveTime(5, SECONDS)
/*.dump(DumpConfig.Builder()
.dumpLogFilePath(File(context.getExternalFilesDir(null), "thread_dump_log_${ SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.ROOT).format(Date()) }.txt").absolutePath)
.dumpPeriod(5, SECONDS)
.threadRunThreshold(10, SECONDS)
.build())*/)
return true
}
override fun callCreateOnMainThread(): Boolean {
return true
}
override fun waitOnMainThread(): Boolean {
return true
}
}

View File

@@ -1,25 +1,22 @@
package com.mogo.launcher.stageone
package com.mogo.launcher.startup
import android.app.Application
import android.content.Context
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.commons.debug.DebugConfig
import com.mogo.eagle.core.utilcode.util.AppUtils
import com.mogo.eagle.core.utilcode.util.CleanUtils
import com.rousetime.android_startup.AndroidStartup
import java.lang.Exception
class ARouterStartUp : AndroidStartup<String>() {
override fun callCreateOnMainThread() = true
override fun create(context: Context): String {
object ARouterStartUp {
@JvmStatic
fun init(app: Application) {
try {
if (DebugConfig.isDebug()) {
ARouter.openDebug()
ARouter.openLog()
}
// 初始化 arouter
ARouter.init(context as Application?)
ARouter.init(app)
} catch (e: Exception) {
e.printStackTrace()
// 由于ARouter会在SP_AROUTER_CACHE.xml缓存路由表如果出现了被删除的情况会报错这里清除下就好了
@@ -27,12 +24,5 @@ class ARouterStartUp : AndroidStartup<String>() {
// 重启应用
AppUtils.relaunchApp()
}
return this.javaClass.simpleName
}
override fun waitOnMainThread() = false
override fun dependenciesByName(): List<String>? {
return listOf("com.mogo.launcher.stageone.ThreadOptStartup")
}
}

View File

@@ -1,11 +1,9 @@
package com.mogo.launcher.stageone
package com.mogo.launcher.startup
import android.content.Context
import android.util.Log
import com.mogo.commons.debug.DebugConfig
import com.mogo.eagle.core.data.app.AppConfigInfo.appBuildTime
import com.mogo.eagle.core.data.app.AppConfigInfo.workingBranchHash
import com.mogo.eagle.core.data.app.AppConfigInfo.workingBranchName
import com.mogo.eagle.core.data.app.AppConfigInfo
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.config.HdMapBuildConfig
import com.mogo.eagle.core.data.config.HmiBuildConfig
@@ -16,30 +14,25 @@ import com.mogo.eagle.core.utilcode.util.ProcessUtils
import com.mogo.launcher.BuildConfig
import com.mogo.launcher.R
import com.mogo.test.crashreport.CrashReportConstants
import com.rousetime.android_startup.AndroidStartup
import com.zhidaoauto.map.sdk.open.HDTypes
import com.zhidaoauto.map.sdk.open.MapAutoApi
import com.zhidaoauto.map.sdk.open.MapParams
import com.zhjt.mogo_core_function_devatools.env.EnvChangeManager
class ConfigStartUp : AndroidStartup<Boolean>() {
object ConfigStartUp {
override fun callCreateOnMainThread() = true
override fun waitOnMainThread() = false
override fun create(context: Context): Boolean {
initDebugConfig(context)
@JvmStatic
fun init(context: Context) {
initDebugConfig()
initBuildConfig()
initOtherConfig(context)
return true
}
private fun initBuildConfig() {
// 初始化构建APP的时候的分支及提交HASH用于辅助定位问题
workingBranchName = BuildConfig.WORKING_BRANCH_NAME
workingBranchHash = BuildConfig.WORKING_BRANCH_HASH
appBuildTime = BuildConfig.APP_BUILD_TIME
AppConfigInfo.workingBranchName = BuildConfig.WORKING_BRANCH_NAME
AppConfigInfo.workingBranchHash = BuildConfig.WORKING_BRANCH_HASH
AppConfigInfo.appBuildTime = BuildConfig.APP_BUILD_TIME
// 使用与渠道配置一样的gps提供者提供的数据,app/productFlavors/fPadLenovo.gradle GPS_PROVIDER 0-Android系统1-工控机2-OBU
FunctionBuildConfig.gpsProvider = BuildConfig.GPS_PROVIDER
// FunctionBuildConfig.gpsProvider = 2
@@ -70,7 +63,7 @@ class ConfigStartUp : AndroidStartup<Boolean>() {
FunctionBuildConfig.adasConnectIP = BuildConfig.ADAS_CONNECT_IP
}
private fun initDebugConfig(context: Context) {
private fun initDebugConfig() {
var mode = BuildConfig.NET_ENV
val envConfig = EnvChangeManager.getEnvConfig()
if (envConfig != null) {
@@ -86,7 +79,6 @@ class ConfigStartUp : AndroidStartup<Boolean>() {
DebugConfig.setMapOptVersion(BuildConfig.MAP_SDK_OPT_VERSION)
DebugConfig.setNeedUploadCoordinatesInTime(BuildConfig.IS_NEED_UPLOAD_COORDINATES_IN_TIME)
DebugConfig.setMultiDisplay(BuildConfig.IS_MULTI_DISPLAY)
}
private fun initOtherConfig(context: Context) {
@@ -105,30 +97,36 @@ class ConfigStartUp : AndroidStartup<Boolean>() {
if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) {
//是否显示 限速UI
HmiBuildConfig.isShowLimitingVelocityView = false
//白天模式
FunctionBuildConfig.skinMode = 1
} else if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) {
//是否显示 限速UI
HmiBuildConfig.isShowLimitingVelocityView = false
}
}
val mapParams = MapParams.init()
mapParams.setDebugMode(false) //todo 1-使用本地地图数据0-使用在线地图数据
//.setDataFileSource(1)
.setCoordinateType(MapParams.COORDINATETYPE_GCJ02)
.setPerspectiveMode(MapParams.MAP_PERSPECTIVE_UP_CAR)
.setHDVisibileArray(intArrayOf(HDTypes.DIVIDER.type,
HDTypes.ROAD_AREA.type,
HDTypes.STOP_LINE.type,
HDTypes.ARROW.type,
HDTypes.STATION_BRIDGE.type,
HDTypes.ZEBRA_LINE.type,
HDTypes.GREEN_BELT.type,
HDTypes.DIVERSION.type,
HDTypes.SAFE_ISLAND.type,
HDTypes.ALPHANUMERIC.type,
HDTypes.GUARDBAR.type,
HDTypes.TRAFFIC_DEVICE.type,
HDTypes.CABLE.type,
HDTypes.SIGNAL_LINE.type))
//.setDataFileSource(1)
.setCoordinateType(MapParams.COORDINATETYPE_GCJ02)
.setPerspectiveMode(MapParams.MAP_PERSPECTIVE_UP_CAR)
.setHDVisibileArray(intArrayOf(
HDTypes.DIVIDER.type,
HDTypes.ROAD_AREA.type,
HDTypes.STOP_LINE.type,
HDTypes.ARROW.type,
HDTypes.STATION_BRIDGE.type,
HDTypes.ZEBRA_LINE.type,
HDTypes.GREEN_BELT.type,
HDTypes.DIVERSION.type,
HDTypes.SAFE_ISLAND.type,
HDTypes.ALPHANUMERIC.type,
HDTypes.GUARDBAR.type,
HDTypes.TRAFFIC_DEVICE.type,
HDTypes.CABLE.type,
HDTypes.SIGNAL_LINE.type))
// .setZoom( 20 )
// .setPointToCenter( 0.734375f, 0.5f )
//todo 2D模式下需要注意ADAS部分遮挡
@@ -148,5 +146,4 @@ class ConfigStartUp : AndroidStartup<Boolean>() {
MapAutoApi.init(context, mapParams)
}
}