httpdns功能
This commit is contained in:
1
foudations/httpdns-tencent/.gitignore
vendored
Normal file
1
foudations/httpdns-tencent/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
31
foudations/httpdns-tencent/build.gradle
Normal file
31
foudations/httpdns-tencent/build.gradle
Normal file
@@ -0,0 +1,31 @@
|
||||
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"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
implementation "com.mogo.tencent.httpdns:android-httpdns:+@aar"
|
||||
implementation "com.mogo.tencent.beacon:android-beacon:+@jar"
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
0
foudations/httpdns-tencent/consumer-rules.pro
Normal file
0
foudations/httpdns-tencent/consumer-rules.pro
Normal file
3
foudations/httpdns-tencent/gradle.properties
Normal file
3
foudations/httpdns-tencent/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
GROUP=com.mogo.httpdns
|
||||
POM_ARTIFACT_ID=httpdns-tencent
|
||||
VERSION_CODE=1
|
||||
21
foudations/httpdns-tencent/proguard-rules.pro
vendored
Normal file
21
foudations/httpdns-tencent/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
|
||||
13
foudations/httpdns-tencent/src/main/AndroidManifest.xml
Normal file
13
foudations/httpdns-tencent/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.httpdns">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<!-- 用于获取手机imei码进行数据上报,非必须 -->
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
|
||||
<!-- 灯塔 -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
</manifest>
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mogo.utils.network;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.List;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/11/18
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
interface HttpDns {
|
||||
|
||||
List< InetAddress > lookup( String hostname ) throws UnknownHostException;
|
||||
}
|
||||
@@ -46,6 +46,8 @@ public final class NetConfig {
|
||||
|
||||
private SSLContext sslContext;
|
||||
|
||||
private HttpDns httpDns;
|
||||
|
||||
private NetConfig() {
|
||||
}
|
||||
|
||||
@@ -157,4 +159,12 @@ public final class NetConfig {
|
||||
public synchronized void setSslContext( SSLContext sslContext ) {
|
||||
this.sslContext = sslContext;
|
||||
}
|
||||
|
||||
public HttpDns getHttpDns() {
|
||||
return httpDns;
|
||||
}
|
||||
|
||||
public void setHttpDns( HttpDns httpDns ) {
|
||||
this.httpDns = httpDns;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package com.mogo.utils.network;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import okhttp3.Dns;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
@@ -45,6 +49,13 @@ public final class OkHttpFactory {
|
||||
builder.addNetworkInterceptor(networkInterceptor);
|
||||
}
|
||||
|
||||
HttpDns httpDns = NetConfig.instance().getHttpDns();
|
||||
if ( httpDns != null ) {
|
||||
builder.dns( hostname -> {
|
||||
return httpDns.lookup( hostname );
|
||||
} );
|
||||
}
|
||||
|
||||
sInstance = builder.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +107,8 @@ TTS_NOOP_VERSION=1.0.0
|
||||
# 自研地图
|
||||
MAP_CUSTOM_VERSION=1.2.1.9
|
||||
MOGO_MODULES_MVISION_VERSION=1.0.0
|
||||
# httpdns
|
||||
HTTPDNS_TENCENT_VERSION = 1.0.0
|
||||
|
||||
######## 外部依赖引用
|
||||
# 车聊聊
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
include ':foudations:httpdns-tencent'
|
||||
include ':modules:mogo-modules-mvision'
|
||||
include ':foudations:mogo-base-websocket-sdk'
|
||||
include ':tts:tts-base'
|
||||
|
||||
Reference in New Issue
Block a user