This commit is contained in:
wangcongtao
2020-10-27 11:57:34 +08:00
parent 19c4859a71
commit 83a004f62b
31 changed files with 705 additions and 32 deletions

View File

@@ -53,10 +53,13 @@ import com.mogo.module.service.refresh.AutoRefreshStrategy;
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.vrmode.VrModeController;
import com.mogo.module.service.websocket.LocationResult;
import com.mogo.module.service.websocket.OnePerSecondSendContent;
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;
@@ -78,6 +81,7 @@ import com.mogo.utils.network.utils.GsonUtil;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -361,6 +365,11 @@ public class MogoServices implements IMogoMapListener,
MarkerServiceHandler.getApis().getMapServiceApi().getMarkerManager( mContext ).removeMarkers();
}
}
@Override
public void onVrModeChanged( boolean isVrMode ) {
VrModeController.getInstance().onVrModeChanged( isVrMode );
}
};
public void init( Context context ) {
@@ -378,6 +387,7 @@ public class MogoServices implements IMogoMapListener,
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.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.VR_MODE, statusChangedListener );
mStatusManager.setAIAssistReady( TAG, AIAssist.getInstance( mContext ).hasFlush() );
registerMogoReceiver( context );
@@ -449,22 +459,35 @@ public class MogoServices implements IMogoMapListener,
LocationResult locationResult = null;
if ( lastCarLocation != null ) {
locationResult = new LocationResult();
locationResult.alt = lastCarLocation.getAltitude();
locationResult.heading = lastCarLocation.getBearing();
locationResult.lat = lastCarLocation.getLatitude();
locationResult.lon = lastCarLocation.getLongitude();
locationResult.satelliteTime = lastCarLocation.getTime();
locationResult.systemTime = System.currentTimeMillis();
locationResult.speed = lastCarLocation.getSpeed();
locationResult.lastCoordinate = new LocationResult.LocationInfo();
locationResult.lastCoordinate.alt = lastCarLocation.getAltitude();
locationResult.lastCoordinate.heading = lastCarLocation.getBearing();
locationResult.lastCoordinate.lat = lastCarLocation.getLatitude();
locationResult.lastCoordinate.lon = lastCarLocation.getLongitude();
locationResult.lastCoordinate.satelliteTime = lastCarLocation.getTime();
locationResult.lastCoordinate.systemTime = System.currentTimeMillis();
locationResult.lastCoordinate.speed = lastCarLocation.getSpeed();
locationResult.coordinates = new ArrayList<>();
locationResult.sn = com.mogo.commons.network.Utils.getSn();
locationResult.mortonCode = MortonCode.wrapEncodeMorton( locationResult.lon, locationResult.lat );
locationResult.mortonCode = MortonCode.wrapEncodeMorton( locationResult.lastCoordinate.lon, locationResult.lastCoordinate.lat );
}
List< ADASRecognizedResult > recognizedResults = MarkerServiceHandler.getADASController().getLastADASRecognizedResult();
OnePerSecondSendContent content = new OnePerSecondSendContent();
content.self = locationResult;
content.adas = recognizedResults;
//todo 通过 websocket 发送内容
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 void initWorkThread() {

View File

@@ -13,7 +13,7 @@ public
abstract class StatusChangedAdapter implements IMogoStatusChangedListener {
@Override
public void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
public final void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
switch ( descriptor ) {
case USER_INTERACTED:
onUserInteracted( isTrue );
@@ -30,6 +30,9 @@ abstract class StatusChangedAdapter implements IMogoStatusChangedListener {
case ACC_STATUS:
onAccStatusChanged( isTrue );
break;
case VR_MODE:
onVrModeChanged( isTrue );
break;
}
}
@@ -42,4 +45,6 @@ abstract class StatusChangedAdapter implements IMogoStatusChangedListener {
public abstract void onSeekHelpingStatusChanged( boolean isSeekingHelping );
public abstract void onAccStatusChanged( boolean accOn );
public abstract void onVrModeChanged( boolean isVrMode );
}

View File

@@ -25,6 +25,7 @@ import com.mogo.module.common.entity.MarkerOnlineCar;
import com.mogo.module.common.entity.MarkerResponse;
import com.mogo.module.common.entity.MarkerShareMusic;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.module.common.entity.MogoSnapshotSetData;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.R;
import com.mogo.module.service.ServiceConst;
@@ -32,8 +33,11 @@ import com.mogo.module.service.Utils;
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;
import com.mogo.service.connection.IMogoOnWebSocketMessageListener;
import com.mogo.service.connection.WebSocketMsgType;
import com.mogo.service.module.IMogoBizActionDoneListener;
import com.mogo.utils.ResourcesHelper;
import com.mogo.utils.ThreadPoolService;
@@ -128,6 +132,33 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
}
} );
MarkerServiceHandler.getApis().getWebSocketManagerApi( mContext )
.registerOnWebSocketMessageListener( new IMogoOnWebSocketMessageListener< MogoSnapshotSetData >() {
@Override
public WebSocketMsgType getUpLinkType() {
return null;
}
@Override
public WebSocketMsgType getDownLinkType() {
return WebSocketMsgType.MSG_TYPE_DOWNLINK_CAR_DATA;
}
@Override
public void onMsgReceived( MogoSnapshotSetData data ) {
if ( data == null ) {
return;
}
VrModeController.getInstance().renderMogoSnapshotSetData( data );
}
@Override
public void onError( String errorMsg ) {
}
} );
}
/**

View File

@@ -0,0 +1,109 @@
package com.mogo.module.service.vrmode;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.module.common.entity.MogoSnapshotSetData;
import com.mogo.module.common.machinevision.IMachineVisionInterface;
import com.mogo.utils.logger.Logger;
public
/**
* @author congtaowang
* @since 2020/10/27
*
* 描述
*/
class VrModeController {
private static final String TAG = "VrModeController";
private static volatile VrModeController sInstance;
private volatile IMachineVisionInterface mMachineVisionInterface;
private ServiceConnection mServiceConnection;
private VrModeController() {
}
public static VrModeController getInstance() {
if ( sInstance == null ) {
synchronized ( VrModeController.class ) {
if ( sInstance == null ) {
sInstance = new VrModeController();
}
}
}
return sInstance;
}
public synchronized void release() {
sInstance = null;
}
private Object readResolve() {
// 阻止反序列化,必须实现 Serializable 接口
return sInstance;
}
public void onVrModeChanged( boolean isVrMode ) {
if ( isVrMode ) {
bindVrModeService();
} else {
unbindVrModeService();
}
}
private void bindVrModeService() {
Intent intent = new Intent();
intent.setComponent( new ComponentName( "com.mogo.launcher.f", "com.mogo.module.machine.vision.MachineVisionMapService" ) );
AbsMogoApplication.getApp().bindService( intent, mServiceConnection = new ServiceConnection() {
@Override
public void onServiceConnected( ComponentName name, IBinder service ) {
mMachineVisionInterface = IMachineVisionInterface.Stub.asInterface( service );
}
@Override
public void onServiceDisconnected( ComponentName name ) {
mMachineVisionInterface = null;
}
@Override
public void onBindingDied( ComponentName name ) {
mMachineVisionInterface = null;
}
@Override
public void onNullBinding( ComponentName name ) {
mMachineVisionInterface = null;
}
}, Context.BIND_AUTO_CREATE );
}
private void unbindVrModeService() {
if ( mServiceConnection != null ) {
try {
AbsMogoApplication.getApp().unbindService( mServiceConnection );
} catch ( Exception e ) {
Logger.e( TAG, e, "unbindVrModeService" );
}
}
}
public void renderMogoSnapshotSetData( MogoSnapshotSetData data ) {
if ( data == null ) {
return;
}
if ( mMachineVisionInterface == null ) {
return;
}
try {
mMachineVisionInterface.postData( data );
} catch ( Exception e ) {
Logger.e( TAG, e, "postData" );
}
}
}

View File

@@ -1,5 +1,7 @@
package com.mogo.module.service.websocket;
import java.util.List;
public
/**
* @author congtaowang
@@ -10,12 +12,18 @@ public
class LocationResult {
public String sn;
public double lat;
public double lon;
public double heading;
public long systemTime;
public long satelliteTime;
public double alt;
public double speed;
public long mortonCode;
public LocationInfo lastCoordinate;
public List< LocationInfo > coordinates;
public static class LocationInfo {
public double lat;
public double lon;
public double heading;
public long systemTime;
public long satelliteTime;
public double alt;
public double speed;
}
}