[3.4.0-map-sdk] remove unuse thread to call mapdata api and fix bug of invoke suspend func which call

This commit is contained in:
zhongchao
2023-09-22 17:29:41 +08:00
parent 34f11edb96
commit cf747fc289
13 changed files with 138 additions and 234 deletions

View File

@@ -95,24 +95,10 @@ class OfflineMapDialog(context: Context) : BaseFloatDialog(context) {
private fun cacheHDDataByCityByLonLat() {
mogoMapData.get()?.cacheHDDataByCityByLonLat(location!!, { _, progress ->
if (Thread.currentThread() != Looper.getMainLooper().thread) {
ThreadUtils.runOnUiThread({
updateProgress(progress.toInt())
}, ThreadUtils.MODE.QUEUE)
} else {
updateProgress(progress.toInt())
}
}, { _, state ->
if (Thread.currentThread() != Looper.getMainLooper().thread) {
ThreadUtils.runOnUiThread({
if (state == 0) {// 失败
showNewContent(isLoading = false, false)
}
}, ThreadUtils.MODE.QUEUE)
} else {
if (state == 0) {// 失败
showNewContent(isLoading = false, false)
}
if (state == 0) {// 失败
showNewContent(isLoading = false, false)
}
})
}
@@ -120,24 +106,10 @@ class OfflineMapDialog(context: Context) : BaseFloatDialog(context) {
private fun cacheHDOfflineData() {
if (location == null) {// 拿到了高德地图的cityCode
mogoMapData.get()?.cacheHDDataByCity({ _, progress ->
if (Thread.currentThread() != Looper.getMainLooper().thread) {
ThreadUtils.runOnUiThread({
updateProgress(progress.toInt())
}, ThreadUtils.MODE.QUEUE)
} else {
updateProgress(progress.toInt())
}
updateProgress(progress.toInt())
}, { _, state ->
if (Thread.currentThread() != Looper.getMainLooper().thread) {
ThreadUtils.runOnUiThread({
if (state == 0) {// 失败
showNewContent(isLoading = false, false)
}
}, ThreadUtils.MODE.QUEUE)
} else {
if (state == 0) {// 失败
showNewContent(isLoading = false, false)
}
if (state == 0) {// 失败
showNewContent(isLoading = false, false)
}
})
} else {// 只拿到了高精的经纬度

View File

@@ -8,7 +8,6 @@ import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.os.Build
import android.os.Looper
import android.os.Process
import android.text.Html
import android.util.AttributeSet
@@ -18,7 +17,6 @@ import androidx.annotation.RequiresApi
import androidx.appcompat.widget.PopupMenu
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
import androidx.core.content.FileProvider
import androidx.core.view.MenuCompat
import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope
@@ -50,9 +48,9 @@ import com.mogo.eagle.core.data.obu.ObuStatusInfo
import com.mogo.eagle.core.function.api.autopilot.*
import com.mogo.eagle.core.function.api.datacenter.obu.IMoGoObuConnectListener
import com.mogo.eagle.core.function.api.datacenter.obu.IMoGoObuInfoListener
import com.mogo.eagle.core.function.api.setting.ISopSettingListener
import com.mogo.eagle.core.function.api.devatools.IMoGoDevaToolsFuncConfigListener
import com.mogo.eagle.core.function.api.devatools.IMoGoDevaToolsListener
import com.mogo.eagle.core.function.api.setting.ISopSettingListener
import com.mogo.eagle.core.function.call.autopilot.*
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsFuncConfigListenerManager
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsListenerManager
@@ -234,7 +232,7 @@ internal class DebugSettingView @JvmOverloads constructor(
//添加 底盘灯光数据 监听
CallerChassisLamplightListenerManager.addListener(TAG, this)
//雨天、美化、点云设置同步
CallerSopSettingManager.addListener(TAG,this)
CallerSopSettingManager.addListener(TAG, this)
//添加 业务配置监听
CallerDevaToolsFuncConfigListenerManager.registerDevaToolsFuncConfigListener(
@@ -597,13 +595,9 @@ internal class DebugSettingView @JvmOverloads constructor(
}
if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
ThreadUtils.getIoPool().execute {
mogoMapData.get()?.isCityDataCached {
isHDCached = it
UiThreadHandler.post {
btn_cache_hd_map.text = "缓存高精离线地图(${if (it) "已是最新版" else "待更新"}!)"
}
}
mogoMapData.get()?.isCityDataCached {
isHDCached = it
btn_cache_hd_map.text = "缓存高精离线地图(${if (it) "已是最新版" else "待更新"}!)"
}
btn_cache_hd_map.visibility = View.VISIBLE
}
@@ -706,7 +700,7 @@ internal class DebugSettingView @JvmOverloads constructor(
tbIsDemoMode.isChecked = FunctionBuildConfig.isDemoMode
// 演示模式
tbIsDemoMode.setOnCheckedChangeListener { compoundButton, isChecked ->
if(!compoundButton.isPressed){
if (!compoundButton.isPressed) {
return@setOnCheckedChangeListener
}
FunctionBuildConfig.isDemoMode = !FunctionBuildConfig.isDemoMode
@@ -745,7 +739,7 @@ internal class DebugSettingView @JvmOverloads constructor(
tbIsRainMode.isChecked = FunctionBuildConfig.isRainMode
//雨天模式
tbIsRainMode.setOnCheckedChangeListener { compoundButton, isChecked ->
if(!compoundButton.isPressed){
if (!compoundButton.isPressed) {
return@setOnCheckedChangeListener
}
CallerAutoPilotControlManager.setRainMode(isChecked)
@@ -869,7 +863,7 @@ internal class DebugSettingView @JvmOverloads constructor(
tbDrawPointCloudData.isChecked = FunctionBuildConfig.isDrawPointCloudData
//是否渲染点云数据
tbDrawPointCloudData.setOnCheckedChangeListener { compoundButton, isChecked ->
if(!compoundButton.isPressed){
if (!compoundButton.isPressed) {
return@setOnCheckedChangeListener
}
CallerAutoPilotControlManager.setIsDrawPointCloud(isChecked)
@@ -2174,40 +2168,16 @@ internal class DebugSettingView @JvmOverloads constructor(
private fun cacheHDOfflineData(isGaoDe: Boolean) {
if (isGaoDe) {// 拿到了高德地图的cityCode
mogoMapData.get()?.cacheHDDataByCity({ _, progress ->
if (Thread.currentThread() != Looper.getMainLooper().thread) {
ThreadUtils.runOnUiThread(Runnable {
cacheHDCityProgressUpdate(progress)
}, ThreadUtils.MODE.QUEUE)
} else {
cacheHDCityProgressUpdate(progress)
}
cacheHDCityProgressUpdate(progress)
}, { _, state ->
if (Thread.currentThread() != Looper.getMainLooper().thread) {
ThreadUtils.runOnUiThread(Runnable {
cacheHDCityResult(state)
}, ThreadUtils.MODE.QUEUE)
} else {
cacheHDCityResult(state)
}
cacheHDCityResult(state)
})
} else {// 只拿到了高精的经纬度
mGnssInfo?.let { loc ->
mogoMapData.get()?.cacheHDDataByCityByLonLat(loc, { _, progress ->
if (Thread.currentThread() != Looper.getMainLooper().thread) {
ThreadUtils.runOnUiThread(Runnable {
cacheHDCityProgressUpdate(progress)
}, ThreadUtils.MODE.QUEUE)
} else {
cacheHDCityProgressUpdate(progress)
}
cacheHDCityProgressUpdate(progress)
}, { _, state ->
if (Thread.currentThread() != Looper.getMainLooper().thread) {
ThreadUtils.runOnUiThread(Runnable {
cacheHDCityResult(state)
}, ThreadUtils.MODE.QUEUE)
} else {
cacheHDCityResult(state)
}
cacheHDCityResult(state)
})
}
}

View File

@@ -157,12 +157,8 @@ class SystemVersionView @JvmOverloads constructor(
}
}
ThreadUtils.getIoPool().execute {
mogoMapData.get()?.isCityDataCached {
UiThreadHandler.post {
updateHDDataCacheStatus(it)
}
}
mogoMapData.get()?.isCityDataCached {
updateHDDataCacheStatus(it)
}
if (AdUpgradeStateHelper.isConfirmUpgrade()) {
@@ -369,12 +365,12 @@ class SystemVersionView @JvmOverloads constructor(
* HQ、M1 MAP350开始弃用其他车型MAP360开始弃用
*/
override fun onAutopilotStatusRespByQuery(status: SystemStatusInfo.StatusInfo) {
Log.i(TAG,"hdMapVer="+status.hdMapVer)
Log.i(TAG, "hdMapVer=" + status.hdMapVer)
//hdMapVer返回示例/home/mogo/autopilot/share/hadmap_engine/data/hadmap_data/db.sqlite|bj|2.2.7|对bus路线上的junction进行修改对原609场景修改为6091、6092、6201、 6202四种细分场景并对通往园区路口改为619
if(status.hdMapVer!= null && status.hdMapVer.isNotEmpty()){
if (status.hdMapVer != null && status.hdMapVer.isNotEmpty()) {
//对地图版本进行截取
val city = status.hdMapVer.substringAfter(".sqlite|").substringBefore("|")
val version =status.hdMapVer.substringAfter("$city|").substringBefore("|")
val version = status.hdMapVer.substringAfter("$city|").substringBefore("|")
AppConfigInfo.adHdMapVersion = "${city}_${version}"
updateAdHdMapVersion()
}
@@ -388,12 +384,12 @@ class SystemVersionView @JvmOverloads constructor(
* @param statusInf 数据
*/
override fun onSystemStatus(statusInf: SsmInfo.SsmStatusInf) {
Log.i(TAG,"hdMapVer="+statusInf.hdMapVer)
Log.i(TAG, "hdMapVer=" + statusInf.hdMapVer)
//hdMapVer返回示例/home/mogo/autopilot/share/hadmap_engine/data/hadmap_data/db.sqlite|bj|2.2.7|对bus路线上的junction进行修改对原609场景修改为6091、6092、6201、 6202四种细分场景并对通往园区路口改为619
if(statusInf.hdMapVer!= null && statusInf.hdMapVer.isNotEmpty()){
if (statusInf.hdMapVer != null && statusInf.hdMapVer.isNotEmpty()) {
//对地图版本进行截取
val city = statusInf.hdMapVer.substringAfter(".sqlite|").substringBefore("|")
val version =statusInf.hdMapVer.substringAfter("$city|").substringBefore("|")
val version = statusInf.hdMapVer.substringAfter("$city|").substringBefore("|")
AppConfigInfo.adHdMapVersion = "${city}_${version}"
updateAdHdMapVersion()
}
@@ -402,8 +398,8 @@ class SystemVersionView @JvmOverloads constructor(
/**
* 更新工控机高精地图版本
*/
private fun updateAdHdMapVersion(){
if(tvAdHdMapVersionContent.text.isNullOrEmpty() && AppConfigInfo.adHdMapVersion.isNotEmpty() || tvAdHdMapVersionContent.text != AppConfigInfo.adHdMapVersion){
private fun updateAdHdMapVersion() {
if (tvAdHdMapVersionContent.text.isNullOrEmpty() && AppConfigInfo.adHdMapVersion.isNotEmpty() || tvAdHdMapVersionContent.text != AppConfigInfo.adHdMapVersion) {
ThreadUtils.runOnUiThread {
tvAdHdMapVersionContent.text = AppConfigInfo.adHdMapVersion
}