Merge branch 'dev_robotaxi-d-app-module_2120_221017_2.12.0' of gitlab.zhidaoauto.com:zhjt/AndroidApp/MoGoEagleEye into dev_robotaxi-d-app-module_2120_221017_2.12.0

This commit is contained in:
xinfengkun
2022-10-25 17:57:06 +08:00
35 changed files with 595 additions and 745 deletions

View File

@@ -12,6 +12,7 @@ import com.mogo.och.bus.bean.BusRoutesResponse;
import com.mogo.och.bus.callback.IBusLinesCallback;
import com.mogo.och.bus.net.BusServiceManager;
import com.mogo.och.bus.ui.BusSwitchLineActivity;
import com.mogo.och.bus.util.BusSendTripInfoManager;
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback;
/**

View File

@@ -28,7 +28,6 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.eagle.core.utilcode.util.NetworkUtils;
import com.mogo.eagle.core.utilcode.util.ToastUtils;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
@@ -49,6 +48,7 @@ import com.mogo.och.bus.constant.BusConst;
import com.mogo.och.bus.net.BusServiceManager;
import com.mogo.och.bus.presenter.BusModelLoopManager;
import com.mogo.och.bus.util.BusAnalyticsManager;
import com.mogo.och.bus.util.BusSendTripInfoManager;
import com.mogo.och.bus.util.BusTrajectoryManager;
import com.mogo.och.common.module.biz.constant.OchCommonConst;
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback;
@@ -67,7 +67,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import io.reactivex.disposables.Disposable;
import io.reactivex.exceptions.UndeliverableException;
import io.reactivex.functions.Consumer;
import io.reactivex.plugins.RxJavaPlugins;
@@ -454,8 +453,9 @@ public class BusOrderModel {
@Override
public void onSuccess(BaseData o) {
CallerLogger.INSTANCE.d(M_BUS + TAG, "abortTask success: " + o);
clearNativeTag();
if (o.code == 0){ // 重置成功
endOrAbortTaskSuccess();
clearBusStationDatas();
queryBusRoutes();
startOrStopQueryPassengerWriteOff(false);
}
@@ -469,9 +469,20 @@ public class BusOrderModel {
}
private void clearNativeTag() {
/**
* 中断或者正常结束任务后的处理
*/
private void endOrAbortTaskSuccess() {
isGoingToNextStation = false;
backgroundCurrentStationIndex = 0;
if (busRoutesResult != null){
BusSendTripInfoManager.INSTANCE.sendBusTripInfo(BusSendTripInfoManager.END_TRIP
, busRoutesResult.getName()
,""
,false);
}
}
/**
@@ -480,6 +491,15 @@ public class BusOrderModel {
* 车机端展示是离开当前站,下一站设置为当前站, 所以服务端数据回来要做处理,不能直接渲染
*/
private void leaveStationSuccess(int leaveIndex) {
if (busRoutesResult != null){
//给bus外屏发送
BusSendTripInfoManager.INSTANCE.sendBusTripInfo(BusSendTripInfoManager.LEAVE_STATION
, busRoutesResult.getName()
,busRoutesResult.getSites().get(leaveIndex).getName()
,false);
}
//开启自动驾驶 2.10.0: 如果自动驾驶状态下开启, 非自动驾驶状态下不开启,需手动点击自动驾驶按钮开启
isGoingToNextStation = true;
if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState()
@@ -597,6 +617,8 @@ public class BusOrderModel {
CallerLogger.INSTANCE.d(M_BUS + TAG,"行程日志-arriveSiteStation success");
queryBusRoutes();
arriveStationSuccess(arrivedStationIndex);
ttsTips(String.format(mContext
.getString(R.string.bus_arrived_station_tip),
arriveStation));
@@ -620,6 +642,22 @@ public class BusOrderModel {
});
}
private void arriveStationSuccess(int arrivedStationIndex) {
if (busRoutesResult != null){
boolean isLastStop;
if (arrivedStationIndex == busRoutesResult.getSites().size() - 1 ){
isLastStop = true;
}else {
isLastStop = false;
}
//给bus外屏发送
BusSendTripInfoManager.INSTANCE.sendBusTripInfo(BusSendTripInfoManager.ARRIVE_STATION
, busRoutesResult.getName()
,busRoutesResult.getSites().get(arrivedStationIndex).getName()
,isLastStop);
}
}
/**
* 离站上报
*/
@@ -629,6 +667,7 @@ public class BusOrderModel {
if (backgroundCurrentStationIndex < stationList.size() - 1){
nextStationName = stationList.get(backgroundCurrentStationIndex + 1).getName();
}
final String currentStationName = stationList.get(backgroundCurrentStationIndex).getName();
String finalNextStationName = nextStationName;
BusServiceManager.leaveStation(mContext,
stationList.get(backgroundCurrentStationIndex).getSeq(),
@@ -678,7 +717,6 @@ public class BusOrderModel {
* 关闭美化模式
*/
public void closeBeautificationMode() {
Logger.d("Route", "BusOrderModel -> closeBeautificationMode ==> isDemoMode:" + FunctionBuildConfig.isDemoMode);
if (FunctionBuildConfig.isDemoMode) {//收车结束美化
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false; //是否强制绘制引导线
CallerAutoPilotManager.INSTANCE.setIgnoreConditionDraw(false);// 同步给乘客屏
@@ -734,6 +772,10 @@ public class BusOrderModel {
if (backgroundCurrentStationIndex == 0 &&
stationList.get(0).getDrivingStatus() == STATION_STATUS_STOPPED
&& !stationList.get(0).isLeaving()){ //默认是第一站到站查询
if (busRoutesResult != null){ // 第一站到站也是行程开始的时候
BusSendTripInfoManager.INSTANCE.sendBusTripInfo(BusSendTripInfoManager.START_TRIP
,busRoutesResult.getName(),"",false);
}
startOrStopQueryPassengerWriteOff(true);
}
@@ -745,7 +787,6 @@ public class BusOrderModel {
+" isLeaving()="+currentStation.isLeaving());
// 美化是否开始
Logger.d("Route", "BusOrderModel -> updateBusStatus ==> isDemoMode:" + FunctionBuildConfig.isDemoMode);
if (FunctionBuildConfig.isDemoMode && (backgroundCurrentStationIndex >= 0
&& backgroundCurrentStationIndex <= stationList.size()-1)){//行驶过程中设置美化
if (stationList.get(backgroundCurrentStationIndex).isLeaving()){
@@ -779,7 +820,6 @@ public class BusOrderModel {
}
private void startBeautificationMode() {
Logger.d("Route", "BusOrderModel -> startBeautificationMode ==> ignore = true");
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = true;
CallerAutoPilotManager.INSTANCE.setIgnoreConditionDraw(true);
CallerAutoPilotManager.INSTANCE.setIPCDemoMode(true);
@@ -837,7 +877,8 @@ public class BusOrderModel {
public void onSuccess(BaseData o) {
CallerLogger.INSTANCE.d(M_BUS + TAG, "endTask success: " + o);
if (o.code == 0){
clearNativeTag();
endOrAbortTaskSuccess();
clearBusStationDatas();
queryBusRoutes();// 重新获取任务
startOrStopQueryPassengerWriteOff(false);
ttsTips(mContext.getString(R.string.bus_end_task_tip));

View File

@@ -0,0 +1,31 @@
package com.mogo.och.bus.util
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
/**
* @author: wangmingjun
* @date: 2022/10/24
*/
object BusSendTripInfoManager{
const val START_TRIP = 1
const val END_TRIP = 2
const val LEAVE_STATION = 3
const val ARRIVE_STATION = 4
/**
* 行程信息
* @param type 事件类型, 1:行程开始, 2:行程结束, 3:出站, 4:进站, 5:城市占道施工预警
* @param lineName 路线名, for type 1, 2
* @param stopName 站点名, for type 3, 4
* @param isLastStop 是否终点站
* @return
*/
fun sendBusTripInfo(type: Int, lineName: String, stationName: String, isLastStop: Boolean) {
d(SceneConstant.M_BUS + "BusSendTripInfoManager", "type: "+ type
+", lineName: "+ lineName + ", stationName: "+stationName+", isLastStop: "+isLastStop)
CallerAutoPilotManager.sendTripInfo(type,lineName,stationName,isLastStop)
}
}

View File

@@ -1,6 +1,7 @@
package com.mogo.och.common.module.utils;
import android.content.Context;
import android.location.Location;
import com.amap.api.maps.CoordinateConverter;
import com.amap.api.maps.model.LatLng;
@@ -8,7 +9,9 @@ import com.mogo.cloud.commons.utils.CoordinateUtils;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import mogo.telematics.pad.MessagePad;
@@ -202,4 +205,108 @@ public class CoordinateCalculateRouteUtil {
}
return currentIndex;
}
public static float calculateRouteSumLengthByLocation(List<Location> points){
if (null == points || points.size() == 0) return 0;
float sumLength = 0;
//计算全路径总距离
for (int i = 0;i + 1< points.size();i++){
double preLat = points.get(i).getLatitude();
double preLon = points.get(i).getLongitude();
double laLat = points.get(i+1).getLatitude();
double laLon = points.get(i+1).getLongitude();
float length = CoordinateUtils.calculateLineDistance(laLon,laLat,preLon,preLat);
sumLength += length;
}
return sumLength;
}
public static List<Location> coordinateConverterWgsToGcjLocations(Context mContext, List<MessagePad.Location> models) {
//转成MogoLatLng集合
List<Location> list = new ArrayList<>();
for (MessagePad.Location m : models) {
LatLng mogoLatLng = coordinateConverterWgsToGcj(mContext, m);
Location location = new Location("gcj_provider");
location.setBearing((float) m.getHeading());
location.setLatitude(mogoLatLng.latitude);
location.setLongitude(mogoLatLng.longitude);
list.add(location);
}
return list;
}
public static Map<Integer,List<LatLng>> getRemainPointListByCompareNew(int preIndex,
List<Location> mRoutePoints,
Location realLocation) {
Map<Integer,List<LatLng>> routePonits = new HashMap<>();
List<LatLng> latePoints = new ArrayList<>(); // 剩余轨迹集合
int currentIndex = 0; //记录疑似点
if (mRoutePoints.size() > preIndex){
//基础点
Location baseLatLng = mRoutePoints.get(preIndex);
float baseDiffDis = CoordinateUtils.calculateLineDistance(realLocation.getLongitude(),
realLocation.getLatitude()
,baseLatLng.getLongitude(),baseLatLng.getLongitude());// lon,lat, prelon, prelat
for (int i= preIndex; i < mRoutePoints.size(); i++){
Location latLng = mRoutePoints.get(i);
//todo 先看index对应点的方向和realLocation方向是否一致 方向角度不能过90度
if (Math.abs(realLocation.getBearing() - latLng.getBearing()) <= 90){
float diff = CoordinateUtils.calculateLineDistance(realLocation.getLongitude(),
realLocation.getLatitude(),
latLng.getLongitude(),latLng.getLatitude());
if (baseDiffDis > diff ){
// Logger.d(M_TAXI + "calculateRouteSumLength", "点:"+i+"-------先记录点----- ");
baseDiffDis = diff;
currentIndex = i;
}
}
}
Logger.d( "calculateRouteSumLength", "点:"+currentIndex+"-------是最近的点------ ");
if (currentIndex == mRoutePoints.size()-1){
Location location = mRoutePoints.get(currentIndex);
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
latePoints.add(latLng);
}else {
List<Location> locations = mRoutePoints.subList(currentIndex,mRoutePoints.size()-1);
for (Location location: locations) {
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
latePoints.add(latLng);
}
}
routePonits.put(currentIndex,latePoints);
return routePonits;
}
return routePonits;
}
public static int getArrivedPointIndexNew(List<Location> mRoutePoints,
Location realLocation) {
int currentIndex = 0; //记录疑似点 //基础点
Location baseLatLng = mRoutePoints.get(0);
float baseDiffDis = CoordinateUtils.calculateLineDistance(realLocation.getLongitude(),
realLocation.getLatitude()
, baseLatLng.getLongitude(), baseLatLng.getLongitude());// lon,lat, prelon, prelat
for (int i = 0; i < mRoutePoints.size(); i++) {
Location latLng = mRoutePoints.get(i);
//todo 先看index对应点的方向和realLocation方向是否一致 方向角度不能过90度
if (Math.abs(realLocation.getBearing() - latLng.getBearing()) <= 90) {
float diff = CoordinateUtils.calculateLineDistance(realLocation.getLongitude(),
realLocation.getLatitude(),
latLng.getLongitude(), latLng.getLatitude());
if (baseDiffDis > diff) {
// Logger.d(M_TAXI + "calculateRouteSumLength", "点:"+i+"-------先记录点----- ");
baseDiffDis = diff;
currentIndex = i;
}
}
}
Logger.d("calculateRouteSumLength", "点:" + currentIndex + "-------是最近的点------ ");
return currentIndex;
}
}

View File

@@ -28,7 +28,6 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
import com.mogo.eagle.core.utilcode.util.NetworkUtils;
import com.mogo.eagle.core.utilcode.util.ToastUtils;
@@ -327,7 +326,7 @@ public class TaxiModel {
//1.1.2. 当本地有currentOrder
//orderId不一致时通过currentOrder.orderId查询订单状态并通知ui更新
//orderId一致且orderStatus不一致时则更新currentOrder并通知ui更新
Logger.d(TAG,"AutopilotControl-mCurrentOCHOrder = "+mCurrentOCHOrder.orderStatus
CallerLogger.INSTANCE.d(M_TAXI + TAG,"AutopilotControl-mCurrentOCHOrder = "+mCurrentOCHOrder.orderStatus
+ ", orderStatus = " +data.data.servicing.get(0).orderStatus);
if (!mCurrentOCHOrder.orderNo.equals(data.data.servicing.get(0).orderNo)) {
queryCurOrderStatus();
@@ -800,7 +799,6 @@ public class TaxiModel {
GsonUtil.jsonFromObject(data));
if (mCurrentOCHOrder.orderStatus == TaxiOrderStatusEnum.OnTheWayToEnd.getCode()){
Logger.d("Route", "TaxiModel -> updateNativeCurrentOrder ==> isDemoMode:" + FunctionBuildConfig.isDemoMode);
if (FunctionBuildConfig.isDemoMode) {
// 当美化模式(演示模式)开启时: 订单对应自动驾驶开启后置true
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = true;
@@ -847,7 +845,6 @@ public class TaxiModel {
TaxiTrajectoryManager.getInstance().syncTrajectoryInfo();
SharedPrefsMgr.getInstance(mContext).remove(TaxiConst.SP_KEY_OCH_TAXI_ORDER);
isRestartAutopilot = false;
Logger.d("Route", "TaxiModel -> clearCurrentOCHOrder ==> isDemoMode:" + FunctionBuildConfig.isDemoMode);
if (FunctionBuildConfig.isDemoMode) {
// 当美化模式(演示模式)开启时: 取消或订单已完成时置false
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false;
@@ -1152,7 +1149,6 @@ public class TaxiModel {
TaxiAnalyticsManager.getInstance().triggerStartAutopilotEvent(isRestartAutopilot, true,
mCurrentOCHOrder.startSiteAddr, mCurrentOCHOrder.endSiteAddr, mCurrentOCHOrder.orderNo);
Logger.d("Route", "TaxiModel -> onAutopilotStatusResponse ==> isDemoMode:" + FunctionBuildConfig.isDemoMode);
if (FunctionBuildConfig.isDemoMode) {
// 当美化模式(演示模式)开启时: 订单对应自动驾驶开启后置true
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = true;
@@ -1325,7 +1321,6 @@ public class TaxiModel {
}
mRoutePoints.addAll(CoordinateCalculateRouteUtil.coordinateConverterWgsToGcjListCommon(mContext, models));
startDynamicCalculateRouteInfo();
startNaviToEndStation(false);
}
public void startDynamicCalculateRouteInfo() {

View File

@@ -291,6 +291,7 @@ public abstract class BaseTaxiTabFragment<V extends IView, P extends Presenter<V
});
mCloseNaviIcon.setOnClickListener(v -> {
showAmapNaviToStationFragment(false);
showRottingToStationFragment(false);
});
}
@@ -566,6 +567,7 @@ public abstract class BaseTaxiTabFragment<V extends IView, P extends Presenter<V
protected void showAmapNaviToStationFragment(boolean isShow) {
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
closeAmapViewIFHadeAdd();
if (isShow) {
closeRouteViewIFHadeAdd();
// if (ochNaviFragment == null){
@@ -580,7 +582,6 @@ public abstract class BaseTaxiTabFragment<V extends IView, P extends Presenter<V
flNaviPanelContainer.setVisibility(View.VISIBLE);
CallerSmpManager.hidePanel();//隐藏小地图
} else {
closeAmapViewIFHadeAdd();
mCloseNaviIcon.setVisibility(View.GONE);
flNaviPanelContainer.setVisibility(View.GONE);
CallerSmpManager.showPanel();//显示小地图

View File

@@ -357,6 +357,7 @@ public class CommonBeingServerdOrdersFragment extends BaseTaxiUIFragment
mNaviToEndIcon.setVisibility(View.GONE);
AmapNaviToDestinationModel.getInstance(getContext()).destroyAmaNavi();
mTaxiFragment.showAmapNaviToStationFragment(false);
mTaxiFragment.showRottingToStationFragment(false);
}
}
@@ -667,7 +668,6 @@ public class CommonBeingServerdOrdersFragment extends BaseTaxiUIFragment
mTaxiFragment.showAmapNaviToStationFragment(false);
return;
}
mTaxiFragment.showAmapNaviToStationFragment(false);
UiThreadHandler.postDelayed(new Runnable() {
@Override
public void run() {

View File

@@ -7,6 +7,7 @@ apply plugin: 'kotlin-android-extensions'
apply plugin: 'android-aspectjx'
apply plugin: 'bugly'
def isReleaseBuild = isReleaseBuild()
//apply ByteX宿主
if (!isAndroidTestBuild()) {
apply plugin: 'bytex'
@@ -38,14 +39,23 @@ if (!isAndroidTestBuild()) {
if (!isAndroidTestBuild()) {
apply plugin: 'bytex.threadOpt'
thread_opt {
enable !isReleaseBuild
enableInDebug !isReleaseBuild
logLevel "DEBUG"
}
}
if (!isAndroidTestBuild()) {
apply plugin: 'LancetX'
LancetX {
enable true
enableInDebug true
logLevel "DEBUG"
//白名单中的类不进行替换
// white_list = [
// 'leakcanary.*',
// 'com.loc.*'
// ]
weaveGroup {
leak_canary_crash_fix {
enable !isReleaseBuild
}
}
}
}
@@ -249,6 +259,7 @@ dependencies {
debugImplementation rootProject.ext.dependencies.debugleakcanary
releaseImplementation rootProject.ext.dependencies.releaseleakcanary
implementation rootProject.ext.dependencies.android_start_up
implementation rootProject.ext.dependencies.lancetx_runtime
// // 暂不使用Shizuku-API
// implementation rootProject.ext.dependencies.shizuku_provider
@@ -373,3 +384,12 @@ boolean isAndroidTestBuild() {
}
return false
}
boolean isReleaseBuild() {
for (String s : gradle.startParameter.taskNames) {
if (s.contains("Release") | s.contains("release")) {
return true
}
}
return false
}

View File

@@ -0,0 +1,51 @@
package com.mogo.launcher.lancet
import android.database.sqlite.*
import androidx.annotation.*
import com.knightboost.lancet.api.*
import com.knightboost.lancet.api.annotations.*
import com.knightboost.lancet.api.annotations.Weaver
/**
* 此类主要用来修正三方库引起的崩溃
*/
@Keep
@Weaver
@Group("leak_canary_crash_fix")
class LeakCanaryCrashFix {
@Insert
@TargetClass("leakcanary.internal.activity.db.ScopedLeaksDb\$DbOpener")
@TargetMethod(methodName = "getReadableDatabase")
fun proxyGetReadableSQLiteDb(): SQLiteDatabase? {
try {
return Origin.call() as SQLiteDatabase?
} catch (t: Throwable) {
t.printStackTrace()
}
return null
}
@Insert
@TargetClass("leakcanary.internal.activity.db.ScopedLeaksDb\$DbOpener")
@TargetMethod(methodName = "getWritableDatabase")
fun proxyGetWritableSQLiteDb(): SQLiteDatabase? {
try {
return Origin.call() as SQLiteDatabase?
} catch (t: Throwable) {
t.printStackTrace()
}
return null
}
@Insert
@TargetClass("leakcanary.internal.activity.db.ScopedLeaksDb\$DbOpener")
@TargetMethod(methodName = "close")
fun proxyClose() {
try {
Origin.callVoid()
} catch (t: Throwable) {
t.printStackTrace()
}
}
}

View File

@@ -38,6 +38,7 @@ buildscript {
classpath 'com.mogo.cloud:systrace:1.0.1'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.18'
classpath 'com.mogo.sticky:service:1.0.8'
classpath 'io.github.knight-zxw:lancet-plugin:0.0.1'
// classpath ("com.tencent.matrix:matrix-gradle-plugin:0.6.6") { changing = true }
}

View File

@@ -237,7 +237,11 @@ ext {
koomxhook : "com.kuaishou.koom:xhook-static:2.2.0",
//========================= Koom ======================
recyclerviewadapterhelper : "io.github.cymchad:BaseRecyclerViewAdapterHelper:3.0.4"
recyclerviewadapterhelper : "io.github.cymchad:BaseRecyclerViewAdapterHelper:3.0.4",
//========================= LancetX ===================
lancetx_runtime : "io.github.knight-zxw:lancet-runtime:0.0.1"
]
android = [
launcherApplicationId : "com.mogo.launcher",

View File

@@ -197,6 +197,8 @@ class MoGoAutopilotProvider :
.build()
AdasManager.getInstance()
.create(options, MoGoAdasMsgConnectStatusListenerImpl())
// 监听ADAS-SDK获取到的工控机数据
AdasManager.getInstance().setOnAdasListener(MoGoAdasListenerImpl())
// 接收司机屏发过来的感知、定位等数据
listenDeviceData()
}

View File

@@ -1,6 +1,5 @@
package com.mogo.eagle.core.function.autopilot.telematic
import android.util.Log
import androidx.lifecycle.ProcessLifecycleOwner
import androidx.lifecycle.lifecycleScope
import com.google.protobuf.TextFormat
@@ -118,10 +117,6 @@ class TeleMsgHandler : IMsgHandler {
"1" -> true
else -> false
}
Logger.d(
"Route",
"TeleMsgHandler -> handleMsgFromServer ==> isDemoMode:" + FunctionBuildConfig.isDemoMode + ",isIgnore:" + FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData
)
timestamp = currTime
invokeNettyConnResult("乘客屏收到的美化模式isIgnore为${FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData}")
} else {

View File

@@ -9,7 +9,6 @@ import android.os.Build.VERSION_CODES
import android.os.Bundle
import android.text.TextUtils
import android.transition.*
import android.util.Log
import android.view.Gravity
import android.view.View
import android.view.WindowManager
@@ -866,7 +865,7 @@ class MoGoHmiFragment : MvpFragment<MoGoHmiContract.View?, HmiPresenter?>(),
AIAssist.getInstance(ctx).speakTTSVoice(text, voiceCallback)
} catch (t: Throwable) {
it.resumeWith(Result.success(Unit))
Logger.e(TAG, t.message)
CallerLogger.d("$M_HMI$TAG", t.message)
}
}
@@ -1458,7 +1457,6 @@ class MoGoHmiFragment : MvpFragment<MoGoHmiContract.View?, HmiPresenter?>(),
* 工控机监控节点上报
*/
override fun onAutopilotGuardian(guardianInfo: MogoReportMsg.MogoReportMessage?) {
Log.d("EmArrow-1013", "onAutopilotGuardian : $guardianInfo , takeOver : $takeOver")
ThreadUtils.runOnUiThread {
guardianInfo?.let {
if (reportList.size > 49) {
@@ -1484,10 +1482,6 @@ class MoGoHmiFragment : MvpFragment<MoGoHmiContract.View?, HmiPresenter?>(),
EXIT_AUTOPILOT_FOR_LOCATION,
EXIT_AUTOPILOT_FOR_CHASSIS,
EXIT_AUTOPILOT_FOR_DISTANCE -> {
Log.d(
"EmArrow-1013",
"it code : ${it.code} , state : ${getAutoPilotStatusInfo().state}"
)
showWarningV2X(
EventTypeEnum.TAKE_OVER_EVENT.poiType,
EventTypeEnum.TAKE_OVER_EVENT.content,
@@ -1495,13 +1489,11 @@ class MoGoHmiFragment : MvpFragment<MoGoHmiContract.View?, HmiPresenter?>(),
EventTypeEnum.TAKE_OVER_EVENT.poiType,
object : IMoGoWarningStatusListener {
override fun onShow() {
Log.d("EmArrow-1013", "onShow")
takeOver = true
clTakeOverView.visibility = View.VISIBLE
}
override fun onDismiss() {
Log.d("EmArrow-1013", "onDismiss")
takeOver = false
clTakeOverView.visibility = View.GONE
}

View File

@@ -623,7 +623,6 @@ class DebugSettingView @JvmOverloads constructor(
// 强制绘制引导线
tbIsDrawAutopilotTrajectoryData.setOnCheckedChangeListener { _, isChecked ->
Logger.d("Route", "DebugSettingView -> initView2 ==> isDemoMode:" + FunctionBuildConfig.isDemoMode + ",isIgnore: $isChecked")
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = isChecked
}

View File

@@ -1,17 +1,17 @@
package com.mogo.eagle.core.function.hmi.ui.widget
import android.content.Context
import android.graphics.Color
import android.graphics.*
import android.location.Location
import android.util.AttributeSet
import android.util.*
import android.view.Gravity
import android.widget.FrameLayout
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import com.mogo.map.MogoMapUIController
import com.mogo.eagle.core.utilcode.util.*
import com.mogo.map.*
import com.mogo.map.navi.IMogoCarLocationChangedListener2
import com.mogo.service.IMogoServiceApis
import java.util.*
@@ -38,6 +38,11 @@ class SpeedPanelView @JvmOverloads constructor(
var mSpeedLimmit = 60;
private val timer by lazy {
Timer()
}
init {
initEvent(context)
@@ -61,29 +66,30 @@ class SpeedPanelView @JvmOverloads constructor(
}
}
private val timerTask = object : TimerTask() {
override fun run() {
if (mLatLng != null) {
mSpeedLimmit = MogoMapUIController.getInstance()
.getLimitSpeed(mLatLng!!.longitude, mLatLng!!.latitude, mLatLng!!.bearing)
UiThreadHandler.post {
val speed = (mLatLng!!.speed * 3.6f).toInt()
mSpeedChartView.setArcColor(Color.parseColor(if (speed > mSpeedLimmit) "#DB3137" else "#3E77F6"))
mSpeedChartView.setValues(speed)
setBackgroundResource(if (speed > mSpeedLimmit) R.drawable.yi_biao_pan_bg_speeding else R.drawable.yi_biao_pan_bg_nor)
private var timerTask : TimerTask? = null
override fun onAttachedToWindow() {
super.onAttachedToWindow() // 注册位置回调
mMogoServiceApis.registerCenterApi.registerCarLocationChangedListener(TAG, this)
// 开启定时查询速度
timerTask?.cancel()
val task = object : TimerTask() {
override fun run() {
if (mLatLng != null) {
mSpeedLimmit = MogoMapUIController.getInstance()
.getLimitSpeed(mLatLng!!.longitude, mLatLng!!.latitude, mLatLng!!.bearing)
UiThreadHandler.post {
val speed = (mLatLng!!.speed * 3.6f).toInt()
mSpeedChartView.setArcColor(Color.parseColor(if (speed > mSpeedLimmit) "#DB3137" else "#3E77F6"))
mSpeedChartView.setValues(speed)
setBackgroundResource(if (speed > mSpeedLimmit) R.drawable.yi_biao_pan_bg_speeding else R.drawable.yi_biao_pan_bg_nor)
}
}
}
}
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
// 注册位置回调
mMogoServiceApis.registerCenterApi
.registerCarLocationChangedListener(TAG, this)
// 开启定时查询速度
Timer().schedule(timerTask, Date(), 100)
this.timerTask = task
timer.schedule(task, Date(), 100)
}
override fun onDetachedFromWindow() {
@@ -92,7 +98,7 @@ class SpeedPanelView @JvmOverloads constructor(
mMogoServiceApis.registerCenterApi
.unregisterMogoLocationListener(TAG)
try {
timerTask.cancel()
timerTask?.cancel()
} catch (e: Exception) {
e.printStackTrace()
}

View File

@@ -16,7 +16,6 @@ import com.mogo.eagle.core.function.call.bindingcar.CallerBindingCarListenerMana
import com.mogo.eagle.core.function.call.bindingcar.CallerBindingcarManager
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_HMI
import com.mogo.eagle.core.utilcode.util.AppUtils
import com.mogo.eagle.core.utilcode.util.ThreadUtils

View File

@@ -71,7 +71,7 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
private BluetoothMonitorReceiver mBluetoothReceiver = null;
private BluetoothAdapter mBluetoothAdapter;
private List<BluetoothDevice> mAreadlyConnectedList = new ArrayList<>();//已连接设备集合
// private List<BluetoothDevice> mAreadlyConnectedList = new ArrayList<>();//已连接设备集合
private int numberA = 0;
private boolean isLongPressA = false;
private int numberB = 0;
@@ -98,13 +98,11 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
super.onResume();
initBluetooth();
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (!mBluetoothAdapter.isEnabled()) {
mBluetoothAdapter.enable();
}
mBluetoothAdapter.startDiscovery();
showBondedDevice(mBluetoothAdapter);
}
@@ -212,30 +210,6 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { //向上长按 开启自动驾驶
long currentTime = System.currentTimeMillis() / (1000);
long oldTime = SharedPrefsMgr.getInstance(getContext()).getLong("old_time_up", 0);
if (currentTime - oldTime > 6) {
SharedPrefsMgr.getInstance(getContext()).putLong("old_time_up", System.currentTimeMillis() / 1000);
// ToastUtils.showShort("长按 ↑↑↑ 开启自动驾驶");
// CallerAutoPilotManager.INSTANCE.setControlAutopilotCarAuto(true);
CallerAutoPilotManager.INSTANCE.startAutoPilot(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getAutopilotControlParameters());
}
return true;
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { //下和中间键盘长按,减速为-2
long currentTime = System.currentTimeMillis() / (1000);
long oldTime = SharedPrefsMgr.getInstance(getContext()).getLong("old_time_down", 0);
if (currentTime - oldTime > 6) {
SharedPrefsMgr.getInstance(getContext()).putLong("old_time_down", System.currentTimeMillis() / 1000);
// ToastUtils.showShort("长按 ↓↓↓ 减速 -2 ");
sendAcc(true, -2);
}
return true;
}
// Log.e("liyz", "onKeyDown keyCode = " + keyCode + "--action = " + event.getAction() + "---" + event);
return super.onKeyDown(keyCode, event);
}
@@ -243,109 +217,112 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
// Log.d("liyz", "dispatchKeyEvent code = " + event.getKeyCode() + "--action = " + event.getAction() + "----" + event);
if (event.getKeyCode() == KeyEvent.KEYCODE_A) { //单击向左变道,长按-1
if (event.getAction() == KeyEvent.ACTION_DOWN) {
numberA++;
if (numberA > 2) {
if (!isLongPressA) {
// ToastUtils.showShort("方块 长按A -2 ");
sendAcc(true, -2);
isLongPressA = true;
}
}
} else if (event.getAction() == KeyEvent.ACTION_UP) {
if (numberA == 1) {
// ToastUtils.showShort("方块 点击A -1 ");
sendAcc(true, -1);
}
numberA = 0;
isLongPressA = false;
}
return true;
} else if (event.getKeyCode() == KeyEvent.KEYCODE_B) { //单击向右变道,长按-2
if (event.getAction() == KeyEvent.ACTION_DOWN) {
numberB++;
if (numberB > 2) {
if (!isLongPressB) {
// ToastUtils.showShort("方块 长按B 无操作 ");
isLongPressB = true;
}
}
} else if (event.getAction() == KeyEvent.ACTION_UP) {
if (numberB == 1) {
// ToastUtils.showShort("方块 单击B 复原 ");
sendAcc(false, 0.0);
}
numberB = 0;
isLongPressB = false;
}
return true;
} else if (event.getKeyCode() == KeyEvent.KEYCODE_C) { //单击鸣笛,
if (event.getAction() == KeyEvent.ACTION_DOWN) {
numberC++;
if (numberC > 2) {
if (!isLongPressC) {
// ToastUtils.showShort("方块 长按C 无操作");
isLongPressC = true;
}
}
} else if (event.getAction() == KeyEvent.ACTION_UP) {
if (numberC == 1) {
// ToastUtils.showShort("方块 单击C ← 向左变道 ");
CallerAutoPilotManager.INSTANCE.sendOperatorChangeLaneLeft();
}
numberC = 0;
isLongPressC = false;
}
return true;
} else if (event.getKeyCode() == KeyEvent.KEYCODE_D) { //单击开启自动驾驶,
if (event.getAction() == KeyEvent.ACTION_DOWN) {
numberD++;
if (numberD > 2) {
if (!isLongPressD) {
// ToastUtils.showShort("方块 长按D 无操作");
isLongPressD = true;
}
}
} else if (event.getAction() == KeyEvent.ACTION_UP) {
if (numberD == 1) {
// ToastUtils.showShort("方块 单击D → 向右变道 ");
CallerAutoPilotManager.INSTANCE.sendOperatorChangeLaneRight();
}
numberD = 0;
isLongPressD = false;
}
return true;
} else if (event.getKeyCode() == KeyEvent.KEYCODE_E) { //单击复原,
if (event.getAction() == KeyEvent.ACTION_DOWN) {
numberE++;
if (numberE > 2) {
if (!isLongPressE) {
// ToastUtils.showShort("方块 长按E 鸣笛 ");
CallerAutoPilotManager.INSTANCE.sendOperatorSetHorn(1);
if (timerHorn == null) {
timerHorn = new Timer();
String bluetoothName = SharedPrefsMgr.getInstance(getContext()).getString("BLUETOOTH");
if (bluetoothName.equals("MINI_KEYBOARD")) {
if (event.getKeyCode() == KeyEvent.KEYCODE_A) { //单击向左变道,长按-1
if (event.getAction() == KeyEvent.ACTION_DOWN) {
numberA++;
if (numberA > 2) {
if (!isLongPressA) {
ToastUtils.showShort("方块 长按A -2 ");
sendAcc(true, -2);
isLongPressA = true;
}
timerHorn.schedule(new TimerTask() {
@Override
public void run() {
CallerAutoPilotManager.INSTANCE.sendOperatorSetHorn(2);
timerHorn = null;
}
}, 500);
isLongPressE = true;
}
} else if (event.getAction() == KeyEvent.ACTION_UP) {
if (numberA == 1) {
ToastUtils.showShort("方块 点击A -1 ");
sendAcc(true, -1);
}
numberA = 0;
isLongPressA = false;
}
} else if (event.getAction() == KeyEvent.ACTION_UP) {
if (numberE == 1) {
// ToastUtils.showShort("方块 单击E 开启自动驾驶 ");
return true;
} else if (event.getKeyCode() == KeyEvent.KEYCODE_B) { //单击向右变道,长按-2
if (event.getAction() == KeyEvent.ACTION_DOWN) {
numberB++;
if (numberB > 2) {
if (!isLongPressB) {
ToastUtils.showShort("方块 长按B 无操作 ");
isLongPressB = true;
}
}
} else if (event.getAction() == KeyEvent.ACTION_UP) {
if (numberB == 1) {
ToastUtils.showShort("方块 单击B 复原 ");
sendAcc(false, 0.0);
}
numberB = 0;
isLongPressB = false;
}
return true;
} else if (event.getKeyCode() == KeyEvent.KEYCODE_C) { //单击鸣笛,
if (event.getAction() == KeyEvent.ACTION_DOWN) {
numberC++;
if (numberC > 2) {
if (!isLongPressC) {
ToastUtils.showShort("方块 长按C 无操作");
isLongPressC = true;
}
}
} else if (event.getAction() == KeyEvent.ACTION_UP) {
if (numberC == 1) {
ToastUtils.showShort("方块 单击C ← 向左变道 ");
CallerAutoPilotManager.INSTANCE.sendOperatorChangeLaneLeft();
}
numberC = 0;
isLongPressC = false;
}
return true;
} else if (event.getKeyCode() == KeyEvent.KEYCODE_D) { //单击开启自动驾驶,
if (event.getAction() == KeyEvent.ACTION_DOWN) {
numberD++;
if (numberD > 2) {
if (!isLongPressD) {
ToastUtils.showShort("方块 长按D 无操作");
isLongPressD = true;
}
}
} else if (event.getAction() == KeyEvent.ACTION_UP) {
if (numberD == 1) {
ToastUtils.showShort("方块 单击D → 向右变道 ");
CallerAutoPilotManager.INSTANCE.sendOperatorChangeLaneRight();
}
numberD = 0;
isLongPressD = false;
}
return true;
} else if (event.getKeyCode() == KeyEvent.KEYCODE_E) { //单击复原,
if (event.getAction() == KeyEvent.ACTION_DOWN) {
numberE++;
if (numberE > 2) {
if (!isLongPressE) {
ToastUtils.showShort("方块 长按E 鸣笛 ");
CallerAutoPilotManager.INSTANCE.sendOperatorSetHorn(1);
if (timerHorn == null) {
timerHorn = new Timer();
}
timerHorn.schedule(new TimerTask() {
@Override
public void run() {
CallerAutoPilotManager.INSTANCE.sendOperatorSetHorn(2);
timerHorn = null;
}
}, 500);
isLongPressE = true;
}
}
} else if (event.getAction() == KeyEvent.ACTION_UP) {
if (numberE == 1) {
ToastUtils.showShort("方块 单击E 开启自动驾驶 ");
// CallerAutoPilotManager.INSTANCE.setControlAutopilotCarAuto(true);
CallerAutoPilotManager.INSTANCE.startAutoPilot(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getAutopilotControlParameters());
CallerAutoPilotManager.INSTANCE.startAutoPilot(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getAutopilotControlParameters());
}
numberE = 0;
isLongPressE = false;
}
numberE = 0;
isLongPressE = false;
return true;
}
return true;
}
return super.dispatchKeyEvent(event);
@@ -353,43 +330,6 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
// Log.d("liyz", "dispatchTouchEvent event.getX() = " + event.getX() + "--event.getY() = " + event.getY() + "--action = " + event.getAction());
if (event.getX() == -1469.6875 && event.getY() == 530.0) { //向左变道
// ToastUtils.showShort("← 向左变道");
CallerAutoPilotManager.INSTANCE.sendOperatorChangeLaneLeft();
return true;
} else if (event.getX() == -1096.25 && event.getY() == 132.5) { //鸣笛
// ToastUtils.showShort("↑ 鸣笛 ");
CallerAutoPilotManager.INSTANCE.sendOperatorSetHorn(1);
if (timerHorn == null) {
timerHorn = new Timer();
}
timerHorn.schedule(new TimerTask() {
@Override
public void run() {
CallerAutoPilotManager.INSTANCE.sendOperatorSetHorn(2);
timerHorn = null;
}
}, 500);
return true;
} else if (event.getX() == -863.4375 && event.getY() == 690.0) { //向右变道
CallerAutoPilotManager.INSTANCE.sendOperatorChangeLaneRight();
// ToastUtils.showShort("→ 向右变道");
return true;
} else if (event.getX() == -1096.25 && event.getY() == 1099.0) { // -1减速
sendAcc(true, -1);
// ToastUtils.showShort("↓ 减速 -1 ");
return true;
} else if (event.getX() == -1096.25 && event.getY() == 690.0) { //复原
// ToastUtils.showShort("O 复原 ");
sendAcc(false, 0.0);
return true;
}
return super.dispatchTouchEvent(event);
}
@@ -444,10 +384,9 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
/**
* 查找蓝牙连接过的蓝牙设备
*
* @param bluetoothAdapter
*/
private void showBondedDevice(BluetoothAdapter bluetoothAdapter) {
mAreadlyConnectedList.clear();
// mAreadlyConnectedList.clear();
Set<BluetoothDevice> deviceList = bluetoothAdapter.getBondedDevices();
for (BluetoothDevice device : deviceList) {
try {
@@ -455,14 +394,10 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
Method isConnectedMethod = BluetoothDevice.class.getDeclaredMethod("isConnected", (Class[]) null);
isConnectedMethod.setAccessible(true);
boolean isConnected = (boolean) isConnectedMethod.invoke(device, (Object[]) null);
mAreadlyConnectedList.add(device);
if (device.getName().equals("JX-05")) { //后面魔戒可能不使用了
SharedPrefsMgr.getInstance(getContext()).putString("BT_MAC", device.getAddress());
}
if (!isConnected) {
UiThreadHandler.postDelayed(() -> {
connectBluetooth(); //主动连接一次
}, 4000L);
// mAreadlyConnectedList.add(device);
// Log.d("liyz", "-- device.getName() = " + device.getName()); //device.getAddress()
if (device.getName().equals("MINI_KEYBOARD")) {
SharedPrefsMgr.getInstance(getContext()).putString("BLUETOOTH", device.getName());
}
} catch (NoSuchMethodException e) {
e.printStackTrace();
@@ -474,41 +409,11 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onAutoConnection(ConnectBluetoothEvent event) {
// connectBluetooth();
}
/**
* 主动连接最近的一次连接
*/
private void connectBluetooth() {
if (mAreadlyConnectedList.size() > 0) {
try {
Method method = BluetoothDevice.class.getMethod("createBond");
String macAddress = SharedPrefsMgr.getInstance(getContext()).getString("BT_MAC");
int pos = -1;
for (int i = 0; i < mAreadlyConnectedList.size(); i++) {
if (macAddress.equals(mAreadlyConnectedList.get(i).getAddress())) {
pos = i;
}
}
if (mAreadlyConnectedList.size() > pos && (pos >= 0)) {
method.invoke(mAreadlyConnectedList.get(pos));
}
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}

View File

@@ -329,69 +329,42 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
private fun refreshCarState(location: MogoLocation) {
V2XStatusManager.getInstance().location = location
// V2XAiRoadEventMarker.onLocationChanged(location)
// 只有车速大于 5 的时候进行计算
if (location.speed < 5) return
val v2xPolyline = BridgeApi.v2xPolyline()?.mogoPolyline
val isRoadEventPOIShow = BridgeApi.v2xStatus()?.isRoadEventPOIShow ?: false
val isOtherSeekHelpPOIShow = BridgeApi.v2xStatus()?.isOtherSeekHelpPOIShow ?: false
val v2xStatusManager = V2XStatusManager.getInstance()
if (v2xPolyline != null && (isRoadEventPOIShow or isOtherSeekHelpPOIShow) && v2xStatusManager.targetMoGoLatLng != null) { // 取出原有的绘制线的经纬度点
if (v2xPolyline != null && (isRoadEventPOIShow) && v2xStatusManager.targetMoGoLatLng != null) { // 取出原有的绘制线的经纬度点
// 取出原有的绘制线的经纬度点
val pointsOdl: MutableList<MogoLatLng> = v2xPolyline.points // 重新设置第一个坐标,也就是当前车辆位置
// 重新设置第一个坐标,也就是当前车辆位置
pointsOdl[0] = MogoLatLng(location.latitude, location.longitude)
v2xPolyline.points = pointsOdl
//CallerLogger.d("$M_V2X$TAG", "当前地图的缩放比例为:" + zoomLevel);
val zoomLevel: Float = CallerMapUIServiceManager.getMapUIController()?.zoomLevel ?: 0.0f
//CallerLogger.d("$M_V2X$TAG", "当前地图的缩放比例为:" + zoomLevel);
if (zoomLevel > 0 && zoomLevel <= 17 && BridgeApi.v2xStatus()?.isRoadEventWindowShow == false) { // 缩放地图
if (zoomLevel > 0 && zoomLevel <= 17) { // 缩放地图
val context: Context = context()
MapUtils.zoomMap(v2xStatusManager.targetMoGoLatLng, context)
}
}
// if (DebugConfig.isMapBased()) { // 只有自研车机才有疲劳驾驶检测
// // 只有自研车机才有疲劳驾驶检测
// if (DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_SELF_INNOVATE) {
// V2XAlarmServer.getFatigueDrivingShow(location) { drivingShowEntity ->
// CallerLogger.i("$M_V2X$TAG", "疲劳驾驶POI查询结果为: " + GsonUtil.jsonFromObject(drivingShowEntity))
// val style = if (V2XServiceManager.getMoGoStatusManager().isMainPageOnResume()) "1" else "2"
// com.mogo.module.v2x.listener.V2XLocationListener.trackWithType(ALERT_FATIGUE_DRIVING.poiType, drivingShowEntity.getLon(), drivingShowEntity.getLat(), style)
// val v2XMessageEntity = V2XMessageEntity<V2XPushMessageEntity>()
// v2XMessageEntity.type = V2XTypeEnum.ALERT_FATIGUE_DRIVING
// v2XMessageEntity.setContent(drivingShowEntity)
// v2XMessageEntity.isShowState = drivingShowEntity.isShowWindow() // 广播给ADAS Launcher
// ADASUtils.broadcastToADAS(context(), drivingShowEntity)
// V2XScenarioManager.getInstance().handlerMessage(v2XMessageEntity)
// }
// }
// }
// 巡航处理
val v2XRoadEventEntity = V2XAlarmServer.getDriveFrontAlarmEvent(
BridgeApi.v2xMarker()?.v2XRoadEventEntityList,
V2XStatusManager.getInstance().location
) // 距离是否大于10米 && 消息是否不为空
// 距离是否大于10米 && 消息是否不为空
if (v2XRoadEventEntity != null && v2XRoadEventEntity.distance >= 5) { // CallerLogger.w("$M_V2X$TAG",
// //"\nV2X预警--当前导航状态:" + V2XServiceManager.getNavi().isNaviing() +
// //"\nV2X预警--roadEventIsNullCount:" + roadEventIsNullCount +
// "\nV2X预警--当前预警事件:" + v2XRoadEventEntity
// );
// CallerLogger.w("$M_V2X$TAG", "V2X预警--前方数据距离:" + v2XRoadEventEntity.getDistance());
// 触发展示操作
TrackUtils.trackV2xRoadProduceEvent(1)
val v2XMessageEntity = V2XMessageEntity<V2XRoadEventEntity>()
v2XMessageEntity.type = V2XTypeEnum.ALERT_ROAD_WARNING
v2XMessageEntity.content = v2XRoadEventEntity
v2XMessageEntity.isShowState = true
V2XScenarioManager.getInstance().handlerMessage(v2XMessageEntity)
// 存储本地,出行动态作展示
saveLocalStory(V2XTypeEnum.ALERT_ROAD_WARNING, v2XRoadEventEntity.noveltyInfo)
)
if (v2XRoadEventEntity != null) { // CallerLogger.w("$M_V2X$TAG",
val distance = v2XRoadEventEntity.distance
val min = if (EventTypeEnum.AI_ROAD_WORK.poiType == v2XRoadEventEntity.poiType) 0 else 5
Logger.d(TAG, "--- trigger show before ---:data=>[${location.longitude}, ${location.latitude}, ${location.speed}], distance: $distance, minDistance: $min, poiType: ${v2XRoadEventEntity.poiType}")
if (distance >= min) {
Logger.d(TAG, "--- trigger show ---:poiType:" + v2XRoadEventEntity.poiType)
TrackUtils.trackV2xRoadProduceEvent(1)
val v2XMessageEntity = V2XMessageEntity<V2XRoadEventEntity>()
v2XMessageEntity.type = V2XTypeEnum.ALERT_ROAD_WARNING
v2XMessageEntity.content = v2XRoadEventEntity
v2XMessageEntity.isShowState = true
V2XScenarioManager.getInstance().handlerMessage(v2XMessageEntity)
}
}
}
@@ -507,11 +480,6 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
private fun handleRoadMarkerEvent(data: V2XMarkerCardResult) {
try {
BridgeApi.v2xStatus()?.let {
if (it.isRoadEventWindowShow) {
return
}
}
scope.launch(Dispatchers.Default) {
BridgeApi.v2xMarker()?.analysisV2XRoadEvent(data)
}

View File

@@ -1,18 +1,13 @@
package com.mogo.eagle.core.function.v2x.events.alarm;
import android.text.TextUtils;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.v2x.events.utils.DrivingDirectionUtils;
import com.mogo.eagle.core.utilcode.constant.TimeConstants;
import com.mogo.eagle.core.utilcode.util.TimeUtils;
import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.entity.MarkerLocation;
import com.mogo.module.common.entity.V2XRoadEventEntity;
import com.mogo.module.common.enums.EventTypeEnum;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.Iterator;
import java.util.concurrent.CopyOnWriteArrayList;
import io.netty.util.internal.ConcurrentSet;
/**
* @author donghongyu
@@ -29,11 +24,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
public class V2XAlarmServer {
// 记录道路播报的事件
public static ConcurrentHashMap<V2XRoadEventEntity, String> mAlertRoadEventList = new ConcurrentHashMap<>();
// 记录违章停车播报事件
private static final HashMap<MarkerExploreWay, String> mAlertIllegalParkEventList = new HashMap<>();
private static ConcurrentSet<V2XRoadEventEntity> showedEvents = new ConcurrentSet<>();
/**
* 获取当前车辆前方距离最近的道路事件
*/
@@ -41,9 +32,22 @@ public class V2XAlarmServer {
CopyOnWriteArrayList<V2XRoadEventEntity> v2XRoadEventEntityList,
MogoLocation currentLocation) {
try {
// 检测道路事件是否需UGC问答
V2XEarlyWarningServer.roadEventUgcCheck(currentLocation);
// 60(km/h)
if (!showedEvents.isEmpty()) {
Iterator<V2XRoadEventEntity> iterator = showedEvents.iterator();
while (iterator.hasNext()) {
V2XRoadEventEntity next = iterator.next();
if (next == null) {
continue;
}
MarkerLocation poiLocation = next.getLocation();
if (poiLocation == null) {
continue;
}
if (isOutOfRange(poiLocation.getLon(), poiLocation.getLat(), currentLocation.getLongitude(), currentLocation.getLatitude(), currentLocation.getBearing())) {
iterator.remove();
}
}
}
if (currentLocation != null && v2XRoadEventEntityList != null) {
// 因为集合是按照距离排序后的所以这里检索出来第一个就发出警告
for (V2XRoadEventEntity v2XRoadEventEntity : v2XRoadEventEntityList) {
@@ -73,71 +77,14 @@ public class V2XAlarmServer {
(int) currentLocation.getBearing()
);
if (0 <= eventAngle && eventAngle <= 20) {
// 判断是否已经提示过道路事件
boolean isAlreadyAlert = false;
String lastTime = mAlertRoadEventList.get(v2XRoadEventEntity);
if (!TextUtils.isEmpty(lastTime)) {
long timeSpan = Math.abs(TimeUtils.getTimeSpanByNow(lastTime, TimeConstants.MIN));
// CallerLogger.INSTANCE.w(M_V2X + "V2XAlarmServer",
// "V2X预警--事件ID" + v2XRoadEventEntity.getNoveltyInfo().getInfoId() +
// "\n上一次预警时间" + lastTime +
// "\n距离当前时间" + timeSpan);
// 5分钟内不重复提醒
if (timeSpan < 5) {
isAlreadyAlert = true;
}
if (showedEvents.contains(v2XRoadEventEntity)) {
return null;
}
// 进行提醒
if (!isAlreadyAlert) {
// CallerLogger.INSTANCE.w(M_V2X + "V2XAlarmServer", "V2X预警--车辆与事件信息:" +
// "\n事件详情ID" + v2XRoadEventEntity.getNoveltyInfo().getInfoId() +
// "\n事件详情" + GsonUtil.jsonFromObject(v2XRoadEventEntity.getNoveltyInfo()) +
// "\n距离" + v2XRoadEventEntity.getDistance() + "米" +
// "\n是否已经提醒" + isAlreadyAlert +
// "\n当前车辆-经度:" + currentLocation.getLongitude() +
// "\n当前车辆-经度:" + currentLocation.getLatitude() +
// "\n当前车辆-角度:" + currentLocation.getBearing() +
// "\n道路事件-经度:" + eventLocation.getLon() +
// "\n道路事件-经度:" + eventLocation.getLat() +
// "\n道路事件-角度:" + eventLocation.getAngle() +
// "\n夹角角度" + eventAngle + " 度"
// );
mAlertRoadEventList.put(v2XRoadEventEntity, TimeUtils.getNowString());
return v2XRoadEventEntity;
}
return null;
} else {
// CallerLogger.INSTANCE.w(M_V2X + "V2XAlarmServer", "V2X预警--事件与车头角度夹角过大:" +
// "\n事件详情" + v2XRoadEventEntity.getNoveltyInfo().getInfoId() +
// "\n当前车辆-经度:" + currentLocation.getLongitude() +
// "\n当前车辆-经度:" + currentLocation.getLatitude() +
// "\n当前车辆-角度:" + currentLocation.getBearing() +
// "\n道路事件-经度:" + eventLocation.getLon() +
// "\n道路事件-经度:" + eventLocation.getLat() +
// "\n道路事件-角度:" + eventLocation.getAngle() +
// "\n夹角角度" + eventAngle + " 度"
// );
showedEvents.add(v2XRoadEventEntity);
return v2XRoadEventEntity;
}
} else {
// CallerLogger.INSTANCE.w(M_V2X + "V2XAlarmServer",
// "V2X预警--车头方向与事件方向角度不一致:" +
// "\n事件详情" + v2XRoadEventEntity.getNoveltyInfo().getInfoId() +
// "\n车头方向 " + carBearing +
// "\n事件方向" + eventBearing +
// "\n角度差值" + diffAngle
// );
}
} else {
// CallerLogger.INSTANCE.w(M_V2X + "V2XAlarmServer", "V2X预警--车辆距离事件距离大于500米了" +
// "\n事件详情" + v2XRoadEventEntity.getNoveltyInfo().getInfoId() +
// "\n距离" + v2XRoadEventEntity.getDistance() + "米"
// );
}
} else {
// CallerLogger.INSTANCE.e(M_V2X + "V2XAlarmServer",
// "V2X预警--道路事件没有角度信息" +
// "\n事件详情" + v2XRoadEventEntity.getNoveltyInfo().getInfoId()
// );
}
}
}
@@ -147,4 +94,14 @@ public class V2XAlarmServer {
return null;
}
private static boolean isOutOfRange(double poi_lon, double poi_lat, double car_lon, double car_lat, double car_angle) {
return !isFrontOfCar(poi_lon, poi_lat, car_lon, car_lat, car_angle);
}
private static boolean isFrontOfCar(double poi_lon, double poi_lat, double car_lon, double car_lat, double car_angle) {
double degree = DrivingDirectionUtils.getDegreeOfCar2Poi(car_lon, car_lat, poi_lon, poi_lat, (int)car_angle);
return degree <= 90;
}
}

View File

@@ -1,101 +0,0 @@
package com.mogo.eagle.core.function.v2x.events.alarm;
import android.content.Intent;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.mogo.eagle.core.function.v2x.events.consts.V2XConst;
import com.mogo.eagle.core.function.v2x.events.utils.DrivingDirectionUtils;
import com.mogo.eagle.core.utilcode.util.Utils;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.module.common.entity.MarkerLocation;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XRoadEventEntity;
import com.mogo.module.common.enums.EventTypeEnum;
import java.util.ArrayList;
import java.util.Set;
/**
* V2X 道路预警服务
*/
public class V2XEarlyWarningServer {
private static final String TAG = "V2XEarlyWarningServer";
private static ArrayList<String> alertMessageId = new ArrayList<>();
/**
* 对提醒过的道路事件进行UGC检测
*
* @param currentLocation 当前车辆位置
*/
public static void roadEventUgcCheck(MogoLocation currentLocation) {
try {
if (currentLocation != null) {
// 循环已经播报的道路事件将刚行驶过的道路事件进行弹窗交互进行UGC问答
Set<V2XRoadEventEntity> keySet = V2XAlarmServer.mAlertRoadEventList.keySet();
for (V2XRoadEventEntity v2XRoadEventEntity : keySet) {
// 计算车辆距离指定气泡的距离
MarkerLocation eventLocation = v2XRoadEventEntity.getLocation();
double eventAngle = DrivingDirectionUtils.getDegreeOfCar2Poi(
currentLocation.getLongitude(),
currentLocation.getLatitude(),
eventLocation.getLon(),
eventLocation.getLat(),
(int) currentLocation.getBearing()
);
double carBearing = currentLocation.getBearing();
String roadInfoId = v2XRoadEventEntity.getNoveltyInfo().getInfoId();
// 封路、施工、拥堵、拥堵 才会有UGC提示
if (EventTypeEnum.isNeedRoadEventUgc(v2XRoadEventEntity.getPoiType())) {
// CallerLogger.INSTANCE.d(M_V2X + TAG,
// "V2X预警--UGC检测" +
// "\n事件详情" + roadInfoId +
// "\n事件详情" + EventTypeUtils.getPoiTypeStr(v2XRoadEventEntity.getPoiType()) +
// "\n车头方向 " + carBearing +
// "\n车与事件夹角" + eventAngle +
// "\n已经UGC的事件" + GsonUtil.jsonFromObject(alertMessageId)
// );
// 判断是否预警过了
if (!alertMessageId.contains(roadInfoId)) {
// 判断车辆行驶角度是否与事件相反,相反的话表示已经行驶过去了
if (80 <= eventAngle) {
// CallerLogger.INSTANCE.d(M_V2X + TAG, "V2X预警UGC--事件与车头角度夹角过大:" +
// "\n角度" + eventAngle + " 度" +
// "\n事件详情" + roadInfoId +
// "\n库存事件" + V2XAlarmServer.mAlertRoadEventList.size()
// );
// 记录已经 UGC 提醒过的数据
alertMessageId.add(roadInfoId);
// 加载数据源
V2XMessageEntity<V2XRoadEventEntity> v2xMessageEntity = new V2XMessageEntity<>();
// 控制类型
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_EVENT_UGC_WARNING);
// 设置数据
v2xMessageEntity.setContent(v2XRoadEventEntity);
// 控制展示状态
v2xMessageEntity.setShowState(true);
// 弹出UGC
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2xMessageEntity);
LocalBroadcastManager.getInstance(Utils.getApp()).sendBroadcast(intent);
}
// 移出已经预警的事件列表
//V2XAlarmServer.mAlertRoadEventList.remove(v2XRoadEventEntity);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -15,26 +15,6 @@ public interface IMoGoV2XStatusManager extends IProvider {
*/
boolean isRoadEventPOIShow();
/**
* 按钮区 V2X道路预警 是否在展示
*/
boolean isRoadEventButtonShow();
/**
* 头部 V2X道路预警 UI 是否在展示
*/
boolean isRoadEventWindowShow();
/**
* 头部 他人车辆故障求助 UI 是否在展示
*/
boolean isOtherSeekHelpWindowShow();
/**
* 地图区域 他人车辆故障求助POI 是否在展示
*/
boolean isOtherSeekHelpPOIShow();
/**
* 设置 V2X道路预警POI 是否在展示
*
@@ -43,67 +23,6 @@ public interface IMoGoV2XStatusManager extends IProvider {
*/
void setRoadEventPOIShow(String tag, boolean show);
/**
* 设置 V2X道路预警 是否在展示
*
* @param tag
* @param show
*/
void setRoadEventButtonShow(String tag, boolean show);
/**
* 设置 右侧2/3 头部 V2X道路预警 是否在展示
*
* @param tag
* @param show
*/
void setRoadEventWindowShow(String tag, boolean show);
/**
* 设置 右侧2/3 头部 V2X的道路直播 是否在展示
*
* @param tag
* @param show
*/
void setRoadLiveCarWindowShow(String tag, boolean show);
/**
* 设置 他人车辆故障求助 UI 是否在展示
*
* @param tag
* @param show
*/
void setOtherSeekHelpWindowShow(String tag, boolean show);
/**
* 设置 右侧2/3 全屏 V2X 场景动画 是否在展示
*
* @param tag
* @param show
*/
void setV2XAnimationWindowShow(String tag, boolean show);
/*
* 道路事件图片/视频资源 全屏
* */
void setV2XRoadVideoWindowShow(String tag, boolean show);
/**
* 设置 模拟直播车机 UI 是否在展示
*
* @param tag
* @param show
*/
void setLiveCarWindowShow(String tag, boolean show);
/**
* 推送弹窗的状态
*
* @param tag
* @param show
*/
void setPushWindowShow(String tag, boolean show);
/**
* 地图区域 推送的 POI 是否在展示
*
@@ -112,11 +31,4 @@ public interface IMoGoV2XStatusManager extends IProvider {
*/
void setPushPOIShow(String tag, boolean show);
/**
* 地图区域 疲劳驾驶 是否在展示
*
* @param tag
* @param show
*/
void setFatigueDrivingWindowShow(String tag, boolean show);
}

View File

@@ -63,7 +63,6 @@ public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager {
private static final CopyOnWriteArraySet<V2XRoadEventEntity> mV2XRoadEventEntityArrayList = new CopyOnWriteArraySet<>();
// 上次的道路事件的预警Marker
private static IMogoMarker mAlarmInfoMarker;
private static IMogoMarker m3DMarker;
@Override
public void drawableLastAllPOI() {
@@ -81,7 +80,6 @@ public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager {
CopyOnWriteArrayList<V2XRoadEventEntity> roadEventEntities = new CopyOnWriteArrayList<>();
// 当前车辆数据
MogoLocation currentLocation = V2XStatusManager.getInstance().getLocation();
if (currentLocation != null) {
// 重新计算距离
for (V2XRoadEventEntity v2XRoadEventEntity : mV2XRoadEventEntityArrayList) {
@@ -96,7 +94,6 @@ public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager {
}
roadEventEntities.add(v2XRoadEventEntity);
}
// 按照与当前车辆距离排序
for (int i = 0; i < roadEventEntities.size(); i++) {
for (int j = i; j > 0; j--) {
@@ -107,37 +104,17 @@ public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager {
}
}
}
//输出日志查看结果
// for (int i = 0; i < roadEventEntities.size(); i++) {
// CallerLogger.INSTANCE.w(M_V2X + TAG, "V2X===" +
// "事件名称:" + roadEventEntities.get(i).getNoveltyInfo() +
// "\t 事件距离:" + roadEventEntities.get(i).getDistance());
// }
}
return roadEventEntities;
}
@Override
public void analysisV2XRoadEvent(V2XMarkerCardResult markerCardResult) {
boolean isShowEventWindow = false;
boolean isShowEventButton = false;
boolean isOtherSeekHelpWindowShow = false;
IMoGoV2XStatusManager v2xStatus = BridgeApi.INSTANCE.v2xStatus();
if (v2xStatus != null) {
//预警Window状态
isShowEventWindow = v2xStatus.isRoadEventWindowShow();
//预警按钮状态
isShowEventButton = v2xStatus.isRoadEventButtonShow();
//道路求助的window
isOtherSeekHelpWindowShow = v2xStatus.isOtherSeekHelpWindowShow();
}
try {
//当没有预警提示的时候重新绘制地图POI点
if (markerCardResult != null && !isShowEventWindow && !isShowEventButton && !isOtherSeekHelpWindowShow) {
if (markerCardResult != null) {
// 清除上次的道路事件, 这里注意,道路事件的触发和这里是异步操作会触发异常
mV2XRoadEventEntityArrayList.clear();
// 获取探路以及新鲜事儿
List<V2XMarkerExploreWay> exploreWayList = markerCardResult.getExploreWay();
if (exploreWayList != null) {
@@ -149,7 +126,6 @@ public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager {
v2XRoadEventEntity.setLocation(EntityUtilsKt.toMarkerLocation(markerLocation));
// 探路目前只有上报拥堵
String poi = markerExploreWay.getPoiType();
v2XRoadEventEntity.setPoiType(poi);
v2XRoadEventEntity.setNoveltyInfo(EntityUtilsKt.toMarkExploreWay(markerExploreWay,markerCardResult.getExtras()));
v2XRoadEventEntity.setExpireTime(20000);

View File

@@ -11,7 +11,6 @@ import com.mogo.eagle.core.function.v2x.events.manager.IMoGoV2XStatusManager;
import com.mogo.eagle.core.function.v2x.events.manager.V2XStatusDescriptor;
import com.mogo.service.statusmanager.IMogoStatusManager;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -53,26 +52,6 @@ public class MoGoV2XStatusManager implements IMoGoV2XStatusManager {
return get_bool_val(V2XStatusDescriptor.RoadEventPOI_UI);
}
@Override
public boolean isRoadEventButtonShow() {
return get_bool_val(V2XStatusDescriptor.RoadEventButton_UI);
}
@Override
public boolean isRoadEventWindowShow() {
return get_bool_val(V2XStatusDescriptor.RoadEventWindow_UI);
}
@Override
public boolean isOtherSeekHelpWindowShow() {
return get_bool_val(V2XStatusDescriptor.OtherSeekHelpWindow_UI);
}
@Override
public boolean isOtherSeekHelpPOIShow() {
return get_bool_val(V2XStatusDescriptor.OtherSeekHelpPOI_UI);
}
@Override
public void setRoadEventPOIShow(String tag, boolean show) {
IMogoStatusManager statusManager = BridgeApi.INSTANCE.statusManager();
@@ -84,62 +63,6 @@ public class MoGoV2XStatusManager implements IMoGoV2XStatusManager {
recordStatusModifier(tag, V2XStatusDescriptor.RoadEventPOI_UI);
}
@Override
public void setRoadEventButtonShow(String tag, boolean show) {
mStatus.put(V2XStatusDescriptor.RoadEventButton_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.RoadEventButton_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.RoadEventButton_UI);
}
@Override
public void setRoadEventWindowShow(String tag, boolean show) {
mStatus.put(V2XStatusDescriptor.RoadEventWindow_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.RoadEventWindow_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.RoadEventWindow_UI);
}
@Override
public void setRoadLiveCarWindowShow(String tag, boolean show) {
mStatus.put(V2XStatusDescriptor.RoadLiveCarWindow_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.RoadLiveCarWindow_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.RoadLiveCarWindow_UI);
}
@Override
public void setOtherSeekHelpWindowShow(String tag, boolean show) {
mStatus.put(V2XStatusDescriptor.OtherSeekHelpWindow_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.OtherSeekHelpWindow_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.OtherSeekHelpWindow_UI);
}
@Override
public void setV2XAnimationWindowShow(String tag, boolean show) {
mStatus.put(V2XStatusDescriptor.V2XAnimationWindow_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.V2XAnimationWindow_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.V2XAnimationWindow_UI);
}
@Override
public void setV2XRoadVideoWindowShow(String tag, boolean show) {
mStatus.put(V2XStatusDescriptor.V2XAnimationWindow_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.V2XRoadVideo_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.V2XRoadVideo_UI);
}
@Override
public void setLiveCarWindowShow(String tag, boolean show) {
mStatus.put(V2XStatusDescriptor.LiveCarWindow_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.LiveCarWindow_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.LiveCarWindow_UI);
}
@Override
public void setPushWindowShow(String tag, boolean show) {
mStatus.put(V2XStatusDescriptor.PushWindow_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.PushWindow_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.PushWindow_UI);
}
@Override
public void setPushPOIShow(String tag, boolean show) {
@@ -148,14 +71,7 @@ public class MoGoV2XStatusManager implements IMoGoV2XStatusManager {
recordStatusModifier(tag, V2XStatusDescriptor.PushWindowPOI_UI);
}
@Override
public void setFatigueDrivingWindowShow(String tag, boolean show) {
mStatus.put(V2XStatusDescriptor.FatigueDrivingWindow_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.FatigueDrivingWindow_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.FatigueDrivingWindow_UI);
}
/**
/**
* 调用所有存储的监听
*
* @param descriptor

View File

@@ -63,7 +63,6 @@ public class V2XScenarioManager implements IV2XScenarioManager {
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
LocalBroadcastManager.getInstance(Utils.getApp()).sendBroadcast(intent);
AiRoadMarker.INSTANCE.clear();
// 如果没有拿到之前的,根据类型分发
switch (v2XMessageEntity.getType()) {
case V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING:

View File

@@ -13,8 +13,10 @@ import androidx.lifecycle.Lifecycle.Event.ON_DESTROY
import com.mogo.eagle.core.data.map.*
import com.mogo.eagle.core.data.map.MapRoadInfo.StopLine
import com.mogo.eagle.core.function.api.map.listener.*
import com.mogo.eagle.core.function.api.v2x.*
import com.mogo.eagle.core.function.call.map.*
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager.OnRoadListener
import com.mogo.eagle.core.function.call.v2x.*
import com.mogo.eagle.core.function.v2x.events.scenario.scene.road.*
import com.mogo.eagle.core.utilcode.kotlin.*
import com.mogo.eagle.core.utilcode.mogo.logger.*
@@ -56,9 +58,30 @@ object AiRoadMarker {
}
private val checkExpiredTask = Runnable {
val marker = this@AiRoadMarker.marker.get()
if (marker != null) {
unMarker(marker)
// val marker = this@AiRoadMarker.marker.get()
// if (marker != null) {
// unMarker(marker)
// }
}
private val onClearAllMarker = object : OnClearAllMarker {
override fun onClearAllMarkers() {
Logger.d(TAG, "--- onClearAllMarkers ----")
val marker = this@AiRoadMarker.marker.get()
if (marker != null) {
Logger.d(TAG, "--- onClearAllMarkers ----2")
unMarker(marker)
}
}
override fun onClearAllMarkers(tag: String) {
Logger.d(TAG, "--- onClearAllMarkers ----: tag: $tag")
val marker = this@AiRoadMarker.marker.get()
if (marker != null) {
Logger.d(TAG, "--- onClearAllMarkers ----: tag: -- 1: $tag")
unMarker(marker)
}
}
}
@@ -160,12 +183,12 @@ object AiRoadMarker {
try {
val loc = arrayOf(location.longitude, location.latitude)
carLocation.set(Triple(loc[0], loc[1], location.bearing.toDouble()))
val marker = marker.get() ?: return
val isOutOfRange = isOutOfRange(marker.poi_lon, marker.poi_lat, carLocation.get().first, carLocation.get().second, carLocation.get().third)
if (isOutOfRange) {
Logger.d(TAG, "--- onLocationChanged: isOutOfRange --- ")
unMarker(marker)
}
// val marker = marker.get() ?: return
// val isOutOfRange = isOutOfRange(marker.poi_lon, marker.poi_lat, carLocation.get().first, carLocation.get().second, carLocation.get().third)
// if (isOutOfRange) {
// Logger.d(TAG, "--- onLocationChanged: isOutOfRange --- ")
// unMarker(marker)
// }
} catch (t: Throwable) {
Logger.e(TAG, "error: ${t.message}")
}
@@ -174,11 +197,13 @@ object AiRoadMarker {
private fun onCreate() {
CallerMapRoadListenerManager.registerRoadListener(TAG, onRoadListener)
CallMarkersClearManager.addAllMarkersClearListener(TAG, onClearAllMarker)
CallerMapLocationListenerManager.addListener(TAG, onLocationListener, true)
}
private fun onDestroy() {
CallerMapRoadListenerManager.unRegisterRoadListener(TAG)
CallMarkersClearManager.removeAllMarkersClearListener(TAG)
CallerMapLocationListenerManager.removeListener(TAG, true)
pool.shutdownNow()
removeLine()
@@ -201,7 +226,15 @@ object AiRoadMarker {
}
fun marker(marker: Marker, drawMarker: Boolean) {
handler.removeCallbacks(checkExpiredTask)
val location = carLocation.get() ?: return
if (markers.contains(marker)) {
Logger.d(TAG, "--- enqueue --- cache hit ---")
return
}
synchronized(markers) {
markers += marker
}
this.marker.set(marker)
//施工中心点前方的自车行驶方向上300米距离
val l1 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(marker.poi_lon, marker.poi_lat, location.third.toFloat(), 300f)
@@ -295,33 +328,7 @@ object AiRoadMarker {
markers -= marker
removeLine()
V2XAiRoadEventMarker.removeMarkers(null)
}
fun clear() {
hideLine()
V2XAiRoadEventMarker.removeMarkers(null)
}
fun restore() {
showLine()
val marker = marker.get()
if (marker != null) {
marker(marker, false)
}
}
private fun hideLine() {
val old = line.get()
if (old != null && !old.isDestroyed) {
old.isVisible = false
}
}
private fun showLine() {
val old = line.get()
if (old != null && !old.isDestroyed) {
old.isVisible = true
}
handler.removeCallbacks(checkExpiredTask)
}
private fun isOutOfRange(markerLon: Double, markerLat: Double, carLon: Double, carLat: Double, carAngle: Double): Boolean {
@@ -335,13 +342,18 @@ object AiRoadMarker {
fun receive(marker: Marker) {
val cur = this.marker.get()
Logger.d(TAG, "receive --- 1 ---")
if (cur == marker) {
Logger.d(TAG, "receive --- 2 ---")
val poi = this.marker.get()
val car = this.carLocation.get()
if (poi != null && car != null) {
val distance = DrivingDirectionUtils.distance(car.first, car.second, marker.poi_lon, marker.poi_lat)
if (distance < 300) {
val distance = DrivingDirectionUtils.distance(car.first, car.second, marker.poi_lon, marker.poi_lat) * 10000
Logger.d(TAG, "receive --- 3 ---:car:[${car.first}, ${car.second}] -> poi:[${marker.poi_lon}, ${marker.poi_lat}] --> distance:$distance")
if (distance < 200) {
checkExpired()
} else {
handler.removeCallbacks(checkExpiredTask)
}
}
}
@@ -349,7 +361,7 @@ object AiRoadMarker {
private fun checkExpired() {
handler.removeCallbacks(checkExpiredTask)
handler.postDelayed(checkExpiredTask, 5000)
handler.postDelayed(checkExpiredTask, 60_000)
}
data class Marker(

View File

@@ -0,0 +1,8 @@
package com.mogo.eagle.core.function.api.v2x
interface OnClearAllMarker {
fun onClearAllMarkers()
fun onClearAllMarkers(tag: String)
}

View File

@@ -0,0 +1,34 @@
package com.mogo.eagle.core.function.call.v2x
import com.mogo.eagle.core.function.api.v2x.*
import java.util.concurrent.*
object CallMarkersClearManager {
private val listeners by lazy { ConcurrentHashMap<String, ArrayList<OnClearAllMarker>>() }
fun addAllMarkersClearListener(tag: String, listener: OnClearAllMarker) {
var ll = listeners[tag]
if (ll == null) {
ll = ArrayList()
}
ll.add(listener)
listeners[tag] = ll
}
fun removeAllMarkersClearListener(tag: String) {
listeners.remove(tag)
}
fun invokeClearAllMarkers() {
listeners.values.flatten().forEach {
it.onClearAllMarkers()
}
}
fun invokeClearAllMarkersOfTag(tag: String) {
listeners.values.flatten().forEach {
it.onClearAllMarkers(tag)
}
}
}

View File

@@ -5,6 +5,7 @@ import android.content.Context;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.util.ToastUtils;
import com.mogo.tts.base.IMogoTTS;
import com.mogo.tts.base.IMogoTTSCallback;
import com.mogo.tts.base.PreemptType;
/**
@@ -90,6 +91,12 @@ public class AIAssist {
}
}
public void speakTTSVoiceWithLevel(String text, int level, IMogoTTSCallback callBack) {
if (mTTS != null) {
mTTS.speakTTSVoiceWithLevel(text, level, callBack);
}
}
/**
* 等级由低到高为0、1、2、3分别对应p3、p2、p1、p0
* @param text

View File

@@ -175,4 +175,4 @@ ADAS_DATA_LIB_CHILD_VERSION=.0
# 线程优化版本
THREAD_OPT_VERSION=3.0.1
THREAD_OPT_VERSION=3.0.2

View File

@@ -302,7 +302,6 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
if (mSocket == null || bytes == null || bytes.length <= 0) {
return false;
}
Log.d("liyz", "sendWsMessag bytes = " + bytes); //TODO
ByteString byteString = ByteString.of(bytes);
if (!byteString.startsWith(Constants.RAW_MG)) {
CupidLogUtils.e(TAG, "协议不匹配,命令下发失败 bytes=" + ByteUtil.byteArrToHex(bytes));

View File

@@ -3,6 +3,7 @@ package com.mogo.map;
import android.content.Context;
import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.eagle.core.function.call.v2x.CallMarkersClearManager;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.IMogoMarkerManager;
import com.mogo.map.marker.MogoMarkerOptions;
@@ -100,11 +101,13 @@ public class MogoMarkerManager implements IMogoMarkerManager {
@Override
public void removeMarkers( String tag ) {
CallMarkersClearManager.INSTANCE.invokeClearAllMarkersOfTag(tag);
MogoMarkersHandler.getInstance().remove( tag );
}
@Override
public void removeMarkers() {
CallMarkersClearManager.INSTANCE.invokeClearAllMarkers();
MogoMarkersHandler.getInstance().removeAll();
}
@@ -115,6 +118,7 @@ public class MogoMarkerManager implements IMogoMarkerManager {
@Override
public void inVisibleAllMarkers() {
CallMarkersClearManager.INSTANCE.invokeClearAllMarkers();
MogoMarkersHandler.getInstance().inVisibleAll();
}

View File

@@ -1,10 +1,6 @@
package com.mogo.module.service.routeoverlay;
import android.os.SystemClock;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
@@ -16,15 +12,11 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager;
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import org.jetbrains.annotations.NotNull;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import mogo.telematics.pad.MessagePad;
import mogo_msg.MogoReportMsg;
@@ -62,7 +54,6 @@ public class MogoRouteOverlayManager implements
@Override
public void onAutopilotTrajectory(@NonNull List<MessagePad.TrajectoryPoint> items) {
Logger.d(TAG, "--- onAutopilotTrajectory ---:" + items.size());
synchronized (queue) {
queue.clear();
queue.offer(items);
@@ -75,11 +66,13 @@ public class MogoRouteOverlayManager implements
return;
}
if (isArriveAtStation.get() && autopilotMode.get() != 1) {
Logger.d(TAG, "--- onLocationChanged 1 -- [isDemo1: " + FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData + ",isDemo2:" +FunctionBuildConfig.isDemoMode + ",isGps:" + isGps + ",mode:" + autopilotMode.get() + ",lon:" + location.getLongitude() + ",lat:" + location.getLatitude() + ",angle:" + location.getBearing() + "]");
RouteOverlayDrawer.getInstance().clearMogoRouteOverlay();
return;
}
boolean force = FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData;
if (!force && autopilotMode.get() != 1) {
Logger.d(TAG, "--- onLocationChanged 2 -- [isDemo1: " + FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData + ",isDemo2:" +FunctionBuildConfig.isDemoMode + ",isGps:" + isGps + ",mode:" + autopilotMode.get() + ",lon:" + location.getLongitude() + ",lat:" + location.getLatitude() + ",angle:" + location.getBearing() + "]");
RouteOverlayDrawer.getInstance().clearMogoRouteOverlay();
return;
}
@@ -87,11 +80,11 @@ public class MogoRouteOverlayManager implements
if (!queue.isEmpty()) {
List<MessagePad.TrajectoryPoint> items = queue.pollLast();
if (items != null && !items.isEmpty()) {
Logger.d(TAG, "--- onLocationChanged -- [isDemo1: " + FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData + ",isDemo2:" +FunctionBuildConfig.isDemoMode + ",isGps:" + isGps + ",mode:" + autopilotMode.get() + ",lon:" + location.getLongitude() + ",lat:" + location.getLatitude() + ",angle:" + location.getBearing() + "]");
RouteOverlayDrawer.getInstance().drawTrajectoryList(items, location.getBearing());
}
}
}
}
@Override
@@ -100,10 +93,6 @@ public class MogoRouteOverlayManager implements
@Override
public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autoPilotStatusInfo) {
if (FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData) {
isArriveAtStation.set(false);
return;
}
int mode = autoPilotStatusInfo.getPilotmode();
if (mode == 1) {
isArriveAtStation.set(false);
@@ -116,7 +105,6 @@ public class MogoRouteOverlayManager implements
if (arrivalNotification == null) {
return;
}
Log.d(TAG, "onArriveAt data : " + arrivalNotification);
if (!isArriveAtStation.get()) {
isArriveAtStation.set(true);
}

View File

@@ -41,6 +41,8 @@ interface IMogoTTS extends IProvider {
void speakTTSVoiceWithLevel( String tts, int level);
void speakTTSVoiceWithLevel( String tts, int level, IMogoTTSCallback callBack);
/**
* 播放 tts 语音
*

View File

@@ -63,6 +63,8 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
// 等级由低到高为0、1、2、3默认为-1表示没有正在tts的
private int curTtsLevel = -1;
// 由于主动打断不会有回调事件所以主动打断时清掉map中被打断的text和callback
private String curTtsContent = "";
private LinkedList<Pair<String, Integer>> linkedList = new LinkedList<>();
public void release() {
@@ -79,6 +81,7 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
}
mQAndAMap.clear();
mVoiceClient.release();
curTtsContent = "";
curTtsLevel = -1;
if (mEngine != null) {
mEngine.destroy();
@@ -351,6 +354,7 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
if (mSpeakVoiceMap.containsKey(text)) {
mSpeakVoiceMap.remove(text);
}
curTtsContent = "";
curTtsLevel = -1;
mEngine.stop();
}
@@ -358,7 +362,11 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
public void stopTts() {
if (mEngine != null && mHasAuth) {
if (mSpeakVoiceMap.containsKey(curTtsContent)) {
mSpeakVoiceMap.remove(curTtsContent);
}
// tts过程中调用stop不会有回调事件
curTtsContent = "";
curTtsLevel = -1;
mEngine.stop();
}
@@ -410,12 +418,21 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
}
}
curTtsLevel = ttsLevel;
curTtsContent = text;
// 合成并播放
CallerLogger.INSTANCE.d(TAG, "tts准备合成" + text + ",curTtsLevel为" + curTtsLevel);
mEngine.speak(text, text, mAILocalTTSIntent);
}
}
@MainThread
public void speakTTSVoiceWithLevel(String text, int ttsLevel, IMogoTTSCallback callBack) {
if (mHasFlush && mEngine != null) {
mSpeakVoiceMap.put(text, callBack);
}
speakTTSVoiceWithLevel(text, ttsLevel);
}
// 降序插入Tts(目前Level0、1可排队)
private void insertTts(String text, int level) {
int index = -1;
@@ -741,6 +758,7 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
public void onError(String utteranceId, AIError aiError) {
CallerLogger.INSTANCE.d(TAG, "检测到错误:" + aiError.toString());
curTtsLevel = -1;
curTtsContent = "";
IMogoTTSCallback callBack = PadTTS.this.mSpeakVoiceMap.remove(utteranceId);
if (callBack != null) {
callBack.onSpeakError(utteranceId, aiError.getError());
@@ -755,6 +773,7 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
@Override
public void onCompletion(String utteranceId) {
curTtsLevel = -1;
curTtsContent = "";
CallerLogger.INSTANCE.d(TAG, "播放完成");
ttsNext();
IMogoTTSCallback callBack = PadTTS.this.mSpeakVoiceMap.remove(utteranceId);