This commit is contained in:
unknown
2021-01-06 14:19:11 +08:00
21 changed files with 213 additions and 85 deletions

1
.idea/gradle.xml generated
View File

@@ -85,6 +85,7 @@
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings>
</option>
</component>

View File

@@ -12,6 +12,7 @@ import com.bytedance.boost_multidex.BoostMultiDex;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.network.Utils;
import com.mogo.map.location.MogoLocation;
import com.mogo.module.authorize.authprovider.invoke.AuthorizeConstant;
import com.mogo.module.carchatting.card.CallChatConstant;
import com.mogo.module.common.MogoApisHandler;
@@ -30,6 +31,7 @@ import com.mogo.service.passport.IMogoTicketCallback;
import com.mogo.test.crashreport.ITestCrashReportProvider;
import com.mogo.utils.ProcessUtils;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.httpdns.HttpSimpleLocation;
import com.mogo.utils.logger.LogLevel;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.storage.SharedPrefsMgr;
@@ -157,6 +159,16 @@ public class MogoApplication extends AbsMogoApplication {
prepareBaseService( apis, 2_000L );
}
@Override
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
*/

View File

@@ -0,0 +1,13 @@
package com.mogo.httpdns;
import android.location.Location;
import com.mogo.utils.httpdns.HttpSimpleLocation;
public interface IHttpDnsLocationChanged {
/**
* 获取当前定位
* @return 当前定位
*/
HttpSimpleLocation getLocation();
}

View File

@@ -1,5 +1,7 @@
package com.mogo.httpdns;
import android.content.Context;
import androidx.annotation.Keep;
import androidx.annotation.Nullable;
@@ -95,4 +97,12 @@ interface IMogoHttpDns extends IProvider {
*/
@Keep
void removeHttpDnsTtlCallback(String host,int type);
/**
* 初始化
*
* @param context 上下文
* @param locationChanged 定位发生变化
*/
void init(Context context, IHttpDnsLocationChanged locationChanged);
}

View File

@@ -32,16 +32,14 @@ dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation rootProject.ext.dependencies.arouter
annotationProcessor rootProject.ext.dependencies.aroutercompiler
implementation 'com.mogo.httpdns:httpdns-helper:1.0.14'
implementation 'com.mogo.httpdns:httpdns-helper:1.0.16'
if (Boolean.valueOf(RELEASE)) {
implementation rootProject.ext.dependencies.httpdnsbase
implementation rootProject.ext.dependencies.mogocommons
implementation rootProject.ext.dependencies.modulecommon
} else {
implementation project(':foudations:httpdns-base')
implementation project(':foudations:mogo-commons')
implementation project(':modules:mogo-module-common')
}
}

View File

