From edb38cbd012212a8d11fa8008a23cdd7aa0050ee Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Wed, 31 May 2023 21:55:46 +0800 Subject: [PATCH] =?UTF-8?q?[3.2.0][Opt]=E4=B9=98=E5=AE=A2=E5=B1=8F?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E4=B8=8B=E8=BD=BD=E9=AB=98=E7=B2=BE=E5=9C=B0?= =?UTF-8?q?=E5=9B=BE=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/cachemap/CacheHDMapManager.kt | 58 +++++++++++++++++++ .../collect/MoGoMapDataCollectProvider.kt | 2 + 2 files changed, 60 insertions(+) create mode 100644 core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/cachemap/CacheHDMapManager.kt diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/cachemap/CacheHDMapManager.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/cachemap/CacheHDMapManager.kt new file mode 100644 index 0000000000..f418646bff --- /dev/null +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/cachemap/CacheHDMapManager.kt @@ -0,0 +1,58 @@ +package com.mogo.eagle.core.function.business.cachemap + +import android.util.Log +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.data.map.MogoLocation +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager +import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils +import com.mogo.eagle.core.utilcode.util.ThreadUtils +import com.mogo.map.hdcache.IHdCacheListener + +object CacheHDMapManager: IMoGoChassisLocationWGS84Listener { + + private const val TAG = "CacheHDMapManager" + + @Volatile + private var location: MogoLocation? = null + + fun scheduleGetLocation() { + if (!AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) { + CallerChassisLocationWGS84ListenerManager.addListener(TAG, this) + ThreadUtils.getIoPool().execute { + if (!CallerMapUIServiceManager.isCityDataCached()) { + while (true) { + if (location != null) { + Log.d(TAG, "开始下载") + CallerMapUIServiceManager.cacheHDDataByCityByLonLat(object : IHdCacheListener { + override fun onMapHdCacheProgress(cityId: Int, progress: Double) { + Log.d(TAG, "下载进度:${progress.toInt()}") + } + + override fun onMapHdCacheResult(cityId: Int, state: Int) { + if (state == 0) { + Log.d(TAG, "下载失败") + } + } + }, location!!) + Log.d(TAG, "移除监听并关闭循环") + CallerChassisLocationWGS84ListenerManager.removeListener(TAG) + return@execute + } + try { + Log.d(TAG, "开始休眠...") + Thread.sleep(1500) + } catch (e: Exception) {} + } + } else { + Log.d(TAG, "高精地图缓存已下载!") + } + } + } + } + + override fun onChassisLocationWGS84(gnssInfo: MogoLocation) { + location = gnssInfo + } +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/collect/MoGoMapDataCollectProvider.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/collect/MoGoMapDataCollectProvider.kt index f7255df29c..054faa08f8 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/collect/MoGoMapDataCollectProvider.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/collect/MoGoMapDataCollectProvider.kt @@ -12,6 +12,7 @@ import com.mogo.eagle.core.data.map.MogoLocation import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotRecordListener import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener import com.mogo.eagle.core.function.api.map.collect.IMoGoMapDataCollectProvider +import com.mogo.eagle.core.function.business.cachemap.CacheHDMapManager import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger @@ -73,6 +74,7 @@ class MoGoMapDataCollectProvider : IMoGoMapDataCollectProvider, OnTaskListener, MoGoAiCloudClient.getInstance().addTokenCallbacks(this) CallerLogger.d("$M_MAP$TAG", "--------- init --------") CallerLogger.d("$M_MAP$TAG", "executor: ${executor.get()?.hashCode() ?: 0}") + CacheHDMapManager.scheduleGetLocation() } override fun onDestroy() {