Merge branch 'renwj/fix_code' into 'dev_MogoAP_eagle-1030_211020_8.0.14'

[Fix]解决ALocationClien定位信息因为使用实时上传的时候当接入工控机位置回调信息会丢失

See merge request zhjt/AndroidApp/MoGoEagleEye!2
This commit is contained in:
donghongyu
2021-11-08 07:52:07 +00:00
9 changed files with 116 additions and 1 deletions

View File

@@ -50,7 +50,6 @@ dependencies {
implementation rootProject.ext.dependencies.rxandroid
kapt rootProject.ext.dependencies.aroutercompiler
implementation rootProject.ext.dependencies.adasHigh
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
@@ -58,11 +57,13 @@ dependencies {
implementation rootProject.ext.dependencies.mogo_core_utils
implementation rootProject.ext.dependencies.mogo_core_function_api
implementation rootProject.ext.dependencies.mogo_core_function_call
implementation rootProject.ext.dependencies.modulecommon
} else {
implementation project(':core:mogo-core-data')
implementation project(':core:mogo-core-utils')
implementation project(':core:mogo-core-function-api')
implementation project(':core:mogo-core-function-call')
implementation project(':modules:mogo-module-common')
}
}

View File

@@ -0,0 +1,34 @@
package com.mogo.eagle.core.function.impl.map
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.function.api.map.location.IMoGoLocationUpdater4AutoPilot
import com.mogo.eagle.core.utilcode.util.Utils
import com.mogo.module.common.MogoApisHandler
import com.mogo.service.IMogoServiceApis
@Route(path = MogoServicePaths.PATH_MAP_LOCATION_UPDATE_4_AUTO_PILOT)
class MoGoLocationUpdater4AutoPilot: IMoGoLocationUpdater4AutoPilot {
private val TAG = "MoGoLocationUpdater4AutoPilot"
override val functionName = TAG;
private val api: IMogoServiceApis? by lazy {
MogoApisHandler.getInstance().apis
}
override fun updateLocation(location: Any?) {
api?.mapServiceApi?.getSingletonLocationClient(Utils.getApp())?.updateLocation(location);
}
override fun init(context: Context?) {
//DO NOTING
}
override fun onDestroy() {
//DO NOTHING
}
}

View File

@@ -386,4 +386,12 @@ public class MogoServicePaths {
@Keep
@Deprecated
public static final String PATH_AI_MONITORING = "/monitoring/api";
/**
* 自动驾驶时,定位信息改变要同步更新
*/
@Keep
@Deprecated
public static final String PATH_MAP_LOCATION_UPDATE_4_AUTO_PILOT = "/map_x/location_update";
}

View File

@@ -0,0 +1,13 @@
package com.mogo.eagle.core.function.api.map.location
import com.mogo.eagle.core.function.api.base.IMoGoFunctionServerProvider
/**
* @author renwj
* @date 2021/11/04 16:10 下午
* 此类主要用来同步自动驾驶定位信息给各业务方
*/
interface IMoGoLocationUpdater4AutoPilot : IMoGoFunctionServerProvider {
fun updateLocation(location: Any?)
}

View File

@@ -0,0 +1,18 @@
package com.mogo.eagle.core.function.call.map
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.function.api.map.location.IMoGoLocationUpdater4AutoPilot
import com.mogo.eagle.core.function.call.base.CallerBase
object CallerLocationUpdaterManager {
private val updater : IMoGoLocationUpdater4AutoPilot? by lazy {
CallerBase.getApiInstance(
IMoGoLocationUpdater4AutoPilot::class.java,
MogoServicePaths.PATH_MAP_LOCATION_UPDATE_4_AUTO_PILOT)
}
fun updateLocation(location: Any?) {
updater?.updateLocation(location);
}
}

View File

@@ -23,6 +23,7 @@ import com.mogo.eagle.core.data.config.FunctionBuildConfig;
import com.mogo.commons.constants.SharedPrefsConstants;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.eagle.core.function.call.map.CallerLocationUpdaterManager;
import com.mogo.map.IMogoMap;
import com.mogo.map.IMogoMapView;
import com.mogo.map.impl.custom.location.GpsTester;
@@ -1076,6 +1077,7 @@ public class AMapViewWrapper implements IMogoMapView,
bean.setLat(lat);
// 使用外部定位数据修改自车位置
mMapView.getLocationClient().updateRTKAutoPilotLocation(bean);
CallerLocationUpdaterManager.INSTANCE.updateLocation(bean);
}
}

View File

@@ -11,6 +11,7 @@ import com.mogo.map.location.MogoLocationListenerRegister;
import com.mogo.utils.logger.Logger;
import com.zhidaoauto.map.sdk.open.location.LocationClient;
import com.zhidaoauto.map.sdk.open.location.LocationListener;
import com.zhidaoauto.map.sdk.open.location.RTKAutopilotLocationBean;
import org.jetbrains.annotations.NotNull;
@@ -135,4 +136,29 @@ public class ALocationClient implements IMogoLocationClient {
private void destroyWarming() {
Logger.w( TAG, "location client has destroyed." );
}
@Override
public void updateLocation(Object locationToUpdate) {
if (locationToUpdate == null) {
return;
}
if (locationToUpdate instanceof MogoLocation) {
return;
}
if (locationToUpdate instanceof RTKAutopilotLocationBean) {
MogoLocation last = getLastKnowLocation();
RTKAutopilotLocationBean current = (RTKAutopilotLocationBean) locationToUpdate;
boolean isNeedUpdate = (last == null || last.getLatitude() != current.getLat() || last.getLongitude() != current.getLon());
if (!isNeedUpdate) {
return;
}
if (last != null) {
last.setLatitude(current.getLat());
last.setLongitude(current.getLon());
}
if (mClient != null) {
mClient.updateRTKAutoPilotLocation(current);
}
}
}
}

View File

@@ -35,4 +35,10 @@ public interface IMogoLocationClient extends IMogoLocationListenerRegister {
MogoLocation getLastKnowLocation();
void destroy();
/**
* 更正最新的位置
* @param locationToUpdate
*/
void updateLocation(Object locationToUpdate);
}

View File

@@ -78,4 +78,11 @@ public class MogoLocationClient implements IMogoLocationClient {
mDelegate.destroy();
}
}
@Override
public void updateLocation(Object locationToUpdate) {
if (mDelegate != null) {
mDelegate.updateLocation(locationToUpdate);
}
}
}