远程控制adas
This commit is contained in:
@@ -39,6 +39,7 @@ import com.mogo.module.common.MogoModulePaths;
|
||||
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.service.autopilot.AutoPilotRemoteController;
|
||||
import com.mogo.module.service.intent.IntentHandlerFactory;
|
||||
import com.mogo.module.service.launchercard.LauncherCardRefresher;
|
||||
import com.mogo.module.service.marker.MapMarkerManager;
|
||||
@@ -54,6 +55,7 @@ import com.mogo.module.service.refresh.RefreshObject;
|
||||
import com.mogo.module.service.strategy.CarIconDisplayStrategy;
|
||||
import com.mogo.service.adas.IMogoADASController;
|
||||
import com.mogo.service.cardmanager.IMogoCardManager;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.service.fragmentmanager.FragmentStackTransactionListener;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
@@ -422,6 +424,8 @@ public class MogoServices implements IMogoMapListener,
|
||||
if ( DebugConfig.isLaunchLocationService() ) {
|
||||
initLocationServiceProcess( context );
|
||||
}
|
||||
|
||||
AutoPilotRemoteController.getInstance().start();
|
||||
}
|
||||
|
||||
private void initLocationServiceProcess( Context context ) {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.mogo.module.service.autopilot;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/16
|
||||
*
|
||||
* 自动驾驶参数
|
||||
*/
|
||||
class AutoPilotParameters {
|
||||
|
||||
public AutoPilotLonLat startLatLon;
|
||||
public List< AutoPilotLonLat > wayLatLons;
|
||||
public AutoPilotLonLat endLatLon;
|
||||
public float speedLimit;
|
||||
|
||||
public static class AutoPilotLonLat {
|
||||
public double lat;
|
||||
public double lon;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.mogo.module.service.autopilot;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.service.connection.IMogoSocketManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/16
|
||||
*
|
||||
* 远端控制自动驾驶
|
||||
*/
|
||||
class AutoPilotRemoteController {
|
||||
|
||||
private static final String TAG = "AutoPilotRemoteController";
|
||||
|
||||
private static volatile AutoPilotRemoteController sInstance;
|
||||
|
||||
private IMogoSocketManager mMogoSocketManager;
|
||||
|
||||
private IMogoOnMessageListener< AutoPilotParameters > mParametersListener = new IMogoOnMessageListener< AutoPilotParameters >() {
|
||||
@Override
|
||||
public Class< AutoPilotParameters > target() {
|
||||
return AutoPilotParameters.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMsgReceived( AutoPilotParameters obj ) {
|
||||
if ( obj == null ) {
|
||||
Logger.e( TAG, "远端控制参数为null", new NullPointerException() );
|
||||
return;
|
||||
}
|
||||
String json = GsonUtil.jsonFromObject( obj );
|
||||
Logger.d( TAG, json );
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().notifyAdas( json );
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 远端控制自动驾驶的消息类型
|
||||
*/
|
||||
public static final int MSG_TYPE_REMOTE_CONTROL_AUTOPILOT = 401014;
|
||||
|
||||
private AutoPilotRemoteController() {
|
||||
mMogoSocketManager = MogoApisHandler.getInstance().getApis().getSocketManagerApi( AbsMogoApplication.getApp() );
|
||||
}
|
||||
|
||||
public static AutoPilotRemoteController getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( AutoPilotRemoteController.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new AutoPilotRemoteController();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
mMogoSocketManager.registerOnMessageListener( MSG_TYPE_REMOTE_CONTROL_AUTOPILOT, mParametersListener );
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
if ( mMogoSocketManager != null ) {
|
||||
mMogoSocketManager.unregisterOnMessageListener( MSG_TYPE_REMOTE_CONTROL_AUTOPILOT, mParametersListener );
|
||||
}
|
||||
mMogoSocketManager = null;
|
||||
mParametersListener = null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -68,4 +68,11 @@ public interface IMogoADASController extends IProvider {
|
||||
* @return
|
||||
*/
|
||||
EnumMapUI getCurrentSkinMode();
|
||||
|
||||
/**
|
||||
* 给adas传递数据
|
||||
*
|
||||
* @param json
|
||||
*/
|
||||
void notifyAdas( String json );
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class MogoADASController implements IMogoADASController {
|
||||
@Override
|
||||
public void showADAS() {
|
||||
if ( !SharedPrefsMgr.getInstance( AbsMogoApplication.getApp() ).getBoolean( getSpGuide(), false ) ) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
Logger.d( TAG, Log.getStackTraceString( new Throwable() ) );
|
||||
init( AbsMogoApplication.getApp() );
|
||||
@@ -159,40 +159,6 @@ public class MogoADASController implements IMogoADASController {
|
||||
mIsReleased = false;
|
||||
}
|
||||
|
||||
//获取已安装应用的 uid,-1 表示未安装此应用或程序异常
|
||||
public static int getPackageUid( Context context, String packageName ) {
|
||||
try {
|
||||
ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo( packageName, 0 );
|
||||
if ( applicationInfo != null ) {
|
||||
return applicationInfo.uid;
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断某一 uid 的程序是否有正在运行的进程,即是否存活
|
||||
* Created by cafeting on 2017/2/4.
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param uid 已安装应用的 uid
|
||||
* @return true 表示正在运行,false 表示没有运行
|
||||
*/
|
||||
public static boolean isProcessRunning( Context context, int uid ) {
|
||||
ActivityManager am = ( ActivityManager ) context.getSystemService( Context.ACTIVITY_SERVICE );
|
||||
List< ActivityManager.RunningServiceInfo > runningServiceInfos = am.getRunningServices( 200 );
|
||||
if ( runningServiceInfos.size() > 0 ) {
|
||||
for ( ActivityManager.RunningServiceInfo appProcess : runningServiceInfos ) {
|
||||
if ( uid == appProcess.uid ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSettingStatus( boolean show ) {
|
||||
AutopilotServiceManage.getInstance().setSettingStatus( show );
|
||||
@@ -245,6 +211,15 @@ public class MogoADASController implements IMogoADASController {
|
||||
return EnumMapUI.Type_Light;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyAdas( String json ) {
|
||||
try {
|
||||
// AutopilotServiceManage.getInstance().aiCloudToAdasData( json );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "notifyAdas" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
mIsReleased = true;
|
||||
|
||||
Reference in New Issue
Block a user