[2.12.0] local code style change

This commit is contained in:
zhongchao
2022-11-08 11:03:10 +08:00
parent 39ececd4d7
commit fbe1801488
200 changed files with 4306 additions and 5612 deletions

View File

@@ -1,21 +1,12 @@
package com.mogo.module.common.drawer;
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_ADAS;
import android.content.Context;
import android.text.TextUtils;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.module.common.R;
import com.mogo.module.common.constants.AdasRecognizedType;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author congtaowang
* @since 2020/10/30
@@ -24,67 +15,12 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class BaseDrawer {
/**
* 移除过期的 marker
*/
public static final int MSG_REMOVE_DIRTY_MARKERS = 9990;
/**
* 地图内部资源md5缓存便于资源复用
*/
protected static final ConcurrentHashMap<String, String> mMarkerCachesResMd5Values = new ConcurrentHashMap<>();
protected final Context mContext;
public BaseDrawer() {
mContext = AbsMogoApplication.getApp();
}
/**
* 清除无效[为 null 或者 已被销毁]的 marker
*/
protected void removeUselessMarker(Map<String, IMogoMarker> mMarkersCaches) {
if (mMarkersCaches == null || mMarkersCaches.isEmpty()) {
return;
}
Iterator<IMogoMarker> iterator = mMarkersCaches.values().iterator();
while (iterator.hasNext()) {
IMogoMarker marker = iterator.next();
if (marker != null) {
iterator.remove();
marker.remove();
marker.destroy();
}
}
}
/**
* 发送消息
*
* @param msg 消息类型
* @param data 数据体
*/
public void sendMessage(int msg, Object data) {
}
/**
* 判断是否是绘制内容
*
* @param type {@link AdasRecognizedType}
* @return render
*/
public boolean nonRenderType(int type) {
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom(type);
return recognizedType != AdasRecognizedType.classIdCar
&& recognizedType != AdasRecognizedType.classIdMoto
&& recognizedType != AdasRecognizedType.classIdBicycle
&& recognizedType != AdasRecognizedType.classIdPerson
&& recognizedType != AdasRecognizedType.classIdTrafficBus
&& recognizedType != AdasRecognizedType.classIdTrafficTruck
&& recognizedType != AdasRecognizedType.classIdUnKnow;
}
/**
* 获取3D锚点模型资源
*
@@ -115,118 +51,4 @@ public class BaseDrawer {
return R.raw.special_vehicle;
}
/**
* 根据数据源判断车辆预警颜色
*
* @param type 车辆类型
* @param fromType 数据来源
* @param drawLevel 危险等级
* @return 实际车辆颜色
*/
protected String getModelRenderColor(int type, int fromType, int drawLevel) {
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom(type);
if (recognizedType == AdasRecognizedType.classIdUnKnow) {
return Car3DModelColor.Normal.color;
}
if (fromType == FROM_ADAS) {
switch (drawLevel) {
case 0:
case 1:
return Car3DModelColor.Normal.color;
case 2:
return Car3DModelColor.Warming.color;
case 3:
return Car3DModelColor.Dangerous.color;
default:
return Car3DModelColor.Error.color;
}
}
return Car3DModelColor.Normal.color;
}
/**
* 返回当前自车经纬度
*
* @return 0:lon 1:lat
*/
protected double[] getCurCoordinates() {
return new double[]{
CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84Lon(),
CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84Lat()
};
}
/**
* 模型颜色
*/
public enum Car3DModelColor {
Normal("#D8D8D8FF"),
Warming("#FFD53EFF"),
Dangerous("#FF3C45FF"),
Error("#7fb80e");
private final String color;
Car3DModelColor(String color) {
this.color = color;
}
}
/**
* 移除markers
*
* @param dirtyMarkers 缓存marker数据
*/
protected static void removeDirtyMarkers(Map<String, IMogoMarker> dirtyMarkers) {
if (dirtyMarkers == null || dirtyMarkers.isEmpty()) {
return;
}
final Collection<IMogoMarker> dirSet = dirtyMarkers.values();
for (IMogoMarker value : dirSet) {
if (value == null || value.isDestroyed()) {
continue;
}
try {
value.destroy();
} catch (Exception e) {
e.printStackTrace();
}
}
dirtyMarkers.clear();
}
/**
* 缓存绘制 marker 的 id 和 marker 资源缓存的 md5 的关系
*
* @param id 缓存资源ID
* @param marker {@link IMogoMarker}
*/
protected static void cacheMarkerIconResMd5Val(String id, IMogoMarker marker) {
if (marker == null || marker.isDestroyed()) {
return;
}
String md5 = marker.getMarkerResName();
if (TextUtils.isEmpty(md5) || TextUtils.isEmpty(id)) {
return;
}
mMarkerCachesResMd5Values.put(id, md5);
}
/**
* 使用系统时间或卫星时间计算出动画的运动时间最小值45防止两个点距离过近设置的最小动画执行时间
*
* @param lastSatelliteTime 上一个点SNTP时间精确值
* @param curSatelliteTime 当前点SNTP时间精确值
* @return 动画运动时间
*/
public long computeAnimDuration(long lastSatelliteTime, long curSatelliteTime) {
if (lastSatelliteTime == 0 || curSatelliteTime == 0) {
return 45;
}
long interval = curSatelliteTime - lastSatelliteTime;
if (interval < 45) {
interval = 45;
}
return interval;
}
}

View File

