@@ -139,8 +139,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
private float mLastZoomLevel = 0;
|
||||
private TtsConfigModleData mTtsModle;
|
||||
private long mRefreshRemainingTime = Long.MAX_VALUE;
|
||||
// 上次手动操作的中心点坐标
|
||||
private MogoLatLng mLastCustomRefreshCenterLocation;
|
||||
|
||||
private IMogoMapService mMogoMapService;
|
||||
private IMogoStatusManager mStatusManager;
|
||||
@@ -328,9 +326,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
|
||||
public void init( Context context ) {
|
||||
|
||||
initWorkThread();
|
||||
|
||||
registerMogoReceiver( context );
|
||||
registerInternalUnWakeupWords();
|
||||
|
||||
@@ -351,19 +346,12 @@ public class MogoServices implements IMogoMapListener,
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_SWITCH_CARD, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_MY_LOCATION, this );
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTION_ADAS_STATUS, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_OPERATION, this );
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTION_VOICE_READY, this );
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTION_MOCK, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_ZHIDAO_NEARBY_CAR_ONLINE, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_ZHIDAO_NEARBY_FRIEND_ONLINE, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_ZHIDAO_NEARBY_FRIEND, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_ZHIDAO_NEARBY_USER_ONLINE, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_ZHIDAO_NEARBY_FRIEND_BYLOCATION, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_BACK, this );
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTION_AUTO_NAVI_RECEIVER, this );
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTION_AUTO_NAVI_SEND, this );
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTION_MOGO, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_ONLINE_CAR_PANEL, this );
|
||||
mIntentManager.registerIntentListener( ConnectivityManager.CONNECTIVITY_ACTION, this );
|
||||
|
||||
mADASController = MarkerServiceHandler.getADASController();
|
||||
@@ -384,44 +372,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
TimeDelayUploadManager.getInstance().init(context);
|
||||
}
|
||||
|
||||
private void initWorkThread() {
|
||||
mThreadHandler = new RefreshWorkThreadHandler( WorkThreadHandler.getInstance().getLooper() ) {
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
//请求大而全数据,刷新地图POI
|
||||
mRefreshModel.refreshExplorerWayData( ro.mLonLat, ro.mRadius, ro.mAmount, ro.mCallback );
|
||||
// if ( !DebugConfig.
|
||||
// isNeedUploadCoordinatesDurationInTime() ) { //todo 实时在线车辆需要注释,否则在2D模式下不能展示
|
||||
// }
|
||||
//请求在线车辆数据,刷新地图在线车辆
|
||||
if (!mLastStatusIsVr){
|
||||
MapMarkerManager.getInstance().getOnlineCarDataByAutoRefreshStrategy( ro.mLonLat );
|
||||
}
|
||||
|
||||
Logger.i( TAG, "刷新半径 = %s, 点 = %s, zoomLevel = %s, amount = %s", ro.mRadius, ro.mLonLat, mLastZoomLevel, ro.mAmount );
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void registerMogoReceiver( Context context ) {
|
||||
if ( context == null ) {
|
||||
return;
|
||||
@@ -545,7 +495,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
|
||||
if ( mIsCameraInited ) {
|
||||
mLastZoomLevel = zoom;
|
||||
mLastCustomRefreshCenterLocation = latLng;
|
||||
mIsCameraInited = false;
|
||||
initMapStatus();
|
||||
return;
|
||||
@@ -554,21 +503,18 @@ public class MogoServices implements IMogoMapListener,
|
||||
// 部分非用户操作导致地图视图变化:绘线、圈点等不触发用户刷新
|
||||
// 消费状态
|
||||
if ( mStatusManager.isUserInteracted() ) {
|
||||
mLastCustomRefreshCenterLocation = latLng;
|
||||
mLastZoomLevel = zoom;
|
||||
return;
|
||||
}
|
||||
|
||||
// v2x // adas 状态下不做任何操作
|
||||
if ( mStatusManager.isV2XShow() ) {
|
||||
mLastCustomRefreshCenterLocation = latLng;
|
||||
mLastZoomLevel = zoom;
|
||||
return;
|
||||
}
|
||||
|
||||
// 搜索页面显示时不做任何策略
|
||||
if ( mStatusManager.isSearchUIShow() ) {
|
||||
mLastCustomRefreshCenterLocation = latLng;
|
||||
mLastZoomLevel = zoom;
|
||||
return;
|
||||
}
|
||||
@@ -577,7 +523,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
if ( mLastZoomLevel - zoom > mCustomRefreshStrategy.getZoomOutLevel() ) {
|
||||
// 缩放级别缩小
|
||||
notifyRefreshData( latLng, getQueryRadius(), mCustomRefreshCallback );
|
||||
mLastCustomRefreshCenterLocation = latLng;
|
||||
mLastZoomLevel = zoom;
|
||||
} else if ( mLastZoomLevel - zoom < 0 ) {
|
||||
mLastZoomLevel = zoom;
|
||||
@@ -602,28 +547,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
return Math.max(radius, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 平移地图刷新策略
|
||||
*/
|
||||
private boolean invokeRefreshWhenTranslationByUser( MogoLatLng latLng ) {
|
||||
try {
|
||||
float factor;
|
||||
if ( mIsVertical ) {
|
||||
factor = getMapCameraFactWidth();
|
||||
} else {
|
||||
factor = getMapCameraFactHeight();
|
||||
}
|
||||
if ( factor == 0.0f ) {
|
||||
return false;
|
||||
}
|
||||
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 ) {
|
||||
|
||||
@@ -899,20 +822,8 @@ public class MogoServices implements IMogoMapListener,
|
||||
MoGoAiCloudRealTime.stopRealTime();
|
||||
}
|
||||
|
||||
public Location getLastCarLocation() {
|
||||
return mLastCarLocation;
|
||||
}
|
||||
|
||||
private boolean mLastStatusIsVr = false;
|
||||
|
||||
public boolean isLastStatusIsVr() {
|
||||
return mLastStatusIsVr;
|
||||
}
|
||||
|
||||
public void setLastStatusIsVr(boolean lastStatusIsVr) {
|
||||
this.mLastStatusIsVr = lastStatusIsVr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapModeChanged( EnumMapUI ui ) {
|
||||
Log.i(TAG, "onMapModeChanged:" + ui + " mLastStatusIsVr:" + mLastStatusIsVr);
|
||||
|
||||
@@ -42,20 +42,11 @@ public class ServiceConst {
|
||||
*/
|
||||
public static final int LOOP_INTERVAL = 10_000;
|
||||
|
||||
/**
|
||||
* 卡片 车聊聊
|
||||
*/
|
||||
public static final String CARD_TYPE_CARS_CHATTING = "CARD_TYPE_CARS_CHATTING";
|
||||
|
||||
/**
|
||||
* 卡片 探路数据
|
||||
*/
|
||||
public static final String CARD_TYPE_ROAD_CONDITION = "CARD_TYPE_ROAD_CONDITION";
|
||||
|
||||
/**
|
||||
* 卡片 分享音乐
|
||||
*/
|
||||
public static final String CARD_TYPE_SHARE_MUSIC = "CARD_TYPE_SHARE_MUSIC";
|
||||
|
||||
/**
|
||||
* 卡片 用户数据
|
||||
@@ -67,11 +58,6 @@ public class ServiceConst {
|
||||
*/
|
||||
public static final String CARD_TYPE_NOVELTY = "CARD_TYPE_NOVELTY";
|
||||
|
||||
/**
|
||||
* 运营位
|
||||
*/
|
||||
public static final String CARD_TYPE_BUSINESS_OPERATION = "CARD_TYPE_BUSINESS_OPERATION";
|
||||
|
||||
/**
|
||||
* 默认地图缩放比例
|
||||
*/
|
||||
@@ -97,10 +83,6 @@ public class ServiceConst {
|
||||
*/
|
||||
public static final int MAX_AMOUNT_ALL = Integer.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* 单个卡片显示时的最大数据量
|
||||
*/
|
||||
public static final int MAX_AMOUNT_SINGLE_CARD = 10;
|
||||
|
||||
/**
|
||||
* 地图变化消息
|
||||
@@ -141,10 +123,6 @@ public class ServiceConst {
|
||||
*/
|
||||
public static final String COMMAND_SWITCH_CARD = "com.zhidao.desk.switchCard";
|
||||
|
||||
/**
|
||||
* 打开/关闭车聊聊
|
||||
*/
|
||||
public static final String COMMAND_OPERATION = "system.application.operation";
|
||||
|
||||
/**
|
||||
* 回到自车
|
||||
@@ -161,41 +139,6 @@ public class ServiceConst {
|
||||
public static final String CMD_BACK = "back";
|
||||
public static final String[] CMD_BACK_WORDS = new String[]{"关闭", "返回"};
|
||||
|
||||
|
||||
/**
|
||||
* 查询附近的人
|
||||
* "data"="{"op":"查询","location":"附近","obj":"人"}"
|
||||
*/
|
||||
public static final String COMMAND_ZHIDAO_NEARBY_CAR_ONLINE = "com.zhidao.nearby.car.online";
|
||||
|
||||
/**
|
||||
* 查询附近的好友
|
||||
* 搜索当前车机所在位置同城市本人有好友关系
|
||||
* (如果一期做不了根据车机所在位置同城查询,则根据车机激活城市查询)
|
||||
* "data"="{"op":"查询","status":"","location":"","obj":"好友"}"
|
||||
*/
|
||||
public static final String COMMAND_ZHIDAO_NEARBY_FRIEND_ONLINE = "com.zhidao.nearby.friend.online";
|
||||
|
||||
/**
|
||||
* 查询在线的好友
|
||||
* "data"="{"op":"查询","status":"在线","obj":"好友"}"
|
||||
*/
|
||||
public static final String COMMAND_ZHIDAO_NEARBY_FRIEND = "com.zhidao.nearby.friend";
|
||||
|
||||
/**
|
||||
* 查询在线的人
|
||||
* <p>
|
||||
* "data"="{"op":"查询","status":"在线","obj":"车主"}"
|
||||
*/
|
||||
public static final String COMMAND_ZHIDAO_NEARBY_USER_ONLINE = "com.zhidao.nearby.user.online";
|
||||
|
||||
/**
|
||||
* 查询指定位置的好友
|
||||
* <p>
|
||||
* "data"="{"op":"看看","obj":"好友","location":"中关村"}"
|
||||
*/
|
||||
public static final String COMMAND_ZHIDAO_NEARBY_FRIEND_BYLOCATION = "com.zhidao.nearby.friend.bylocation";
|
||||
|
||||
/**
|
||||
* 返回桌面
|
||||
*/
|
||||
@@ -204,11 +147,6 @@ public class ServiceConst {
|
||||
public static final int ONLINE_SEARCH_LIMIT = 20;
|
||||
public static final int ONLINE_SEARCH_RADIUS = 2_000;
|
||||
|
||||
/**
|
||||
* 查找目的地车友
|
||||
*/
|
||||
public static final String COMMAND_ONLINE_CAR_PANEL = "com.zhidao.search.riders";
|
||||
|
||||
/**
|
||||
* 导航开始后,延时1分钟开启推送策略
|
||||
*/
|
||||
@@ -219,24 +157,5 @@ public class ServiceConst {
|
||||
*/
|
||||
public static final long INTERVAL_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH = 60 * 1_000L;
|
||||
|
||||
/**
|
||||
* 发送自车位置和adas识别结果给服务端
|
||||
*/
|
||||
public static final int MSG_SEND_CAR_LOCATION_AND_ADAS_RECOGNIZED_RESULT_2_SERVER = 0x401;
|
||||
|
||||
/**
|
||||
* 间隔 1s 发送一次
|
||||
*/
|
||||
public static final long INTERVAL_SEND_CAR_LOCATION_AND_ADAS_RECOGNIZED_RESULT_2_SERVER = 1 * 1_000L;
|
||||
|
||||
/**
|
||||
* adas识别数据
|
||||
*/
|
||||
public static final String TYPE_MARKER_ADAS = "TYPE_MARKER_ADAS";
|
||||
|
||||
/**
|
||||
* 云端下发数据
|
||||
*/
|
||||
public static final String TYPE_MARKER_CLOUD_DATA = "TYPE_MARKER_CLOUD_DATA";
|
||||
|
||||
}
|
||||
|
||||
@@ -38,7 +38,8 @@ public class MogoDataHandler implements IMogoDataManager {
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
public synchronized void registerDataListener( String tag, IMogoDataChangedListener listener ) {
|
||||
@Override
|
||||
public synchronized void registerDataListener(String tag, IMogoDataChangedListener listener ) {
|
||||
if ( listener == null || TextUtils.isEmpty( tag ) ) {
|
||||
return;
|
||||
}
|
||||
@@ -48,7 +49,8 @@ public class MogoDataHandler implements IMogoDataManager {
|
||||
mListeners.get( tag ).add( listener );
|
||||
}
|
||||
|
||||
public synchronized void unregisterListener( String tag, IMogoDataChangedListener listener ) {
|
||||
@Override
|
||||
public synchronized void unregisterListener(String tag, IMogoDataChangedListener listener ) {
|
||||
if ( listener == null || TextUtils.isEmpty( tag ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -6,14 +6,14 @@ import android.content.Intent;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
|
||||
public
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/6/5
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
class AIAssistIntentHandler implements IntentHandler {
|
||||
public class AIAssistIntentHandler implements IntentHandler {
|
||||
|
||||
private static final String TAG = "AIAssistIntentHandler";
|
||||
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
package com.mogo.module.service.intent;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.util.LaunchUtils;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-17
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppOperationIntentHandler implements IntentHandler {
|
||||
|
||||
public final Map< String, String > sAppPackages = new HashMap<>();
|
||||
|
||||
public AppOperationIntentHandler() {
|
||||
// sAppPackages.put( "车聊聊", "com.zhidao.imdemo" );
|
||||
// sAppPackages.put( "VR模式", "" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle( Context context, Intent intent ) {
|
||||
try {
|
||||
JSONObject object = new JSONObject( intent.getStringExtra( "data" ) );
|
||||
String app = object.optString( "object" );
|
||||
String operation = object.optString( "operation" );
|
||||
if ( TextUtils.equals( "打开", operation ) ) {
|
||||
if ( TextUtils.equals( "VR模式", app ) ) {
|
||||
if ( MarkerServiceHandler.getApis().getStatusManagerApi().isMainPageOnResume() ) {
|
||||
MarkerServiceHandler.getApis().getMapFrameControllerApi().changeToVRMode();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ( TextUtils.isEmpty( sAppPackages.get( app ) ) ) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
LaunchUtils.launchByPkg( context, sAppPackages.get( app ) );
|
||||
} catch ( Exception e ) {
|
||||
TipToast.shortTip( "应用程序未安装" );
|
||||
}
|
||||
} else if ( TextUtils.equals( "关闭", operation ) ) {
|
||||
if ( TextUtils.equals( "VR模式", app ) ) {
|
||||
if ( MarkerServiceHandler.getApis().getStatusManagerApi().isMainPageOnResume() ) {
|
||||
MarkerServiceHandler.getApis().getMapFrameControllerApi().changeTo2dMode();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,13 +22,7 @@ public class IntentHandlerFactory {
|
||||
private IntentHandlerFactory() {
|
||||
// private constructor
|
||||
mHandlers.put( MogoReceiver.ACTION_MOCK, new MockIntentHandler() );
|
||||
mHandlers.put( ServiceConst.COMMAND_OPERATION, new AppOperationIntentHandler() );
|
||||
mHandlers.put( ServiceConst.COMMAND_MY_LOCATION, new MyLocationHandler() );
|
||||
mHandlers.put( ServiceConst.COMMAND_ZHIDAO_NEARBY_CAR_ONLINE, OnlineCarSearchIntentHandler.getInstance() );
|
||||
mHandlers.put( ServiceConst.COMMAND_ZHIDAO_NEARBY_FRIEND_ONLINE, OnlineCarSearchIntentHandler.getInstance() );
|
||||
mHandlers.put( ServiceConst.COMMAND_ZHIDAO_NEARBY_FRIEND, OnlineCarSearchIntentHandler.getInstance() );
|
||||
mHandlers.put( ServiceConst.COMMAND_ZHIDAO_NEARBY_USER_ONLINE, OnlineCarSearchIntentHandler.getInstance() );
|
||||
mHandlers.put( ServiceConst.COMMAND_ZHIDAO_NEARBY_FRIEND_BYLOCATION, OnlineCarSearchIntentHandler.getInstance() );
|
||||
mHandlers.put( MogoReceiver.ACTION_VOICE_UI, new VoiceUiIntentHandler() );
|
||||
mHandlers.put( Intent.ACTION_POWER_CONNECTED, AccStatusIntentHandler.getInstance() );
|
||||
mHandlers.put( Intent.ACTION_POWER_DISCONNECTED, AccStatusIntentHandler.getInstance() );
|
||||
@@ -38,7 +32,6 @@ public class IntentHandlerFactory {
|
||||
mHandlers.put( MogoReceiver.ACTION_VOICE_READY, new AIAssistIntentHandler() );
|
||||
mHandlers.put( ServiceConst.COMMAND_BACK, WholeVoiceCommandIntentHandler.getInstance() );
|
||||
mHandlers.put( MogoReceiver.ACTION_MOGO, new MogoControllerIntentHandler() );
|
||||
mHandlers.put( ServiceConst.COMMAND_ONLINE_CAR_PANEL, new OnlineCarPanelIntentHandler() );
|
||||
mHandlers.put( ConnectivityManager.CONNECTIVITY_ACTION, new NetworkChangedIntentHandler() );
|
||||
}
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.mogo.module.service.intent;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.commons.storage.SpStorage;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/9/21
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class OnlineCarPanelIntentHandler implements IntentHandler {
|
||||
|
||||
@Override
|
||||
public void handle( Context context, Intent intent ) {
|
||||
String json = SpStorage.getNavigationTarget();
|
||||
if ( TextUtils.isEmpty( json ) ) {
|
||||
AIAssist.getInstance( context ).speakTTSVoice( "没有导航目的地" );
|
||||
return;
|
||||
}
|
||||
AIAssist.getInstance( context ).speakTTSVoice( "正在查询" );
|
||||
if ( MarkerServiceHandler.getMogoStatusManager().isMainPageOnResume() ) {
|
||||
MarkerServiceHandler.getApis().getOnlineCarPanelApi().showPanel();
|
||||
} else {
|
||||
Intent start = new Intent( Intent.ACTION_VIEW );
|
||||
start.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
|
||||
start.setData( Uri.parse( "mogo://launcher/main/switch2?type=showOnlineCarPanel" ) );
|
||||
context.startActivity( start );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,183 +0,0 @@
|
||||
package com.mogo.module.service.intent;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.map.search.geo.IMogoGeoSearch;
|
||||
import com.mogo.map.search.geo.IMogoGeoSearchListener;
|
||||
import com.mogo.map.search.geo.MogoGeocodeAddress;
|
||||
import com.mogo.map.search.geo.MogoGeocodeResult;
|
||||
import com.mogo.map.search.geo.query.MogoGeocodeQuery;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.mogo.module.service.marker.MapMarkerManager;
|
||||
import com.mogo.module.service.receiver.MogoReceiver;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/6/5
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
class OnlineCarSearchIntentHandler implements IntentHandler {
|
||||
|
||||
private static final String TAG = "OnlineCarSearchIntentHandler";
|
||||
|
||||
private static volatile OnlineCarSearchIntentHandler sInstance;
|
||||
|
||||
private OnlineCarSearchIntentHandler() {
|
||||
}
|
||||
|
||||
public static OnlineCarSearchIntentHandler getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( OnlineCarSearchIntentHandler.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new OnlineCarSearchIntentHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle( Context context, Intent intent ) {
|
||||
|
||||
if ( DebugConfig.isNeedUploadCoordinatesDurationInTime() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
String command = intent.getStringExtra( MogoReceiver.PARAM_COMMAND );
|
||||
if ( TextUtils.isEmpty( command ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
MogoLocation location = MarkerServiceHandler.getMogoLocationClient().getLastKnowLocation();
|
||||
MogoLatLng target = null;
|
||||
if ( location != null ) {
|
||||
target = new MogoLatLng( location.getLatitude(), location.getLongitude() );
|
||||
}
|
||||
boolean isFocus = false;
|
||||
boolean isSameCity = false;
|
||||
switch ( command ) {
|
||||
case ServiceConst.COMMAND_ZHIDAO_NEARBY_FRIEND:
|
||||
case ServiceConst.COMMAND_ZHIDAO_NEARBY_USER_ONLINE:
|
||||
isFocus = true;
|
||||
isSameCity = true;
|
||||
case ServiceConst.COMMAND_ZHIDAO_NEARBY_CAR_ONLINE:
|
||||
case ServiceConst.COMMAND_ZHIDAO_NEARBY_FRIEND_ONLINE:
|
||||
Logger.d( TAG, "搜索附近的好友/在线车辆" );
|
||||
doDataRequest(
|
||||
target,
|
||||
isFocus,
|
||||
isSameCity,
|
||||
ServiceConst.ONLINE_SEARCH_LIMIT,
|
||||
ServiceConst.ONLINE_SEARCH_RADIUS );
|
||||
break;
|
||||
case ServiceConst.COMMAND_ZHIDAO_NEARBY_FRIEND_BYLOCATION:
|
||||
handleAreaSearch( intent, context, target );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleAreaSearch( Intent intent, Context context, MogoLatLng target ) {
|
||||
String data = intent.getStringExtra( "data" );
|
||||
if ( TextUtils.isEmpty( data ) ) {
|
||||
Logger.e( TAG, "语音没有携带数据!!!!!" );
|
||||
return;
|
||||
}
|
||||
String keyword = null;
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject( data );
|
||||
keyword = jsonObject.get( "location" ).toString();
|
||||
Logger.d( TAG, "location 查询指定位置的好友 keyword = " + keyword );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, "语音携带数据异常!!!!!" );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( TextUtils.isEmpty( keyword ) ) {
|
||||
Logger.e( TAG, "语音携带数据为空!!!!!" );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( TextUtils.equals( "附近", keyword ) ) {
|
||||
doDataRequest(
|
||||
target,
|
||||
false,
|
||||
false,
|
||||
ServiceConst.ONLINE_SEARCH_LIMIT,
|
||||
ServiceConst.ONLINE_SEARCH_RADIUS );
|
||||
} else {
|
||||
String cityCode = MarkerServiceHandler.getMogoLocationClient().getLastKnowLocation().getCityCode();
|
||||
IMogoGeoSearch search = MarkerServiceHandler.getMapService().getGeoSearch( context );
|
||||
search.setGeoSearchListener( new IMogoGeoSearchListener() {
|
||||
@Override
|
||||
public void onGeocodeSearched( MogoGeocodeResult geocodeResult ) {
|
||||
MogoLatLng target = getGeoTargetAddress( geocodeResult );
|
||||
if ( target == null ) {
|
||||
Logger.e( TAG, "geo 检索位置错误" );
|
||||
return;
|
||||
}
|
||||
doDataRequest(
|
||||
target,
|
||||
false,
|
||||
false,
|
||||
ServiceConst.ONLINE_SEARCH_LIMIT,
|
||||
ServiceConst.ONLINE_SEARCH_RADIUS );
|
||||
}
|
||||
} );
|
||||
MogoGeocodeQuery mogoGeocodeQuery = new MogoGeocodeQuery();
|
||||
mogoGeocodeQuery.setCity( cityCode );
|
||||
mogoGeocodeQuery.setLocationName( keyword );
|
||||
search.getFromLocationNameAsyn( mogoGeocodeQuery );
|
||||
}
|
||||
}
|
||||
|
||||
private MogoLatLng getGeoTargetAddress( MogoGeocodeResult geocodeResult ) {
|
||||
if ( geocodeResult == null
|
||||
|| geocodeResult.getAddresses() == null
|
||||
|| geocodeResult.getAddresses().isEmpty() ) {
|
||||
return null;
|
||||
}
|
||||
for ( MogoGeocodeAddress address : geocodeResult.getAddresses() ) {
|
||||
if ( address == null ) {
|
||||
continue;
|
||||
}
|
||||
if ( address.getLatlng() == null ) {
|
||||
continue;
|
||||
}
|
||||
return address.getLatlng();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void doDataRequest( MogoLatLng target,
|
||||
boolean onlyFocus,
|
||||
boolean onlySameCity,
|
||||
int limit,
|
||||
int radius ) {
|
||||
MarkerServiceHandler.getApis().getRefreshStrategyControllerApi().restartAutoRefreshAtTime( 30_000 );
|
||||
MarkerServiceHandler.getMogoStatusManager().setUserInteractionStatus( TAG, true, false );
|
||||
if(!MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode()){
|
||||
MarkerServiceHandler.getMapUIController().moveToCenter( target );
|
||||
}
|
||||
MapMarkerManager.getInstance().getOnlineCarDataByVoiceControl(
|
||||
target,
|
||||
onlyFocus,
|
||||
onlySameCity,
|
||||
limit,
|
||||
radius );
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.ResourcesHelper;
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadPoolService;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.eagle.core.utilcode.util.ViewUtils;
|
||||
@@ -19,7 +20,6 @@ import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.module.common.api.CallChatApi;
|
||||
import com.mogo.module.common.drawer.MarkerDrawer;
|
||||
import com.mogo.module.common.drawer.OnlineCarDrawer;
|
||||
import com.mogo.module.common.drawer.RoadConditionDrawer;
|
||||
import com.mogo.module.common.drawer.marker.IMarkerView;
|
||||
import com.mogo.module.common.drawer.marker.MapMarkerAdapter;
|
||||
@@ -39,7 +39,6 @@ import com.mogo.realtime.api.MoGoAiCloudRealTime;
|
||||
import com.mogo.realtime.socket.IMogoCloudOnMsgListener;
|
||||
import com.mogo.service.adas.IMogoADASControlStatusChangedListener;
|
||||
import com.mogo.service.module.IMogoBizActionDoneListener;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.ResourcesHelper;
|
||||
import com.zhidao.carchattingprovider.ICallChatResponse;
|
||||
|
||||
import org.json.JSONArray;
|
||||
@@ -555,32 +554,6 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
mCarLatLng = new MogoLatLng(lat, lon);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据经纬度请求数据
|
||||
*
|
||||
* @param latlng
|
||||
*/
|
||||
public void getOnlineCarDataByAutoRefreshStrategy(MogoLatLng latlng) {
|
||||
UiThreadHandler.removeCallbacks(runnable);
|
||||
getOnlineCarDataImpl(latlng, false, false, ServiceConst.ONLINE_SEARCH_LIMIT, ServiceConst.ONLINE_SEARCH_RADIUS, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param latLng
|
||||
* @param onlyFocus
|
||||
* @param onlySameCity
|
||||
* @param limit
|
||||
* @param radius
|
||||
*/
|
||||
public void getOnlineCarDataByVoiceControl(MogoLatLng latLng,
|
||||
boolean onlyFocus,
|
||||
boolean onlySameCity,
|
||||
int limit,
|
||||
int radius) {
|
||||
UiThreadHandler.removeCallbacks(runnable);
|
||||
getOnlineCarDataImpl(latLng, onlyFocus, onlySameCity, limit, radius, true);
|
||||
}
|
||||
|
||||
private final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -662,7 +635,6 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
|
||||
runOnTargetThread(() -> {
|
||||
trackData(size);
|
||||
OnlineCarDrawer.getInstance().drawOnlineCarMarkers(onlineCarList, Integer.MAX_VALUE, fitBounds, fitBounds, mMarkerDisplayBounds, latLng, MapMarkerManager.this);
|
||||
UiThreadHandler.postDelayed(runnable, SMOOTH_DURATION * 1000);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
package com.mogo.module.service.mocktools;
|
||||
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.thread.WorkThreadHandler;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class DataCollectionHandler {
|
||||
|
||||
private static volatile DataCollectionHandler handler;
|
||||
private static final byte[] obj = new byte[0];
|
||||
private volatile boolean openDataCollect = false;
|
||||
|
||||
private Handler mLocationDataCollectHandler;
|
||||
private Handler mRecognizeDataCollectHandler;
|
||||
|
||||
private static final String WRITE_FILE_PATH = Environment.getExternalStorageDirectory().getPath() + File.separator + "mockWrite";
|
||||
|
||||
private DataCollectionHandler() {
|
||||
|
||||
}
|
||||
|
||||
public static DataCollectionHandler getInstance() {
|
||||
if (handler == null) {
|
||||
synchronized (obj) {
|
||||
if (handler == null) {
|
||||
handler = new DataCollectionHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
return handler;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
openDataCollect = true;
|
||||
}
|
||||
|
||||
public boolean canCollectData() {
|
||||
return openDataCollect;
|
||||
}
|
||||
|
||||
public void collectLocationDataToFile(String locationData) {
|
||||
if (mLocationDataCollectHandler == null) {
|
||||
mLocationDataCollectHandler = new Handler(WorkThreadHandler.newInstance("data-collect-thread").getLooper()) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public void collectRecogniseDataToFile() {
|
||||
if (mRecognizeDataCollectHandler == null) {
|
||||
mRecognizeDataCollectHandler = new Handler(WorkThreadHandler.newInstance("recognize-collect-thread").getLooper()) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
openDataCollect = false;
|
||||
mLocationDataCollectHandler = null;
|
||||
mRecognizeDataCollectHandler = null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package com.mogo.module.service.polyline;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description 前车碰撞的画线
|
||||
* @since 2021/4/25
|
||||
*/
|
||||
public class LimberCollisionPolyline {
|
||||
|
||||
private volatile static LimberCollisionPolyline mInstance = null;
|
||||
|
||||
private IMogoPolyline mMoGoPolyline;
|
||||
// 连接线参数
|
||||
private MogoPolylineOptions mPolylineOptions;
|
||||
// 线路径集合
|
||||
private List<MogoLatLng> mPolylinePointList;
|
||||
|
||||
|
||||
public static LimberCollisionPolyline getInstance() {
|
||||
if (mInstance == null) {
|
||||
synchronized (LimberCollisionPolyline.class) {
|
||||
if (mInstance == null) {
|
||||
mInstance = new LimberCollisionPolyline();
|
||||
}
|
||||
}
|
||||
}
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
protected LimberCollisionPolyline() {
|
||||
mPolylineOptions = new MogoPolylineOptions();
|
||||
// 绘制路径集合
|
||||
mPolylinePointList = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
public IMogoPolyline draw(float width, List<MogoLatLng> polylinePoint) {
|
||||
try {
|
||||
if (mMoGoPolyline != null) {
|
||||
mMoGoPolyline.remove();
|
||||
mPolylinePointList.clear();
|
||||
}
|
||||
|
||||
// 连接线参数
|
||||
MogoPolylineOptions options = new MogoPolylineOptions();
|
||||
|
||||
// 渐变色
|
||||
List<Integer> colors = new ArrayList<>();
|
||||
// colors.add(0x0DE32F46);
|
||||
colors.add(0xD9E32F46);
|
||||
colors.add(0x0DE32F46);
|
||||
|
||||
// 线条粗细,渐变,渐变色值 TODO liyz 宽度需要传过来
|
||||
options.width(60).useGradient(true).colorValues(colors);
|
||||
for (int i = 0; i < polylinePoint.size(); i++) {
|
||||
options.add(polylinePoint.get(i));
|
||||
}
|
||||
// 绘制线的对象
|
||||
mMoGoPolyline = MarkerServiceHandler.getsIMogoOverlayManager().addPolyline(options);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return mMoGoPolyline;
|
||||
}
|
||||
|
||||
|
||||
public IMogoPolyline getPolyLine() {
|
||||
return mMoGoPolyline;
|
||||
}
|
||||
|
||||
public void clearLine() {
|
||||
if (mMoGoPolyline != null) {
|
||||
mMoGoPolyline.remove();
|
||||
mMoGoPolyline = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,161 +0,0 @@
|
||||
package com.mogo.module.service.status;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.wm.WindowManagerView;
|
||||
import com.mogo.module.service.R;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.util.CommonUtils.getVersionName;
|
||||
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2021/3/17
|
||||
*
|
||||
* 环境状态
|
||||
*/
|
||||
public class EnvStatusManager {
|
||||
|
||||
private static volatile EnvStatusManager sInstance;
|
||||
|
||||
private EnvStatusManager() {
|
||||
}
|
||||
|
||||
public static EnvStatusManager getInstance() {
|
||||
if (sInstance == null) {
|
||||
synchronized (EnvStatusManager.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new EnvStatusManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private WindowManagerView mPanelView;
|
||||
private TextView mStatusTv;
|
||||
private final Handler mMainHandler = new Handler(Looper.getMainLooper()) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (mPanelView.isShowing()) {
|
||||
renderStatus();
|
||||
mMainHandler.sendEmptyMessageDelayed(MSG, 5_000L);
|
||||
}
|
||||
}
|
||||
};
|
||||
public static final int MSG = 10000;
|
||||
|
||||
private void renderStatus() {
|
||||
String[] sStatusName = {
|
||||
"工控机定位",
|
||||
"ADAS近景感知",
|
||||
"云端远景感知",
|
||||
"自动驾驶状态",
|
||||
"socket长链",
|
||||
"经度",
|
||||
"纬度",
|
||||
"网络状态",
|
||||
"App版本",
|
||||
"Map版本",
|
||||
"SN",
|
||||
"OBU状态",
|
||||
"HV状态",
|
||||
"RV状态"
|
||||
};
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int i = 0; i < sStatusName.length; i++) {
|
||||
stringBuilder.append(sStatusName[i]).append(":");
|
||||
if (i == 3) {
|
||||
stringBuilder.append(DebugConfig.getAutoPilotStatus()).append("\n");
|
||||
} else if (i == 4) {
|
||||
stringBuilder.append(DebugConfig.isDownloadSnapshot() ? "正常" : "异常").append("\n");
|
||||
} else if (i == 5 || i == 6) {
|
||||
stringBuilder.append(DebugConfig.getStatusData(i)).append("\n");
|
||||
} else if (i == 7) {
|
||||
stringBuilder.append(NetworkUtils.isConnected(mContext)).append("\n");
|
||||
} else if (i == 8) {
|
||||
stringBuilder.append(getVersionName(mContext, "com.mogo.launcher.f")).append("\n");
|
||||
} else if (i == 9) {
|
||||
String mapVersion = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapVersion();
|
||||
if (!TextUtils.isEmpty(mapVersion)) {
|
||||
stringBuilder.append(mapVersion).append("\n");
|
||||
}
|
||||
} else if(i == 10){
|
||||
stringBuilder.append(MoGoAiCloudClientConfig.getInstance().getSn()).append("\n");
|
||||
} else if (i == 11) {
|
||||
boolean isObuConnect = SharedPrefsMgr.getInstance(mContext).getBoolean("OBU", false);
|
||||
stringBuilder.append(isObuConnect == true ? "已连接" : "未连接").append("\n");
|
||||
} else if (i == 12) {
|
||||
boolean isHv = SharedPrefsMgr.getInstance( mContext ).getBoolean("OBU_HV", false );
|
||||
stringBuilder.append(isHv == true ? "已连接" : "未连接").append("\n");
|
||||
} else if (i == 13) {
|
||||
boolean isRv = SharedPrefsMgr.getInstance( mContext ).getBoolean("OBU_RV", false );
|
||||
stringBuilder.append(isRv == true ? "已连接" : "未连接").append("\n");
|
||||
} else {
|
||||
stringBuilder.append("true".equals(DebugConfig.getStatus(i, true)) ? "正常" : "异常").append("\n");
|
||||
}
|
||||
}
|
||||
mStatusTv.setText(stringBuilder);
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
mStatusTv.setTextColor(Color.WHITE);
|
||||
} else {
|
||||
if (MogoApisHandler.getInstance().getApis().getAdasControllerApi()
|
||||
.getCurrentSkinMode() == EnumMapUI.Type_Light) {
|
||||
mStatusTv.setTextColor(Color.BLACK);
|
||||
} else {
|
||||
mStatusTv.setTextColor(Color.WHITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Context mContext;
|
||||
|
||||
public void showPanel(Context context) {
|
||||
mContext = context;
|
||||
if (mPanelView == null) {
|
||||
mPanelView = new WindowManagerView.Builder(context)
|
||||
.contentView(R.layout.module_services_status_panel)
|
||||
.position(0, 100)
|
||||
.size(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
.gravity(Gravity.TOP)
|
||||
.showInWindowManager();
|
||||
mPanelView.attachTouchEvent(((view, xPos, yPos) -> closePanel()));
|
||||
mPanelView.findViewById(R.id.module_services_status_iv).setOnClickListener(view -> closePanel());
|
||||
mStatusTv = mPanelView.findViewById(R.id.module_services_status_tv);
|
||||
}
|
||||
mPanelView.show();
|
||||
mMainHandler.sendEmptyMessageDelayed(MSG, 0L);
|
||||
}
|
||||
|
||||
public void closePanel() {
|
||||
if (mPanelView != null) {
|
||||
mPanelView.dismiss();
|
||||
mMainHandler.removeMessages(MSG);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.mogo.module.service.utils;
|
||||
|
||||
import android.location.Location;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.service.cloud.location.CloudLocationInfo;
|
||||
|
||||
@@ -11,25 +9,6 @@ import com.mogo.service.cloud.location.CloudLocationInfo;
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class LocationParseUtil {
|
||||
/**
|
||||
* 从Location 转 CloudLocationInfo
|
||||
* @param info 待转数据
|
||||
* @return 转后数据
|
||||
*/
|
||||
public static CloudLocationInfo locationToCloudLocation(Location info) {
|
||||
if (info == null) {
|
||||
return null;
|
||||
}
|
||||
CloudLocationInfo cloud = new CloudLocationInfo();
|
||||
cloud.setLat(info.getLatitude());
|
||||
cloud.setLon(info.getLongitude());
|
||||
cloud.setAlt(info.getAltitude());
|
||||
cloud.setHeading(info.getBearing());
|
||||
cloud.setSpeed(info.getSpeed());
|
||||
cloud.setSatelliteTime(info.getTime());
|
||||
cloud.setSystemTime(System.currentTimeMillis());
|
||||
return cloud;
|
||||
}
|
||||
|
||||
public static MogoLatLng cloudLocationToMogoLatLng(CloudLocationInfo info) {
|
||||
if (info == null) {
|
||||
|
||||
@@ -1,256 +0,0 @@
|
||||
package com.mogo.module.service.utils;
|
||||
|
||||
import android.os.SystemClock;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.service.cloud.location.CloudLocationInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 定位预测纠错策略
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class SimpleLocationCorrectStrategy {
|
||||
private static final String TAG = "SimpleLocationCorrectStrategy";
|
||||
private static final int ERR_COUNT_THRESHOLD = 3;
|
||||
/**
|
||||
* 目标距离误差是10米,就是在原目标距离基础上增加10米
|
||||
*/
|
||||
private static final float TARGET_DISTANCE_DEVIATION = 10;
|
||||
|
||||
private CloudLocationInfo lastLocation = null;
|
||||
private long anchorTime;
|
||||
private int errCount;
|
||||
|
||||
private static final SimpleLocationCorrectStrategy instance = new SimpleLocationCorrectStrategy();
|
||||
|
||||
public static SimpleLocationCorrectStrategy getInstance(){
|
||||
return instance;
|
||||
}
|
||||
|
||||
private final List<CloudLocationInfo> historyList = new ArrayList<>();
|
||||
private final List<CloudLocationInfo> validList = new ArrayList<>();
|
||||
private final List<CloudLocationInfo> correctList = new ArrayList<>();
|
||||
private final List<CloudLocationInfo> errList = new ArrayList<>();
|
||||
|
||||
public CloudLocationInfo correct(CloudLocationInfo info) {
|
||||
Logger.d(TAG, "info: " + info.print());
|
||||
if(isLocationValid(info)) {
|
||||
if(recordLocation()) {
|
||||
historyList.add(info);
|
||||
}
|
||||
|
||||
if (lastLocation == null) {
|
||||
lastLocation = info;
|
||||
anchorTime = SystemClock.elapsedRealtime();
|
||||
Logger.d(TAG, "第一条数据");
|
||||
if(recordLocation()) {
|
||||
validList.add(lastLocation);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
if (lastLocation.equals(info)) {
|
||||
Logger.d(TAG, "相同坐标点==");
|
||||
return info;
|
||||
}
|
||||
try {
|
||||
float targetDistance =
|
||||
(float) (lastLocation.getSpeed() * (SystemClock.elapsedRealtime() - anchorTime) / 1000) + TARGET_DISTANCE_DEVIATION;
|
||||
float distance = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().calculateLineDistance(LocationParseUtil.cloudLocationToMogoLatLng(lastLocation), LocationParseUtil.cloudLocationToMogoLatLng(info));
|
||||
Logger.d(TAG,
|
||||
"准备计算{ lastInfo: " + lastLocation.print() + " info: " + info.print() + " targetDistance: " + targetDistance + " distance : " + distance + "}");
|
||||
if (distance <= targetDistance) {
|
||||
// 新的定位点在目标距离范围内,认为此数据有效
|
||||
lastLocation = info;
|
||||
anchorTime = SystemClock.elapsedRealtime();
|
||||
errCount = 0;
|
||||
Logger.d(TAG, "在范围内,为有效点");
|
||||
if(recordLocation()) {
|
||||
validList.add(lastLocation);
|
||||
}
|
||||
return info;
|
||||
} else {
|
||||
// 出现异常点
|
||||
if (errCount >= ERR_COUNT_THRESHOLD) {
|
||||
// 出错次数超过阈值,认为本次出错点为正确点
|
||||
if(recordLocation()) {
|
||||
errList.add(new CloudLocationInfo(lastLocation));
|
||||
correctList.add(info);
|
||||
}
|
||||
lastLocation = info;
|
||||
anchorTime = SystemClock.elapsedRealtime();
|
||||
errCount = 0;
|
||||
Logger.d(TAG, "出错次数超限,异常点变有效点");
|
||||
return info;
|
||||
} else {
|
||||
// 按照上一个点的方向和速度,计算下一个点的位置,下一个点除坐标点外,其余数据与上一个点相同
|
||||
CloudLocationInfo nextInfo = new CloudLocationInfo(lastLocation);
|
||||
MogoLatLng nextLatLon = computerThatLonLat(lastLocation.getLon(),
|
||||
lastLocation.getLat(), lastLocation.getHeading(), targetDistance);
|
||||
nextInfo.setLon(nextLatLon.lon);
|
||||
nextInfo.setLat(nextLatLon.lat);
|
||||
if(recordLocation()) {
|
||||
errList.add(info);
|
||||
correctList.add(nextInfo);
|
||||
}
|
||||
lastLocation = nextInfo;
|
||||
anchorTime = SystemClock.elapsedRealtime();
|
||||
errCount++;
|
||||
Logger.d(TAG, "异常点纠偏 info: " + lastLocation);
|
||||
// return lastLocation;
|
||||
if(recordLocation()) {
|
||||
correctList.add(nextInfo);
|
||||
}
|
||||
return nextInfo;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.e(TAG, e, "纠偏异常");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else{
|
||||
Logger.d(TAG, "定位点异常");
|
||||
if (lastLocation == null) {
|
||||
return null;
|
||||
}else{
|
||||
try {
|
||||
float targetDistance =
|
||||
(float) (lastLocation.getSpeed() * (SystemClock.elapsedRealtime() - anchorTime) / 1000) + TARGET_DISTANCE_DEVIATION;
|
||||
float distance = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().calculateLineDistance(LocationParseUtil.cloudLocationToMogoLatLng(lastLocation), LocationParseUtil.cloudLocationToMogoLatLng(info));
|
||||
Logger.d(TAG,
|
||||
"异常定位点\n准备计算{ lastInfo: " + lastLocation.print() + " info: " + info.print() + " targetDistance: " + targetDistance + " distance : " + distance + "}");
|
||||
// 按照上一个点的方向和速度,计算下一个点的位置,下一个点除坐标点外,其余数据与上一个点相同
|
||||
CloudLocationInfo nextInfo = new CloudLocationInfo(lastLocation);
|
||||
MogoLatLng nextLatLon = computerThatLonLat(lastLocation.getLon(),
|
||||
lastLocation.getLat(), lastLocation.getHeading(), targetDistance);
|
||||
nextInfo.setLon(nextLatLon.lon);
|
||||
nextInfo.setLat(nextLatLon.lat);
|
||||
if(recordLocation()) {
|
||||
errList.add(info);
|
||||
correctList.add(nextInfo);
|
||||
}
|
||||
lastLocation = nextInfo;
|
||||
anchorTime = SystemClock.elapsedRealtime();
|
||||
errCount++;
|
||||
Logger.d(TAG, "异常点纠偏 info: " + lastLocation);
|
||||
if(recordLocation()) {
|
||||
correctList.add(nextInfo);
|
||||
}
|
||||
// return lastLocation;
|
||||
return nextInfo;
|
||||
}catch (Exception e){
|
||||
Logger.e(TAG, e, "纠偏异常");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isLocationValid(CloudLocationInfo info) {
|
||||
return info.getLat() != 0 && info.getLon() != 0;
|
||||
}
|
||||
|
||||
private RecordLocationListener recordLocationListener = null;
|
||||
private boolean hasCallbackRecord = false;
|
||||
|
||||
public void setRecordLocationListener(RecordLocationListener recordLocationListener) {
|
||||
this.recordLocationListener = recordLocationListener;
|
||||
}
|
||||
|
||||
private boolean recordLocation(){
|
||||
if (historyList.size() >= 100 && !hasCallbackRecord && recordLocationListener != null) {
|
||||
hasCallbackRecord = true;
|
||||
recordLocationListener.onRecordFinish(historyList, correctList,validList,correctList);
|
||||
}
|
||||
return historyList.size() < 100;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据距离和角度计算下一个经纬度
|
||||
* 大地坐标系资料WGS-84 长半径a=6378137 短半径b=6356752.3142 扁率f=1/298.2572236
|
||||
*/
|
||||
public MogoLatLng computerThatLonLat(double lon, double lat, double brng, double dist) {
|
||||
|
||||
double alpha1 = rad(brng);
|
||||
double sinAlpha1 = Math.sin(alpha1);
|
||||
double cosAlpha1 = Math.cos(alpha1);
|
||||
|
||||
// 扁率f=1/298.2572236
|
||||
double f = 1 / 298.2572236;
|
||||
double tanU1 = (1 - f) * Math.tan(rad(lat));
|
||||
double cosU1 = 1 / Math.sqrt((1 + tanU1 * tanU1));
|
||||
double sinU1 = tanU1 * cosU1;
|
||||
double sigma1 = Math.atan2(tanU1, cosAlpha1);
|
||||
double sinAlpha = cosU1 * sinAlpha1;
|
||||
double cosSqAlpha = 1 - sinAlpha * sinAlpha;
|
||||
// 长半径a=6378137
|
||||
double a = 6378137;
|
||||
// 短半径b=6356752.3142
|
||||
double b = 6356752.3142;
|
||||
double uSq = cosSqAlpha * (a * a - b * b) / (b * b);
|
||||
double A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
|
||||
double B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
|
||||
|
||||
double cos2SigmaM=0;
|
||||
double sinSigma=0;
|
||||
double cosSigma=0;
|
||||
double sigma = dist / (b * A), sigmaP = 2 * Math.PI;
|
||||
while (Math.abs(sigma - sigmaP) > 1e-12) {
|
||||
cos2SigmaM = Math.cos(2 * sigma1 + sigma);
|
||||
sinSigma = Math.sin(sigma);
|
||||
cosSigma = Math.cos(sigma);
|
||||
double deltaSigma = B * sinSigma * (cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)
|
||||
- B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM)));
|
||||
sigmaP = sigma;
|
||||
sigma = dist / (b * A) + deltaSigma;
|
||||
}
|
||||
|
||||
double tmp = sinU1 * sinSigma - cosU1 * cosSigma * cosAlpha1;
|
||||
double lat2 = Math.atan2(sinU1 * cosSigma + cosU1 * sinSigma * cosAlpha1,
|
||||
(1 - f) * Math.sqrt(sinAlpha * sinAlpha + tmp * tmp));
|
||||
double lambda = Math.atan2(sinSigma * sinAlpha1, cosU1 * cosSigma - sinU1 * sinSigma * cosAlpha1);
|
||||
double C = f / 16 * cosSqAlpha * (4 + f * (4 - 3 * cosSqAlpha));
|
||||
double L = lambda - (1 - C) * f * sinAlpha
|
||||
* (sigma + C * sinSigma * (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)));
|
||||
|
||||
// final bearing
|
||||
double revAz = Math.atan2(sinAlpha, -tmp);
|
||||
|
||||
System.out.println(revAz);
|
||||
System.out.println(lon+deg(L)+","+deg(lat2));
|
||||
return new MogoLatLng(deg(lat2), lon + deg(L));
|
||||
}
|
||||
|
||||
/**
|
||||
* 度换成弧度
|
||||
*
|
||||
* @param d
|
||||
* 度
|
||||
* @return 弧度
|
||||
*/
|
||||
private double rad(double d) {
|
||||
return d * Math.PI / 180.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 弧度换成度
|
||||
*
|
||||
* @param x
|
||||
* 弧度
|
||||
* @return 度
|
||||
*/
|
||||
private double deg(double x) {
|
||||
return x * 180 / Math.PI;
|
||||
}
|
||||
|
||||
public interface RecordLocationListener{
|
||||
void onRecordFinish(List<CloudLocationInfo> history, List<CloudLocationInfo> correct,List<CloudLocationInfo> valid,List<CloudLocationInfo> err);
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
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.eagle.core.utilcode.mogo.logger.Logger;
|
||||
|
||||
public
|
||||
/*
|
||||
* @author congtaowang
|
||||
* @since 2020/10/27
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class VrModeController {
|
||||
|
||||
private static final String TAG = "VrModeController";
|
||||
|
||||
private static volatile VrModeController sInstance;
|
||||
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;
|
||||
}
|
||||
|
||||
private boolean mIsBinding = false;
|
||||
|
||||
public void onVrModeChanged( boolean isVrMode ) {
|
||||
if ( isVrMode ) {
|
||||
bindVrModeService();
|
||||
} else {
|
||||
unbindVrModeService();
|
||||
}
|
||||
}
|
||||
|
||||
private void bindVrModeService() {
|
||||
if ( mIsBinding ) {
|
||||
return;
|
||||
}
|
||||
mIsBinding = true;
|
||||
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 ) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected( ComponentName name ) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindingDied( ComponentName name ) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNullBinding( ComponentName name ) {
|
||||
}
|
||||
}, Context.BIND_AUTO_CREATE );
|
||||
}
|
||||
|
||||
private void unbindVrModeService() {
|
||||
mIsBinding = false;
|
||||
if ( mServiceConnection != null ) {
|
||||
try {
|
||||
AbsMogoApplication.getApp().unbindService( mServiceConnection );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "unbindVrModeService" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onMainPageResumeStatusChanged( boolean isResume ) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user