Merge branch 'dev_arch_opt_3.0' of gitlab.zhidaoauto.com:zhjt/AndroidApp/MoGoEagleEye into dev_arch_opt_3.0

This commit is contained in:
lixiaopeng
2023-02-21 18:33:36 +08:00
30 changed files with 326 additions and 247 deletions

View File

@@ -55,7 +55,6 @@ dependencies {
implementation rootProject.ext.dependencies.androidxroomktx
implementation rootProject.ext.dependencies.mogoaicloudtelematic
implementation rootProject.ext.dependencies.amapnavi3dmap
implementation project(':libraries:mogo-obu')
implementation project(':libraries:mogo-adas')

View File

@@ -59,7 +59,7 @@ import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.support.obu.ObuScene
import com.zhidao.support.adas.high.AdasManager
import com.zhidao.support.adas.high.OnAdasListener
import com.zhidao.support.adas.high.bean.AutopilotStatistics
import com.zhjt.mogo.adas.data.bean.AutopilotStatistics
import com.zhidao.support.adas.high.common.ProtocolStatus
import com.zhjt.service.chain.ChainLog
import com.zhjt.service.chain.TracingConstants.Endpoint.Companion.PAD

View File

@@ -1,26 +1,21 @@
package com.mogo.eagle.core.function.datacenter.location
import com.amap.api.location.AMapLocation
import com.amap.api.location.AMapLocationClient
import com.amap.api.location.AMapLocationClientOption
import com.amap.api.location.AMapLocationListener
import com.mogo.commons.AbsMogoApplication
import com.mogo.commons.constants.SharedPrefsConstants
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.enums.DataSourceType
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisGnssListener
import com.mogo.eagle.core.function.api.map.listener.IGaoDeMapLocationListener
import com.mogo.eagle.core.function.api.obu.IMoGoObuLocationWGS84Listener
import com.mogo.eagle.core.function.call.autopilot.CallerChassisGnssListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
import com.mogo.eagle.core.function.call.map.CallerGaoDeMapLocationListenerManager
import com.mogo.eagle.core.function.call.obu.CallerObuLocationWGS84ListenerManager
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
import com.mogo.eagle.core.utilcode.util.CoordinateTransform
import com.mogo.eagle.core.utilcode.util.MultiDisplayUtils
import com.mogo.eagle.core.utilcode.util.TimeUtils
import com.mogo.eagle.core.utilcode.util.Utils
import com.mogo.support.obu.model.MogoObuHvBasicsData
import mogo.telematics.pad.MessagePad
/**
@@ -31,12 +26,11 @@ import mogo.telematics.pad.MessagePad
object MoGoLocationDispatcher :
IMoGoChassisGnssListener,
IMoGoObuLocationWGS84Listener,
AMapLocationListener {
IGaoDeMapLocationListener {
private const val TAG = "MoGoLocationManager"
private var mCityCode: String? = null
private var mapLocation: AMapLocation? = null
/**
* 最后一次工控机GNSS返回更新的位置
@@ -54,33 +48,10 @@ object MoGoLocationDispatcher :
private var lastGaoDeLocation: MogoLocation = MogoLocation()
fun initListener() {
// 高德SDK隐私政策
AMapLocationClient.updatePrivacyShow(Utils.getApp(), true, true)
AMapLocationClient.updatePrivacyAgree(Utils.getApp(), true)
try {
val mLocationClient = AMapLocationClient(Utils.getApp())
//初始化定位参数
//声明mLocationOption对象
val mLocationOption = AMapLocationClientOption()
//设置定位监听
mLocationClient.setLocationListener(this)
//设置定位模式为高精度模式Battery_Saving为低功耗模式Device_Sensors是仅设备模式
mLocationOption.locationMode = AMapLocationClientOption.AMapLocationMode.Hight_Accuracy
//设置定位间隔,单位毫秒,默认为2000ms
mLocationOption.interval = 1000
//设置定位参数
mLocationClient.setLocationOption(mLocationOption)
// 启动定位监听
mLocationClient.startLocation()
} catch (e: Exception) {
e.printStackTrace()
}
// 初始化监听订阅工控机位置信息
CallerChassisGnssListenerManager.addListener(TAG, this)
CallerObuLocationWGS84ListenerManager.addListener(TAG, this)
CallerGaoDeMapLocationListenerManager.addListener(TAG, this)
}
override fun onChassisGnss(gnssInfo: MessagePad.GnssInfo) {
@@ -88,13 +59,13 @@ object MoGoLocationDispatcher :
lastGnssLocation.gnssInfo = gnssInfo
lastGnssLocation.lastReceiveTime = TimeUtils.getNowMills()
// 将高德中的一些用于业务的数据进行融合例如CityCode、address等
mapLocation?.let {
lastGaoDeLocation.let {
//agps 高德
//agps_rtk 高德-高精
lastGnssLocation.locType = 1000 // 定位类型为WGS84进行转译的坐标
lastGnssLocation.satellite = 4
lastGnssLocation.cityName = it.city
lastGnssLocation.cityName = it.cityName
lastGnssLocation.cityCode = it.cityCode
lastGnssLocation.provider = it.provider
lastGnssLocation.address = it.address
@@ -128,79 +99,42 @@ object MoGoLocationDispatcher :
MultiDisplayUtils.getOtherDisplay()
}
/**
* 高德地图位置改变回调
* @param aMapLocation 位置信息
* @param mogoLocation 位置信息
*/
override fun onLocationChanged(aMapLocation: AMapLocation) {
mapLocation = aMapLocation
// 更新GNSS 信息
lastGaoDeLocation.lastReceiveTime = TimeUtils.getNowMills()
// 将高德中的一些用于业务的数据进行融合例如CityCode、address等
mapLocation?.let {
// 转换 GCJ02-->WGS84 坐标
val wgs84Location =
CoordinateTransform.GCJ02ToWGS84(it.longitude, it.latitude)
lastGaoDeLocation.longitude = wgs84Location[0]
lastGaoDeLocation.latitude = wgs84Location[1]
lastGaoDeLocation.heading = it.bearing.toDouble()
lastGaoDeLocation.gnssSpeed = it.speed
lastGaoDeLocation.altitude = it.altitude
lastGaoDeLocation.satelliteTime = it.time
lastGaoDeLocation.lastReceiveTime = TimeUtils.getNowMills()
lastGaoDeLocation.locType = 1 // 定位类型为高德坐标(网路或者硬件定位)
lastGaoDeLocation.satellite = 4
lastGaoDeLocation.cityName = it.city
lastGaoDeLocation.cityCode = it.cityCode
lastGaoDeLocation.provider = it.provider
lastGaoDeLocation.address = it.address
lastGaoDeLocation.district = it.district
lastGaoDeLocation.province = it.province
lastGaoDeLocation.adCode = it.adCode
lastGaoDeLocation.locationDetail = it.locationDetail
lastGaoDeLocation.poiName = it.poiName
lastGaoDeLocation.aoiName = it.aoiName
lastGaoDeLocation.street = it.street
lastGaoDeLocation.streetNum = it.streetNum
lastGaoDeLocation.description = it.description
lastGaoDeLocation.buildingId = it.buildingId
lastGaoDeLocation.floor = it.floor
lastGaoDeLocation.errorCode = it.errorCode
lastGaoDeLocation.errorInfo = it.errorInfo
}
override fun onMoGoLocationChanged(mogoLocation: MogoLocation) {
// 更新GaoDe 信息
lastGaoDeLocation = mogoLocation
// 计算最后一次工控机同步的定位是否超时,如果超时则切换为高德地图定位,暂定超过30秒需要切换
if (1 == FunctionBuildConfig.gpsProvider) {
if (TimeUtils.getNowMills() - lastGnssLocation.lastReceiveTime > 30000) {
if (TimeUtils.getNowMills() - lastGnssLocation.lastReceiveTime > 10000) {
syncGaoDeLocation()
}
} else if (2 == FunctionBuildConfig.gpsProvider) {
if (TimeUtils.getNowMills() - lastOBULocation.lastReceiveTime > 30000) {
if (TimeUtils.getNowMills() - lastOBULocation.lastReceiveTime > 10000) {
syncGaoDeLocation()
}
}
// 本地SP缓存城市Code
val cityCode = aMapLocation.cityCode
val cityCode = mogoLocation.cityCode
if (cityCode != null && cityCode.isNotEmpty()) {
mCityCode = aMapLocation.cityCode
mCityCode = mogoLocation.cityCode
SharedPrefsMgr.getInstance(AbsMogoApplication.getApp())
.putString(SharedPrefsConstants.LOCATION_CITY_CODE, cityCode)
SharedPrefsMgr.getInstance(AbsMogoApplication.getApp())
.putString(
SharedPrefsConstants.LOCATION_LATITUDE,
aMapLocation.latitude.toString()
mogoLocation.latitude.toString()
)
SharedPrefsMgr.getInstance(AbsMogoApplication.getApp())
.putString(
SharedPrefsConstants.LOCATION_LONGITUDE,
aMapLocation.longitude.toString()
mogoLocation.longitude.toString()
)
}
@@ -236,13 +170,13 @@ object MoGoLocationDispatcher :
lastOBULocation.lastReceiveTime = TimeUtils.getNowMills()
// 将高德中的一些用于业务的数据进行融合例如CityCode、address等
mapLocation?.let {
lastGaoDeLocation.let {
//agps 高德
//agps_rtk 高德-高精
lastOBULocation.locType = 1000 // 定位类型为WGS84进行转译的坐标
lastOBULocation.satellite = 4
lastOBULocation.cityName = it.city
lastOBULocation.cityName = it.cityName
lastOBULocation.cityCode = it.cityCode
lastOBULocation.provider = it.provider
lastOBULocation.address = it.address
@@ -274,4 +208,5 @@ object MoGoLocationDispatcher :
)
}
}
}

View File

@@ -2,6 +2,7 @@ package com.mogo.eagle.core.function.msgbox
import android.content.Context
import android.os.Looper
import com.mogo.eagle.core.data.enums.DataSourceType
import com.mogo.eagle.core.data.msgbox.*
import com.mogo.eagle.core.data.report.ReportEntity
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxListenerManager
@@ -87,7 +88,16 @@ object DataManager {
msg.timestamp = System.currentTimeMillis()
msg.bean2Json = GsonUtils.toJson(msg.bean)
when (type) {
MsgBoxType.V2X, MsgBoxType.OBU, MsgBoxType.NOTICE, MsgBoxType.OPERATION -> {
MsgBoxType.V2X -> {
// 汇总消息不存数据库
if (msg.sourceType != DataSourceType.SUMMARY) {
synchronized(this) {
notifyList.add(msg)
}
}
CallerMsgBoxListenerManager.invokeListener(MsgCategory.NOTICE, msg)
}
MsgBoxType.OBU, MsgBoxType.NOTICE, MsgBoxType.OPERATION -> {
synchronized(this) {
notifyList.add(msg)
}

View File

@@ -60,8 +60,8 @@ class OfflineMapDialog(context: Context): BaseFloatDialog(context) {
leftView?.setOnClickListener {
when {
isConfirm -> {
cacheHDOfflineData()
showNewContent(isLoading = true, false)
cacheHDOfflineData()
}
else -> {
dismiss()
@@ -72,6 +72,7 @@ class OfflineMapDialog(context: Context): BaseFloatDialog(context) {
rightView?.setOnClickListener {
when {
isRetry -> {
showNewContent(isLoading = true, false)
cacheHDOfflineData()
}
else -> {
@@ -81,6 +82,9 @@ class OfflineMapDialog(context: Context): BaseFloatDialog(context) {
}
okView?.setOnClickListener {
if (isLoading) {
CallerMapUIServiceManager.cancelDownloadCacheData()
}
dismiss()
}
}
@@ -90,6 +94,12 @@ class OfflineMapDialog(context: Context): BaseFloatDialog(context) {
override fun onMapHdCacheProgress(cityId: Int, progress: Double) {
updateProgress(progress.toInt())
}
override fun onMapHdCacheResult(cityId: Int, state: Int) {
if (state == 0) {// 失败
showNewContent(isLoading = false, false)
}
}
})
}
@@ -131,6 +141,7 @@ class OfflineMapDialog(context: Context): BaseFloatDialog(context) {
@SuppressLint("UseCompatLoadingForDrawables")
private fun showNewContent(isLoading: Boolean, isSuccess: Boolean) {
this.isLoading = isLoading
change2NewStyle()
when {
isLoading -> {
@@ -150,11 +161,14 @@ class OfflineMapDialog(context: Context): BaseFloatDialog(context) {
downloadResultImg?.background = ContextCompat.getDrawable(context, R.drawable.download_success_icon)
}
else -> {
isRetry = true
isConfirm = false
offlineTitleView?.text = context.resources.getString(R.string.offline_download_failure)
okView?.visibility = View.GONE
progressBar?.visibility = View.GONE
downloadPercentView?.visibility = View.GONE
leftView?.visibility = View.VISIBLE
leftView?.text = context.resources.getString(R.string.ok_tip)
rightView?.visibility = View.VISIBLE
vertLineView?.visibility = View.VISIBLE
rightView?.text = context.resources.getString(R.string.retry)

View File

@@ -60,7 +60,6 @@ dependencies {
implementation rootProject.ext.dependencies.mogocustommap
implementation rootProject.ext.dependencies.amapnavi3dmap
// implementation rootProject.ext.dependencies.amaplocation
implementation rootProject.ext.dependencies.androidxroomruntime
kapt rootProject.ext.dependencies.androidxroomcompiler

View File

@@ -141,8 +141,9 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
}
if (mogoLocation != null && mogoLocation.latitude != 0.0 && mogoLocation.longitude != 0.0) {
// 更新
httpDnsSimpleLocation = if (mogoLocation.cityCode.isNullOrEmpty()
&& !CallerMapUIServiceManager.getGDLocationServer(context!!)?.lastCityCode.isNullOrEmpty()
httpDnsSimpleLocation = if (
mogoLocation.cityCode.isNullOrEmpty() &&
!CallerMapUIServiceManager.getGDLocationServer(context!!)?.lastCityCode.isNullOrEmpty()
) {
HttpDnsSimpleLocation(
CallerMapUIServiceManager.getGDLocationServer(context!!)?.lastCityCode
@@ -233,7 +234,7 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
}
private fun startSocketService() {
CallerLogger.d("$M_MAIN$TAG","startSocketService")
CallerLogger.d("$M_MAIN$TAG", "startSocketService")
val location = CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02()
MogoAiCloudSocketManager.getInstance(context)
.registerLifecycleListener(10020, object : IMogoLifecycleListener {
@@ -306,7 +307,10 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
clientPkFileName = "sn"
)
private fun reConnectSocket(oldCityCode: String, newCityCode: String) {
CallerLogger.d("$M_MAIN$TAG", "reConnectSocket oldCityCode : $oldCityCode , newCityCode : $newCityCode")
CallerLogger.d(
"$M_MAIN$TAG",
"reConnectSocket oldCityCode : $oldCityCode , newCityCode : $newCityCode"
)
MogoAiCloudSocketManager.getInstance(context).reConnect()
}