This commit is contained in:
wangcongtao
2020-04-14 11:27:04 +08:00
parent dccc9be8be
commit 00dcc08075
8 changed files with 98 additions and 63 deletions

View File

@@ -551,9 +551,6 @@ public class AMapNaviViewWrapper implements IMogoMapView,
style.strokeWidth( 0 );
style.radiusFillColor( Color.TRANSPARENT );
mMapView.getMap().setMyLocationStyle( style );
mMapView.getMap().setOnMyLocationChangeListener( location -> {
Logger.d( TAG, "%s", location );
} );
}
}

View File

@@ -14,6 +14,7 @@ import com.mogo.map.IMogoMap;
import com.mogo.map.IMogoUiSettings;
import com.mogo.map.impl.amap.marker.AMapInfoWindowAdapter;
import com.mogo.map.impl.amap.marker.AMapMarkerWrapper;
import com.mogo.map.impl.amap.navi.NaviClient;
import com.mogo.map.impl.amap.overlay.AMapPolylineWrapper;
import com.mogo.map.impl.amap.uicontroller.AMapUIController;
import com.mogo.map.impl.amap.utils.ObjectUtils;

View File

@@ -312,6 +312,7 @@ public class NaviClient implements IMogoNavi {
AMapWrapper.getAMap().setLocationSource( null );
mOnLocationChangedListener = null;
}
AMapWrapper.getAMap().setMyLocationEnabled( true );
}
@Override

View File

