opt
This commit is contained in:
@@ -4,7 +4,6 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.location.Location;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.os.Handler;
|
||||
@@ -15,12 +14,10 @@ import android.view.MotionEvent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.network.ParamsProvider;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.commons.storage.SpStorage;
|
||||
import com.mogo.commons.utils.MortonCode;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
|
||||
import com.mogo.map.IDestroyable;
|
||||
@@ -28,27 +25,23 @@ import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.navi.IMogoAimlessModeListener;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.map.navi.IMogoNavi;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.map.navi.MogoCongestionInfo;
|
||||
import com.mogo.map.navi.MogoTraffic;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.MogoModule;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.common.entity.CloudLocationInfo;
|
||||
import com.mogo.module.common.entity.MarkerResponse;
|
||||
import com.mogo.module.common.map.MapCenterPointStrategy;
|
||||
import com.mogo.module.common.map.Scene;
|
||||
import com.mogo.module.common.utils.CoordinateSystemTransformationUtil;
|
||||
import com.mogo.module.service.autopilot.AutoPilotRemoteController;
|
||||
import com.mogo.module.service.handler.MainLooperHandler;
|
||||
import com.mogo.module.service.handler.RefreshWorkThreadHandler;
|
||||
import com.mogo.module.service.intent.IntentHandlerFactory;
|
||||
import com.mogo.module.service.launchercard.LauncherCardRefresher;
|
||||
import com.mogo.module.service.location.MogoRTKLocation;
|
||||
import com.mogo.module.service.marker.MapMarkerManager;
|
||||
import com.mogo.module.service.network.RefreshCallback;
|
||||
import com.mogo.module.service.network.RefreshModel;
|
||||
@@ -61,14 +54,8 @@ import com.mogo.module.service.refresh.CustomRefreshStrategy;
|
||||
import com.mogo.module.service.refresh.RefreshObject;
|
||||
import com.mogo.module.service.strategy.CarIconDisplayStrategy;
|
||||
import com.mogo.module.service.ttsConfig.TtsConfigModleData;
|
||||
import com.mogo.module.service.utils.SimpleLocationCorrectStrategy;
|
||||
import com.mogo.module.service.vrmode.VrModeController;
|
||||
import com.mogo.module.service.websocket.LocationResult;
|
||||
import com.mogo.module.service.websocket.OnePerSecondSendContent;
|
||||
import com.mogo.module.service.uploadintime.SnapshotUploadInTime;
|
||||
import com.mogo.service.adas.IMogoADASController;
|
||||
import com.mogo.service.adas.entity.ADASRecognizedResult;
|
||||
import com.mogo.service.connection.IMogoOnWebSocketMessageListener;
|
||||
import com.mogo.service.connection.WebSocketMsgType;
|
||||
import com.mogo.service.fragmentmanager.FragmentStackTransactionListener;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
@@ -81,20 +68,11 @@ import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.NetworkUtils;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.RequestOptions;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
import com.zhidao.carchattingprovider.CallChattingProviderConstant;
|
||||
import com.zhidao.carchattingprovider.ICallChatResponse;
|
||||
import com.zhidao.carchattingprovider.ICallProviderResponse;
|
||||
import com.zhidao.carchattingprovider.ICarsChattingProvider;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -123,7 +101,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
IDestroyable {
|
||||
|
||||
private boolean mInternalUnWakeupRegisterStatus = false;
|
||||
private ICarsChattingProvider carsChattingProvider;
|
||||
|
||||
private Location mLastCarLocation;
|
||||
|
||||
private MogoServices() {
|
||||
@@ -185,7 +163,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
private IMogoNavi mNavi;
|
||||
private IMogoRegisterCenter mRegisterCenter;
|
||||
|
||||
private ICallProviderResponse mCallProviderResponse;
|
||||
|
||||
/**
|
||||
* 地图视图初始化
|
||||
@@ -199,41 +176,42 @@ public class MogoServices implements IMogoMapListener,
|
||||
*/
|
||||
private boolean mLoopRequest = false;
|
||||
|
||||
private Handler mHandler = new Handler( Looper.getMainLooper() ) {
|
||||
private Handler mHandler = new MainLooperHandler( Looper.getMainLooper() ) {
|
||||
|
||||
@Override
|
||||
public void handleMessage( @NonNull Message msg ) {
|
||||
super.handleMessage( msg );
|
||||
switch ( msg.what ) {
|
||||
case ServiceConst.MSG_TYPE_REFRESH_DECREASE:
|
||||
if ( mStatusManager.isSearchUIShow() || mStatusManager.isV2XShow() ) {
|
||||
invokeAutoRefreshStrategy();
|
||||
return;
|
||||
}
|
||||
mRefreshRemainingTime -= ServiceConst.DECREASE_INTERVAL;
|
||||
if ( mRefreshRemainingTime <= 0 ) {
|
||||
Logger.d( TAG, "move to center and refresh data." );
|
||||
invokeAutoRefresh();
|
||||
} else {
|
||||
mHandler.sendEmptyMessageDelayed( msg.what, ServiceConst.DECREASE_INTERVAL );
|
||||
}
|
||||
break;
|
||||
case ServiceConst.MSG_LOOP_REQUEST:
|
||||
if ( mStatusManager.isSearchUIShow() || mStatusManager.isV2XShow() ) {
|
||||
return;
|
||||
}
|
||||
if ( mLoopRequest ) {
|
||||
Logger.d( TAG, "补偿刷新触发" );
|
||||
invokeAutoRefresh();
|
||||
}
|
||||
break;
|
||||
case ServiceConst.MSG_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH:
|
||||
handleCalculationNotHomeCompanyDistanceForPush( msg.arg1 );
|
||||
break;
|
||||
protected void handleRefreshDecrease( Message msg ) {
|
||||
if ( mStatusManager.isSearchUIShow() || mStatusManager.isV2XShow() ) {
|
||||
invokeAutoRefreshStrategy();
|
||||
return;
|
||||
}
|
||||
mRefreshRemainingTime -= ServiceConst.DECREASE_INTERVAL;
|
||||
if ( mRefreshRemainingTime <= 0 ) {
|
||||
Logger.d( TAG, "move to center and refresh data." );
|
||||
invokeAutoRefresh();
|
||||
} else {
|
||||
mHandler.sendEmptyMessageDelayed( msg.what, ServiceConst.DECREASE_INTERVAL );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleLoopRequestMessage( Message msg ) {
|
||||
if ( mStatusManager.isSearchUIShow() || mStatusManager.isV2XShow() ) {
|
||||
return;
|
||||
}
|
||||
if ( mLoopRequest ) {
|
||||
Logger.d( TAG, "补偿刷新触发" );
|
||||
invokeAutoRefresh();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public RefreshModel getRefreshModel() {
|
||||
if ( mRefreshModel == null ) {
|
||||
mRefreshModel = new RefreshModel( mContext );
|
||||
}
|
||||
return mRefreshModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动刷新:锁车、缩放比例:16、半径 2KM
|
||||
*/
|
||||
@@ -243,10 +221,10 @@ public class MogoServices implements IMogoMapListener,
|
||||
mUiController.recoverLockMode();
|
||||
return;
|
||||
}
|
||||
mStatusManager.setUserInteractionStatus(ServiceConst.TYPE, true, false);
|
||||
mUiController.changeZoom(ServiceConst.DEFAULT_LOCK_CAR_ZOOM_LEVEL);
|
||||
mStatusManager.setUserInteractionStatus( ServiceConst.TYPE, true, false );
|
||||
mUiController.changeZoom( ServiceConst.DEFAULT_LOCK_CAR_ZOOM_LEVEL );
|
||||
// mUiController.setLockZoom( ServiceConst.DEFAULT_LOCK_CAR_ZOOM_LEVEL );
|
||||
mStatusManager.setUserInteractionStatus(TAG, true, false);
|
||||
mStatusManager.setUserInteractionStatus( TAG, true, false );
|
||||
mUiController.recoverLockMode();
|
||||
notifyRefreshData( mLastAutoRefreshLocation, ServiceConst.DEFAULT_AUTO_REFRESH_DATA_RADIUS, mAutoRefreshCallback );
|
||||
}
|
||||
@@ -314,17 +292,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
*/
|
||||
private int mCurrentLimit = -1;
|
||||
|
||||
private boolean mIsMainPageFirstResume = true;
|
||||
|
||||
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 ) {
|
||||
@@ -338,113 +306,24 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMainPageResumeStatusChanged( boolean resume ) {
|
||||
if ( resume ) {
|
||||
registerInternalUnWakeupWords();
|
||||
if ( !mIsMainPageFirstResume ) {
|
||||
restartAutoRefreshAtTime( 2_000L );
|
||||
}
|
||||
mIsMainPageFirstResume = false;
|
||||
LauncherCardRefresher.getInstance(mContext).stop();
|
||||
playAppTts();
|
||||
} else {
|
||||
unregisterInternalUnWakeupWords();
|
||||
stopAutoRefreshStrategy();
|
||||
}
|
||||
VrModeController.getInstance().onMainPageResumeStatusChanged( resume );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMainPageIsBackgroundStatusChanged(boolean isBackground) {
|
||||
if (isBackground) {
|
||||
closeAllPanel();
|
||||
}
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTopViewStatusChanged(boolean visible) {
|
||||
if (visible) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
MapMarkerManager.getInstance().onCloseCurrentSelectedMarker();
|
||||
} catch (Exception e) {
|
||||
Logger.e(TAG, e, "onTopViewStatusChanged");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVrModeChanged( boolean isVrMode ) {
|
||||
VrModeController.getInstance().onVrModeChanged( isVrMode );
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 每次onResume的时候 在独立app里面播放系统配置的tts语音
|
||||
*/
|
||||
private void playAppTts() {
|
||||
if (DebugConfig.isLauncher()) {
|
||||
public void playAppTts() {
|
||||
if ( DebugConfig.isLauncher() ) {
|
||||
return;
|
||||
}
|
||||
mTtsModle.playTts();
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭所有模块的控制面板
|
||||
*/
|
||||
private void closeAllPanel() {
|
||||
|
||||
if ( mCallProviderResponse == null ) {
|
||||
mCallProviderResponse = new ICallChatResponse() {
|
||||
@Override
|
||||
public void hideUserWindowError(@NotNull String errorMsg) {
|
||||
}
|
||||
};
|
||||
}
|
||||
MogoApisHandler.getInstance().getApis().getShareManager().dismissShareDialog();
|
||||
MogoApisHandler.getInstance().getApis().getOnlineCarPanelApi().hidePanel();
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().setSettingStatus(false);
|
||||
MogoApisHandler.getInstance().getApis().getEventPanelManager().hidePanel();
|
||||
if ( carsChattingProvider == null ) {
|
||||
carsChattingProvider = (ICarsChattingProvider) ARouter.getInstance().build(CallChattingProviderConstant.CAR_CALL_PROVIDER).navigation();
|
||||
}
|
||||
if ( carsChattingProvider != null ) {
|
||||
carsChattingProvider.hideUserWindow(TAG, mContext, mCallProviderResponse);
|
||||
}
|
||||
}
|
||||
|
||||
public void preInit( Context context ) {
|
||||
mContext = context;
|
||||
|
||||
mRefreshModel = new RefreshModel( context );
|
||||
mTtsModle = new TtsConfigModleData();
|
||||
mMogoMapService = MarkerServiceHandler.getMapService();
|
||||
mUiController = mMogoMapService.getMapUIController();
|
||||
mNavi = mMogoMapService.getNavi( context );
|
||||
@@ -456,6 +335,8 @@ public class MogoServices implements IMogoMapListener,
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.SEEK_HELPING, statusChangedListener );
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.ACC_STATUS, statusChangedListener );
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.VR_MODE, statusChangedListener );
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.TOP_VIEW, statusChangedListener );
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.MAIN_PAGE_IS_BACKGROUND, statusChangedListener );
|
||||
mStatusManager.setAIAssistReady( TAG, AIAssist.getInstance( mContext ).hasFlush() );
|
||||
}
|
||||
|
||||
@@ -515,53 +396,11 @@ public class MogoServices implements IMogoMapListener,
|
||||
Intent intent = new Intent( "com.freedom.ser.ACTION" );
|
||||
intent.addFlags( Intent.FLAG_INCLUDE_STOPPED_PACKAGES );
|
||||
mContext.sendBroadcast( intent );
|
||||
MogoRTKLocation.getInstance().registerRTKLocationListener( cloudLocationInfos -> {
|
||||
Logger.i( TAG, "cloudLocationInfos size : " + cloudLocationInfos.size() );
|
||||
startSendCarLocationAndAdasRecognizedResult2Server( cloudLocationInfos );
|
||||
} );
|
||||
|
||||
// SimpleLocationCorrectStrategy.getInstance().setRecordLocationListener((history, correct,valid,err) -> {
|
||||
// // todo 打点
|
||||
// Logger.d("SimpleCorrect","correct: "+correct);
|
||||
// Logger.d("SimpleCorrect","valid: "+valid);
|
||||
// Logger.d("SimpleCorrect","err: "+err);
|
||||
// ArrayList<MogoMarkerOptions> optionList = new ArrayList<>();
|
||||
//// for (CloudLocationInfo h : history) {
|
||||
//// MogoMarkerOptions options = new MogoMarkerOptions();
|
||||
//// options.position(LocationParseUtil.cloudLocationToMogoLatLng(h));
|
||||
//// options.icon(BitmapFactory.decodeResource(context.getResources(),
|
||||
//// R.drawable.bg_map_marker_blue));
|
||||
//// optionList.add(options);
|
||||
//// }
|
||||
//
|
||||
// for (CloudLocationInfo v : valid) {
|
||||
// MogoMarkerOptions options = new MogoMarkerOptions();
|
||||
// options.position(LocationParseUtil.cloudLocationToMogoLatLng(v));
|
||||
// options.icon(BitmapFactory.decodeResource(context.getResources(),
|
||||
// R.drawable.bg_map_marker_oragne));
|
||||
// optionList.add(options);
|
||||
// }
|
||||
//
|
||||
// for (CloudLocationInfo c : correct) {
|
||||
// MogoMarkerOptions options = new MogoMarkerOptions();
|
||||
// options.position(LocationParseUtil.cloudLocationToMogoLatLng(c));
|
||||
// options.icon(BitmapFactory.decodeResource(context.getResources(),
|
||||
// R.drawable.bg_map_marker_green));
|
||||
// optionList.add(options);
|
||||
// }
|
||||
//
|
||||
// for (CloudLocationInfo e : err) {
|
||||
// MogoMarkerOptions options = new MogoMarkerOptions();
|
||||
// options.position(LocationParseUtil.cloudLocationToMogoLatLng(e));
|
||||
// options.icon(BitmapFactory.decodeResource(context.getResources(),
|
||||
// R.drawable.bg_map_marker_red));
|
||||
// optionList.add(options);
|
||||
// }
|
||||
// MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(context).addMarkers("MogoServices", optionList, false);
|
||||
// });
|
||||
SnapshotUploadInTime.getInstance().start( mContext );
|
||||
}
|
||||
|
||||
private void initLocationServiceProcess( Context context ) {
|
||||
public void initLocationServiceProcess( Context context ) {
|
||||
try {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction( "com.zhidao.locationinfo.service.uploaddataservice" );
|
||||
@@ -574,125 +413,34 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
|
||||
|
||||
private List< List< Double > > coors = new ArrayList<>();
|
||||
private CloudLocationInfo mLastInfo;
|
||||
private void startSendCarLocationAndAdasRecognizedResult2Server( List< CloudLocationInfo > cloudLocationInfo ) {
|
||||
// Location lastCarLocation = mLastCarLocation;
|
||||
CloudLocationInfo lastInfo = null;
|
||||
// 如果数组内容不为空,就用数组最后一个值
|
||||
if ( cloudLocationInfo != null && !cloudLocationInfo.isEmpty() ) {
|
||||
lastInfo = cloudLocationInfo.get( cloudLocationInfo.size() - 1 );
|
||||
mLastInfo = lastInfo;
|
||||
}
|
||||
if ( lastInfo == null ) {
|
||||
lastInfo = mLastInfo;
|
||||
}
|
||||
LocationResult locationResult = null;
|
||||
if ( lastInfo != null ) {
|
||||
// 定位点预测纠偏
|
||||
lastInfo = SimpleLocationCorrectStrategy.getInstance().correct( lastInfo );
|
||||
locationResult = new LocationResult();
|
||||
if ( lastInfo != null ) {
|
||||
// List<Double> coor = new ArrayList<>( );
|
||||
// double pos[] = CoordinateUtils.transformFromWGSToGCJ( lastInfo.getLat(), lastInfo.getLon() );
|
||||
// coor.add( pos[1]);
|
||||
// coor.add(pos[0] );
|
||||
// coors.add( coor );
|
||||
// if ( coors.size()>50 ) {
|
||||
// Logger.d( "Print-coor", GsonUtil.jsonFromObject( coors ) );
|
||||
// coors.clear();
|
||||
// }
|
||||
// moveMarker( lastInfo.getLat(), lastInfo.getLon() );
|
||||
locationResult.lastCoordinate = lastInfo;
|
||||
locationResult.mortonCode = MortonCode.wrapEncodeMorton( lastInfo.getLon(), lastInfo.getLat() );
|
||||
}
|
||||
locationResult.coordinates = new ArrayList<>();
|
||||
locationResult.sn = com.mogo.commons.network.Utils.getSn();
|
||||
if ( cloudLocationInfo == null ) {
|
||||
locationResult.coordinates.addAll( new ArrayList<>() );
|
||||
} else {
|
||||
locationResult.coordinates.addAll( cloudLocationInfo );
|
||||
}
|
||||
}
|
||||
List< ADASRecognizedResult > recognizedResults = MarkerServiceHandler.getADASController().getLastADASRecognizedResult();
|
||||
OnePerSecondSendContent content = new OnePerSecondSendContent();
|
||||
content.self = locationResult;
|
||||
content.adas = recognizedResults;
|
||||
|
||||
Logger.d( TAG, GsonUtil.jsonFromObject( content ) );
|
||||
MarkerServiceHandler.getApis().getWebSocketManagerApi( mContext ).sendMsg( content, new IMogoOnWebSocketMessageListener() {
|
||||
@Override
|
||||
public WebSocketMsgType getDownLinkType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebSocketMsgType getUpLinkType() {
|
||||
return WebSocketMsgType.MSG_TYPE_UPLINK_CAR_DATA;
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private IMogoMarker marker = null;
|
||||
|
||||
private void moveMarker( double lat, double lon ) {
|
||||
List< Double > coor = new ArrayList<>();
|
||||
double pos[] = CoordinateSystemTransformationUtil.transformWgsToGcj( lat, lon );
|
||||
coor.add( pos[1] );
|
||||
coor.add( pos[0] );
|
||||
coors.add( coor );
|
||||
if ( coors.size() > 50 ) {
|
||||
Logger.d( "Print-coor", GsonUtil.jsonFromObject( coors ) );
|
||||
coors.clear();
|
||||
}
|
||||
if ( marker == null ) {
|
||||
marker = MogoApisHandler.getInstance().getApis()
|
||||
.getMapServiceApi().getMarkerManager( mContext )
|
||||
.addMarker( TAG, new MogoMarkerOptions()
|
||||
.latitude( lat )
|
||||
.longitude( lon )
|
||||
.gps( true )
|
||||
.icon( BitmapFactory.decodeResource( mContext.getResources(), R.drawable.bg_map_marker_blue ) ) )
|
||||
;
|
||||
}
|
||||
if ( marker != null ) {
|
||||
marker.setPosition( lat, lon );
|
||||
}
|
||||
}
|
||||
|
||||
private void initWorkThread() {
|
||||
mThreadHandler = new Handler( WorkThreadHandler.getInstance().getLooper() ) {
|
||||
mThreadHandler = new RefreshWorkThreadHandler( WorkThreadHandler.getInstance().getLooper() ) {
|
||||
@Override
|
||||
public void handleMessage( Message msg ) {
|
||||
super.handleMessage( msg );
|
||||
Logger.d( TAG, "current thread: %s, msg = %s", Thread.currentThread(), msg.what );
|
||||
if ( msg.what == ServiceConst.MSG_MAP_CHANGED ) {
|
||||
if ( msg.obj instanceof RefreshObject ) {
|
||||
RefreshObject ro = ( ( RefreshObject ) msg.obj );
|
||||
if ( invokeRefreshWhenTranslationByUser( ro.mLonLat ) ) {
|
||||
notifyRefreshData( ro.mLonLat, ro.mRadius, ro.mCallback );
|
||||
mLastCustomRefreshCenterLocation = ro.mLonLat;
|
||||
}
|
||||
protected void handleMapChangedMessage( Message msg ) {
|
||||
if ( msg.obj instanceof RefreshObject ) {
|
||||
RefreshObject ro = ( ( RefreshObject ) msg.obj );
|
||||
if ( invokeRefreshWhenTranslationByUser( ro.mLonLat ) ) {
|
||||
notifyRefreshData( ro.mLonLat, ro.mRadius, ro.mCallback );
|
||||
mLastCustomRefreshCenterLocation = ro.mLonLat;
|
||||
}
|
||||
} else if ( msg.what == ServiceConst.MSG_REQUEST_DATA ) {
|
||||
if ( msg.obj instanceof RefreshObject ) {
|
||||
RefreshObject ro = ( ( RefreshObject ) msg.obj );
|
||||
if ( ro.mLonLat == null ) {
|
||||
invokeAutoRefreshStrategy();
|
||||
Logger.w( TAG, "lonLat is null." );
|
||||
return;
|
||||
}
|
||||
mRefreshModel.refreshExplorerWayData( ro.mLonLat, ro.mRadius, ro.mAmount, ro.mCallback );
|
||||
// MapMarkerManager.getInstance().getOnlineCarDataByAutoRefreshStrategy( ro.mLonLat );
|
||||
}
|
||||
}
|
||||
|
||||
Logger.i(TAG, "刷新半径 = %s, 点 = %s, zoomLevel = %s, amount = %s", ro.mRadius, ro.mLonLat, mLastZoomLevel, ro.mAmount);
|
||||
}
|
||||
} else if ( msg.what == ServiceConst.MSG_LOCK_CAR ) {
|
||||
if ( mStatusManager.isSearchUIShow() ) {
|
||||
@Override
|
||||
protected void handleRequestDataMessage( Message msg ) {
|
||||
if ( msg.obj instanceof RefreshObject ) {
|
||||
RefreshObject ro = ( ( RefreshObject ) msg.obj );
|
||||
if ( ro.mLonLat == null ) {
|
||||
invokeAutoRefreshStrategy();
|
||||
Logger.w( TAG, "lonLat is null." );
|
||||
return;
|
||||
}
|
||||
mStatusManager.setUserInteractionStatus( TAG, true, false );
|
||||
mUiController.recoverLockMode();
|
||||
mRefreshModel.refreshExplorerWayData( ro.mLonLat, ro.mRadius, ro.mAmount, ro.mCallback );
|
||||
if ( !DebugConfig.isNeedUploadCoordinatesDurationInTime() ) {
|
||||
MapMarkerManager.getInstance().getOnlineCarDataByAutoRefreshStrategy( ro.mLonLat );
|
||||
}
|
||||
|
||||
Logger.i( TAG, "刷新半径 = %s, 点 = %s, zoomLevel = %s, amount = %s", ro.mRadius, ro.mLonLat, mLastZoomLevel, ro.mAmount );
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -730,9 +478,9 @@ public class MogoServices implements IMogoMapListener,
|
||||
filter.addAction( MogoReceiver.ACTION_TXZ_BLOCK_SEARCH );
|
||||
filter.addAction( ConnectivityManager.CONNECTIVITY_ACTION );
|
||||
try {
|
||||
context.getApplicationContext().registerReceiver(mAIAssistReceiver, filter);
|
||||
} catch (Exception e) {
|
||||
Logger.e(TAG, e, "error. ");
|
||||
context.getApplicationContext().registerReceiver( mAIAssistReceiver, filter );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error. " );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -793,22 +541,22 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
}
|
||||
|
||||
private void stopAutoRefreshStrategy() {
|
||||
public void stopAutoRefreshStrategy() {
|
||||
stopAutoRefreshStrategy( true );
|
||||
}
|
||||
|
||||
private void stopAutoRefreshStrategy(boolean stopOnlineCarRefresh) {
|
||||
mHandler.removeMessages(ServiceConst.MSG_TYPE_REFRESH_DECREASE);
|
||||
if (stopOnlineCarRefresh) {
|
||||
private void stopAutoRefreshStrategy( boolean stopOnlineCarRefresh ) {
|
||||
mHandler.removeMessages( ServiceConst.MSG_TYPE_REFRESH_DECREASE );
|
||||
if ( stopOnlineCarRefresh ) {
|
||||
MapMarkerManager.getInstance().stopAutoRefresh();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLockMap(boolean isLock) {
|
||||
mThreadHandler.removeMessages(ServiceConst.MSG_LOCK_CAR);
|
||||
if (!isLock) {
|
||||
mThreadHandler.sendEmptyMessageDelayed(ServiceConst.MSG_LOCK_CAR, ServiceConst.DEFAULT_AUTO_REFRESH_WHEN_INTERRUPT);
|
||||
public void onLockMap( boolean isLock ) {
|
||||
mThreadHandler.removeMessages( ServiceConst.MSG_LOCK_CAR );
|
||||
if ( !isLock ) {
|
||||
mThreadHandler.sendEmptyMessageDelayed( ServiceConst.MSG_LOCK_CAR, ServiceConst.DEFAULT_AUTO_REFRESH_WHEN_INTERRUPT );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -859,8 +607,8 @@ public class MogoServices implements IMogoMapListener,
|
||||
// 手动平移
|
||||
Message msg = Message.obtain();
|
||||
msg.what = ServiceConst.MSG_MAP_CHANGED;
|
||||
msg.obj = new RefreshObject(mCustomRefreshCallback, getQueryRadius(), latLng, 0);
|
||||
mThreadHandler.sendMessage(msg);
|
||||
msg.obj = new RefreshObject( mCustomRefreshCallback, getQueryRadius(), latLng, 0 );
|
||||
mThreadHandler.sendMessage( msg );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -893,30 +641,30 @@ public class MogoServices implements IMogoMapListener,
|
||||
if ( factor == 0.0f ) {
|
||||
return false;
|
||||
}
|
||||
float distance = Utils.calculateLineDistance(latLng, mLastCustomRefreshCenterLocation);
|
||||
return distance > (factor / 2);
|
||||
} catch (Exception e) {
|
||||
Logger.e(TAG, e, "warming. ");
|
||||
float distance = Utils.calculateLineDistance( latLng, mLastCustomRefreshCenterLocation );
|
||||
return distance > ( factor / 2 );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "warming. " );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(MogoLocation location) {
|
||||
public void onLocationChanged( MogoLocation location ) {
|
||||
|
||||
if (!DebugConfig.isMapBased()) {
|
||||
if ( !DebugConfig.isMapBased() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mStatusManager.isMainPageLaunched()) {
|
||||
if ( !mStatusManager.isMainPageLaunched() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mStatusManager.isMainPageOnResume()) {
|
||||
if ( !mStatusManager.isMainPageOnResume() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mStatusManager.isV2XShow()) {
|
||||
if ( mStatusManager.isV2XShow() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -977,21 +725,21 @@ public class MogoServices implements IMogoMapListener,
|
||||
/**
|
||||
* 刷新数据
|
||||
*/
|
||||
private void notifyRefreshData(MogoLatLng latLng, int radius, RefreshCallback callback) {
|
||||
private void notifyRefreshData( MogoLatLng latLng, int radius, RefreshCallback callback ) {
|
||||
|
||||
if (!DebugConfig.isMapBased()) {
|
||||
if ( !DebugConfig.isMapBased() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mStatusManager.isMainPageLaunched()) {
|
||||
if ( !mStatusManager.isMainPageLaunched() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mStatusManager.isMainPageOnResume()) {
|
||||
if ( !mStatusManager.isMainPageOnResume() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mStatusManager.isSearchUIShow()) {
|
||||
if ( mStatusManager.isSearchUIShow() ) {
|
||||
return;
|
||||
}
|
||||
int amount = 20;
|
||||
@@ -1004,21 +752,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
}
|
||||
|
||||
private void notifySeekHelpingStatusChanged( boolean seekHelpingStatus ) {
|
||||
Intent intent = new Intent( "com.mogo.launcher.adas.app" );
|
||||
try {
|
||||
JSONObject data = new JSONObject();
|
||||
data.put( "object", "辅助驾驶" );
|
||||
data.put( "action", seekHelpingStatus ? "2" : "1" );
|
||||
data.put( "des", "自身故障报警" );
|
||||
data.put( "v2x_warning_type", "20007" );// 后台返回
|
||||
intent.putExtra( "data", data.toString() );
|
||||
mContext.sendBroadcast( intent );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
}
|
||||
|
||||
public void restartAutoRefreshAtTime( long time ) {
|
||||
restartAutoRefreshAtTime( time, true );
|
||||
}
|
||||
@@ -1031,26 +764,26 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
}
|
||||
|
||||
private void restartAutoRefreshAtTime(long time, boolean stopOnlineCarRefresh) {
|
||||
if (time < 0) {
|
||||
Logger.w(TAG, "refresh request case time < 0, set to 0 and go on.");
|
||||
private void restartAutoRefreshAtTime( long time, boolean stopOnlineCarRefresh ) {
|
||||
if ( time < 0 ) {
|
||||
Logger.w( TAG, "refresh request case time < 0, set to 0 and go on." );
|
||||
time = 0;
|
||||
}
|
||||
stopAutoRefreshStrategy(stopOnlineCarRefresh);
|
||||
stopAutoRefreshStrategy( stopOnlineCarRefresh );
|
||||
mRefreshRemainingTime = time;
|
||||
long delay = ServiceConst.DECREASE_INTERVAL;
|
||||
if (mRefreshRemainingTime < ServiceConst.DECREASE_INTERVAL) {
|
||||
if ( mRefreshRemainingTime < ServiceConst.DECREASE_INTERVAL ) {
|
||||
delay = mRefreshRemainingTime;
|
||||
}
|
||||
if (time == 0) {
|
||||
if ( time == 0 ) {
|
||||
invokeAutoRefresh();
|
||||
} else {
|
||||
mHandler.sendEmptyMessageDelayed(ServiceConst.MSG_TYPE_REFRESH_DECREASE, delay);
|
||||
mHandler.sendEmptyMessageDelayed( ServiceConst.MSG_TYPE_REFRESH_DECREASE, delay );
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshStrategy() {
|
||||
mStatusManager.setUserInteractionStatus(ServiceConst.TYPE, true, false);
|
||||
mStatusManager.setUserInteractionStatus( ServiceConst.TYPE, true, false );
|
||||
mUiController.recoverLockMode();// 锁车代替移到中心点
|
||||
restartAutoRefreshAtTime( 0 );
|
||||
}
|
||||
@@ -1075,11 +808,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
mContext.sendBroadcast( intent );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateCongestion( MogoCongestionInfo info ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntentReceived( String command, Intent intent ) {
|
||||
|
||||
@@ -1099,7 +827,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
/**
|
||||
* 注册桌面免唤醒指令
|
||||
*/
|
||||
private void registerInternalUnWakeupWords() {
|
||||
public void registerInternalUnWakeupWords() {
|
||||
if ( mInternalUnWakeupRegisterStatus ) {
|
||||
return;
|
||||
}
|
||||
@@ -1112,7 +840,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
/**
|
||||
* 注销桌面免唤醒指令
|
||||
*/
|
||||
private void unregisterInternalUnWakeupWords() {
|
||||
public void unregisterInternalUnWakeupWords() {
|
||||
if ( !mInternalUnWakeupRegisterStatus ) {
|
||||
return;
|
||||
}
|
||||
@@ -1191,67 +919,13 @@ public class MogoServices implements IMogoMapListener,
|
||||
/**
|
||||
* 延时一分钟发起计算导航目的地推送策略
|
||||
*/
|
||||
private void scheduleCalculationNotHomeCompanyDistanceForPush( int time, long delay ) {
|
||||
public void scheduleCalculationNotHomeCompanyDistanceForPush( int time, long delay ) {
|
||||
Message msg = Message.obtain();
|
||||
msg.what = ServiceConst.MSG_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH;
|
||||
msg.arg1 = time;
|
||||
mHandler.sendMessageDelayed( msg, delay );
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起计算导航目的地推送策略
|
||||
*
|
||||
* @param time 第x次重试
|
||||
*/
|
||||
private void handleCalculationNotHomeCompanyDistanceForPush( final int time ) {
|
||||
if ( time > 3 ) {
|
||||
return;
|
||||
}
|
||||
String json = SpStorage.getNavigationTarget();
|
||||
if ( !TextUtils.isEmpty( json ) ) {
|
||||
try {
|
||||
NavigationTargetInfo info = GsonUtil.objectFromJson( json, NavigationTargetInfo.class );
|
||||
|
||||
Logger.d( TAG, "info = %s", info );
|
||||
|
||||
HomeCompanyDistanceForPushData data = new HomeCompanyDistanceForPushData();
|
||||
data.lat = Double.valueOf( info.getToPoiLatitude() );
|
||||
data.lon = Double.valueOf( info.getToPoiLongitude() );
|
||||
|
||||
final Map< String, Object > query = new ParamsProvider.Builder( mContext ).build();
|
||||
query.put( "data", GsonUtil.jsonFromObject( data ) );
|
||||
mRefreshModel.getRefreshApiService().calculationNotHomeCompanyDistanceForPush( query )
|
||||
.subscribeOn( Schedulers.io() )
|
||||
.observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe( new SubscribeImpl< HomeCompanyDistanceForPushResponse >( RequestOptions.create( mContext ) ) {
|
||||
@Override
|
||||
public void onSuccess( HomeCompanyDistanceForPushResponse o ) {
|
||||
super.onSuccess( o );
|
||||
if ( o != null && o.result != null ) {
|
||||
Logger.d( TAG, "calculationNotHomeCompanyDistanceForPush result %s", o.result.pushFlag );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError( Throwable e ) {
|
||||
super.onError( e );
|
||||
Logger.d( TAG, "re scheduleCalculationNotHomeCompanyDistanceForPush after 30s" );
|
||||
// 延时30s重试
|
||||
scheduleCalculationNotHomeCompanyDistanceForPush( time + 1, 30_000L );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError( String message, int code ) {
|
||||
super.onError( message, code );
|
||||
}
|
||||
} );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "handleCalculationNotHomeCompanyDistanceForPush" );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
Logger.d( TAG, "MogoServices do nothings." );
|
||||
@@ -1260,4 +934,13 @@ public class MogoServices implements IMogoMapListener,
|
||||
public Location getLastCarLocation() {
|
||||
return mLastCarLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapModeChanged( EnumMapUI ui ) {
|
||||
if ( ui == EnumMapUI.Type_VR ) {
|
||||
MapCenterPointStrategy.resetByChangeMode();
|
||||
} else {
|
||||
MapCenterPointStrategy.resetByChangeMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,25 @@
|
||||
package com.mogo.module.service;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.service.launchercard.LauncherCardRefresher;
|
||||
import com.mogo.module.service.marker.MapMarkerManager;
|
||||
import com.mogo.module.service.strategy.CarIconDisplayStrategy;
|
||||
import com.mogo.module.service.vrmode.VrModeController;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.carchattingprovider.CallChattingProviderConstant;
|
||||
import com.zhidao.carchattingprovider.ICallChatResponse;
|
||||
import com.zhidao.carchattingprovider.ICallProviderResponse;
|
||||
import com.zhidao.carchattingprovider.ICarsChattingProvider;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public
|
||||
/**
|
||||
@@ -12,6 +30,15 @@ public
|
||||
*/
|
||||
abstract class StatusChangedAdapter implements IMogoStatusChangedListener {
|
||||
|
||||
private static final String TAG = "StatusChangedAdapter";
|
||||
|
||||
private boolean mIsMainPageFirstResume = true;
|
||||
|
||||
private ICallProviderResponse mCallProviderResponse;
|
||||
private ICarsChattingProvider mCarsChattingProvider;
|
||||
|
||||
private boolean mIsFirstAccOn = true;
|
||||
|
||||
@Override
|
||||
public final void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
|
||||
switch ( descriptor ) {
|
||||
@@ -42,19 +69,111 @@ abstract class StatusChangedAdapter implements IMogoStatusChangedListener {
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void onUserInteracted( boolean userInteracted );
|
||||
public void onUserInteracted( boolean userInteracted ) {
|
||||
if ( userInteracted ) {
|
||||
MogoServices.getInstance().restartAutoRefreshAtTime( ServiceConst.DEFAULT_AUTO_REFRESH_WHEN_INTERRUPT );
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void onSearchUIShow( boolean visible );
|
||||
|
||||
public abstract void onMainPageResumeStatusChanged( boolean resume );
|
||||
public void onMainPageResumeStatusChanged( boolean resume ) {
|
||||
if ( resume ) {
|
||||
MogoServices.getInstance().registerInternalUnWakeupWords();
|
||||
if ( !mIsMainPageFirstResume ) {
|
||||
MogoServices.getInstance().restartAutoRefreshAtTime( 2_000L );
|
||||
}
|
||||
mIsMainPageFirstResume = false;
|
||||
LauncherCardRefresher.getInstance( AbsMogoApplication.getApp() ).stop();
|
||||
MogoServices.getInstance().playAppTts();
|
||||
} else {
|
||||
MogoServices.getInstance().unregisterInternalUnWakeupWords();
|
||||
MogoServices.getInstance().stopAutoRefreshStrategy();
|
||||
}
|
||||
VrModeController.getInstance().onMainPageResumeStatusChanged( resume );
|
||||
}
|
||||
|
||||
public abstract void onMainPageIsBackgroundStatusChanged( boolean isBackground );
|
||||
public void onMainPageIsBackgroundStatusChanged( boolean isBackground ) {
|
||||
if ( isBackground ) {
|
||||
closeAllPanel();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void onSeekHelpingStatusChanged( boolean isSeekingHelping );
|
||||
/**
|
||||
* 关闭所有模块的控制面板
|
||||
*/
|
||||
private void closeAllPanel() {
|
||||
|
||||
public abstract void onAccStatusChanged( boolean accOn );
|
||||
if ( mCallProviderResponse == null ) {
|
||||
mCallProviderResponse = new ICallChatResponse() {
|
||||
@Override
|
||||
public void hideUserWindowError( @NotNull String errorMsg ) {
|
||||
}
|
||||
};
|
||||
}
|
||||
MogoApisHandler.getInstance().getApis().getShareManager().dismissShareDialog();
|
||||
MogoApisHandler.getInstance().getApis().getOnlineCarPanelApi().hidePanel();
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().setSettingStatus( false );
|
||||
MogoApisHandler.getInstance().getApis().getEventPanelManager().hidePanel();
|
||||
if ( mCarsChattingProvider == null ) {
|
||||
mCarsChattingProvider = ( ICarsChattingProvider ) ARouter.getInstance().build( CallChattingProviderConstant.CAR_CALL_PROVIDER ).navigation();
|
||||
}
|
||||
if ( mCarsChattingProvider != null ) {
|
||||
mCarsChattingProvider.hideUserWindow( TAG, AbsMogoApplication.getApp(), mCallProviderResponse );
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void onVrModeChanged( boolean isVrMode );
|
||||
public void onSeekHelpingStatusChanged( boolean isSeekingHelping ) {
|
||||
CarIconDisplayStrategy.getInstance().changeCarIconStatus( isSeekingHelping );
|
||||
notifySeekHelpingStatusChanged( isSeekingHelping );
|
||||
}
|
||||
|
||||
public abstract void onTopViewStatusChanged( boolean visible );
|
||||
private void notifySeekHelpingStatusChanged( boolean seekHelpingStatus ) {
|
||||
Intent intent = new Intent( "com.mogo.launcher.adas.app" );
|
||||
try {
|
||||
JSONObject data = new JSONObject();
|
||||
data.put( "object", "辅助驾驶" );
|
||||
data.put( "action", seekHelpingStatus ? "2" : "1" );
|
||||
data.put( "des", "自身故障报警" );
|
||||
data.put( "v2x_warning_type", "20007" );// 后台返回
|
||||
intent.putExtra( "data", data.toString() );
|
||||
AbsMogoApplication.getApp().sendBroadcast( intent );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
}
|
||||
|
||||
public void onAccStatusChanged( boolean accOn ) {
|
||||
if ( accOn ) {
|
||||
if ( mIsFirstAccOn ) {
|
||||
mIsFirstAccOn = false;
|
||||
return;
|
||||
}
|
||||
MogoServices.getInstance().initLocationServiceProcess( AbsMogoApplication.getApp() );
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().showADAS();
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getSingletonLocationClient( AbsMogoApplication.getApp() ).start();
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMarkerManager( AbsMogoApplication.getApp() ).removeMarkers();
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
MogoServices.getInstance().refreshStrategy();
|
||||
}, 3_000L );
|
||||
} else {
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getSingletonLocationClient( AbsMogoApplication.getApp() ).stop();
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMarkerManager( AbsMogoApplication.getApp() ).removeMarkers();
|
||||
}
|
||||
}
|
||||
|
||||
public void onVrModeChanged( boolean isVrMode ) {
|
||||
VrModeController.getInstance().onVrModeChanged( isVrMode );
|
||||
}
|
||||
|
||||
public void onTopViewStatusChanged( boolean visible ) {
|
||||
if ( visible ) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
MapMarkerManager.getInstance().onCloseCurrentSelectedMarker();
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "onTopViewStatusChanged" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.mogo.module.service.handler;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.network.ParamsProvider;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.commons.storage.SpStorage;
|
||||
import com.mogo.module.service.MogoServices;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.mogo.module.service.network.bean.HomeCompanyDistanceForPushData;
|
||||
import com.mogo.module.service.network.bean.HomeCompanyDistanceForPushResponse;
|
||||
import com.mogo.module.service.onlinecar.panel.NavigationTargetInfo;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.RequestOptions;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/12/14
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
abstract class MainLooperHandler extends Handler {
|
||||
|
||||
private static final String TAG = "MainLooperHandler";
|
||||
|
||||
public MainLooperHandler( Looper looper ) {
|
||||
super( looper );
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void handleMessage( Message msg ) {
|
||||
super.handleMessage( msg );
|
||||
|
||||
switch ( msg.what ) {
|
||||
case ServiceConst.MSG_TYPE_REFRESH_DECREASE:
|
||||
handleRefreshDecrease( msg );
|
||||
break;
|
||||
case ServiceConst.MSG_LOOP_REQUEST:
|
||||
handleLoopRequestMessage( msg );
|
||||
break;
|
||||
case ServiceConst.MSG_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH:
|
||||
handleScheduleCalculateNotHomeCompanyDistanceForPushMessage( msg );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void handleRefreshDecrease( Message msg );
|
||||
|
||||
protected abstract void handleLoopRequestMessage( Message msg );
|
||||
|
||||
protected void handleScheduleCalculateNotHomeCompanyDistanceForPushMessage( Message msg ) {
|
||||
handleCalculationNotHomeCompanyDistanceForPush( msg.arg1 );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发起计算导航目的地推送策略
|
||||
*
|
||||
* @param time 第x次重试
|
||||
*/
|
||||
private void handleCalculationNotHomeCompanyDistanceForPush( final int time ) {
|
||||
if ( time > 3 ) {
|
||||
return;
|
||||
}
|
||||
String json = SpStorage.getNavigationTarget();
|
||||
if ( !TextUtils.isEmpty( json ) ) {
|
||||
try {
|
||||
NavigationTargetInfo info = GsonUtil.objectFromJson( json, NavigationTargetInfo.class );
|
||||
|
||||
Logger.d( TAG, "info = %s", info );
|
||||
|
||||
HomeCompanyDistanceForPushData data = new HomeCompanyDistanceForPushData();
|
||||
data.lat = Double.valueOf( info.getToPoiLatitude() );
|
||||
data.lon = Double.valueOf( info.getToPoiLongitude() );
|
||||
|
||||
final Map< String, Object > query = new ParamsProvider.Builder( AbsMogoApplication.getApp() ).build();
|
||||
query.put( "data", GsonUtil.jsonFromObject( data ) );
|
||||
MogoServices.getInstance().getRefreshModel().getRefreshApiService().calculationNotHomeCompanyDistanceForPush( query )
|
||||
.subscribeOn( Schedulers.io() )
|
||||
.observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe( new SubscribeImpl< HomeCompanyDistanceForPushResponse >( RequestOptions.create( AbsMogoApplication.getApp() ) ) {
|
||||
@Override
|
||||
public void onSuccess( HomeCompanyDistanceForPushResponse o ) {
|
||||
super.onSuccess( o );
|
||||
if ( o != null && o.result != null ) {
|
||||
Logger.d( TAG, "calculationNotHomeCompanyDistanceForPush result %s", o.result.pushFlag );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError( Throwable e ) {
|
||||
super.onError( e );
|
||||
Logger.d( TAG, "re scheduleCalculationNotHomeCompanyDistanceForPush after 30s" );
|
||||
// 延时30s重试
|
||||
MogoServices.getInstance().scheduleCalculationNotHomeCompanyDistanceForPush( time + 1, 30_000L );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError( String message, int code ) {
|
||||
super.onError( message, code );
|
||||
}
|
||||
} );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "handleCalculationNotHomeCompanyDistanceForPush" );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.mogo.module.service.handler;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.mogo.module.service.marker.MapMarkerManager;
|
||||
import com.mogo.module.service.refresh.RefreshObject;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/12/14
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
abstract class RefreshWorkThreadHandler extends Handler {
|
||||
|
||||
private static final String TAG = "RefreshWorkThreadHandler";
|
||||
|
||||
public RefreshWorkThreadHandler( Looper looper ) {
|
||||
super( looper );
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void handleMessage( Message msg ) {
|
||||
super.handleMessage( msg );
|
||||
if ( msg.what == ServiceConst.MSG_MAP_CHANGED ) {
|
||||
try {
|
||||
handleMapChangedMessage( msg );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "handleMapChangedMessage" );
|
||||
}
|
||||
} else if ( msg.what == ServiceConst.MSG_REQUEST_DATA ) {
|
||||
try {
|
||||
handleRequestDataMessage( msg );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "handleRequestDataMessage" );
|
||||
}
|
||||
} else if ( msg.what == ServiceConst.MSG_LOCK_CAR ) {
|
||||
try {
|
||||
handleLockCarMessage( msg );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "handleLockCarMessage" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void handleMapChangedMessage( Message msg );
|
||||
|
||||
protected abstract void handleRequestDataMessage( Message msg );
|
||||
|
||||
protected void handleLockCarMessage( Message msg ) {
|
||||
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isSearchUIShow() ) {
|
||||
return;
|
||||
}
|
||||
MogoApisHandler.getInstance().getApis().getStatusManagerApi().setUserInteractionStatus( TAG, true, false );
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().recoverLockMode();
|
||||
}
|
||||
}
|
||||
@@ -71,6 +71,10 @@ public class MogoRTKLocation {
|
||||
rtkLocationListener = locationListener;
|
||||
}
|
||||
|
||||
public void unregisterRTKLocationListener(){
|
||||
rtkLocationListener = null;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
locationManager = (LocationManager) AbsMogoApplication.getApp().getApplicationContext().getSystemService(Context.LOCATION_SERVICE);
|
||||
String provider = locationManager.getBestProvider(getCriteria(), true);
|
||||
|
||||
@@ -35,7 +35,6 @@ import com.mogo.module.service.R;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.mogo.module.service.network.RefreshCallback;
|
||||
import com.mogo.module.service.network.RefreshModel;
|
||||
import com.mogo.module.service.utils.ViewUtils;
|
||||
import com.mogo.module.service.vrmode.VrModeController;
|
||||
import com.mogo.service.adas.IMogoADASControlStatusChangedListener;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
@@ -45,6 +44,7 @@ import com.mogo.service.module.IMogoBizActionDoneListener;
|
||||
import com.mogo.utils.ResourcesHelper;
|
||||
import com.mogo.utils.ThreadPoolService;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.ViewUtils;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
import com.zhidao.carchattingprovider.ICallChatResponse;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -160,7 +160,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
if ( data == null ) {
|
||||
return;
|
||||
}
|
||||
if ( !MogoApisHandler.getInstance().getApis().getMapFrameControllerApi().isVrMode() ) {
|
||||
if ( !MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
|
||||
// return;
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
mogoMarker.setToTop();
|
||||
}
|
||||
}
|
||||
if ( !MarkerServiceHandler.getApis().getMapFrameControllerApi().isVrMode() ) {
|
||||
if ( !MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode() ) {
|
||||
MarkerServiceHandler.getMogoStatusManager().setUserInteractionStatus( TAG, true, false );
|
||||
MarkerServiceHandler.getMapUIController().moveToCenter( mogoMarker.getPosition(), DebugConfig.isRoadEventAnimated() );
|
||||
}
|
||||
@@ -654,7 +654,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
|| MarkerServiceHandler.getMogoStatusManager().isV2XShow()
|
||||
|| !MarkerServiceHandler.getMogoStatusManager().isMainPageLaunched()
|
||||
|| !MarkerServiceHandler.getMogoStatusManager().isMainPageOnResume()
|
||||
|| MarkerServiceHandler.getApis().getMapFrameControllerApi().isVrMode();
|
||||
|| MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode();
|
||||
}
|
||||
|
||||
private void runOnTargetThread( Runnable runnable ) {
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.mogo.module.service.uploadintime;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.commons.utils.MortonCode;
|
||||
import com.mogo.module.common.entity.CloudLocationInfo;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.location.MogoRTKLocation;
|
||||
import com.mogo.module.service.utils.SimpleLocationCorrectStrategy;
|
||||
import com.mogo.module.service.websocket.LocationResult;
|
||||
import com.mogo.module.service.websocket.OnePerSecondSendContent;
|
||||
import com.mogo.service.adas.entity.ADASRecognizedResult;
|
||||
import com.mogo.service.connection.IMogoOnWebSocketMessageListener;
|
||||
import com.mogo.service.connection.WebSocketMsgType;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/12/14
|
||||
*
|
||||
* 实时上报坐标、识别物体
|
||||
*/
|
||||
class SnapshotUploadInTime implements MogoRTKLocation.RTKLocationListener {
|
||||
|
||||
private static final String TAG = "SnapshotUploadInTime";
|
||||
|
||||
private static volatile SnapshotUploadInTime sInstance;
|
||||
private Context mContext;
|
||||
|
||||
private SnapshotUploadInTime() {
|
||||
}
|
||||
|
||||
public static SnapshotUploadInTime getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( SnapshotUploadInTime.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new SnapshotUploadInTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void start( Context context ) {
|
||||
mContext = context.getApplicationContext();
|
||||
MogoRTKLocation.getInstance().registerRTKLocationListener( this );
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
MogoRTKLocation.getInstance().unregisterRTKLocationListener();
|
||||
MogoRTKLocation.getInstance().stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged( List< CloudLocationInfo > cloudLocationInfos ) {
|
||||
startSendCarLocationAndAdasRecognizedResult2Server( cloudLocationInfos );
|
||||
}
|
||||
|
||||
private CloudLocationInfo mLastInfo;
|
||||
|
||||
private void startSendCarLocationAndAdasRecognizedResult2Server( List< CloudLocationInfo > cloudLocationInfo ) {
|
||||
CloudLocationInfo lastInfo = null;
|
||||
// 如果数组内容不为空,就用数组最后一个值
|
||||
if ( cloudLocationInfo != null && !cloudLocationInfo.isEmpty() ) {
|
||||
lastInfo = cloudLocationInfo.get( cloudLocationInfo.size() - 1 );
|
||||
mLastInfo = lastInfo;
|
||||
}
|
||||
if ( lastInfo == null ) {
|
||||
lastInfo = mLastInfo;
|
||||
}
|
||||
LocationResult locationResult = null;
|
||||
if ( lastInfo != null ) {
|
||||
// 定位点预测纠偏
|
||||
lastInfo = SimpleLocationCorrectStrategy.getInstance().correct( lastInfo );
|
||||
locationResult = new LocationResult();
|
||||
if ( lastInfo != null ) {
|
||||
locationResult.lastCoordinate = lastInfo;
|
||||
locationResult.mortonCode = MortonCode.wrapEncodeMorton( lastInfo.getLon(), lastInfo.getLat() );
|
||||
}
|
||||
locationResult.coordinates = new ArrayList<>();
|
||||
locationResult.sn = com.mogo.commons.network.Utils.getSn();
|
||||
if ( cloudLocationInfo == null ) {
|
||||
locationResult.coordinates.addAll( new ArrayList<>() );
|
||||
} else {
|
||||
locationResult.coordinates.addAll( cloudLocationInfo );
|
||||
}
|
||||
}
|
||||
List< ADASRecognizedResult > recognizedResults = MarkerServiceHandler.getADASController().getLastADASRecognizedResult();
|
||||
OnePerSecondSendContent content = new OnePerSecondSendContent();
|
||||
content.self = locationResult;
|
||||
content.adas = recognizedResults;
|
||||
|
||||
MarkerServiceHandler.getApis().getWebSocketManagerApi( mContext ).sendMsg( content, new IMogoOnWebSocketMessageListener() {
|
||||
@Override
|
||||
public WebSocketMsgType getDownLinkType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebSocketMsgType getUpLinkType() {
|
||||
return WebSocketMsgType.MSG_TYPE_UPLINK_CAR_DATA;
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.mogo.module.service.utils;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020-02-2123:51
|
||||
* desc :
|
||||
* version: 1.0
|
||||
*/
|
||||
public class ViewUtils {
|
||||
public static Bitmap fromView(View view) {
|
||||
view.setDrawingCacheEnabled(true);
|
||||
processChildView(view);
|
||||
view.destroyDrawingCache();
|
||||
view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
|
||||
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
|
||||
Bitmap bitmap = null;
|
||||
return (bitmap = view.getDrawingCache()) != null ? bitmap.copy(Bitmap.Config.ARGB_8888, false) : null;
|
||||
}
|
||||
|
||||
public static void processChildView(View view) {
|
||||
if (!(view instanceof ViewGroup)) {
|
||||
if (view instanceof TextView) {
|
||||
((TextView) view).setHorizontallyScrolling(false);
|
||||
}
|
||||
} else {
|
||||
for (int var1 = 0; var1 < ((ViewGroup) view).getChildCount(); ++var1) {
|
||||
processChildView(((ViewGroup) view).getChildAt(var1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user