Merge remote-tracking branch 'origin/dev_merge_shunyi_vr_map' 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$/app2" />
|
||||||
<option value="$PROJECT_DIR$/foudations" />
|
<option value="$PROJECT_DIR$/foudations" />
|
||||||
<option value="$PROJECT_DIR$/foudations/httpdns-base" />
|
<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-noop" />
|
||||||
<option value="$PROJECT_DIR$/foudations/httpdns-tencent" />
|
<option value="$PROJECT_DIR$/foudations/httpdns-tencent" />
|
||||||
<option value="$PROJECT_DIR$/foudations/mogo-base-services-apk" />
|
<option value="$PROJECT_DIR$/foudations/mogo-base-services-apk" />
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||||||
|
|
||||||
import com.alibaba.android.arouter.launcher.ARouter;
|
import com.alibaba.android.arouter.launcher.ARouter;
|
||||||
import com.mogo.commons.network.SubscribeImpl;
|
import com.mogo.commons.network.SubscribeImpl;
|
||||||
|
import com.mogo.httpdns.HttpDnsConst;
|
||||||
import com.mogo.httpdns.IHttpDnsCallback;
|
import com.mogo.httpdns.IHttpDnsCallback;
|
||||||
import com.mogo.httpdns.IMogoHttpDns;
|
import com.mogo.httpdns.IMogoHttpDns;
|
||||||
import com.mogo.httpdns.MogoHttpDnsHandler;
|
import com.mogo.httpdns.MogoHttpDnsHandler;
|
||||||
@@ -76,7 +77,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
WorkThreadHandler.getInstance().post( new Runnable() {
|
WorkThreadHandler.getInstance().post( new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
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
|
@Override
|
||||||
public void onParsed( @Nullable String ip ) {
|
public void onParsed( @Nullable String ip ) {
|
||||||
StringBuilder sb = new StringBuilder( "httpDns ip:\n" );
|
StringBuilder sb = new StringBuilder( "httpDns ip:\n" );
|
||||||
@@ -100,7 +101,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
WorkThreadHandler.getInstance().post( new Runnable() {
|
WorkThreadHandler.getInstance().post( new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
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
|
@Override
|
||||||
public void onParsed( @Nullable String ip ) {
|
public void onParsed( @Nullable String ip ) {
|
||||||
StringBuilder sb = new StringBuilder( "httpDns ip:\n" );
|
StringBuilder sb = new StringBuilder( "httpDns ip:\n" );
|
||||||
@@ -121,7 +122,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private void renderResponse( ResponseBody body ) {
|
private void renderResponse( ResponseBody body ) {
|
||||||
StringBuilder sb = new StringBuilder( "httpDns ip:\n" );
|
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( ip ).append( "\n" );
|
||||||
sb.append( "\nserverIp: \n" ).append( body.result.serverIp ).append( "\n" );
|
sb.append( "\nserverIp: \n" ).append( body.result.serverIp ).append( "\n" );
|
||||||
content.setText( sb.toString() );
|
content.setText( sb.toString() );
|
||||||
|
|||||||
@@ -14,4 +14,8 @@ class HttpDnsConst {
|
|||||||
|
|
||||||
@Keep
|
@Keep
|
||||||
public static final String PATH = "/httpdns/api";
|
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
|
@Nullable
|
||||||
HttpDns dns();
|
HttpDns dns();
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 获取缓存中的 dns ip地址
|
||||||
|
// *
|
||||||
|
// * @param host
|
||||||
|
// * @return
|
||||||
|
// */
|
||||||
|
// @Nullable
|
||||||
|
// String getCachedHttpDnsIps( String host );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取缓存中的 dns ip地址
|
* 获取缓存中的dns ip地址
|
||||||
*
|
* @param host domain
|
||||||
* @param host
|
* @param type 类型
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Nullable
|
String getCachedHttpDnsIps(String host, int type);
|
||||||
String getCachedHttpDnsIps( String host );
|
//
|
||||||
|
// /**
|
||||||
|
// * dns 解析
|
||||||
|
// *
|
||||||
|
// * @param host 域名
|
||||||
|
// * @param useCache 是否使用缓存,是 - 如果没有缓存,则解析新地址、否 - 解析新地址,并将新地址缓存
|
||||||
|
// * @param callback
|
||||||
|
// */
|
||||||
|
// void getHttpDnsIp( String host, boolean useCache, IHttpDnsCallback callback );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dns 解析
|
* dns解析
|
||||||
*
|
* @param host
|
||||||
* @param host 域名
|
* @param type
|
||||||
* @param useCache 是否使用缓存,是 - 如果没有缓存,则解析新地址、否 - 解析新地址,并将新地址缓存
|
* @param useCache
|
||||||
* @param callback
|
* @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 回调
|
* 监听ttl回调
|
||||||
*
|
* @param host
|
||||||
* @param host 域名
|
* @param type
|
||||||
* @param callback
|
* @param callback
|
||||||
*/
|
*/
|
||||||
void addHttpDnsTtlCallback( String host, IHttpDnsTtlCallback callback );
|
void addHttpDnsTtlCallback(String host, int type, IHttpDnsTtlCallback callback);
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 注销 ttl 回调
|
||||||
|
// *
|
||||||
|
// * @param host 域名
|
||||||
|
// */
|
||||||
|
// void removeHttpDnsTtlCallback( String host );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注销 ttl 回调
|
* 注销ttl回调
|
||||||
*
|
* @param host
|
||||||
* @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.Collections;
|
||||||
import java.util.List;
|
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
|
public
|
||||||
/**
|
/**
|
||||||
* @author congtaowang
|
* @author congtaowang
|
||||||
@@ -50,8 +53,13 @@ class TencentHttpDns implements IMogoHttpDns, HttpDns {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCachedHttpDnsIps( String host ) {
|
public String getCachedHttpDnsIps( String host,int type ) {
|
||||||
return HttpDnsIpsCache.getHttpDnsIps( host );
|
String ip = HttpDnsIpsCache.getHttpDnsIps(host);
|
||||||
|
if (ip == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return tailPort(ip, type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCacheOrParseIpIfNecessary( String host ) {
|
private String getCacheOrParseIpIfNecessary( String host ) {
|
||||||
@@ -66,7 +74,7 @@ class TencentHttpDns implements IMogoHttpDns, HttpDns {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getHttpDnsIp( String host, boolean useCache, IHttpDnsCallback callback ) {
|
public void getHttpDnsIp( String host,int type, boolean useCache, IHttpDnsCallback callback ) {
|
||||||
String cacheIp = null;
|
String cacheIp = null;
|
||||||
if ( useCache ) {
|
if ( useCache ) {
|
||||||
cacheIp = getCacheOrParseIpIfNecessary( host );
|
cacheIp = getCacheOrParseIpIfNecessary( host );
|
||||||
@@ -78,7 +86,7 @@ class TencentHttpDns implements IMogoHttpDns, HttpDns {
|
|||||||
}
|
}
|
||||||
if ( !TextUtils.isEmpty( cacheIp ) ) {
|
if ( !TextUtils.isEmpty( cacheIp ) ) {
|
||||||
if ( callback != null ) {
|
if ( callback != null ) {
|
||||||
callback.onParsed( cacheIp );
|
callback.onParsed( tailPort(cacheIp,type) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,12 +96,12 @@ class TencentHttpDns implements IMogoHttpDns, HttpDns {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addHttpDnsTtlCallback( String host, IHttpDnsTtlCallback callback ) {
|
public void addHttpDnsTtlCallback( String host,int type, IHttpDnsTtlCallback callback ) {
|
||||||
HttpDnsIpsCache.addHttpDnsTtlCallback( host, callback );
|
HttpDnsIpsCache.addHttpDnsTtlCallback( host, callback );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeHttpDnsTtlCallback( String host ) {
|
public void removeHttpDnsTtlCallback( String host,int type ) {
|
||||||
HttpDnsIpsCache.removeHttpDnsTtlCallback( host );
|
HttpDnsIpsCache.removeHttpDnsTtlCallback( host );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,4 +121,15 @@ class TencentHttpDns implements IMogoHttpDns, HttpDns {
|
|||||||
HttpDnsIpsCache.loopDnsParse();
|
HttpDnsIpsCache.loopDnsParse();
|
||||||
sInited = true;
|
sInited = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String tailPort(String ip, int type) {
|
||||||
|
switch (type) {
|
||||||
|
case HTTP_DNS_ADDRESS_TYPE_WS:
|
||||||
|
return ip + ":4003";
|
||||||
|
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_QA = "ws://62.234.196.121";
|
||||||
private static final String HOST_DEMO = "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 HOST_RELEASE = "ws://62.234.196.121";
|
||||||
// private static final String PORT = ":14001/ws";
|
// private static final String PORT = ":14001/ws";
|
||||||
public static final String PORT = ":4004/ws";
|
public static final String PATH = "/ws";
|
||||||
|
public static final String PORT = ":4004"+PATH;
|
||||||
public static final String PROTOCOL = "ws://";
|
public static final String PROTOCOL = "ws://";
|
||||||
|
|
||||||
private static final String DOMAIN_DEV = "dzt-city.zhidaozhixing.com";
|
private static final String DOMAIN_DEV = "dzt-city.zhidaozhixing.com";
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.mogo.base.websocket;
|
package com.mogo.base.websocket;
|
||||||
|
|
||||||
import com.alibaba.android.arouter.launcher.ARouter;
|
import com.alibaba.android.arouter.launcher.ARouter;
|
||||||
|
import com.mogo.httpdns.HttpDnsConst;
|
||||||
import com.mogo.httpdns.IMogoHttpDns;
|
import com.mogo.httpdns.IMogoHttpDns;
|
||||||
import com.mogo.utils.ThreadPoolService;
|
import com.mogo.utils.ThreadPoolService;
|
||||||
import com.mogo.utils.logger.Logger;
|
import com.mogo.utils.logger.Logger;
|
||||||
@@ -27,22 +28,22 @@ public class WebSocketDnsManager {
|
|||||||
public void getHttpDnsIp(WebSocketDns webSocketDns) {
|
public void getHttpDnsIp(WebSocketDns webSocketDns) {
|
||||||
this.webSocketDns = webSocketDns;
|
this.webSocketDns = webSocketDns;
|
||||||
IMogoHttpDns mogoHttpDns = ARouter.getInstance().navigation(IMogoHttpDns.class);
|
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");
|
Logger.d(TAG, "getHttpDnsIp ip : " + ip + " , 得到Dns IP,准备回调 初始化webSocket");
|
||||||
this.cacheIp = ip;
|
this.cacheIp = ip;
|
||||||
this.webSocketDns.getDnsIp((cacheIp != null ?
|
this.webSocketDns.getDnsIp((cacheIp != null ?
|
||||||
WebSocketConstant.PROTOCOL + ip + WebSocketConstant.PORT :
|
WebSocketConstant.PROTOCOL + ip + WebSocketConstant.PATH :
|
||||||
WebSocketConstant.getSocketServer() + WebSocketConstant.PORT));
|
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");
|
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) {
|
if (dnsCacheIp == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Logger.d(TAG, "获取缓存Dns IP : " + dnsCacheIp + " , 原缓存 IP : " + cacheIp);
|
Logger.d(TAG, "获取缓存Dns IP : " + dnsCacheIp + " , 原缓存 IP : " + cacheIp);
|
||||||
if (cacheIp != null && !cacheIp.equals(dnsCacheIp)) {
|
if (cacheIp != null && !cacheIp.equals(dnsCacheIp)) {
|
||||||
this.webSocketDns.ttlIp(dnsCacheIp + WebSocketConstant.PORT);
|
this.webSocketDns.ttlIp(dnsCacheIp + WebSocketConstant.PATH);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.mogo.commons;
|
|||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -59,7 +60,7 @@ public abstract class AbsMogoApplication extends Application {
|
|||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
// 在设置皮肤布局填充器之前进行克隆一个出来
|
// 在设置皮肤布局填充器之前进行克隆一个出来
|
||||||
mLayoutInflaterNoSkin = LayoutInflater.from(this).cloneInContext(this);
|
mLayoutInflaterNoSkin = LayoutInflater.from(new ContextThemeWrapper(this, R.style.Theme_AppCompat)).cloneInContext(new ContextThemeWrapper(this, R.style.Theme_AppCompat));
|
||||||
sApp = this;
|
sApp = this;
|
||||||
initARouter();
|
initARouter();
|
||||||
if ( shouldInit() ) {
|
if ( shouldInit() ) {
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
package com.mogo.module.extensions.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.GET;
|
|
||||||
import retrofit2.http.POST;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 时延验证相关接口
|
|
||||||
*
|
|
||||||
* @author tongchenfei
|
|
||||||
*/
|
|
||||||
public interface DelayCheckApiServices {
|
|
||||||
|
|
||||||
@GET("/yycp-test-service/net/delay/heartbeat")
|
|
||||||
Observable<BaseData> emptyInterface();
|
|
||||||
|
|
||||||
@POST("/yycp-test-service/net/delay/log")
|
|
||||||
@FormUrlEncoded
|
|
||||||
Observable<BaseData> uploadDelayCheckData(@FieldMap Map<String, Object> params);
|
|
||||||
}
|
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
package com.mogo.module.extensions.utils;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Message;
|
|
||||||
import android.os.SystemClock;
|
|
||||||
|
|
||||||
import com.mogo.commons.data.BaseData;
|
|
||||||
import com.mogo.commons.network.SubscribeImpl;
|
|
||||||
import com.mogo.commons.network.Utils;
|
|
||||||
import com.mogo.map.location.MogoLocation;
|
|
||||||
import com.mogo.module.common.MogoApisHandler;
|
|
||||||
import com.mogo.module.extensions.net.DelayCheckApiServices;
|
|
||||||
import com.mogo.module.extensions.net.DztHttpConstant;
|
|
||||||
import com.mogo.utils.NetworkUtils;
|
|
||||||
import com.mogo.utils.network.RequestOptions;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import io.reactivex.schedulers.Schedulers;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 延时验证工具类
|
|
||||||
*
|
|
||||||
* @author tongchenfei
|
|
||||||
*/
|
|
||||||
public class DelayCheckUtil implements Handler.Callback {
|
|
||||||
|
|
||||||
private final Handler handler = new Handler(this);
|
|
||||||
|
|
||||||
private static final int MSG_CHECK_NET_CONNECT_STATUS = 1001;
|
|
||||||
private static final long FIRST_CHECK_NET_CONNECT_STATUS_DELAY = 10 * 60 * 1000;
|
|
||||||
private static final long CHECK_NET_CONNECT_STATUS_DELAY = 5000L;
|
|
||||||
|
|
||||||
private static final int MSG_START_DELAY_CHECK = 1002;
|
|
||||||
private static final long DELAY_CHECK_DELAY = 10 * 60 * 1000;
|
|
||||||
|
|
||||||
private final Context context;
|
|
||||||
|
|
||||||
public DelayCheckUtil(Context context) {
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 每5s检查一下网络状态,网络状态为连接状态时,开始空接口请求以及后续的参数上报
|
|
||||||
*/
|
|
||||||
public void waitingForCheck() {
|
|
||||||
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, FIRST_CHECK_NET_CONNECT_STATUS_DELAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
private long requestTime, netDelay, requestSystemTime;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handleMessage(Message msg) {
|
|
||||||
switch (msg.what) {
|
|
||||||
case MSG_CHECK_NET_CONNECT_STATUS:
|
|
||||||
if (NetworkUtils.isConnected(context)) {
|
|
||||||
handler.sendEmptyMessage(MSG_START_DELAY_CHECK);
|
|
||||||
} else {
|
|
||||||
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case MSG_START_DELAY_CHECK:
|
|
||||||
// 请求空接口
|
|
||||||
startEmptyRequest();
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startEmptyRequest() {
|
|
||||||
requestTime = SystemClock.elapsedRealtime();
|
|
||||||
requestSystemTime = System.currentTimeMillis();
|
|
||||||
MogoApisHandler.getInstance().getApis().getNetworkApi()
|
|
||||||
.create(DelayCheckApiServices.class, DztHttpConstant.getBaseUrl())
|
|
||||||
.emptyInterface().subscribeOn(Schedulers.io()).observeOn(Schedulers.io())
|
|
||||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(context)) {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(BaseData o) {
|
|
||||||
super.onSuccess(o);
|
|
||||||
netDelay = SystemClock.elapsedRealtime() - requestTime;
|
|
||||||
startUpload();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Throwable e) {
|
|
||||||
super.onError(e);
|
|
||||||
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(String message, int code) {
|
|
||||||
super.onError(message, code);
|
|
||||||
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startUpload() {
|
|
||||||
MogoLocation lastLocation = MogoApisHandler.getInstance().getApis().getMapServiceApi().getSingletonLocationClient(context).getLastKnowLocation();
|
|
||||||
if (lastLocation == null) {
|
|
||||||
handler.sendEmptyMessageDelayed(MSG_START_DELAY_CHECK, DELAY_CHECK_DELAY);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Map<String, Object> params = new HashMap<>(8);
|
|
||||||
params.put("sn", Utils.getSn());
|
|
||||||
params.put("startTime", requestSystemTime);
|
|
||||||
params.put("endTime", System.currentTimeMillis());
|
|
||||||
params.put("netState", NetworkUtils.netStrengthLevel);
|
|
||||||
params.put("place", lastLocation.getAddress());
|
|
||||||
params.put("cityCode", lastLocation.getCityCode());
|
|
||||||
params.put("lat", lastLocation.getLatitude());
|
|
||||||
params.put("lon", lastLocation.getLongitude());
|
|
||||||
|
|
||||||
MogoApisHandler.getInstance().getApis().getNetworkApi()
|
|
||||||
.create(DelayCheckApiServices.class, DztHttpConstant.getBaseUrl())
|
|
||||||
.uploadDelayCheckData(params).observeOn(Schedulers.io()).subscribeOn(Schedulers.io())
|
|
||||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(context)) {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(BaseData o) {
|
|
||||||
super.onSuccess(o);
|
|
||||||
|
|
||||||
handler.sendEmptyMessageDelayed(MSG_START_DELAY_CHECK, DELAY_CHECK_DELAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(String message, int code) {
|
|
||||||
super.onError(message, code);
|
|
||||||
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Throwable e) {
|
|
||||||
super.onError(e);
|
|
||||||
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -292,12 +292,12 @@ public class TopViewAnimHelper {
|
|||||||
int scene = 0;
|
int scene = 0;
|
||||||
if (animNavInfoView.isVisible()) {
|
if (animNavInfoView.isVisible()) {
|
||||||
scene = Scene.NAVI_WITH_ROAD_EVENT;
|
scene = Scene.NAVI_WITH_ROAD_EVENT;
|
||||||
animNavInfoView.animate().translationY(computeNaviMarginTop(child.getHeight())).start();
|
animNavInfoView.animate().translationY(computeNaviMarginTop(params.height)).start();
|
||||||
animNavInfoView.exchangeToSmall(true);
|
animNavInfoView.exchangeToSmall(true);
|
||||||
} else {
|
} else {
|
||||||
scene = Scene.AIMLESS_WITH_ROAD_EVENT;
|
scene = Scene.AIMLESS_WITH_ROAD_EVENT;
|
||||||
}
|
}
|
||||||
topContainer.animate().translationY(child.getHeight()).setListener(mainAnimListener).start();
|
topContainer.animate().translationY(params.height).setListener(mainAnimListener).start();
|
||||||
Logger.d(TAG, "show top setMapCenterPointByScene: " + scene);
|
Logger.d(TAG, "show top setMapCenterPointByScene: " + scene);
|
||||||
MapCenterPointStrategy.setMapCenterPointByScene(mogoMapUIController, scene);
|
MapCenterPointStrategy.setMapCenterPointByScene(mogoMapUIController, scene);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.mogo.module.main.delaycheck;
|
||||||
|
|
||||||
|
import com.mogo.commons.data.BaseData;
|
||||||
|
|
||||||
|
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.GET;
|
||||||
|
import retrofit2.http.Headers;
|
||||||
|
import retrofit2.http.POST;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时延验证相关接口
|
||||||
|
*
|
||||||
|
* @author tongchenfei
|
||||||
|
*/
|
||||||
|
public interface DelayCheckApiServices {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 空接口
|
||||||
|
* @return 什么都不返回
|
||||||
|
*/
|
||||||
|
@GET("/yycp-test-service/net/delay/heartbeat")
|
||||||
|
Observable<BaseData> emptyInterface();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时延上报接口 接口文档如下
|
||||||
|
* http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=48967034
|
||||||
|
* @param params 相关参数,详见文档
|
||||||
|
* @return 相关返回值,详见文档
|
||||||
|
*/
|
||||||
|
@POST("/yycp-test-service/net/delay/log")
|
||||||
|
@Headers({"Content-type:application/json;charset=UTF-8"})
|
||||||
|
Observable<DelayCheckResponse> uploadDelayCheckData(@Body RequestBody params);
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.mogo.module.main.delaycheck;
|
||||||
|
|
||||||
|
import com.mogo.commons.debug.DebugConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dzt base url
|
||||||
|
*
|
||||||
|
* @author tongchenfei
|
||||||
|
*/
|
||||||
|
public class DelayCheckHttpConstant {
|
||||||
|
public static final String HOST_DEV = "http://dzt-test.zhidaozhixing.com";
|
||||||
|
public static final String HOST_TEST = "http://dzt-test.zhidaozhixing.com";
|
||||||
|
public static final String HOST_DEMO = "http://dzt-show.zhidaozhixing.com";
|
||||||
|
public static final String HOST_PRODUCT = "http://dzt.zhidaozhixing.com";
|
||||||
|
|
||||||
|
public static String getBaseUrl(){
|
||||||
|
switch ( DebugConfig.getNetMode() ) {
|
||||||
|
case DebugConfig.NET_MODE_DEV:
|
||||||
|
return HOST_DEV;
|
||||||
|
case DebugConfig.NET_MODE_QA:
|
||||||
|
return HOST_TEST;
|
||||||
|
case DebugConfig.NET_MODE_DEMO:
|
||||||
|
return HOST_DEMO;
|
||||||
|
default:
|
||||||
|
return HOST_PRODUCT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.mogo.module.main.delaycheck;
|
||||||
|
|
||||||
|
import com.mogo.commons.data.BaseData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 延迟检测response
|
||||||
|
*
|
||||||
|
* @author tongchenfei
|
||||||
|
*/
|
||||||
|
public class DelayCheckResponse extends BaseData {
|
||||||
|
private DelayCheckResult result;
|
||||||
|
|
||||||
|
public DelayCheckResult getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResult(DelayCheckResult result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "DelayCheckResponse{" +
|
||||||
|
"result=" + result +
|
||||||
|
", code=" + code +
|
||||||
|
", msg='" + msg + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.mogo.module.main.delaycheck;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 延迟检查返回结果
|
||||||
|
*
|
||||||
|
* @author tongchenfei
|
||||||
|
*/
|
||||||
|
public class DelayCheckResult {
|
||||||
|
/**
|
||||||
|
* 是否保持心跳
|
||||||
|
*/
|
||||||
|
private boolean necessary;
|
||||||
|
/**
|
||||||
|
* 心跳间隔,单位 s
|
||||||
|
*/
|
||||||
|
private int beatSeconds;
|
||||||
|
|
||||||
|
public boolean isNecessary() {
|
||||||
|
return necessary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNecessary(boolean necessary) {
|
||||||
|
this.necessary = necessary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBeatSeconds() {
|
||||||
|
return beatSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBeatSeconds(int beatSeconds) {
|
||||||
|
this.beatSeconds = beatSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "DelayCheckResult{" +
|
||||||
|
"necessary=" + necessary +
|
||||||
|
", beatSeconds=" + beatSeconds +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
package com.mogo.module.main.delaycheck;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时延检测上报请求参数
|
||||||
|
*
|
||||||
|
* @author tongchenfei
|
||||||
|
*/
|
||||||
|
public class DelayCheckUploadRequest {
|
||||||
|
private String sn;
|
||||||
|
private long startTime;
|
||||||
|
private long endTime;
|
||||||
|
/**
|
||||||
|
* 请求时长
|
||||||
|
*/
|
||||||
|
private long burning;
|
||||||
|
/**
|
||||||
|
* 信号强度
|
||||||
|
*/
|
||||||
|
private int netState;
|
||||||
|
private String place;
|
||||||
|
private String cityCode;
|
||||||
|
private double lat;
|
||||||
|
private double lon;
|
||||||
|
|
||||||
|
public String getSn() {
|
||||||
|
return sn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSn(String sn) {
|
||||||
|
this.sn = sn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartTime(long startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getEndTime() {
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndTime(long endTime) {
|
||||||
|
this.endTime = endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getBurning() {
|
||||||
|
return burning;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBurning(long burning) {
|
||||||
|
this.burning = burning;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNetState() {
|
||||||
|
return netState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNetState(int netState) {
|
||||||
|
this.netState = netState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPlace() {
|
||||||
|
return place;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlace(String place) {
|
||||||
|
this.place = place;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "DelayCheckUploadRequest{" +
|
||||||
|
"sn='" + sn + '\'' +
|
||||||
|
", startTime=" + startTime +
|
||||||
|
", endTime=" + endTime +
|
||||||
|
", burning=" + burning +
|
||||||
|
", netState=" + netState +
|
||||||
|
", place='" + place + '\'' +
|
||||||
|
", cityCode='" + cityCode + '\'' +
|
||||||
|
", lat=" + lat +
|
||||||
|
", lon=" + lon +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
package com.mogo.module.main.delaycheck;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.os.SystemClock;
|
||||||
|
|
||||||
|
import com.mogo.commons.data.BaseData;
|
||||||
|
import com.mogo.commons.network.SubscribeImpl;
|
||||||
|
import com.mogo.commons.network.Utils;
|
||||||
|
import com.mogo.map.location.MogoLocation;
|
||||||
|
import com.mogo.module.common.MogoApisHandler;
|
||||||
|
import com.mogo.utils.NetworkUtils;
|
||||||
|
import com.mogo.utils.logger.Logger;
|
||||||
|
import com.mogo.utils.network.RequestOptions;
|
||||||
|
import com.mogo.utils.network.utils.GsonUtil;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
import okhttp3.MediaType;
|
||||||
|
import okhttp3.RequestBody;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 延时验证工具类
|
||||||
|
*
|
||||||
|
* @author tongchenfei
|
||||||
|
*/
|
||||||
|
public class DelayCheckUtil implements Handler.Callback {
|
||||||
|
private static final String TAG = "DelayCheckUtil";
|
||||||
|
private final Handler handler = new Handler(this);
|
||||||
|
|
||||||
|
private static final int MSG_CHECK_NET_CONNECT_STATUS = 1001;
|
||||||
|
/**
|
||||||
|
* 首次延时检测时间间隔,暂定10分钟,等待机器稳定后再做打算
|
||||||
|
*/
|
||||||
|
private static final long FIRST_CHECK_NET_CONNECT_STATUS_DELAY = 10 * 60 * 1000;
|
||||||
|
private static final long CHECK_NET_CONNECT_STATUS_DELAY = 5000L;
|
||||||
|
|
||||||
|
private static final int MSG_START_DELAY_CHECK = 1002;
|
||||||
|
/**
|
||||||
|
* 默认检测时间间隔,若服务端正确返回,以服务端返回为主
|
||||||
|
*/
|
||||||
|
private static final long DELAY_CHECK_DELAY = 10 * 60 * 1000;
|
||||||
|
|
||||||
|
private final Context context;
|
||||||
|
|
||||||
|
public DelayCheckUtil(Context context) {
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每5s检查一下网络状态,网络状态为连接状态时,开始空接口请求以及后续的参数上报
|
||||||
|
*/
|
||||||
|
public void waitingForCheck() {
|
||||||
|
Logger.d(TAG, "waitingForCheck===");
|
||||||
|
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, FIRST_CHECK_NET_CONNECT_STATUS_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private long requestTime, netDelay, requestStartSystemTime,requestEndSystem;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handleMessage(Message msg) {
|
||||||
|
switch (msg.what) {
|
||||||
|
case MSG_CHECK_NET_CONNECT_STATUS:
|
||||||
|
if (NetworkUtils.isConnected(context)) {
|
||||||
|
handler.sendEmptyMessage(MSG_START_DELAY_CHECK);
|
||||||
|
} else {
|
||||||
|
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case MSG_START_DELAY_CHECK:
|
||||||
|
// 请求空接口
|
||||||
|
startEmptyRequest();
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startEmptyRequest() {
|
||||||
|
Logger.d(TAG, "start empty request");
|
||||||
|
requestTime = SystemClock.elapsedRealtime();
|
||||||
|
requestStartSystemTime = System.currentTimeMillis();
|
||||||
|
MogoApisHandler.getInstance().getApis().getNetworkApi()
|
||||||
|
.create(DelayCheckApiServices.class, DelayCheckHttpConstant.getBaseUrl())
|
||||||
|
.emptyInterface().subscribeOn(Schedulers.io()).observeOn(Schedulers.io())
|
||||||
|
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(context)) {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(BaseData o) {
|
||||||
|
super.onSuccess(o);
|
||||||
|
requestEndSystem = System.currentTimeMillis();
|
||||||
|
netDelay = SystemClock.elapsedRealtime() - requestTime;
|
||||||
|
startUpload();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Throwable e) {
|
||||||
|
super.onError(e);
|
||||||
|
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(String message, int code) {
|
||||||
|
super.onError(message, code);
|
||||||
|
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startUpload() {
|
||||||
|
Logger.d(TAG, "start upload");
|
||||||
|
MogoLocation lastLocation = MogoApisHandler.getInstance().getApis().getMapServiceApi().getSingletonLocationClient(context).getLastKnowLocation();
|
||||||
|
if (lastLocation == null) {
|
||||||
|
handler.sendEmptyMessageDelayed(MSG_START_DELAY_CHECK, DELAY_CHECK_DELAY);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Logger.d(TAG, "lastLocation: " + lastLocation);
|
||||||
|
DelayCheckUploadRequest request = new DelayCheckUploadRequest();
|
||||||
|
request.setSn(Utils.getSn());
|
||||||
|
request.setStartTime(requestStartSystemTime);
|
||||||
|
request.setEndTime(requestEndSystem);
|
||||||
|
request.setNetState(NetworkUtils.netStrengthLevel);
|
||||||
|
request.setPlace(lastLocation.getAddress());
|
||||||
|
request.setCityCode(lastLocation.getCityCode());
|
||||||
|
request.setLat(lastLocation.getLatitude());
|
||||||
|
request.setLon(lastLocation.getLongitude());
|
||||||
|
request.setBurning(netDelay);
|
||||||
|
|
||||||
|
RequestBody params = RequestBody.create(MediaType.get("application/json"), GsonUtil.jsonFromObject(request));
|
||||||
|
|
||||||
|
MogoApisHandler.getInstance().getApis().getNetworkApi()
|
||||||
|
.create(DelayCheckApiServices.class, DelayCheckHttpConstant.getBaseUrl())
|
||||||
|
.uploadDelayCheckData(params).observeOn(Schedulers.io()).subscribeOn(Schedulers.io())
|
||||||
|
.subscribe(new SubscribeImpl<DelayCheckResponse>(RequestOptions.create(context)) {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(DelayCheckResponse o) {
|
||||||
|
super.onSuccess(o);
|
||||||
|
Logger.d(TAG, "上报时延成功 " + o);
|
||||||
|
DelayCheckResult result = o.getResult();
|
||||||
|
if(result.isNecessary()) {
|
||||||
|
handler.sendEmptyMessageDelayed(MSG_START_DELAY_CHECK, result.getBeatSeconds() * 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(String message, int code) {
|
||||||
|
super.onError(message, code);
|
||||||
|
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Throwable e) {
|
||||||
|
super.onError(e);
|
||||||
|
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@ import com.mogo.map.location.MogoLocation;
|
|||||||
import com.mogo.module.common.MogoApisHandler;
|
import com.mogo.module.common.MogoApisHandler;
|
||||||
import com.mogo.module.main.EventDispatchCenter;
|
import com.mogo.module.main.EventDispatchCenter;
|
||||||
import com.mogo.module.main.cards.MogoModulesManager;
|
import com.mogo.module.main.cards.MogoModulesManager;
|
||||||
|
import com.mogo.module.main.delaycheck.DelayCheckUtil;
|
||||||
import com.mogo.service.IMogoServiceApis;
|
import com.mogo.service.IMogoServiceApis;
|
||||||
import com.mogo.utils.UiThreadHandler;
|
import com.mogo.utils.UiThreadHandler;
|
||||||
import com.mogo.utils.logger.Logger;
|
import com.mogo.utils.logger.Logger;
|
||||||
@@ -48,6 +49,9 @@ class MogoMainService extends Service implements IMogoLocationListener {
|
|||||||
initGpsSimulatorListener();
|
initGpsSimulatorListener();
|
||||||
}, 2_000L
|
}, 2_000L
|
||||||
);
|
);
|
||||||
|
// 开启延时检测
|
||||||
|
DelayCheckUtil delayCheckUtil = new DelayCheckUtil(this);
|
||||||
|
delayCheckUtil.waitingForCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.mogo.module.small.map">
|
package="com.mogo.module.small.map">
|
||||||
|
|
||||||
|
<application>
|
||||||
|
<service
|
||||||
|
android:name=".SmallMapService"
|
||||||
|
android:exported="false"
|
||||||
|
android:process=":smallMap"/>
|
||||||
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
package com.mogo.module.small.map;
|
||||||
|
|
||||||
|
import android.app.Service;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.IBinder;
|
||||||
|
import android.os.RemoteException;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.mogo.module.common.entity.MogoSnapshotSetData;
|
||||||
|
import com.mogo.module.common.machinevision.IMachineVisionInterface;
|
||||||
|
import com.mogo.module.common.wm.WindowManagerView;
|
||||||
|
import com.mogo.utils.logger.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author donghongyu
|
||||||
|
* @date 12/10/20 1:35 PM
|
||||||
|
*/
|
||||||
|
public class SmallMapService extends Service {
|
||||||
|
private static final String TAG = "MachineVisionMapService";
|
||||||
|
private IBinder mBinder;
|
||||||
|
|
||||||
|
private WindowManagerView mWindowManagerView;
|
||||||
|
private SmallMapDirectionView mSmallMapDirectionView;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate() {
|
||||||
|
super.onCreate();
|
||||||
|
Logger.d(TAG, "onCreate");
|
||||||
|
addSmallMapView();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public IBinder onBind(Intent intent) {
|
||||||
|
Logger.d(TAG, "onBind");
|
||||||
|
mBinder = new SmallMapServiceBinder();
|
||||||
|
return mBinder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRebind(Intent intent) {
|
||||||
|
super.onRebind(intent);
|
||||||
|
addSmallMapView();
|
||||||
|
Logger.d(TAG, "onRebind");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onUnbind(Intent intent) {
|
||||||
|
Logger.d(TAG, "onUnbind");
|
||||||
|
if (mWindowManagerView != null && mWindowManagerView.isShowing()) {
|
||||||
|
mWindowManagerView.dismiss();
|
||||||
|
}
|
||||||
|
mWindowManagerView = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
Logger.d(TAG, "onDestroy");
|
||||||
|
if (mWindowManagerView != null) {
|
||||||
|
mWindowManagerView.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加小地图View
|
||||||
|
*/
|
||||||
|
private void addSmallMapView() {
|
||||||
|
Logger.d(TAG, "addSmallMapView");
|
||||||
|
|
||||||
|
// 初始化小地图控件
|
||||||
|
mSmallMapDirectionView = new SmallMapDirectionView(getApplicationContext());
|
||||||
|
|
||||||
|
mWindowManagerView = new WindowManagerView.Builder(getApplicationContext())
|
||||||
|
.contentView(mSmallMapDirectionView)
|
||||||
|
.size(
|
||||||
|
WindowManager.LayoutParams.WRAP_CONTENT,
|
||||||
|
WindowManager.LayoutParams.WRAP_CONTENT
|
||||||
|
)
|
||||||
|
.position(
|
||||||
|
getResources().getDimensionPixelOffset(R.dimen.module_small_map_view_x),
|
||||||
|
getResources().getDimensionPixelOffset(R.dimen.module_small_map_view_y)
|
||||||
|
)
|
||||||
|
.gravity(Gravity.TOP | Gravity.LEFT)
|
||||||
|
.showInWindowManager();
|
||||||
|
mWindowManagerView.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小地图与大地图之间进程通讯
|
||||||
|
*/
|
||||||
|
public class SmallMapServiceBinder extends IMachineVisionInterface.Stub {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void linkToDeath(@NonNull DeathRecipient recipient, int flags) {
|
||||||
|
super.linkToDeath(recipient, flags);
|
||||||
|
Logger.d(TAG, "linkToDeath");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean unlinkToDeath(@NonNull DeathRecipient recipient, int flags) {
|
||||||
|
Logger.d(TAG, "unlinkToDeath");
|
||||||
|
|
||||||
|
return super.unlinkToDeath(recipient, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postData(MogoSnapshotSetData data) throws RemoteException {
|
||||||
|
Logger.d(TAG, "postData");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hideViewIfExist() throws RemoteException {
|
||||||
|
Logger.d(TAG, "hideViewIfExist");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showViewIfExist() throws RemoteException {
|
||||||
|
Logger.d(TAG, "showViewIfExist");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,24 +1,22 @@
|
|||||||
package com.mogo.module.small.map;
|
package com.mogo.module.small.map;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||||
|
import com.mogo.commons.AbsMogoApplication;
|
||||||
import com.mogo.module.common.MogoApisHandler;
|
import com.mogo.module.common.MogoApisHandler;
|
||||||
import com.mogo.module.common.wm.WindowManagerView;
|
|
||||||
import com.mogo.service.MogoServicePaths;
|
import com.mogo.service.MogoServicePaths;
|
||||||
import com.mogo.service.map.IMogoSmallMapProvider;
|
import com.mogo.service.map.IMogoSmallMapProvider;
|
||||||
import com.mogo.service.module.ModuleType;
|
import com.mogo.service.module.ModuleType;
|
||||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||||
import com.mogo.utils.logger.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author donghongyu
|
* @author donghongyu
|
||||||
@@ -28,11 +26,9 @@ import com.mogo.utils.logger.Logger;
|
|||||||
public class SmallVisionProvider implements IMogoSmallMapProvider, IMogoStatusChangedListener {
|
public class SmallVisionProvider implements IMogoSmallMapProvider, IMogoStatusChangedListener {
|
||||||
private final String TAG = "SmallVisionProvider";
|
private final String TAG = "SmallVisionProvider";
|
||||||
|
|
||||||
|
private Intent mSmallMapServiceIntent;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
private WindowManagerView mWindowManagerView;
|
|
||||||
private SmallMapDirectionView mSmallMapDirectionView;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Fragment createFragment(Context context, Bundle data) {
|
public Fragment createFragment(Context context, Bundle data) {
|
||||||
return null;
|
return null;
|
||||||
@@ -80,22 +76,22 @@ public class SmallVisionProvider implements IMogoSmallMapProvider, IMogoStatusCh
|
|||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
Log.d(TAG, "小地图模块销毁……");
|
Log.d(TAG, "小地图模块销毁……");
|
||||||
hidePanel();
|
hidePanel();
|
||||||
// 释放组件内存
|
|
||||||
mSmallMapDirectionView = null;
|
|
||||||
mWindowManagerView = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showPanel() {
|
public void showPanel() {
|
||||||
Log.d(TAG, "小地图模块触发展示……");
|
Log.d(TAG, "小地图模块触发展示……");
|
||||||
addSmallMapView();
|
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||||
|
mSmallMapServiceIntent = new Intent(mContext, SmallMapService.class);
|
||||||
|
mContext.startService(mSmallMapServiceIntent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hidePanel() {
|
public void hidePanel() {
|
||||||
Log.d(TAG, "小地图模块触发隐藏……");
|
Log.d(TAG, "小地图模块触发隐藏……");
|
||||||
if (mWindowManagerView != null && mWindowManagerView.isShowing()) {
|
if (mSmallMapServiceIntent != null) {
|
||||||
mWindowManagerView.dismiss();
|
AbsMogoApplication.getApp().stopService(mSmallMapServiceIntent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,33 +122,4 @@ public class SmallVisionProvider implements IMogoSmallMapProvider, IMogoStatusCh
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加小地图View
|
|
||||||
*/
|
|
||||||
private void addSmallMapView() {
|
|
||||||
Logger.d(TAG, "addSmallMapView");
|
|
||||||
// 初始化小地图控件
|
|
||||||
if (mSmallMapDirectionView == null) {
|
|
||||||
mSmallMapDirectionView = new SmallMapDirectionView(mContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mWindowManagerView == null) {
|
|
||||||
mWindowManagerView = new WindowManagerView.Builder(mContext)
|
|
||||||
.contentView(mSmallMapDirectionView)
|
|
||||||
.size(
|
|
||||||
WindowManager.LayoutParams.WRAP_CONTENT,
|
|
||||||
WindowManager.LayoutParams.WRAP_CONTENT
|
|
||||||
)
|
|
||||||
.position(
|
|
||||||
mContext.getResources().getDimensionPixelOffset(R.dimen.module_small_map_view_x),
|
|
||||||
mContext.getResources().getDimensionPixelOffset(R.dimen.module_small_map_view_y)
|
|
||||||
)
|
|
||||||
.gravity(Gravity.TOP | Gravity.LEFT)
|
|
||||||
.showInWindowManager();
|
|
||||||
}
|
|
||||||
mWindowManagerView.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,19 +111,19 @@ public class V2XAlarmServer {
|
|||||||
}
|
}
|
||||||
// 进行提醒
|
// 进行提醒
|
||||||
if (!isAlreadyAlert) {
|
if (!isAlreadyAlert) {
|
||||||
Logger.w(MODULE_NAME, "V2X预警--车辆与事件信息:" +
|
// Logger.w(MODULE_NAME, "V2X预警--车辆与事件信息:" +
|
||||||
"\n事件详情ID:" + v2XRoadEventEntity.getNoveltyInfo().getInfoId() +
|
// "\n事件详情ID:" + v2XRoadEventEntity.getNoveltyInfo().getInfoId() +
|
||||||
"\n事件详情:" + GsonUtil.jsonFromObject(v2XRoadEventEntity.getNoveltyInfo()) +
|
// "\n事件详情:" + GsonUtil.jsonFromObject(v2XRoadEventEntity.getNoveltyInfo()) +
|
||||||
"\n距离:" + v2XRoadEventEntity.getDistance() + "米" +
|
// "\n距离:" + v2XRoadEventEntity.getDistance() + "米" +
|
||||||
"\n是否已经提醒:" + isAlreadyAlert +
|
// "\n是否已经提醒:" + isAlreadyAlert +
|
||||||
"\n当前车辆-经度:" + currentLocation.getLongitude() +
|
// "\n当前车辆-经度:" + currentLocation.getLongitude() +
|
||||||
"\n当前车辆-经度:" + currentLocation.getLatitude() +
|
// "\n当前车辆-经度:" + currentLocation.getLatitude() +
|
||||||
"\n当前车辆-角度:" + currentLocation.getBearing() +
|
// "\n当前车辆-角度:" + currentLocation.getBearing() +
|
||||||
"\n道路事件-经度:" + eventLocation.getLon() +
|
// "\n道路事件-经度:" + eventLocation.getLon() +
|
||||||
"\n道路事件-经度:" + eventLocation.getLat() +
|
// "\n道路事件-经度:" + eventLocation.getLat() +
|
||||||
"\n道路事件-角度:" + eventLocation.getAngle() +
|
// "\n道路事件-角度:" + eventLocation.getAngle() +
|
||||||
"\n夹角角度:" + eventAngle + " 度"
|
// "\n夹角角度:" + eventAngle + " 度"
|
||||||
);
|
// );
|
||||||
mAlertRoadEventList.put(v2XRoadEventEntity, TimeUtils.getNowString());
|
mAlertRoadEventList.put(v2XRoadEventEntity, TimeUtils.getNowString());
|
||||||
return v2XRoadEventEntity;
|
return v2XRoadEventEntity;
|
||||||
}
|
}
|
||||||
@@ -141,13 +141,13 @@ public class V2XAlarmServer {
|
|||||||
// );
|
// );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Logger.w(MODULE_NAME,
|
// Logger.w(MODULE_NAME,
|
||||||
"V2X预警--车头方向与事件方向角度不一致:" +
|
// "V2X预警--车头方向与事件方向角度不一致:" +
|
||||||
"\n事件详情:" + v2XRoadEventEntity.getNoveltyInfo().getInfoId() +
|
// "\n事件详情:" + v2XRoadEventEntity.getNoveltyInfo().getInfoId() +
|
||||||
"\n车头方向: " + carBearing +
|
// "\n车头方向: " + carBearing +
|
||||||
"\n事件方向:" + eventBearing +
|
// "\n事件方向:" + eventBearing +
|
||||||
"\n角度差值:" + diffAngle
|
// "\n角度差值:" + diffAngle
|
||||||
);
|
// );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Logger.w(MODULE_NAME, "V2X预警--车辆距离事件距离大于500米了:" +
|
// Logger.w(MODULE_NAME, "V2X预警--车辆距离事件距离大于500米了:" +
|
||||||
@@ -156,10 +156,10 @@ public class V2XAlarmServer {
|
|||||||
// );
|
// );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Logger.e(MODULE_NAME,
|
// Logger.e(MODULE_NAME,
|
||||||
"V2X预警--道路事件没有角度信息" +
|
// "V2X预警--道路事件没有角度信息" +
|
||||||
"\n事件详情:" + v2XRoadEventEntity.getNoveltyInfo().getInfoId()
|
// "\n事件详情:" + v2XRoadEventEntity.getNoveltyInfo().getInfoId()
|
||||||
);
|
// );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,14 @@ public class RoundLayout extends RelativeLayout implements IMogoSkinCompatSuppor
|
|||||||
super.draw(canvas);
|
super.draw(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBackgroundResource(int resId) {
|
||||||
|
super.setBackgroundResource(resId);
|
||||||
|
if (mBackgroundTintHelper != null) {
|
||||||
|
mBackgroundTintHelper.onSetBackgroundResource(resId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applySkin() {
|
public void applySkin() {
|
||||||
if (mBackgroundTintHelper != null) {
|
if (mBackgroundTintHelper != null) {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
include ':foudations:httpdns-mogo'
|
||||||
include ':modules:mogo-module-smp'
|
include ':modules:mogo-module-smp'
|
||||||
include ':app2'
|
include ':app2'
|
||||||
include ':foudations:httpdns-base'
|
include ':foudations:httpdns-base'
|
||||||
|
|||||||
Reference in New Issue
Block a user