@@ -20,7 +20,7 @@ public class JWebSocketClient extends WebSocketClient {
@Override
public void onOpen( ServerHandshake handshakedata ) {
Logger.e( "JWebSocketClient", "onOpen()" );
Logger.d( "JWebSocketClient", "onOpen()" );
bindSN();
}
@@ -36,12 +36,11 @@ public class JWebSocketClient extends WebSocketClient {
@Override
public void onClose( int code, String reason, boolean remote ) {
Logger.e( "JWebSocketClient", "onClose()" );
Logger.d( "JWebSocketClient", "onClose()" );
}
@Override
public void onError( Exception ex ) {
Logger.e( "JWebSocketClient", "onError()" );
ex.printStackTrace();
Logger.d( "JWebSocketClient", "onError()" );
}
}

View File

@@ -3,6 +3,7 @@ package com.mogo.module.gps.simulator;
import android.content.Context;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.utils.UiThreadHandler;
/**
@@ -18,12 +19,15 @@ public class MogoGpsSimulatorManagerDebug implements IMogoGpsSimulatorManager {
@Override
public void open() {
WebSocketManager.getInstance().connect( true );
WebSocketManager.getInstance().connect();
}
@Override
public void close() {
WebSocketManager.getInstance().disConnect();
UiThreadHandler.postDelayed( () -> {
WebSocketManager.destroy();
}, 1_000L );
}
@Override

View File

@@ -2,12 +2,17 @@ package com.mogo.module.gps.simulator;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.map.MogoLatLng;
import com.mogo.map.navi.IMogoCarLocationChangedListener;
import com.mogo.map.navi.IMogoNavi;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.MogoServicePaths;
import com.mogo.utils.TipToast;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.utils.GsonUtil;
import org.java_websocket.handshake.ServerHandshake;
import org.json.JSONObject;
import java.net.URI;
@@ -29,7 +34,7 @@ public class WebSocketManager {
private JWebSocketClient mClient;
private URI mUri;
private ExecutorService mService = Executors.newSingleThreadExecutor();
private ExecutorService mService;
public static WebSocketManager getInstance() {
if ( sWebSocketManager == null ) {
@@ -55,7 +60,25 @@ public class WebSocketManager {
Logger.e( TAG, e, "error." );
}
}
@Override
public void onOpen( ServerHandshake handshakedata ) {
super.onOpen( handshakedata );
UiThreadHandler.post( () -> {
TipToast.shortTip( "模拟GPS开启成功" );
} );
}
@Override
public void onClose( int code, String reason, boolean remote ) {
super.onClose( code, reason, remote );
UiThreadHandler.post( () -> {
TipToast.shortTip( "模拟GPS关闭成功" );
} );
shutdownServiceQuietly();
}
};
initThreadService();
}
private void parseMessage( String jsonStr ) throws Exception {
@@ -67,56 +90,56 @@ public class WebSocketManager {
} else if ( jsonObject.has( "realTimeLocationVo" ) ) {
Logger.d( TAG, "收到定位消息" );
CationVo realTimeLocationVo = GsonUtil.objectFromJson( jsonObject.getString( "realTimeLocationVo" ), CationVo.class );
mNavi.setExtraGPSData(
realTimeLocationVo.getLon(),
realTimeLocationVo.getLat(),
realTimeLocationVo.getVehicleSpeed(),
1,
realTimeLocationVo.getDirection(),
realTimeLocationVo.getLocationTime()
);
UiThreadHandler.post( () -> {
mNavi.setExtraGPSData(
realTimeLocationVo.getLon(),
realTimeLocationVo.getLat(),
realTimeLocationVo.getVehicleSpeed(),
1,
realTimeLocationVo.getDirection(),
realTimeLocationVo.getLocationTime()
);
} );
}
}
public void connect( final boolean block ) {
public void connect() {
if ( mClient == null ) {
return;
}
if ( mClient.isOpen() ) {
return;
}
mService.execute( () -> {
if ( block ) {
try {
if ( mClient.isClosed() ) {
mClient.reconnectBlocking();
} else {
mClient.connectBlocking();
}
} catch ( InterruptedException e ) {
Logger.e( TAG, e, "error." );
}
} else {
if ( mClient.isClosed() ) {
mClient.reconnect();
} else {
mClient.connect();
}
try {
mClient.connectBlocking();
} catch ( InterruptedException e ) {
Logger.e( TAG, e, "error." );
}
} );
}
private void initThreadService() {
if ( mService == null || mService.isShutdown() ) {
mService = Executors.newSingleThreadExecutor();
}
}
public void disConnect() {
if ( mClient == null ) {
return;
}
if ( mClient.isClosing() || mClient.isClosed() || !mClient.isOpen() ) {
return;
}
try {
mService.execute( () -> { mClient.close(); } );
mService.execute( () -> {
mClient.close();
} );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
}
}
public static void destroy() {
sWebSocketManager = null;
}
private void shutdownServiceQuietly() {
if ( mService != null && !mService.isShutdown() ) {
mService.shutdown();
}
mService = null;
}
}

View File

@@ -204,8 +204,6 @@ class NaviSettingFragment : BaseFragment(), OnCheckedChangeListener {
tb_navi.setOnCheckedChangeListener { _, isChecked ->
SettingManager.setMonitor(isChecked)
}
tb_navi.isChecked = SettingManager.isMonitor()
tb_gps.isChecked = SettingManager.isGpsSimulator()
tb_gps.setOnCheckedChangeListener { _, isChecked ->
@@ -222,6 +220,8 @@ class NaviSettingFragment : BaseFragment(), OnCheckedChangeListener {
SearchServiceHolder.gpsSimulator.close()
}
}
tb_navi.isChecked = SettingManager.isMonitor()
tb_gps.isChecked = SettingManager.isGpsSimulator()
ll_navi_simulator.visibility = View.VISIBLE
tv_navi_simulator.visibility = View.VISIBLE

View File

@@ -286,6 +286,7 @@ public class MogoServices implements IMogoMapListener,
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.setAIAssistReady( TAG, AIAssist.getInstance( mContext ).hasFlush() );
registerMogoReceiver( context );
@@ -664,6 +665,24 @@ public class MogoServices implements IMogoMapListener,
unregisterInternalUnWakeupWords();
}
break;
case SEEK_HELPING:
notifySeekHelpingStatusChanged( isTrue );
break;
}
}
private void notifySeekHelpingStatusChanged( boolean open ) {
Intent intent = new Intent( "com.mogo.launcher.adas.app" );
try {
JSONObject data = new JSONObject();
data.put( "object", "辅助驾驶" );
data.put( "action", open ? "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." );
}
}
@@ -905,15 +924,9 @@ public class MogoServices implements IMogoMapListener,
return;
}
mInternalUnWakeupRegisterStatus = true;
// AIAssist.getInstance( mContext )
// .registerUnWakeupCommand( ServiceConst.CMD_UN_WAKE_PREV,
// ServiceConst.CMD_UN_WAKE_PREV_UN_WAKE_WORDS, this );
// AIAssist.getInstance( mContext )
// .registerUnWakeupCommand( ServiceConst.CMD_UN_WAKE_NEXT,
// ServiceConst.CMD_UN_WAKE_NEXT_UN_WAKE_WORDS, this );
AIAssist.getInstance( mContext )
.registerUnWakeupCommand( ServiceConst.CMD_UN_WAKEUP_MY_LOCATION,
ServiceConst.CMD_UN_WAKEUP_WORDS_MY_LOCATION, this );
// AIAssist.getInstance( mContext ).registerUnWakeupCommand( ServiceConst.CMD_UN_WAKE_PREV,ServiceConst.CMD_UN_WAKE_PREV_UN_WAKE_WORDS, this );
// AIAssist.getInstance( mContext ).registerUnWakeupCommand( ServiceConst.CMD_UN_WAKE_NEXT,ServiceConst.CMD_UN_WAKE_NEXT_UN_WAKE_WORDS, this );
AIAssist.getInstance( mContext ).registerUnWakeupCommand( ServiceConst.CMD_UN_WAKEUP_MY_LOCATION, ServiceConst.CMD_UN_WAKEUP_WORDS_MY_LOCATION, this );
}
/**
@@ -924,12 +937,9 @@ public class MogoServices implements IMogoMapListener,
return;
}
mInternalUnWakeupRegisterStatus = false;
// AIAssist.getInstance( mContext )
// .unregisterUnWakeupCommand( ServiceConst.CMD_UN_WAKE_PREV, this );
// AIAssist.getInstance( mContext )
// .unregisterUnWakeupCommand( ServiceConst.CMD_UN_WAKE_NEXT, this );
AIAssist.getInstance( mContext )
.unregisterUnWakeupCommand( ServiceConst.CMD_UN_WAKEUP_MY_LOCATION, this );
// AIAssist.getInstance( mContext ).unregisterUnWakeupCommand( ServiceConst.CMD_UN_WAKE_PREV, this );
// AIAssist.getInstance( mContext ).unregisterUnWakeupCommand( ServiceConst.CMD_UN_WAKE_NEXT, this );
AIAssist.getInstance( mContext ).unregisterUnWakeupCommand( ServiceConst.CMD_UN_WAKEUP_MY_LOCATION, this );
}
@Override
@@ -976,9 +986,9 @@ public class MogoServices implements IMogoMapListener,
mStatusManager.setSearchUIShow( TAG, false );
}
if ( mNavi.isNaviing() ) {
MapCenterPointStrategy.setMapCenterPointByScene(mUiController, Scene.NAVI );
MapCenterPointStrategy.setMapCenterPointByScene( mUiController, Scene.NAVI );
} else {
MapCenterPointStrategy.setMapCenterPointByScene(mUiController, Scene.AIMLESS );
MapCenterPointStrategy.setMapCenterPointByScene( mUiController, Scene.AIMLESS );
}
mUiController.recoverLockMode();
} else {