@@ -1,7 +1,6 @@
package com.mogo.httpdns.mogo;
import android.content.Context;
import android.os.Debug;
import android.text.TextUtils;
import android.util.ArrayMap;
@@ -12,14 +11,14 @@ import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.network.Utils;
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.map.location.MogoLocation;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.utils.httpdns.HttpSimpleLocation;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.HttpDns;
@@ -50,14 +49,8 @@ public class MogoHttpDns implements IMogoHttpDns, HttpDns, OnAddressChangedListe
@Override
public void getHttpDnsIp(String host, int type, boolean useCache, IHttpDnsCallback callback) {
Logger.d("MogoHttpDns", "host: " + host + " type: " + type);
Logger.d("MogoHttpDns", "getHttpDnsIp host: " + host + " type: " + type);
Map<String,String> map = httpDnsHelper.getAllAddress();
if(map != null) {
Logger.d("MogoHttpDns", "all host: ");
for (String key : map.keySet()) {
Logger.d("MogoHttpDns", "key: " + key + " value: " + map.get(key));
}
}
if (useCache) {
String address = httpDnsHelper.getHttpDnsCachedAddress(type, host);
if (address != null) {
@@ -74,6 +67,7 @@ public class MogoHttpDns implements IMogoHttpDns, HttpDns, OnAddressChangedListe
@Override
public void addHttpDnsTtlCallback(String host, int type, IHttpDnsTtlCallback callback) {
Logger.d("MogoHttpDns","addHttpDnsTtlCallback: host: "+host+" type: "+type);
if (ttlCallbackMap.get(type + "-" + host) == null) {
ttlCallbackMap.put(type + "-" + host, new ArrayList<IHttpDnsTtlCallback>());
}
@@ -88,13 +82,18 @@ public class MogoHttpDns implements IMogoHttpDns, HttpDns, OnAddressChangedListe
@Override
public void init(final Context context) {
httpDnsHelper = new HttpDnsHelper.Builder().setContext(context).setEnv(DebugConfig.getNetMode()).setSn(Utils.getSn()).setShowDebugLog(true).setLoopCheckDelay(15 * 60 * 1000).setCurrentLocation(new IHttpDnsCurrentLocation() {
}
@Override
public void init(Context context, final IHttpDnsLocationChanged locationChanged) {
httpDnsHelper = new HttpDnsHelper.Builder().setContext(context).setEnv(DebugConfig.getNetMode()).setDefaultUrl("dzt.zhidaozhixing.com").setSn(Utils.getSn()).setShowDebugLog(true).setLoopCheckDelay(15 * 60 * 1000).setCurrentLocation(new IHttpDnsCurrentLocation() {
@org.jetbrains.annotations.Nullable
@Override
public HttpDnsSimpleLocation getCurrentLocation() {
MogoLocation last = MogoApisHandler.getInstance().getApis().getMapServiceApi().getSingletonLocationClient(context).getLastKnowLocation();
if (last != null) {
return new HttpDnsSimpleLocation(last.getCityCode(), last.getLatitude(), last.getLongitude());
HttpSimpleLocation simpleLocation = locationChanged.getLocation();
if (simpleLocation != null) {
return new HttpDnsSimpleLocation("0734", simpleLocation.getLat(), simpleLocation.getLon());
}
return null;
}
@@ -126,7 +125,7 @@ public class MogoHttpDns implements IMogoHttpDns, HttpDns, OnAddressChangedListe
}
@Override
public void onAddressChanged(@org.jetbrains.annotations.Nullable Map<String, String> map) {
public void onAddressChanged(Map<String, String> map) {
if (map != null) {
for (String key : map.keySet()) {
if (ttlCallbackMap.get(key) != null) {

View File

@@ -28,7 +28,7 @@ public class WebSocketDnsManager {
public void getHttpDnsIp(WebSocketDns webSocketDns) {
this.webSocketDns = webSocketDns;
IMogoHttpDns mogoHttpDns = ARouter.getInstance().navigation(IMogoHttpDns.class);
IMogoHttpDns mogoHttpDns = MogoHttpDnsHandler.getHttpDnsApi();
ThreadPoolService.execute(() -> mogoHttpDns.getHttpDnsIp(WebSocketConstant.getDomain(), HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_WS,false, ip -> {
Logger.d(TAG, "getHttpDnsIp ip : " + ip + " , 得到Dns IP,准备回调 初始化webSocket");
this.cacheIp = ip;

View File

@@ -78,6 +78,9 @@ public class WebSocketManager implements IMogoWebSocketManager, ISocketMsgSettin
@Override
public void ttlIp(String url) {
Logger.d(TAG,"ttlIp url : " + url);
if(!WebSocketInstanceHolder.getClientProxy().isOpen()){
return;
}
WebSocketInstanceHolder.getClientProxy().stop();
WebSocketInstanceHolder.getClientProxy().disConnect();
Logger.d(TAG,"ready to re initWebSocket : " + url);

View File

@@ -24,6 +24,7 @@ import com.mogo.httpdns.MogoHttpDnsHandler;
import com.mogo.utils.ThreadPoolService;
import com.mogo.utils.TipDrawable;
import com.mogo.utils.TipToast;
import com.mogo.utils.httpdns.HttpSimpleLocation;
import com.mogo.utils.network.NetConfig;
import java.security.SecureRandom;
@@ -87,6 +88,7 @@ public abstract class AbsMogoApplication extends Application {
}
private void syncInit() {
MogoHttpDnsHandler.getHttpDnsApi().init(this, this::getCurrentLocation);
TipToast.init( this, ( ( context, message, tipDrawable ) -> {
if ( TextUtils.isEmpty( message ) ) {
return null;
@@ -100,6 +102,10 @@ public abstract class AbsMogoApplication extends Application {
} ) );
}
protected HttpSimpleLocation getCurrentLocation(){
return null;
}
private View generateToastView( Context context, String message, TipDrawable tipDrawable){
View contentView;
if(tipDrawable==null) {

View File

@@ -0,0 +1,37 @@
package com.mogo.utils.httpdns;
public class HttpSimpleLocation {
private String cityCode;
private double lat;
private double lon;
public HttpSimpleLocation(String cityCode, double lat, double lon) {
this.cityCode = cityCode;
this.lat = lat;
this.lon = lon;
}
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;
}
}

View File

@@ -0,0 +1,19 @@
package com.mogo.module.common.constants;
/**
* 通用接口请求host
*
* @author tong
*/
public class HostConst {
public static final String DEVA_HOST = "http://dzt-deva.zhidaozhixing.com";
public static final String IM_HOST = "http://dzt-im.zhidaozhixing.com";
public static final String LAUNCHER_SNAPSHOT_HOST = "http://dzt-launcherSnapshot.zhidaozhixing.com";
public static final String CHANNEL_MANAGER_HOST = "http://dzt-channelManager.zhidaozhixing.com";
public static final String DATA_SERVICE_HOST = "http://dzt-dataService.zhidaozhixing.com";
public static final String REALTIME_LOCATION_HOST = "http://dzt-realtimeLocation.zhidaozhixing.com";
public static final String INSTANT_HOST = "http://dzt-Instant.zhidaozhixing.com";
public static final String IM_SOCKET_DOMAIN = "dzt-im.zhidaozhixing.com";
public static final String WEBSOCKET_DOMAIN = "dzt-city.zhidaozhixing.com";
}

View File

@@ -2,4 +2,7 @@
-keep class com.mogo.module.share.bean.**{*;}
-keep class com.mogo.module.share.constant.**{*;}
-keep class com.mogo.module.share.manager.ISeekHelpListener
-keep class com.mogo.module.share.net.ShareApiService
-keep class com.mogo.module.share.net.ShareDevaApiService
-keep class com.mogo.module.share.net.ShareLsApiService
-keep class com.mogo.module.share.net.ShareRtlApiService
#-keep class com.mogo.module.share.net.ShareApiService

View File

@@ -24,4 +24,7 @@
-keep class com.mogo.module.share.bean.**{*;}
-keep class com.mogo.module.share.constant.**{*;}
-keep class com.mogo.module.share.manager.ISeekHelpListener
-keep class com.mogo.module.share.net.ShareApiService
-keep class com.mogo.module.share.net.ShareDevaApiService
-keep class com.mogo.module.share.net.ShareLsApiService
-keep class com.mogo.module.share.net.ShareRtlApiService
#-keep class com.mogo.module.share.net.ShareApiService

View File

@@ -16,6 +16,7 @@ import com.mogo.module.authorize.authprovider.invoke.AuthorizeConstant;
import com.mogo.module.authorize.authprovider.invoke.AuthorizeInvokerConstant;
import com.mogo.module.authorize.authprovider.module.IMogoAcquireAuthorizeListener;
import com.mogo.module.authorize.authprovider.module.IMogoAuthorizeModuleManager;
import com.mogo.module.common.constants.HostConst;
import com.mogo.module.common.dialog.BaseFloatDialog;
import com.mogo.module.common.utils.CloudPoiManager;
import com.mogo.module.share.bean.FixableButton;
@@ -27,7 +28,7 @@ import com.mogo.module.share.constant.ShareConstants;
import com.mogo.module.share.dialog.GridFixableShareDialog;
import com.mogo.module.share.manager.ServiceApisManager;
import com.mogo.module.share.manager.UploadHelper;
import com.mogo.module.share.net.ShareApiService;
import com.mogo.module.share.net.ShareDevaApiService;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.share.IMogoShareManager;
import com.mogo.service.share.IMogoTanluProvider;
@@ -454,8 +455,8 @@ public class ShareControl implements IMogoShareManager, Handler.Callback {
ShareConfigRequest request = new ShareConfigRequest(Utils.getSn(),
location.getAdCode());
params.put("data", request.toJson());
ServiceApisManager.serviceApis.getNetworkApi().create(ShareApiService.class,
HttpConstant.Companion.getNetHost()).queryShareButtonConfig(params).subscribeOn(Schedulers.io()).observeOn(Schedulers.io()).subscribe(new SubscribeImpl<ShareButtonConfigResponse>(RequestOptions.create(mContext)) {
ServiceApisManager.serviceApis.getNetworkApi().create(ShareDevaApiService.class,
HostConst.DEVA_HOST).queryShareButtonConfig(params).subscribeOn(Schedulers.io()).observeOn(Schedulers.io()).subscribe(new SubscribeImpl<ShareButtonConfigResponse>(RequestOptions.create(mContext)) {
@Override
public void onSuccess(ShareButtonConfigResponse o) {
super.onSuccess(o);

View File

@@ -10,6 +10,10 @@ class HttpConstant {
const val HOST_DEMO = "http://dzt-show.zhidaozhixing.com"
const val HOST_PRODUCT = "http://dzt.zhidaozhixing.com"
const val DEVA_HOST = "http://dzt-deva.zhidaozhixing.com"
const val RTL_HOST = "http://dzt-realtimeLocation.zhidaozhixing.com"
const val LS_HOST = "http://dzt-launcherSnapshot.zhidaozhixing.com"
@JvmStatic
fun getNetHost(): String {

View File

@@ -10,11 +10,12 @@ import com.mogo.commons.network.SubscribeImpl
import com.mogo.commons.network.Utils
import com.mogo.commons.voice.AIAssist
import com.mogo.commons.voice.IMogoVoiceCmdCallBack
import com.mogo.module.common.constants.HostConst
import com.mogo.module.share.bean.SeekRecord
import com.mogo.module.share.bean.SeekRequest
import com.mogo.module.share.bean.getJson
import com.mogo.module.share.constant.HttpConstant
import com.mogo.module.share.net.ShareApiService
import com.mogo.module.share.net.ShareRtlApiService
import com.mogo.utils.TipToast
import com.mogo.utils.logger.Logger
import com.mogo.utils.network.RequestOptions
@@ -164,7 +165,7 @@ object SeekHelpManager {
properties["from"] = from
AnalyticsUtils.track("v2x_share_type", properties)
ServiceApisManager.serviceApis.networkApi.create(ShareApiService::class.java, HttpConstant.getNetHost()).sendHelpSignal(param).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(object : SubscribeImpl<BaseData>(RequestOptions.create(context)) {
ServiceApisManager.serviceApis.networkApi.create(ShareRtlApiService::class.java, HostConst.REALTIME_LOCATION_HOST).sendHelpSignal(param).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(object : SubscribeImpl<BaseData>(RequestOptions.create(context)) {
override fun onSuccess(o: BaseData?) {
super.onSuccess(o)
// 接口请求成功内部同步v2x状态通知adas改变自车图标
@@ -222,7 +223,7 @@ object SeekHelpManager {
fun debugCancelSeek() {
val seekRequest = SeekRequest(Utils.getSn(), 0)
val param = mutableMapOf("data" to seekRequest.getJson())
ServiceApisManager.serviceApis.networkApi.create(ShareApiService::class.java, HttpConstant.getNetHost()).sendHelpSignal(param).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(object : SubscribeImpl<BaseData>(RequestOptions.create(context)) {
ServiceApisManager.serviceApis.networkApi.create(ShareRtlApiService::class.java, HostConst.REALTIME_LOCATION_HOST).sendHelpSignal(param).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(object : SubscribeImpl<BaseData>(RequestOptions.create(context)) {
override fun onSuccess(o: BaseData?) {
super.onSuccess(o)
// 接口请求成功内部同步v2x状态通知adas改变自车图标

View File

@@ -1,47 +0,0 @@
package com.mogo.module.share.net
import com.mogo.commons.data.BaseData
import com.mogo.module.share.bean.AverateSpeedResponse
import com.mogo.module.share.bean.BaseDataCompat
import com.mogo.module.share.bean.RoadInfos
import com.mogo.module.share.bean.ShareButtonConfigResponse
import io.reactivex.Observable
import okhttp3.RequestBody
import retrofit2.http.*
/**
* 分享用到的api接口
*/
interface ShareApiService {
/**
* 发起求助接口
*/
@FormUrlEncoded
@POST("/yycp-realtimeLocations/vehicleTypeManage/car/updateVehicleType/v1")
fun sendHelpSignal(@FieldMap param: Map<String, String>): Observable<BaseData>
/**
* 拥堵策略,上报平均速度
*/
@Headers("Content-type:application/json;charset=UTF-8")
@POST("/deva/car/path/no/poiStrategyCheck/v1")
fun sendAverageSpeedForBlockStrategy(@Body request: RequestBody, @Query("sn") sn: String): Observable<AverateSpeedResponse>
/**
* 获取分享框服务端配置
*/
@FormUrlEncoded
@POST("/deva/car/poiType/no/poiTypeList")
fun queryShareButtonConfig(@FieldMap param: Map<String, String>): Observable<ShareButtonConfigResponse>
/**
* 查询(搜索)道路事件信息
* 接口文档http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=42305842
* 文档中有些参数暂时没有用到包括radius,limit
* @return
*/
@FormUrlEncoded
@POST("/yycp-launcherSnapshot/launcherSnapshot/searchRoadEventsSync")
fun queryRoadInfos(@FieldMap params: Map<String, Any>): Observable<BaseDataCompat<RoadInfos>>
}

View File

@@ -0,0 +1,32 @@
package com.mogo.module.share.net;
import com.mogo.module.share.bean.AverateSpeedResponse;
import com.mogo.module.share.bean.ShareButtonConfigResponse;
import java.util.Map;
import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Query;
public interface ShareDevaApiService {
/**
* 拥堵策略,上报平均速度
*/
@Headers("Content-type:application/json;charset=UTF-8")
@POST("/deva/car/path/no/poiStrategyCheck/v1")
Observable<AverateSpeedResponse> sendAverageSpeedForBlockStrategy(@Body RequestBody request, @Query("sn")String sn);
/**
* 获取分享框服务端配置
*/
@FormUrlEncoded
@POST("/deva/car/poiType/no/poiTypeList")
Observable<ShareButtonConfigResponse> queryShareButtonConfig(@FieldMap Map<String, String> param);
}

View File

@@ -0,0 +1,25 @@
package com.mogo.module.share.net;
import com.mogo.module.share.bean.BaseDataCompat;
import com.mogo.module.share.bean.RoadInfos;
import java.util.Map;
import io.reactivex.Observable;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;
public interface ShareLsApiService {
/**
* 查询(搜索)道路事件信息
* 接口文档http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=42305842
* 文档中有些参数暂时没有用到包括radius,limit
*
* @return
*/
@FormUrlEncoded
@POST("/yycp-launcherSnapshot/launcherSnapshot/searchRoadEventsSync")
Observable<BaseDataCompat<RoadInfos>> queryRoadInfos(@FieldMap Map<String, Object> params);
}

View File

@@ -0,0 +1,19 @@
package com.mogo.module.share.net;
import com.mogo.commons.data.BaseData;
import java.util.Map;
import io.reactivex.Observable;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;
public interface ShareRtlApiService {
/**
* 发起求助接口
*/
@FormUrlEncoded
@POST("/yycp-realtimeLocations/vehicleTypeManage/car/updateVehicleType/v1")
Observable<BaseData> sendHelpSignal(@FieldMap Map<String, String> param );
}

View File

@@ -3,24 +3,13 @@ package com.mogo.module.share.strategyreceiver
import android.content.Context
import android.os.Handler
import android.os.SystemClock
import android.util.ArrayMap
import com.mogo.commons.network.SubscribeImpl
import com.mogo.commons.network.Utils
import com.mogo.map.MogoLatLng
import com.mogo.module.share.bean.AverateSpeedResponse
import com.mogo.module.share.constant.HttpConstant
import com.mogo.module.share.manager.ServiceApisManager
import com.mogo.module.share.net.ShareApiService
import com.mogo.service.IMogoServiceApis
import com.mogo.service.share.IMogoTanluProvider
import com.mogo.service.share.TanluUploadParams
import com.mogo.utils.logger.Logger
import com.mogo.utils.network.RequestOptions
import com.mogo.utils.network.utils.GsonUtil
import com.mogo.utils.storage.SharedPrefsMgr
import io.reactivex.schedulers.Schedulers
import okhttp3.MediaType
import okhttp3.RequestBody
import java.util.*
import kotlin.collections.ArrayList