Merge branch 'dev' into dev_1.1.2
This commit is contained in:
@@ -61,6 +61,7 @@ public class ParamsUtil {
|
||||
STATIC_PARAMS.put( ServerParam.DEVICE_ID, DeviceIdUtils.getDeviceId( AbsMogoApplication.getApp() ) );
|
||||
STATIC_PARAMS.put( ServerParam.IMEI, CommonUtils.getIMEI( AbsMogoApplication.getApp() ) );
|
||||
STATIC_PARAMS.put( ServerParam.IMSI, CommonUtils.getIMSI( AbsMogoApplication.getApp() ) );
|
||||
STATIC_PARAMS.put( ServerParam.FOTA_VERSION, Utils.getFotaVersion() );
|
||||
STATIC_PARAMS.put( ServerParam.END_POINT, ServerParam.END_POINT_CAR );
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ class ServerParam {
|
||||
public static final String SN = "sn";
|
||||
public static final String CHANNEL = "channel";
|
||||
|
||||
public static final String FOTA_VERSION = "fotaVersion";
|
||||
|
||||
public static final String USER_ID = "userId";
|
||||
public static final String FILE = "file";
|
||||
public static final String END_POINT = "endPoint";
|
||||
|
||||
@@ -16,6 +16,7 @@ public class MarkerCardResult extends BaseData {
|
||||
|
||||
private List<MarkerOnlineCar> onlineCar;
|
||||
private List<MarkerExploreWay> exploreWay;
|
||||
private long messageTime;
|
||||
|
||||
public List<MarkerCarChat> getCarChat() {
|
||||
return carChat;
|
||||
@@ -65,15 +66,11 @@ public class MarkerCardResult extends BaseData {
|
||||
this.dataType = dataType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MarkerCardResult{" +
|
||||
"dataType=" + dataType +
|
||||
", carChat=" + carChat +
|
||||
", exploreWay=" + exploreWay +
|
||||
", onlineCar=" + onlineCar +
|
||||
", shareMusic=" + shareMusic +
|
||||
", noveltyInfo=" + noveltyInfo +
|
||||
'}';
|
||||
public long getMessageTime() {
|
||||
return messageTime;
|
||||
}
|
||||
|
||||
public void setMessageTime(long messageTime) {
|
||||
this.messageTime = messageTime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,6 @@ import com.mogo.service.module.MogoAction;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.TipToast;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -64,8 +63,6 @@ import org.json.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import retrofit2.http.HEAD;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-03
|
||||
@@ -80,7 +77,6 @@ import retrofit2.http.HEAD;
|
||||
public class MogoServices implements IMogoMapListener,
|
||||
IMogoLocationListener,
|
||||
IMogoNaviListener,
|
||||
IMogoStatusChangedListener,
|
||||
IMogoIntentListener,
|
||||
IMogoAimlessModeListener,
|
||||
IMogoVoiceCmdCallBack,
|
||||
@@ -278,6 +274,68 @@ public class MogoServices implements IMogoMapListener,
|
||||
|
||||
private boolean mIsFirstAccOn = true;
|
||||
|
||||
private IMogoStatusChangedListener statusChangedListener = new StatusChangedAdapter(){
|
||||
@Override
|
||||
public void onUserInteracted( boolean userInteracted ) {
|
||||
if ( userInteracted ) {
|
||||
restartAutoRefreshAtTime( ServiceConst.DEFAULT_AUTO_REFRESH_WHEN_INTERRUPT );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSearchUIShow( boolean visible ) {
|
||||
if ( visible ) {
|
||||
// 搜索时,不在自动刷新打点策略
|
||||
stopAutoRefreshStrategy();
|
||||
} else {
|
||||
// 搜索后,打开打点策略
|
||||
if ( mAutoRefreshCallback != null ) {
|
||||
mAutoRefreshCallback.onSuccess( null );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMainPageResumeStatusChanged( boolean resume ) {
|
||||
if ( resume ) {
|
||||
registerInternalUnWakeupWords();
|
||||
if ( !mIsMainPageFirstResume ) {
|
||||
restartAutoRefreshAtTime( 2_000L );
|
||||
}
|
||||
mIsMainPageFirstResume = false;
|
||||
} else {
|
||||
unregisterInternalUnWakeupWords();
|
||||
stopAutoRefreshStrategy();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSeekHelpingStatusChanged( boolean isSeekingHelping ) {
|
||||
CarIconDisplayStrategy.getInstance().changeCarIconStatus( isSeekingHelping );
|
||||
notifySeekHelpingStatusChanged( isSeekingHelping );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccStatusChanged( boolean accOn ) {
|
||||
if ( accOn ) {
|
||||
if ( mIsFirstAccOn ) {
|
||||
mIsFirstAccOn = false;
|
||||
return;
|
||||
}
|
||||
initLocationServiceProcess( mContext );
|
||||
mADASController.showADAS();
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getSingletonLocationClient( mContext ).start();
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMarkerManager( mContext ).removeMarkers();
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
refreshStrategy();
|
||||
}, 3_000L );
|
||||
} else {
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getSingletonLocationClient( mContext ).stop();
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMarkerManager( mContext ).removeMarkers();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void init( Context context ) {
|
||||
mContext = context;
|
||||
|
||||
@@ -288,12 +346,11 @@ public class MogoServices implements IMogoMapListener,
|
||||
mUiController = mMogoMapService.getMapUIController();
|
||||
mNavi = mMogoMapService.getNavi( context );
|
||||
mStatusManager = MarkerServiceHandler.getMogoStatusManager();
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.USER_INTERACTED, this );
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.SEARCH_UI, this );
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.ADAS_UI, this );
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.MAIN_PAGE_RESUME, this );
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.SEEK_HELPING, this );
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.ACC_STATUS, this );
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.USER_INTERACTED, statusChangedListener );
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.SEARCH_UI, statusChangedListener );
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.MAIN_PAGE_RESUME, statusChangedListener );
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.SEEK_HELPING, statusChangedListener );
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.ACC_STATUS, statusChangedListener );
|
||||
mStatusManager.setAIAssistReady( TAG, AIAssist.getInstance( mContext ).hasFlush() );
|
||||
|
||||
registerMogoReceiver( context );
|
||||
@@ -370,6 +427,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
if ( msg.obj instanceof RefreshObject ) {
|
||||
RefreshObject ro = ( ( RefreshObject ) msg.obj );
|
||||
if ( ro.mLonLat == null ) {
|
||||
invokeAutoRefreshStrategy();
|
||||
Logger.w( TAG, "lonLat is null." );
|
||||
return;
|
||||
}
|
||||
@@ -690,74 +748,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
mThreadHandler.sendMessage( msg );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
|
||||
//Logger.d( TAG, "状态发生改变---descriptor---" + descriptor + "----isTrue---" + isTrue );
|
||||
switch ( descriptor ) {
|
||||
case USER_INTERACTED:
|
||||
if ( isTrue ) {
|
||||
restartAutoRefreshAtTime( ServiceConst.DEFAULT_AUTO_REFRESH_WHEN_INTERRUPT );
|
||||
}
|
||||
break;
|
||||
case SEARCH_UI:
|
||||
if ( isTrue ) {
|
||||
// 搜索时,不在自动刷新打点策略
|
||||
stopAutoRefreshStrategy();
|
||||
} else {
|
||||
// 搜索后,打开打点策略
|
||||
if ( mAutoRefreshCallback != null ) {
|
||||
mAutoRefreshCallback.onSuccess( null );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ADAS_UI:
|
||||
try {
|
||||
if ( isTrue ) {
|
||||
onAdasOn();
|
||||
} else {
|
||||
onAdasClosed();
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
case MAIN_PAGE_RESUME:
|
||||
if ( isTrue ) {
|
||||
registerInternalUnWakeupWords();
|
||||
if ( !mIsMainPageFirstResume ) {
|
||||
restartAutoRefreshAtTime( 2_000L );
|
||||
}
|
||||
mIsMainPageFirstResume = false;
|
||||
} else {
|
||||
unregisterInternalUnWakeupWords();
|
||||
stopAutoRefreshStrategy();
|
||||
}
|
||||
break;
|
||||
case SEEK_HELPING:
|
||||
CarIconDisplayStrategy.getInstance().changeCarIconStatus( isTrue );
|
||||
notifySeekHelpingStatusChanged( isTrue );
|
||||
break;
|
||||
case ACC_STATUS:
|
||||
if ( isTrue ) {
|
||||
if ( mIsFirstAccOn ) {
|
||||
mIsFirstAccOn = false;
|
||||
return;
|
||||
}
|
||||
initLocationServiceProcess( mContext );
|
||||
mADASController.showADAS();
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getSingletonLocationClient( mContext ).start();
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMarkerManager( mContext ).removeMarkers();
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
refreshStrategy();
|
||||
}, 3_000L );
|
||||
} else {
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getSingletonLocationClient( mContext ).stop();
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMarkerManager( mContext ).removeMarkers();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void notifySeekHelpingStatusChanged( boolean seekHelpingStatus ) {
|
||||
Intent intent = new Intent( "com.mogo.launcher.adas.app" );
|
||||
try {
|
||||
@@ -773,24 +763,11 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
}
|
||||
|
||||
private void onAdasOn() {
|
||||
// ADAS 时,不在自动刷新打点策略
|
||||
stopAutoRefreshStrategy();
|
||||
}
|
||||
|
||||
private void onAdasClosed() {
|
||||
refreshStrategy();
|
||||
// ADAS关闭后,打开打点策略
|
||||
if ( mAutoRefreshCallback != null ) {
|
||||
mAutoRefreshCallback.onSuccess( null );
|
||||
}
|
||||
}
|
||||
|
||||
public void restartAutoRefreshAtTime( long time ) {
|
||||
restartAutoRefreshAtTime( time, true );
|
||||
}
|
||||
|
||||
public void clearAllData(){
|
||||
public void clearAllData() {
|
||||
try {
|
||||
MarkerServiceHandler.getMapService().getMarkerManager( mContext ).removeMarkers();
|
||||
} catch ( Exception e ) {
|
||||
@@ -800,8 +777,8 @@ public class MogoServices implements IMogoMapListener,
|
||||
|
||||
private void restartAutoRefreshAtTime( long time, boolean stopOnlineCarRefresh ) {
|
||||
if ( time < 0 ) {
|
||||
Logger.w( TAG, "ignore refresh request case time < 0" );
|
||||
return;
|
||||
Logger.w( TAG, "refresh request case time < 0, set to 0 and go on." );
|
||||
time = 0;
|
||||
}
|
||||
stopAutoRefreshStrategy( stopOnlineCarRefresh );
|
||||
mRefreshRemainingTime = time;
|
||||
@@ -828,20 +805,22 @@ public class MogoServices implements IMogoMapListener,
|
||||
@Override
|
||||
public void onUpdateTraffic2( MogoTraffic traffic ) {
|
||||
|
||||
if ( traffic != null ) {
|
||||
|
||||
if ( mCurrentLimit == traffic.getSpeedLimit() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
mCurrentLimit = traffic.getSpeedLimit();
|
||||
|
||||
Logger.i( TAG, "speed = %d, desc = %s", traffic.getSpeedLimit(), traffic.getDesc() );
|
||||
// 发送当前限速到 adas
|
||||
Intent intent = new Intent( "com.mogo.launcher.adas" );
|
||||
intent.putExtra( "adas_speed_limit", traffic.getSpeedLimit() );
|
||||
mContext.sendBroadcast( intent );
|
||||
if ( traffic == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( mCurrentLimit == traffic.getSpeedLimit() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
mCurrentLimit = traffic.getSpeedLimit();
|
||||
|
||||
Logger.i( TAG, "speed = %d, desc = %s", traffic.getSpeedLimit(), traffic.getDesc() );
|
||||
// 发送当前限速到 adas
|
||||
Intent intent = new Intent( "com.mogo.launcher.adas" );
|
||||
intent.putExtra( "adas_speed_limit", traffic.getSpeedLimit() );
|
||||
mContext.sendBroadcast( intent );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.mogo.module.service;
|
||||
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/8/6
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
abstract class StatusChangedAdapter implements IMogoStatusChangedListener {
|
||||
|
||||
@Override
|
||||
public void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
|
||||
switch ( descriptor ) {
|
||||
case USER_INTERACTED:
|
||||
onUserInteracted( isTrue );
|
||||
break;
|
||||
case SEARCH_UI:
|
||||
onSearchUIShow( isTrue );
|
||||
break;
|
||||
case MAIN_PAGE_RESUME:
|
||||
onMainPageResumeStatusChanged( isTrue );
|
||||
break;
|
||||
case SEEK_HELPING:
|
||||
onSeekHelpingStatusChanged( isTrue );
|
||||
break;
|
||||
case ACC_STATUS:
|
||||
onAccStatusChanged( isTrue );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void onUserInteracted( boolean userInteracted );
|
||||
|
||||
public abstract void onSearchUIShow( boolean visible );
|
||||
|
||||
public abstract void onMainPageResumeStatusChanged( boolean resume );
|
||||
|
||||
public abstract void onSeekHelpingStatusChanged( boolean isSeekingHelping );
|
||||
|
||||
public abstract void onAccStatusChanged( boolean accOn );
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.mogo.module.v2x;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.module.common.entity.V2XRoadEventEntity;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
@@ -53,6 +54,7 @@ public class V2XStatusManager {
|
||||
if (mLocation == null) {
|
||||
mLocation = new MogoLocation();
|
||||
}
|
||||
Logger.d(V2XConst.MODULE_NAME, "当前车辆位置:" + mLocation.toString());
|
||||
return mLocation;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.mogo.module.service.Utils;
|
||||
import com.mogo.module.v2x.V2XConst;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.alarm.V2XAlarmServer;
|
||||
import com.mogo.module.v2x.utils.TimeConstants;
|
||||
import com.mogo.module.v2x.utils.TimeUtils;
|
||||
import com.mogo.module.v2x.utils.V2XUtils;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
@@ -42,38 +43,48 @@ public class V2XMessageListener_401012 implements IMogoOnMessageListener<MarkerC
|
||||
Logger.d(MODULE_NAME, "V2XMessageListener_401012==V2X服务端下发:\n"
|
||||
+ GsonUtil.jsonFromObject(response));
|
||||
try {
|
||||
if (response.getExploreWay() != null && response.getExploreWay().size() > 0) {
|
||||
MarkerExploreWay markerExploreWay = response.getExploreWay().get(0);
|
||||
MarkerLocation markerLocation = markerExploreWay.getLocation();
|
||||
// 记录道路事件
|
||||
V2XRoadEventEntity v2XRoadEventEntity = new V2XRoadEventEntity();
|
||||
v2XRoadEventEntity.setLocation(markerLocation);
|
||||
// 探路目前只有上报拥堵
|
||||
v2XRoadEventEntity.setPoiType(markerExploreWay.getPoiType());
|
||||
// 当前车辆数据
|
||||
MogoLocation currentLocation = V2XServiceManager.getV2XStatusManager().getLocation();
|
||||
float calculateDistance = Utils.calculateLineDistance(
|
||||
new MogoLatLng(markerLocation.getLat(), markerLocation.getLon()),
|
||||
new MogoLatLng(currentLocation.getLatitude(), currentLocation.getLongitude())
|
||||
);
|
||||
v2XRoadEventEntity.setDistance(calculateDistance);
|
||||
v2XRoadEventEntity.setNoveltyInfo(markerExploreWay);
|
||||
v2XRoadEventEntity.setExpireTime(20000);
|
||||
long timeSpan = TimeUtils.getTimeSpan(TimeUtils.getNowMills(), response.getMessageTime(), TimeConstants.MIN);
|
||||
// 三分钟以内的消息才会提示用户
|
||||
if (timeSpan <= 3) {
|
||||
if (response.getExploreWay() != null && response.getExploreWay().size() > 0) {
|
||||
MarkerExploreWay markerExploreWay = response.getExploreWay().get(0);
|
||||
MarkerLocation markerLocation = markerExploreWay.getLocation();
|
||||
// 记录道路事件
|
||||
V2XRoadEventEntity v2XRoadEventEntity = new V2XRoadEventEntity();
|
||||
v2XRoadEventEntity.setLocation(markerLocation);
|
||||
// 探路目前只有上报拥堵
|
||||
v2XRoadEventEntity.setPoiType(markerExploreWay.getPoiType());
|
||||
// 当前车辆数据
|
||||
MogoLocation currentLocation = V2XServiceManager.getV2XStatusManager().getLocation();
|
||||
float calculateDistance;
|
||||
if (currentLocation.getLatitude() > 0 || currentLocation.getLongitude() > 0) {
|
||||
calculateDistance = Utils.calculateLineDistance(
|
||||
new MogoLatLng(markerLocation.getLat(), markerLocation.getLon()),
|
||||
new MogoLatLng(currentLocation.getLatitude(), currentLocation.getLongitude())
|
||||
);
|
||||
markerExploreWay.setDistance(calculateDistance);
|
||||
}
|
||||
v2XRoadEventEntity.setDistance(markerExploreWay.getDistance());
|
||||
v2XRoadEventEntity.setNoveltyInfo(markerExploreWay);
|
||||
v2XRoadEventEntity.setExpireTime(20000);
|
||||
|
||||
// 记录播报过的道路事件
|
||||
V2XAlarmServer.mAlertRoadEventList.put(v2XRoadEventEntity, TimeUtils.getNowString());
|
||||
// 记录播报过的道路事件
|
||||
V2XAlarmServer.mAlertRoadEventList.put(v2XRoadEventEntity, TimeUtils.getNowString());
|
||||
|
||||
V2XMessageEntity<V2XRoadEventEntity> v2xMessageEntity = new V2XMessageEntity<>();
|
||||
// 控制类型
|
||||
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING);
|
||||
// 设置数据
|
||||
v2xMessageEntity.setContent(v2XRoadEventEntity);
|
||||
// 控制展示状态
|
||||
v2xMessageEntity.setShowState(true);
|
||||
V2XMessageEntity<V2XRoadEventEntity> v2xMessageEntity = new V2XMessageEntity<>();
|
||||
// 控制类型
|
||||
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING);
|
||||
// 设置数据
|
||||
v2xMessageEntity.setContent(v2XRoadEventEntity);
|
||||
// 控制展示状态
|
||||
v2xMessageEntity.setShowState(true);
|
||||
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2xMessageEntity);
|
||||
LocalBroadcastManager.getInstance(V2XUtils.getApp()).sendBroadcast(intent);
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2xMessageEntity);
|
||||
LocalBroadcastManager.getInstance(V2XUtils.getApp()).sendBroadcast(intent);
|
||||
}
|
||||
} else {
|
||||
Logger.e(MODULE_NAME, "V2XMessageListener_401012==V2X服务端下发:消息已过期,大于3分钟了不进行消费");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Reference in New Issue
Block a user