Merge branch 'dev_merge_shunyi_vr_map' of http://gitlab.zhidaoauto.com/ecos/yycp-service/Launcher into dev_merge_shunyi_vr_map
This commit is contained in:
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
@@ -16,6 +16,7 @@
|
||||
<option value="$PROJECT_DIR$/app2" />
|
||||
<option value="$PROJECT_DIR$/foudations" />
|
||||
<option value="$PROJECT_DIR$/foudations/httpdns-base" />
|
||||
<option value="$PROJECT_DIR$/foudations/httpdns-mogo" />
|
||||
<option value="$PROJECT_DIR$/foudations/httpdns-noop" />
|
||||
<option value="$PROJECT_DIR$/foudations/httpdns-tencent" />
|
||||
<option value="$PROJECT_DIR$/foudations/mogo-base-services-apk" />
|
||||
|
||||
@@ -203,7 +203,7 @@ android {
|
||||
// 分享时是否隐藏 adas
|
||||
buildConfigField 'boolean', 'IS_NEED_HIDE_ADAS_WHEN_SHARE', 'false'
|
||||
// 是否需要实时上报坐标
|
||||
buildConfigField 'boolean', 'IS_NEED_UPLOAD_COORDINATES_IN_TIME', 'false'
|
||||
buildConfigField 'boolean', 'IS_NEED_UPLOAD_COORDINATES_IN_TIME', 'true'
|
||||
}
|
||||
// 同上
|
||||
em4 {
|
||||
|
||||
@@ -8,7 +8,7 @@ project.dependencies {
|
||||
d8xxImplementation rootProject.ext.dependencies.httpdnsnoop
|
||||
d80xImplementation rootProject.ext.dependencies.httpdnsnoop
|
||||
em4Implementation rootProject.ext.dependencies.httpdnsnoop
|
||||
e8xxImplementation rootProject.ext.dependencies.httpdnsnoop
|
||||
e8xxImplementation rootProject.ext.dependencies.httpdnstencent
|
||||
f8xxImplementation rootProject.ext.dependencies.httpdnstencent
|
||||
f80xImplementation rootProject.ext.dependencies.httpdnstencent
|
||||
f8AmapImplementation rootProject.ext.dependencies.httpdnstencent
|
||||
@@ -20,7 +20,7 @@ project.dependencies {
|
||||
d8xxImplementation project(':foudations:httpdns-noop')
|
||||
d80xImplementation project(':foudations:httpdns-noop')
|
||||
em4Implementation project(':foudations:httpdns-noop')
|
||||
e8xxImplementation project(':foudations:httpdns-noop')
|
||||
e8xxImplementation project(':foudations:httpdns-tencent')
|
||||
f8xxImplementation project(':foudations:httpdns-tencent')
|
||||
f80xImplementation project(':foudations:httpdns-tencent')
|
||||
f8AmapImplementation project(':foudations:httpdns-tencent')
|
||||
|
||||
@@ -75,7 +75,7 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
|
||||
MogoModulePaths.addBaseModule( new MogoModule( MogoServicePaths.PATH_WIDGETS, MogoServicePaths.PATH_WIDGETS ) );
|
||||
if ( DebugConfig.isMapBased() ) {
|
||||
MogoModulePaths.addModule( new MogoModule( CallChatConstant.PROVIDER, CallChatConstant.MODULE_NAME ) );
|
||||
// MogoModulePaths.addModule( new MogoModule( CallChatConstant.PROVIDER, CallChatConstant.MODULE_NAME ) );
|
||||
}
|
||||
|
||||
MogoModulePaths.addBaseModule( new MogoModule( ShareConstants.TAG, ShareConstants.MODEL_NAME ) );
|
||||
|
||||
@@ -10,6 +10,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.httpdns.HttpDnsConst;
|
||||
import com.mogo.httpdns.IHttpDnsCallback;
|
||||
import com.mogo.httpdns.IMogoHttpDns;
|
||||
import com.mogo.httpdns.MogoHttpDnsHandler;
|
||||
@@ -76,7 +77,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
WorkThreadHandler.getInstance().post( new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
httpDns.getHttpDnsIp( "dnstest.zhidaozhixing.com", false, new IHttpDnsCallback() {
|
||||
httpDns.getHttpDnsIp( "dnstest.zhidaozhixing.com", HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_HTTP, false, new IHttpDnsCallback() {
|
||||
@Override
|
||||
public void onParsed( @Nullable String ip ) {
|
||||
StringBuilder sb = new StringBuilder( "httpDns ip:\n" );
|
||||
@@ -100,7 +101,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
WorkThreadHandler.getInstance().post( new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
httpDns.getHttpDnsIp( "dzt-city.zhidaozhixing.com", false, new IHttpDnsCallback() {
|
||||
httpDns.getHttpDnsIp( "dzt-city.zhidaozhixing.com", HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_HTTP, false, new IHttpDnsCallback() {
|
||||
@Override
|
||||
public void onParsed( @Nullable String ip ) {
|
||||
StringBuilder sb = new StringBuilder( "httpDns ip:\n" );
|
||||
@@ -121,7 +122,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private void renderResponse( ResponseBody body ) {
|
||||
StringBuilder sb = new StringBuilder( "httpDns ip:\n" );
|
||||
String ip = httpDns.getCachedHttpDnsIps( "dnstest.zhidaozhixing.com" );
|
||||
String ip = httpDns.getCachedHttpDnsIps( "dnstest.zhidaozhixing.com", HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_HTTP );
|
||||
sb.append( ip ).append( "\n" );
|
||||
sb.append( "\nserverIp: \n" ).append( body.result.serverIp ).append( "\n" );
|
||||
content.setText( sb.toString() );
|
||||
|
||||
@@ -14,4 +14,8 @@ class HttpDnsConst {
|
||||
|
||||
@Keep
|
||||
public static final String PATH = "/httpdns/api";
|
||||
|
||||
public static final int HTTP_DNS_ADDRESS_TYPE_HTTP = 0;
|
||||
public static final int HTTP_DNS_ADDRESS_TYPE_WS = 1;
|
||||
public static final int HTTP_DNS_ADDRESS_TYPE_IM = 2;
|
||||
}
|
||||
|
||||
@@ -27,36 +27,68 @@ interface IMogoHttpDns extends IProvider {
|
||||
@Nullable
|
||||
HttpDns dns();
|
||||
|
||||
// /**
|
||||
// * 获取缓存中的 dns ip地址
|
||||
// *
|
||||
// * @param host
|
||||
// * @return
|
||||
// */
|
||||
// @Nullable
|
||||
// String getCachedHttpDnsIps( String host );
|
||||
|
||||
/**
|
||||
* 获取缓存中的 dns ip地址
|
||||
*
|
||||
* @param host
|
||||
* 获取缓存中的dns ip地址
|
||||
* @param host domain
|
||||
* @param type 类型
|
||||
* @return
|
||||
*/
|
||||
@Nullable
|
||||
String getCachedHttpDnsIps( String host );
|
||||
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 useCache 是否使用缓存,是 - 如果没有缓存,则解析新地址、否 - 解析新地址,并将新地址缓存
|
||||
* dns解析
|
||||
* @param host
|
||||
* @param type
|
||||
* @param useCache
|
||||
* @param callback
|
||||
*/
|
||||
void getHttpDnsIp( String host, boolean useCache, IHttpDnsCallback callback );
|
||||
void getHttpDnsIp(String host, int type, boolean useCache, IHttpDnsCallback callback);
|
||||
|
||||
// /**
|
||||
// * 监听 ttl 回调
|
||||
// *
|
||||
// * @param host 域名
|
||||
// * @param callback
|
||||
// */
|
||||
// void addHttpDnsTtlCallback( String host, IHttpDnsTtlCallback callback );
|
||||
|
||||
/**
|
||||
* 监听 ttl 回调
|
||||
*
|
||||
* @param host 域名
|
||||
* 监听ttl回调
|
||||
* @param host
|
||||
* @param type
|
||||
* @param callback
|
||||
*/
|
||||
void addHttpDnsTtlCallback( String host, IHttpDnsTtlCallback callback );
|
||||
void addHttpDnsTtlCallback(String host, int type, IHttpDnsTtlCallback callback);
|
||||
|
||||
// /**
|
||||
// * 注销 ttl 回调
|
||||
// *
|
||||
// * @param host 域名
|
||||
// */
|
||||
// void removeHttpDnsTtlCallback( String host );
|
||||
|
||||
/**
|
||||
* 注销 ttl 回调
|
||||
*
|
||||
* @param host 域名
|
||||
* 注销ttl回调
|
||||
* @param host
|
||||
* @param type
|
||||
*/
|
||||
void removeHttpDnsTtlCallback( String host );
|
||||
void removeHttpDnsTtlCallback(String host,int type);
|
||||
}
|
||||
|
||||
1
foudations/httpdns-mogo/.gitignore
vendored
Normal file
1
foudations/httpdns-mogo/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
48
foudations/httpdns-mogo/build.gradle
Normal file
48
foudations/httpdns-mogo/build.gradle
Normal file
@@ -0,0 +1,48 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
// buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode Integer.valueOf(VERSION_CODE)
|
||||
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles "consumer-rules.pro"
|
||||
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments = [AROUTER_MODULE_NAME: project.getName()]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.3'
|
||||
|
||||
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')
|
||||
}
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
0
foudations/httpdns-mogo/consumer-rules.pro
Normal file
0
foudations/httpdns-mogo/consumer-rules.pro
Normal file
3
foudations/httpdns-mogo/gradle.properties
Normal file
3
foudations/httpdns-mogo/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
GROUP=com.mogo.httpdns
|
||||
POM_ARTIFACT_ID=httpdns-mogo
|
||||
VERSION_CODE=1
|
||||
21
foudations/httpdns-mogo/proguard-rules.pro
vendored
Normal file
21
foudations/httpdns-mogo/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.mogo.httpdns.mogo;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("com.mogo.httpdns.mogo.test", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
5
foudations/httpdns-mogo/src/main/AndroidManifest.xml
Normal file
5
foudations/httpdns-mogo/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.httpdns.mogo">
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.mogo.httpdns.mogo;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.commons.network.Utils;
|
||||
import com.mogo.httpdns.HttpDnsConst;
|
||||
import com.mogo.httpdns.IHttpDnsCallback;
|
||||
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.IHttpDnsConfig;
|
||||
import com.mogo.httpdnshelper.sdk.listener.OnAddressChangedListener;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.utils.network.HttpDns;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
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;
|
||||
|
||||
@Route( path = HttpDnsConst.PATH )
|
||||
public class MogoHttpDns implements IMogoHttpDns, HttpDns,OnAddressChangedListener{
|
||||
private final HttpDnsHelper httpDnsHelper = new HttpDnsHelper();
|
||||
@Nullable
|
||||
@Override
|
||||
public HttpDns dns() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCachedHttpDnsIps(String host, int type) {
|
||||
return httpDnsHelper.getHttpDnsCachedAddress(type, host);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHttpDnsIp(String host, int type, boolean useCache, IHttpDnsCallback callback) {
|
||||
if(useCache) {
|
||||
String address = httpDnsHelper.getHttpDnsCachedAddress(type, host);
|
||||
if (address != null) {
|
||||
callback.onParsed(address);
|
||||
}else{
|
||||
callback.onParsed(httpDnsHelper.getHttpDnsAddress(type, host));
|
||||
}
|
||||
}else {
|
||||
callback.onParsed(httpDnsHelper.getHttpDnsAddress(type, host));
|
||||
}
|
||||
}
|
||||
|
||||
private final Map<String, IHttpDnsTtlCallback> ttlCallbackMap = new ArrayMap<>();
|
||||
@Override
|
||||
public void addHttpDnsTtlCallback(String host, int type, IHttpDnsTtlCallback callback) {
|
||||
ttlCallbackMap.put(type + "-" + host, callback);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeHttpDnsTtlCallback(String host, int type) {
|
||||
ttlCallbackMap.remove(type + "-" + host);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(final Context context) {
|
||||
httpDnsHelper.init(context, new IHttpDnsConfig() {
|
||||
@NotNull
|
||||
@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());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDebugLog() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getSn() {
|
||||
return Utils.getSn();
|
||||
}
|
||||
});
|
||||
httpDnsHelper.setAddressChangedListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InetAddress> lookup(String hostname) throws UnknownHostException {
|
||||
String cacheIp = httpDnsHelper.getHttpDnsCachedAddress(HTTP_DNS_ADDRESS_TYPE_HTTP, hostname);
|
||||
if ( cacheIp == null || TextUtils.isEmpty( 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(@org.jetbrains.annotations.Nullable Map<String, String> map) {
|
||||
if (map != null) {
|
||||
for (String key : map.keySet()) {
|
||||
ttlCallbackMap.get(key).onTtl();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mogo.httpdns.mogo;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,9 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
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
|
||||
@@ -50,8 +53,13 @@ class TencentHttpDns implements IMogoHttpDns, HttpDns {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCachedHttpDnsIps( String host ) {
|
||||
return HttpDnsIpsCache.getHttpDnsIps( host );
|
||||
public String getCachedHttpDnsIps( String host,int type ) {
|
||||
String ip = HttpDnsIpsCache.getHttpDnsIps(host);
|
||||
if (ip == null) {
|
||||
return null;
|
||||
} else {
|
||||
return tailPort(ip, type);
|
||||
}
|
||||
}
|
||||
|
||||
private String getCacheOrParseIpIfNecessary( String host ) {
|
||||
@@ -66,7 +74,7 @@ class TencentHttpDns implements IMogoHttpDns, HttpDns {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHttpDnsIp( String host, boolean useCache, IHttpDnsCallback callback ) {
|
||||
public void getHttpDnsIp( String host,int type, boolean useCache, IHttpDnsCallback callback ) {
|
||||
String cacheIp = null;
|
||||
if ( useCache ) {
|
||||
cacheIp = getCacheOrParseIpIfNecessary( host );
|
||||
@@ -78,7 +86,7 @@ class TencentHttpDns implements IMogoHttpDns, HttpDns {
|
||||
}
|
||||
if ( !TextUtils.isEmpty( cacheIp ) ) {
|
||||
if ( callback != null ) {
|
||||
callback.onParsed( cacheIp );
|
||||
callback.onParsed( tailPort(cacheIp,type) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -88,12 +96,12 @@ class TencentHttpDns implements IMogoHttpDns, HttpDns {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHttpDnsTtlCallback( String host, IHttpDnsTtlCallback callback ) {
|
||||
public void addHttpDnsTtlCallback( String host,int type, IHttpDnsTtlCallback callback ) {
|
||||
HttpDnsIpsCache.addHttpDnsTtlCallback( host, callback );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeHttpDnsTtlCallback( String host ) {
|
||||
public void removeHttpDnsTtlCallback( String host,int type ) {
|
||||
HttpDnsIpsCache.removeHttpDnsTtlCallback( host );
|
||||
}
|
||||
|
||||
@@ -113,4 +121,15 @@ class TencentHttpDns implements IMogoHttpDns, HttpDns {
|
||||
HttpDnsIpsCache.loopDnsParse();
|
||||
sInited = true;
|
||||
}
|
||||
|
||||
private String tailPort(String ip, int type) {
|
||||
switch (type) {
|
||||
case HTTP_DNS_ADDRESS_TYPE_WS:
|
||||
return ip + ":4004";
|
||||
case HTTP_DNS_ADDRESS_TYPE_IM:
|
||||
return ip + ":4002";
|
||||
default:
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,9 @@ public class WebSocketConstant {
|
||||
private static final String HOST_QA = "ws://62.234.196.121";
|
||||
private static final String HOST_DEMO = "ws://62.234.196.121";
|
||||
private static final String HOST_RELEASE = "ws://62.234.196.121";
|
||||
// private static final String PORT = ":14001/ws";
|
||||
public static final String PORT = ":4004/ws";
|
||||
// private static final String PORT = ":14001/ws";
|
||||
public static final String PATH = "/ws";
|
||||
public static final String PORT = ":4004"+PATH;
|
||||
public static final String PROTOCOL = "ws://";
|
||||
|
||||
private static final String DOMAIN_DEV = "dzt-city.zhidaozhixing.com";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.base.websocket;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.httpdns.HttpDnsConst;
|
||||
import com.mogo.httpdns.IMogoHttpDns;
|
||||
import com.mogo.utils.ThreadPoolService;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -27,22 +28,22 @@ public class WebSocketDnsManager {
|
||||
public void getHttpDnsIp(WebSocketDns webSocketDns) {
|
||||
this.webSocketDns = webSocketDns;
|
||||
IMogoHttpDns mogoHttpDns = ARouter.getInstance().navigation(IMogoHttpDns.class);
|
||||
ThreadPoolService.execute(() -> mogoHttpDns.getHttpDnsIp(WebSocketConstant.getDomain(), false, ip -> {
|
||||
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;
|
||||
this.webSocketDns.getDnsIp((cacheIp != null ?
|
||||
WebSocketConstant.PROTOCOL + ip + WebSocketConstant.PORT :
|
||||
WebSocketConstant.PROTOCOL + ip + WebSocketConstant.PATH :
|
||||
WebSocketConstant.getSocketServer() + WebSocketConstant.PORT));
|
||||
}));
|
||||
mogoHttpDns.addHttpDnsTtlCallback(WebSocketConstant.getDomain(), () -> {
|
||||
mogoHttpDns.addHttpDnsTtlCallback(WebSocketConstant.getDomain(), HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_WS, () -> {
|
||||
Logger.d(TAG, "ttl callBack ,ready to getCache Dns IP");
|
||||
String dnsCacheIp = mogoHttpDns.getCachedHttpDnsIps(WebSocketConstant.getDomain());
|
||||
String dnsCacheIp = mogoHttpDns.getCachedHttpDnsIps(WebSocketConstant.getDomain(),HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_WS);
|
||||
if (dnsCacheIp == null) {
|
||||
return;
|
||||
}
|
||||
Logger.d(TAG, "获取缓存Dns IP : " + dnsCacheIp + " , 原缓存 IP : " + cacheIp);
|
||||
if (cacheIp != null && !cacheIp.equals(dnsCacheIp)) {
|
||||
this.webSocketDns.ttlIp(dnsCacheIp + WebSocketConstant.PORT);
|
||||
this.webSocketDns.ttlIp(dnsCacheIp + WebSocketConstant.PATH);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class WebSocketHandlerThread extends HandlerThread {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == MSG_SEND) {
|
||||
Logger.d(tag, "WebSocketHandlerThread handleMessage = " + msg.obj.toString());
|
||||
SocketClient.getInstance().getClientProxy().sendMessage(msg.obj.toString());
|
||||
WebSocketInstanceHolder.getClientProxy().sendMessage(msg.obj.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.mogo.base.websocket;
|
||||
|
||||
import com.mogo.websocket.SocketClient;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/12/24
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class WebSocketInstanceHolder {
|
||||
|
||||
private volatile static SocketClient sClient;
|
||||
|
||||
public static SocketClient getClientProxy() {
|
||||
if ( sClient == null ) {
|
||||
synchronized ( WebSocketInstanceHolder.class ) {
|
||||
if ( sClient == null ) {
|
||||
sClient = new SocketClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sClient;
|
||||
}
|
||||
}
|
||||
@@ -82,8 +82,8 @@ public class WebSocketManager implements IMogoWebSocketManager, ISocketMsgSettin
|
||||
@Override
|
||||
public void ttlIp(String url) {
|
||||
Logger.d(TAG,"ttlIp url : " + url);
|
||||
SocketClient.getInstance().getClientProxy().stop();
|
||||
SocketClient.getInstance().getClientProxy().disConnect();
|
||||
WebSocketInstanceHolder.getClientProxy().stop();
|
||||
WebSocketInstanceHolder.getClientProxy().disConnect();
|
||||
Logger.d(TAG,"ready to re initWebSocket : " + url);
|
||||
initWebSocket(url);
|
||||
}
|
||||
@@ -91,10 +91,10 @@ public class WebSocketManager implements IMogoWebSocketManager, ISocketMsgSettin
|
||||
}
|
||||
|
||||
private void initWebSocket(String ip){
|
||||
SocketClient.getInstance().getClientProxy().initSocketServer(ip);
|
||||
SocketClient.getInstance().getClientProxy().getMessageSettings(this);
|
||||
SocketClient.getInstance().getClientProxy().addISocketMsgCallBack(this);
|
||||
SocketClient.getInstance().getClientProxy().startConnect();
|
||||
WebSocketInstanceHolder.getClientProxy().initSocketServer(ip);
|
||||
WebSocketInstanceHolder.getClientProxy().getMessageSettings(this);
|
||||
WebSocketInstanceHolder.getClientProxy().addISocketMsgCallBack(this);
|
||||
WebSocketInstanceHolder.getClientProxy().startConnect();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -224,8 +224,8 @@ public class WebSocketManager implements IMogoWebSocketManager, ISocketMsgSettin
|
||||
@Override
|
||||
public void onConnectClose() {
|
||||
Logger.d(TAG, "websocket ready to reconnect");
|
||||
SocketClient.getInstance().getClientProxy().stop();
|
||||
SocketClient.getInstance().getClientProxy().reConnect();
|
||||
WebSocketInstanceHolder.getClientProxy().stop();
|
||||
WebSocketInstanceHolder.getClientProxy().reConnect();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.mogo.commons.layoutinflater;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.LayoutRes;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/12/23
|
||||
*
|
||||
* 系统实现的布局加载
|
||||
*/
|
||||
class OriginalLayoutInflater {
|
||||
|
||||
private static LayoutInflater sLayoutInflater;
|
||||
|
||||
public static void init( Context context ) {
|
||||
sLayoutInflater = LayoutInflater.from( context ).cloneInContext( context );
|
||||
}
|
||||
|
||||
public static View inflate( @LayoutRes int layoutId, ViewGroup container, boolean attachToRoot ) {
|
||||
return sLayoutInflater.inflate( layoutId, container, attachToRoot );
|
||||
}
|
||||
|
||||
public static View inflate( @LayoutRes int layoutId, ViewGroup container ) {
|
||||
return sLayoutInflater.inflate( layoutId, container, container != null );
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,8 @@ dependencies {
|
||||
implementation project(':foudations:mogo-commons')
|
||||
}
|
||||
|
||||
implementation 'com.zhidaoauto.machine:map:1.0.0-vr-7.4.4'
|
||||
// implementation 'com.zhidaoauto.machine:map:1.0.0-vr-7.4.5'
|
||||
implementation 'com.zhidaoauto.machine:map:1.0.0-vr-7.4.5-log-1'
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
|
||||
@@ -74,8 +74,8 @@ class GpsTester {
|
||||
break;
|
||||
case 2:
|
||||
try {
|
||||
readOneLineGpsDataAndSet2Map();
|
||||
sendEmptyMessageDelayed( 2, 0 );
|
||||
long time = readOneLineGpsDataAndSet2Map();
|
||||
sendEmptyMessageDelayed( 2, time );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -112,7 +112,6 @@ class GpsTester {
|
||||
if ( TextUtils.isEmpty( line ) ) {
|
||||
return 0;
|
||||
}
|
||||
int count = 0;
|
||||
long duration = 3;
|
||||
|
||||
|
||||
@@ -154,7 +153,6 @@ class GpsTester {
|
||||
step++;
|
||||
if ( step >= 50 ) {
|
||||
step = 0;
|
||||
count++;
|
||||
|
||||
long realDuration = mogoLocation.getDuration() + 75;
|
||||
realDuration = realDuration / 4;
|
||||
|
||||
@@ -34,7 +34,6 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
implementation rootProject.ext.dependencies.callchatprovider
|
||||
implementation "com.mogo.httpdns:httpdns-helper:1.0.1"
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
api rootProject.ext.dependencies.mogomap
|
||||
api rootProject.ext.dependencies.mogomapapi
|
||||
|
||||
@@ -24,7 +24,8 @@ import com.mogo.utils.logger.Logger;
|
||||
* desc : 地图Marker图标
|
||||
* version: 1.0
|
||||
*/
|
||||
public class MapMarkerView extends MapMarkerBaseView {
|
||||
public class
|
||||
MapMarkerView extends MapMarkerBaseView {
|
||||
private String TAG = "MapMarkerView";
|
||||
|
||||
private FrameLayout clMarkerTopView;
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
package com.mogo.module.common.utils;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.commons.network.Utils;
|
||||
import com.mogo.httpdnshelper.sdk.HttpDnsHelper;
|
||||
import com.mogo.httpdnshelper.sdk.IHttpDnsConfig;
|
||||
import com.mogo.httpdnshelper.sdk.bean.HttpDnsSimpleLocation;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* MogoHttpDnsHelper包装类
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class MogoHttpDnsUtil {
|
||||
private MogoHttpDnsUtil(){
|
||||
|
||||
}
|
||||
private final static MogoHttpDnsUtil INSTANCE = new MogoHttpDnsUtil();
|
||||
public static MogoHttpDnsUtil getInstance(){
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public void init(Context context){
|
||||
HttpDnsHelper.INSTANCE.init(context, new IHttpDnsConfig() {
|
||||
@NotNull
|
||||
@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());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDebugLog() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getSn() {
|
||||
return Utils.getSn();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public String getHttpAddress(){
|
||||
return HttpDnsHelper.INSTANCE.getHttpDnsAddress(HttpDnsHelper.HTTP_DNS_TYPE_HTTP);
|
||||
}
|
||||
|
||||
public String getWsAddress(){
|
||||
return HttpDnsHelper.INSTANCE.getHttpDnsAddress(HttpDnsHelper.HTTP_DNS_TYPE_WS);
|
||||
}
|
||||
|
||||
public void release(){
|
||||
HttpDnsHelper.INSTANCE.release();
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@ import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.utils.MogoHttpDnsUtil;
|
||||
import com.mogo.module.main.EventDispatchCenter;
|
||||
import com.mogo.module.main.cards.MogoModulesManager;
|
||||
import com.mogo.module.main.delaycheck.DelayCheckUtil;
|
||||
@@ -53,8 +52,6 @@ class MogoMainService extends Service implements IMogoLocationListener {
|
||||
// 开启延时检测
|
||||
DelayCheckUtil delayCheckUtil = new DelayCheckUtil(this);
|
||||
delayCheckUtil.waitingForCheck();
|
||||
|
||||
MogoHttpDnsUtil.getInstance().init(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -111,6 +108,5 @@ class MogoMainService extends Service implements IMogoLocationListener {
|
||||
mLocationClient = null;
|
||||
}
|
||||
mServiceApis = null;
|
||||
MogoHttpDnsUtil.getInstance().release();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ import java.util.List;
|
||||
public class MockIntentHandler implements IntentHandler {
|
||||
|
||||
private static final String TAG = "MockIntentHandler";
|
||||
private IMogoMarker centerMarker;
|
||||
|
||||
@Override
|
||||
public void handle( Context context, Intent intent ) {
|
||||
@@ -364,6 +365,24 @@ public class MockIntentHandler implements IntentHandler {
|
||||
MogoApisHandler.getInstance().getApis().getMapFrameControllerApi().changeTo2dMode();
|
||||
}
|
||||
break;
|
||||
case 35:
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().testGpsData();
|
||||
break;
|
||||
case 36:
|
||||
MogoLatLng center = MogoApisHandler.getInstance().getApis()
|
||||
.getMapServiceApi().getMapUIController()
|
||||
.getWindowCenterLocation();
|
||||
centerMarker = MogoApisHandler.getInstance().getApis()
|
||||
.getMapServiceApi().getMarkerManager( context )
|
||||
.addMarker( TAG, new MogoMarkerOptions()
|
||||
.position( center )
|
||||
.icon( BitmapFactory.decodeResource( context.getResources(), R.drawable.bg_map_marker_red ) ) );
|
||||
break;
|
||||
case 37:
|
||||
if ( centerMarker != null ) {
|
||||
centerMarker.destroy();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.mogo.module.service.websocket.OnePerSecondSendContent;
|
||||
import com.mogo.service.adas.entity.ADASRecognizedResult;
|
||||
import com.mogo.service.connection.IMogoOnWebSocketMessageListener;
|
||||
import com.mogo.service.connection.WebSocketMsgType;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -104,6 +105,7 @@ class SnapshotUploadInTime implements MogoRTKLocation.RTKLocationListener {
|
||||
|
||||
if ( content.self == null &&
|
||||
( content.adas == null || content.adas.isEmpty() ) ) {
|
||||
Logger.d( TAG, "no information 2 sent" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class AdasObjectUtils {
|
||||
recognizedResults.add( result );
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
return recognizedResults;
|
||||
@@ -65,8 +65,13 @@ class AdasObjectUtils {
|
||||
if ( rectBean == null ) {
|
||||
return null;
|
||||
}
|
||||
if( rectBean.getLat() < 1){
|
||||
return null;
|
||||
}
|
||||
ADASRecognizedResult result = new ADASRecognizedResult();
|
||||
result.uuid = rectBean.getUuid();
|
||||
|
||||
|
||||
double amapCoord[] = CoordinateUtils.transformFromWGSToGCJ( rectBean.getLat(), rectBean.getLon() );
|
||||
if ( amapCoord != null ) {
|
||||
result.lat = amapCoord[0];
|
||||
|
||||
@@ -547,8 +547,13 @@ public class MogoADASController implements IMogoADASController {
|
||||
@Override
|
||||
public List< ADASRecognizedResult > getLastADASRecognizedResult() {
|
||||
RectInfo rectInfo = mLastFrameData;
|
||||
List< ADASRecognizedResult > recognizedResultList = AdasObjectUtils.fromAdasObject( rectInfo );
|
||||
return recognizedResultList;
|
||||
List< ADASRecognizedResult > recognizedResultList = null;
|
||||
try {
|
||||
recognizedResultList = AdasObjectUtils.fromAdasObject( rectInfo );
|
||||
return recognizedResultList;
|
||||
} catch ( Exception e ) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
include ':foudations:httpdns-mogo'
|
||||
include ':modules:mogo-module-smp'
|
||||
include ':app2'
|
||||
include ':foudations:httpdns-base'
|
||||
|
||||
Reference in New Issue
Block a user