add new func of httpdns switch city to fit socketserver
This commit is contained in:
4
.idea/gradle.xml
generated
4
.idea/gradle.xml
generated
@@ -4,11 +4,10 @@
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="delegatedBuild" value="true" />
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="1.8" />
|
||||
<option name="gradleJvm" value="11" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
@@ -90,6 +89,7 @@
|
||||
<option value="$PROJECT_DIR$/tts/tts-zhi" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveExternalAnnotations" value="false" />
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
|
||||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -8,7 +8,7 @@
|
||||
<asm skipDebug="false" skipFrames="false" skipCode="false" expandFrames="false" />
|
||||
<groovy codeStyle="LEGACY" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -4,23 +4,20 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.location.Location;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.data.BaseData;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.constants.HostConst;
|
||||
import com.mogo.och.taxi.ui.OCHTaxiUiController;
|
||||
import com.mogo.service.adas.IMogoAdasOCHCallback;
|
||||
import com.mogo.service.adas.IMogoAdasRouteCallBack;
|
||||
import com.mogo.service.adas.RemoteControlAutoPilotParameters;
|
||||
import com.mogo.service.adas.entity.AdasOCHData;
|
||||
import com.mogo.service.connection.IMogoLifecycleListener;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.utils.NetworkUtils;
|
||||
@@ -32,8 +29,11 @@ import com.mogo.utils.storage.SharedPrefsMgr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
public
|
||||
@@ -79,6 +79,7 @@ class MogoOCHTaxiModel {
|
||||
private Context mContext;
|
||||
private OCHTaxiOrderResponse mCurrentOCHOrder;
|
||||
private OCHArriveNotifyCallback mNotifyCallback;
|
||||
private OCHSocketLifeCycleLisnter mSocketLifeCycleLisnter;
|
||||
private IMogoCarLocationChangedListener2 mCarLocationChangedListener2;
|
||||
/**
|
||||
* 是否达到起始站点
|
||||
@@ -126,6 +127,10 @@ class MogoOCHTaxiModel {
|
||||
.getApis()
|
||||
.getSocketManagerApi( context )
|
||||
.registerOnMessageListener( 401019, mOrderStatusMsgListener = new OrderStatusMsgListener() );
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getSocketManagerApi(context)
|
||||
.registerLifecycleListener(10010,mSocketLifeCycleLisnter = new OCHSocketLifeCycleLisnter());
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getAdasControllerApi()
|
||||
@@ -137,9 +142,9 @@ class MogoOCHTaxiModel {
|
||||
// if ( NetworkUtils.isConnected( mContext ) ) {
|
||||
// restoreOrderInfo();
|
||||
// }
|
||||
// if ( NetworkUtils.isConnected( mContext ) ) {
|
||||
// querryCarStatus();
|
||||
// }
|
||||
if ( NetworkUtils.isConnected( mContext ) ) {
|
||||
querryCarStatus();
|
||||
}
|
||||
}
|
||||
|
||||
public void querryCarStatus() {
|
||||
@@ -153,6 +158,7 @@ class MogoOCHTaxiModel {
|
||||
Logger.e(TAG,"querryCarStatus:"+data.data.status);
|
||||
|
||||
mOCHRHCarstatus = data.data.status == 1 ? 1:0;
|
||||
|
||||
//更新view
|
||||
OCHTaxiUiController.getInstance().onOperationChanged(mOCHRHCarstatus==1);
|
||||
//刷新数据
|
||||
@@ -186,39 +192,9 @@ class MogoOCHTaxiModel {
|
||||
private void restoreOrderInfo() {
|
||||
Logger.d( TAG, "重新查询订单状态" );
|
||||
mRetryCounter = 0;
|
||||
if ( mCurrentOCHOrder == null ) {
|
||||
// 订单恢复
|
||||
String orderInfo = SharedPrefsMgr.getInstance( mContext ).getString( SP_KEY_OCH_TAXI_ORDER );
|
||||
Logger.d(TAG,"restoreOrderInfo:"+orderInfo);
|
||||
if ( !TextUtils.isEmpty( orderInfo ) ) {
|
||||
mCurrentOCHOrder = GsonUtil.objectFromJson( orderInfo, OCHTaxiOrderResponse.class );
|
||||
}
|
||||
}
|
||||
query2RestoreOrderStatus(mCurrentOCHOrder == null ? null : mCurrentOCHOrder.orderNo);
|
||||
query2RestoreOrderStatus(null);
|
||||
}
|
||||
|
||||
// private void restoreOrderInfo_() {
|
||||
// Logger.d( TAG, "重新查询订单状态" );
|
||||
// mRetryCounter = 0;
|
||||
// if ( mCurrentOCHOrder == null ) {
|
||||
// // 订单恢复
|
||||
// String orderInfo = SharedPrefsMgr.getInstance( mContext ).getString( SP_KEY_OCH_TAXI_ORDER );
|
||||
// if ( !TextUtils.isEmpty( orderInfo ) ) {
|
||||
// mCurrentOCHOrder = GsonUtil.objectFromJson( orderInfo, OCHTaxiOrderResponse.class );
|
||||
// if ( mCurrentOCHOrder == null ) {
|
||||
// // 解决本地没有缓存订单号的问题
|
||||
// query2RestoreOrderStatus( null );
|
||||
// } else {
|
||||
// query2RestoreOrderStatus( mCurrentOCHOrder.orderNo );
|
||||
// }
|
||||
// } else {
|
||||
// // 解决本地没有缓存订单号的问题
|
||||
// query2RestoreOrderStatus( null );
|
||||
// }
|
||||
// } else {
|
||||
// query2RestoreOrderStatus( mCurrentOCHOrder.orderNo );
|
||||
// }
|
||||
// }
|
||||
/**
|
||||
* 查询订单状态,来恢复旧订单(因crash导致应用重启、断网没收到推送等)状态
|
||||
* <p>
|
||||
@@ -236,7 +212,7 @@ class MogoOCHTaxiModel {
|
||||
queryOCHOrderStatus( orderNo, new OCHOrderStatusCallback< OCHTaxiOrderResponse2 >() {
|
||||
@Override
|
||||
public void onSuccess( OCHTaxiOrderResponse2 data ) {
|
||||
|
||||
Logger.d( TAG, "query2RestoreOrderStatus:"+ data.toString());
|
||||
if ( data == null || data.data == null) {
|
||||
Logger.d( TAG, "订单已取消或已完成" );
|
||||
clearCurrentOCHOrder();
|
||||
@@ -247,7 +223,7 @@ class MogoOCHTaxiModel {
|
||||
OCHOrderStatus status = OCHOrderStatus.valueOf( data.data.orderDispatchType );
|
||||
OCHTaxiUiController.getInstance().onOrderStatusChanged(data.data.orderDispatchType);
|
||||
switch ( status ) {
|
||||
case Completed:
|
||||
case JourneyCompleted:
|
||||
TipToast.shortTip( mContext.getString( R.string.module_och_taxi_order_completed ) );
|
||||
clearCurrentOCHOrder();
|
||||
// OCHTaxiUiController.getInstance().removeFragment();
|
||||
@@ -258,6 +234,7 @@ class MogoOCHTaxiModel {
|
||||
// OCHTaxiUiController.getInstance().removeFragment();
|
||||
break;
|
||||
case ArriveAtEndStation:
|
||||
case UserState:
|
||||
mIsArriveAtEndStation = true;
|
||||
mIsArriveAtStartStation = false;
|
||||
mIsOnTheWay2EndStation = false;
|
||||
@@ -311,6 +288,58 @@ class MogoOCHTaxiModel {
|
||||
} );
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于长连接
|
||||
* @param orderNo
|
||||
*/
|
||||
private void querryOrderStatusForMakeUp( String orderNo ) {
|
||||
Logger.e(TAG,"querryOrderStatusForMakeUp:"+orderNo);
|
||||
queryOCHOrderStatus( orderNo, new OCHOrderStatusCallback< OCHTaxiOrderResponse2 >() {
|
||||
@Override
|
||||
public void onSuccess( OCHTaxiOrderResponse2 data ) {
|
||||
Logger.d( TAG, "querryOrderStatusForMakeUp:"+ data.toString());
|
||||
if ( data == null || data.data == null) {
|
||||
Logger.d( TAG, "订单已取消或已完成" );
|
||||
clearCurrentOCHOrder();
|
||||
OCHTaxiUiController.getInstance().onOrderStatusChanged(OCHOrderStatus.None.getCode());
|
||||
return;
|
||||
}
|
||||
convertCurrentOrder( data );
|
||||
OCHOrderStatus status = OCHOrderStatus.valueOf( data.data.orderDispatchType );
|
||||
switch ( status ) {
|
||||
case JourneyCompleted:
|
||||
TipToast.shortTip( mContext.getString( R.string.module_och_taxi_order_completed ) );
|
||||
OCHTaxiUiController.getInstance().onOrderStatusChanged(data.data.orderDispatchType);
|
||||
clearCurrentOCHOrder();
|
||||
break;
|
||||
case Cancel:
|
||||
TipToast.shortTip( mContext.getString( R.string.module_och_taxi_order_cancel ) );
|
||||
OCHTaxiUiController.getInstance().onOrderStatusChanged(data.data.orderDispatchType);
|
||||
clearCurrentOCHOrder();
|
||||
break;
|
||||
case OnTheWayToStartStation:
|
||||
default:
|
||||
mIsArriveAtStartStation = false;
|
||||
mIsArriveAtEndStation = false;
|
||||
mIsOnTheWay2EndStation = false;
|
||||
OCHTaxiUiController.getInstance().onOrderStatusChanged(data.data.orderDispatchType);
|
||||
mOrderMsgListener.onMsgReceived( mCurrentOCHOrder );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail() {
|
||||
Logger.w( TAG, "查询订单失败" );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
/**
|
||||
* 将查询到的订单转换成推送的订单数据,目前两者数据结构不一样
|
||||
*
|
||||
@@ -332,18 +361,26 @@ class MogoOCHTaxiModel {
|
||||
mCurrentOCHOrder.drivingRoutes = new ArrayList<>();
|
||||
OCHTaxiOrderResponse.OCHTaxiStation startStation = new OCHTaxiOrderResponse.OCHTaxiStation();
|
||||
List< Double > startStationCoordinate = data.data.startStationCoordinate;
|
||||
if (startStationCoordinate != null && startStationCoordinate.size()>1){
|
||||
startStation.lon = startStationCoordinate.get( 0 );
|
||||
startStation.lat = startStationCoordinate.get( 1 );
|
||||
List< Double > startGcjStationCoordinate = data.data.startGcjStationCoordinate;
|
||||
if (startStationCoordinate != null && startStationCoordinate.size()>1 &&
|
||||
startGcjStationCoordinate!= null && startGcjStationCoordinate.size() > 1){
|
||||
startStation.lon = startGcjStationCoordinate.get( 0 );
|
||||
startStation.lat = startGcjStationCoordinate.get( 1 );
|
||||
startStation.wgsLon = startStationCoordinate.get(0);
|
||||
startStation.wgsLat = startStationCoordinate.get(1);
|
||||
startStation.siteId = data.data.startStationId;
|
||||
startStation.siteName = data.data.startStation;
|
||||
mCurrentOCHOrder.drivingRoutes.add( startStation );
|
||||
}
|
||||
OCHTaxiOrderResponse.OCHTaxiStation endStation = new OCHTaxiOrderResponse.OCHTaxiStation();
|
||||
List< Double > endStationCoordinate = data.data.endStationCoordinate;
|
||||
if (endStationCoordinate != null && endStationCoordinate.size()>1){
|
||||
endStation.lon = endStationCoordinate.get( 0 );
|
||||
endStation.lat = endStationCoordinate.get( 1 );
|
||||
List< Double > endGcjStationCoordinate = data.data.endGcjStationCoordinate;
|
||||
if (endStationCoordinate != null && endStationCoordinate.size()>1 &&
|
||||
endGcjStationCoordinate!=null && endGcjStationCoordinate.size() > 1){
|
||||
endStation.lon = endGcjStationCoordinate.get( 0 );
|
||||
endStation.lat = endGcjStationCoordinate.get( 1 );
|
||||
endStation.wgsLon = endStationCoordinate.get( 0 );
|
||||
endStation.wgsLat = endStationCoordinate.get( 1 );
|
||||
endStation.siteId = data.data.endStationId;
|
||||
endStation.siteName = data.data.endStation;
|
||||
mCurrentOCHOrder.drivingRoutes.add( endStation );
|
||||
@@ -388,8 +425,6 @@ class MogoOCHTaxiModel {
|
||||
super.onSuccess(o);
|
||||
Logger.d(TAG,"OCHCarStatusResponse:"+o.data.status);
|
||||
mOCHRHCarstatus = o.data.status;
|
||||
// mIsWork = mOCHRHCarstatus.status == 1;
|
||||
// mOCHRHCarstatus.status = status;
|
||||
OCHTaxiUiController.getInstance().onOperationChanged(mOCHRHCarstatus == 1);
|
||||
updateData(mOCHRHCarstatus);
|
||||
Logger.d(TAG,"changeCarStatus:"+status);
|
||||
@@ -472,6 +507,7 @@ class MogoOCHTaxiModel {
|
||||
updateOCHOrderStatus( OCHOrderStatus.ArriveAtStartStation, new OCHOrderStatusCallback() {
|
||||
@Override
|
||||
public void onSuccess( Object data ) {
|
||||
OCHTaxiUiController.getInstance().onOrderStatusChanged(OCHOrderStatus.ArriveAtStartStation.getCode());
|
||||
Logger.d( TAG, "更新状态成功" );
|
||||
}
|
||||
|
||||
@@ -488,7 +524,7 @@ class MogoOCHTaxiModel {
|
||||
} );
|
||||
return;
|
||||
}
|
||||
Logger.d( TAG, "distance = %s", distance );
|
||||
// Logger.d( TAG, "distance = %s", distance );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -507,14 +543,6 @@ class MogoOCHTaxiModel {
|
||||
return mIsArriveAtEndStation;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 用户是否达到上车站点
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// public boolean isUserArriveAtStartStation() {
|
||||
// return mIsUserArriveAtStartStation;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 设置去往终点状态
|
||||
@@ -553,6 +581,7 @@ class MogoOCHTaxiModel {
|
||||
return;
|
||||
}
|
||||
Logger.d( TAG, "收到新订单" + GsonUtil.jsonFromObject(obj));
|
||||
|
||||
mCurrentOCHOrder = obj;
|
||||
cacheOrderInfo2Native( mCurrentOCHOrder );
|
||||
Location location = MogoApisHandler.getInstance()
|
||||
@@ -564,7 +593,6 @@ class MogoOCHTaxiModel {
|
||||
if ( !isArriveAtStartStation() ) {
|
||||
registerCarLocationListener();
|
||||
}
|
||||
// OCHTaxiUiController.getInstance().addFragment();
|
||||
OCHTaxiUiController.getInstance().onOrderStatusChanged(mCurrentOCHOrder.orderDispatchType);
|
||||
}
|
||||
}
|
||||
@@ -605,6 +633,13 @@ class MogoOCHTaxiModel {
|
||||
.unregisterCarLocationChangedListener( TAG, mCarLocationChangedListener2 );
|
||||
}
|
||||
|
||||
public void unregisterSocketListener(){
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getSocketManagerApi(mContext)
|
||||
.unregisterLifecycleListener(10010);
|
||||
}
|
||||
|
||||
/**
|
||||
* 后端长链推送通知订单状态被改变
|
||||
*/
|
||||
@@ -623,17 +658,16 @@ class MogoOCHTaxiModel {
|
||||
if (mOCHRHCarstatus != 1){
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.d(TAG, "订单状态被改变:" + GsonUtil.jsonFromObject(obj));
|
||||
OCHOrderStatus status = OCHOrderStatus.valueOf( obj.orderDispatchType );
|
||||
switch ( status ) {
|
||||
case Cancel:
|
||||
clearCurrentOCHOrder();
|
||||
// OCHTaxiUiController.getInstance().removeFragment();
|
||||
OCHTaxiUiController.getInstance().onOrderStatusChanged(status.getCode());
|
||||
break;
|
||||
case UserArriveAtStartStation:
|
||||
mIsArriveAtStartStation = true;
|
||||
// mIsUserArriveAtStartStation = true;
|
||||
OCHTaxiUiController.getInstance().onUserArriveAtStartStation();
|
||||
break;
|
||||
default:
|
||||
@@ -643,6 +677,38 @@ class MogoOCHTaxiModel {
|
||||
}
|
||||
}
|
||||
|
||||
private class OCHSocketLifeCycleLisnter implements IMogoLifecycleListener {
|
||||
|
||||
@Override
|
||||
public void onConnectFailure() {
|
||||
Logger.e(TAG,"socket onConnectFailure");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectSuccess() {
|
||||
Logger.e(TAG,"socket onConnectSuccess");
|
||||
stopSocketMakeUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectLost() {
|
||||
Logger.e(TAG,"socket onConnectLost");
|
||||
startSocketMakeUp();
|
||||
}
|
||||
}
|
||||
|
||||
public void startSocketMakeUp(){
|
||||
if (mOCHRHCarstatus == 1){
|
||||
timeLoop();
|
||||
}
|
||||
}
|
||||
|
||||
public void stopSocketMakeUp(){
|
||||
if (mDisposable != null){
|
||||
mDisposable.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动驾驶本地通知订单到站
|
||||
*/
|
||||
@@ -789,8 +855,8 @@ class MogoOCHTaxiModel {
|
||||
|
||||
RemoteControlAutoPilotParameters parameters = new RemoteControlAutoPilotParameters();
|
||||
parameters.vehicleType = mCurrentOCHOrder.orderType;
|
||||
parameters.startLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat( mCurrentOCHOrder.drivingRoutes.get( 0 ).lat, mCurrentOCHOrder.drivingRoutes.get( 0 ).lon );
|
||||
parameters.endLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat( mCurrentOCHOrder.drivingRoutes.get( 1 ).lat, mCurrentOCHOrder.drivingRoutes.get( 1 ).lon );
|
||||
parameters.startLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat( mCurrentOCHOrder.drivingRoutes.get( 0 ).wgsLat, mCurrentOCHOrder.drivingRoutes.get( 0 ).wgsLon );
|
||||
parameters.endLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat( mCurrentOCHOrder.drivingRoutes.get( 1 ).wgsLat, mCurrentOCHOrder.drivingRoutes.get( 1 ).wgsLon );
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getAdasControllerApi()
|
||||
@@ -807,6 +873,16 @@ class MogoOCHTaxiModel {
|
||||
return mCurrentOCHOrder;
|
||||
}
|
||||
|
||||
public void calculateTravelDistance(Location carLocation){
|
||||
if (mCurrentOCHOrder.drivingRoutes != null && mCurrentOCHOrder.drivingRoutes.size()>0){
|
||||
OCHTaxiOrderResponse.OCHTaxiStation endStationOCHLocation = mCurrentOCHOrder.drivingRoutes.get(1);
|
||||
double distance = CoordinateUtils.calculateLineDistance(
|
||||
endStationOCHLocation.lon, endStationOCHLocation.lat,
|
||||
carLocation.getLongitude(), carLocation.getLatitude());
|
||||
mCurrentOCHOrder.decreaseTravelDistance(distance);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束自动驾驶
|
||||
*/
|
||||
@@ -822,4 +898,18 @@ class MogoOCHTaxiModel {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static final int PERIOD = 1 * 1000;
|
||||
private static final int DELAY = 100;
|
||||
private Disposable mDisposable;
|
||||
/**
|
||||
* 定时循环任务
|
||||
*/
|
||||
private void timeLoop() {
|
||||
mDisposable = Observable.interval(DELAY, PERIOD, TimeUnit.MILLISECONDS)
|
||||
.map((aLong -> aLong + 1))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(aLong -> querryOrderStatusForMakeUp(null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,9 @@ enum OCHOrderStatus {
|
||||
UserArriveAtStartStation( 3 ),
|
||||
OnTheWayToEndStation( 4 ),
|
||||
ArriveAtEndStation( 5 ),
|
||||
Completed( 6 ),
|
||||
Cancel( 7 );
|
||||
UserState( 6 ),//小程序用的状态 车机不处理
|
||||
Cancel( 7 ),
|
||||
JourneyCompleted(8);//行程完成
|
||||
|
||||
private int code;
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class OCHTaxiOrderResponse implements Parcelable {
|
||||
* @param distance
|
||||
*/
|
||||
public void decreaseTravelDistance( double distance ) {
|
||||
travelDistance -= ( ( float ) distance / 1000f );
|
||||
travelDistance = ( ( float ) distance / 1000f );
|
||||
if ( travelDistance < 0 ) {
|
||||
travelDistance = 0;
|
||||
}
|
||||
@@ -42,9 +42,10 @@ class OCHTaxiOrderResponse implements Parcelable {
|
||||
public static class OCHTaxiStation implements Parcelable {
|
||||
public String siteId;
|
||||
public String siteName;
|
||||
public double lon;
|
||||
public double lon;// 用于计算距离
|
||||
public double lat;
|
||||
|
||||
public double wgsLon;//用于自动驾驶
|
||||
public double wgsLat;
|
||||
public OCHTaxiStation() {
|
||||
}
|
||||
|
||||
@@ -59,6 +60,8 @@ class OCHTaxiOrderResponse implements Parcelable {
|
||||
dest.writeString( this.siteName );
|
||||
dest.writeDouble( this.lon );
|
||||
dest.writeDouble( this.lat );
|
||||
dest.writeDouble( this.wgsLon );
|
||||
dest.writeDouble( this.wgsLat );
|
||||
}
|
||||
|
||||
protected OCHTaxiStation( Parcel in ) {
|
||||
@@ -66,6 +69,8 @@ class OCHTaxiOrderResponse implements Parcelable {
|
||||
this.siteName = in.readString();
|
||||
this.lon = in.readDouble();
|
||||
this.lat = in.readDouble();
|
||||
this.wgsLon = in.readDouble();
|
||||
this.wgsLat = in.readDouble();
|
||||
}
|
||||
|
||||
public static final Creator< OCHTaxiStation > CREATOR = new Creator< OCHTaxiStation >() {
|
||||
|
||||
@@ -36,6 +36,7 @@ class OCHTaxiOrderResponse2 extends BaseData {
|
||||
public String startStationId;
|
||||
// 起点站点
|
||||
public List< Double > startStationCoordinate;
|
||||
public List< Double > startGcjStationCoordinate;//高德坐标系 用于距离计算
|
||||
|
||||
// 目的站名称
|
||||
public String endStation;
|
||||
@@ -43,6 +44,7 @@ class OCHTaxiOrderResponse2 extends BaseData {
|
||||
public String endStationId;
|
||||
// 终点站点
|
||||
public List< Double > endStationCoordinate;
|
||||
public List< Double > endGcjStationCoordinate;//高德坐标系 用于距离计算
|
||||
|
||||
public String orderStartTime;
|
||||
public String cityCode;
|
||||
|
||||
@@ -8,9 +8,6 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
@@ -30,23 +27,13 @@ import com.mogo.och.view.SlidePanelView;
|
||||
import com.mogo.service.adas.IMogoAdasOCHCallback;
|
||||
import com.mogo.service.adas.IMogoAdasRouteCallBack;
|
||||
import com.mogo.service.adas.entity.AdasOCHData;
|
||||
import com.mogo.service.adas.IMogoAdasRouteCallBack;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.RequestOptions;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -80,6 +67,7 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
private TextView mDistance;
|
||||
|
||||
private MogoPolylineOptions mogoPolylineOptions;
|
||||
private volatile int saveOrderState = -1;
|
||||
@Override
|
||||
public int getStationPanelViewId() {
|
||||
return R.layout.module_och_taxi_panel;
|
||||
@@ -170,6 +158,7 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSpeakedEndingNotice = false;
|
||||
/**
|
||||
* 初始化订单信息
|
||||
*/
|
||||
@@ -180,7 +169,6 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
slidePanelView.setVisibility( View.VISIBLE );
|
||||
slidePanelView.setText( getString( R.string.module_och_taxi_arrive_at_end_station ) );
|
||||
mOrderStatus.setText( R.string.module_och_taxi_arrive_at_end_station2 );
|
||||
showNotice( getString( R.string.module_och_taxi_order_complete_1) );
|
||||
} else if ( MogoOCHTaxiModel.getInstance().isOnTheWay2EndStation() ) {
|
||||
Logger.d( TAG, "已经去往终点" );
|
||||
slidePanelView.setVisibility( View.GONE );
|
||||
@@ -188,15 +176,6 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
} else if ( MogoOCHTaxiModel.getInstance().isArriveAtStartStation() ) {
|
||||
Logger.d( TAG, "已经达到起点" );
|
||||
mOrderStatus.setText( R.string.module_och_taxi_waiting );
|
||||
// if ( MogoOCHTaxiModel.getInstance().isUserArriveAtStartStation() ) {
|
||||
// Logger.d( TAG, "乘客已上车" );
|
||||
// slidePanelView.setVisibility( View.VISIBLE );
|
||||
//// if ( MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() == IMogoAdasOCHCallback.STATUS_AUTOPILOT_ENABLE ) {
|
||||
//// } else {
|
||||
//// slidePanelView.setVisibility( View.GONE );
|
||||
//// }
|
||||
// slidePanelView.setText( getString( R.string.module_och_taxi_arrive_at_start_station ) );
|
||||
// }
|
||||
slidePanelView.setVisibility( View.VISIBLE );
|
||||
slidePanelView.setText( getString( R.string.module_och_taxi_arrive_at_start_station ) );
|
||||
} else if ( MogoOCHTaxiModel.getInstance().checkCurrentOCHOrder() ) {
|
||||
@@ -206,6 +185,13 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void SpeakNoticeOnce(){
|
||||
if (!isSpeakedEndingNotice){
|
||||
isSpeakedEndingNotice = true;
|
||||
showNotice( getString( R.string.module_och_taxi_order_complete_1) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新订单基本信息
|
||||
*/
|
||||
@@ -246,6 +232,7 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
@Override
|
||||
public void onSuccess( Object data ) {
|
||||
Logger.d( TAG, "更新状态成功" );
|
||||
onOrderStatusChanged(OCHOrderStatus.ArriveAtEndStation.getCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -259,10 +246,10 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
Logger.d( TAG, "更新状态失败2" );
|
||||
}
|
||||
} );
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getRegisterCenterApi()
|
||||
.unregisterCarLocationChangedListener( TAG, this );
|
||||
// MogoApisHandler.getInstance()
|
||||
// .getApis()
|
||||
// .getRegisterCenterApi()
|
||||
// .unregisterCarLocationChangedListener( TAG, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -292,6 +279,7 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
.getRegisterCenterApi()
|
||||
.unregisterCarLocationChangedListener( TAG, this );
|
||||
MogoOCHTaxiModel.getInstance().unregisterCarLocationListener();
|
||||
MogoOCHTaxiModel.getInstance().unregisterSocketListener();
|
||||
mLocation = null;
|
||||
}
|
||||
|
||||
@@ -303,7 +291,7 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
private void onSlidePanelMoveToEnd() {
|
||||
// 已到达终点,需要结束订单
|
||||
if ( MogoOCHTaxiModel.getInstance().isArriveAtEndStation() ) {
|
||||
MogoOCHTaxiModel.getInstance().updateOCHOrderStatus( OCHOrderStatus.Completed, new OCHOrderStatusCallback() {
|
||||
MogoOCHTaxiModel.getInstance().updateOCHOrderStatus( OCHOrderStatus.JourneyCompleted, new OCHOrderStatusCallback() {
|
||||
@Override
|
||||
public void onSuccess( Object data ) {
|
||||
Logger.d( TAG, "更新状态成功" );
|
||||
@@ -325,7 +313,6 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
return;
|
||||
// 乘客已确认到达起点,前往下一站并开启自动驾驶
|
||||
} else if ( !MogoOCHTaxiModel.getInstance().isOnTheWay2EndStation() ) {
|
||||
// MogoOCHTaxiModel.getInstance().isUserArriveAtStartStation() &&
|
||||
MogoOCHTaxiModel.getInstance().startAutoPilot();
|
||||
}
|
||||
}
|
||||
@@ -334,7 +321,7 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
public void onAutoPilotStatusChanged( int status, String reason ) {
|
||||
Logger.d( TAG, "status = %s, reason = %s", status, reason );
|
||||
onAutopilotStatusChanged( status == IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING );
|
||||
if ( status == IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING ) {
|
||||
if ( status == IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING && !MogoOCHTaxiModel.getInstance().isArriveAtEndStation()) {
|
||||
resetOCHTaxiOrderAutopilotStatus();
|
||||
} else {
|
||||
updateOrderStatus();
|
||||
@@ -350,6 +337,7 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
@Override
|
||||
public void onSuccess( Object data ) {
|
||||
Logger.d( TAG, "更新状态成功" );
|
||||
onOrderStatusChanged(OCHOrderStatus.OnTheWayToEndStation.getCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -367,7 +355,6 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged( MogoLatLng latLng ) {
|
||||
|
||||
}
|
||||
|
||||
private Location mLocation;
|
||||
@@ -377,18 +364,17 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
OCHTaxiUiController.getInstance().runOnUIThread( () -> {
|
||||
calculateTravelDistance( location );
|
||||
} );
|
||||
|
||||
//坐标转换
|
||||
MogoLocation loc = new MogoLocation();
|
||||
loc.setTime(loc.getTime());
|
||||
loc.setAccuracy(location.getAccuracy());
|
||||
loc.setSpeed(location.getSpeed());
|
||||
loc.setLongitude(location.getLongitude());
|
||||
loc.setLatitude(location.getLatitude());
|
||||
loc.setAltitude(location.getAltitude());
|
||||
loc.setBearing(location.getBearing());
|
||||
loc.setProvider(location.getProvider());
|
||||
mogoLocation = loc;
|
||||
// //坐标转换
|
||||
// MogoLocation loc = new MogoLocation();
|
||||
// loc.setTime(loc.getTime());
|
||||
// loc.setAccuracy(location.getAccuracy());
|
||||
// loc.setSpeed(location.getSpeed());
|
||||
// loc.setLongitude(location.getLongitude());
|
||||
// loc.setLatitude(location.getLatitude());
|
||||
// loc.setAltitude(location.getAltitude());
|
||||
// loc.setBearing(location.getBearing());
|
||||
// loc.setProvider(location.getProvider());
|
||||
// mogoLocation = loc;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -400,21 +386,26 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
if ( location == null ) {
|
||||
return;
|
||||
}
|
||||
if ( !MogoOCHTaxiModel.getInstance().isOnTheWay2EndStation() ) {
|
||||
return;
|
||||
}
|
||||
if ( MogoOCHTaxiModel.getInstance().isArriveAtEndStation() ) {
|
||||
return;
|
||||
}
|
||||
// if ( !MogoOCHTaxiModel.getInstance().isOnTheWay2EndStation() ) {
|
||||
// return;
|
||||
// }
|
||||
// if ( MogoOCHTaxiModel.getInstance().isArriveAtEndStation() ) {
|
||||
// return;
|
||||
// }
|
||||
if ( mLocation == null ) {
|
||||
mLocation = location;
|
||||
}
|
||||
double distance = CoordinateUtils.calculateLineDistance(
|
||||
location.getLongitude(), location.getLatitude(),
|
||||
mLocation.getLongitude(), mLocation.getLatitude()
|
||||
);
|
||||
if ( MogoOCHTaxiModel.getInstance().checkCurrentOCHOrder() ) {
|
||||
MogoOCHTaxiModel.getInstance().getCurrentOCHOrder().decreaseTravelDistance( distance );
|
||||
// double distance = CoordinateUtils.calculateLineDistance(
|
||||
// location.getLongitude(), location.getLatitude(),
|
||||
// mLocation.getLongitude(), mLocation.getLatitude()
|
||||
// );
|
||||
// Logger.e("lianglihui","calculateTravelDistance:"+distance);
|
||||
|
||||
if ( MogoOCHTaxiModel.getInstance().isOnTheWay2EndStation() &&
|
||||
MogoOCHTaxiModel.getInstance().checkCurrentOCHOrder() &&
|
||||
!MogoOCHTaxiModel.getInstance().isArriveAtEndStation()) {
|
||||
MogoOCHTaxiModel.getInstance().calculateTravelDistance(location);
|
||||
// MogoOCHTaxiModel.getInstance().getCurrentOCHOrder().decreaseTravelDistance( distance );
|
||||
updateOrderBaseStatusInfo();
|
||||
}
|
||||
mLocation = location;
|
||||
@@ -443,15 +434,46 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
|
||||
@Override
|
||||
public void onOrderStatusChanged(int status) {
|
||||
|
||||
// int orderState = MogoOCHTaxiModel.getInstance().getCurrentOCHOrder().orderDispatchType;
|
||||
// if (orderState == status){
|
||||
// return;
|
||||
// }
|
||||
getActivity().runOnUiThread(() -> {
|
||||
if (status == OCHOrderStatus.None.getCode() || status == OCHOrderStatus.Cancel.getCode() || status == OCHOrderStatus.Completed.getCode() ){
|
||||
if (status == OCHOrderStatus.None.getCode() || status == OCHOrderStatus.Cancel.getCode() || status == OCHOrderStatus.JourneyCompleted.getCode() ){
|
||||
getPanelView().setVisibility(View.INVISIBLE);
|
||||
hideSlidePanel();
|
||||
changeOperationViewVisible(View.VISIBLE);
|
||||
}else {
|
||||
isSpeakedEndingNotice = false;
|
||||
} else {
|
||||
getPanelView().setVisibility(View.VISIBLE);
|
||||
changeOperationViewVisible(View.INVISIBLE);
|
||||
}
|
||||
|
||||
if(status != saveOrderState){
|
||||
OCHOrderStatus ochStatus = OCHOrderStatus.valueOf( status );
|
||||
switch (ochStatus){
|
||||
case OnTheWayToStartStation:
|
||||
showNotice(getString( R.string.module_och_taxi_new_order));
|
||||
break;
|
||||
case Cancel:
|
||||
showNotice(getString( R.string.module_och_taxi_order_cancel));
|
||||
break;
|
||||
case ArriveAtStartStation:
|
||||
showNotice( getString( R.string.module_och_taxi_order_status_ph_text) );
|
||||
break;
|
||||
case OnTheWayToEndStation:
|
||||
// showNotice("欢迎使用蘑菇智行");
|
||||
break;
|
||||
case ArriveAtEndStation:
|
||||
showNotice( getString( R.string.module_och_taxi_order_complete_1) );
|
||||
break;
|
||||
case JourneyCompleted:
|
||||
showNotice( "感谢您使用蘑菇智行,再见~" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
saveOrderState = status;
|
||||
updateOrderStatus();
|
||||
});
|
||||
}
|
||||
@@ -460,11 +482,11 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
@Override
|
||||
public void routeResult(List<MogoLatLng> routeList) {
|
||||
if (routeList == null ) return;
|
||||
double distance = calculateTravelDistance(mogoLocation,routeList);
|
||||
if ( MogoOCHTaxiModel.getInstance().checkCurrentOCHOrder() ) {
|
||||
MogoOCHTaxiModel.getInstance().getCurrentOCHOrder().decreaseTravelDistance( distance );
|
||||
updateOrderBaseStatusInfo();
|
||||
}
|
||||
// double distance = calculateTravelDistance(mogoLocation,routeList);
|
||||
// if ( MogoOCHTaxiModel.getInstance().checkCurrentOCHOrder() ) {
|
||||
// MogoOCHTaxiModel.getInstance().getCurrentOCHOrder().decreaseTravelDistance( distance );
|
||||
// updateOrderBaseStatusInfo();
|
||||
// }
|
||||
// Logger.d("lianglihui","routeResult 剩余导航距离:"+distance);
|
||||
// if (routeList != null && routeList.size() >0){
|
||||
// Logger.d("lianglihui","routeResult:"+routeList.size());
|
||||
@@ -482,7 +504,7 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
MogoLatLng routeLatLng;
|
||||
for (int i = 0 ; i< routeList.size() ; i++) {
|
||||
routeLatLng =routeList.get(i);
|
||||
//需要剔除已经行驶过的经纬度,这里需要比对推荐路线集合中的点是否在当前车辆行驶方向前面如果不在则抛弃
|
||||
//需要剔除已经行驶过的经纬度,这里需要比对推荐路线集合中点是否在当前车w辆行驶方向前面如果不在则抛弃
|
||||
if (LocationUtils.isPointOnCarFront(carLocation, routeLatLng)) {
|
||||
mPolylinePointList.add(routeLatLng);
|
||||
}
|
||||
@@ -506,7 +528,6 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
|
||||
public void onArriveAt(AdasOCHData data) {
|
||||
Logger.d( TAG, "行程结束");
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().cancelAutopilot();
|
||||
// AIAssist.getInstance( getContext() ).speakTTSVoice( "即将到达目的地,请您携带好随身物品,安全下车。" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
android:id="@+id/module_och_taxi_layoutview"
|
||||
android:layout_width="@dimen/module_mogo_och_autopilot_order_bg_width"
|
||||
android:layout_height="@dimen/module_mogo_och_autopilot_order_bg_height"
|
||||
android:minHeight="@dimen/module_mogo_och_autopilot_order_bg_height"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
@@ -63,13 +62,10 @@
|
||||
android:layout_marginLeft="@dimen/module_och_taxi_order_start_station_marginLeft"
|
||||
android:textColor="@color/module_och_order_status_textColor"
|
||||
android:textSize="@dimen/module_och_taxi_order_start_station_textSize"
|
||||
android:ellipsize="end"
|
||||
android:maxWidth="252px"
|
||||
android:lines="2"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintLeft_toRightOf="@+id/greenDot"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="后路站后路站后路站后路站后路站" />
|
||||
tools:text="后路站" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_och_taxi_order_start_station_anchor"
|
||||
@@ -111,9 +107,6 @@
|
||||
android:textColor="@color/module_och_order_status_textColor"
|
||||
android:textSize="@dimen/module_och_taxi_order_start_station_textSize"
|
||||
android:textStyle="bold"
|
||||
android:ellipsize="end"
|
||||
android:maxWidth="252px"
|
||||
android:lines="2"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/module_och_taxi_order_start_station"
|
||||
app:layout_constraintLeft_toRightOf="@+id/greenDot"
|
||||
@@ -135,112 +128,6 @@
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
<!-- <LinearLayout-->
|
||||
<!-- android:id="@+id/module_och_taxi_order_status_stationInfo"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:orientation="vertical"-->
|
||||
<!-- android:paddingLeft="@dimen/module_och_taxi_order_status_stationInfo_paddingLeft"-->
|
||||
<!-- android:paddingTop="@dimen/module_och_taxi_order_status_stationInfo_paddingTop"-->
|
||||
<!-- android:paddingRight="@dimen/module_och_taxi_order_status_stationInfo_paddingRight"-->
|
||||
<!-- android:paddingBottom="@dimen/module_och_taxi_order_status_stationInfo_paddingBottom"-->
|
||||
|
||||
<!-- app:layout_constraintTop_toBottomOf="@+id/module_och_taxi_order_status_divider">-->
|
||||
<!-- >-->
|
||||
<!-- <RelativeLayout-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:orientation="horizontal">-->
|
||||
<!-- <ImageView-->
|
||||
<!-- android:id="@+id/greenDot"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:src="@drawable/module_mogo_och_icon_arriving_station"-->
|
||||
<!-- android:layout_centerVertical="true"-->
|
||||
<!-- />-->
|
||||
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/module_och_taxi_order_start_station"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:layout_marginLeft="@dimen/module_och_taxi_order_start_station_marginLeft"-->
|
||||
<!-- android:textColor="@color/module_och_order_status_textColor"-->
|
||||
<!-- android:textSize="@dimen/module_och_taxi_order_start_station_textSize"-->
|
||||
<!-- android:ellipsize="end"-->
|
||||
<!-- android:maxWidth="252px"-->
|
||||
<!-- android:lines="2"-->
|
||||
<!-- android:textStyle="bold"-->
|
||||
<!-- android:layout_toRightOf="@id/greenDot"-->
|
||||
<!-- tools:text="后路站后路站后路站后路站后路站" />-->
|
||||
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/module_och_taxi_order_start_station_anchor"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:text="上车"-->
|
||||
<!-- android:textColor="@color/module_och_taxi_order_start_station_anchor_textColor"-->
|
||||
<!-- android:layout_marginRight="@dimen/module_och_taxi_order_text_marginRight"-->
|
||||
<!-- android:textSize="@dimen/module_och_taxi_order_start_station_anchor_textSize"-->
|
||||
<!-- android:textStyle="bold"-->
|
||||
<!-- android:layout_alignParentRight="true"-->
|
||||
<!-- android:layout_centerVertical="true"-->
|
||||
<!-- />-->
|
||||
<!-- </RelativeLayout>-->
|
||||
|
||||
<!-- <ImageView-->
|
||||
<!-- android:id="@+id/dotLine"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="0dp"-->
|
||||
<!-- android:scaleType="fitXY"-->
|
||||
<!-- android:src="@drawable/module_och_dot_line"-->
|
||||
<!-- app:layout_constraintBottom_toTopOf="@+id/blueDot"-->
|
||||
<!-- app:layout_constraintLeft_toLeftOf="@+id/greenDot"-->
|
||||
<!-- app:layout_constraintRight_toRightOf="@+id/greenDot"-->
|
||||
<!-- app:layout_constraintTop_toBottomOf="@+id/greenDot" />-->
|
||||
|
||||
<!-- <RelativeLayout-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:orientation="horizontal">-->
|
||||
<!-- <ImageView-->
|
||||
<!-- android:id="@+id/blueDot"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:src="@drawable/module_mogo_och_icon_arrived_station"-->
|
||||
<!-- android:layout_centerVertical="true"-->
|
||||
<!-- />-->
|
||||
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/module_och_taxi_order_end_station"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:layout_marginLeft="@dimen/module_och_taxi_order_start_station_marginLeft"-->
|
||||
<!-- android:textColor="@color/module_och_order_status_textColor"-->
|
||||
<!-- android:textSize="@dimen/module_och_taxi_order_start_station_textSize"-->
|
||||
<!-- android:textStyle="bold"-->
|
||||
<!-- android:ellipsize="end"-->
|
||||
<!-- android:maxWidth="252px"-->
|
||||
<!-- android:lines="2"-->
|
||||
<!-- android:layout_toRightOf="@id/blueDot"-->
|
||||
<!-- tools:text="后路站后路站后路站后路站后路站" />-->
|
||||
|
||||
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/module_och_taxi_order_end_station_anchor"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:text="下车"-->
|
||||
<!-- android:layout_marginRight="@dimen/module_och_taxi_order_text_marginRight"-->
|
||||
<!-- android:textColor="@color/module_och_taxi_order_end_station_anchor_textColor"-->
|
||||
<!-- android:textSize="@dimen/module_och_taxi_order_end_station_anchor_textSize"-->
|
||||
<!-- android:textStyle="bold"-->
|
||||
<!-- android:layout_centerVertical="true"-->
|
||||
<!-- android:layout_alignParentRight="true"-->
|
||||
<!-- />-->
|
||||
<!-- </RelativeLayout>-->
|
||||
|
||||
<!-- </LinearLayout>-->
|
||||
<FrameLayout
|
||||
android:id="@+id/module_och_taxi_order_distance_container"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="module_och_taxi_arrive_at_start_station">乘客已上车,准备出发</string>
|
||||
<string name="module_och_taxi_arrive_at_start_station">确认上车,行程开始</string>
|
||||
<string name="module_och_taxi_arrive_at_end_station">到达站点,乘客已下车</string>
|
||||
<string name="module_och_taxi_order_status_ph_text">已到达上车站点,等待乘客上车</string>
|
||||
<string name="module_och_taxi_order_distance_anchor_text">预计里程</string>
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_shell_name"
|
||||
android:largeHeap="true"
|
||||
android:resizeableActivity="false"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme.App"
|
||||
android:resizeableActivity="false"
|
||||
tools:replace="android:label">
|
||||
|
||||
<!-- 配置APP ID -->
|
||||
@@ -45,9 +45,18 @@
|
||||
|
||||
<activity
|
||||
android:name="com.zhidao.boot.persistent.lib.PersistentAliveActivity"
|
||||
android:screenOrientation="landscape"
|
||||
android:resizeableActivity="false"
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
|
||||
|
||||
<receiver android:name=".SocketTestBroadCastReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="com.socket.test_panel_control" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.mogo.launcher;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Process;
|
||||
@@ -25,6 +24,7 @@ import com.mogo.module.carchatting.card.CallChatConstant;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.MogoModule;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.common.constants.HostConst;
|
||||
import com.mogo.module.main.service.MogoMainService;
|
||||
import com.mogo.module.push.base.PushUIConstants;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
@@ -57,6 +57,7 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
|
||||
private long start;
|
||||
private volatile static RefWatcher refWatcher;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
initDebugConfig();
|
||||
@@ -69,7 +70,7 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
CrashSystem crashSystem = CrashSystem.getInstance(this);
|
||||
crashSystem.init();
|
||||
//设置debug模式,日志不上传
|
||||
crashSystem.setDebug(BuildConfig.DEBUG);
|
||||
// crashSystem.setDebug(BuildConfig.DEBUG);
|
||||
Logger.init(BuildConfig.DEBUG ? LogLevel.DEBUG : LogLevel.OFF);
|
||||
initTipToast();
|
||||
initModules();
|
||||
@@ -120,16 +121,6 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
prepareBaseService();
|
||||
}
|
||||
|
||||
//todo
|
||||
protected HttpSimpleLocation getCurrentLocation() {
|
||||
MogoLocation location = MogoApisHandler.getInstance().getApis().getMapServiceApi().getSingletonLocationClient(this).getLastKnowLocation();
|
||||
if (location == null) {
|
||||
return null;
|
||||
} else {
|
||||
return new HttpSimpleLocation(location.getCityCode(), location.getLatitude(), location.getLongitude());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 基础服务:passport、location、socket
|
||||
*/
|
||||
@@ -177,9 +168,9 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
break;
|
||||
}
|
||||
// 设置应用服务AppId 长链、鉴权
|
||||
if(DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE){
|
||||
if (DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE) {
|
||||
clientConfig.setServiceAppId("com_mogo_launcher");
|
||||
}else{
|
||||
} else {
|
||||
clientConfig.setServiceAppId("com.mogo.launcher");
|
||||
}
|
||||
// 设置AI云平台分配给三方应用的签名密钥,需要从AI云平台申请
|
||||
@@ -189,69 +180,75 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
clientConfig.setLoopCheckDelay(15 * 1000);
|
||||
|
||||
// 设置DNS经纬度位置
|
||||
clientConfig.setIHttpDnsCurrentLocation(new IHttpDnsCurrentLocation() {
|
||||
@Override
|
||||
public HttpDnsSimpleLocation getCurrentLocation() {
|
||||
MogoLocation mogoLocation =
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis().getMapServiceApi()
|
||||
.getSingletonLocationClient(getApp())
|
||||
.getLastKnowLocation();
|
||||
HttpDnsSimpleLocation httpDnsSimpleLocation;
|
||||
if (mogoLocation != null
|
||||
&& mogoLocation.getLatitude() != 0
|
||||
&& mogoLocation.getLongitude() != 0) {
|
||||
httpDnsSimpleLocation = new HttpDnsSimpleLocation(
|
||||
mogoLocation.getCityCode(),
|
||||
mogoLocation.getLatitude(),
|
||||
mogoLocation.getLongitude());
|
||||
Logger.i(TAG, "使用实时GPS信息:" + httpDnsSimpleLocation);
|
||||
} else {
|
||||
String ciyCode = SharedPrefsMgr.getInstance(getApp())
|
||||
.getString(SharedPrefsConstants.LOCATION_CITY_CODE);
|
||||
String latitude = SharedPrefsMgr.getInstance(getApp())
|
||||
.getString(SharedPrefsConstants.LOCATION_LATITUDE);
|
||||
String longitude = SharedPrefsMgr.getInstance(getApp())
|
||||
.getString(SharedPrefsConstants.LOCATION_LONGITUDE);
|
||||
try {
|
||||
httpDnsSimpleLocation = new HttpDnsSimpleLocation(
|
||||
ciyCode,
|
||||
Double.parseDouble(latitude),
|
||||
Double.parseDouble(longitude));
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
httpDnsSimpleLocation = new HttpDnsSimpleLocation("010", 1, 1);
|
||||
}
|
||||
Logger.i(TAG, "使用缓存GPS信息:" + httpDnsSimpleLocation);
|
||||
}
|
||||
return httpDnsSimpleLocation;
|
||||
}
|
||||
clientConfig.setIHttpDnsCurrentLocation(() -> {
|
||||
SocketTestBroadCastReceiver.SocketTestData socketTestData = SocketTestBroadCastReceiver.SocketTestData.getInstance();
|
||||
Log.d("TEST-SOCKET","socketTestData cityCode: " + socketTestData.getCityCode());
|
||||
return new HttpDnsSimpleLocation(socketTestData.getCityCode(),socketTestData.getLat(),socketTestData.getLon()); //todo 对象唯一实例优化
|
||||
});
|
||||
// clientConfig.setIHttpDnsCurrentLocation(new IHttpDnsCurrentLocation() {
|
||||
// @Override
|
||||
// public HttpDnsSimpleLocation getCurrentLocation() {
|
||||
// MogoLocation mogoLocation =
|
||||
// MogoApisHandler.getInstance()
|
||||
// .getApis().getMapServiceApi()
|
||||
// .getSingletonLocationClient(getApp())
|
||||
// .getLastKnowLocation();
|
||||
// HttpDnsSimpleLocation httpDnsSimpleLocation;
|
||||
// if (mogoLocation != null
|
||||
// && mogoLocation.getLatitude() != 0
|
||||
// && mogoLocation.getLongitude() != 0) {
|
||||
// httpDnsSimpleLocation = new HttpDnsSimpleLocation(
|
||||
// mogoLocation.getCityCode(),
|
||||
// mogoLocation.getLatitude(),
|
||||
// mogoLocation.getLongitude());
|
||||
// Logger.i(TAG, "使用实时GPS信息:" + httpDnsSimpleLocation);
|
||||
// } else {
|
||||
// String ciyCode = SharedPrefsMgr.getInstance(getApp())
|
||||
// .getString(SharedPrefsConstants.LOCATION_CITY_CODE);
|
||||
// String latitude = SharedPrefsMgr.getInstance(getApp())
|
||||
// .getString(SharedPrefsConstants.LOCATION_LATITUDE);
|
||||
// String longitude = SharedPrefsMgr.getInstance(getApp())
|
||||
// .getString(SharedPrefsConstants.LOCATION_LONGITUDE);
|
||||
// try {
|
||||
// httpDnsSimpleLocation = new HttpDnsSimpleLocation(
|
||||
// ciyCode,
|
||||
// Double.parseDouble(latitude),
|
||||
// Double.parseDouble(longitude));
|
||||
// } catch (NumberFormatException e) {
|
||||
// e.printStackTrace();
|
||||
// httpDnsSimpleLocation = new HttpDnsSimpleLocation("010", 1, 1);
|
||||
// }
|
||||
// Logger.i(TAG, "使用缓存GPS信息:" + httpDnsSimpleLocation);
|
||||
// }
|
||||
// return httpDnsSimpleLocation;
|
||||
// }
|
||||
// });
|
||||
|
||||
// 初始化SDK,可以设置状态回调来监听
|
||||
MoGoAiCloudClient.getInstance().init(this, clientConfig).addTokenCallbacks(
|
||||
new IMoGoTokenCallback() {
|
||||
@Override
|
||||
public void onTokenGot(String token, String sn) {
|
||||
//todo
|
||||
Logger.d("TEST-SOCKET", "onTokenGot ");
|
||||
// 异步初始化NetConfig
|
||||
asyncInit();
|
||||
// 鉴权成功后开启socket长链服务
|
||||
prepareSocketAndLocationServices();
|
||||
// HttpDns ttl回调 --- socketTTL
|
||||
registerSocketHttpDnsTTL(HostConst.SOCKET_CENTER_DOMAIN);
|
||||
// 开启每5s/次定位上报
|
||||
uploadLocPerFiveSecond();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
Log.d(TAG,"初始化MogoAiCloudSdk failed ,reason : " + msg + " , 未能开启长链服务和初始化Modules服务");
|
||||
Log.d(TAG, "初始化MogoAiCloudSdk failed ,reason : " + msg + " , 未能开启长链服务和初始化Modules服务");
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private void prepareSocketAndLocationServices() {
|
||||
//开启Socket长链服务
|
||||
IMogoServiceApis apis = MogoApisHandler.getInstance().getApis();
|
||||
apis.getSocketManagerApi(getApplicationContext()).init(getApplicationContext(), DebugConfig.getSocketAppId());
|
||||
private void uploadLocPerFiveSecond(){
|
||||
if (DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_SELF_INNOVATE) {
|
||||
IMogoServiceApis apis = MogoApisHandler.getInstance().getApis();
|
||||
apis.getLocationInfoApi().start();
|
||||
apis.getMapServiceApi().getSingletonLocationClient(getApplicationContext()).addLocationListener(location -> {
|
||||
apis.getLocationInfoApi().provideLocation(location);
|
||||
@@ -259,8 +256,22 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
}
|
||||
}
|
||||
|
||||
private void initModules(){
|
||||
Logger.d(TAG,"initModules");
|
||||
private void prepareSocketAndLocationServices() {
|
||||
IMogoServiceApis apis = MogoApisHandler.getInstance().getApis();
|
||||
// 关闭长链服务
|
||||
apis.getSocketManagerApi(getApplicationContext()).destroy();
|
||||
// 开启Socket长链服务
|
||||
apis.getSocketManagerApi(getApplicationContext()).init(getApplicationContext(), DebugConfig.getSocketAppId());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void socketTTL() {
|
||||
// 鉴权成功后开启socket长链服务
|
||||
prepareSocketAndLocationServices();
|
||||
}
|
||||
|
||||
private void initModules() {
|
||||
Logger.d(TAG, "initModules");
|
||||
if (DebugConfig.isNeedLoadGuideModule()) {
|
||||
MogoModulePaths.addModule(new MogoModule(MogoModulePaths.PATH_GUIDE, MogoModulePaths.PATH_GUIDE));
|
||||
}
|
||||
@@ -309,8 +320,8 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
startService(intent);
|
||||
}
|
||||
|
||||
if (refWatcher == null){
|
||||
refWatcher = LeakCanary.install(this);
|
||||
if (refWatcher == null) {
|
||||
refWatcher = LeakCanary.install(this);
|
||||
}
|
||||
|
||||
// 初始化 bugly 升级
|
||||
@@ -320,18 +331,18 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
// }
|
||||
ARouter.getInstance().navigation(ITestCrashReportProvider.class);
|
||||
Log.i("timer", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
|
||||
try {
|
||||
if (DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_LENOVO) {
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent(new ComponentName("com.zhidao.speech.voice.pad",
|
||||
"com.zhidao.speech.MainActivity"));
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// try {
|
||||
// if (DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_LENOVO) {
|
||||
// Intent intent = new Intent();
|
||||
// intent.setComponent(new ComponentName("com.zhidao.speech",
|
||||
// "com.zhidao.speech.MainActivity"));
|
||||
// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
// startActivity(intent);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.mogo.launcher;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
public class SocketTestBroadCastReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final String TAG = "SocketTestBroadCastReceiver";
|
||||
|
||||
/**
|
||||
* Adas测试控制面板广播Action
|
||||
*/
|
||||
public static final String BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY = "sceneType";
|
||||
|
||||
private Context mContext;
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
try {
|
||||
this.mContext = context;
|
||||
int sceneType = intent.getIntExtra(BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY, 0);
|
||||
Logger.d(TAG, "textPanelOpenType:" + sceneType);
|
||||
// 分发场景
|
||||
dispatchSceneTest(sceneType);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void dispatchSceneTest(int sceneType) {
|
||||
if (sceneType == 0) {
|
||||
// 更改地址为衡阳
|
||||
SocketTestData socketTestData = SocketTestData.getInstance();
|
||||
socketTestData.setCityCode("0734");
|
||||
socketTestData.setLat(26.81624);
|
||||
socketTestData.setLon(112.580089);
|
||||
}
|
||||
if (sceneType == 1) {
|
||||
// 更改地址为北京
|
||||
SocketTestData socketTestData = SocketTestData.getInstance();
|
||||
socketTestData.setCityCode("010");
|
||||
socketTestData.setLat(40.1993457314);
|
||||
socketTestData.setLon(116.7355931215);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SocketTestData {
|
||||
|
||||
private SocketTestData(){}
|
||||
|
||||
private static final byte[] bytes = new byte[0];
|
||||
|
||||
private volatile static SocketTestData instance;
|
||||
|
||||
public static SocketTestData getInstance(){
|
||||
if(instance == null){
|
||||
synchronized (bytes){
|
||||
if(instance == null){
|
||||
instance = new SocketTestData();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private String cityCode = "010";
|
||||
private Double lat = 0.0;
|
||||
private Double lon = 0.0;
|
||||
|
||||
public String getCityCode() {
|
||||
return cityCode;
|
||||
}
|
||||
|
||||
public void setCityCode(String cityCode) {
|
||||
this.cityCode = cityCode;
|
||||
}
|
||||
|
||||
public Double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(Double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public Double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(Double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
0
app2/build/jrebel/project-cleaned.marker
Normal file
0
app2/build/jrebel/project-cleaned.marker
Normal file
@@ -4,13 +4,13 @@ apply from: "javadoc.gradle"
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
|
||||
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
|
||||
maven { url 'https://maven.aliyun.com/repository/public' }
|
||||
maven { url 'https://maven.aliyun.com/repository/google' }
|
||||
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
|
||||
maven { url 'https://maven.aliyun.com/repository/jcenter' }
|
||||
maven { url 'http://nexus.zhidaoauto.com/repository/maven-releases/' }
|
||||
maven { url 'http://nexus.zhidaoauto.com/repository/maven-public/' }
|
||||
maven { url 'https://nexus.zhidaoauto.com/repository/maven-releases/' }
|
||||
maven { url 'https://nexus.zhidaoauto.com/repository/maven-public/' }
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
|
||||
@@ -250,6 +250,7 @@ ext {
|
||||
mogoaicloudrealtime : "com.mogo.cloud:realtime:${MOGO_REALTIME_VERSION}",
|
||||
mogoaicloudtanlu : "com.mogo.cloud:tanlu:${MOGO_TANLU_VERSION}",
|
||||
mogoaicloudtrafficlive : "com.mogo.cloud:trafficlive:${MOGO_TRAFFICLIVE_VERSION}",
|
||||
mogoaicloudlocation : "com.mogo.cloud:location:${MOGO_LOCATION_VERSION}",
|
||||
]
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.mogo.httpdns;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/11/19
|
||||
*
|
||||
* dns ttl 通知
|
||||
*/
|
||||
@Keep
|
||||
public interface IHttpDnsTtlCallback {
|
||||
|
||||
@Keep
|
||||
void onTtl();
|
||||
}
|
||||
@@ -1,63 +1,32 @@
|
||||
package com.mogo.httpdns;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.utils.network.HttpDns;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import com.mogo.cloud.httpdns.listener.OnAddressChangedListener;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/11/18
|
||||
*
|
||||
* <p>
|
||||
* http 请求做http dns转换
|
||||
*/
|
||||
@Keep
|
||||
public interface IMogoHttpDns extends IProvider {
|
||||
|
||||
/**
|
||||
* 获取 dns 代理实例
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Keep
|
||||
@Nullable
|
||||
HttpDns dns();
|
||||
|
||||
// /**
|
||||
// * 获取缓存中的 dns ip地址
|
||||
// *
|
||||
// * @param host
|
||||
// * @return
|
||||
// */
|
||||
// @Nullable
|
||||
// String getCachedHttpDnsIps( String host );
|
||||
|
||||
/**
|
||||
* 获取缓存中的dns ip地址
|
||||
*
|
||||
* @param host domain
|
||||
* @param type 类型
|
||||
* @return
|
||||
*/
|
||||
@Keep
|
||||
String getCachedHttpDnsIps(String host, int type);
|
||||
//
|
||||
// /**
|
||||
// * dns 解析
|
||||
// *
|
||||
// * @param host 域名
|
||||
// * @param useCache 是否使用缓存,是 - 如果没有缓存,则解析新地址、否 - 解析新地址,并将新地址缓存
|
||||
// * @param callback
|
||||
// */
|
||||
// void getHttpDnsIp( String host, boolean useCache, IHttpDnsCallback callback );
|
||||
|
||||
/**
|
||||
* dns解析
|
||||
*
|
||||
* @param host
|
||||
* @param type
|
||||
* @param useCache
|
||||
@@ -68,51 +37,17 @@ public interface IMogoHttpDns extends IProvider {
|
||||
|
||||
/**
|
||||
* 同步进行dns解析,无需回调
|
||||
*
|
||||
* @param host
|
||||
* @param type
|
||||
* @param useCache
|
||||
*
|
||||
* @return ip:port
|
||||
*/
|
||||
String syncGetHttpDns(String host, int type, boolean useCache);
|
||||
|
||||
// /**
|
||||
// * 监听 ttl 回调
|
||||
// *
|
||||
// * @param host 域名
|
||||
// * @param callback
|
||||
// */
|
||||
// void addHttpDnsTtlCallback( String host, IHttpDnsTtlCallback callback );
|
||||
|
||||
/**
|
||||
* 监听ttl回调
|
||||
* @param host
|
||||
* @param type
|
||||
* @param callback
|
||||
* 注册HttpDns地址变化监听
|
||||
* @param listener {@link OnAddressChangedListener}
|
||||
*/
|
||||
@Keep
|
||||
void addHttpDnsTtlCallback(String host, int type, IHttpDnsTtlCallback callback);
|
||||
|
||||
// /**
|
||||
// * 注销 ttl 回调
|
||||
// *
|
||||
// * @param host 域名
|
||||
// */
|
||||
// void removeHttpDnsTtlCallback( String host );
|
||||
|
||||
/**
|
||||
* 注销ttl回调
|
||||
* @param host
|
||||
* @param type
|
||||
*/
|
||||
@Keep
|
||||
void removeHttpDnsTtlCallback(String host,int type);
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param locationChanged 定位发生变化
|
||||
*/
|
||||
void init(Context context, IHttpDnsLocationChanged locationChanged);
|
||||
void addressChangedListener(OnAddressChangedListener listener);
|
||||
}
|
||||
|
||||
@@ -1,192 +1,81 @@
|
||||
package com.mogo.httpdns.mogo;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.constants.SharedPrefsConstants;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.network.Utils;
|
||||
import com.mogo.cloud.httpdns.MogoHttpDnsClient;
|
||||
import com.mogo.cloud.httpdns.listener.OnAddressChangedListener;
|
||||
import com.mogo.httpdns.HttpDnsConst;
|
||||
import com.mogo.httpdns.IHttpDnsCallback;
|
||||
import com.mogo.httpdns.IHttpDnsLocationChanged;
|
||||
import com.mogo.httpdns.IHttpDnsTtlCallback;
|
||||
import com.mogo.httpdns.IMogoHttpDns;
|
||||
import com.mogo.httpdnshelper.sdk.HttpDnsHelper;
|
||||
import com.mogo.httpdnshelper.sdk.bean.HttpDnsSimpleLocation;
|
||||
import com.mogo.httpdnshelper.sdk.listener.IHttpDnsCurrentLocation;
|
||||
import com.mogo.httpdnshelper.sdk.listener.OnAddressChangedListener;
|
||||
import com.mogo.utils.httpdns.HttpSimpleLocation;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.HttpDns;
|
||||
import com.mogo.utils.storage.SharedPrefsMgr;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.mogo.httpdns.HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_HTTP;
|
||||
|
||||
@Keep
|
||||
@Route(path = HttpDnsConst.PATH)
|
||||
public class MogoHttpDns implements IMogoHttpDns, HttpDns, OnAddressChangedListener {
|
||||
public class MogoHttpDns implements IMogoHttpDns {
|
||||
private static final String TAG = "MogoHttpDns";
|
||||
private HttpDnsHelper httpDnsHelper;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public HttpDns dns() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCachedHttpDnsIps(String host, int type) {
|
||||
return httpDnsHelper.getHttpDnsCachedAddress(type, host);
|
||||
return MogoHttpDnsClient.INSTANCE.getHttpDnsCachedAddress(type, host);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String syncGetHttpDns(String host, int type, boolean useCache) {
|
||||
Logger.d(TAG, "getHttpDnsIp host: " + host + " type: " + type);
|
||||
Map<String, String> map = httpDnsHelper.getAllAddress();
|
||||
if (useCache) {
|
||||
String address = httpDnsHelper.getHttpDnsCachedAddress(type, host);
|
||||
if (address != null) {
|
||||
return address;
|
||||
} else {
|
||||
return httpDnsHelper.getHttpDnsAddress(type, host);
|
||||
}
|
||||
} else {
|
||||
return httpDnsHelper.getHttpDnsAddress(type, host);
|
||||
}
|
||||
return MogoHttpDnsClient.INSTANCE.syncGetHttpDns(host, type, useCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addressChangedListener(OnAddressChangedListener listener) {
|
||||
MogoHttpDnsClient.INSTANCE.addressChangedListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHttpDnsIp(String host, int type, boolean useCache, IHttpDnsCallback callback) {
|
||||
Logger.d(TAG, "getHttpDnsIp host: " + host + " type: " + type);
|
||||
Map<String, String> map = httpDnsHelper.getAllAddress();
|
||||
if (useCache) {
|
||||
String address = httpDnsHelper.getHttpDnsCachedAddress(type, host);
|
||||
String address = MogoHttpDnsClient.INSTANCE.getHttpDnsCachedAddress(type, host);
|
||||
if (address != null) {
|
||||
callback.onParsed(address);
|
||||
} else {
|
||||
callback.onParsed(httpDnsHelper.getHttpDnsAddress(type, host));
|
||||
callback.onParsed(MogoHttpDnsClient.INSTANCE.getHttpDnsAddress(type, host));
|
||||
}
|
||||
} else {
|
||||
callback.onParsed(httpDnsHelper.getHttpDnsAddress(type, host));
|
||||
callback.onParsed(MogoHttpDnsClient.INSTANCE.getHttpDnsAddress(type, host));
|
||||
}
|
||||
}
|
||||
|
||||
private final Map<String, List<IHttpDnsTtlCallback>> ttlCallbackMap = new ArrayMap<>();
|
||||
|
||||
@Override
|
||||
public void addHttpDnsTtlCallback(String host, int type, IHttpDnsTtlCallback callback) {
|
||||
Logger.d(TAG, "addHttpDnsTtlCallback: host: " + host + " type: " + type);
|
||||
if (ttlCallbackMap.get(type + "-" + host) == null) {
|
||||
ttlCallbackMap.put(type + "-" + host, new ArrayList<IHttpDnsTtlCallback>());
|
||||
}
|
||||
ttlCallbackMap.get(type + "-" + host).add(callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeHttpDnsTtlCallback(String host, int type) {
|
||||
// 先不实现
|
||||
// ttlCallbackMap.remove(type + "-" + host);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(final Context context) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(final Context context, final IHttpDnsLocationChanged locationChanged) {
|
||||
httpDnsHelper = new HttpDnsHelper.Builder().setContext(context).setEnv(DebugConfig.getNetMode()).setSn(MoGoAiCloudClientConfig.getInstance().getSn()).setShowDebugLog(true).setLoopCheckDelay(15 * 60 * 1000).setCurrentLocation(new IHttpDnsCurrentLocation() {
|
||||
@org.jetbrains.annotations.Nullable
|
||||
@Override
|
||||
public HttpDnsSimpleLocation getCurrentLocation() {
|
||||
HttpSimpleLocation simpleLocation = locationChanged.getLocation();
|
||||
// @Override
|
||||
// public List<InetAddress> lookup(String hostname) throws UnknownHostException {
|
||||
// String cacheIp = httpDnsHelper.getHttpDnsCachedAddress(HTTP_DNS_ADDRESS_TYPE_HTTP, hostname);
|
||||
// Logger.d("MogoHttpDnsLook", "lookup host: " + hostname + " cacheIp: " + cacheIp);
|
||||
// if (cacheIp == null || TextUtils.isEmpty(cacheIp)) {
|
||||
// cacheIp = httpDnsHelper.getHttpDnsAddress(HttpDnsHelper.HTTP_DNS_TYPE_HTTP, hostname);
|
||||
// Logger.d("MogoHttpDnsLook", "==== lookup host: " + hostname + " cacheIp: " + cacheIp);
|
||||
// if (!TextUtils.isEmpty(cacheIp)) {
|
||||
// String[] info = cacheIp.split(":");
|
||||
// if (info.length > 1) {
|
||||
// return Arrays.asList(InetAddress.getAllByName(info[0]));
|
||||
// } else {
|
||||
// return Arrays.asList(InetAddress.getAllByName(cacheIp));
|
||||
// }
|
||||
// }
|
||||
// return Collections.emptyList();
|
||||
// }
|
||||
// String[] info = cacheIp.split(":");
|
||||
// if (info.length > 1) {
|
||||
// return Arrays.asList(InetAddress.getAllByName(info[0]));
|
||||
// } else {
|
||||
// return Arrays.asList(InetAddress.getAllByName(cacheIp));
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
HttpDnsSimpleLocation httpDnsSimpleLocation;
|
||||
if (simpleLocation != null
|
||||
&& simpleLocation.getLat() != 0
|
||||
&& simpleLocation.getLon() != 0) {
|
||||
httpDnsSimpleLocation = new HttpDnsSimpleLocation(
|
||||
simpleLocation.getCityCode(),
|
||||
simpleLocation.getLat(),
|
||||
simpleLocation.getLon());
|
||||
Logger.i(TAG, "使用实时GPS信息:" + httpDnsSimpleLocation);
|
||||
} else {
|
||||
String ciyCode = SharedPrefsMgr.getInstance(context)
|
||||
.getString(SharedPrefsConstants.LOCATION_CITY_CODE);
|
||||
String latitude = SharedPrefsMgr.getInstance(context)
|
||||
.getString(SharedPrefsConstants.LOCATION_LATITUDE);
|
||||
String longitude = SharedPrefsMgr.getInstance(context)
|
||||
.getString(SharedPrefsConstants.LOCATION_LONGITUDE);
|
||||
try {
|
||||
httpDnsSimpleLocation = new HttpDnsSimpleLocation(
|
||||
ciyCode,
|
||||
Double.parseDouble(latitude),
|
||||
Double.parseDouble(longitude));
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
httpDnsSimpleLocation = new HttpDnsSimpleLocation("010", 1, 1);
|
||||
}
|
||||
Logger.i(TAG, "使用缓存GPS信息:" + httpDnsSimpleLocation);
|
||||
}
|
||||
return httpDnsSimpleLocation;
|
||||
}
|
||||
}).build();
|
||||
httpDnsHelper.setAddressChangedListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InetAddress> lookup(String hostname) throws UnknownHostException {
|
||||
String cacheIp = httpDnsHelper.getHttpDnsCachedAddress(HTTP_DNS_ADDRESS_TYPE_HTTP, hostname);
|
||||
Logger.d("MogoHttpDnsLook", "lookup host: " + hostname + " cacheIp: " + cacheIp);
|
||||
if (cacheIp == null || TextUtils.isEmpty(cacheIp)) {
|
||||
cacheIp = httpDnsHelper.getHttpDnsAddress(HttpDnsHelper.HTTP_DNS_TYPE_HTTP, hostname);
|
||||
Logger.d("MogoHttpDnsLook", "==== lookup host: " + hostname + " cacheIp: " + cacheIp);
|
||||
if (!TextUtils.isEmpty(cacheIp)) {
|
||||
String[] info = cacheIp.split(":");
|
||||
if (info.length > 1) {
|
||||
return Arrays.asList(InetAddress.getAllByName(info[0]));
|
||||
} else {
|
||||
return Arrays.asList(InetAddress.getAllByName(cacheIp));
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
String[] info = cacheIp.split(":");
|
||||
if (info.length > 1) {
|
||||
return Arrays.asList(InetAddress.getAllByName(info[0]));
|
||||
} else {
|
||||
return Arrays.asList(InetAddress.getAllByName(cacheIp));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddressChanged(Map<String, String> map) {
|
||||
if (map != null) {
|
||||
for (String key : map.keySet()) {
|
||||
if (ttlCallbackMap.get(key) != null) {
|
||||
Logger.d("MogoHttpDns", "onAddressChanged key: " + key);
|
||||
for (IHttpDnsTtlCallback callback : ttlCallbackMap.get(key)) {
|
||||
callback.onTtl();
|
||||
}
|
||||
} else {
|
||||
Logger.d("MogoHttpDns", "callback is null: " + key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,10 @@ package com.mogo.httpdns.noop;
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.cloud.httpdns.listener.OnAddressChangedListener;
|
||||
import com.mogo.httpdns.HttpDnsConst;
|
||||
import com.mogo.httpdns.IHttpDnsCallback;
|
||||
import com.mogo.httpdns.IHttpDnsLocationChanged;
|
||||
import com.mogo.httpdns.IHttpDnsTtlCallback;
|
||||
import com.mogo.httpdns.IMogoHttpDns;
|
||||
import com.mogo.utils.network.HttpDns;
|
||||
|
||||
public
|
||||
/**
|
||||
@@ -17,16 +15,11 @@ public
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
@Route( path = HttpDnsConst.PATH )
|
||||
@Route(path = HttpDnsConst.PATH)
|
||||
class HttpDnsNoop implements IMogoHttpDns {
|
||||
|
||||
@Override
|
||||
public HttpDns dns() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCachedHttpDnsIps( String host,int type ) {
|
||||
public String getCachedHttpDnsIps(String host, int type) {
|
||||
return host;
|
||||
}
|
||||
|
||||
@@ -36,29 +29,19 @@ class HttpDnsNoop implements IMogoHttpDns {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHttpDnsIp( String host,int type, boolean useCache, IHttpDnsCallback callback ) {
|
||||
if ( callback != null ) {
|
||||
callback.onParsed( host );
|
||||
public void addressChangedListener(OnAddressChangedListener listener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHttpDnsIp(String host, int type, boolean useCache, IHttpDnsCallback callback) {
|
||||
if (callback != null) {
|
||||
callback.onParsed(host);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHttpDnsTtlCallback( String host,int type, IHttpDnsTtlCallback callback ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeHttpDnsTtlCallback( String host,int type ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context, IHttpDnsLocationChanged locationChanged) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
public void init(Context context) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.httpdns.IHttpDnsTtlCallback;
|
||||
import com.mogo.utils.ThreadPoolService;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.tencent.msdk.dns.MSDKDnsResolver;
|
||||
@@ -36,12 +35,12 @@ class HttpDnsIpsCache {
|
||||
// ttl
|
||||
public static final int MSG_DNS_TTL = 6000001;
|
||||
|
||||
private static Map< String, String > sCaches = new ConcurrentHashMap<>();
|
||||
private static Map< String, String > sTTLCaches = new ConcurrentHashMap<>();
|
||||
private final static Map< String, String > sCaches = new ConcurrentHashMap<>();
|
||||
private final static Map< String, String > sTTLCaches = new ConcurrentHashMap<>();
|
||||
|
||||
private static Map< String, IHttpDnsTtlCallback > sTtlCallbacks = new ConcurrentHashMap<>();
|
||||
private final static Map< String, IHttpDnsTtlCallback > sTtlCallbacks = new ConcurrentHashMap<>();
|
||||
|
||||
private static Handler sHandler = new Handler( Looper.getMainLooper() ) {
|
||||
private final static Handler sHandler = new Handler( Looper.getMainLooper() ) {
|
||||
@Override
|
||||
public void handleMessage( Message msg ) {
|
||||
super.handleMessage( msg );
|
||||
@@ -62,8 +61,8 @@ class HttpDnsIpsCache {
|
||||
if ( sTtlCallbacks.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
Collection< IHttpDnsTtlCallback > callbacks = sTtlCallbacks.values();
|
||||
if ( callbacks == null || callbacks.isEmpty() ) {
|
||||
Collection<IHttpDnsTtlCallback> callbacks = sTtlCallbacks.values();
|
||||
if (callbacks.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for ( IHttpDnsTtlCallback callback : callbacks ) {
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.mogo.httpdns.tencent;
|
||||
|
||||
public class IHttpDnsTtlCallback {
|
||||
public void onTtl() {
|
||||
}
|
||||
}
|
||||
@@ -6,11 +6,10 @@ import android.text.TextUtils;
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.cloud.httpdns.listener.OnAddressChangedListener;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.httpdns.HttpDnsConst;
|
||||
import com.mogo.httpdns.IHttpDnsCallback;
|
||||
import com.mogo.httpdns.IHttpDnsLocationChanged;
|
||||
import com.mogo.httpdns.IHttpDnsTtlCallback;
|
||||
import com.mogo.httpdns.IMogoHttpDns;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.HttpDns;
|
||||
@@ -25,25 +24,14 @@ import java.util.List;
|
||||
import static com.mogo.httpdns.HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_IM;
|
||||
import static com.mogo.httpdns.HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_WS;
|
||||
|
||||
public
|
||||
/*
|
||||
* @author congtaowang
|
||||
* @since 2020/11/18
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
|
||||
@Route( path = HttpDnsConst.PATH )
|
||||
class TencentHttpDns implements IMogoHttpDns, HttpDns {
|
||||
public class TencentHttpDns implements IMogoHttpDns, HttpDns {
|
||||
|
||||
private static volatile boolean sInited = false;
|
||||
|
||||
private static final String TAG = "TencentHttpDns";
|
||||
|
||||
@Override
|
||||
public HttpDns dns() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List< InetAddress > lookup( String hostname ) throws UnknownHostException {
|
||||
Logger.d( TAG, "需要dns解析" );
|
||||
@@ -78,7 +66,7 @@ class TencentHttpDns implements IMogoHttpDns, HttpDns {
|
||||
|
||||
@Override
|
||||
public void getHttpDnsIp( String host,int type, boolean useCache, IHttpDnsCallback callback ) {
|
||||
String cacheIp = null;
|
||||
String cacheIp;
|
||||
if ( useCache ) {
|
||||
cacheIp = getCacheOrParseIpIfNecessary( host );
|
||||
} else {
|
||||
@@ -104,17 +92,7 @@ class TencentHttpDns implements IMogoHttpDns, HttpDns {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHttpDnsTtlCallback( String host,int type, IHttpDnsTtlCallback callback ) {
|
||||
HttpDnsIpsCache.addHttpDnsTtlCallback( host, callback );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeHttpDnsTtlCallback( String host,int type ) {
|
||||
HttpDnsIpsCache.removeHttpDnsTtlCallback( host );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context, IHttpDnsLocationChanged locationChanged) {
|
||||
public void addressChangedListener(OnAddressChangedListener listener) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -8,11 +8,13 @@ import com.mogo.cloud.socket.IMogoCloudSocketMsgAckListener;
|
||||
import com.mogo.cloud.socket.IMogoCloudSocketOnMessageListener;
|
||||
import com.mogo.cloud.socket.SocketManager;
|
||||
import com.mogo.cloud.socket.entity.MsgBody;
|
||||
import com.mogo.service.connection.IMogoLifecycleListener;
|
||||
import com.mogo.service.connection.IMogoMsgAckListener;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.service.connection.IMogoSocketManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.ptech.connsvr.commom.protocol.MogoCommon;
|
||||
import com.zhidao.socket.ConnectionLifecycleListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -26,7 +28,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* 长链实现:基于 netty
|
||||
*/
|
||||
@Keep
|
||||
public class MogoAiCloudSocketManager implements IMogoSocketManager {
|
||||
public class MogoAiCloudSocketManager extends ConnectionLifecycleListener implements IMogoSocketManager {
|
||||
|
||||
private static final String TAG = "MogoAiCloudSocketManager-apk";
|
||||
|
||||
@@ -54,6 +56,7 @@ public class MogoAiCloudSocketManager implements IMogoSocketManager {
|
||||
* key - msgType
|
||||
*/
|
||||
private final Map<Integer, List<IMogoOnMessageListener>> mListeners = new ConcurrentHashMap<>();
|
||||
private final Map<Integer, IMogoLifecycleListener> mLifeCycleListeners = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 管理消息回执
|
||||
@@ -66,6 +69,7 @@ public class MogoAiCloudSocketManager implements IMogoSocketManager {
|
||||
public void init(Context context, String appId) {
|
||||
this.mAppId = appId;
|
||||
SocketManager.getInstance().init(context);
|
||||
SocketManager.getInstance().registerSocketConnCallback(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,6 +105,24 @@ public class MogoAiCloudSocketManager implements IMogoSocketManager {
|
||||
SocketManager.getInstance().unregisterOnMessageListener(msgType, mogoCloudSocketOnMessageListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerLifecycleListener(int msgType, IMogoLifecycleListener listener) {
|
||||
if (mLifeCycleListeners.containsKey(msgType)) {
|
||||
return;
|
||||
}
|
||||
if (!mLifeCycleListeners.containsKey(msgType)) {
|
||||
mLifeCycleListeners.put(msgType, listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterLifecycleListener(int msgType) {
|
||||
if (!mLifeCycleListeners.containsKey(msgType)) {
|
||||
return;
|
||||
}
|
||||
mLifeCycleListeners.remove(msgType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMsg(MsgBody body, IMogoMsgAckListener listener) {
|
||||
Logger.d(TAG, "sendMsg.");
|
||||
@@ -112,10 +134,13 @@ public class MogoAiCloudSocketManager implements IMogoSocketManager {
|
||||
SocketManager.getInstance().sendMsg(mAppId, MogoCommon.Product.mogoBussiness.getNumber(), msgBody, mogoCloudSocketMsgAckListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
release();
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
SocketManager.getInstance().release();
|
||||
mListeners.clear();
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -150,4 +175,37 @@ public class MogoAiCloudSocketManager implements IMogoSocketManager {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onConnectSuccess() {
|
||||
if (mLifeCycleListeners.size() > 0){
|
||||
for (IMogoLifecycleListener lifecycleListener : mLifeCycleListeners.values()){
|
||||
if (lifecycleListener != null){
|
||||
lifecycleListener.onConnectSuccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectFailure() {
|
||||
if (mLifeCycleListeners.size() > 0){
|
||||
for (IMogoLifecycleListener lifecycleListener : mLifeCycleListeners.values()){
|
||||
if (lifecycleListener != null){
|
||||
lifecycleListener.onConnectFailure();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectLost(boolean reconnect) {
|
||||
if (mLifeCycleListeners.size() > 0){
|
||||
for (IMogoLifecycleListener lifecycleListener : mLifeCycleListeners.values()){
|
||||
if (lifecycleListener != null){
|
||||
lifecycleListener.onConnectLost();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,9 +28,7 @@ android {
|
||||
|
||||
dependencies {
|
||||
implementation rootProject.ext.dependencies.mogoaicloudsocket
|
||||
|
||||
// 上报位置
|
||||
implementation 'com.zhidao.locupload:loc-upload-sdk:1.1.7'
|
||||
implementation rootProject.ext.dependencies.mogoaicloudlocation
|
||||
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
implementation rootProject.ext.dependencies.mogoutils
|
||||
|
||||
@@ -4,22 +4,13 @@ import android.content.Context;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.cloud.location.LocationManager;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.service.locationinfo.IMogoLocationInfoService;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.locupload.LocUploadConfig;
|
||||
import com.zhidao.locupload.LocUploadManager;
|
||||
|
||||
public
|
||||
/*
|
||||
* @author congtaowang
|
||||
* @since 2020/7/16
|
||||
*
|
||||
* 位置服务
|
||||
*/
|
||||
@Keep
|
||||
class MogoLocationInfoServices implements IMogoLocationInfoService {
|
||||
public class MogoLocationInfoServices implements IMogoLocationInfoService {
|
||||
|
||||
private static final String TAG = "MogoLocationInfoServices-sdk";
|
||||
|
||||
@@ -31,9 +22,9 @@ class MogoLocationInfoServices implements IMogoLocationInfoService {
|
||||
|
||||
@Keep
|
||||
public static MogoLocationInfoServices getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( MogoLocationInfoServices.class ) {
|
||||
if ( sInstance == null ) {
|
||||
if (sInstance == null) {
|
||||
synchronized (MogoLocationInfoServices.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new MogoLocationInfoServices();
|
||||
}
|
||||
}
|
||||
@@ -46,9 +37,9 @@ class MogoLocationInfoServices implements IMogoLocationInfoService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void provideLocation( MogoLocation location ) {
|
||||
public void provideLocation(MogoLocation location) {
|
||||
mLocation = location;
|
||||
Logger.d( TAG, "sdk - provideLocation" );
|
||||
Logger.d(TAG, "sdk - provideLocation");
|
||||
}
|
||||
|
||||
public MogoLocation getLocation() {
|
||||
@@ -57,23 +48,19 @@ class MogoLocationInfoServices implements IMogoLocationInfoService {
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
LocUploadManager.getInstance().startUpload();
|
||||
Logger.d( TAG, "sdk - start" );
|
||||
LocationManager.getInstance().start();
|
||||
Logger.d(TAG, "sdk - start");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
LocUploadManager.getInstance().stopUpload();
|
||||
Logger.d( TAG, "sdk - stop" );
|
||||
LocationManager.getInstance().stop();
|
||||
Logger.d(TAG, "sdk - stop");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
LocUploadConfig.instance().
|
||||
setAppId( DebugConfig.getSocketAppId() ).
|
||||
setContext( context.getApplicationContext() ).
|
||||
setLoggable( DebugConfig.isDebug() ).
|
||||
setLocInterval( 2000L );
|
||||
Logger.d( TAG, "sdk - init" );
|
||||
public void init(Context context) {
|
||||
LocationManager.getInstance().init(context);
|
||||
Logger.d(TAG, "sdk - init");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,19 +3,12 @@ package com.mogo.aicloud.services.locationinfo;
|
||||
import com.elegant.spi.annotations.Service;
|
||||
import com.zhidao.locupload.location.LocationServiceProvider;
|
||||
|
||||
public
|
||||
/*
|
||||
* @author congtaowang
|
||||
* @since 2020/7/16
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
@Service( value = LocationServiceProvider.class )
|
||||
class MogoLocationSource extends LocationServiceProvider {
|
||||
@Service(value = LocationServiceProvider.class)
|
||||
public class MogoLocationSource extends LocationServiceProvider {
|
||||
|
||||
@Override
|
||||
public float getBearing() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getBearing();
|
||||
}
|
||||
return 0;
|
||||
@@ -23,7 +16,7 @@ class MogoLocationSource extends LocationServiceProvider {
|
||||
|
||||
@Override
|
||||
public float getAccuracy() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getAccuracy();
|
||||
}
|
||||
return 0;
|
||||
@@ -31,7 +24,7 @@ class MogoLocationSource extends LocationServiceProvider {
|
||||
|
||||
@Override
|
||||
public String getProvider() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getProvider();
|
||||
}
|
||||
return null;
|
||||
@@ -39,7 +32,7 @@ class MogoLocationSource extends LocationServiceProvider {
|
||||
|
||||
@Override
|
||||
public float getSpeed() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getSpeed();
|
||||
}
|
||||
return 0;
|
||||
@@ -47,7 +40,7 @@ class MogoLocationSource extends LocationServiceProvider {
|
||||
|
||||
@Override
|
||||
public double getAltitude() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getAltitude();
|
||||
}
|
||||
return 0;
|
||||
@@ -55,7 +48,7 @@ class MogoLocationSource extends LocationServiceProvider {
|
||||
|
||||
@Override
|
||||
public String getAdCode() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getAdCode();
|
||||
}
|
||||
return null;
|
||||
@@ -63,7 +56,7 @@ class MogoLocationSource extends LocationServiceProvider {
|
||||
|
||||
@Override
|
||||
public int getLocType() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getLocType();
|
||||
}
|
||||
return 0;
|
||||
@@ -71,7 +64,7 @@ class MogoLocationSource extends LocationServiceProvider {
|
||||
|
||||
@Override
|
||||
public double getLatitude() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getLatitude();
|
||||
}
|
||||
return 0;
|
||||
@@ -79,7 +72,7 @@ class MogoLocationSource extends LocationServiceProvider {
|
||||
|
||||
@Override
|
||||
public double getLongitude() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getLongitude();
|
||||
}
|
||||
return 0;
|
||||
@@ -87,7 +80,7 @@ class MogoLocationSource extends LocationServiceProvider {
|
||||
|
||||
@Override
|
||||
public long getTime() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getTime();
|
||||
}
|
||||
return 0;
|
||||
@@ -95,7 +88,7 @@ class MogoLocationSource extends LocationServiceProvider {
|
||||
|
||||
@Override
|
||||
public String getCityCode() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getCityCode();
|
||||
}
|
||||
return null;
|
||||
@@ -103,7 +96,7 @@ class MogoLocationSource extends LocationServiceProvider {
|
||||
|
||||
@Override
|
||||
public String getCityName() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getCityName();
|
||||
}
|
||||
return null;
|
||||
@@ -111,7 +104,7 @@ class MogoLocationSource extends LocationServiceProvider {
|
||||
|
||||
@Override
|
||||
public int getGpsAccuracyStatus() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getGpsAccuracyStatus();
|
||||
}
|
||||
return 0;
|
||||
@@ -119,7 +112,7 @@ class MogoLocationSource extends LocationServiceProvider {
|
||||
|
||||
@Override
|
||||
public int getSatellites() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
if (MogoLocationInfoServices.getInstance().getLocation() != null) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getSatellite();
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -8,11 +8,13 @@ import com.mogo.cloud.socket.IMogoCloudSocketMsgAckListener;
|
||||
import com.mogo.cloud.socket.IMogoCloudSocketOnMessageListener;
|
||||
import com.mogo.cloud.socket.SocketManager;
|
||||
import com.mogo.cloud.socket.entity.MsgBody;
|
||||
import com.mogo.service.connection.IMogoLifecycleListener;
|
||||
import com.mogo.service.connection.IMogoMsgAckListener;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.service.connection.IMogoSocketManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.ptech.connsvr.commom.protocol.MogoCommon;
|
||||
import com.zhidao.socket.ConnectionLifecycleListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -26,7 +28,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* 长链实现:基于 netty
|
||||
*/
|
||||
@Keep
|
||||
public class MogoAiCloudSocketManager implements IMogoSocketManager {
|
||||
public class MogoAiCloudSocketManager extends ConnectionLifecycleListener implements IMogoSocketManager {
|
||||
|
||||
private static final String TAG = "MogoAiCloudSocketManager-sdk";
|
||||
|
||||
@@ -55,6 +57,11 @@ public class MogoAiCloudSocketManager implements IMogoSocketManager {
|
||||
*/
|
||||
private final Map<Integer, List<IMogoOnMessageListener>> mListeners = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 长链生命周期管理
|
||||
*/
|
||||
private final Map<Integer, IMogoLifecycleListener> mLifeCycleListeners = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 管理消息回执
|
||||
* <p>
|
||||
@@ -71,7 +78,7 @@ public class MogoAiCloudSocketManager implements IMogoSocketManager {
|
||||
@Override
|
||||
public void registerOnMessageListener(int msgType, IMogoOnMessageListener listener) {
|
||||
if (mListeners.containsKey(msgType)) {
|
||||
com.mogo.cloud.utils.logger.Logger.w(TAG, "msgType %d is exist.", msgType);
|
||||
Logger.w(TAG, "msgType %d is exist.", msgType);
|
||||
return;
|
||||
}
|
||||
if (!mListeners.containsKey(msgType)) {
|
||||
@@ -101,6 +108,24 @@ public class MogoAiCloudSocketManager implements IMogoSocketManager {
|
||||
SocketManager.getInstance().unregisterOnMessageListener(msgType, mogoCloudSocketOnMessageListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerLifecycleListener(int msgType, IMogoLifecycleListener listener) {
|
||||
if (mLifeCycleListeners.containsKey(msgType)) {
|
||||
return;
|
||||
}
|
||||
if (!mLifeCycleListeners.containsKey(msgType)) {
|
||||
mLifeCycleListeners.put(msgType, listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterLifecycleListener(int msgType) {
|
||||
if (!mLifeCycleListeners.containsKey(msgType)) {
|
||||
return;
|
||||
}
|
||||
mLifeCycleListeners.remove(msgType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMsg(MsgBody body, IMogoMsgAckListener listener) {
|
||||
Logger.d(TAG, "sendMsg.");
|
||||
@@ -112,10 +137,13 @@ public class MogoAiCloudSocketManager implements IMogoSocketManager {
|
||||
SocketManager.getInstance().sendMsg(mAppId, MogoCommon.Product.mogoBussiness.getNumber(), msgBody, mogoCloudSocketMsgAckListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
release();
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
SocketManager.getInstance().release();
|
||||
mListeners.clear();
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -150,4 +178,37 @@ public class MogoAiCloudSocketManager implements IMogoSocketManager {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onConnectSuccess() {
|
||||
if (mLifeCycleListeners.size() > 0){
|
||||
for (IMogoLifecycleListener lifecycleListener : mLifeCycleListeners.values()){
|
||||
if (lifecycleListener != null){
|
||||
lifecycleListener.onConnectSuccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectFailure() {
|
||||
if (mLifeCycleListeners.size() > 0){
|
||||
for (IMogoLifecycleListener lifecycleListener : mLifeCycleListeners.values()){
|
||||
if (lifecycleListener != null){
|
||||
lifecycleListener.onConnectFailure();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectLost(boolean reconnect) {
|
||||
if (mLifeCycleListeners.size() > 0){
|
||||
for (IMogoLifecycleListener lifecycleListener : mLifeCycleListeners.values()){
|
||||
if (lifecycleListener != null){
|
||||
lifecycleListener.onConnectLost();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mogo.base.websocket;
|
||||
|
||||
|
||||
import com.mogo.httpdns.HttpDnsConst;
|
||||
import com.mogo.httpdns.IMogoHttpDns;
|
||||
import com.mogo.httpdns.MogoHttpDnsHandler;
|
||||
@@ -7,6 +8,7 @@ import com.mogo.module.common.constants.HostConst;
|
||||
import com.mogo.utils.ThreadPoolService;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
|
||||
public class WebSocketDnsManager {
|
||||
|
||||
private static final String TAG = "WebSocketDnsManager";
|
||||
@@ -16,7 +18,7 @@ public class WebSocketDnsManager {
|
||||
}
|
||||
|
||||
private static final class Holder {
|
||||
private static WebSocketDnsManager dnsManager = new WebSocketDnsManager();
|
||||
private static final WebSocketDnsManager dnsManager = new WebSocketDnsManager();
|
||||
}
|
||||
|
||||
public static WebSocketDnsManager getInstance() {
|
||||
@@ -36,7 +38,7 @@ public class WebSocketDnsManager {
|
||||
WebSocketConstant.PROTOCOL + ip + WebSocketConstant.PATH :
|
||||
WebSocketConstant.getSocketServer() + WebSocketConstant.PORT));
|
||||
}));
|
||||
mogoHttpDns.addHttpDnsTtlCallback(HostConst.WEBSOCKET_DOMAIN, HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_WS, () -> {
|
||||
mogoHttpDns.addressChangedListener(map -> {
|
||||
Logger.d(TAG, "ttl callBack ,ready to getCache Dns IP");
|
||||
String dnsCacheIp = mogoHttpDns.getCachedHttpDnsIps(HostConst.WEBSOCKET_DOMAIN, HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_WS);
|
||||
if (dnsCacheIp == null) {
|
||||
@@ -45,6 +47,7 @@ public class WebSocketDnsManager {
|
||||
Logger.d(TAG, "获取缓存Dns IP : " + dnsCacheIp + " , 原缓存 IP : " + cacheIp);
|
||||
if (cacheIp != null && !cacheIp.equals(dnsCacheIp)) {
|
||||
this.webSocketDns.ttlIp(dnsCacheIp + WebSocketConstant.PATH);
|
||||
this.cacheIp = dnsCacheIp;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.mogo.commons;
|
||||
|
||||
import static com.mogo.commons.debug.DebugConfig.CAR_MACHINE_TYPE_SELF_INNOVATE;
|
||||
import static com.mogo.httpdns.HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_HTTP;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
@@ -11,7 +14,8 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.amap.api.maps.TextureMapView;
|
||||
import com.amap.api.navi.AMapNaviView;
|
||||
import com.mogo.cloud.httpdns.MogoHttpDnsClient;
|
||||
import com.mogo.commons.analytics.AnalyticsUtils;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.device.Devices;
|
||||
@@ -20,7 +24,6 @@ import com.mogo.commons.network.Constants;
|
||||
import com.mogo.commons.network.ParamsUtil;
|
||||
import com.mogo.commons.network.X509TrustManagerImpl;
|
||||
import com.mogo.commons.storage.SpStorage;
|
||||
import com.mogo.httpdns.HttpDnsConst;
|
||||
import com.mogo.httpdns.IMogoHttpDns;
|
||||
import com.mogo.httpdns.MogoHttpDnsHandler;
|
||||
import com.mogo.utils.ThreadPoolService;
|
||||
@@ -59,30 +62,30 @@ public abstract class AbsMogoApplication extends Application {
|
||||
return sApp;
|
||||
}
|
||||
|
||||
public static TextureMapView aMapNaviView;
|
||||
public static AMapNaviView aMapNaviView;
|
||||
|
||||
public static TextureMapView getMapNaviView() {
|
||||
public static AMapNaviView getMapNaviView() {
|
||||
return aMapNaviView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
aMapNaviView = new TextureMapView(this);
|
||||
aMapNaviView = new AMapNaviView(this);
|
||||
aMapNaviView.onCreate(null);
|
||||
// 在设置皮肤布局填充器之前进行克隆一个出来
|
||||
mLayoutInflaterNoSkin = LayoutInflater.from(new ContextThemeWrapper(this, R.style.Theme_AppCompat)).cloneInContext(new ContextThemeWrapper(this, R.style.Theme_AppCompat));
|
||||
sApp = this;
|
||||
initARouter();
|
||||
if ( shouldInit() ) {
|
||||
if (shouldInit()) {
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
private void initARouter() {
|
||||
ARouter.init( sApp );
|
||||
ARouter.init(sApp);
|
||||
// 初始化 arouter
|
||||
if ( DebugConfig.isDebug() ) {
|
||||
if (DebugConfig.isDebug()) {
|
||||
ARouter.openDebug();
|
||||
ARouter.openLog();
|
||||
}
|
||||
@@ -97,26 +100,26 @@ public abstract class AbsMogoApplication extends Application {
|
||||
}
|
||||
|
||||
protected void initTipToast() {
|
||||
TipToast.init( this, ( ( context, message, tipDrawable ) -> {
|
||||
if ( TextUtils.isEmpty( message ) ) {
|
||||
TipToast.init(this, ((context, message, tipDrawable) -> {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
View contentView = generateToastView( context, message, tipDrawable );
|
||||
View contentView = generateToastView(context, message, tipDrawable);
|
||||
return contentView;
|
||||
} catch ( Exception e ) {
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return null;
|
||||
} ) );
|
||||
}));
|
||||
}
|
||||
|
||||
private View generateToastView( Context context, String message, TipDrawable tipDrawable){
|
||||
private View generateToastView(Context context, String message, TipDrawable tipDrawable) {
|
||||
View contentView;
|
||||
if(tipDrawable==null) {
|
||||
if (tipDrawable == null) {
|
||||
contentView = LayoutInflater.from(context).inflate(R.layout.module_commons_layout_toast, null);
|
||||
TextView txt = contentView.findViewById(R.id.module_commons_toast_msg);
|
||||
txt.setText(message);
|
||||
}else{
|
||||
} else {
|
||||
// 有图片,使用带图片的布局,当前只实现了左侧图片
|
||||
contentView = LayoutInflater.from(context).inflate(R.layout.module_commons_layout_toast_with_left_drawable, null);
|
||||
TextView txt = contentView.findViewById(R.id.module_commons_toast_msg);
|
||||
@@ -138,20 +141,22 @@ public abstract class AbsMogoApplication extends Application {
|
||||
*/
|
||||
private static SSLContext getSslContext() throws Exception {
|
||||
SSLContext sc = null;
|
||||
sc = SSLContext.getInstance( "SSL" );
|
||||
sc.init( null, new TrustManager[]{new X509TrustManagerImpl()}, new SecureRandom() );
|
||||
sc = SSLContext.getInstance("SSL");
|
||||
sc.init(null, new TrustManager[]{new X509TrustManagerImpl()}, new SecureRandom());
|
||||
return sc;
|
||||
}
|
||||
|
||||
protected void asyncInit() {
|
||||
ThreadPoolService.execute( () -> {
|
||||
ThreadPoolService.execute(() -> {
|
||||
initNetConfig();
|
||||
// 初始化埋点
|
||||
AnalyticsUtils.init(sApp);
|
||||
Devices.init( getApp() );
|
||||
Devices.checkBindState();
|
||||
if (DebugConfig.getCarMachineType() == CAR_MACHINE_TYPE_SELF_INNOVATE) {
|
||||
Devices.init(getApp());
|
||||
Devices.checkBindState();
|
||||
}
|
||||
asyncInitImpl();
|
||||
} );
|
||||
});
|
||||
}
|
||||
|
||||
protected void asyncInitImpl() {
|
||||
@@ -162,35 +167,55 @@ public abstract class AbsMogoApplication extends Application {
|
||||
|
||||
try {
|
||||
SSLContext sc = getSslContext();
|
||||
NetConfig.instance().setSslContext( sc );
|
||||
} catch ( Exception e ) {
|
||||
NetConfig.instance().setSslContext(sc);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
IMogoHttpDns dns = MogoHttpDnsHandler.getHttpDnsApi();
|
||||
if(dns == null){
|
||||
Logger.d(TAG,"dns is null");
|
||||
if (dns == null) {
|
||||
Logger.d(TAG, "dns is null");
|
||||
}
|
||||
NetConfig.instance().setSignaturePrefix( Constants.SIGN_PREFIX )
|
||||
.setPublicParams( ParamsUtil.getStaticParams() )
|
||||
.setHostnameVerifier( new AllAllowedHostnameVerifier() )
|
||||
.addNetworkInterceptor( chain -> {
|
||||
NetConfig.instance().setSignaturePrefix(Constants.SIGN_PREFIX)
|
||||
.setPublicParams(ParamsUtil.getStaticParams())
|
||||
.setHostnameVerifier(new AllAllowedHostnameVerifier())
|
||||
.addNetworkInterceptor(chain -> {
|
||||
Request original = chain.request();
|
||||
Request request = original.newBuilder()
|
||||
.header( "token", SpStorage.getTicket() )
|
||||
.method( original.method(), original.body() )
|
||||
.header("token", SpStorage.getTicket())
|
||||
.method(original.method(), original.body())
|
||||
.build();
|
||||
return chain.proceed( request );
|
||||
} )
|
||||
return chain.proceed(request);
|
||||
})
|
||||
// 增加域名->域名的转换方式,暂时去掉httpdns方式
|
||||
.addInterceptor(chain -> {
|
||||
Request request = chain.request();
|
||||
String path = request.url().encodedPath();
|
||||
String host = "http://" + dns.syncGetHttpDns(request.url().host().replace("http://", "").replace("https://", ""), HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_HTTP, true);
|
||||
String host = "http://" + dns.syncGetHttpDns(request.url().host().replace("http://", "").replace("https://", ""), HTTP_DNS_ADDRESS_TYPE_HTTP, true);
|
||||
String url = host + path;
|
||||
Logger.d("DomainExchange", "oriHost: " + request.url().host() + " newHost: " + host+" \r\n newUrl: "+url);
|
||||
Logger.d("DomainExchange", "oriHost: " + request.url().host() + " newHost: " + host + " \r\n newUrl: " + url);
|
||||
return chain.proceed(request.newBuilder().url(url).build());
|
||||
})
|
||||
.setHttpDns( null )
|
||||
.setLoggable( DebugConfig.isDebug() );
|
||||
.setHttpDns(null)
|
||||
.setLoggable(DebugConfig.isDebug());
|
||||
}
|
||||
|
||||
private String cacheIp = null;
|
||||
|
||||
protected void registerSocketHttpDnsTTL(String host) {
|
||||
IMogoHttpDns mogoHttpDns = MogoHttpDnsHandler.getHttpDnsApi();
|
||||
mogoHttpDns.addressChangedListener(map -> {
|
||||
Logger.d("TEST-SOCKET", "ttl callBack ,ready to getCache Dns IP");
|
||||
String dnsCacheIp = mogoHttpDns.getCachedHttpDnsIps(host, HTTP_DNS_ADDRESS_TYPE_HTTP);
|
||||
if (dnsCacheIp == null) {
|
||||
return;
|
||||
}
|
||||
Logger.d("TEST-SOCKET", "获取缓存Dns IP : " + dnsCacheIp + " , 原缓存 IP : " + cacheIp);
|
||||
if (!dnsCacheIp.equals(cacheIp)) {
|
||||
socketTTL();
|
||||
this.cacheIp = dnsCacheIp;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract void socketTTL();
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public abstract class MvpActivity< V extends IView, P extends Presenter< V > >
|
||||
try {
|
||||
if (DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_LENOVO) {
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent(new ComponentName("com.zhidao.speech.voice.pad",
|
||||
intent.setComponent(new ComponentName("com.zhidao.speech",
|
||||
"com.zhidao.speech.MainActivity"));
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
|
||||
@@ -158,21 +158,22 @@ LOGLIB_VERSION = 1.0.4
|
||||
|
||||
######## MogoAiCloudSDK Version
|
||||
# 网络请求
|
||||
MOGO_NETWORK_VERSION=1.1.18
|
||||
MOGO_NETWORK_VERSION=1.1.32
|
||||
# 鉴权
|
||||
MOGO_PASSPORT_VERSION=1.1.18
|
||||
MOGO_PASSPORT_VERSION=1.1.32
|
||||
# 常链接
|
||||
MOGO_SOCKET_VERSION=1.1.18
|
||||
MOGO_SOCKET_VERSION=1.1.32
|
||||
# 数据采集
|
||||
MOGO_REALTIME_VERSION=1.1.18
|
||||
MOGO_REALTIME_VERSION=1.1.32
|
||||
# 探路,道路事件发布,获取
|
||||
MOGO_TANLU_VERSION=1.1.18
|
||||
MOGO_TANLU_VERSION=1.1.32
|
||||
# 直播推流
|
||||
MOGO_LIVE_VERSION=1.1.18
|
||||
MOGO_LIVE_VERSION=1.1.32
|
||||
# 直播拉流
|
||||
MOGO_TRAFFICLIVE_VERSION=1.1.18
|
||||
#ADAS HIGHT
|
||||
MOGO_ADASHIGH_VERSION=1.1.3
|
||||
MOGO_TRAFFICLIVE_VERSION=1.1.32
|
||||
# 定位服务
|
||||
MOGO_LOCATION_VERSION=1.1.32
|
||||
|
||||
|
||||
######## Foundation MogoAiCloud Module
|
||||
# mogoAiCloud apk services
|
||||
@@ -180,11 +181,11 @@ MOGO_AICLOUD_SERVICES_APK_VERSION=1.0.0-SNAPSHOT
|
||||
# mogoAiCloud sdk services
|
||||
MOGO_AICLOUD_SERVICES_SDK_VERSION=1.0.0-SNAPSHOT
|
||||
# 自研地图
|
||||
MAP_SDK_VERSION=1.0.0-vr-8.5.61
|
||||
MAP_SDK_VERSION=1.0.0-vr-8.5.77
|
||||
|
||||
|
||||
## 产品库必备配置,产品库自动对versionCode和versionName版本进行升级
|
||||
applicationId=com.mogo.launcer
|
||||
applicationName=IntelligentPilot
|
||||
versionCode=80007
|
||||
versionName=8.0.8
|
||||
versionName=8.0.9
|
||||
@@ -245,6 +245,11 @@ public class AMapWrapper implements IMogoMap {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMapVersion() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean checkAMap() {
|
||||
if ( mAMap == null ) {
|
||||
Logger.e( TAG, "高德map实例为空,请检查" );
|
||||
|
||||
@@ -107,4 +107,10 @@ fix crash
|
||||
修改画线问题
|
||||
|
||||
8.5.60
|
||||
修改崩溃
|
||||
|
||||
8.5.63
|
||||
修改infoWindow崩溃
|
||||
|
||||
8.5.64
|
||||
修改崩溃
|
||||
@@ -263,6 +263,11 @@ public class AMapWrapper implements IMogoMap {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMapVersion() {
|
||||
return MapAutoApi.INSTANCE.getSDKVersion();
|
||||
}
|
||||
|
||||
private boolean checkAMap() {
|
||||
mAMap = mMapView.getMapAutoViewHelper();
|
||||
sAMap = mAMap;
|
||||
|
||||
@@ -95,7 +95,7 @@ class CustomMapApiBuilder implements IMogoMapApiBuilder {
|
||||
public IMogoMapView getMapView( Context context ) {
|
||||
Log.d(TAG,"setDebugMode==true");
|
||||
NavAutoApi.INSTANCE.init( context, MapParams.Companion.init()
|
||||
.setDebugMode( true )
|
||||
.setDebugMode( DebugConfig.isDebug() )
|
||||
.setDataFileSource(1) //todo 1-使用本地地图数据,0-使用在线地图数据
|
||||
.setCoordinateType( MapParams.COORDINATETYPE_GCJ02 )
|
||||
.setPerspectiveMode( MapParams.MAP_PERSPECTIVE_2D )
|
||||
|
||||
@@ -568,7 +568,7 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
@Override
|
||||
public void addDynamicAnchorPosition( MogoLatLng latLng, float angle, long duration ) {
|
||||
try {
|
||||
mMarker.addDynamicAnchorPostion( new LonLatPoint( latLng.lon, latLng.lat, angle ), System.currentTimeMillis(), ( int ) duration ,false , true);
|
||||
mMarker.addDynamicAnchorPostion( new LonLatPoint( latLng.lon, latLng.lat, angle ), System.currentTimeMillis(), ( int ) duration);
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -737,11 +737,6 @@ public class ObjectUtils {
|
||||
}
|
||||
target.setLineWidth( options.getWidth() );
|
||||
target.setColor( options.getColor() );
|
||||
// target.setGps(options.gps()); //todo 地图侧 验证画线问题 需要设置GPS提前至加点之前
|
||||
// target.zIndex( options.getWidth() );
|
||||
// target.visible( options.isVisible() );
|
||||
//// target.geodesic( options.isGeodesic() );
|
||||
// target.setDottedLine( options.isDottedLine() );
|
||||
target.useGradient( options.isGradient() );
|
||||
if ( options.getColorValues() != null ) {
|
||||
target.colorValues( options.getColorValues() );
|
||||
|
||||
@@ -142,4 +142,10 @@ public interface IMogoMap {
|
||||
* @return
|
||||
*/
|
||||
IMogoPolyline addPolyline( MogoPolylineOptions options );
|
||||
|
||||
/**
|
||||
* 获取地图版本号
|
||||
* @return
|
||||
*/
|
||||
String getMapVersion();
|
||||
}
|
||||
|
||||
@@ -56,6 +56,12 @@ public interface IMogoMarkerManager {
|
||||
*/
|
||||
void inVisibleAllMarkers();
|
||||
|
||||
/**
|
||||
* 隐藏除了某些类别的所有marker {@link MogoMarkerOptions Owner}
|
||||
* @param owner
|
||||
*/
|
||||
void inVisibleWithoutMarkers(String owner); //todo 后续需要把Owner类别统一起来,基类下沉,此接口为临时方案,应该设计为隐藏某一类元素
|
||||
|
||||
/**
|
||||
* 获取某种类型的全部marker。
|
||||
*
|
||||
|
||||
@@ -61,6 +61,17 @@ public class MogoMarkersHandler implements IMogoMarkerClickListener, IMogoMarker
|
||||
.forEach(mogoMarkerList -> mogoMarkerList.forEach(mogoMarker -> mogoMarker.setVisible(false)));
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public synchronized void inVisibleMarkers(String owner){
|
||||
mServicesMarkers.values().stream()
|
||||
.filter(mogoMarkerList -> mogoMarkerList != null && !mogoMarkerList.isEmpty())
|
||||
.forEach(mogoMarkerList -> mogoMarkerList.forEach(mogoMarker -> {
|
||||
if(TextUtils.isEmpty(mogoMarker.getOwner()) || !mogoMarker.getOwner().equals(owner)){
|
||||
mogoMarker.setVisible(false);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public synchronized void removeAll() {
|
||||
final Collection< List< IMogoMarker > > mogoMarkers = mServicesMarkers.values();
|
||||
for ( List< IMogoMarker > mogoMarkerList : mogoMarkers ) {
|
||||
|
||||
@@ -84,6 +84,11 @@ public class MogoMarkerManager implements IMogoMarkerManager {
|
||||
MogoMarkersHandler.getInstance().inVisibleAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inVisibleWithoutMarkers(String owner) {
|
||||
MogoMarkersHandler.getInstance().inVisibleMarkers(owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List< IMogoMarker > getMarkers( String tag ) {
|
||||
return MogoMarkersHandler.getInstance().getMarkers( tag );
|
||||
|
||||
@@ -2,16 +2,11 @@ package com.mogo.module.adas;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.google.gson.Gson;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.data.BaseData;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.module.adas.entity.AutonomousDriveStatusBean;
|
||||
import com.mogo.module.adas.entity.ReportSiteBean;
|
||||
import com.mogo.module.adas.entity.WarnMessageModel;
|
||||
import com.mogo.module.adas.model.AdasServiceModel;
|
||||
import com.mogo.module.adas.network.IAdasApiService;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.RequestOptions;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotArriveModel;
|
||||
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotStateModel;
|
||||
@@ -33,14 +28,9 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Flowable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.annotations.NonNull;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
import static com.mogo.commons.context.ContextHolderUtil.getContext;
|
||||
import static com.mogo.module.adas.AdasConstant.getBaseUrl;
|
||||
|
||||
/**
|
||||
@@ -55,9 +45,7 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
|
||||
|
||||
private final Gson gson;
|
||||
private final ArrayList<IAdasDataListener> iAdasEventListeners = new ArrayList<>();
|
||||
private final ArrayList<AdasStatusListener> iAdasStatusListeners = new ArrayList<>();
|
||||
private final IAdasApiService mAdasApiService;
|
||||
//private final AdasProvider adasProvider;
|
||||
private final ArrayList<IAdasStatusListener> iAdasStatusListeners = new ArrayList<>();
|
||||
private Disposable uploadAutopilotStatus;
|
||||
//自动驾驶状态
|
||||
private int mCurrentAutopilotStatus = -1;
|
||||
@@ -67,10 +55,10 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
|
||||
//自动驾驶状态
|
||||
private AutopilotStatus.ValuesBean mAutopilotValuesStatus = null;
|
||||
|
||||
private IAdasProviderBizListener providerBizListener;
|
||||
|
||||
private AdasEventManager() {
|
||||
gson = GsonUtil.getGson();
|
||||
mAdasApiService = MogoApisHandler.getInstance().getApis().getNetworkApi().create(IAdasApiService.class, getBaseUrl());
|
||||
//adasProvider = ARouter.getInstance().navigation(AdasProvider.class);
|
||||
}
|
||||
|
||||
public static AdasEventManager getInstance() {
|
||||
@@ -97,7 +85,7 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
|
||||
iAdasEventListeners.remove(listener);
|
||||
}
|
||||
|
||||
public void addStatusListener(AdasStatusListener listener) {
|
||||
public void addStatusListener(IAdasStatusListener listener) {
|
||||
Logger.d(TAG, "添加adas状态事件监听");
|
||||
if (iAdasStatusListeners.contains(listener)) {
|
||||
return;
|
||||
@@ -105,7 +93,7 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
|
||||
iAdasStatusListeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeStatusListener(AdasStatusListener listener) {
|
||||
public void removeStatusListener(IAdasStatusListener listener) {
|
||||
Logger.d(TAG, "注销adas状态事件监听");
|
||||
iAdasStatusListeners.remove(listener);
|
||||
}
|
||||
@@ -119,15 +107,9 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
|
||||
public void onWarnMessage(WarnMessageInfo warnMessageInfo) {
|
||||
Logger.d(TAG, "onWarnMessage " + warnMessageInfo);
|
||||
//报警model
|
||||
WarnMessageModel warnMessageModel = null;
|
||||
for (IAdasDataListener listener : iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
if (warnMessageModel == null) {
|
||||
warnMessageModel = new WarnMessageModel();
|
||||
warnMessageModel.setAction(MsgActionType.ACTION_WS_MSG_WARNING_TYPE.getmActionType());
|
||||
}
|
||||
warnMessageModel.setValues(warnMessageInfo);
|
||||
listener.cameraEyeDetectResult(gson.toJson(warnMessageModel));
|
||||
listener.onWarnMessage(warnMessageInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,7 +129,7 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
|
||||
try {
|
||||
for (IAdasDataListener listener : iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.cameraEyeDetectResult(gson.toJson(rectInfo));
|
||||
listener.onRectData(rectInfo);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -252,17 +234,17 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
|
||||
|
||||
@Override
|
||||
public void onAutopilotSNRequest() {
|
||||
// if (adasProvider != null) {
|
||||
// adasProvider.setBasicInfo();
|
||||
// } else {
|
||||
// Logger.e(TAG, "onAutopilotSNRequest adasProvider is null");
|
||||
// }
|
||||
if (providerBizListener != null) {
|
||||
providerBizListener.getDeviceSn();
|
||||
} else {
|
||||
Logger.e(TAG, "onAutopilotSNRequest providerBizListener is null");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWebSocketConnectSuccess() {
|
||||
Logger.d(TAG, "webSocket 连接成功");
|
||||
for (AdasStatusListener listener : iAdasStatusListeners) {
|
||||
for (IAdasStatusListener listener : iAdasStatusListeners) {
|
||||
listener.onServiceConnected();
|
||||
}
|
||||
updateDriveStatusTask();
|
||||
@@ -271,7 +253,7 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
|
||||
@Override
|
||||
public void onWebSocketConnectFailed() {
|
||||
Logger.d(TAG, "webSocket 连接失败");
|
||||
for (AdasStatusListener listener : iAdasStatusListeners) {
|
||||
for (IAdasStatusListener listener : iAdasStatusListeners) {
|
||||
listener.onServiceDisconnected();
|
||||
}
|
||||
}
|
||||
@@ -282,62 +264,15 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
|
||||
.subscribeOn(Schedulers.io())
|
||||
.unsubscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<Long>() {
|
||||
@Override
|
||||
public void accept(@NonNull Long aLong) throws Exception {
|
||||
updateDriveStatus();
|
||||
}
|
||||
});
|
||||
.subscribe(aLong -> updateDriveStatus());
|
||||
}
|
||||
|
||||
private void updateDriveStatus() {
|
||||
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
AutonomousDriveStatusBean request = new AutonomousDriveStatusBean(sn, mCurrentAutopilotStatus, mCurrentAutopilotSpeed);
|
||||
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(request));
|
||||
mAdasApiService.updateAutonomousDriveStatus(requestBody).
|
||||
subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getContext())) {
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
Logger.d(TAG, "updateDriveStatus success");
|
||||
}
|
||||
});
|
||||
AdasServiceModel.getInstance().updateDriveStatus(mCurrentAutopilotStatus, mCurrentAutopilotSpeed);
|
||||
}
|
||||
|
||||
private void reportSite(double lon, double lat) {
|
||||
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
ReportSiteBean reportSiteBean = new ReportSiteBean(sn, lon, lat);
|
||||
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(reportSiteBean));
|
||||
mAdasApiService.updateReportSite(requestBody).
|
||||
subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getContext())) {
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
Logger.d(TAG, "autopilotArrive success");
|
||||
}
|
||||
});
|
||||
AdasServiceModel.getInstance().reportSite(lon, lat);
|
||||
}
|
||||
|
||||
public AutopilotStatus.ValuesBean getAutopilotValuesStatus() {
|
||||
@@ -354,5 +289,7 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
|
||||
return adasAIDLAutopilotStateModel;
|
||||
}
|
||||
|
||||
|
||||
public void setProviderBizListener(IAdasProviderBizListener listener) {
|
||||
providerBizListener = listener;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class AdasProvider implements IProvider {
|
||||
initAdas(context, adasEventManager);
|
||||
initAutoPilotBusiness(context);
|
||||
|
||||
addAdasStatusListener(new AdasStatusListener() {
|
||||
addAdasStatusListener(new IAdasStatusListener() {
|
||||
@Override
|
||||
public void onServiceConnected() {
|
||||
Logger.d(TAG, "adas statusListener connected & send sn");
|
||||
@@ -49,6 +49,7 @@ public class AdasProvider implements IProvider {
|
||||
AdasManager.getInstance().create(context);
|
||||
AdasManager.getInstance().setOnAdasListener(adasEventManager);
|
||||
AdasManager.getInstance().setOnAdasConnectStatusListener(adasEventManager);
|
||||
adasEventManager.setProviderBizListener(this::setBasicInfo);
|
||||
}
|
||||
|
||||
private void initAutoPilotBusiness(Context context) {
|
||||
@@ -73,11 +74,11 @@ public class AdasProvider implements IProvider {
|
||||
adasEventManager.removeEventListener(listener);
|
||||
}
|
||||
|
||||
public void addAdasStatusListener(AdasStatusListener listener) {
|
||||
public void addAdasStatusListener(IAdasStatusListener listener) {
|
||||
adasEventManager.addStatusListener(listener);
|
||||
}
|
||||
|
||||
public void removeAdasStatusListener(AdasStatusListener listener) {
|
||||
public void removeAdasStatusListener(IAdasStatusListener listener) {
|
||||
adasEventManager.removeStatusListener(listener);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,35 +1,32 @@
|
||||
package com.mogo.module.adas;
|
||||
|
||||
import com.mogo.module.adas.entity.WarnMessageModel;
|
||||
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotArriveModel;
|
||||
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotStateModel;
|
||||
import com.zhidao.autopilotservice.model.AdasAIDLOwnerCarRectModel;
|
||||
import com.zhidao.autopilotservice.model.AdasAIDLOwnerCarStateModel;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotRoute;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotStatus;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotWayArrive;
|
||||
import com.zhidao.support.adas.high.bean.CarLaneInfo;
|
||||
import com.zhidao.support.adas.high.bean.CarStateInfo;
|
||||
import com.zhidao.support.adas.high.bean.LightStatueInfo;
|
||||
import com.zhidao.support.adas.high.bean.ObstaclesInfo;
|
||||
import com.zhidao.support.adas.high.bean.RectInfo;
|
||||
import com.zhidao.support.adas.high.bean.WarnMessageInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by XuYong on 2021/4/25 16:52
|
||||
*/
|
||||
|
||||
public interface IAdasDataListener {
|
||||
|
||||
default void sendMsg( String msg ){
|
||||
default void sendMsg(String msg) {
|
||||
|
||||
};
|
||||
|
||||
default void cameraEyeDetectResult( String detectResult ) {
|
||||
}
|
||||
|
||||
default void selectCarModelUrl( String carStyleUrl ) {
|
||||
default void onRectData(RectInfo rectInfo) {
|
||||
|
||||
}
|
||||
|
||||
default void onWarnMessage(WarnMessageInfo warnMessageInfo) {
|
||||
|
||||
}
|
||||
|
||||
default void selectCarModelUrl(String carStyleUrl) {
|
||||
}
|
||||
|
||||
default void requestGetCarModelListInfo() {
|
||||
@@ -38,42 +35,41 @@ public interface IAdasDataListener {
|
||||
default void clickSettingBack() {
|
||||
}
|
||||
|
||||
default void showToast( String msg ) {
|
||||
default void showToast(String msg) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动驾驶到达站点回调接口
|
||||
*
|
||||
* @param autopilotArriveModel
|
||||
*/
|
||||
default void autopilotArrive( AdasAIDLAutopilotArriveModel autopilotArriveModel ) {
|
||||
default void autopilotArrive(AdasAIDLAutopilotArriveModel autopilotArriveModel) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动驾驶路线回调
|
||||
*
|
||||
* @param autopilotRoute {@link AutopilotRoute}
|
||||
*/
|
||||
default void autopilotRoute(AutopilotRoute autopilotRoute){
|
||||
default void autopilotRoute(AutopilotRoute autopilotRoute) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 自车定位信息
|
||||
*
|
||||
* @param ownerCarStateInfo
|
||||
*/
|
||||
default void ownerCarStateInfo( String ownerCarStateInfo ) {
|
||||
}
|
||||
|
||||
default void notifyOwnerCarState( AdasAIDLOwnerCarStateModel ownerCarStateModel ) {
|
||||
default void ownerCarStateInfo(String ownerCarStateInfo) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动驾驶状态信息
|
||||
*
|
||||
* @param autopilotStatus {@link AutopilotStatus}
|
||||
*/
|
||||
default void notifyAutopilotState( AutopilotStatus autopilotStatus ) {
|
||||
default void notifyAutopilotState(AutopilotStatus autopilotStatus) {
|
||||
}
|
||||
|
||||
default void notifyOwnerCarRect( List<AdasAIDLOwnerCarRectModel> ownerCarStateRectList ) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.mogo.module.adas;
|
||||
|
||||
public interface IAdasProviderBizListener {
|
||||
|
||||
void getDeviceSn();
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package com.mogo.module.adas;
|
||||
/**
|
||||
* Created by XuYong on 4/28/21 16:19
|
||||
*/
|
||||
public interface AdasStatusListener {
|
||||
public interface IAdasStatusListener {
|
||||
|
||||
void onServiceConnected();
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.mogo.module.adas.model;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.data.BaseData;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.module.adas.entity.AutonomousDriveStatusBean;
|
||||
import com.mogo.module.adas.entity.ReportDispatchResult;
|
||||
import com.mogo.module.adas.entity.ReportSiteBean;
|
||||
import com.mogo.module.adas.entity.ReportedRoute;
|
||||
import com.mogo.module.adas.network.IAdasApiService;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
@@ -14,16 +15,16 @@ import com.mogo.utils.network.utils.GsonUtil;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotRoute;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotStatus;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
import static com.mogo.commons.context.ContextHolderUtil.getContext;
|
||||
import static com.mogo.module.adas.AdasConstant.getBaseUrl;
|
||||
import static com.mogo.module.common.constants.HostConst.DATA_SERVICE_HOST;
|
||||
|
||||
public class AdasServiceModel {
|
||||
@@ -126,7 +127,7 @@ public class AdasServiceModel {
|
||||
*
|
||||
* @param dispatchResultType int
|
||||
*/
|
||||
public void dispatchResultUpload(int dispatchResultType,IDispatch dispatch) {
|
||||
public void dispatchResultUpload(int dispatchResultType, IDispatch dispatch) {
|
||||
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
ReportDispatchResult reportDispatchResult = new ReportDispatchResult(sn, dispatchResultType);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
@@ -157,4 +158,54 @@ public class AdasServiceModel {
|
||||
});
|
||||
}
|
||||
|
||||
public void updateDriveStatus(int autoPilotStatus, float autoPilotSpeed) {
|
||||
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
AutonomousDriveStatusBean request = new AutonomousDriveStatusBean(sn, autoPilotStatus, autoPilotSpeed);
|
||||
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(request));
|
||||
mAdasApiService.updateAutonomousDriveStatus(requestBody).
|
||||
subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getContext())) {
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
Logger.d(TAG, "updateDriveStatus success");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void reportSite(double lon, double lat){
|
||||
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
ReportSiteBean reportSiteBean = new ReportSiteBean(sn, lon, lat);
|
||||
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(reportSiteBean));
|
||||
mAdasApiService.updateReportSite(requestBody).
|
||||
subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getContext())) {
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
Logger.d(TAG, "autopilotArrive success");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
[{"lat":26.820175208327566,"lng":0.0,"lon":112.57748204198309},{"lat":26.82009891465042,"lng":0.0,"lon":112.57735739748664},{"lat":26.820022750763542,"lng":0.0,"lon":112.57723266155585},{"lat":26.81994655656347,"lng":0.0,"lon":112.57710795477944},{"lat":26.81987031666393,"lng":0.0,"lon":112.57698328267305},{"lat":26.819793988171348,"lng":0.0,"lon":112.57685866945901},{"lat":26.819717530408877,"lng":0.0,"lon":112.57673414980971},{"lat":26.819635079638967,"lng":0.0,"lon":112.57661462149986},{"lat":26.819532022659132,"lng":0.0,"lon":112.5765234581422},{"lat":26.819488197195188,"lng":0.0,"lon":112.5764835085963},{"lat":26.81947053563866,"lng":0.0,"lon":112.57645743645142},{"lat":26.81945285740347,"lng":0.0,"lon":112.5764313389555},{"lat":26.81941584428336,"lng":0.0,"lon":112.57637074918446},{"lat":26.819355855639404,"lng":0.0,"lon":112.57626774620917},{"lat":26.8193352833325,"lng":0.0,"lon":112.57623094969783},{"lat":26.819315738575742,"lng":0.0,"lon":112.57619587959701},{"lat":26.81929619389902,"lng":0.0,"lon":112.5761608096667},{"lat":26.819276064037396,"lng":0.0,"lon":112.5761245744324},{"lat":26.819221654527443,"lng":0.0,"lon":112.5760208132482},{"lat":26.819153675938914,"lng":0.0,"lon":112.5758903945585},{"lat":26.8190859083974,"lng":0.0,"lon":112.57576035026403},{"lat":26.81904791926707,"lng":0.0,"lon":112.57568644394968},{"lat":26.819047477540156,"lng":0.0,"lon":112.57568591545105},{"lat":26.819047035811135,"lng":0.0,"lon":112.57568538694994},{"lat":26.819046594080046,"lng":0.0,"lon":112.57568485844635},{"lat":26.81902999052958,"lng":0.0,"lon":112.57568137976324},{"lat":26.818966668056316,"lng":0.0,"lon":112.57572279587626},{"lat":26.81896660310204,"lng":0.0,"lon":112.57572518130716},{"lat":26.81896683258833,"lng":0.0,"lon":112.57572606581252},{"lat":26.81896706207354,"lng":0.0,"lon":112.57572695031374},{"lat":26.818971211272444,"lng":0.0,"lon":112.57573544393973},{"lat":26.819027657144368,"lng":0.0,"lon":112.57584589447032},{"lat":26.819095546341085,"lng":0.0,"lon":112.57597644303986},{"lat":26.8191650468231,"lng":0.0,"lon":112.57610591408428},{"lat":26.819236806047,"lng":0.0,"lon":112.5762338575302},{"lat":26.819310184480436,"lng":0.0,"lon":112.57636063880027},{"lat":26.819384451187933,"lng":0.0,"lon":112.5764867800095},{"lat":26.819460642360763,"lng":0.0,"lon":112.57661149583805},{"lat":26.819536878267925,"lng":0.0,"lon":112.57673619431976},{"lat":26.819613220428206,"lng":0.0,"lon":112.57686079387894},{"lat":26.819689146973122,"lng":0.0,"lon":112.57698570087358},{"lat":26.819765257290772,"lng":0.0,"lon":112.57711047564952},{"lat":26.81984156841068,"lng":0.0,"lon":112.57723510283108},{"lat":26.819916608456698,"lng":0.0,"lon":112.57735767331373},{"lat":26.819990868286688,"lng":0.0,"lon":112.57747918205983},{"lat":26.82006704845146,"lng":0.0,"lon":112.57760363217366},{"lat":26.820142688927376,"lng":0.0,"lon":112.57772676391022},{"lat":26.820220480866162,"lng":0.0,"lon":112.57784947830805},{"lat":26.82029609426984,"lng":0.0,"lon":112.57797111160743},{"lat":26.820372540342063,"lng":0.0,"lon":112.57809575812311},{"lat":26.820449035279513,"lng":0.0,"lon":112.57822036992494},{"lat":26.82052479395364,"lng":0.0,"lon":112.5783432083879},{"lat":26.820600741070034,"lng":0.0,"lon":112.57846626552721},{"lat":26.820676451505513,"lng":0.0,"lon":112.57858892597905},{"lat":26.820750627333855,"lng":0.0,"lon":112.57870908764811},{"lat":26.820788099971104,"lng":0.0,"lon":112.57876896886103},{"lat":26.82079340880141,"lng":0.0,"lon":112.57877600898784},{"lat":26.82079871765643,"lng":0.0,"lon":112.57878304914836},{"lat":26.820804096213536,"lng":0.0,"lon":112.57879017489086},{"lat":26.820866626548845,"lng":0.0,"lon":112.5788587003478},{"lat":26.820983640738305,"lng":0.0,"lon":112.57893123552938},{"lat":26.82111632395692,"lng":0.0,"lon":112.57893777257203},{"lat":26.82117204164965,"lng":0.0,"lon":112.57891747212024},{"lat":26.821184743761496,"lng":0.0,"lon":112.57890962148315},{"lat":26.821197445813166,"lng":0.0,"lon":112.5789017
|
||||
@@ -19,7 +19,6 @@ public class RecycleViewHolder extends RecyclerView.ViewHolder {
|
||||
super(itemView);
|
||||
this.mConvertView = itemView;
|
||||
mViews = new SparseArray<View>();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public static RecycleViewHolder get(View itemView) {
|
||||
|
||||
@@ -131,7 +131,6 @@ open class IMogoAuthorizeController {
|
||||
}
|
||||
}
|
||||
onError {
|
||||
//todo
|
||||
Logger.d(TAG, it.message ?: "checkIfNeedAuthorize onError, message is null")
|
||||
setAuthorizeStatus(agreementType, true)
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ abstract class MogoAuthorizeManagerImpl : IMogoAuthorizeInvoke {
|
||||
}
|
||||
|
||||
override fun invokeAuthorizeContent(tag: String) {
|
||||
//todo 后面动态代理统一处理校验问题
|
||||
Logger.d(TAG, "tag:$tag")
|
||||
val agreementType = AuthorizeProxy.getAuthorizeType(tag)
|
||||
Logger.d(TAG, "agreementType:$agreementType")
|
||||
|
||||
@@ -56,6 +56,8 @@ dependencies {
|
||||
api project(":foudations:mogo-commons")
|
||||
api project(':services:mogo-service-api')
|
||||
}
|
||||
|
||||
annotationProcessor 'com.elegant.spi:compiler:1.0.3'
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
|
||||
@@ -1,2 +1,12 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.module.common" />
|
||||
package="com.mogo.module.common" >
|
||||
|
||||
<application>
|
||||
<receiver android:name=".datacenter.receiver.SnapShotMockTestPanelBroadCastReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="com.loc.test_panel_control" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
</application>
|
||||
</manifest>
|
||||
|
||||
@@ -21,6 +21,8 @@ public class HostConst {
|
||||
public static final String IM_SOCKET_DOMAIN = "dzt-im.zhidaozhixing.com";
|
||||
public static final String WEBSOCKET_DOMAIN = "dzt-Instant.zhidaozhixing.com";
|
||||
|
||||
public static final String SOCKET_CENTER_DOMAIN = "socketRegion";
|
||||
|
||||
// 网约车
|
||||
public static final String OCH_DOMAIN = "http://dzt-hailing.zhidaozhixing.com";
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.mogo.module.common.datacenter;
|
||||
|
||||
public class RealTimeData {
|
||||
|
||||
private static volatile RealTimeData realTimeData;
|
||||
private static final byte[] bytes = new byte[0];
|
||||
|
||||
private double lat;
|
||||
private double lon;
|
||||
private double heading;
|
||||
private int speed;
|
||||
private long satelliteTime;
|
||||
|
||||
private RealTimeData() {
|
||||
|
||||
}
|
||||
|
||||
public static RealTimeData getInstance() {
|
||||
if (realTimeData == null) {
|
||||
synchronized (bytes) {
|
||||
if (realTimeData == null) {
|
||||
realTimeData = new RealTimeData();
|
||||
}
|
||||
}
|
||||
}
|
||||
return realTimeData;
|
||||
}
|
||||
|
||||
public void setLat(double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public void setLon(double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public void setHeading(double heading) {
|
||||
this.heading = heading;
|
||||
}
|
||||
|
||||
public void setSpeed(int speed) {
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
public void setSatelliteTime(long satelliteTime) {
|
||||
this.satelliteTime = satelliteTime;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public double getHeading() {
|
||||
return heading;
|
||||
}
|
||||
|
||||
public int getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public long getSatelliteTime() {
|
||||
return satelliteTime;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +1,30 @@
|
||||
package com.mogo.module.common.uploadintime;
|
||||
package com.mogo.module.common.datacenter;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.service.locationinfo.CloudLocationInfo;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* @author congtaowang
|
||||
* @since 2020/12/14
|
||||
*
|
||||
* 实时坐标数据处理中心
|
||||
/**
|
||||
* 定位坐标同步数据中心
|
||||
* 接收来自工控机实际定位数据
|
||||
*/
|
||||
public class SnapshotLocationController {
|
||||
public class SnapshotLocationDataCenter {
|
||||
|
||||
private static final String TAG = "SnapshotLocationController";
|
||||
private static volatile SnapshotLocationDataCenter sInstance;
|
||||
|
||||
private static volatile SnapshotLocationController sInstance;
|
||||
|
||||
private SnapshotLocationController() {
|
||||
private SnapshotLocationDataCenter() {
|
||||
}
|
||||
|
||||
public static SnapshotLocationController getInstance() {
|
||||
public static SnapshotLocationDataCenter getInstance() {
|
||||
if (sInstance == null) {
|
||||
synchronized (SnapshotLocationController.class) {
|
||||
synchronized (SnapshotLocationDataCenter.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new SnapshotLocationController();
|
||||
sInstance = new SnapshotLocationDataCenter();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,6 +47,7 @@ public class SnapshotLocationController {
|
||||
private double mCurSpeed;
|
||||
private double mCurLon;
|
||||
private double mCurLat;
|
||||
private long mSatelliteTime = 0;
|
||||
|
||||
/**
|
||||
* 同步从定位来的数据(也可能是rtk)
|
||||
@@ -81,7 +77,6 @@ public class SnapshotLocationController {
|
||||
//测试面板状态同步
|
||||
DebugConfig.setStatus(DebugConfig.sLocation, true);
|
||||
|
||||
// Logger.d(TAG, "同步到rtk数据");
|
||||
double lon = data.optDouble("lon", -1);
|
||||
double lat = data.optDouble("lat", -1);
|
||||
double alt = data.optDouble("alt", -1);
|
||||
@@ -111,6 +106,7 @@ public class SnapshotLocationController {
|
||||
mCurSpeed = cloudLocationInfo.getSpeed();
|
||||
mCurLon = cloudLocationInfo.getLon();
|
||||
mCurLat = cloudLocationInfo.getLat();
|
||||
mSatelliteTime = cloudLocationInfo.getSatelliteTime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,7 +139,6 @@ public class SnapshotLocationController {
|
||||
if (list.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
//Logger.d( TAG, "upload loc size = %s", list == null ? 0 : list.size() );
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -153,7 +148,6 @@ public class SnapshotLocationController {
|
||||
* @return 精度
|
||||
*/
|
||||
public int getDataAccuracy() {
|
||||
//Logger.d( TAG, "upload loc accuracy = %s", mDataAccuracy );
|
||||
return mDataAccuracy;
|
||||
}
|
||||
|
||||
@@ -168,4 +162,8 @@ public class SnapshotLocationController {
|
||||
public double getCurLat() {
|
||||
return mCurLat;
|
||||
}
|
||||
|
||||
public long getSatelliteTime(){
|
||||
return mSatelliteTime;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.mogo.module.common.datacenter;
|
||||
|
||||
import com.elegant.spi.annotations.Service;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.realtime.api.IRealTimeProvider;
|
||||
import com.mogo.realtime.entity.SocketReceiveDataProto3;
|
||||
import com.mogo.realtime.util.MortonCode;
|
||||
|
||||
import static com.mogo.cloud.socket.SocketMsgType.MSG_TYPE_UPLINK_CAR_DATA;
|
||||
|
||||
@Service(value = IRealTimeProvider.class)
|
||||
public class SpiRealTimeProvider implements IRealTimeProvider {
|
||||
|
||||
@Override
|
||||
public SocketReceiveDataProto3.SocketReceiveDataProto getLocationMsg() {
|
||||
|
||||
double lat = RealTimeData.getInstance().getLat();
|
||||
double lon = RealTimeData.getInstance().getLon();
|
||||
if (lat == 0.0f || lon == 0.0f) {
|
||||
return null;
|
||||
}
|
||||
double heading = RealTimeData.getInstance().getHeading();
|
||||
int speed = RealTimeData.getInstance().getSpeed();
|
||||
long satelliteTime = RealTimeData.getInstance().getSatelliteTime();
|
||||
long mortonCode = MortonCode.encodeMorton(lon, lat);
|
||||
|
||||
SocketReceiveDataProto3.LocationInfoProto locationInfoProto =
|
||||
SocketReceiveDataProto3.LocationInfoProto.newBuilder()
|
||||
.setLat(lat)
|
||||
.setLon(lon)
|
||||
.setHeading(heading)
|
||||
.setSystemTime(System.currentTimeMillis())
|
||||
.setSatelliteTime(satelliteTime)
|
||||
.setAlt(0)
|
||||
.setDataAccuracy(1)
|
||||
.setSpeed(speed)
|
||||
.setMortonCode(mortonCode)
|
||||
.setSn(MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
.build();
|
||||
|
||||
SocketReceiveDataProto3.MyLocationReq myLocationReq =
|
||||
SocketReceiveDataProto3.MyLocationReq.newBuilder()
|
||||
.setLastCoordinate(locationInfoProto)
|
||||
.setDataAccuracy(1)
|
||||
.setMortonCode(mortonCode)
|
||||
.setFromType(0)
|
||||
.setSn(MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
.build();
|
||||
|
||||
SocketReceiveDataProto3.OnePerSecondSendReqProto self =
|
||||
SocketReceiveDataProto3.OnePerSecondSendReqProto.newBuilder()
|
||||
.setSelf(myLocationReq)
|
||||
.build();
|
||||
return SocketReceiveDataProto3.SocketReceiveDataProto.newBuilder()
|
||||
.setIPCSn(MoGoAiCloudClientConfig.getInstance().getSn() + "xavier")
|
||||
.setSn(MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
.setData(self)
|
||||
.setMsgType(MSG_TYPE_UPLINK_CAR_DATA.getMsgType())
|
||||
.setSeq(System.currentTimeMillis()).build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.mogo.module.common.datacenter.receiver;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.mogo.module.common.datacenter.RealTimeData;
|
||||
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
public class SnapShotMockTestPanelBroadCastReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final String TAG = "SnapShotMockTestPanelBroadCastReceiver";
|
||||
|
||||
/**
|
||||
* 定位模拟测试控制面板广播Action
|
||||
*/
|
||||
public static final String BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY = "sceneType";
|
||||
|
||||
private Context mContext;
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
try {
|
||||
this.mContext = context;
|
||||
int sceneType = intent.getIntExtra(BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY, 0);
|
||||
Logger.d(TAG, "textPanelOpenType:" + sceneType);
|
||||
// 分发场景
|
||||
dispatchSceneTest(sceneType);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分发处理场景
|
||||
* 定位模拟分发场景中,需要case自己处理数据,以生产者消费者模式来提供 RealTimeData 所需字段
|
||||
*
|
||||
* @param sceneType 场景类型
|
||||
*/
|
||||
private void dispatchSceneTest(int sceneType) {
|
||||
Logger.d(TAG, "sceneType=" + sceneType);
|
||||
if (sceneType == 1) {
|
||||
//模拟顺义固定位置
|
||||
RealTimeData.getInstance().setLat(39.968309);
|
||||
RealTimeData.getInstance().setLon(116.410871);
|
||||
RealTimeData.getInstance().setHeading(120);
|
||||
RealTimeData.getInstance().setSpeed(30);
|
||||
long satelliteTime = SnapshotLocationDataCenter.getInstance().getSatelliteTime();
|
||||
if (satelliteTime == 0) {
|
||||
satelliteTime = System.currentTimeMillis();
|
||||
}
|
||||
RealTimeData.getInstance().setSatelliteTime(satelliteTime);
|
||||
} else if (sceneType == 2) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.module.common.drawer;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -11,6 +12,7 @@ import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.constants.DataTypes;
|
||||
import com.mogo.module.common.drawer.bean.SpeedData;
|
||||
import com.mogo.module.common.utils.Trigonometric;
|
||||
import com.mogo.service.adas.entity.ADASRecognizedResult;
|
||||
|
||||
@@ -19,6 +21,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_ADAS;
|
||||
|
||||
@@ -38,7 +41,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
/**
|
||||
* 上一帧数据的缓存
|
||||
*/
|
||||
protected static Map<String, IMogoMarker> mMarkersCaches = new ConcurrentHashMap<>();
|
||||
private static Map<String, IMogoMarker> mMarkersCaches = new ConcurrentHashMap<>();
|
||||
|
||||
public AdasRecognizedResultDrawer() {
|
||||
super();
|
||||
@@ -73,9 +76,10 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
/**
|
||||
* 渲染 adas 识别的数据
|
||||
*
|
||||
* @param resultList
|
||||
* @param resultList adas感知融合数据
|
||||
*/
|
||||
public void renderAdasRecognizedResult(List<ADASRecognizedResult> resultList) {
|
||||
final long start = System.nanoTime();
|
||||
if (resultList == null || resultList.isEmpty() || !DebugConfig.isUseAdasRecognize()) {
|
||||
clearOldMarker();
|
||||
return;
|
||||
@@ -100,9 +104,9 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
String uniqueKey = recognizedListResult.uuid;
|
||||
IMogoMarker marker = mMarkersCaches.remove(uniqueKey);
|
||||
if (marker != null && !marker.isDestroyed()) {
|
||||
Log.d(TAG, "发现缓存marker id : " + uniqueKey);
|
||||
// Log.d(TAG, "发现缓存marker id : " + uniqueKey);
|
||||
updateCacheMarkerRes(marker, recognizedListResult);
|
||||
renderAdasOneFrame(true, marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
|
||||
renderAdasOneFrame(marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
|
||||
} else {
|
||||
// 新增添加进差集
|
||||
newDiffSet.add(recognizedListResult);
|
||||
@@ -110,10 +114,9 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
}
|
||||
removeUselessMarker(mMarkersCaches);
|
||||
removeUselessLastRecord();
|
||||
|
||||
// 需要新增的 marker 数量
|
||||
int newDiffSetSize = newDiffSet.size();
|
||||
Log.d(TAG, "原数据量 : " + resultList.size() + " 新增marker数量 : " + newDiffSetSize);
|
||||
// Log.d(TAG, "原数据量 : " + resultList.size() + " 新增marker数量 : " + newDiffSetSize);
|
||||
// 复用过期 marker
|
||||
if (newDiffSetSize > 0) {
|
||||
for (int i = 0; i < newDiffSetSize; i++) {
|
||||
ADASRecognizedResult recognizedListResult = newDiffSet.get(i);
|
||||
@@ -122,14 +125,14 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
if (marker == null) {
|
||||
continue;
|
||||
}
|
||||
Log.d(TAG, "新增marker id : " + uniqueKey);
|
||||
renderAdasOneFrame(false, marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
|
||||
// Log.d(TAG, "新增marker id : " + uniqueKey);
|
||||
renderAdasOneFrame(marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
|
||||
}
|
||||
}
|
||||
sendMessage(MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches);
|
||||
mMarkersCaches.clear();
|
||||
mMarkersCaches = newAdasRecognizedMarkersCaches;
|
||||
Log.d(TAG, "更新缓存marker, size : " + mMarkersCaches.size());
|
||||
Log.d("ADAS数据延时绘制", "render 接收数据 -> 处理结束 " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)) + "ms");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,7 +215,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
while (iterator.hasNext()) {
|
||||
ADASRecognizedResult result = iterator.next();
|
||||
long internal = result.satelliteTime - getCurSatelliteTime();
|
||||
if (internal > 300) {
|
||||
if (internal > 3000) { //防止帧率过低导致误删除上一个节点对象,从而出现跳跃现象
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
@@ -228,7 +231,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
if (recognizedListResult == null) {
|
||||
return true;
|
||||
}
|
||||
if (!isRenderType(recognizedListResult.type)) {
|
||||
if (nonRenderType(recognizedListResult.type)) {
|
||||
return true;
|
||||
}
|
||||
String uniqueKey = recognizedListResult.uuid;
|
||||
@@ -241,13 +244,12 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
* @param recognizedListResult {@link ADASRecognizedResult}
|
||||
* @param newAdasRecognizedMarkersCaches 缓存集合
|
||||
*/
|
||||
private void renderAdasOneFrame(boolean useCache, IMogoMarker marker,
|
||||
private void renderAdasOneFrame(IMogoMarker marker,
|
||||
String uniqueKey,
|
||||
ADASRecognizedResult recognizedListResult,
|
||||
Map<String, IMogoMarker> newAdasRecognizedMarkersCaches) {
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
Log.d(TAG, "renderAdasOneFrame uuid : " + uniqueKey + " type : " + recognizedListResult.type);
|
||||
final long start = System.nanoTime();
|
||||
// Log.d(TAG, "renderAdasOneFrame uuid : " + uniqueKey + " type : " + recognizedListResult.type + " heading : " + recognizedListResult.heading);
|
||||
ADASRecognizedResult lastPosition = mLastPositions.remove(uniqueKey);
|
||||
// 道路吸附
|
||||
// double lastLon = -1;
|
||||
@@ -257,36 +259,43 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
// lastLat = lastPosition.lat;
|
||||
// }
|
||||
// double[] matchLonLat = getMatchLonLat(recognizedListResult.uuid, recognizedListResult.lon, recognizedListResult.lat, recognizedListResult.heading, lastLon, lastLat);
|
||||
//
|
||||
// recognizedListResult.lon = matchLonLat[0];
|
||||
// recognizedListResult.lat = matchLonLat[1];
|
||||
// Log.d( "matchRoad", "cost = %s", System.currentTimeMillis() - start );
|
||||
|
||||
mLastPositions.put(uniqueKey, recognizedListResult);
|
||||
if (useCache) {
|
||||
Log.d(TAG, "使用缓存 id : " + uniqueKey);
|
||||
long interval = 45;
|
||||
if(lastPosition != null){
|
||||
interval = computeAnimDuration(lastPosition.systemTime, recognizedListResult.systemTime, lastPosition.satelliteTime, recognizedListResult.satelliteTime);
|
||||
}
|
||||
final MogoLatLng renderLoc = new MogoLatLng(recognizedListResult.lat, recognizedListResult.lon);
|
||||
long cost = System.currentTimeMillis() - start;
|
||||
final long intervalRef = interval - cost;
|
||||
marker.addDynamicAnchorPosition(renderLoc, (float) recognizedListResult.heading, intervalRef);
|
||||
} else {
|
||||
Log.d(TAG, "未使用缓存 id : " + uniqueKey);
|
||||
marker.setRotateAngle(((float) recognizedListResult.heading));
|
||||
marker.setPosition(recognizedListResult.lat, recognizedListResult.lon);
|
||||
// Log.d(TAG, "使用缓存 id : " + uniqueKey);
|
||||
long interval = 45;
|
||||
if (lastPosition != null) {
|
||||
interval = computeAnimDuration(lastPosition.satelliteTime, recognizedListResult.satelliteTime);
|
||||
}
|
||||
final MogoLatLng renderLoc = new MogoLatLng(recognizedListResult.lat, recognizedListResult.lon);
|
||||
long cost = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
|
||||
Log.d("ADAS动画数据","cost : " + cost);
|
||||
final long intervalRef = interval - cost;
|
||||
Log.d("ADAS动画数据", "最终赋值 : " + intervalRef + " 两帧间隔 : " + interval + " uuid : " + recognizedListResult.uuid);
|
||||
marker.addDynamicAnchorPosition(renderLoc, (float) recognizedListResult.heading, intervalRef);
|
||||
String carColor = recognizedListResult.color;
|
||||
if (TextUtils.isEmpty(carColor)) {
|
||||
carColor = getModelRenderColor(recognizedListResult.type, FROM_ADAS, recognizedListResult.drawlevel);
|
||||
}
|
||||
marker.setAnchorColor(carColor);
|
||||
|
||||
newAdasRecognizedMarkersCaches.put(uniqueKey, marker);
|
||||
|
||||
// if (shouldShowSpeed(recognizedListResult.type)) {
|
||||
// showSelfSpeed(marker, recognizedListResult.speed, recognizedListResult.uuid, recognizedListResult.type, recognizedListResult.heading, MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
|
||||
// }
|
||||
if (shouldShowSpeed(recognizedListResult.type)) {
|
||||
Message msg = mRenderThreadHandler.obtainMessage();
|
||||
msg.obj = new SpeedData(marker
|
||||
, recognizedListResult.speed
|
||||
, recognizedListResult.uuid
|
||||
, recognizedListResult.type
|
||||
, recognizedListResult.heading
|
||||
, MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
|
||||
msg.what = MSG_DISPLAY_SPEED;
|
||||
msg.sendToTarget();
|
||||
}
|
||||
Log.d("ADAS数据延时", "render 刷新一台车 cost : " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -296,6 +305,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
* @return {@link IMogoMarker}
|
||||
*/
|
||||
private IMogoMarker drawAdasRecognizedDataMarker(ADASRecognizedResult recognizedListResult) {
|
||||
long start = System.nanoTime();
|
||||
if (recognizedListResult == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -320,6 +330,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
.position(new MogoLatLng(recognizedListResult.lat, recognizedListResult.lon));
|
||||
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(DataTypes.TYPE_MARKER_ADAS, options);
|
||||
cacheMarkerIconResMd5Val(resIdVal, marker);
|
||||
Log.d("ADAS数据延时", "创建一个新 marker cost : " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)));
|
||||
return marker;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package com.mogo.module.common.drawer;
|
||||
|
||||
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_ADAS;
|
||||
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_MY_LOCATION;
|
||||
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_ADAS;
|
||||
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_DATA;
|
||||
import static java.lang.Math.PI;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
@@ -15,21 +21,17 @@ import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.R;
|
||||
import com.mogo.module.common.constants.AdasRecognizedType;
|
||||
import com.mogo.module.common.uploadintime.SnapshotLocationController;
|
||||
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter;
|
||||
import com.mogo.module.common.drawer.bean.SpeedData;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_ADAS;
|
||||
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_MY_LOCATION;
|
||||
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_ADAS;
|
||||
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_DATA;
|
||||
import static java.lang.Math.PI;
|
||||
|
||||
public
|
||||
/*
|
||||
* @author congtaowang
|
||||
@@ -47,6 +49,11 @@ class BaseDrawer {
|
||||
*/
|
||||
public static final int MAP_RENDER_FRAME_FREQUENCY = 30;
|
||||
|
||||
/**
|
||||
* 显示速度
|
||||
*/
|
||||
public static final int MSG_DISPLAY_SPEED = 11;
|
||||
|
||||
/**
|
||||
* 移动点的时间间隔
|
||||
*/
|
||||
@@ -59,7 +66,7 @@ class BaseDrawer {
|
||||
|
||||
protected final Context mContext;
|
||||
|
||||
private TextView mSpeedView;
|
||||
private static TextView mSpeedView;
|
||||
|
||||
public BaseDrawer() {
|
||||
mContext = AbsMogoApplication.getApp();
|
||||
@@ -78,6 +85,7 @@ class BaseDrawer {
|
||||
}
|
||||
|
||||
private static Handler mWorkThreadHandler;
|
||||
protected static Handler mRenderThreadHandler = null;
|
||||
|
||||
/**
|
||||
* 处理 marker 移除的线程
|
||||
@@ -106,6 +114,29 @@ class BaseDrawer {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (mRenderThreadHandler == null) {
|
||||
mRenderThreadHandler = new Handler(WorkThreadHandler.newInstance("render-thread-" + new Random().nextLong()).getLooper()) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == MSG_DISPLAY_SPEED) {
|
||||
if (msg.obj instanceof SpeedData) {
|
||||
showSpeed((SpeedData) msg.obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static void showSpeed(SpeedData speedData) {
|
||||
showSelfSpeed(speedData.getMarker()
|
||||
, speedData.getSpeed()
|
||||
, speedData.getUuid()
|
||||
, speedData.getType()
|
||||
, speedData.getHeading()
|
||||
, speedData.getIsVrMode());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,15 +176,15 @@ class BaseDrawer {
|
||||
* @param type {@link AdasRecognizedType}
|
||||
* @return render
|
||||
*/
|
||||
public boolean isRenderType(int type) {
|
||||
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;
|
||||
return recognizedType != AdasRecognizedType.classIdCar
|
||||
&& recognizedType != AdasRecognizedType.classIdMoto
|
||||
&& recognizedType != AdasRecognizedType.classIdBicycle
|
||||
&& recognizedType != AdasRecognizedType.classIdPerson
|
||||
&& recognizedType != AdasRecognizedType.classIdTrafficBus
|
||||
&& recognizedType != AdasRecognizedType.classIdTrafficTruck
|
||||
&& recognizedType != AdasRecognizedType.classIdUnKnow;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,8 +194,9 @@ class BaseDrawer {
|
||||
* @return showSpeed
|
||||
*/
|
||||
public boolean shouldShowSpeed(int type) {
|
||||
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom(type);
|
||||
return recognizedType != AdasRecognizedType.classIdPerson;
|
||||
return true; //todo 验证行人预警,对行人和自行车不做infoWindow过滤
|
||||
// AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom(type);
|
||||
// return recognizedType != AdasRecognizedType.classIdPerson;
|
||||
// &&recognizedType != AdasRecognizedType.classIdBicycle //todo Bicycle显示
|
||||
// && recognizedType != AdasRecognizedType.classIdMoto //todo moto显示
|
||||
}
|
||||
@@ -178,7 +210,8 @@ class BaseDrawer {
|
||||
public int getModelRes(int type) {
|
||||
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom(type);
|
||||
if (recognizedType == AdasRecognizedType.classIdCar) {
|
||||
return R.raw.othercar;
|
||||
// TODO 这里临时替换模型解决穿模现象
|
||||
return R.raw.tachexiaoche;
|
||||
} else if (recognizedType == AdasRecognizedType.classIdTrafficBus) {
|
||||
return R.raw.bus;
|
||||
} else if (recognizedType == AdasRecognizedType.classIdMoto) {
|
||||
@@ -192,14 +225,18 @@ class BaseDrawer {
|
||||
} else if (recognizedType == AdasRecognizedType.classIdBicycle) {
|
||||
return R.raw.zixingche;
|
||||
} else if (recognizedType == AdasRecognizedType.classIdTrafficTruck) {
|
||||
return R.raw.kache;
|
||||
// TODO 这里临时替换模型解决穿模现象
|
||||
return R.raw.daba;
|
||||
}
|
||||
return R.raw.people;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据速度、经纬度计算距离判断车辆颜色
|
||||
* 根据数据源判断车辆预警颜色
|
||||
*
|
||||
* @param speed 车速
|
||||
* @param lon 经度
|
||||
* @param lat 纬度
|
||||
* @return 实际车辆颜色
|
||||
*/
|
||||
protected String getModelRenderColor(int type, int fromType, int drawLevel) {
|
||||
@@ -220,6 +257,8 @@ class BaseDrawer {
|
||||
}
|
||||
}
|
||||
return Car3DModelColor.Normal.color;
|
||||
// todo 方案2
|
||||
// return Car3DTestModelColor.getTestModelColor(fromType, Waring_Normal);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,7 +269,7 @@ class BaseDrawer {
|
||||
protected double getCurSpeed() {
|
||||
double speed = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastSpeed();
|
||||
if (speed <= 0) {
|
||||
speed = SnapshotLocationController.getInstance().getCurSpeed();
|
||||
speed = SnapshotLocationDataCenter.getInstance().getCurSpeed();
|
||||
}
|
||||
return speed;
|
||||
}
|
||||
@@ -246,8 +285,8 @@ class BaseDrawer {
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat(),
|
||||
};
|
||||
if (coordinates[0] <= 0) {
|
||||
coordinates[0] = SnapshotLocationController.getInstance().getCurLon();
|
||||
coordinates[1] = SnapshotLocationController.getInstance().getCurLat();
|
||||
coordinates[0] = SnapshotLocationDataCenter.getInstance().getCurLon();
|
||||
coordinates[1] = SnapshotLocationDataCenter.getInstance().getCurLat();
|
||||
}
|
||||
return coordinates;
|
||||
}
|
||||
@@ -290,8 +329,7 @@ class BaseDrawer {
|
||||
* @param speed 是否显示速度
|
||||
* @param isVrMode 是否是vrMode
|
||||
*/
|
||||
public void showSelfSpeed(IMogoMarker mogoMarker, double speed, String uuid, int type, double heading, boolean isVrMode) {
|
||||
Log.d("EmArrow", "showSelf uuid : " + uuid + " speed : " + speed);
|
||||
public static void showSelfSpeed(IMogoMarker mogoMarker, double speed, String uuid, int type, double heading, boolean isVrMode) {
|
||||
if (mogoMarker == null || mogoMarker.isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
@@ -305,7 +343,8 @@ class BaseDrawer {
|
||||
return;
|
||||
}
|
||||
mogoMarker.setInfoWindowOffset(0, 20);
|
||||
String text = "speed : " + speedIntVal + "\n" + uuid + "\n" + "type : " + type + "\n" + "heading : " + heading;
|
||||
// String text = "speed : " + speedIntVal + "\n" + uuid + "\n" + "type : " + type + "\n" + "heading : " + heading;
|
||||
String text = uuid + " , " + (int) heading;
|
||||
mSpeedView.setText(text);
|
||||
mogoMarker.updateInfoWindowView(mSpeedView);
|
||||
}
|
||||
@@ -382,16 +421,18 @@ class BaseDrawer {
|
||||
/**
|
||||
* 使用系统时间或卫星时间计算出动画的运动时间,最小值45,防止两个点距离过近设置的最小动画执行时间
|
||||
*
|
||||
* @param lastSystemTime 上一个点系统时间,误差值
|
||||
* @param curSystemTime 当前点系统时间,误差值
|
||||
* @param lastSatelliteTime 上一个点SNTP时间,精确值
|
||||
* @param curSatelliteTime 当前点SNTP时间,精确值
|
||||
* @return 动画运动时间
|
||||
*/
|
||||
public long computeAnimDuration(long lastSystemTime, long curSystemTime, long lastSatelliteTime, long curSatelliteTime) {
|
||||
long systemTimeInterval = curSystemTime - lastSystemTime;
|
||||
long satelliteTimeInterval = curSatelliteTime - lastSatelliteTime;
|
||||
long interval = systemTimeInterval < satelliteTimeInterval || satelliteTimeInterval == 0 ? systemTimeInterval : satelliteTimeInterval;
|
||||
public long computeAnimDuration(long lastSatelliteTime, long curSatelliteTime) {
|
||||
if (lastSatelliteTime == 0 || curSatelliteTime == 0) {
|
||||
Log.d("ADAS动画数据", "卫星时间存在错误");
|
||||
return 45;
|
||||
}
|
||||
long interval = curSatelliteTime - lastSatelliteTime;
|
||||
Log.d("ADAS动画数据", "lastSatelliteTime : " + lastSatelliteTime +
|
||||
" ---- curSatelliteTime : " + curSatelliteTime + " ===== 插值 : " + interval);
|
||||
if (interval < 45) {
|
||||
interval = 45;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.mogo.module.common.drawer;
|
||||
|
||||
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_DATA;
|
||||
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -33,6 +35,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -70,20 +73,13 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上一帧数据的缓存
|
||||
*/
|
||||
protected static Map<String, IMogoMarker> mMarkersCaches = new ConcurrentHashMap<>();
|
||||
private static final Map<String, IMogoMarker> mMarkersCaches = new ConcurrentHashMap<>();
|
||||
|
||||
private final Map<String, SocketDownData.CloudRoadDataProto> mLastPositions = new ConcurrentHashMap<>();
|
||||
|
||||
private boolean mIsVrMode = false;
|
||||
|
||||
/**
|
||||
* 注册StatusDescriptor.VR_MODE类型,VR_MODE状态改变回调
|
||||
*
|
||||
@@ -96,15 +92,10 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
mChangeCarModeStatus = true;
|
||||
sendMessage(MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches);
|
||||
removeUselessMarker(mMarkersCaches);
|
||||
mMarkersCaches = new ConcurrentHashMap<>();
|
||||
mLastPositions.clear();
|
||||
AdasRecognizedResultDrawer.getInstance().notifyVrModeChanged(); //清除ADAS old marker data
|
||||
}
|
||||
|
||||
public boolean isVrMode() {
|
||||
return mIsVrMode;
|
||||
}
|
||||
|
||||
public boolean isChangeCarModeStatus() {
|
||||
return mChangeCarModeStatus;
|
||||
}
|
||||
@@ -148,7 +139,7 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
* @param data 自车周边数据
|
||||
*/
|
||||
public void renderSnapshotData(SocketDownData.LauncherSnapshotProto data) {
|
||||
|
||||
final long start = System.nanoTime();
|
||||
if (clear(data)) {
|
||||
return;
|
||||
}
|
||||
@@ -162,8 +153,8 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
|
||||
Map<String, IMogoMarker> newMarkersCaches = new ConcurrentHashMap<>(allDatumsList.size());
|
||||
List<SocketDownData.CloudRoadDataProto> newDiffSet = new ArrayList<>();
|
||||
|
||||
for (SocketDownData.CloudRoadDataProto cloudRoadData : allDatumsList) {
|
||||
|
||||
if (isUselessValue(cloudRoadData)) {
|
||||
continue;
|
||||
}
|
||||
@@ -171,16 +162,16 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
IMogoMarker marker = mMarkersCaches.remove(uniqueKey);
|
||||
if (marker != null && !marker.isDestroyed()) {
|
||||
updateCacheMarkerRes(marker, cloudRoadData);
|
||||
renderSnapshotOneFrame(true, marker, uniqueKey, cloudRoadData, newMarkersCaches);
|
||||
renderSnapshotOneFrame(marker, uniqueKey, cloudRoadData, newMarkersCaches);
|
||||
} else {
|
||||
newDiffSet.add(cloudRoadData);
|
||||
}
|
||||
}
|
||||
removeUselessMarker(mMarkersCaches);
|
||||
removeUselessLastRecord();
|
||||
|
||||
// 需要新增的 marker 数量
|
||||
int newDiffSetSize = newDiffSet.size();
|
||||
// 复用过期 marker
|
||||
if (newDiffSetSize > 0) {
|
||||
// 复用过后还需新增的 marker
|
||||
for (int i = 0; i < newDiffSetSize; i++) {
|
||||
SocketDownData.CloudRoadDataProto cloudRoadData = newDiffSet.get(i);
|
||||
String uniqueKey = cloudRoadData.getUuid();
|
||||
@@ -188,13 +179,14 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
if (marker == null) {
|
||||
continue;
|
||||
}
|
||||
renderSnapshotOneFrame(false, marker, uniqueKey, cloudRoadData, newMarkersCaches);
|
||||
renderSnapshotOneFrame(marker, uniqueKey, cloudRoadData, newMarkersCaches);
|
||||
}
|
||||
}
|
||||
sendMessage(MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches);
|
||||
mMarkersCaches.clear();
|
||||
mMarkersCaches = newMarkersCaches;
|
||||
|
||||
mMarkersCaches.putAll(newMarkersCaches);
|
||||
// 移除超时 marker
|
||||
delayRemoveUselessMarker();
|
||||
removeUselessLastRecord();
|
||||
Log.d("云端数据延时绘制", "render 接收数据 -> 处理结束 " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)) + "ms");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -218,6 +210,33 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
}
|
||||
}
|
||||
|
||||
private void delayRemoveUselessMarker() {
|
||||
if (mMarkersCaches.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
IMogoADASController adasControllerApi = MogoApisHandler.getInstance().getApis().getAdasControllerApi();
|
||||
if (TextUtils.isEmpty(adasControllerApi.getSatelliteTime())) {
|
||||
return;
|
||||
}
|
||||
Iterator<IMogoMarker> iterator = mMarkersCaches.values().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
IMogoMarker result = iterator.next();
|
||||
SocketDownData.CloudRoadDataProto proto = ((SocketDownData.CloudRoadDataProto) result.getObject());
|
||||
if(proto == null){ // 后续有业务数据在操作,更新数据,不做处理
|
||||
continue;
|
||||
}
|
||||
long internal = Long.parseLong(adasControllerApi.getSatelliteTime()) - proto.getSatelliteTime();
|
||||
Log.d("MogoArrow", "delayRemoveUselessMarker uuid : " + proto.getUuid()
|
||||
+ " localTime : " + adasControllerApi.getSatelliteTime()
|
||||
+ " originTime : " + proto.getSatelliteTime()
|
||||
+ " internal : " + internal);
|
||||
if (internal > 5000) {
|
||||
iterator.remove();
|
||||
result.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeUselessLastRecord() { // todo 最好重新设计一个数据结构,用于多线程数据过期失效的场景,参见redis数据过期
|
||||
if (mLastPositions.isEmpty()) {
|
||||
return;
|
||||
@@ -230,8 +249,8 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
Log.d("EmArrow", "removeUselessLastRecord size : " + mLastPositions.size());
|
||||
while (iterator.hasNext()) {
|
||||
SocketDownData.CloudRoadDataProto result = iterator.next();
|
||||
long internal = result.getSatelliteTime() - Long.parseLong(adasControllerApi.getSatelliteTime());
|
||||
if (internal > 300) {
|
||||
long internal = Long.parseLong(adasControllerApi.getSatelliteTime()) - result.getSatelliteTime();
|
||||
if (internal > 3000) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
@@ -247,7 +266,7 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
if (cloudRoadData == null) {
|
||||
return true;
|
||||
}
|
||||
if (!isRenderType(cloudRoadData.getType())) {
|
||||
if (nonRenderType(cloudRoadData.getType())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -261,49 +280,45 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
* @param cloudRoadData {@link SocketDownData.CloudRoadDataProto}
|
||||
* @param newSnapshotCaches 缓存数据
|
||||
*/
|
||||
private void renderSnapshotOneFrame(boolean useCache, IMogoMarker marker, String uniqueKey, SocketDownData.CloudRoadDataProto cloudRoadData, Map<String, IMogoMarker> newSnapshotCaches) {
|
||||
|
||||
Logger.d(TAG, "renderSnapshotOneFrame");
|
||||
final long start = System.currentTimeMillis();
|
||||
|
||||
private void renderSnapshotOneFrame(IMogoMarker marker, String uniqueKey, SocketDownData.CloudRoadDataProto cloudRoadData, Map<String, IMogoMarker> newSnapshotCaches) {
|
||||
final long start = System.nanoTime();
|
||||
SocketDownData.CloudRoadDataProto lastPosition = mLastPositions.remove(uniqueKey);
|
||||
|
||||
double lastLon = -1;
|
||||
double lastLat = -1;
|
||||
if (lastPosition != null) {
|
||||
lastLon = lastPosition.getWgslon();
|
||||
lastLat = lastPosition.getWgslat();
|
||||
}
|
||||
|
||||
double[] matchLonLat = getMatchLonLat(cloudRoadData.getUuid(), cloudRoadData.getWgslon(), cloudRoadData.getWgslat(), cloudRoadData.getHeading(), lastLon, lastLat);
|
||||
|
||||
SocketDownData.CloudRoadDataProto.Builder builder = cloudRoadData.toBuilder();
|
||||
builder.setWgslon(matchLonLat[0]);
|
||||
builder.setWgslat(matchLonLat[1]);
|
||||
|
||||
cloudRoadData = builder.build();
|
||||
// 道路吸附
|
||||
// double lastLon = -1;
|
||||
// double lastLat = -1;
|
||||
// if (lastPosition != null) {
|
||||
// lastLon = lastPosition.getWgslon();
|
||||
// lastLat = lastPosition.getWgslat();
|
||||
// }
|
||||
// double[] matchLonLat = getMatchLonLat(cloudRoadData.getUuid(), cloudRoadData.getWgslon(), cloudRoadData.getWgslat(), cloudRoadData.getHeading(), lastLon, lastLat);
|
||||
// SocketDownData.CloudRoadDataProto.Builder builder = cloudRoadData.toBuilder();
|
||||
// builder.setWgslon(matchLonLat[0]);
|
||||
// builder.setWgslat(matchLonLat[1]);
|
||||
// cloudRoadData = builder.build();
|
||||
|
||||
mLastPositions.put(uniqueKey, cloudRoadData);
|
||||
|
||||
if (useCache) {
|
||||
long interval = 45;
|
||||
if (lastPosition != null) {
|
||||
interval = computeAnimDuration(lastPosition.getSystemTime(), cloudRoadData.getSystemTime(), lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime());
|
||||
}
|
||||
final MogoLatLng point = new MogoLatLng(cloudRoadData.getWgslat(), cloudRoadData.getWgslon());
|
||||
long cost = System.currentTimeMillis() - start;
|
||||
final long intervalRef = interval - cost;
|
||||
marker.addDynamicAnchorPosition(point, (float) cloudRoadData.getHeading(), intervalRef);
|
||||
} else {
|
||||
marker.setRotateAngle(((float) cloudRoadData.getHeading()));
|
||||
marker.setPosition(cloudRoadData.getWgslat(), cloudRoadData.getWgslon());
|
||||
long interval = 45;
|
||||
if (lastPosition != null) {
|
||||
interval = computeAnimDuration(lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime());
|
||||
}
|
||||
newSnapshotCaches.put(uniqueKey, marker);
|
||||
final MogoLatLng point = new MogoLatLng(cloudRoadData.getWgslat(), cloudRoadData.getWgslon());
|
||||
long cost = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
|
||||
final long intervalRef = interval - cost;
|
||||
marker.addDynamicAnchorPosition(point, (float) cloudRoadData.getHeading(), intervalRef);
|
||||
marker.setAnchorColor(getModelRenderColor(cloudRoadData.getType(), cloudRoadData.getFromType(), 1));
|
||||
|
||||
if (shouldShowSpeed(cloudRoadData.getType())) {
|
||||
showSelfSpeed(marker, cloudRoadData.getSpeed(), cloudRoadData.getUuid(), cloudRoadData.getType(), cloudRoadData.getHeading(), MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
|
||||
}
|
||||
newSnapshotCaches.put(uniqueKey, marker);
|
||||
// if (shouldShowSpeed(cloudRoadData.getType())) {
|
||||
// Message msg = mRenderThreadHandler.obtainMessage();
|
||||
// msg.obj = new SpeedData(marker
|
||||
// , cloudRoadData.getSpeed()
|
||||
// , cloudRoadData.getUuid()
|
||||
// , cloudRoadData.getType()
|
||||
// , cloudRoadData.getHeading()
|
||||
// , MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
|
||||
// msg.what = MSG_DISPLAY_SPEED;
|
||||
// msg.sendToTarget();
|
||||
// }
|
||||
Log.d("云端数据延时", "render 刷新一台车 cost : " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -313,35 +328,10 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
* @param out 输出集合
|
||||
*/
|
||||
private void prepareData(List<SocketDownData.CloudRoadDataProto> in, List<SocketDownData.CloudRoadDataProto> out) {
|
||||
filterData(in);
|
||||
// foreCastPoint(in, out);
|
||||
out.addAll(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* vr 模式下显示合并数据,否则只显示 mogo 车辆上报的数据
|
||||
* 展示融合数据,不包括自车定位数据和adas识别数据
|
||||
*
|
||||
* @param data 道路数据集合
|
||||
*/
|
||||
private void filterData(List<SocketDownData.CloudRoadDataProto> data) {
|
||||
if (data == null || data.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
return;
|
||||
}
|
||||
List<SocketDownData.CloudRoadDataProto> newList = new ArrayList<>();
|
||||
for (SocketDownData.CloudRoadDataProto cloudRoadData : data) {
|
||||
if (cloudRoadData.getFromType() != SocketDownDataHelper.FROM_MY_LOCATION) {
|
||||
continue;
|
||||
}
|
||||
newList.add(cloudRoadData);
|
||||
}
|
||||
data.clear();
|
||||
data.addAll(newList);
|
||||
}
|
||||
|
||||
private final static String FORECAST = "snapshotForecast";
|
||||
|
||||
/**
|
||||
@@ -402,12 +392,13 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
* @return {@link IMogoMarker}
|
||||
*/
|
||||
public IMogoMarker drawSnapshotDataMarker(SocketDownData.CloudRoadDataProto data) {
|
||||
long start = System.nanoTime();
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.owner(getDataTypes(data.getFromType()))
|
||||
.owner(TYPE_MARKER_CLOUD_DATA)
|
||||
.anchor(0.5f, 0.5f)
|
||||
.rotate((float) data.getHeading())
|
||||
.object(data)
|
||||
@@ -428,13 +419,13 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
options.icon(view);
|
||||
resIdVal = view.getId() + "";
|
||||
}
|
||||
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(getDataTypes(data.getFromType()), options);
|
||||
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(TYPE_MARKER_CLOUD_DATA, options);
|
||||
cacheMarkerIconResMd5Val(resIdVal, marker);
|
||||
|
||||
if (!TextUtils.isEmpty(data.getSn())) {
|
||||
bindClickListener(marker);
|
||||
}
|
||||
|
||||
Log.d("云端数据延时", "创建一个新 marker cost : " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)));
|
||||
return marker;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,43 +74,36 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
|
||||
|
||||
|
||||
/**
|
||||
* 绘制行人和二轮车,前方和左右
|
||||
* 识别物移动
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
public void renderWarnData(V2XWarningEntity data) {
|
||||
MarkerLocation location = new MarkerLocation();
|
||||
location.setLat(data.getDirection() == 1 ? data.getStopLines().get(0).lat : data.getLat());
|
||||
location.setLon(data.getDirection() == 1 ? data.getStopLines().get(0).lon : data.getLon());
|
||||
location.setLat(data.getLat());
|
||||
location.setLon(data.getLon());
|
||||
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
markerShowEntity.setMarkerLocation(location);
|
||||
markerShowEntity.setMarkerType(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
IMogoMarker marker = drawMarker(markerShowEntity, modeResType(data.getType()));
|
||||
//识别物
|
||||
marker.addDynamicAnchorPosition(new MogoLatLng(
|
||||
data.getDirection() == 1 ? data.getStopLines().get(1).lat : data.getCollisionLat(),
|
||||
data.getDirection() == 1 ? data.getStopLines().get(1).lon : data.getCollisionLon()), (float) data.getHeading(), 5000);
|
||||
//移动完成以后,3s后消失
|
||||
marker.addDynamicAnchorPosition(new MogoLatLng(data.getCollisionLat(), data.getCollisionLon()), (float) data.getHeading(), (long) (data.getShowTime() * 1000));
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
marker.remove();
|
||||
}, data.getShowTime());
|
||||
}, data.getShowTime() * 1000);
|
||||
|
||||
}
|
||||
|
||||
//根据识别物类型 (行人0/自行车1/摩托车2/小汽车3/公交车4)获取3D模型(对应查看getModelRes)
|
||||
//根据识别物类型 (行人1/自行车2/摩托车4/骑行车辆11)获取3D模型(对应查看getModelRes)
|
||||
private int modeResType(int dataType) {
|
||||
switch (dataType) {
|
||||
case 0:
|
||||
return 1;
|
||||
case 1:
|
||||
return 2;
|
||||
case 11:
|
||||
return 1;
|
||||
case 2:
|
||||
return 4;
|
||||
case 3:
|
||||
return 3;
|
||||
return 2;
|
||||
case 4:
|
||||
return 6;
|
||||
return 4;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -181,8 +174,6 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
|
||||
markerShowEntity.setMarkerLocation(location);
|
||||
markerShowEntity.setMarkerType(TYPE_MARKER_CLOUD_STOP_LINE_DATA);
|
||||
IMogoMarker marker = drawStopLineMarker(markerShowEntity);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.mogo.module.common.drawer.bean;
|
||||
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
|
||||
/**
|
||||
* 速度显示对象
|
||||
*/
|
||||
public class SpeedData {
|
||||
|
||||
public IMogoMarker marker;
|
||||
public double speed;
|
||||
public String uuid;
|
||||
public int type;
|
||||
public double heading;
|
||||
public boolean isVrMode;
|
||||
|
||||
public SpeedData(IMogoMarker marker, double speed, String uuid, int type, double heading, boolean isVrMode) {
|
||||
this.marker = marker;
|
||||
this.speed = speed;
|
||||
this.uuid = uuid;
|
||||
this.type = type;
|
||||
this.heading = heading;
|
||||
this.isVrMode = isVrMode;
|
||||
}
|
||||
|
||||
public IMogoMarker getMarker() {
|
||||
return marker;
|
||||
}
|
||||
|
||||
public void setMarker(IMogoMarker marker) {
|
||||
this.marker = marker;
|
||||
}
|
||||
|
||||
public double getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public void setSpeed(double speed) {
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public double getHeading() {
|
||||
return heading;
|
||||
}
|
||||
|
||||
public void setHeading(double heading) {
|
||||
this.heading = heading;
|
||||
}
|
||||
|
||||
public boolean getIsVrMode() {
|
||||
return isVrMode;
|
||||
}
|
||||
|
||||
public void setIsVrMode(boolean isVrMode) {
|
||||
this.isVrMode = isVrMode;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
*/
|
||||
public class V2XWarningEntity implements Serializable {
|
||||
|
||||
//事件类型 行人0/自行车1/摩托车2/小汽车3/公交车4
|
||||
//事件类型 行人1/自行车2/摩托车4/骑行车辆11
|
||||
private int type;
|
||||
//目标物位置
|
||||
private double lat;
|
||||
|
||||
BIN
modules/mogo-module-common/src/main/res/raw/daba.n3d
Normal file
BIN
modules/mogo-module-common/src/main/res/raw/daba.n3d
Normal file
Binary file not shown.
Binary file not shown.
BIN
modules/mogo-module-common/src/main/res/raw/tachexiaoche.n3d
Normal file
BIN
modules/mogo-module-common/src/main/res/raw/tachexiaoche.n3d
Normal file
Binary file not shown.
@@ -3,8 +3,8 @@
|
||||
<dimen name="dp_32">42px</dimen>
|
||||
<dimen name="module_v2n_tip_width">628px</dimen>
|
||||
<dimen name="module_v2n_tip_height">188px</dimen>
|
||||
<dimen name="module_v2n_tip_text_width">106px</dimen>
|
||||
<dimen name="module_v2n_tip_text_margin_right">52px</dimen>
|
||||
<dimen name="module_v2n_tip_text_width">120px</dimen>
|
||||
<dimen name="module_v2n_tip_text_margin_right">26px</dimen>
|
||||
<dimen name="module_v2n_image_margin_left">37px</dimen>
|
||||
<dimen name="module_v2x_brake_tip_width">435px</dimen>
|
||||
<dimen name="module_v2x_brake_tip_height">186px</dimen>
|
||||
|
||||
@@ -49,6 +49,7 @@ import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.map.uicontroller.VisualAngleMode;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.constants.DataTypes;
|
||||
import com.mogo.module.common.dialog.WMDialog;
|
||||
import com.mogo.module.common.glide.SkinAbleBitmapTarget;
|
||||
import com.mogo.module.common.map.CustomNaviInterrupter;
|
||||
@@ -68,6 +69,7 @@ import com.mogo.module.extensions.utils.NoMapTopViewShaderHelper;
|
||||
import com.mogo.module.extensions.utils.TopViewAnimHelper;
|
||||
import com.mogo.module.extensions.utils.TopViewNoLinkageAnimHelper;
|
||||
import com.mogo.module.extensions.view.ArcView;
|
||||
import com.mogo.module.service.receiver.MogoReceiver;
|
||||
import com.mogo.module.share.manager.ServiceApisManager;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.analytics.IMogoAnalytics;
|
||||
@@ -97,6 +99,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import static android.content.Intent.ACTION_VIEW;
|
||||
import static com.mogo.module.common.utils.SPConst.getSPGuideRecord;
|
||||
import static com.mogo.module.common.utils.SPConst.getSpGuide;
|
||||
import static com.mogo.module.extensions.ExtensionsModuleConst.TYPE_ENTRANCE;
|
||||
@@ -367,6 +370,16 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
|
||||
flSpeed = (FrameLayout) findViewById(R.id.fl_speed);
|
||||
mouduleArc = (ArcView) findViewById(R.id.moudule_arc);
|
||||
if (DebugConfig.isDebug()) {
|
||||
mouduleArc.setLongClickable(true);
|
||||
mouduleArc.setOnLongClickListener(v -> {
|
||||
Log.d(TAG,"长按显示状态工具栏");
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("oper", 52);
|
||||
MogoApisHandler.getInstance().getApis().getIntentManagerApi().invoke(MogoReceiver.ACTION_MOCK, intent);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
clTrafficLight = (ConstraintLayout) findViewById(R.id.cl_traffic_light);
|
||||
tvYellow = (TextView) findViewById(R.id.tv_yellow);
|
||||
tvRed = (TextView) findViewById(R.id.tv_red);
|
||||
@@ -391,53 +404,53 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
private Group groupFix;
|
||||
|
||||
private void enterVrMode() {
|
||||
tvEnterVrMode.setVisibility(View.GONE);
|
||||
mMove2CurrentLocation.setVisibility(View.GONE);
|
||||
mUploadRoadCondition.setVisibility(View.GONE);
|
||||
mWeatherContainer.setVisibility(View.GONE);
|
||||
mMsgContainer.setVisibility(View.GONE);
|
||||
groupUserHead.setVisibility(View.GONE);
|
||||
seekHelpGroup.setVisibility(View.GONE);
|
||||
tvEnterVrMode.setVisibility(View.GONE);
|
||||
mMove2CurrentLocation.setVisibility(View.GONE);
|
||||
mUploadRoadCondition.setVisibility(View.GONE);
|
||||
mWeatherContainer.setVisibility(View.GONE);
|
||||
mMsgContainer.setVisibility(View.GONE);
|
||||
groupUserHead.setVisibility(View.GONE);
|
||||
seekHelpGroup.setVisibility(View.GONE);
|
||||
// tvExitVrMode.setVisibility(View.VISIBLE);
|
||||
TopViewAnimHelper.getInstance().enterVrMode();
|
||||
TopViewNoLinkageAnimHelper.getInstance().enterVrMode();
|
||||
mNaviInfo = vrModeNavInfoView;
|
||||
adasNoticeHelper.enterVrMode();
|
||||
mCameraLiveNoticeHelper.enterVrMode();
|
||||
TopViewAnimHelper.getInstance().enterVrMode();
|
||||
TopViewNoLinkageAnimHelper.getInstance().enterVrMode();
|
||||
mNaviInfo = vrModeNavInfoView;
|
||||
adasNoticeHelper.enterVrMode();
|
||||
mCameraLiveNoticeHelper.enterVrMode();
|
||||
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi()
|
||||
.registerCarLocationChangedListener(TAG, this);
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi()
|
||||
.registerCarLocationChangedListener(TAG, this);
|
||||
|
||||
localIsVrMode = true;
|
||||
flSpeed.setVisibility(View.VISIBLE);
|
||||
mSwitchMapModeLayout.setVisibility(View.VISIBLE);
|
||||
mApis.getV2XListenerManager().changeTipWindowStatusForListener(ACTION_V2X_REMOVE_TIP_WINDOW);
|
||||
localIsVrMode = true;
|
||||
flSpeed.setVisibility(View.VISIBLE);
|
||||
mSwitchMapModeLayout.setVisibility(View.VISIBLE);
|
||||
mApis.getV2XListenerManager().changeTipWindowStatusForListener(ACTION_V2X_REMOVE_TIP_WINDOW);
|
||||
}
|
||||
|
||||
private void exitVrMode() {
|
||||
EntranceViewHolder.getInstance().forceHideNoticeView();
|
||||
tvEnterVrMode.setVisibility(View.VISIBLE);
|
||||
mMove2CurrentLocation.setVisibility(View.VISIBLE);
|
||||
mUploadRoadCondition.setVisibility(View.VISIBLE);
|
||||
groupUserHead.setVisibility(View.VISIBLE);
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isSeekHelping()) {
|
||||
seekHelpGroup.setVisibility(View.VISIBLE);
|
||||
}
|
||||
EntranceViewHolder.getInstance().forceHideNoticeView();
|
||||
tvEnterVrMode.setVisibility(View.VISIBLE);
|
||||
mMove2CurrentLocation.setVisibility(View.VISIBLE);
|
||||
mUploadRoadCondition.setVisibility(View.VISIBLE);
|
||||
groupUserHead.setVisibility(View.VISIBLE);
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isSeekHelping()) {
|
||||
seekHelpGroup.setVisibility(View.VISIBLE);
|
||||
}
|
||||
// mWeatherContainer.setVisibility(View.VISIBLE);
|
||||
// mMsgContainer.setVisibility(View.VISIBLE);
|
||||
|
||||
// tvExitVrMode.setVisibility(View.GONE);
|
||||
TopViewAnimHelper.getInstance().exitVrMode();
|
||||
TopViewNoLinkageAnimHelper.getInstance().exitVrMode();
|
||||
mNaviInfo = animNavInfoView;
|
||||
adasNoticeHelper.exitVrMode();
|
||||
mCameraLiveNoticeHelper.exitVrMode();
|
||||
TopViewAnimHelper.getInstance().exitVrMode();
|
||||
TopViewNoLinkageAnimHelper.getInstance().exitVrMode();
|
||||
mNaviInfo = animNavInfoView;
|
||||
adasNoticeHelper.exitVrMode();
|
||||
mCameraLiveNoticeHelper.exitVrMode();
|
||||
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().unregisterMogoLocationListener(TAG);
|
||||
localIsVrMode = false;
|
||||
flSpeed.setVisibility(View.GONE);
|
||||
mSwitchMapModeLayout.setVisibility(View.GONE);
|
||||
clTrafficLight.setVisibility(View.GONE);
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().unregisterMogoLocationListener(TAG);
|
||||
localIsVrMode = false;
|
||||
flSpeed.setVisibility(View.GONE);
|
||||
mSwitchMapModeLayout.setVisibility(View.GONE);
|
||||
clTrafficLight.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void debugCrashWarn() {
|
||||
@@ -728,7 +741,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
// 进入鹰眼模式,设置手势缩放地图失效
|
||||
Logger.d(TAG, "进入vr模式");
|
||||
mMApUIController.changeMapMode(EnumMapUI.Type_VR);
|
||||
MogoApisHandler.getInstance().getApis().getStatusManagerApi().setVrMode( TAG, true );
|
||||
MogoApisHandler.getInstance().getApis().getStatusManagerApi().setVrMode(TAG, true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -963,7 +976,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
}
|
||||
}
|
||||
|
||||
private int[] heights = new int[]{100, 200, 300};
|
||||
private final int[] heights = new int[]{100, 200, 300};
|
||||
private int currentHeight;
|
||||
|
||||
private void debugTopView() {
|
||||
@@ -1363,7 +1376,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
.getMapUIController().changeMapVisualAngle(VisualAngleMode.MODE_MEDIUM_SIGHT, null);
|
||||
mSwitchText.setText(R.string.module_map_model_normal);
|
||||
} else if (MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().getCurrentMapVisualAngle().isMediumSight()) {
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(AbsMogoApplication.getApp()).inVisibleAllMarkers();
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(AbsMogoApplication.getApp()).inVisibleWithoutMarkers(DataTypes.TYPE_MARKER_ADAS);
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi()
|
||||
.getMapUIController().changeMapVisualAngle(VisualAngleMode.MODE_LONG_SIGHT, null);
|
||||
mSwitchText.setText(R.string.module_map_model_faster);
|
||||
|
||||
@@ -35,7 +35,7 @@ import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.common.entity.MarkerResponse;
|
||||
import com.mogo.module.common.map.MapCenterPointStrategy;
|
||||
import com.mogo.module.common.map.Scene;
|
||||
import com.mogo.module.common.uploadintime.SnapshotLocationController;
|
||||
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter;
|
||||
import com.mogo.module.service.autopilot.AutoPilotRemoteController;
|
||||
import com.mogo.module.service.handler.MainLooperHandler;
|
||||
import com.mogo.module.service.handler.RefreshWorkThreadHandler;
|
||||
@@ -1003,7 +1003,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
e.printStackTrace();
|
||||
}
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( data );
|
||||
SnapshotLocationController.getInstance().syncAdasLocationInfo( data );
|
||||
SnapshotLocationDataCenter.getInstance().syncAdasLocationInfo( data );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.module.common.uploadintime.SnapshotLocationController;
|
||||
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.mogo.module.service.carinfo.CarStateInfo;
|
||||
@@ -73,7 +73,7 @@ class ADASStatusIntentHandler implements IntentHandler {
|
||||
data.putOpt( "acceleration", stateInfo.getValues().getAcceleration() );
|
||||
data.putOpt( "yawRate", stateInfo.getValues().getYaw_rate() );
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( data );
|
||||
SnapshotLocationController.getInstance().syncAdasLocationInfo( data );
|
||||
SnapshotLocationDataCenter.getInstance().syncAdasLocationInfo( data );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.constants.DataTypes;
|
||||
import com.mogo.module.common.dialog.WMDialog;
|
||||
import com.mogo.module.common.drawer.SnapshotSetDataDrawer;
|
||||
import com.mogo.module.common.uploadintime.SnapshotLocationController;
|
||||
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.R;
|
||||
import com.mogo.module.service.status.EnvStatusManager;
|
||||
@@ -341,7 +341,7 @@ public class MockIntentHandler implements IntentHandler {
|
||||
MarkerServiceHandler.getApis().getRefreshStrategyControllerApi().restartAutoRefreshAtTime(duration);
|
||||
IMogoMarker marker = MarkerServiceHandler.getMarkerManager().addMarker(TAG, options);
|
||||
MarkerServiceHandler.getMogoStatusManager().setUserInteractionStatus(TAG, true, false);
|
||||
if(!MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode()){
|
||||
if (!MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode()) {
|
||||
MarkerServiceHandler.getMapUIController().moveToCenter(mogoLatLngs.get(0));
|
||||
}
|
||||
WorkThreadHandler.getInstance().post(() -> marker.startSmooth(mogoLatLngs, duration));
|
||||
@@ -652,7 +652,7 @@ public class MockIntentHandler implements IntentHandler {
|
||||
String carsLine = roadSizeBr.readLine();
|
||||
SocketDownData.LauncherSnapshotProto.Builder data = SocketDownData.LauncherSnapshotProto.newBuilder();
|
||||
List<SocketDownData.CloudRoadDataProto> allList = GsonUtil.arrayFromJson(carsLine, SocketDownData.CloudRoadDataProto.class);
|
||||
if(allList == null || allList.size() == 0){
|
||||
if (allList == null || allList.size() == 0) {
|
||||
return;
|
||||
}
|
||||
for (SocketDownData.CloudRoadDataProto cloudRoadData : allList) {
|
||||
@@ -852,9 +852,9 @@ public class MockIntentHandler implements IntentHandler {
|
||||
//改变rtk定位数据,触发自车移动
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map(jo);
|
||||
Log.i("mock-timer-loc-map", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
SnapshotLocationController.getInstance().syncAdasLocationInfo(jo);
|
||||
SnapshotLocationDataCenter.getInstance().syncAdasLocationInfo(jo);
|
||||
Log.i("mock-timer-loc", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
Log.i("mock-timer-loc-info",jo.toString());
|
||||
Log.i("mock-timer-loc-info", jo.toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -917,10 +917,7 @@ public class MockIntentHandler implements IntentHandler {
|
||||
}
|
||||
}
|
||||
|
||||
AdasRec adasRec = new AdasRec();
|
||||
adasRec.models = allList;
|
||||
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockAdasRecognized(GsonUtil.jsonFromObject(adasRec));
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockAdasRecognized(allList);
|
||||
Log.i("mock-timer-adas", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
return true;
|
||||
}
|
||||
@@ -947,16 +944,9 @@ public class MockIntentHandler implements IntentHandler {
|
||||
}
|
||||
}
|
||||
|
||||
AdasRec adasRec = new AdasRec();
|
||||
adasRec.models = allList;
|
||||
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockAdasRecognized(GsonUtil.jsonFromObject(adasRec));
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockAdasRecognized(allList);
|
||||
Log.i("mock-timer-adas", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class AdasRec {
|
||||
public String action = "view";
|
||||
public List<ADASRecognizedResult> models;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import android.os.Bundle;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.uploadintime.SnapshotLocationController;
|
||||
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter;
|
||||
import com.mogo.service.locationinfo.CloudLocationInfo;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
@@ -74,7 +74,7 @@ public class MogoRTKLocation {
|
||||
cloudLocationInfo.setSystemTime(System.currentTimeMillis());
|
||||
cloudLocationInfo.setTileId(String.valueOf(MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController()
|
||||
.getTileId(location.getLongitude(), location.getLatitude())));
|
||||
SnapshotLocationController.getInstance().syncLocationInfo(cloudLocationInfo);
|
||||
SnapshotLocationDataCenter.getInstance().syncLocationInfo(cloudLocationInfo);
|
||||
}
|
||||
} else {
|
||||
Logger.e(TAG, "location == null");
|
||||
|
||||
@@ -2,8 +2,6 @@ package com.mogo.module.service.marker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -17,6 +15,7 @@ import com.mogo.map.marker.IMogoMarkerManager;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.api.CallChatApi;
|
||||
import com.mogo.module.common.drawer.AdasRecognizedResultDrawer;
|
||||
import com.mogo.module.common.drawer.MarkerDrawer;
|
||||
@@ -43,12 +42,12 @@ import com.mogo.realtime.api.MoGoAiCloudRealTime;
|
||||
import com.mogo.realtime.socket.IMogoCloudOnMsgListener;
|
||||
import com.mogo.service.adas.IMogoADASControlStatusChangedListener;
|
||||
import com.mogo.service.adas.entity.ADASRecognizedResult;
|
||||
import com.mogo.service.connection.IMogoLifecycleListener;
|
||||
import com.mogo.service.module.IMogoBizActionDoneListener;
|
||||
import com.mogo.utils.ResourcesHelper;
|
||||
import com.mogo.utils.ThreadPoolService;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.ViewUtils;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.carchattingprovider.ICallChatResponse;
|
||||
|
||||
@@ -147,19 +146,38 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
MoGoAiCloudRealTime.registerOnMsgListener(new IMogoCloudOnMsgListener() {
|
||||
@Override
|
||||
public void onMsgSend(long id) {
|
||||
DebugConfig.setStatus(DebugConfig.sDownloadLink, true);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMsgReceived(SocketDownData.LauncherSnapshotProto mogoSnapshotSetData) {
|
||||
DebugConfig.setStatus(DebugConfig.sDownloadSnapshot, true);
|
||||
SnapshotSetDataDrawer.getInstance().renderSnapshotData(mogoSnapshotSetData);
|
||||
// SnapshotSetDataDrawer.getInstance().renderSnapshotData(mogoSnapshotSetData);
|
||||
// Message msg = mSnapshotHandler.obtainMessage();
|
||||
// msg.obj = mogoSnapshotSetData;
|
||||
// msg.what = MSG_SNAPSHOT;
|
||||
// msg.sendToTarget();
|
||||
}
|
||||
});
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getSocketManagerApi(context)
|
||||
.registerLifecycleListener(10020, new IMogoLifecycleListener() {
|
||||
@Override
|
||||
public void onConnectFailure() {
|
||||
DebugConfig.setStatus(DebugConfig.sDownloadLink, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectSuccess() {
|
||||
DebugConfig.setStatus(DebugConfig.sDownloadLink, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectLost() {
|
||||
DebugConfig.setStatus(DebugConfig.sDownloadLink, false);
|
||||
}
|
||||
});
|
||||
|
||||
// adas 每隔一定频率传递过来的数据
|
||||
MarkerServiceHandler.getApis().getAdasControllerApi().addAdasRecognizedDataCallback(resultList -> {
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.graphics.Color;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
@@ -14,6 +15,9 @@ 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 com.mogo.utils.NetworkUtils;
|
||||
|
||||
import static com.mogo.utils.CommonUtils.getVersionName;
|
||||
|
||||
|
||||
/*
|
||||
@@ -65,13 +69,16 @@ public class EnvStatusManager {
|
||||
|
||||
private void renderStatus() {
|
||||
String[] sStatusName = {
|
||||
"定位",
|
||||
"近景",
|
||||
"下发",
|
||||
"AUTO",
|
||||
"长链",
|
||||
"工控机定位",
|
||||
"ADAS近景感知",
|
||||
"云端远景感知",
|
||||
"自动驾驶状态",
|
||||
"socket长链",
|
||||
"经度",
|
||||
"纬度"
|
||||
"纬度",
|
||||
"网络状态",
|
||||
"App版本",
|
||||
"Map版本"
|
||||
};
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int i = 0; i < sStatusName.length; i++) {
|
||||
@@ -80,6 +87,15 @@ public class EnvStatusManager {
|
||||
stringBuilder.append(DebugConfig.getAutoPilotStatus()).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 {
|
||||
stringBuilder.append("true".equals(DebugConfig.getStatus(i, true)) ? "正常" : "异常").append("\n");
|
||||
}
|
||||
@@ -97,7 +113,10 @@ public class EnvStatusManager {
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
@@ -13,7 +13,7 @@ import com.mogo.cloud.socket.entity.SocketDownData;
|
||||
import com.mogo.commons.data.BaseData;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.uploadintime.SnapshotLocationController;
|
||||
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.network.TimeDelayApiService;
|
||||
import com.mogo.module.service.network.bean.MockSocketReceiverData;
|
||||
@@ -100,7 +100,7 @@ public class TimeDelayUploadManager implements IMogoOnMessageListener<MockSocket
|
||||
e.printStackTrace();
|
||||
}
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map(jo);
|
||||
SnapshotLocationController.getInstance().syncAdasLocationInfo(jo);
|
||||
SnapshotLocationDataCenter.getInstance().syncAdasLocationInfo(jo);
|
||||
mockHandler.sendEmptyMessageDelayed(MOCK_MSG, 50);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +1,41 @@
|
||||
package com.mogo.module.small.map;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.location.Location;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.thread.CancelableCountDownLatch;
|
||||
import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.CameraUpdate;
|
||||
import com.amap.api.maps.CameraUpdateFactory;
|
||||
import com.amap.api.maps.TextureMapView;
|
||||
import com.amap.api.maps.UiSettings;
|
||||
import com.amap.api.maps.model.BitmapDescriptorFactory;
|
||||
import com.amap.api.maps.model.CameraPosition;
|
||||
import com.amap.api.maps.model.CustomMapStyleOptions;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.amap.api.maps.model.LatLngBounds;
|
||||
import com.amap.api.maps.model.Marker;
|
||||
import com.amap.api.maps.model.MarkerOptions;
|
||||
import com.amap.api.maps.model.Polyline;
|
||||
import com.amap.api.maps.model.PolylineOptions;
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.amap.api.navi.AMapNavi;
|
||||
import com.amap.api.navi.AMapNaviView;
|
||||
import com.amap.api.navi.AMapNaviViewOptions;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.view.RoundLayout;
|
||||
import com.mogo.module.small.map.animation.DirectionRotateAnimation;
|
||||
import com.mogo.module.small.map.utils.MapAssetStyleUtils;
|
||||
import com.mogo.module.small.map.view.ISmallMapDirectionView;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.List;
|
||||
|
||||
import ch.hsr.geohash.GeoHash;
|
||||
|
||||
/**
|
||||
* 小地图的方向View
|
||||
*
|
||||
@@ -55,17 +50,14 @@ public class SmallMapDirectionView
|
||||
public static final String MODULE_NAME = "SmallMap";
|
||||
|
||||
private RoundLayout rlSmallMapBorder;
|
||||
private TextureMapView mAMapNaviView;
|
||||
private AMap mAMap;
|
||||
private Marker mCarMarker;
|
||||
private Marker mStartMarker;
|
||||
private Marker mEndMarker;
|
||||
private ImageView mIvMapBorder;
|
||||
private DirectionRotateAnimation mRotateAnimation;
|
||||
private int lastAngle = 0;
|
||||
|
||||
private int zoomLevel = 13;
|
||||
private List<LatLng> mCoordinatesLatLng = new ArrayList<>();
|
||||
private List<MogoLatLng> mCoordinatesLatLngCurrent = new ArrayList<>();
|
||||
private Polyline mPolyline;
|
||||
private CameraUpdate mCameraUpdate;
|
||||
private AMapNaviView mAMapNaviView;
|
||||
private AMap mAMap;
|
||||
private AMapNavi mAMapNavi;
|
||||
private int zoomLevel = 15;
|
||||
|
||||
public SmallMapDirectionView(Context context) {
|
||||
this(context, null);
|
||||
@@ -85,11 +77,15 @@ public class SmallMapDirectionView
|
||||
}
|
||||
|
||||
private void initView(Context context) {
|
||||
mRotateAnimation = new DirectionRotateAnimation(context, null);
|
||||
|
||||
LayoutInflater.from(context).inflate(R.layout.module_small_map_view, this);
|
||||
|
||||
mAMapNaviView = AbsMogoApplication.getMapNaviView();
|
||||
rlSmallMapBorder = findViewById(R.id.rlSmallMapBorder);
|
||||
rlSmallMapBorder.addView(mAMapNaviView);
|
||||
mIvMapBorder = findViewById(R.id.ivMapBorder);
|
||||
|
||||
|
||||
initAMapView();
|
||||
|
||||
@@ -122,7 +118,10 @@ public class SmallMapDirectionView
|
||||
}
|
||||
|
||||
private void initAMapView() {
|
||||
mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
||||
// 车头朝上
|
||||
mAMapNaviView.setNaviMode(AMapNaviView.CAR_UP_MODE);
|
||||
// 设置电子眼所在路线的可见性
|
||||
mAMapNaviView.setRouteOverlayVisible(false);
|
||||
mAMap = mAMapNaviView.getMap();
|
||||
// 关闭地图文字标注
|
||||
mAMap.showMapText(false);
|
||||
@@ -130,15 +129,25 @@ public class SmallMapDirectionView
|
||||
mAMap.setMapType(AMap.MAP_TYPE_NIGHT);
|
||||
// 关闭显示实时路况图层,aMap是地图控制器对象。
|
||||
mAMap.setTrafficEnabled(false);
|
||||
mAMap.setOnCameraChangeListener(new AMap.OnCameraChangeListener() {
|
||||
@Override
|
||||
public void onCameraChange(CameraPosition cameraPosition) {
|
||||
if (cameraPosition != null) {
|
||||
//Log.w("onCameraChange", "cameraPosition=" + cameraPosition.bearing);
|
||||
changeAngle((int) cameraPosition.bearing);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChangeFinish(CameraPosition cameraPosition) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
mAMapNavi = AMapNavi.getInstance(getContext());
|
||||
//使用外部GPS数据
|
||||
mAMapNavi.setIsUseExtraGPSData(true);
|
||||
|
||||
// 设置 锚点 图标
|
||||
mCarMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_my_location_logo))
|
||||
.anchor(0.5f, 0.5f));
|
||||
mStartMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_start)));
|
||||
mEndMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_end)));
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
@@ -154,7 +163,8 @@ public class SmallMapDirectionView
|
||||
);
|
||||
|
||||
//设置希望展示的地图缩放级别
|
||||
mAMap.moveCamera(mCameraUpdate);
|
||||
CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
||||
mAMap.moveCamera(cameraUpdate);
|
||||
}).start();
|
||||
|
||||
// 设置地图的样式
|
||||
@@ -164,6 +174,70 @@ public class SmallMapDirectionView
|
||||
uiSettings.setMyLocationButtonEnabled(false); // 显示默认的定位按钮
|
||||
uiSettings.setLogoBottomMargin(-150); //设置Logo下边界距离屏幕底部的边距,设置为负值即可
|
||||
|
||||
// 导航地图
|
||||
AMapNaviViewOptions options = mAMapNaviView.getViewOptions();
|
||||
//设置导航界面UI是否显示。
|
||||
if (options != null) {
|
||||
// 设置是否开启自动黑夜模式切换,默认为false,不自动切换
|
||||
options.setAutoNaviViewNightMode(false);
|
||||
// 设置6秒后是否自动锁车
|
||||
options.setAutoLockCar(true);
|
||||
// 设置路线上的摄像头气泡是否显示
|
||||
options.setCameraBubbleShow(false);
|
||||
// 设置路线相关的配置属性,如:路线的路况颜色,路线上是否显示摄像头气泡等。
|
||||
// options.setRouteOverlayOptions( MapStyleUtils.getRouteOverlayOptions() );
|
||||
// 设置自车的图片对象
|
||||
options.setCarBitmap(BitmapFactory.decodeResource(getContext().getResources(),
|
||||
R.drawable.module_small_map_view_my_location_logo));
|
||||
// 设置罗盘位图对象
|
||||
options.setFourCornersBitmap(BitmapFactory.decodeResource(getContext().getResources(),
|
||||
R.drawable.icon_module_small_map_four_corners));
|
||||
// 设置指南针图标否在导航界面显示,默认显示。true,显示;false,隐藏。
|
||||
options.setCompassEnabled(false);
|
||||
//设置路况光柱条是否显示(只适用于驾车导航,需要联网)。
|
||||
options.setTrafficBarEnabled(false);
|
||||
// 设置[实时交通图层开关按钮]是否显示(只适用于驾车导航,需要联网)。
|
||||
options.setTrafficLayerEnabled(false);
|
||||
// 设置导航界面是否显示路线全览按钮。
|
||||
options.setRouteListButtonShow(false);
|
||||
// 设置屏幕是否常亮,默认开启
|
||||
options.setScreenAlwaysBright(false);
|
||||
// 设置交通播报是否打开(只适用于驾车导航,需要联网)。
|
||||
options.setTrafficInfoUpdateEnabled(false);
|
||||
// 设置摄像头播报是否打开(只适用于驾车导航)。
|
||||
options.setCameraInfoUpdateEnabled(false);
|
||||
// 设置菜单按钮是否在导航界面显示。
|
||||
options.setSettingMenuEnabled(false);
|
||||
// 设置是否绘制显示交通路况的线路(彩虹线),拥堵-红色,畅通-绿色,缓慢-黄色,未知-蓝色。默认不绘制彩虹线。
|
||||
options.setTrafficLine(false);
|
||||
// 设置是否绘制牵引线(当前位置到目的地的指引线)。默认不绘制牵引线。
|
||||
options.setLeaderLineEnabled(-1);
|
||||
// 设置导航界面UI是否显示。
|
||||
options.setLayoutVisible(false);
|
||||
// 设置是否自动画路
|
||||
options.setAutoDrawRoute(false);
|
||||
// 设置是否显示路口放大图(实景图)
|
||||
options.setRealCrossDisplayShow(false);
|
||||
// 设置是否显示路口放大图(路口模型图)
|
||||
options.setModeCrossDisplayShow(false);
|
||||
// 设置是否显示道路信息view
|
||||
options.setLaneInfoShow(false);
|
||||
// 设置是否自动改变缩放等级
|
||||
options.setAutoChangeZoom(false);
|
||||
// 设置是否自动全览模式,即在算路成功后自动进入全览模式
|
||||
options.setAutoDisplayOverview(false);
|
||||
// 设置路线转向箭头隐藏和显示
|
||||
options.setNaviArrowVisible(false);
|
||||
// 通过路线是否自动置灰,仅支持驾车导航
|
||||
options.setAfterRouteAutoGray(false);
|
||||
options.setZoom(((int) 10));
|
||||
//options.setPointToCenter(0.7D, 0.5D);
|
||||
// 2D模式
|
||||
options.setTilt(0);
|
||||
// 黑夜模式
|
||||
options.setNaviNight(true);
|
||||
mAMapNaviView.setViewOptions(options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -175,44 +249,21 @@ public class SmallMapDirectionView
|
||||
@Override
|
||||
public void onCarLocationChanged2(Location latLng) {
|
||||
Logger.d(MODULE_NAME, "onCarLocationChanged2 latLng:" + latLng);
|
||||
LatLng currentLatLng = new LatLng(latLng.getLatitude(), latLng.getLongitude());
|
||||
|
||||
if (mCarMarker != null) {
|
||||
mCarMarker.setRotateAngle(360 - latLng.getBearing());
|
||||
mCarMarker.setPosition(currentLatLng);
|
||||
mCarMarker.setToTop();
|
||||
}
|
||||
|
||||
|
||||
if (mCoordinatesLatLng.size() > 1) {
|
||||
mCoordinatesLatLngCurrent.clear();
|
||||
for (LatLng lng : mCoordinatesLatLng) {
|
||||
MogoLatLng mogoLatLng = new MogoLatLng(lng.latitude, lng.longitude);
|
||||
mCoordinatesLatLngCurrent.add(mogoLatLng);
|
||||
if (mAMapNavi != null) {
|
||||
NumberFormat nf = NumberFormat.getNumberInstance();
|
||||
// 保留两位小数
|
||||
nf.setMaximumFractionDigits(6);
|
||||
// 如果不需要四舍五入,可以使用RoundingMode.DOWN
|
||||
nf.setRoundingMode(RoundingMode.UP);
|
||||
try {
|
||||
latLng.setLatitude(Double.valueOf(nf.format(latLng.getLatitude())));
|
||||
latLng.setLongitude(Double.valueOf(nf.format(latLng.getLongitude())));
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
latLng.setLatitude(latLng.getLatitude());
|
||||
latLng.setLongitude(latLng.getLongitude());
|
||||
}
|
||||
|
||||
// 结束位置
|
||||
LatLng endLatLng = mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1);
|
||||
// 与结束位置进行 GeoHash 0-12
|
||||
// GeoHash endGeoHash = GeoHash.withCharacterPrecision(endLatLng.latitude, endLatLng.longitude, 7);
|
||||
// GeoHash currentGeoHash = GeoHash.withCharacterPrecision(currentLatLng.latitude, currentLatLng.longitude, 7);
|
||||
// Log.d(MODULE_NAME, "currentGeoHash=" + currentGeoHash);
|
||||
// Log.d(MODULE_NAME, "endGeoHash=" + endGeoHash);
|
||||
|
||||
float calculateDistance = CoordinateUtils.calculateLineDistance(
|
||||
endLatLng.latitude, endLatLng.longitude,
|
||||
currentLatLng.latitude, currentLatLng.longitude
|
||||
);
|
||||
|
||||
Log.d(MODULE_NAME, "calculateDistance=" + calculateDistance);
|
||||
if (calculateDistance <= 20) {
|
||||
clearPolyline();
|
||||
} else {
|
||||
drawablePolyline(mCoordinatesLatLngCurrent);
|
||||
}
|
||||
} else {
|
||||
//设置希望展示的地图缩放级别
|
||||
mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, zoomLevel));
|
||||
mAMapNavi.setExtraGPSData(2, latLng);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,57 +274,39 @@ public class SmallMapDirectionView
|
||||
|
||||
@Override
|
||||
public void drawablePolyline(List<MogoLatLng> coordinates) {
|
||||
clearPolyline();
|
||||
mCoordinatesLatLng.clear();
|
||||
|
||||
for (MogoLatLng coordinate : coordinates) {
|
||||
mCoordinatesLatLng.add(new LatLng(coordinate.getLat(), coordinate.getLon()));
|
||||
}
|
||||
|
||||
if (mAMap != null) {
|
||||
if (mCoordinatesLatLng.size() > 2) {
|
||||
// 设置开始结束Marker位置
|
||||
mStartMarker.setPosition(mCoordinatesLatLng.get(0));
|
||||
mEndMarker.setPosition(mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1));
|
||||
mStartMarker.setVisible(true);
|
||||
mEndMarker.setVisible(true);
|
||||
|
||||
//存放所有点的经纬度
|
||||
LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
|
||||
|
||||
for (int i = 0; i < mCoordinatesLatLng.size(); i++) {
|
||||
//把所有点都include进去(LatLng类型)
|
||||
boundsBuilder.include(mCoordinatesLatLng.get(i));
|
||||
}
|
||||
//第二个参数为四周留空宽度
|
||||
mAMap.animateCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 65, 65, 65, 65));
|
||||
|
||||
// 绘制线
|
||||
mPolyline = mAMap.addPolyline(
|
||||
new PolylineOptions()
|
||||
.addAll(mCoordinatesLatLng)
|
||||
.color(Color.argb(255, 31, 127, 255))
|
||||
.width(5));
|
||||
|
||||
} else {
|
||||
//设置希望展示的地图缩放级别
|
||||
mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mCoordinatesLatLng.get(0), zoomLevel));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPolyline() {
|
||||
mCoordinatesLatLng.clear();
|
||||
if (mPolyline != null) {
|
||||
mPolyline.remove();
|
||||
}
|
||||
if (mStartMarker != null) {
|
||||
mStartMarker.setVisible(false);
|
||||
}
|
||||
if (mEndMarker != null) {
|
||||
mEndMarker.setVisible(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改角度
|
||||
*
|
||||
* @param angle 角度 0 - 359度旋转,相对于自身中心位置
|
||||
*/
|
||||
public void changeAngle(int angle) {
|
||||
int tempAngle = 360 - angle;
|
||||
|
||||
// if (tempAngle <= 180) {
|
||||
// tempAngle = tempAngle;
|
||||
// } else {
|
||||
// tempAngle = -(360 - tempAngle);
|
||||
// }
|
||||
|
||||
mRotateAnimation.setFromDegrees(lastAngle);
|
||||
mRotateAnimation.setToDegrees(tempAngle);
|
||||
|
||||
//设置线性插值,可以解决旋转一圈后卡顿问题
|
||||
mRotateAnimation.setInterpolator(new LinearInterpolator());
|
||||
//设置旋转一圈时间
|
||||
mRotateAnimation.setDuration(300);
|
||||
//控件动画结束时是否保持动画最后的状态
|
||||
mRotateAnimation.setFillAfter(true);
|
||||
mIvMapBorder.startAnimation(mRotateAnimation);
|
||||
// 刷新最后一次角度
|
||||
lastAngle = tempAngle;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
android:layout_width="@dimen/module_small_map_view_border_width"
|
||||
android:layout_height="@dimen/module_small_map_view_border_width"
|
||||
android:layout_centerInParent="true"
|
||||
android:background="@drawable/module_small_map_view_border_north" />
|
||||
android:background="@drawable/module_small_map_view_border" />
|
||||
|
||||
<com.mogo.module.common.view.RoundLayout
|
||||
android:id="@+id/rlSmallMapBorder"
|
||||
@@ -30,4 +30,11 @@
|
||||
android:layout_height="match_parent" />-->
|
||||
</com.mogo.module.common.view.RoundLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivMapBorder"
|
||||
android:layout_width="@dimen/module_small_map_border_view_width"
|
||||
android:layout_height="@dimen/module_small_map_border_view_width"
|
||||
android:layout_centerInParent="true"
|
||||
android:src="@drawable/module_small_map_view_border_north" />
|
||||
|
||||
</merge>
|
||||
@@ -1,7 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="module_small_map_padding">40px</dimen>
|
||||
<dimen name="module_small_map_view_border_width">550px</dimen>
|
||||
<dimen name="module_small_map_view_border_width">400px</dimen>
|
||||
<dimen name="module_small_map_border_view_width">550px</dimen>
|
||||
<dimen name="module_small_map_view_width">360px</dimen>
|
||||
|
||||
</resources>
|
||||
@@ -1,7 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="module_small_map_padding">30px</dimen>
|
||||
<dimen name="module_small_map_view_border_width">450px</dimen>
|
||||
<dimen name="module_small_map_view_border_width">288px</dimen>
|
||||
<dimen name="module_small_map_border_view_width">450px</dimen>
|
||||
<dimen name="module_small_map_view_width">260px</dimen>
|
||||
|
||||
</resources>
|
||||
@@ -11,7 +11,6 @@ import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.v2x.alarm.V2XCalculateServer;
|
||||
import com.mogo.module.v2x.manager.IMoGoPersonWarnPolylineManager;
|
||||
import com.mogo.module.v2x.manager.IMoGoStopPolylineManager;
|
||||
import com.mogo.module.v2x.manager.IMoGoV2XCloundDataManager;
|
||||
import com.mogo.module.v2x.manager.IMoGoV2XMarkerManager;
|
||||
import com.mogo.module.v2x.manager.IMoGoV2XPolylineManager;
|
||||
import com.mogo.module.v2x.manager.IMoGoV2XStatusManager;
|
||||
@@ -45,9 +44,6 @@ import com.mogo.service.windowview.IMogoWindowManager;
|
||||
import com.zhidao.carchattingprovider.CallChattingProviderConstant;
|
||||
import com.zhidao.carchattingprovider.ICarsChattingProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
@@ -109,7 +105,6 @@ public class V2XServiceManager {
|
||||
private static IMoGoWarnPolylineManager moGoWarnPolylineManager;
|
||||
private static IMoGoPersonWarnPolylineManager moGoPersonWarnPolylineManager;
|
||||
private static IMoGoStopPolylineManager moGoStopPolylineManager;
|
||||
private static IMoGoV2XCloundDataManager moGoV2XCloundDataManager;
|
||||
|
||||
private V2XServiceManager() {
|
||||
|
||||
@@ -165,7 +160,6 @@ public class V2XServiceManager {
|
||||
moGoV2XMarkerManager = (IMoGoV2XMarkerManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_MARKER_MANAGER).navigation(context);
|
||||
moGoV2XPolylineManager = (IMoGoV2XPolylineManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_POLYLINE_MANAGER).navigation(context);
|
||||
moGoWarnPolylineManager = (IMoGoWarnPolylineManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_WARN_POLYLINE_MANAGER).navigation(context);
|
||||
moGoV2XCloundDataManager = (IMoGoV2XCloundDataManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_WARN_CLOUND_DATA_MANAGER).navigation(context);
|
||||
moGoPersonWarnPolylineManager = (IMoGoPersonWarnPolylineManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_PERSON_WARN_POLYLINE_MANAGER).navigation(context);
|
||||
moGoStopPolylineManager = (IMoGoStopPolylineManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_STOP_POLYLINE_MANAGER).navigation(context);
|
||||
|
||||
@@ -337,14 +331,6 @@ public class V2XServiceManager {
|
||||
V2XServiceManager.mIMogoADASController = mIMogoADASController;
|
||||
}
|
||||
|
||||
public static IMoGoV2XCloundDataManager getMoGoV2XCloundDataManager() {
|
||||
return moGoV2XCloundDataManager;
|
||||
}
|
||||
|
||||
public static void setMoGoV2XCloundDataManager(IMoGoV2XCloundDataManager moGoV2XCloundDataManager) {
|
||||
V2XServiceManager.moGoV2XCloundDataManager = moGoV2XCloundDataManager;
|
||||
}
|
||||
|
||||
public static IMoGoPersonWarnPolylineManager getMoGoPersonWarnPolylineManager() {
|
||||
return moGoPersonWarnPolylineManager;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class DrawLineInfo {
|
||||
|
||||
private float width;
|
||||
|
||||
private int direction;
|
||||
private boolean hasStopLines;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
@@ -69,12 +69,12 @@ public class DrawLineInfo {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public int getDirection() {
|
||||
return direction;
|
||||
public boolean isHasStopLines() {
|
||||
return hasStopLines;
|
||||
}
|
||||
|
||||
public void setDirection(int direction) {
|
||||
this.direction = direction;
|
||||
public void setHasStopLines(boolean hasStopLines) {
|
||||
this.hasStopLines = hasStopLines;
|
||||
}
|
||||
|
||||
public List<MogoLatLng> getLocations() {
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.mogo.module.v2x.listener;
|
||||
|
||||
import com.mogo.module.common.entity.V2XWarningEntity;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 车路云—场景预警-云下发数据监听 前车/行人/摩托车/盲区碰撞预警
|
||||
* @since: 2021/3/31
|
||||
*/
|
||||
public class V2XMessageListener_401013 implements IMogoOnMessageListener<V2XWarningEntity> {
|
||||
@Override
|
||||
public Class target() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMsgReceived(V2XWarningEntity obj) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.mogo.module.v2x.manager;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.module.common.entity.V2XWarningEntity;
|
||||
|
||||
/**
|
||||
* desc: V2X 处理云端预警消息
|
||||
*/
|
||||
public interface IMoGoV2XCloundDataManager extends IProvider {
|
||||
|
||||
/**
|
||||
* 处理下发数据
|
||||
*/
|
||||
void analysisV2XCloundDataEvent(V2XWarningEntity cloundWarningInfo);
|
||||
|
||||
/**
|
||||
* 清除 所有的 POI
|
||||
*/
|
||||
void clearALLPOI();
|
||||
|
||||
}
|
||||
@@ -1,367 +0,0 @@
|
||||
package com.mogo.module.v2x.manager.impl;
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.Location;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.drawer.V2XWarnDataDrawer;
|
||||
import com.mogo.module.common.entity.V2XWarningEntity;
|
||||
import com.mogo.module.common.utils.Trigonometric;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.receiver.MogoReceiver;
|
||||
import com.mogo.module.v2x.MoGoV2XServicePaths;
|
||||
import com.mogo.module.v2x.V2XConst;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.entity.model.DrawLineInfo;
|
||||
import com.mogo.module.v2x.listener.V2XLocationListener;
|
||||
import com.mogo.module.v2x.manager.IMoGoV2XCloundDataManager;
|
||||
import com.mogo.module.v2x.scenario.scene.warning.V2XFrontWarningScenario;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_STOP_LINE_DATA;
|
||||
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_WARN_DATA;
|
||||
import static com.mogo.module.common.entity.V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_TOP;
|
||||
import static com.mogo.module.v2x.V2XServiceManager.getContext;
|
||||
|
||||
/**
|
||||
* desc : V2X 服务端下发数据处理 点的绘制
|
||||
*/
|
||||
@Route(path = MoGoV2XServicePaths.PATH_V2X_WARN_CLOUND_DATA_MANAGER)
|
||||
public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMogoCarLocationChangedListener2 {
|
||||
private static String WARNING_ARROWS = "WARNING_ARROWS";
|
||||
private V2XWarningEntity mCloundWarningInfo;
|
||||
private static String TAG = "MoGoV2XCloundDataManager";
|
||||
private boolean isSelfLineClear = true;//绘制线是否已被清除
|
||||
private List fillPoints = new ArrayList();//停止线经纬度合集
|
||||
private boolean isFirstLocation = false;
|
||||
private MogoLatLng carLocation = new MogoLatLng(
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat(),
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon()
|
||||
);
|
||||
|
||||
/*
|
||||
* 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
|
||||
* */
|
||||
private MogoLatLng middleLocationInStopLine;
|
||||
private V2XFrontWarningScenario mV2XScenario;
|
||||
|
||||
private static long showTime = 4000;
|
||||
private float bearing;
|
||||
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi()
|
||||
.registerCarLocationChangedListener(TAG, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void analysisV2XCloundDataEvent(V2XWarningEntity cloundWarningInfo) {
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
mCloundWarningInfo = cloundWarningInfo;
|
||||
showTime = mCloundWarningInfo.getShowTime();
|
||||
pointsBetween();
|
||||
bearing = V2XLocationListener.getInstance().getLastCarLocation().getBearing();
|
||||
|
||||
//顶部弹框
|
||||
if (mV2XScenario == null) {
|
||||
mV2XScenario = new V2XFrontWarningScenario();
|
||||
}
|
||||
// mV2XScenario.setWarningEntity(cloundWarningInfo);
|
||||
mV2XScenario.init(null);
|
||||
//预警蒙层
|
||||
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(cloundWarningInfo.getDirection(), MogoReceiver.ACTION_V2X_FRONT_WARNING);
|
||||
isSelfLineClear = false;
|
||||
isFirstLocation = false;
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(WARNING_ARROWS);
|
||||
if (cloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP) { //前方 TODO
|
||||
middleLocationInStopLine = getMiddleLocationInStopLine();
|
||||
//如果是正前方类型,红色绘制区域从停止线向前绘制50米
|
||||
MogoLatLng warningLocation = Trigonometric.getNewLocation(middleLocationInStopLine, 50, cloundWarningInfo.getAngle());
|
||||
//停止线前方画线
|
||||
WorkThreadHandler.getInstance().postDelayed(() -> {
|
||||
//二轮车和行人的渲染和移动
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
|
||||
//绘制识别物与交汇点连线,并且更新连线数据
|
||||
drawRedWarningLineFrontOfStopLine(cloundWarningInfo, middleLocationInStopLine, warningLocation);
|
||||
//添加停止线marker
|
||||
handleStopLine();
|
||||
//自车画线
|
||||
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
|
||||
}, 500);
|
||||
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
||||
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
|
||||
V2XServiceManager.getMoGoStopPolylineManager().clearLine();
|
||||
isSelfLineClear = true;
|
||||
}, showTime);
|
||||
|
||||
} else { //左侧或者右侧
|
||||
WorkThreadHandler.getInstance().postDelayed(() -> {
|
||||
//绘制识别物与交汇点连线,并且更新连线数据
|
||||
drawOtherObjectLine(cloundWarningInfo);
|
||||
//二轮车和行人的渲染和移动
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
|
||||
|
||||
//车辆静止的时候
|
||||
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
|
||||
|
||||
}, 500);
|
||||
|
||||
//延迟3秒清理线
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
||||
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
|
||||
isSelfLineClear = true;
|
||||
}, showTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自车为起点绘制(根据设计,前方行人/弱势交通参与者预警 getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP自车与停止线之间为蓝色预警;其他侧方预警自车与预碰撞点之间显示红色预警)
|
||||
*/
|
||||
private void drawSelfCarLine(double lon, double lat, float bearing) {
|
||||
if (!isSelfLineClear) {
|
||||
IMogoPolyline mogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
|
||||
if (mCloundWarningInfo != null) {
|
||||
MogoLatLng startLatlng = null;
|
||||
MogoLatLng endLatlng = null;
|
||||
MogoLatLng addMiddleLoc = null;
|
||||
|
||||
if (!isFirstLocation) {
|
||||
carLocation = getMogoLat(new MogoLatLng(lat, lon));
|
||||
isFirstLocation = true;
|
||||
}
|
||||
//绘制线的终点(在停止线上或者预碰撞点上)
|
||||
|
||||
endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP ? middleLocationInStopLine.lat : mCloundWarningInfo.getCollisionLat(),
|
||||
mCloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP ? middleLocationInStopLine.lon : mCloundWarningInfo.getCollisionLon());
|
||||
//自车位置
|
||||
startLatlng = new MogoLatLng(lat, lon);
|
||||
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);
|
||||
//扩展点为了渐变色添加
|
||||
addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2, Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));
|
||||
Log.d(TAG, "自车为起点绘制 自车;" + startLatlng.lon + "," + startLatlng.lat +
|
||||
"中间扩展点" + addMiddleLoc.lon + "," + addMiddleLoc.lat + "终点:" + endLatlng.lon + "," + endLatlng.lat);
|
||||
|
||||
if (mogoPolyline != null) {
|
||||
mogoPolyline.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
|
||||
mogoPolyline.setTransparency(0.5f);
|
||||
} else {
|
||||
DrawLineInfo info = new DrawLineInfo(); // 对象
|
||||
Log.d(TAG, "安全区域的画线点为" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
|
||||
List locations = new ArrayList();
|
||||
locations.add(startLatlng);
|
||||
locations.add(addMiddleLoc);
|
||||
locations.add(endLatlng);
|
||||
info.setLocations(locations);
|
||||
info.setHeading(bearing);
|
||||
info.setWidth(mCloundWarningInfo.getRoadwidth() * 14 + 5);
|
||||
info.setDirection(mCloundWarningInfo.getDirection());
|
||||
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(getContext(), info);
|
||||
}
|
||||
} else {
|
||||
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 停止线绘制
|
||||
* */
|
||||
private void handleStopLine() {
|
||||
try {
|
||||
if (mCloundWarningInfo != null) {
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_STOP_LINE_DATA);
|
||||
for (int i = 0; i < fillPoints.size(); i++) {
|
||||
V2XWarningEntity entity = new V2XWarningEntity();
|
||||
MogoLatLng latLng = (MogoLatLng) fillPoints.get(i);
|
||||
entity.setLat(latLng.lat);
|
||||
entity.setLon(latLng.lon);
|
||||
entity.heading = mCloundWarningInfo.heading;
|
||||
V2XWarnDataDrawer.getInstance().renderStopLineData(entity);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 场景如:车辆行驶正前方绘制红色区域(停止线继续前行的预警区域) TODO 需要实时给行人当前位置
|
||||
*/
|
||||
private void drawRedWarningLineFrontOfStopLine(V2XWarningEntity info, MogoLatLng
|
||||
startLatLng, MogoLatLng mogoLatLng) {
|
||||
if (info != null) {
|
||||
IMogoPolyline polyLine = V2XServiceManager.getMoGoStopPolylineManager().getMogoStopPolyline();
|
||||
MogoLatLng endLatlng = new MogoLatLng(mogoLatLng.lat, mogoLatLng.lon);
|
||||
float distance = CoordinateUtils.calculateLineDistance(startLatLng.lon, startLatLng.lat, endLatlng.lon, endLatlng.lat);
|
||||
MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatLng, distance / 2, mCloundWarningInfo.getAngle());
|
||||
Log.d(TAG, "红色区域起始点 = " + startLatLng.lon + "," + startLatLng.lat +
|
||||
"中间点坐标:" + addMiddleLoc.lon + "," + addMiddleLoc.lat
|
||||
+ "终点" + endLatlng.lon + "," + endLatlng.lat);
|
||||
if (polyLine != null) {
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "drawStopLine polyLine != null");
|
||||
polyLine.setPoints(Arrays.asList(startLatLng, addMiddleLoc, endLatlng));
|
||||
polyLine.setTransparency(0.5f);
|
||||
} else {
|
||||
DrawLineInfo lineInfo = new DrawLineInfo();
|
||||
List locations = new ArrayList();
|
||||
locations.add(startLatLng);
|
||||
locations.add(addMiddleLoc);
|
||||
locations.add(endLatlng);
|
||||
lineInfo.setLocations(locations);
|
||||
lineInfo.setHeading(info.heading);
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "drawStopLine width = " + info.getRoadwidth());
|
||||
lineInfo.setWidth(info.getRoadwidth() * 14 + 5);
|
||||
V2XServiceManager.getMoGoStopPolylineManager().drawStopPolyline(getContext(), lineInfo);
|
||||
}
|
||||
} else {
|
||||
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
||||
V2XServiceManager.getMoGoStopPolylineManager().clearLine();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 侧方目标物与预碰撞点连线,并且更新数据 TODO 需要实时给行人当前位置
|
||||
*/
|
||||
private void drawOtherObjectLine(V2XWarningEntity info) {
|
||||
if (info != null) {
|
||||
IMogoPolyline polyLine = V2XServiceManager.getMoGoPersonWarnPolylineManager().getMogoPersonWarnPolyline();
|
||||
MogoLatLng startLatlng = new MogoLatLng(info.getLat(), info.getLon());//识别物坐标
|
||||
MogoLatLng endLatlng = new MogoLatLng(info.getCollisionLat(), info.getCollisionLon());//预碰撞点坐标
|
||||
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);//识别物到碰撞点之间的距离
|
||||
MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2,
|
||||
Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));//补点
|
||||
if (polyLine != null) {
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "polyLine != null");
|
||||
polyLine.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
|
||||
polyLine.setTransparency(0.5f);
|
||||
} else {
|
||||
DrawLineInfo lineInfo = new DrawLineInfo();
|
||||
Log.d(TAG, "目标物与预碰撞点画线点为" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
|
||||
List locations = new ArrayList();
|
||||
locations.add(startLatlng);
|
||||
locations.add(addMiddleLoc);
|
||||
locations.add(endLatlng);
|
||||
lineInfo.setLocations(locations);
|
||||
lineInfo.setHeading(info.heading);
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "drawOtherObjectLine width = " + info.getRoadwidth());
|
||||
lineInfo.setWidth(info.getRoadwidth() * 14 + 5);
|
||||
V2XServiceManager.getMoGoPersonWarnPolylineManager().drawPersonWarnPolyline(getContext(), lineInfo);
|
||||
//识别物到预碰撞点之间的箭头
|
||||
addArrows(startLatlng, endLatlng);
|
||||
}
|
||||
} else {
|
||||
Log.e(V2XConst.LOG_NAME_WARN, "info == null");
|
||||
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
||||
}
|
||||
}
|
||||
|
||||
//侧面目标物与碰撞点之间添加多个小箭头
|
||||
private void addArrows(MogoLatLng startLatLng, MogoLatLng endLatLng) {
|
||||
float distance = CoordinateUtils.calculateLineDistance(
|
||||
startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat);
|
||||
double rotate = Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat);
|
||||
Log.d(TAG, "添加小箭头--目标物与预碰撞点之间的距离是" + String.valueOf(distance));
|
||||
if (distance > 5) {
|
||||
int count = (int) (distance / 5);
|
||||
for (int i = 0; i < count; i++) {
|
||||
MogoLatLng newLo = Trigonometric.getNewLocation(
|
||||
startLatLng, 5 * (i + 1), Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat));
|
||||
Log.d(TAG, "小箭头位置" + newLo);
|
||||
V2XWarnDataDrawer.getInstance().drawerArrowsMarkerWithLocation(newLo, WARNING_ARROWS, 10, new Double(rotate).intValue());
|
||||
}
|
||||
}
|
||||
//延迟3秒清理线
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(WARNING_ARROWS);
|
||||
}, showTime);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearALLPOI() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 自车定位 移动完成需要 3s消失,这里何时清理,应该是没有数据的时候
|
||||
* 地图侧回调回的定位Location为高德坐标
|
||||
*/
|
||||
@Override
|
||||
public void onCarLocationChanged2(Location latLng) {
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() && isSelfLineClear == false) {
|
||||
//当行人经纬度交点 开始画线,否则清理
|
||||
if (mCloundWarningInfo != null) {
|
||||
mCloundWarningInfo.setCarLocation(new MogoLatLng(latLng.getLatitude(), latLng.getLongitude()));
|
||||
}
|
||||
drawSelfCarLine(latLng.getLongitude(), latLng.getLatitude(), latLng.getBearing());
|
||||
}
|
||||
carLocation = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude());
|
||||
Log.d("车行驶的轨迹---", String.valueOf(latLng.getLongitude()) + "," + String.valueOf(latLng.getLatitude()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged(MogoLatLng latLng) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 补点后的停止线经纬度合集
|
||||
*/
|
||||
public void pointsBetween() {
|
||||
try {
|
||||
fillPoints.clear();
|
||||
List stopLines = mCloundWarningInfo.getStopLines();
|
||||
if (stopLines.size() > 1) {
|
||||
MogoLatLng x = mCloundWarningInfo.getStopLines().get(0);
|
||||
MogoLatLng y = mCloundWarningInfo.getStopLines().get(1);
|
||||
//两点间的距离
|
||||
float distance = CoordinateUtils.calculateLineDistance(x.lon, x.lat, y.lon, y.lat);
|
||||
float average = distance / 3;
|
||||
//两点间的角度
|
||||
double angle = Trigonometric.getAngle(x.lon, x.lat, y.lon, y.lat);
|
||||
//根据距离和角度获取下个点的经纬度
|
||||
fillPoints.add(x);
|
||||
for (int i = 1; i < 3; i++) {
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation(x, average * i, angle);
|
||||
fillPoints.add(newLocation);
|
||||
}
|
||||
fillPoints.add(y);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private MogoLatLng getMogoLat(MogoLatLng latlng) {
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation(latlng, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle());
|
||||
return newLocation;
|
||||
}
|
||||
|
||||
/*
|
||||
* 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
|
||||
* */
|
||||
private MogoLatLng getMiddleLocationInStopLine() {
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation(carLocation, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle());
|
||||
return newLocation;
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
|
||||
.setGps(false);
|
||||
List<Integer> colors = new ArrayList<>();
|
||||
|
||||
if (info.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP) {
|
||||
if (info.isHasStopLines() == true) {
|
||||
colors.add(0x0D3036FF);
|
||||
colors.add(0xD93036FF);
|
||||
colors.add(0x0D3036FF);
|
||||
@@ -75,6 +75,8 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.remove();
|
||||
mMogoPolyline = null;
|
||||
} else {
|
||||
Log.d("V2XWarningMarker", "mMogoPolyline==null");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.mogo.module.v2x.scenario.view.IV2XMarker;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.ViewUtils;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
import com.mogo.utils.network.utils.Util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -58,9 +59,10 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
/*
|
||||
* 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
|
||||
* */
|
||||
private MogoLatLng middleLocationInStopLine;
|
||||
private static long showTime = 5000;
|
||||
private MogoLatLng middleLocationInStopLine = new MogoLatLng(0, 0);
|
||||
private static long showTime = 6000;
|
||||
private float bearing;
|
||||
private boolean hasStopLines = false;
|
||||
|
||||
@Override
|
||||
public void drawPOI(Object entity) {
|
||||
@@ -75,36 +77,39 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
}
|
||||
|
||||
public void drawLineWithEntity() {
|
||||
showTime = mCloundWarningInfo.getShowTime() > 0 ? mCloundWarningInfo.getShowTime() : 5000;
|
||||
Log.d(TAG, "显示时间为++" + String.valueOf(showTime));
|
||||
pointsBetween();
|
||||
showTime = mCloundWarningInfo.getShowTime() > 0 ? mCloundWarningInfo.getShowTime() * 1000 : 6000;
|
||||
|
||||
fillPointOnStopLine();
|
||||
bearing = V2XLocationListener.getInstance().getLastCarLocation().getBearing();
|
||||
hasStopLines = mCloundWarningInfo.getStopLines().size() > 0;
|
||||
isSelfLineClear = false;
|
||||
isFirstLocation = false;
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(WARNING_ARROWS);
|
||||
if (fillPoints.size() > 0) { //存在停止线的情况 TODO
|
||||
if (fillPoints.size() > 0) {
|
||||
//存在停止线的情况 自车与停止线之间绘制蓝色安全线 停止线向前50m绘制红色预警线
|
||||
middleLocationInStopLine = getMiddleLocationInStopLine();
|
||||
//如果是正前方类型,红色绘制区域从停止线向前绘制50米
|
||||
MogoLatLng warningLocation = Trigonometric.getNewLocation(middleLocationInStopLine, 50, mCloundWarningInfo.getAngle());
|
||||
//停止线前方画线
|
||||
WorkThreadHandler.getInstance().postDelayed(() -> {
|
||||
if (carLocation.lat != 0 && carLocation.lon != 0) {
|
||||
//在自车与停止线直线绘制蓝色预警线
|
||||
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
|
||||
} else {
|
||||
Log.d(TAG, "自车定位数据为空carLocation == null");
|
||||
}
|
||||
//二轮车和行人的渲染和移动
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
//获取停止线前方50m坐标点
|
||||
MogoLatLng warningLocation = Trigonometric.getNewLocation(middleLocationInStopLine,
|
||||
50, angleForCarMoveDirection());
|
||||
//停止线向前方50m绘制红色预警线
|
||||
drawRedWarningLineFrontOfStopLine(mCloundWarningInfo, middleLocationInStopLine,
|
||||
warningLocation);
|
||||
V2XWarnDataDrawer.getInstance().renderWarnData(mCloundWarningInfo);
|
||||
//绘制识别物与交汇点连线,并且更新连线数据
|
||||
drawRedWarningLineFrontOfStopLine(mCloundWarningInfo, middleLocationInStopLine, warningLocation);
|
||||
//添加停止线marker
|
||||
handleStopLine();
|
||||
//自车画线
|
||||
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
|
||||
}, 0);
|
||||
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
||||
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
|
||||
V2XServiceManager.getMoGoStopPolylineManager().clearLine();
|
||||
isSelfLineClear = true;
|
||||
}, showTime);
|
||||
Log.d(TAG, "显示时间为++" + String.valueOf(showTime) + "识别物类型:" +
|
||||
String.valueOf(mCloundWarningInfo.getType()));
|
||||
clearAllLine();
|
||||
|
||||
} else { //无停止线
|
||||
WorkThreadHandler.getInstance().postDelayed(() -> {
|
||||
@@ -112,39 +117,48 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
drawOtherObjectLine(mCloundWarningInfo);
|
||||
//二轮车和行人的渲染和移动
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
if (carLocation.lat != 0 && carLocation.lon != 0) {
|
||||
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
|
||||
} else {
|
||||
Log.d(TAG, "数据为空carLocation == null");
|
||||
}
|
||||
V2XWarnDataDrawer.getInstance().renderWarnData(mCloundWarningInfo);
|
||||
//车辆静止的时候
|
||||
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
|
||||
|
||||
}, 0);
|
||||
|
||||
//延迟3秒清理线
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
||||
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
|
||||
isSelfLineClear = true;
|
||||
}, showTime);
|
||||
clearAllLine();
|
||||
}
|
||||
//预警蒙层
|
||||
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(mCloundWarningInfo.getDirection(), MogoReceiver.ACTION_V2X_FRONT_WARNING);
|
||||
|
||||
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection
|
||||
(mCloundWarningInfo.getDirection(), MogoReceiver.ACTION_V2X_FRONT_WARNING);
|
||||
}
|
||||
|
||||
/**
|
||||
* 场景如:车辆行驶正前方绘制红色区域(停止线继续前行的预警区域) TODO 需要实时给行人当前位置
|
||||
*/
|
||||
/*
|
||||
*
|
||||
* */
|
||||
public double angleForCarMoveDirection() {
|
||||
MogoLatLng startLatLng = new MogoLatLng(carLocation.lat, carLocation.lon);
|
||||
MogoLatLng endLatLng = new MogoLatLng(middleLocationInStopLine.lat, middleLocationInStopLine.lon);
|
||||
double angle = Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat);
|
||||
Log.d(TAG, "angle==" + String.valueOf(angle));
|
||||
return angle;
|
||||
}
|
||||
|
||||
|
||||
/*绘制停止线前方50m的红色预警线
|
||||
* startLatLng: 划线起点=停止线上的坐标点
|
||||
* mogoLatLng: 停止线前方50m坐标点
|
||||
* */
|
||||
private void drawRedWarningLineFrontOfStopLine(V2XWarningEntity info, MogoLatLng
|
||||
startLatLng, MogoLatLng mogoLatLng) {
|
||||
if (info != null) {
|
||||
double angle = Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, mogoLatLng.lon, mogoLatLng.lat);
|
||||
Log.d(TAG, "angle==drawRedWarningLineFrontOfStopLine:" + String.valueOf(angle));
|
||||
IMogoPolyline polyLine = V2XServiceManager.getMoGoStopPolylineManager().getMogoStopPolyline();
|
||||
MogoLatLng endLatlng = new MogoLatLng(mogoLatLng.lat, mogoLatLng.lon);
|
||||
float distance = CoordinateUtils.calculateLineDistance(startLatLng.lon, startLatLng.lat, endLatlng.lon, endLatlng.lat);
|
||||
MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatLng, distance / 2, mCloundWarningInfo.getAngle());
|
||||
Log.d(TAG, "红色区域起始点 = " + startLatLng.lon + "," + startLatLng.lat +
|
||||
"中间点坐标:" + addMiddleLoc.lon + "," + addMiddleLoc.lat
|
||||
+ "终点" + endLatlng.lon + "," + endLatlng.lat);
|
||||
MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatLng, 25, angle);
|
||||
if (polyLine != null) {
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "drawStopLine polyLine != null");
|
||||
Log.d(TAG, "drawStopLine polyLine != null");
|
||||
polyLine.setPoints(Arrays.asList(startLatLng, addMiddleLoc, endLatlng));
|
||||
polyLine.setTransparency(0.5f);
|
||||
} else {
|
||||
@@ -155,20 +169,39 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
locations.add(endLatlng);
|
||||
lineInfo.setLocations(locations);
|
||||
lineInfo.setHeading(info.heading);
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "drawStopLine width = " + info.getRoadwidth());
|
||||
Log.d(TAG, "drawStopLine width = " + info.getRoadwidth());
|
||||
lineInfo.setWidth(info.getRoadwidth() * 14 + 5);
|
||||
V2XServiceManager.getMoGoStopPolylineManager().drawStopPolyline(getContext(), lineInfo);
|
||||
}
|
||||
Log.d(TAG, "停止线前方50m区域的三个坐标点是:" + startLatLng.lon + "," + startLatLng.lat +
|
||||
"中间点坐标:" + addMiddleLoc.lon + "," + addMiddleLoc.lat
|
||||
+ "终点" + endLatlng.lon + "," + endLatlng.lat);
|
||||
} else {
|
||||
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
||||
V2XServiceManager.getMoGoStopPolylineManager().clearLine();
|
||||
clearAllLine();
|
||||
}
|
||||
}
|
||||
|
||||
public void clearAllLine() {
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
Log.d(TAG, "清除所有预警线的时间是:" + String.valueOf(showTime));
|
||||
//清除识别物到碰撞点预警线
|
||||
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
||||
//清除车前方第一条预警线
|
||||
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
|
||||
//清除停止线
|
||||
V2XServiceManager.getMoGoStopPolylineManager().clearLine();
|
||||
//清除小箭头
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(WARNING_ARROWS);
|
||||
//清除停止线
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_STOP_LINE_DATA);
|
||||
isSelfLineClear = true;
|
||||
}, showTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 补点后的停止线经纬度合集
|
||||
*/
|
||||
public void pointsBetween() {
|
||||
public void fillPointOnStopLine() {
|
||||
try {
|
||||
fillPoints.clear();
|
||||
List stopLines = mCloundWarningInfo.getStopLines();
|
||||
@@ -209,65 +242,72 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
V2XWarnDataDrawer.getInstance().renderStopLineData(entity);
|
||||
}
|
||||
}
|
||||
//移动完成以后,3s后消失
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_STOP_LINE_DATA);
|
||||
}, mCloundWarningInfo.getShowTime());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private MogoLatLng getMogoLat(MogoLatLng latlng) {
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation(latlng, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle());
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation(latlng, mCloundWarningInfo.getStopLineDistance(),
|
||||
mCloundWarningInfo.getAngle());
|
||||
return newLocation;
|
||||
}
|
||||
|
||||
/*
|
||||
* 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
|
||||
* 自车前方的点,落点在停止线上--通过自车位置与距离停止线之间的距离计算
|
||||
* */
|
||||
private MogoLatLng getMiddleLocationInStopLine() {
|
||||
Log.d(TAG, "计算停止线上的某个点" + String.valueOf(carLocation.lat + "," + String.valueOf(carLocation.lon)));
|
||||
if (carLocation.lat == 0 || carLocation.lon == 0) {
|
||||
Log.d(TAG, "获取不到车的位置");
|
||||
}
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation(carLocation, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle());
|
||||
MogoLatLng newLocation = new MogoLatLng(0, 0);
|
||||
if (mCloundWarningInfo.getStopLines().size() > 1) {
|
||||
MogoLatLng x = mCloundWarningInfo.getStopLines().get(0);
|
||||
MogoLatLng y = mCloundWarningInfo.getStopLines().get(1);
|
||||
float distance = CoordinateUtils.calculateLineDistance(x.lon, x.lat, y.lon, y.lat);
|
||||
double angle = Trigonometric.getAngle(x.lon, x.lat, y.lon, y.lat);
|
||||
newLocation = Trigonometric.getNewLocation(x, distance * 0.5, angle);
|
||||
} else {
|
||||
Log.d(TAG, "停止线返回坐标点数量不正确" + String.valueOf(mCloundWarningInfo.getStopLines().size()));
|
||||
}
|
||||
return newLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自车为起点绘制(根据设计,前方行人/弱势交通参与者预警 getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP自车与停止线之间为蓝色预警;其他侧方预警自车与预碰撞点之间显示红色预警)
|
||||
* 存在停止线时自车与停止线之间为蓝色预警
|
||||
* 不存在停止线,自车与预碰撞点之间为红色预警
|
||||
* lon 自车经度
|
||||
* lat 自车纬度
|
||||
*/
|
||||
public void drawSelfCarLine(double lon, double lat, float bearing) {
|
||||
if (!isSelfLineClear) {
|
||||
IMogoPolyline mogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
|
||||
if (mCloundWarningInfo != null) {
|
||||
MogoLatLng startLatlng = null;
|
||||
MogoLatLng endLatlng = null;
|
||||
MogoLatLng addMiddleLoc = null;
|
||||
IMogoPolyline mogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
|
||||
MogoLatLng startLatlng = new MogoLatLng(0, 0);
|
||||
MogoLatLng endLatlng = new MogoLatLng(0, 0);
|
||||
MogoLatLng addMiddleLoc = new MogoLatLng(0, 0);
|
||||
|
||||
if (!isFirstLocation) {
|
||||
carLocation = getMogoLat(new MogoLatLng(lat, lon));
|
||||
isFirstLocation = true;
|
||||
}
|
||||
//绘制线的终点(在停止线上或者预碰撞点上)
|
||||
endLatlng = new MogoLatLng(hasStopLines ?
|
||||
middleLocationInStopLine.lat : mCloundWarningInfo.getCollisionLat(), hasStopLines ?
|
||||
middleLocationInStopLine.lon : mCloundWarningInfo.getCollisionLon());
|
||||
|
||||
endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP ? middleLocationInStopLine.lat : mCloundWarningInfo.getCollisionLat(),
|
||||
mCloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP ? middleLocationInStopLine.lon : mCloundWarningInfo.getCollisionLon());
|
||||
//自车位置
|
||||
startLatlng = new MogoLatLng(lat, lon);
|
||||
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);
|
||||
//扩展点为了渐变色添加
|
||||
addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2, Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));
|
||||
Log.d(TAG, "自车为起点绘制 自车;" + startLatlng.lon + "," + startLatlng.lat +
|
||||
"中间扩展点" + addMiddleLoc.lon + "," + addMiddleLoc.lat + "终点:" + endLatlng.lon + "," + endLatlng.lat);
|
||||
|
||||
addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2,
|
||||
Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));
|
||||
Log.d(TAG, "angle==扩展点为了渐变色添加:" +
|
||||
String.valueOf(Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat)));
|
||||
if (mogoPolyline != null) {
|
||||
mogoPolyline.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
|
||||
mogoPolyline.setTransparency(0.5f);
|
||||
} else {
|
||||
DrawLineInfo info = new DrawLineInfo(); // 对象
|
||||
Log.d(TAG, "安全区域的画线点为" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
|
||||
List locations = new ArrayList();
|
||||
locations.add(startLatlng);
|
||||
locations.add(addMiddleLoc);
|
||||
@@ -275,11 +315,14 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
info.setLocations(locations);
|
||||
info.setHeading(bearing);
|
||||
info.setWidth(mCloundWarningInfo.getRoadwidth() * 14 + 5);
|
||||
info.setDirection(mCloundWarningInfo.getDirection());
|
||||
info.setHasStopLines(mCloundWarningInfo.getStopLines().size() > 0);
|
||||
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(getContext(), info);
|
||||
Log.d(TAG, "自车前方第一条线" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
|
||||
}
|
||||
Log.d(TAG, "自车为起点绘制 自车;" + startLatlng.lon + "," + startLatlng.lat +
|
||||
"中间扩展点" + addMiddleLoc.lon + "," + addMiddleLoc.lat + "终点:" + endLatlng.lon + "," + endLatlng.lat);
|
||||
} else {
|
||||
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
|
||||
clearAllLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -300,23 +343,22 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
polyLine.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
|
||||
polyLine.setTransparency(0.5f);
|
||||
} else {
|
||||
//识别物到预碰撞点之间的箭头
|
||||
addArrows(startLatlng, endLatlng);
|
||||
DrawLineInfo lineInfo = new DrawLineInfo();
|
||||
Log.d(TAG, "目标物与预碰撞点画线点为" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
|
||||
List locations = new ArrayList();
|
||||
locations.add(startLatlng);
|
||||
locations.add(addMiddleLoc);
|
||||
locations.add(endLatlng);
|
||||
lineInfo.setLocations(locations);
|
||||
lineInfo.setHeading(info.heading);
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "drawOtherObjectLine width = " + info.getRoadwidth());
|
||||
lineInfo.setWidth(info.getRoadwidth() * 14 + 5);
|
||||
V2XServiceManager.getMoGoPersonWarnPolylineManager().drawPersonWarnPolyline(getContext(), lineInfo);
|
||||
//识别物到预碰撞点之间的箭头
|
||||
addArrows(startLatlng, endLatlng);
|
||||
Log.d(TAG, "目标物与预碰撞点画线点为" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
|
||||
}
|
||||
} else {
|
||||
Log.e(V2XConst.LOG_NAME_WARN, "info == null");
|
||||
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
||||
clearAllLine();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,51 +373,17 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
for (int i = 0; i < count; i++) {
|
||||
MogoLatLng newLo = Trigonometric.getNewLocation(
|
||||
startLatLng, 5 * (i + 1), Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat));
|
||||
Log.d(TAG, "小箭头位置" + newLo);
|
||||
V2XWarnDataDrawer.getInstance().drawerArrowsMarkerWithLocation(newLo, WARNING_ARROWS, 10, new Double(rotate).intValue());
|
||||
Log.d(TAG, "小箭头位置" + newLo);
|
||||
}
|
||||
}
|
||||
//延迟3秒清理线
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(WARNING_ARROWS);
|
||||
}, showTime);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 2D资源绘制停止线 暂时不需要
|
||||
* */
|
||||
private void drawStopLineWith2Resource() {
|
||||
MogoLatLng carlo = mCloundWarningInfo.getCarLocation();
|
||||
if (carlo == null) {
|
||||
double lon = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon();
|
||||
double lat = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat();
|
||||
carlo = new MogoLatLng(lat, lon);
|
||||
}
|
||||
//自车行驶方向的前方*米的经纬度,该经纬度在停止线上
|
||||
MogoLatLng drawStopLineLon = Trigonometric.getNewLocation(carlo, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle());
|
||||
Log.d(TAG, "2D资源绘" + drawStopLineLon);
|
||||
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
|
||||
.latitude(drawStopLineLon.getLat())
|
||||
.longitude(drawStopLineLon.getLon())
|
||||
.anchor(1.0f, 1.0f)
|
||||
.zIndex(MarkerDrawer.MARKER_Z_INDEX_HIGH);
|
||||
|
||||
optionsRipple
|
||||
.icon(ViewUtils.fromView(new EmptyMarkerView(V2XServiceManager.getContext())));
|
||||
IMogoMarker stopLine = V2XServiceManager.getMarkerManager().addMarker(TYPE_MARKER_CLOUD_STOP_LINE_DATA, optionsRipple);
|
||||
stopLine.setInfoWindowAdapter(new SimpleWindow3DAdapter(new V2XFrontTargetMarkerView(V2XServiceManager.getContext())));
|
||||
stopLine.showInfoWindow();
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
stopLine.hideInfoWindow();
|
||||
}, showTime);
|
||||
}
|
||||
|
||||
//线随车动
|
||||
public void onCarLocationChanged2(Location latLng) {
|
||||
carLocation = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude());
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() && isSelfLineClear == false) {
|
||||
//当行人经纬度交点 开始画线,否则清理
|
||||
if (mCloundWarningInfo != null) {
|
||||
mCloundWarningInfo.setCarLocation(new MogoLatLng(latLng.getLatitude(), latLng.getLongitude()));
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/module_v2n_image_margin_left"
|
||||
android:layout_marginTop="@dimen/dp_20"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/v2x_road_front_car_warning" />
|
||||
|
||||
<TextView
|
||||
@@ -22,7 +22,7 @@
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginRight="@dimen/dp_28"
|
||||
android:maxWidth="@dimen/module_v2n_tip_text_width"
|
||||
android:text="1.2米"
|
||||
android:text="112米"
|
||||
android:textColor="@color/v2x_FF3036"
|
||||
android:textSize="@dimen/dp_32" />
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignEnd="@+id/warning_distance"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="@dimen/dp_20"
|
||||
android:layout_marginLeft="@dimen/dp_30"
|
||||
android:layout_marginRight="@dimen/module_v2n_tip_text_margin_right"
|
||||
android:layout_toRightOf="@+id/warning_type_image"
|
||||
android:text="前车碰撞预警"
|
||||
|
||||
@@ -16,6 +16,6 @@
|
||||
"stopLineDistance": 60,
|
||||
"warningContent": "注意自行车",
|
||||
"heading": 0,
|
||||
"showTime": 5000,
|
||||
"showTime": 3,
|
||||
"roadwidth": 4.0
|
||||
}
|
||||
@@ -24,6 +24,6 @@
|
||||
"stopLineDistance": 60,
|
||||
"warningContent": "小心行人",
|
||||
"heading": 0,
|
||||
"showTime": 5000,
|
||||
"showTime": 3,
|
||||
"roadwidth": 4.0
|
||||
}
|
||||
@@ -15,6 +15,6 @@
|
||||
"stopLineDistance": 60,
|
||||
"warningContent": "注意摩托车",
|
||||
"heading": 0,
|
||||
"showTime": 5000,
|
||||
"showTime": 3,
|
||||
"roadwidth": 4.0
|
||||
}
|
||||
|
||||
@@ -108,13 +108,6 @@ public interface IMogoADASController extends IProvider {
|
||||
*/
|
||||
void removeAdasWarnMessageCallback(IMogoAdasWarnMessageCallback callback);
|
||||
|
||||
/**
|
||||
* 获取 adas 识别列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<ADASRecognizedResult> getLastADASRecognizedResult();
|
||||
|
||||
/**
|
||||
* 添加adas识别物体回调
|
||||
*
|
||||
@@ -213,5 +206,4 @@ public interface IMogoADASController extends IProvider {
|
||||
|
||||
void mockAdasRecognized(List<ADASRecognizedResult> recognizedResults);
|
||||
|
||||
void mockAdasRecognized(String json);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.mogo.service.connection;
|
||||
|
||||
public interface IMogoLifecycleListener {
|
||||
void onConnectFailure();
|
||||
|
||||
void onConnectSuccess();
|
||||
|
||||
void onConnectLost();
|
||||
}
|
||||
@@ -45,6 +45,11 @@ public interface IMogoSocketManager extends IProvider {
|
||||
*/
|
||||
void unregisterOnMessageListener( int msgType, IMogoOnMessageListener listener );
|
||||
|
||||
|
||||
void registerLifecycleListener(int msgType,IMogoLifecycleListener listener);
|
||||
|
||||
void unregisterLifecycleListener(int msgType);
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
@@ -52,4 +57,9 @@ public interface IMogoSocketManager extends IProvider {
|
||||
* @param listener 回执监听
|
||||
*/
|
||||
void sendMsg(MsgBody body, IMogoMsgAckListener listener );
|
||||
|
||||
/**
|
||||
* 停止Socket服务
|
||||
*/
|
||||
void destroy();
|
||||
}
|
||||
|
||||
@@ -144,4 +144,10 @@ public interface IMogoMapService extends IProvider {
|
||||
* @return
|
||||
*/
|
||||
CoordinatesTransformer getCoordinatesTransformer();
|
||||
|
||||
/**
|
||||
* 获取地图版本号
|
||||
* @return
|
||||
*/
|
||||
String getMapVersion();
|
||||
}
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
package com.mogo.service.impl.adas;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.utils.MortonCode;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.adas.entity.ADASRecognizedResult;
|
||||
import com.mogo.service.adas.entity.ADASWarnMessage;
|
||||
import com.zhidao.autopilotservice.model.AdasAIDLOwnerCarRectModel;
|
||||
import com.zhidao.support.adas.high.bean.RectInfo;
|
||||
import com.zhidao.support.adas.high.bean.WarnMessageInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
/*
|
||||
@@ -37,12 +40,12 @@ public class AdasObjectUtils {
|
||||
return warnMessage;
|
||||
}
|
||||
|
||||
public static List<ADASRecognizedResult> regroupData(List<AdasAIDLOwnerCarRectModel> datums) {
|
||||
public static List<ADASRecognizedResult> regroupData(List<RectInfo.RectBean> datums) {
|
||||
if (datums == null || datums.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
List<ADASRecognizedResult> recognizedListResults = new ArrayList<>();
|
||||
for (AdasAIDLOwnerCarRectModel model : datums) {
|
||||
for (RectInfo.RectBean model : datums) {
|
||||
if (model == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -54,10 +57,11 @@ public class AdasObjectUtils {
|
||||
return recognizedListResults;
|
||||
}
|
||||
|
||||
public static ADASRecognizedResult fromAdasObject(AdasAIDLOwnerCarRectModel model) {
|
||||
public static ADASRecognizedResult fromAdasObject(RectInfo.RectBean model) {
|
||||
if (model == null) {
|
||||
return null;
|
||||
}
|
||||
long start = System.nanoTime();
|
||||
ADASRecognizedResult result = new ADASRecognizedResult();
|
||||
result.uuid = model.getUuid();
|
||||
result.lat = model.getLat();
|
||||
@@ -73,11 +77,14 @@ public class AdasObjectUtils {
|
||||
result.dataAccuracy = model.dataAccuracy;
|
||||
result.distance = model.distance;
|
||||
result.drawlevel = model.getDrawlevel();
|
||||
result.mortonCode = MortonCode.wrapEncodeMorton(result.lon, result.lat);
|
||||
IMogoMapUIController mogoMapUIController = ARouter.getInstance().navigation(IMogoServiceApis.class).getMapServiceApi().getMapUIController();
|
||||
if (mogoMapUIController != null) {
|
||||
result.tileId = String.valueOf(mogoMapUIController.getTileId(result.lon, result.lat));
|
||||
}
|
||||
// result.mortonCode = MortonCode.wrapEncodeMorton(result.lon, result.lat);
|
||||
Log.d("ADAS数据延时","fromAdasObject cost : " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)));
|
||||
// IMogoMapUIController mogoMapUIController = ARouter.getInstance().navigation(IMogoServiceApis.class).getMapServiceApi().getMapUIController();
|
||||
// if (mogoMapUIController != null) {
|
||||
// long start = System.currentTimeMillis();
|
||||
// result.tileId = String.valueOf(mogoMapUIController.getTileId(result.lon, result.lat));
|
||||
// Log.d("ADAS数据延时", "getTileId 耗时 : " + (System.currentTimeMillis() - start) + "ms");
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
@@ -18,8 +17,8 @@ import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.module.adas.AdasProvider;
|
||||
import com.mogo.module.adas.AdasStatusListener;
|
||||
import com.mogo.module.adas.IAdasDataListener;
|
||||
import com.mogo.module.adas.IAdasStatusListener;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.adas.IMogoADASController;
|
||||
import com.mogo.service.adas.IMogoAdasCarDataCallback;
|
||||
@@ -51,15 +50,11 @@ import com.zhidao.adasconfig.common.config.EnumCarHeading;
|
||||
import com.zhidao.adasconfig.common.config.EnumSkinStyle;
|
||||
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotArriveModel;
|
||||
import com.zhidao.autopilotservice.model.AdasAIDLOwnerCarRectModel;
|
||||
import com.zhidao.autopilotservice.model.AdasAIDLOwnerCarStateModel;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotRoute;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotStatus;
|
||||
import com.zhidao.support.adas.high.bean.RectInfo;
|
||||
import com.zhidao.support.adas.high.bean.WarnMessageInfo;
|
||||
import com.zhidao.support.adas.high.msg.MyMessageFactory;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -69,19 +64,8 @@ import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
|
||||
import static rx.android.schedulers.AndroidSchedulers.mainThread;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-10
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
@Route(path = MogoServicePaths.PATH_ADAS_CONTROLLER)
|
||||
public class MogoADASController implements IMogoADASController {
|
||||
|
||||
@@ -101,10 +85,8 @@ public class MogoADASController implements IMogoADASController {
|
||||
|
||||
private boolean mIsReleased = true;
|
||||
|
||||
private IAdasDataListener mAdasDataListener;
|
||||
private AdasProvider adasProvider;
|
||||
|
||||
|
||||
/**
|
||||
* 获取adas前车距离
|
||||
*/
|
||||
@@ -125,9 +107,33 @@ public class MogoADASController implements IMogoADASController {
|
||||
*/
|
||||
private final List<IMogoAdasRouteCallBack> mMogoAdasRouteCallBacks = new CopyOnWriteArrayList<>();
|
||||
|
||||
private IAdasDataListener mAdasDataListener;
|
||||
|
||||
private IMogoAdasCarDataCallback mMogoAdasCarDataCallback;
|
||||
|
||||
private List<AdasAIDLOwnerCarRectModel> mLastFrameDatums;
|
||||
private IMogoAdasOCHCallback mAdasOCHCallback;
|
||||
|
||||
private double mLastLon;
|
||||
private double mLastLat;
|
||||
private double mSpeed;
|
||||
private String satelliteTime;
|
||||
|
||||
@Override
|
||||
public double getLastSpeed() {
|
||||
return mSpeed;
|
||||
}
|
||||
|
||||
public double getLastLat() {
|
||||
return mLastLat;
|
||||
}
|
||||
|
||||
public double getLastLon() {
|
||||
return mLastLon;
|
||||
}
|
||||
|
||||
public String getSatelliteTime() {
|
||||
return satelliteTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收 adas 识别数据线程
|
||||
@@ -137,9 +143,9 @@ public class MogoADASController implements IMogoADASController {
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.obj instanceof List) {
|
||||
mAdasDataListener.notifyOwnerCarRect((List<AdasAIDLOwnerCarRectModel>) msg.obj);
|
||||
handleAdasRecognizedData((List<RectInfo.RectBean>) msg.obj);
|
||||
} else if (msg.obj == null) {
|
||||
mAdasDataListener.notifyOwnerCarRect(null);
|
||||
handleAdasRecognizedData(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -167,8 +173,8 @@ public class MogoADASController implements IMogoADASController {
|
||||
|
||||
mLastLon = stateInfo.getValues().getLon();
|
||||
mLastLat = stateInfo.getValues().getLat();
|
||||
// satelliteTime = stateInfo.getValues().getSatelliteTime();
|
||||
satelliteTime = stateInfo.getValues().getSystemTime();
|
||||
mSpeed = stateInfo.getValues().getGnss_speed();
|
||||
satelliteTime = stateInfo.getValues().getSatelliteTime();
|
||||
if (mMogoAdasCarDataCallback != null) {
|
||||
mMogoAdasCarDataCallback.onAdasCarDataCallback(stateInfo);
|
||||
}
|
||||
@@ -176,116 +182,12 @@ public class MogoADASController implements IMogoADASController {
|
||||
}
|
||||
};
|
||||
|
||||
private final OnAdasListener mOnAdasListener = new OnAdasListenerAdapter() {
|
||||
|
||||
@Override
|
||||
public void onRectData(RectInfo rectInfo) {
|
||||
|
||||
List<AdasAIDLOwnerCarRectModel> data = new ArrayList<>();
|
||||
if (rectInfo != null && rectInfo.getModels() != null && !rectInfo.getModels().isEmpty()) {
|
||||
List<RectInfo.RectBean> beans = rectInfo.getModels();
|
||||
for (RectInfo.RectBean bean : beans) {
|
||||
if (bean == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
AdasAIDLOwnerCarRectModel model = new AdasAIDLOwnerCarRectModel();
|
||||
model.setId(bean.getId());
|
||||
model.setXl(bean.getXl());
|
||||
model.setXr(bean.getXr());
|
||||
model.setYb(bean.getYb());
|
||||
model.setYt(bean.getYt());
|
||||
model.setDistance_x(bean.getDistance_x());
|
||||
model.setDistance_y(bean.getDistance_y());
|
||||
String type;
|
||||
if (TextUtils.isEmpty(bean.getType())) {
|
||||
type = "100";
|
||||
Logger.d(TAG, " === ADAS 返回结果出现 type 为 null情况 ====");
|
||||
} else {
|
||||
type = bean.getType();
|
||||
}
|
||||
model.setType(type);
|
||||
model.setLat(bean.getLat());
|
||||
model.setLon(bean.getLon());
|
||||
model.setHeading(bean.getHeading());
|
||||
model.setSystemTime(bean.getSystemTime());
|
||||
model.setSatelliteTime(bean.getSystemTime());
|
||||
model.setAlt(bean.getAlt());
|
||||
model.setCarId(bean.getCarId());
|
||||
model.setUuid(bean.getUuid());
|
||||
model.setColor(bean.getColor());
|
||||
model.setSpeed(bean.getSpeed());
|
||||
model.setDataAccuracy(bean.getDataAccuracy());
|
||||
model.setDistance(bean.getDistance());
|
||||
model.setDrawlevel(bean.getDrawlevel()); //liyz
|
||||
|
||||
data.add(model);
|
||||
|
||||
Log.d("ADAS数据延时", "uuid : " + bean.getUuid() + " type : " + bean.getType() + "systemTime : " + System.currentTimeMillis() + " GPS time" + Long.parseLong(bean.getSystemTime())
|
||||
+ " timeDelay : " + (System.currentTimeMillis() - Long.parseLong(bean.getSystemTime())));
|
||||
|
||||
// Log.d("ADAS原始数据", "uuid : " + bean.getUuid() + " type : " + bean.getType());
|
||||
Logger.d(TAG, "识别距离:x = %s, y = %s", model.getDistance_x(), model.getDistance_y());
|
||||
}
|
||||
}
|
||||
|
||||
if (mLastFrameDatums == null) {
|
||||
mLastFrameDatums = new ArrayList<>();
|
||||
}
|
||||
try {
|
||||
mLastFrameDatums.addAll(data);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
Message message = mAdasRecognizedRecHandler.obtainMessage();
|
||||
message.obj = data;
|
||||
message.sendToTarget();
|
||||
DebugConfig.setStatus(DebugConfig.sAdasRecognized, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotRoute(AutopilotRoute autopilotRoute) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotSNRequest() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWarnMessage(WarnMessageInfo warnMessageInfo) {
|
||||
if (warnMessageInfo == null) {
|
||||
return;
|
||||
}
|
||||
// 警告消息
|
||||
Logger.d(TAG, "onWarnMessage = %s", warnMessageInfo.toString());
|
||||
if (mMogoAdasWarnMessageCallbackList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final ADASWarnMessage warnMessage = AdasObjectUtils.fromAdasObject(warnMessageInfo);
|
||||
if (warnMessage == null) {
|
||||
return;
|
||||
}
|
||||
UiThreadHandler.post(() -> {
|
||||
for (IMogoAdasWarnMessageCallback callback : mMogoAdasWarnMessageCallbackList) {
|
||||
if (callback != null) {
|
||||
callback.onReceiveData(warnMessage);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
private IMogoAdasOCHCallback mAdasOCHCallback;
|
||||
|
||||
/**
|
||||
* 处理数据
|
||||
*
|
||||
* @param models
|
||||
*/
|
||||
private void handleAdasRecognizedData(List<AdasAIDLOwnerCarRectModel> models) {
|
||||
private void handleAdasRecognizedData(List<RectInfo.RectBean> models) {
|
||||
if (models == null
|
||||
|| models.isEmpty()) {
|
||||
invokeCallbackPerSecond(null);
|
||||
@@ -294,7 +196,7 @@ public class MogoADASController implements IMogoADASController {
|
||||
invokeCallbackPerSecond(models);
|
||||
}
|
||||
|
||||
private void invokeCallbackPerSecond(List<AdasAIDLOwnerCarRectModel> models) {
|
||||
private void invokeCallbackPerSecond(List<RectInfo.RectBean> models) {
|
||||
List<ADASRecognizedResult> recognizedListResults = AdasObjectUtils.regroupData(models);
|
||||
if (!mMogoAdasRecognizedDataCallbacks.isEmpty()) {
|
||||
for (IMogoAdasRecognizedDataCallback callback : mMogoAdasRecognizedDataCallbacks) {
|
||||
@@ -306,8 +208,6 @@ public class MogoADASController implements IMogoADASController {
|
||||
}
|
||||
}
|
||||
|
||||
private MyMessageFactory mAdasMessageFactory;
|
||||
|
||||
@Override
|
||||
public void openADAS() {
|
||||
showADAS();
|
||||
@@ -338,7 +238,7 @@ public class MogoADASController implements IMogoADASController {
|
||||
// }
|
||||
Logger.d(TAG, Log.getStackTraceString(new Throwable()));
|
||||
init(AbsMogoApplication.getApp());
|
||||
adasProvider.addAdasStatusListener(new AdasStatusListener() {
|
||||
adasProvider.addAdasStatusListener(new IAdasStatusListener() {
|
||||
@Override
|
||||
public void onServiceConnected() {
|
||||
Logger.d(TAG, "adas statusListener connected");
|
||||
@@ -367,20 +267,54 @@ public class MogoADASController implements IMogoADASController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cameraEyeDetectResult(String detectResult) {
|
||||
Logger.d(TAG, "detectResult " + detectResult);
|
||||
try {
|
||||
JSONObject jsonObjectWs = new JSONObject(detectResult);
|
||||
String action = jsonObjectWs.optString("action");
|
||||
if (TextUtils.isEmpty(action)) {
|
||||
Logger.w(TAG, "--->action is null");
|
||||
return;
|
||||
}
|
||||
//识别的他车移动操作
|
||||
mAdasMessageFactory.createMessage(action).handlerMsg(GsonUtil.getGson(), mOnAdasListener, detectResult);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
public void onRectData(RectInfo rectInfo) {
|
||||
// 仅在 vr 模式下显示 adas 识别车辆
|
||||
if (!SingletonsHolder.get(IMogoStatusManager.class).isVrMode()) {
|
||||
return;
|
||||
}
|
||||
if (!SingletonsHolder.get(IMogoStatusManager.class).isMainPageLaunched()) {
|
||||
return;
|
||||
}
|
||||
if (rectInfo == null || TextUtils.isEmpty(rectInfo.getAction())) {
|
||||
Logger.w(TAG, "--->action is null");
|
||||
return;
|
||||
}
|
||||
final long start = System.nanoTime();
|
||||
if (rectInfo.getModels() != null && !rectInfo.getModels().isEmpty()) {
|
||||
List<RectInfo.RectBean> beans = rectInfo.getModels();
|
||||
try {
|
||||
Message message = mAdasRecognizedRecHandler.obtainMessage();
|
||||
message.obj = beans;
|
||||
message.sendToTarget();
|
||||
Log.i("ADAS数据延时", "接收数据 -> 发出 cost :" + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)) + "ms");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
DebugConfig.setStatus(DebugConfig.sAdasRecognized, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWarnMessage(WarnMessageInfo warnMessageInfo) {
|
||||
if (warnMessageInfo == null) {
|
||||
return;
|
||||
}
|
||||
// 警告消息
|
||||
Logger.d(TAG, "onWarnMessage = %s", warnMessageInfo.toString());
|
||||
if (mMogoAdasWarnMessageCallbackList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final ADASWarnMessage warnMessage = AdasObjectUtils.fromAdasObject(warnMessageInfo);
|
||||
if (warnMessage == null) {
|
||||
return;
|
||||
}
|
||||
UiThreadHandler.post(() -> {
|
||||
for (IMogoAdasWarnMessageCallback callback : mMogoAdasWarnMessageCallbackList) {
|
||||
if (callback != null) {
|
||||
callback.onReceiveData(warnMessage);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -462,31 +396,6 @@ public class MogoADASController implements IMogoADASController {
|
||||
message.sendToTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyOwnerCarState(AdasAIDLOwnerCarStateModel ownerCarStateModel) {
|
||||
Logger.d(TAG, "AdasAIDLOwnerCarStateModel " + ownerCarStateModel);
|
||||
ADASCarStateInfo stateInf = new ADASCarStateInfo();
|
||||
stateInf.setAction("state");
|
||||
ADASCarStateInfo.ValuesBean bean = new ADASCarStateInfo.ValuesBean();
|
||||
bean.setSatelliteTime(ownerCarStateModel.getSatelliteTime());
|
||||
bean.setAcceleration(ownerCarStateModel.getAcceleration());
|
||||
bean.setAlt(ownerCarStateModel.getAlt());
|
||||
bean.setGnss_speed(ownerCarStateModel.getGnss_speed());
|
||||
bean.setHeading(ownerCarStateModel.getHeading());
|
||||
bean.setLat(ownerCarStateModel.getLat());
|
||||
bean.setLon(ownerCarStateModel.getLon());
|
||||
bean.setReceiverDataTime(ownerCarStateModel.getReceiverDataTime());
|
||||
bean.setSystemTime(ownerCarStateModel.getSystemTime());
|
||||
bean.setYaw_rate(ownerCarStateModel.getYaw_rate());
|
||||
stateInf.setValues(bean);
|
||||
mLastLon = ownerCarStateModel.getLon();
|
||||
mLastLat = ownerCarStateModel.getLat();
|
||||
mSpeed = ownerCarStateModel.getGnss_speed();
|
||||
if (mMogoAdasCarDataCallback != null) {
|
||||
mMogoAdasCarDataCallback.onAdasCarDataCallback(stateInf);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyAutopilotState(AutopilotStatus autopilotStatus) {
|
||||
Logger.d(TAG, "notifyAutopilotState: " + autopilotStatus);
|
||||
@@ -495,53 +404,11 @@ public class MogoADASController implements IMogoADASController {
|
||||
mAdasOCHCallback.onStateChanged(autopilotStatus.getValues().getState(), autopilotStatus.getValues().getReason());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyOwnerCarRect(List<AdasAIDLOwnerCarRectModel> ownerCarStateRectList) {
|
||||
// 物体识别返回
|
||||
Logger.d(TAG, "ADAS-REC-received data: size = %s", ownerCarStateRectList == null ? 0 : ownerCarStateRectList.size());
|
||||
final long start = System.currentTimeMillis();
|
||||
// 仅在 vr 模式下显示 adas 识别车辆
|
||||
if (!SingletonsHolder.get(IMogoStatusManager.class).isVrMode()) {
|
||||
return;
|
||||
}
|
||||
if (!SingletonsHolder.get(IMogoStatusManager.class).isMainPageLaunched()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
handleAdasRecognizedData(ownerCarStateRectList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Logger.i("ADAS-REC-timer", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
}
|
||||
};
|
||||
adasProvider.addAdasEventListener(mAdasDataListener);
|
||||
}
|
||||
}
|
||||
|
||||
private double mLastLon;
|
||||
private double mLastLat;
|
||||
private double mSpeed;
|
||||
private String satelliteTime;
|
||||
|
||||
@Override
|
||||
public double getLastSpeed() {
|
||||
return mSpeed;
|
||||
}
|
||||
|
||||
public double getLastLat() {
|
||||
return mLastLat;
|
||||
}
|
||||
|
||||
public double getLastLon() {
|
||||
return mLastLon;
|
||||
}
|
||||
|
||||
public String getSatelliteTime() {
|
||||
return satelliteTime;
|
||||
}
|
||||
|
||||
private boolean useTestSn = false;
|
||||
|
||||
private void invokeShowADASOperation() {
|
||||
@@ -614,7 +481,6 @@ public class MogoADASController implements IMogoADASController {
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
mIsReleased = false;
|
||||
mAdasMessageFactory = new MyMessageFactory();
|
||||
adasProvider = ARouter.getInstance().navigation(AdasProvider.class);
|
||||
this.context = context;
|
||||
}
|
||||
@@ -634,7 +500,6 @@ public class MogoADASController implements IMogoADASController {
|
||||
if (ui == null || !DebugConfig.isMapBased()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.d(TAG, "new Mode: " + ui.name());
|
||||
switch (ui) {
|
||||
case CarUp_2D:
|
||||
@@ -784,25 +649,6 @@ public class MogoADASController implements IMogoADASController {
|
||||
mMogoAdasWarnMessageCallbackList.remove(callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ADASRecognizedResult> getLastADASRecognizedResult() {
|
||||
if (mLastFrameDatums == null) {
|
||||
return null;
|
||||
}
|
||||
if (!DebugConfig.isUseAdasRecognize()) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
List<AdasAIDLOwnerCarRectModel> data = mLastFrameDatums;
|
||||
mLastFrameDatums = null;
|
||||
List<ADASRecognizedResult> recognizedResultList;
|
||||
recognizedResultList = AdasObjectUtils.regroupData(data);
|
||||
return recognizedResultList;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAdasRecognizedDataCallback(IMogoAdasRecognizedDataCallback callback) {
|
||||
if (callback == null) {
|
||||
@@ -928,27 +774,6 @@ public class MogoADASController implements IMogoADASController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mockAdasRecognized(String json) {
|
||||
mAdasDataListener.cameraEyeDetectResult(json);
|
||||
}
|
||||
|
||||
//
|
||||
// private static final int PERIOD = 5 * 1000;
|
||||
// private static final int DELAY = 10000;
|
||||
// private Disposable mDisposable;
|
||||
//
|
||||
// /**
|
||||
// * 定时循环任务
|
||||
// */
|
||||
// private void timeLoop() {
|
||||
// mDisposable = Observable.interval(DELAY, PERIOD, TimeUnit.MILLISECONDS)
|
||||
// .map((aLong -> aLong + 1))
|
||||
// .subscribeOn(Schedulers.io())
|
||||
// .subscribe(aLong ->
|
||||
// adasProvider.setBasicInfo()
|
||||
// );//getUnreadCount()执行的任务
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.content.Context;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.cloud.socket.entity.MsgBody;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.connection.IMogoLifecycleListener;
|
||||
import com.mogo.service.connection.IMogoMsgAckListener;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.service.connection.IMogoSocketManager;
|
||||
@@ -52,6 +53,20 @@ public class MogoSocketManager implements IMogoSocketManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerLifecycleListener(int msgType, IMogoLifecycleListener listener) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.registerLifecycleListener( msgType, listener );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterLifecycleListener(int msgType) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.unregisterLifecycleListener( msgType);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMsg(MsgBody body, IMogoMsgAckListener listener ) {
|
||||
if ( mDelegate != null ) {
|
||||
@@ -59,6 +74,13 @@ public class MogoSocketManager implements IMogoSocketManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class IntentManager implements IMogoIntentManager {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Map< String, CopyOnWriteArrayList< IMogoIntentListener > > mListeners = new ConcurrentHashMap<>();
|
||||
private final Map< String, CopyOnWriteArrayList< IMogoIntentListener > > mListeners = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public void registerIntentListener( String intent, IMogoIntentListener listener ) {
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.mogo.map.MogoCoordinatesTransformer;
|
||||
import com.mogo.map.MogoGeoSearch;
|
||||
import com.mogo.map.MogoInputtipsSearch;
|
||||
import com.mogo.map.MogoLocationClient;
|
||||
import com.mogo.map.MogoMap;
|
||||
import com.mogo.map.MogoMapUIController;
|
||||
import com.mogo.map.MogoMapViewInstanceHandler;
|
||||
import com.mogo.map.MogoMarkerManager;
|
||||
@@ -120,6 +121,11 @@ public class MogoMapService implements IMogoMapService {
|
||||
return MogoCoordinatesTransformer.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMapVersion() {
|
||||
return MogoMap.getInstance().getMogoMap().getMapVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user