@@ -112,21 +112,6 @@ public class MarkerDrawer {
return marker;
}
private boolean isNewVehicleType(Object object, IMogoMarker marker) {
if (object instanceof MarkerOnlineCar
&& marker != null
&& marker.getObject() instanceof MarkerShowEntity
&& ((MarkerShowEntity) marker.getObject()).getBindObj() instanceof MarkerOnlineCar) {
try {
return ((MarkerOnlineCar) object).getCarInfo().getVehicleType()
!= ((MarkerOnlineCar) ((MarkerShowEntity) marker.getObject()).getBindObj()).getCarInfo().getVehicleType();
} catch (Exception e) {
}
}
return false;
}
public String getPrimaryKeyFromEntity(Object entity) {
if (entity instanceof MarkerExploreWay) {
String id = ((MarkerExploreWay) entity).getInfoId();

View File

@@ -4,34 +4,26 @@ import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_STOP_
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_WARN_DATA;
import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.eagle.core.utilcode.util.ViewUtils;
import com.mogo.map.MogoMarkerManager;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.drawer.marker.IMarkerView;
import com.mogo.module.common.drawer.marker.MapMarkerAdapter;
import com.mogo.module.common.entity.MarkerLocation;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
/**
* 云端 预警数据绘制
*/
public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedListener {
public class V2XWarnDataDrawer extends BaseDrawer {
private static final String TAG = "V2XWarnDataDrawer";
private static volatile V2XWarnDataDrawer sInstance;
private V2XWarnDataDrawer() {
super();
MogoApisHandler.getInstance().getApis()
.getStatusManagerApi()
.registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, this);
}
public static V2XWarnDataDrawer getInstance() {
@@ -49,21 +41,8 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
sInstance = null;
}
private boolean mIsVrMode = false;
@Override
public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
CallerLogger.INSTANCE.d(TAG, descriptor + " , "+ isTrue);
}
public boolean isVrMode() {
return mIsVrMode;
}
/**
* 识别物移动
*
*/
public void renderWarnData(double lon, double lat, int type, double collisionlat, double collisionLon, double angle, long showTime) {
MarkerLocation location = new MarkerLocation();
@@ -95,7 +74,6 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
return 1;
}
public IMogoMarker drawMarker(MarkerShowEntity markerShowEntity, int modeResType) {
MogoMarkerOptions options = new MogoMarkerOptions()
.data(markerShowEntity)
@@ -128,10 +106,8 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
marker.setRotateAngle(rotate);
}
/**
* 绘制停止线 marker
*
*/
public void renderStopLineData(double lon, double lat) {
MarkerLocation location = new MarkerLocation();
@@ -162,5 +138,4 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
return marker;
}
}

View File

@@ -11,16 +11,16 @@ import android.widget.LinearLayout;
import androidx.annotation.Nullable;
import com.mogo.eagle.core.utilcode.mogo.glide.GlideImageLoader;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.eagle.core.utilcode.util.ViewUtils;
import com.mogo.eagle.core.utilcode.util.WindowUtils;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.R;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.service.imageloader.IMogoImageLoaderListener;
import com.mogo.service.imageloader.MogoImageView;
import com.mogo.eagle.core.utilcode.mogo.imageloader.IMogoImageLoaderListener;
import com.mogo.eagle.core.utilcode.mogo.imageloader.MogoImageView;
/**
* author : donghongyu
@@ -93,7 +93,7 @@ public abstract class MapMarkerBaseView extends LinearLayout implements IMarkerV
if (!url.isEmpty()) {
ivIcon.setPlaceHolder(res);
ivIcon.setFailureHolder(res);
MogoApisHandler.getInstance().getApis().getImageLoaderApi().displayImage(url,
GlideImageLoader.getInstance().displayImage(url,
ivIcon, WindowUtils.dip2px(mContext, 50), WindowUtils.dip2px(mContext, 50),
new IMogoImageLoaderListener() {
@Override
@@ -118,7 +118,7 @@ public abstract class MapMarkerBaseView extends LinearLayout implements IMarkerV
private void runOnUiThread(final MarkerShowEntity markerShowEntity) {
if (!TextUtils.isEmpty(markerShowEntity.getIconUrl())) {
MogoApisHandler.getInstance().getApis().getImageLoaderApi().displayImage(markerShowEntity.getIconUrl(),
GlideImageLoader.getInstance().displayImage(markerShowEntity.getIconUrl(),
ivUserHead,
WindowUtils.dip2px(mContext, 50), WindowUtils.dip2px(mContext, 50),
new IMogoImageLoaderListener() {

View File

@@ -35,11 +35,6 @@ public class OnlineCarMarkerView implements IMarkerView {
return InstanceHolder.INSTANCE;
}
private Object readResolve() {
// 阻止反序列化,必须实现 Serializable 接口
return InstanceHolder.INSTANCE;
}
@Override
public View getView() {
return null;
@@ -72,20 +67,6 @@ public class OnlineCarMarkerView implements IMarkerView {
return sRef.get( vehicleType ).get();
}
public Bitmap getSelectedBitmap( int vehicleType ) {
if ( sTypedRef.get( vehicleType ) == null || sTypedRef.get( vehicleType ).get() == null
|| sTypedRef.get( vehicleType ).get().isRecycled() ) {
switch ( vehicleType ) {
case 2:
sTypedRef.put( vehicleType, new SoftReference<>( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_type2 ) ) );
break;
default:
sTypedRef.put( vehicleType, new SoftReference<>( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_gray_selected ) ) );
}
}
return sTypedRef.get( vehicleType ).get();
}
@Override
public void setMarker( IMogoMarker marker ) {

View File

@@ -1,6 +1,7 @@
package com.mogo.module.common.entity;
/**
* 新鲜事儿Marker数据
*/
@@ -8,9 +9,6 @@ public class MarkerNoveltyInfo {
private String type;
private String sn;
private MarkerLocation location;
/**
* @see com.mogo.module.common.enums.EventTypeEnum
*/
private String poiType;
private ContentData contentData;

View File

@@ -447,7 +447,7 @@ enum class EventTypeEnum(
fun getPoiTypeBg(poiType: String, isVrMode: Boolean): Int {
return when (poiType) {
FOURS_BLOCK_UP.poiType, FOURS_LIVING.poiType-> if (isVrMode) R.drawable.bg_v2x_event_type_orange_vr else R.drawable.bg_v2x_event_type_orange
TRAFFIC_CHECK.poiType, ROAD_CLOSED.poiType, FOURS_ROAD_WORK.poiType,AI_ROAD_WORK.poiType,
TRAFFIC_CHECK.poiType, ROAD_CLOSED.poiType, FOURS_ROAD_WORK.poiType, AI_ROAD_WORK.poiType,
FOURS_PONDING.poiType, FOURS_FOG.poiType, FOURS_ICE.poiType, FOURS_ACCIDENT.poiType,
FOURS_ACCIDENT_01.poiType, FOURS_ACCIDENT_02.poiType, FOURS_ACCIDENT_03.poiType,
FOURS_ACCIDENT_04.poiType, FOURS_ACCIDENT_05.poiType -> if (isVrMode) R.drawable.bg_v2x_event_type_red_vr else R.drawable.bg_v2x_event_type_read
@@ -463,7 +463,7 @@ enum class EventTypeEnum(
FOURS_BLOCK_UP.poiType, FOURS_LIVING.poiType ->
R.drawable.bg_v2x_event_type_orange
TRAFFIC_CHECK.poiType, ROAD_CLOSED.poiType,
FOURS_ROAD_WORK.poiType,AI_ROAD_WORK.poiType, FOURS_PONDING.poiType,
FOURS_ROAD_WORK.poiType, AI_ROAD_WORK.poiType, FOURS_PONDING.poiType,
FOURS_FOG.poiType, FOURS_ICE.poiType,
FOURS_ACCIDENT.poiType, FOURS_ACCIDENT_01.poiType,
FOURS_ACCIDENT_02.poiType, FOURS_ACCIDENT_03.poiType,
@@ -480,7 +480,7 @@ enum class EventTypeEnum(
fun isRoadEvent(poiType: String?): Boolean {
return when (poiType) {
TRAFFIC_CHECK.poiType, ROAD_CLOSED.poiType,
FOURS_ROAD_WORK.poiType,AI_ROAD_WORK.poiType, FOURS_BLOCK_UP.poiType,
FOURS_ROAD_WORK.poiType, AI_ROAD_WORK.poiType, FOURS_BLOCK_UP.poiType,
FOURS_PONDING.poiType, FOURS_FOG.poiType,
FOURS_ICE.poiType, FOURS_ACCIDENT.poiType,
FOURS_ACCIDENT_01.poiType, FOURS_ACCIDENT_02.poiType,
@@ -496,7 +496,7 @@ enum class EventTypeEnum(
@JvmStatic
fun isNeedRoadEventUgc(poiType: String?): Boolean {
return when (poiType) {
ROAD_CLOSED.poiType, FOURS_ROAD_WORK.poiType,AI_ROAD_WORK.poiType,
ROAD_CLOSED.poiType, FOURS_ROAD_WORK.poiType, AI_ROAD_WORK.poiType,
FOURS_BLOCK_UP.poiType, FOURS_ACCIDENT.poiType,
FOURS_ACCIDENT_01.poiType, FOURS_ACCIDENT_02.poiType,
FOURS_ACCIDENT_03.poiType, FOURS_ACCIDENT_04.poiType,

View File

@@ -15,7 +15,7 @@
android:background="@drawable/module_services_marker_bkg"
android:layout_height="@dimen/module_service_marker_bubble_height">
<com.mogo.service.imageloader.MogoImageView
<com.mogo.eagle.core.utilcode.mogo.imageloader.MogoImageView
android:id="@+id/ivIcon"
android:layout_width="@dimen/module_service_marker_bubble_icon_width"
android:layout_height="@dimen/module_service_marker_bubble_icon_height"

View File

@@ -18,7 +18,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.mogo.service.imageloader.MogoImageView
<com.mogo.eagle.core.utilcode.mogo.imageloader.MogoImageView
android:id="@+id/ivUserHead"
android:layout_width="@dimen/dp_76"
android:layout_height="@dimen/dp_76"
@@ -28,7 +28,7 @@
app:miv_placeHolder="@drawable/icon_default_user_head"
app:miv_shape="circle" />
<com.mogo.service.imageloader.MogoImageView
<com.mogo.eagle.core.utilcode.mogo.imageloader.MogoImageView
android:id="@+id/ivIcon"
android:layout_width="@dimen/module_service_marker_bubble_icon_width"
android:layout_height="@dimen/module_service_marker_bubble_icon_height"

View File

@@ -15,7 +15,7 @@
android:background="@drawable/module_services_marker_vr_bkg"
android:layout_height="@dimen/module_service_marker_bubble_vr_height">
<com.mogo.service.imageloader.MogoImageView
<com.mogo.eagle.core.utilcode.mogo.imageloader.MogoImageView
android:id="@+id/ivIcon"
android:layout_width="@dimen/module_service_marker_bubble_icon_vr_width"
android:layout_height="@dimen/module_service_marker_bubble_icon_vr_height"

View File

@@ -1,19 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mogo.module.service" >
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application>
<receiver android:name=".receiver.AccStatusReceiver"
android:exported="true"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.ACTION_POWER_CONNECTED"/>
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED"/>
<action android:name="com.nwd.action.ACTION_MCU_STATE_CHANGE"/>
</intent-filter>
</receiver>
</application>
</manifest>

View File

@@ -9,10 +9,8 @@ import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.module.service.routeoverlay.MogoRouteOverlayManager;
import com.mogo.service.module.IMogoModuleProvider;
import com.mogo.service.module.ModuleType;
/**
* @author congtaowang
@@ -32,7 +30,7 @@ public class MogoServiceProvider implements IMogoModuleProvider {
@Override
public int getType() {
return ModuleType.TYPE_SERVICE;
return 0;
}
@NonNull
@@ -63,14 +61,10 @@ public class MogoServiceProvider implements IMogoModuleProvider {
@Override
public void init( Context context ) {
MarkerServiceHandler.init( context );
MogoServices.getInstance().preInit( context );
MogoServices.getInstance().init( AbsMogoApplication.getApp() );
MogoRouteOverlayManager.getInstance().init();
}
@Override
public void onDestroy() {
MogoServices.getInstance().destroy();
}
}

View File

@@ -1,176 +0,0 @@
package com.mogo.module.service;
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_OLD_OTHER;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.text.TextUtils;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.voice.AIAssist;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.util.NetworkUtils;
import com.mogo.map.IDestroyable;
import com.mogo.map.MogoMarkerManager;
import com.mogo.map.listener.IMogoMapListener;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.MogoModule;
import com.mogo.module.common.MogoModulePaths;
import com.mogo.module.service.intent.IntentHandlerFactory;
import com.mogo.module.service.receiver.MogoReceiver;
import com.mogo.realtime.api.MoGoAiCloudRealTime;
import com.mogo.service.intent.IMogoIntentListener;
import com.mogo.service.intent.IMogoIntentManager;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.IMogoStatusManager;
import com.mogo.service.statusmanager.StatusDescriptor;
import java.util.List;
/**
* @author congtaowang
* @since 2020-01-03
* <p>
* 数据刷新策略
* <p>
* 1. 位置移动触发刷新
* 2. 用户手势交互导致地图视图移动跨过当前视图,延时 1 分钟,不累加
* 3. 用户手势缩小比例尺级别达2级延时 1 分钟,不累加
* 4. 用户交互语音导致地图视图移动,缩放,不触发刷新
*/
public class MogoServices implements IMogoMapListener,
IMogoIntentListener,
IDestroyable {
private MogoServices() {
// private constructor
}
private static final class InstanceHolder {
private static final MogoServices INSTANCE = new MogoServices();
}
public static MogoServices getInstance() {
return InstanceHolder.INSTANCE;
}
private static final String TAG = "MogoServices";
private MogoReceiver mAIAssistReceiver;
private IMogoIntentManager mIntentManager;
private Context mContext;
private final IMogoStatusChangedListener statusChangedListener = new StatusChangedAdapter() {
};
public void preInit(Context context) {
mContext = context;
IMogoStatusManager mStatusManager = MarkerServiceHandler.getMogoStatusManager();
mStatusManager.registerStatusChangedListener(ServiceConst.TYPE, StatusDescriptor.ACC_STATUS, statusChangedListener);
mStatusManager.setAIAssistReady(TAG, AIAssist.getInstance(mContext).hasFlush());
}
public void init(Context context) {
registerMogoReceiver(context);
mIntentManager = MarkerServiceHandler.getIntentManager();
mIntentManager.registerIntentListener(MogoReceiver.ACTION_VOICE_UI, this);
mIntentManager.registerIntentListener(MogoReceiver.ACTION_VOICE_READY, this);
mIntentManager.registerIntentListener(MogoReceiver.ACTION_MOCK, this);
mIntentManager.registerIntentListener(ConnectivityManager.CONNECTIVITY_ACTION, this);
Intent intent = new Intent("com.freedom.ser.ACTION");
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
mContext.sendBroadcast(intent);
if (DebugConfig.isNeedUploadCoordinatesDurationInTime()) {
MoGoAiCloudRealTime.startRealTime(mContext, DebugConfig.getSocketAppId());
}
}
private void registerMogoReceiver(Context context) {
if (context == null) {
return;
}
List<MogoModule> modules = MogoModulePaths.getModules();
if (modules.isEmpty()) {
return;
}
mAIAssistReceiver = new MogoReceiver(context);
IntentFilter filter = new IntentFilter();
if (!modules.isEmpty()) {
for (MogoModule module : modules) {
if (TextUtils.isEmpty(module.getBroadcastAction())) {
continue;
}
filter.addAction(module.getBroadcastAction());
}
}
filter.addAction(MogoReceiver.VOICE_ACTION);
// 小智语音
filter.addAction(MogoReceiver.ACTION_VOICE_UI);
filter.addAction(MogoReceiver.ACTION_VOICE_READY);
filter.addAction(MogoReceiver.ACTION_MOCK);
filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
try {
context.getApplicationContext().registerReceiver(mAIAssistReceiver, filter);
} catch (Exception e) {
CallerLogger.INSTANCE.e(M_OLD_OTHER + TAG, "registerMogoReceiver error : " + e);
}
}
public void clearAllData() {
try {
MogoMarkerManager.getInstance(mContext).removeMarkers();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onIntentReceived(String command, Intent intent) {
if (TextUtils.equals(command, ConnectivityManager.CONNECTIVITY_ACTION)
&& NetworkUtils.isConnected(mContext)) {
mIntentManager.unregisterIntentListener(ConnectivityManager.CONNECTIVITY_ACTION, this);
}
IntentHandlerFactory.getInstance().handle(mContext, command, intent);
}
@Override
public void destroy() {
CallerLogger.INSTANCE.d(M_OLD_OTHER + TAG, "MogoServices do nothings.");
MoGoAiCloudRealTime.stopRealTime();
}
private boolean mLastStatusIsVr = false;
@Override
public void onMapModeChanged(EnumMapUI mCurrentUI) {
clearAllData();
if (mCurrentUI == EnumMapUI.MAP_STYLE_NIGHT_VR || mCurrentUI == EnumMapUI.MAP_STYLE_DAY_VR) {
if (!mLastStatusIsVr) {
MogoApisHandler.getInstance().getApis().getStatusManagerApi().setVrMode(TAG, true);
if (DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_LENOVO) {
//AIAssist.getInstance(mContext).speakTTSVoice("已开启鹰眼模式");
}
mLastStatusIsVr = true;
}
} else {
if (mLastStatusIsVr) {
mLastStatusIsVr = false;
MogoApisHandler.getInstance().getApis().getStatusManagerApi().setVrMode(TAG, false);
if (DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_LENOVO) {
//AIAssist.getInstance(mContext).speakTTSVoice("已退出鹰眼模式");
}
}
}
}
}

View File

@@ -16,12 +16,6 @@ import com.mogo.module.service.receiver.AccStatusReceiver;
*/
public class AccStatusIntentHandler implements IntentHandler {
public static final byte ACC_ON = 1;
public static final byte ACC_OFF = 0;
public static final byte ACC_OFF_DELAY = 3;
private static final String TAG = "AccStatusIntentHandler";
private static volatile AccStatusIntentHandler sInstance;
private AccStatusIntentHandler() {
@@ -53,17 +47,6 @@ public class AccStatusIntentHandler implements IntentHandler {
if ( CarSeries.isF8xxSeries() ) {
MarkerServiceHandler.getMogoStatusManager().setAccStatus( ServiceConst.TYPE, false );
}
} else if ( AccStatusReceiver.ACTION_NWD_ACC.equals( action ) ) {
int state = intent.getByteExtra( AccStatusReceiver.PARAM_ACC_STATUS, ACC_OFF );
if ( state != ACC_OFF && state != ACC_ON && state != ACC_OFF_DELAY ) {
return;
}
if ( state == ACC_ON || state == ACC_OFF_DELAY ) {
Intent newIntent = new Intent( "com.freedom.ser.ACTION" );
newIntent.putExtra( "acc", true );
newIntent.addFlags( Intent.FLAG_INCLUDE_STOPPED_PACKAGES );
context.sendBroadcast( newIntent );
}
}
}
}

View File

@@ -19,11 +19,9 @@ public class IntentHandlerFactory {
private IntentHandlerFactory() {
// private constructor
mHandlers.put( MogoReceiver.ACTION_MOCK, new MockIntentHandler() );
mHandlers.put( MogoReceiver.ACTION_VOICE_UI, new VoiceUiIntentHandler() );
mHandlers.put( Intent.ACTION_POWER_CONNECTED, AccStatusIntentHandler.getInstance() );
mHandlers.put( Intent.ACTION_POWER_DISCONNECTED, AccStatusIntentHandler.getInstance() );
mHandlers.put( AccStatusReceiver.ACTION_NWD_ACC, AccStatusIntentHandler.getInstance() );
mHandlers.put( MogoReceiver.ACTION_VOICE_READY, new AIAssistIntentHandler() );
}
@@ -40,9 +38,9 @@ public class IntentHandlerFactory {
return InstanceHolder.INSTANCE;
}
private Map< String, IntentHandler > mHandlers = new HashMap<>();
private final Map< String, IntentHandler > mHandlers = new HashMap<>();
private IntentHandler DEFAULT = new EmptyIntentHandler();
private final IntentHandler DEFAULT = new EmptyIntentHandler();
private IntentHandler getIntentHandler( String intent ) {
if ( mHandlers.containsKey( intent ) && mHandlers.get( intent ) != null ) {

View File

@@ -1,587 +0,0 @@
package com.mogo.module.service.intent;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import com.mogo.cloud.commons.utils.CoordinateUtils;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.voice.AIAssist;
import com.mogo.eagle.core.data.autopilot.AutopilotCarStateInfo;
import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
import com.mogo.eagle.core.network.utils.GsonUtil;
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
import com.mogo.eagle.core.utilcode.mogo.thread.WorkThreadHandler;
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
import com.mogo.eagle.core.utilcode.util.AppStateManager;
import com.mogo.map.MogoMapUIController;
import com.mogo.map.MogoMarkerManager;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.map.search.geo.IMogoGeoSearch;
import com.mogo.map.search.geo.IMogoGeoSearchListener;
import com.mogo.map.search.geo.MogoGeocodeResult;
import com.mogo.map.search.geo.MogoRegeocodeResult;
import com.mogo.map.search.geo.query.MogoRegeocodeQuery;
import com.mogo.module.common.constants.DataTypes;
import com.mogo.module.common.dialog.WMDialog;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.R;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/**
* @author congtaowang
* @since 2020-04-17
* <p>
* 使用控制台发送广播这里接收intent来处理场景
*/
public class MockIntentHandler implements IntentHandler {
private static final String TAG = "MockIntentHandler";
private IMogoMarker centerMarker;
@Override
public void handle(Context context, Intent intent) {
if (!DebugConfig.isDebug()) {
return;
}
final int oper = intent.getIntExtra("oper", -1);
switch (oper) {
case 1:
// 展示自车位置
MogoMapUIController.getInstance().showMyLocation(intent.getBooleanExtra("status", true));
break;
case 2:
// 发起求助
boolean status = intent.getBooleanExtra("status", false);
MarkerServiceHandler.getMogoStatusManager().setSeekHelping(TAG, status);
break;
case 3:
String msg = intent.getStringExtra("msg");
if (!TextUtils.isEmpty(msg)) {
TipToast.shortTip(msg);
}
break;
case 9:// 测试弹窗
Activity activity = AppStateManager.INSTANCE.currentActivity();
if (activity != null) {
new WMDialog.Builder(activity)
.setOkButton("确认", (dlg, which) -> dlg.dismiss())
.setCancelButton("取消", (dlg, which) -> dlg.dismiss())
.setContent("内容内容内容内容内容内容内容内容")
.build()
.show();
}
break;
case 10://测试GEO查询
IMogoGeoSearch geoSearch = CallerMapUIServiceManager.INSTANCE.getGeoSearch(context);
geoSearch.setGeoSearchListener(new IMogoGeoSearchListener() {
@Override
public void onRegeocodeSearched(MogoRegeocodeResult regeocodeResult) {
}
@Override
public void onGeocodeSearched(MogoGeocodeResult geocodeResult) {
}
});
MogoRegeocodeQuery query = new MogoRegeocodeQuery();
query.setLatlngType("autonavi");
query.setPoint(new MogoLatLng(intent.getFloatExtra("lat", 39.917366f), intent.getFloatExtra("lon", 116.39962f)));
query.setRadius(1000);
geoSearch.getFromLocationAsyn(query);
break;
case 14: {//测试点的动画移动,模拟周边车辆移动
List<MogoLatLng> mogoLatLngs = new ArrayList<>();
mogoLatLngs.add(new MogoLatLng(39.615986, 116.396716));
mogoLatLngs.add(new MogoLatLng(39.616007, 116.396995));
mogoLatLngs.add(new MogoLatLng(39.616012, 116.397169));
mogoLatLngs.add(new MogoLatLng(39.616017, 116.397343));
mogoLatLngs.add(new MogoLatLng(39.616022, 116.397517));
mogoLatLngs.add(new MogoLatLng(39.616029, 116.397693));
mogoLatLngs.add(new MogoLatLng(39.616039, 116.397896));
mogoLatLngs.add(new MogoLatLng(39.616051, 116.3981));
mogoLatLngs.add(new MogoLatLng(39.616058, 116.39827));
mogoLatLngs.add(new MogoLatLng(39.616066, 116.398441));
mogoLatLngs.add(new MogoLatLng(39.616074, 116.398612));
mogoLatLngs.add(new MogoLatLng(39.616083, 116.398787));
mogoLatLngs.add(new MogoLatLng(39.616093, 116.39899));
mogoLatLngs.add(new MogoLatLng(39.616105, 116.399195));
mogoLatLngs.add(new MogoLatLng(39.616112, 116.399334));
mogoLatLngs.add(new MogoLatLng(39.61612, 116.399473));
mogoLatLngs.add(new MogoLatLng(39.616128, 116.399612));
mogoLatLngs.add(new MogoLatLng(39.616136, 116.399751));
mogoLatLngs.add(new MogoLatLng(39.616148, 116.399893));
mogoLatLngs.add(new MogoLatLng(39.616153, 116.40008));
mogoLatLngs.add(new MogoLatLng(39.616159, 116.400301));
mogoLatLngs.add(new MogoLatLng(39.616167, 116.400471));
mogoLatLngs.add(new MogoLatLng(39.616175, 116.400642));
mogoLatLngs.add(new MogoLatLng(39.616183, 116.400813));
mogoLatLngs.add(new MogoLatLng(39.616192, 116.400988));
mogoLatLngs.add(new MogoLatLng(39.616201, 116.401191));
mogoLatLngs.add(new MogoLatLng(39.616213, 116.401396));
mogoLatLngs.add(new MogoLatLng(39.616235, 116.401728));
mogoLatLngs.add(new MogoLatLng(39.616246, 116.401986));
mogoLatLngs.add(new MogoLatLng(39.61625, 116.402146));
mogoLatLngs.add(new MogoLatLng(39.616255, 116.402307));
mogoLatLngs.add(new MogoLatLng(39.61626, 116.402468));
mogoLatLngs.add(new MogoLatLng(39.616267, 116.40263));
mogoLatLngs.add(new MogoLatLng(39.616272, 116.402762));
mogoLatLngs.add(new MogoLatLng(39.616277, 116.402894));
mogoLatLngs.add(new MogoLatLng(39.616282, 116.403026));
mogoLatLngs.add(new MogoLatLng(39.616287, 116.403158));
mogoLatLngs.add(new MogoLatLng(39.616292, 116.40329));
mogoLatLngs.add(new MogoLatLng(39.616297, 116.403422));
mogoLatLngs.add(new MogoLatLng(39.616302, 116.403554));
mogoLatLngs.add(new MogoLatLng(39.616307, 116.403686));
mogoLatLngs.add(new MogoLatLng(39.616321, 116.403821));
mogoLatLngs.add(new MogoLatLng(39.616331, 116.404045));
mogoLatLngs.add(new MogoLatLng(39.616343, 116.404272));
mogoLatLngs.add(new MogoLatLng(39.616353, 116.404551));
mogoLatLngs.add(new MogoLatLng(39.616363, 116.404753));
mogoLatLngs.add(new MogoLatLng(39.616375, 116.404958));
mogoLatLngs.add(new MogoLatLng(39.616375, 116.405055));
mogoLatLngs.add(new MogoLatLng(39.616379, 116.405184));
mogoLatLngs.add(new MogoLatLng(39.616384, 116.405313));
mogoLatLngs.add(new MogoLatLng(39.616389, 116.405442));
mogoLatLngs.add(new MogoLatLng(39.616394, 116.405571));
mogoLatLngs.add(new MogoLatLng(39.616399, 116.4057));
mogoLatLngs.add(new MogoLatLng(39.616404, 116.405829));
mogoLatLngs.add(new MogoLatLng(39.616409, 116.405958));
mogoLatLngs.add(new MogoLatLng(39.616414, 116.406087));
mogoLatLngs.add(new MogoLatLng(39.616419, 116.406216));
mogoLatLngs.add(new MogoLatLng(39.616424, 116.406345));
mogoLatLngs.add(new MogoLatLng(39.616429, 116.406474));
mogoLatLngs.add(new MogoLatLng(39.61644, 116.406611));
mogoLatLngs.add(new MogoLatLng(39.616461, 116.406879));
mogoLatLngs.add(new MogoLatLng(39.616465, 116.407033));
mogoLatLngs.add(new MogoLatLng(39.616469, 116.407187));
mogoLatLngs.add(new MogoLatLng(39.616473, 116.407341));
mogoLatLngs.add(new MogoLatLng(39.616477, 116.407495));
mogoLatLngs.add(new MogoLatLng(39.616483, 116.407694));
mogoLatLngs.add(new MogoLatLng(39.616493, 116.407876));
mogoLatLngs.add(new MogoLatLng(39.616504, 116.408059));
mogoLatLngs.add(new MogoLatLng(39.616515, 116.408327));
mogoLatLngs.add(new MogoLatLng(39.616526, 116.408596));
mogoLatLngs.add(new MogoLatLng(39.616536, 116.408757));
mogoLatLngs.add(new MogoLatLng(39.616547, 116.409025));
mogoLatLngs.add(new MogoLatLng(39.616556, 116.409227));
mogoLatLngs.add(new MogoLatLng(39.616568, 116.409432));
mogoLatLngs.add(new MogoLatLng(39.616579, 116.409711));
mogoLatLngs.add(new MogoLatLng(39.61659, 116.409914));
mogoLatLngs.add(new MogoLatLng(39.616601, 116.410119));
mogoLatLngs.add(new MogoLatLng(39.616601, 116.410387));
mogoLatLngs.add(new MogoLatLng(39.616601, 116.410602));
mogoLatLngs.add(new MogoLatLng(39.616622, 116.410816));
mogoLatLngs.add(new MogoLatLng(39.616633, 116.411084));
mogoLatLngs.add(new MogoLatLng(39.616643, 116.411395));
mogoLatLngs.add(new MogoLatLng(39.616654, 116.411492));
mogoLatLngs.add(new MogoLatLng(39.616665, 116.411771));
mogoLatLngs.add(new MogoLatLng(39.616674, 116.411974));
mogoLatLngs.add(new MogoLatLng(39.616686, 116.412178));
mogoLatLngs.add(new MogoLatLng(39.616697, 116.412447));
mogoLatLngs.add(new MogoLatLng(39.616697, 116.412586));
mogoLatLngs.add(new MogoLatLng(39.616718, 116.412876));
mogoLatLngs.add(new MogoLatLng(39.616729, 116.413144));
mogoLatLngs.add(new MogoLatLng(39.616738, 116.413347));
mogoLatLngs.add(new MogoLatLng(39.61675, 116.413551));
mogoLatLngs.add(new MogoLatLng(39.61675, 116.41383));
mogoLatLngs.add(new MogoLatLng(39.616761, 116.414002));
mogoLatLngs.add(new MogoLatLng(39.616761, 116.414098));
mogoLatLngs.add(new MogoLatLng(39.616767, 116.414279));
mogoLatLngs.add(new MogoLatLng(39.616774, 116.414461));
mogoLatLngs.add(new MogoLatLng(39.616782, 116.414645));
mogoLatLngs.add(new MogoLatLng(39.616792, 116.41483));
mogoLatLngs.add(new MogoLatLng(39.616802, 116.415016));
mogoLatLngs.add(new MogoLatLng(39.616814, 116.415203));
mogoLatLngs.add(new MogoLatLng(39.616824, 116.415395));
mogoLatLngs.add(new MogoLatLng(39.616836, 116.415589));
mogoLatLngs.add(new MogoLatLng(39.616842, 116.415745));
mogoLatLngs.add(new MogoLatLng(39.616849, 116.415902));
mogoLatLngs.add(new MogoLatLng(39.616857, 116.416061));
mogoLatLngs.add(new MogoLatLng(39.616868, 116.416307));
MogoMarkerOptions options = new MogoMarkerOptions();
options.icon(BitmapFactory.decodeResource(AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_gray))
.position(mogoLatLngs.get(0))
.owner(TAG)
.autoManager(false);
int duration = intent.getIntExtra("duration", 30);
IMogoMarker marker = MogoMarkerManager.getInstance(context).addMarker(TAG, options);
if (!MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode()) {
MogoMapUIController.getInstance().moveToCenter(mogoLatLngs.get(0));
}
WorkThreadHandler.getInstance().post(() -> marker.startSmooth(mogoLatLngs, duration));
break;
}
case 17:// 查询在线车辆数据
DebugConfig.setRequestOnlineCarData(intent.getBooleanExtra("status", true));
break;
case 18:// 设置是否使用自研地图
TipToast.shortTip("设置完成,下次启动生效");
SharedPrefsMgr.getInstance(context).putBoolean("useCustomMap", intent.getBooleanExtra("useCustomMap", false));
break;
case 30:// 强制刷新地图
MogoMapUIController.getInstance().forceRender();
break;
case 31://
Intent intent3 = new Intent();
intent3.setAction("AUTONAVI_STANDARD_BROADCAST_RECV");
intent3.putExtra("KEY_TYPE", 12404);
intent3.putExtra("EXTRA_REQUEST_AUTO_STATE", 0);
context.sendBroadcast(intent3);
break;
case 33:// 测试小智语音
AIAssist.getInstance(context).speakTTSVoice("庞帆说这个是一个 hard coding.");
break;
case 36:// 测试打点功能
MogoLatLng center = MogoMapUIController.getInstance()
.getWindowCenterLocation();
centerMarker = MogoMarkerManager.getInstance(context)
.addMarker(TAG, new MogoMarkerOptions()
.position(center)
.icon(BitmapFactory.decodeResource(context.getResources(), R.drawable.bg_map_marker_red)));
break;
case 37:// 销毁测试打点
if (centerMarker != null) {
centerMarker.destroy();
}
break;
case 38:// 控制RTK
MogoMapUIController.getInstance()
.rtkEnable(false);
break;
case 40:
double[][] coors = new double[][]{{40.17511749267578, 116.74359130859375},
{40.20258331298828, 116.74071502685547},
{40.202598571777344, 116.74067687988281},
{40.20256805419922, 116.74071502685547},
{40.202598571777344, 116.74064636230469},
{40.20258712768555, 116.74067687988281},
{40.202579498291016, 116.74068450927734},
{40.202545166015625, 116.7406005859375},
{40.202571868896484, 116.74054718017578},
{40.20256042480469, 116.74057006835938},
{40.202510833740234, 116.74053192138672},
{40.202552795410156, 116.74053955078125},
{40.202537536621094, 116.74044799804688},
{40.202552795410156, 116.74042510986328},
{40.202510833740234, 116.74038696289062},
{40.202537536621094, 116.74044799804688},
{40.202552795410156, 116.74042510986328},
{40.202518463134766, 116.74039459228516},
{40.202537536621094, 116.74038696289062},
{40.202552795410156, 116.74036407470703},
{40.20252227783203, 116.7403335571289},
{40.20253372192383, 116.74038696289062},
{40.202552795410156, 116.74036407470703},
{40.2025260925293, 116.7403335571289},
{40.20253372192383, 116.74030303955078},
{40.20254898071289, 116.74028778076172},
{40.20252990722656, 116.7402572631836},
{40.2025260925293, 116.740234375},
{40.202545166015625, 116.74022674560547},
{40.20252990722656, 116.74020385742188},
{40.20254898071289, 116.74014282226562},
{40.20253372192383, 116.74011993408203},
{40.2025260925293, 116.74014282226562},
{40.20254898071289, 116.74014282226562},
{40.202537536621094, 116.74011993408203},
{40.2025260925293, 116.74014282226562},
{40.20255661010742, 116.74008178710938},
{40.20254135131836, 116.74005889892578},
{40.20252990722656, 116.74007415771484},
{40.20254898071289, 116.74008178710938},
{40.20254135131836, 116.74005889892578},
{40.20252227783203, 116.74006652832031},
{40.20254898071289, 116.74002838134766},
{40.20254135131836, 116.74000549316406},
{40.20252227783203, 116.73999786376953},
{40.20269012451172, 116.73983001708984},
{40.20265579223633, 116.73978424072266},
{40.202667236328125, 116.7397689819336},
{40.20264434814453, 116.73973083496094},
{40.202632904052734, 116.7397689819336},
{40.202613830566406, 116.73974609375},
{40.2026252746582, 116.73970794677734},
{40.202613830566406, 116.73968505859375},
{40.202598571777344, 116.73970031738281},
{40.20258712768555, 116.73969268798828},
{40.20258712768555, 116.73961639404297},
{40.202579498291016, 116.73960876464844},
{40.20257568359375, 116.7396240234375},
{40.20256805419922, 116.73960876464844},
{40.20256042480469, 116.73941802978516},
{40.20255661010742, 116.73941802978516},
{40.20256042480469, 116.73941802978516},
{40.20254898071289, 116.73941802978516},
{40.20255661010742, 116.7393569946289},
{40.20254898071289, 116.7393569946289},
{40.20256042480469, 116.7393569946289},
{40.20254898071289, 116.7393569946289},
{40.20255661010742, 116.73928833007812},
{40.202545166015625, 116.7392807006836},
{40.20254898071289, 116.73928833007812},
{40.20254135131836, 116.7392807006836}};
for (double[] coor : coors) {
double lat = coor[0], lon = coor[1];
double[] translateCoor = CoordinateUtils.transformWgsToGcj(lat, lon);
double[] originCoor = CoordinateUtils.transformGcj02toWgs84(translateCoor[1], translateCoor[0]);
double delta = CoordinateUtils.calculateLineDistance(lon, lat, originCoor[0], originCoor[1]);
}
break;
case 42://
WorkThreadHandler.getInstance().post(() -> {
try {
InputStream is = context.getAssets().open("coors.json");
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line = "";
List<AutopilotCarStateInfo> vals = new ArrayList<>();
while ((line = br.readLine()) != null) {
String[] json = line.split(" - ");
long time = Long.parseLong(json[0]);
AutopilotCarStateInfo si = GsonUtil.objectFromJson(json[1], AutopilotCarStateInfo.class);
// si.getValues().setSatelliteTime( time + "" );
vals.add(si);
}
long interval = -1;
AutopilotCarStateInfo last = null;
for (AutopilotCarStateInfo val : vals) {
if (last == null) {
interval = 0;
} else {
interval = Long.parseLong(val.getValues().getSatelliteTime()) - Long.parseLong(last.getValues().getSatelliteTime());
}
last = val;
WorkThreadHandler.getInstance().postDelayed(() -> onAdasCarDataCallback(val), interval);
}
} catch (Exception e) {
e.printStackTrace();
}
});
break;
case 46:// 模拟鹰眼模式下绘制车辆周边的数据
mTimeTickHandler.sendEmptyMessageDelayed(1, 0L);
break;
case 48:// 模拟3D模型绘制
MogoMarkerOptions options = new MogoMarkerOptions()
.owner(DataTypes.TYPE_MARKER_ADAS)
.anchor(0.5f, 0.5f)
.set3DMode(true)
.position(new MogoLatLng(39.981971055705, 116.41150648393))
.gps(true)
.controlAngle(true)
.icon3DRes(R.raw.special_vehicle)
.rotate((float) 358.526123);
IMogoMarker marker = MogoMarkerManager.getInstance(context).addMarker(DataTypes.TYPE_MARKER_ADAS, options);
List<MogoLatLng> latLngs = new ArrayList<>();
latLngs.add(new MogoLatLng(39.981971055705, 116.41150648393));
latLngs.add(new MogoLatLng(39.981990561932, 116.412893641626));
marker.startSmoothInMs(latLngs, 20_000L);
break;
case 49:// 绘制marker
// 39.96741320378243, 116.41045709250723
// 39.98232698552779,116.41879656379113;
MogoMarkerOptions options1 = new MogoMarkerOptions()
.owner(DataTypes.TYPE_MARKER_ADAS)
.anchor(0.5f, 0.5f)
.set3DMode(false)
.position(new MogoLatLng(39.96741320378243, 116.41045709250723))
.gps(true)
.controlAngle(false)
.icon(BitmapFactory.decodeResource(context.getResources(), R.drawable.sy))
.rotate((float) 358.526123);
IMogoMarker marker1 = MogoMarkerManager.getInstance(context).addMarker(DataTypes.TYPE_MARKER_ADAS, options1);
MogoMarkerOptions options2 = new MogoMarkerOptions()
.owner(DataTypes.TYPE_MARKER_ADAS)
.anchor(0.5f, 0.5f)
.set3DMode(false)
.position(new MogoLatLng(39.98232698552779, 116.41879656379113))
.gps(true)
.controlAngle(false)
.icon(BitmapFactory.decodeResource(context.getResources(), R.drawable.sr))
.rotate((float) 358.526123);
IMogoMarker marker2 = MogoMarkerManager.getInstance(context).addMarker(DataTypes.TYPE_MARKER_ADAS, options2);
MogoMarkerOptions options3 = new MogoMarkerOptions()
.owner(DataTypes.TYPE_MARKER_ADAS)
.anchor(0.5f, 0.5f)
.set3DMode(false)
.position(new MogoLatLng(39.97631642243, 116.418249382739))
.gps(true)
.controlAngle(false)
.icon(BitmapFactory.decodeResource(context.getResources(), R.drawable.bg_map_marker_red))
.rotate((float) 358.526123);
IMogoMarker marker3 = MogoMarkerManager.getInstance(context).addMarker(DataTypes.TYPE_MARKER_ADAS, options3);
break;
case 53:// 控制 Adas识别 是否可用
boolean isUseAdasRecognize = intent.getBooleanExtra("status", false);
DebugConfig.setUseAdasRecognize(isUseAdasRecognize);
break;
case 56:
// 开启数据采集 自车定位和视觉识别
break;
}
}
private BufferedReader roadSizeBr;
private JSONObject locJo = null;
/**
* 处理模拟单Loc数据意图
*/
private void handleMockSingleLocDataIntent() throws Exception {
if (locJo == null) {
String locLine = "{\"systemTime\":1615529718585,\"satelliteTime\":1615529718585,\"lon\":116.73573385415098,\"lat\":40.19907712731953,\"alt\":34.4018669128417,\"heading\":0.342695406938048,\"speed\":0.003303937}";
locJo = new JSONObject(locLine);
locJo.put("satelliteTime", System.currentTimeMillis());
locJo.put("systemTime", System.currentTimeMillis());
}
MogoMapUIController.getInstance().syncLocation2Map(locJo);
mLocationMockHandler.sendEmptyMessageDelayed(100, 50L);
}
public void onAdasCarDataCallback(AutopilotCarStateInfo stateInfo) {
if (stateInfo != null && stateInfo.getValues() != null) {
JSONObject data = new JSONObject();
try {
data.putOpt("lon", stateInfo.getValues().getLon());
data.putOpt("lat", stateInfo.getValues().getLat());
data.putOpt("alt", stateInfo.getValues().getAlt());
data.putOpt("speed", stateInfo.getValues().getGnss_speed());
data.putOpt("satelliteTime", stateInfo.getValues().getSatelliteTime());
data.putOpt("heading", stateInfo.getValues().getHeading());
data.putOpt("acceleration", stateInfo.getValues().getAcceleration());
data.putOpt("yawRate", stateInfo.getValues().getYaw_rate());
MogoMapUIController.getInstance().syncLocation2Map(data);
// SnapshotUploadInTime.getInstance().syncAdasLocationInfo( data );
} catch (Exception e) {
e.printStackTrace();
}
}
}
private final Handler mLocationMockHandler = new Handler(WorkThreadHandler.newInstance("loc-mock-thread").getLooper()) {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
// 模拟处理当前车辆位置
if (msg.what == 1) {
try {
if (!handleMockLocationIntent()) {
br.close();
br = null;
}
} catch (Exception e) {
try {
br.close();
} catch (IOException ex) {
ex.printStackTrace();
}
br = null;
}
}
// 模拟单个车数据
else if (msg.what == 100) {
try {
handleMockSingleLocDataIntent();
} catch (Exception e) {
e.printStackTrace();
}
}
}
};
private final Handler mLocationMockHandler1 = new Handler(WorkThreadHandler.newInstance("loc-mock-thread1").getLooper()) {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (msg.what == 1) {
try {
if (!handleMockLocationIntent()) {
br.close();
br = null;
}
} catch (Exception e) {
try {
br.close();
} catch (IOException ex) {
ex.printStackTrace();
}
br = null;
}
}
}
};
private long mLocDelay = 0;
private final Handler mTimeTickHandler = new Handler(WorkThreadHandler.newInstance("loc-mock-thread2").getLooper()) {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
mLocDelay += 50;
// 这里处理自车移动延时4秒
if (mLocDelay > 4_000L) {
mLocationMockHandler1.sendEmptyMessageDelayed(1, 0L);
}
mLocationMockHandler.sendEmptyMessageDelayed(3, 0L);
// 延时50毫秒重复发送自己
mTimeTickHandler.sendEmptyMessageDelayed(0, 50L);
}
};
private final Handler mTimeTickCarHandler = new Handler(WorkThreadHandler.newInstance("loc-time-mock-thread").getLooper()) {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
mLocDelay += 50;
if (mLocDelay > 4_000L) {
mLocationMockHandler1.sendEmptyMessageDelayed(1, 0L);
}
mLocationMockHandler.sendEmptyMessageDelayed(8, 0L);
mTimeTickCarHandler.sendEmptyMessageDelayed(0, 50L);
}
};
private BufferedReader br;
/**
* 处理模拟位置意图
*/
private boolean handleMockLocationIntent() throws Exception {
if (br == null) {
br = new BufferedReader(new InputStreamReader(AbsMogoApplication.getApp().getAssets().open("loc.txt")));
}
final long start = System.currentTimeMillis();
String line = br.readLine();
if (line == null) {
throw new Exception("end of file.");
}
JSONObject jo = new JSONObject(line);
//改变rtk定位数据触发自车移动
MogoMapUIController.getInstance().syncLocation2Map(jo);
return true;
}
private BufferedReader[] readers = null;
private BufferedReader[] readers2 = null;
}

View File

@@ -46,8 +46,6 @@ public class MapMarkerManager implements IMogoMarkerClickListener {
private static final String TAG = "MapMarkerManager";
private Context mContext;
// 最后一次选中的气泡
private IMogoMarker mLastCheckMarker;
private static MapMarkerManager mMarkerManager;
private RefreshModel mRefreshModel;
@@ -87,123 +85,9 @@ public class MapMarkerManager implements IMogoMarkerClickListener {
*/
@Override
public boolean onMarkerClicked(IMogoMarker marker) {
try {
boolean result = switchMarkerOpenStatus(marker);
if (!result) {
return false;
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
/**
* 切换当前选中marker和上一个选中的状态
*
* @param marker 地图marker抽象对象
* @return markerOpenStatus
*/
private boolean switchMarkerOpenStatus(IMogoMarker marker) {
if (mLastCheckMarker != null) {
// 判断点击的是否是同一个
if (marker.equals(mLastCheckMarker)) {
return false;
}
// 将上次选中 Marker 设置为未选中状态
closeMarker(mLastCheckMarker);
}
// 将当前的Marker设置为选中
openMarker(marker);
return true;
}
// 展开气泡
private void openMarker(IMogoMarker mogoMarker) {
if (mogoMarker == null) {
return;
}
mLastCheckMarker = mogoMarker;
// 在线车辆点击使用infoWindow
if (!TextUtils.equals(mogoMarker.getOwner(), ModuleNames.CARD_TYPE_USER_DATA)) {
Object object = mogoMarker.getObject();
if (object instanceof MarkerShowEntity) {
MarkerShowEntity markerShowEntity = (MarkerShowEntity) object;
markerShowEntity.setChecked(true);
IMarkerView markerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, mogoMarker.getMogoMarkerOptions());
markerView.setMarker(mogoMarker);
if (markerView instanceof OnlineCarMarkerView) {
try {
mogoMarker.setIcon(markerView.getBitmap(((MarkerOnlineCar) markerShowEntity.getBindObj()).getCarInfo().getVehicleType()));
} catch (Exception e) {
mogoMarker.setIcon(markerView.getBitmap(0));
}
} else {
if (MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode()) {
mogoMarker.hideInfoWindow();
mogoMarker.showInfoWindow();
} else {
mogoMarker.setIcon(ViewUtils.fromView(markerView.getView()));
}
}
mogoMarker.setToTop();
}
}
if (!MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode()) {
MogoMapUIController.getInstance().moveToCenter(mogoMarker.getPosition(), true);
}
}
// 折叠气泡
private void closeMarker(IMogoMarker mogoMarker) {
if (mogoMarker == null) {
return;
}
// 在线车辆点击使用infoWindow
if (TextUtils.equals(mogoMarker.getOwner(), ModuleNames.CARD_TYPE_USER_DATA)) {
mogoMarker.setIcon(OnlineCarMarkerView.getInstance().getBitmap(getCarVehicleType(mogoMarker)));
} else {
Object object = mogoMarker.getObject();
if (object != null) {
MarkerShowEntity markerShowEntity = (MarkerShowEntity) object;
markerShowEntity.setChecked(false);
IMarkerView markerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, mogoMarker.getMogoMarkerOptions());
markerView.setMarker(mogoMarker);
if (markerView instanceof OnlineCarMarkerView) {
try {
mogoMarker.setIcon(markerView.getBitmap(((MarkerOnlineCar) markerShowEntity.getBindObj()).getCarInfo().getVehicleType()));
} catch (Exception e) {
mogoMarker.setIcon(markerView.getBitmap(0));
}
} else {
if (MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode()) {
mogoMarker.hideInfoWindow();
mogoMarker.showInfoWindow();
} else {
mogoMarker.setIcon(ViewUtils.fromView(markerView.getView()));
}
}
}
}
}
/**
* 获取特殊车辆类型
*
* @param marker
* @return
*/
private int getCarVehicleType(IMogoMarker marker) {
try {
return ((MarkerOnlineCar)
((MarkerShowEntity) marker.getObject()).getBindObj())
.getCarInfo()
.getVehicleType();
} catch (Exception e) {
return 0;
}
}
/**
* 绘制Marker这里绘制的会使用markerShowEntities队列进行维护
*
@@ -258,31 +142,25 @@ public class MapMarkerManager implements IMogoMarkerClickListener {
return;
}
mRefreshModel.queryOnLineCarWithRoute(latLng, onlyFocus, onlySameCity, radius, limit, false, new RefreshCallback() {
@Override
public void onSuccess(Object o) {
MarkerResponse data = (MarkerResponse) o;
MarkerCardResult result = data.getResult();
if (result == null) {
return;
}
List<MarkerOnlineCar> onlineCarList = result.getOnlineCar();
final int size = onlineCarList == null ? 0 : onlineCarList.size();
if (mMarkerDisplayBounds == null) {
mMarkerDisplayBounds = new Rect(
ResourcesHelper.getDimensionPixelSize(AbsMogoApplication.getApp(), R.dimen.module_service_marker_bounds_leftMargin),
ResourcesHelper.getDimensionPixelSize(AbsMogoApplication.getApp(), R.dimen.module_service_marker_bounds_topMargin),
ResourcesHelper.getDimensionPixelSize(AbsMogoApplication.getApp(), R.dimen.module_service_marker_bounds_rightMargin),
ResourcesHelper.getDimensionPixelSize(AbsMogoApplication.getApp(), R.dimen.module_service_marker_bounds_bottomMargin)
);
}
runOnTargetThread(() -> {
UiThreadHandler.postDelayed(runnable, SMOOTH_DURATION * 1000);
});
mRefreshModel.queryOnLineCarWithRoute(latLng, onlyFocus, onlySameCity, radius, limit, false, o -> {
MarkerResponse data = (MarkerResponse) o;
MarkerCardResult result = data.getResult();
if (result == null) {
return;
}
if (mMarkerDisplayBounds == null) {
mMarkerDisplayBounds = new Rect(
ResourcesHelper.getDimensionPixelSize(AbsMogoApplication.getApp(), R.dimen.module_service_marker_bounds_leftMargin),
ResourcesHelper.getDimensionPixelSize(AbsMogoApplication.getApp(), R.dimen.module_service_marker_bounds_topMargin),
ResourcesHelper.getDimensionPixelSize(AbsMogoApplication.getApp(), R.dimen.module_service_marker_bounds_rightMargin),
ResourcesHelper.getDimensionPixelSize(AbsMogoApplication.getApp(), R.dimen.module_service_marker_bounds_bottomMargin)
);
}
runOnTargetThread(() -> {
UiThreadHandler.postDelayed(runnable, SMOOTH_DURATION * 1000);
});
});
}

View File

@@ -4,29 +4,12 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.intent.IntentHandlerFactory;
public
/**
* @author congtaowang
* @since 2020/6/19
*
* 描述
*/
class AccStatusReceiver extends BroadcastReceiver {
public class AccStatusReceiver extends BroadcastReceiver {
private static final String TAG = "AccStatusReceiver";
// 诺威达 acc 状态
public static final String PARAM_ACC_STATUS = "extra_mcu_state";
// 诺威达 acc 状态
public static final String ACTION_NWD_ACC = "com.nwd.action.ACTION_MCU_STATE_CHANGE";
@Override
public void onReceive( Context context, Intent intent ) {
MarkerServiceHandler.init( context );
IntentHandlerFactory.getInstance().handle( context, intent.getAction(), intent );
}
}

View File

@@ -33,8 +33,6 @@ public class MogoReceiver extends BroadcastReceiver {
*/
public static final String ACTION_VOICE_READY = "com.zhidao.auto.AIAssist.ready";
public static final String ACTION_MOCK = "com.mogo.mock";
private final IMogoIntentManager mMogoIntentManager;
public MogoReceiver(Context context) {

View File

@@ -1,139 +0,0 @@
package com.mogo.module.service.utils;
import java.util.Arrays;
/**
* 莫顿编码
*
* @author linyang
* @since 2020.07.09
*/
public class MortonCode {
/**
* morton 转 经纬度 时的中间常量
*/
private static final long NDS_180_DEGREES = 0x7fffffff;
/**
* morton 转 经纬度 时的中间常量
*/
private static final long NDS_360_DEGREES = 4294967295L;
/**
* morton 转 经纬度 时的中间常量
*/
private static final long NDS_90_DEGREES = 0x3fffffff;
/**
* 经纬度转 morton 时的中间常量
*/
private static final double RULE_MORTON = Math.pow( 2, 32 ) / 360;
/**
* morton 转 经纬度 时的中间常量
*/
private static final double RULE_MORTON_TO_LONLAT = 360.0 / Math.pow( 2, 32 );
/**
* 编码 morton code
*
* @param lon
* @param lat
* @return
*/
public static long encodeMorton( Double lon, Double lat ) {
Long bit = 1L;
long mortonCode = 0L;
long x = ( long ) ( lon * RULE_MORTON );
long y = ( long ) ( lat * RULE_MORTON );
if ( y < 0 ) {
y += 0x7FFFFFFF;
}
y = y << 1;
for ( int i = 0; i < 32; i++ ) {
// x-part
mortonCode = mortonCode | ( x & bit );
x = x << 1;
bit = bit << 1;
// y-part
mortonCode = mortonCode | ( y & bit );
y = y << 1;
bit = bit << 1;
}
return mortonCode;
}
/**
* 将莫顿码解码为坐标
*
* @param mortonCode
* @return
*/
public static double[] decodeMorton( long mortonCode ) {
long[] midPoint = mortonCodeToCoord( mortonCode );
normalizeCoord( midPoint );
double[] point = new double[2];
// 将经纬度长整数转化为 浮点类型
point[0] = midPoint[0] * RULE_MORTON_TO_LONLAT;
point[1] = midPoint[1] * RULE_MORTON_TO_LONLAT;
return point;
}
/**
* 莫顿码分别拆解为 编码后的经纬度长整数
*
* @param mortonCode
* @return
*/
private static long[] mortonCodeToCoord( long mortonCode ) {
long bit = 1L;
long[] longPoint = new long[2];
for ( int i = 0; i < 32; i++ ) {
longPoint[0] |= mortonCode & bit;
mortonCode >>= 1;
longPoint[1] |= mortonCode & bit;
bit <<= 1;
}
return longPoint;
}
/**
* 对编码后的经纬度长整数进行解码
*
* @param midPoint
*/
private static void normalizeCoord( long[] midPoint ) {
// if x > 180 degrees, then subtract 360 degrees
if ( midPoint[0] > NDS_180_DEGREES ) {
midPoint[0] -=
NDS_360_DEGREES + 1; // add 1 because 0 must be counted as well
} else if ( midPoint[0] < -NDS_180_DEGREES ) // if x < 180 , x += 360
{
midPoint[0] +=
NDS_360_DEGREES + 1; // add 1 because 0 must be counted as well
}
// if y > 90 degrees, then subtract 180 degrees
if ( midPoint[1] > NDS_90_DEGREES ) {
midPoint[1] -=
NDS_180_DEGREES + 1; // add 1 because 0 must be counted as well
} else if ( midPoint[1] < -NDS_90_DEGREES ) // if y < 90, y += 180
{
midPoint[1] +=
NDS_180_DEGREES + 1; // add 1 because 0 must be counted as well
}
return;
}
public static void main( String[] args ) {
System.out.println( encodeMorton( 116.39584, 39.98152 ) );
System.out.println( Arrays.toString( decodeMorton( 1415388919630379091L ) ) );
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

View File

@@ -19,7 +19,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.mogo.service.imageloader.MogoImageView
<com.mogo.eagle.core.utilcode.mogo.imageloader.MogoImageView
android:id="@+id/module_service_id_user_header"
android:layout_width="@dimen/module_service_user_header_width"
android:layout_height="@dimen/module_service_user_header_height"