t:wq
:wq remove httpdns logic
This commit is contained in:
@@ -56,6 +56,7 @@ dependencies {
|
||||
// 从车机获取视频流
|
||||
implementation 'com.zhidao.carmanager:common:1.0.25@aar'
|
||||
implementation 'com.google.android.material:material:1.3.0'
|
||||
implementation project(path: ':foudations:mogo-passport')
|
||||
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
implementation "com.mogo.cloud:location:${MOGO_LOCATION_VERSION}"
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
package com.mogo.cloud;
|
||||
|
||||
|
||||
import android.util.Log;
|
||||
import static com.mogo.cloud.passport.MoGoAiCloudClientConfig.HTTP_DNS_ENV_RELEASE;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.multidex.MultiDexApplication;
|
||||
|
||||
import com.auto.zhidao.logsdk.CrashSystem;
|
||||
import com.mogo.cloud.httpdns.MogoHttpDnsConfig;
|
||||
import com.mogo.cloud.httpdns.bean.HttpDnsSimpleLocation;
|
||||
import com.mogo.cloud.httpdns.listener.IHttpDnsCurrentLocation;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.cloud.passport.location.ICurrentLocation;
|
||||
import com.mogo.cloud.passport.location.SimpleLocation;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -46,7 +44,7 @@ public class MoGoApplication extends MultiDexApplication {
|
||||
// 配置云服务API
|
||||
MoGoAiCloudClientConfig clientConfig = MoGoAiCloudClientConfig.getInstance();
|
||||
// 设置网络环境:HTTP_DNS_ENV_QA、HTTP_DNS_ENV_RELEASE、HTTP_DNS_ENV_DEV
|
||||
clientConfig.setNetMode(MogoHttpDnsConfig.HTTP_DNS_ENV_RELEASE);
|
||||
clientConfig.setNetMode(HTTP_DNS_ENV_RELEASE);
|
||||
// 设置是否是第三APP登录,false:自有车机 true:外部三方车机
|
||||
clientConfig.setThirdLogin(true);
|
||||
// 设置是否输出日志
|
||||
@@ -63,19 +61,11 @@ public class MoGoApplication extends MultiDexApplication {
|
||||
clientConfig.setThirdPartyDeviceId("12345678998765432169");
|
||||
// 设置应用服务AppId 长链、鉴权 //todo 需要卸载智慧驾驶、行车记录仪
|
||||
clientConfig.setServiceAppId("com.mogo.launcher");
|
||||
// 设置循环检测间隔时间
|
||||
clientConfig.setLoopCheckDelay(60 * 60 * 24 * 1000);
|
||||
// 设置是否属于高精定位设备
|
||||
clientConfig.setIsAccuracyDevice(false);
|
||||
|
||||
// 设置DNS经纬度位置
|
||||
clientConfig.setIHttpDnsCurrentLocation(new IHttpDnsCurrentLocation() {
|
||||
@Nullable
|
||||
@Override
|
||||
public HttpDnsSimpleLocation getCurrentLocation() {
|
||||
return new HttpDnsSimpleLocation("0734", randomLat, randomLon);
|
||||
}
|
||||
});
|
||||
clientConfig.setIHttpCurrentLocation(() -> new SimpleLocation("0734", randomLat, randomLon));
|
||||
|
||||
clientConfig.setUseOriginSocket(true);
|
||||
// 初始化SDK,可以设置状态回调来监听
|
||||
|
||||
1
foudations/mogo-httpdns/.gitignore
vendored
1
foudations/mogo-httpdns/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
/build
|
||||
@@ -1,59 +0,0 @@
|
||||
plugins {
|
||||
id 'com.android.library'
|
||||
id 'kotlin-android'
|
||||
id 'kotlin-android-extensions'
|
||||
}
|
||||
// 对kotlin生成doc
|
||||
apply plugin: 'org.jetbrains.dokka'
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
|
||||
versionCode 1
|
||||
versionName "${MOGO_HTTPDNS_VERSION}"
|
||||
|
||||
consumerProguardFiles "consumer-rules.pro"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '1.8'
|
||||
}
|
||||
|
||||
dokka {
|
||||
outputFormat = 'javadoc'
|
||||
outputDirectory = "$rootDir/ApiDoc/foudations/httpdns"
|
||||
|
||||
configuration {
|
||||
// Do not output deprecated members
|
||||
skipDeprecated = true
|
||||
// Emit warnings about not documented members.
|
||||
reportUndocumented = true
|
||||
// Do not create index pages for empty packages
|
||||
skipEmptyPackages = true
|
||||
|
||||
noJdkLink = true
|
||||
noStdlibLink = true
|
||||
noAndroidSdkLink = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
|
||||
implementation rootProject.ext.dependencies.logger
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
@@ -1,2 +0,0 @@
|
||||
-keep class com.mogo.cloud.httpdns.bean.*{*;}
|
||||
-keep class com.mogo.cloud.httpdns.util.ApiManager{*;}
|
||||
@@ -1,4 +0,0 @@
|
||||
GROUP=com.mogo.cloud
|
||||
POM_ARTIFACT_ID=httpdns
|
||||
VERSION_CODE=1
|
||||
VERSION_NAME=1.0.0-SNAPSHOT
|
||||
21
foudations/mogo-httpdns/proguard-rules.pro
vendored
21
foudations/mogo-httpdns/proguard-rules.pro
vendored
@@ -1,21 +0,0 @@
|
||||
# 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
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.cloud.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" />
|
||||
</manifest>
|
||||
@@ -1,195 +0,0 @@
|
||||
package com.mogo.cloud.httpdns
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.HandlerThread
|
||||
import android.os.Message
|
||||
import android.text.TextUtils
|
||||
import android.util.ArrayMap
|
||||
import com.mogo.cloud.httpdns.bean.HttpDnsSimpleLocation
|
||||
import com.mogo.cloud.httpdns.listener.IMogoHttpDns
|
||||
import com.mogo.cloud.httpdns.listener.OnAddressChangedListener
|
||||
import com.mogo.cloud.httpdns.util.ApiManager
|
||||
import com.mogo.cloud.httpdns.util.L
|
||||
import com.mogo.cloud.httpdns.util.NetWorkUtil
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* 1. 网络状态发生变化时候,重置轮询,并查询一次
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
internal class HttpDnsHelper(private val builder: MogoHttpDnsConfig) : Handler.Callback,
|
||||
IMogoHttpDns {
|
||||
companion object {
|
||||
const val HTTP_DNS_TYPE_HTTP = 0
|
||||
const val HTTP_DNS_TYPE_WS = 1
|
||||
const val HTTP_DNS_TYPE_IM = 2
|
||||
|
||||
private const val MSG_REQUEST_IP_PORT = 1001
|
||||
|
||||
private const val TAG = "HttpDnsHelper"
|
||||
}
|
||||
|
||||
private val netWorkUtil = NetWorkUtil()
|
||||
private var localConnectStateCache = false
|
||||
private val workThread = HandlerThread("mogo-http-dns-work-thread")
|
||||
private val handler: Handler
|
||||
private var addressMap: Map<String, String>? = null
|
||||
private var addressChangedListener: OnAddressChangedListener? = null
|
||||
|
||||
private val apiManager: ApiManager
|
||||
private var isInit = false
|
||||
private var defaultUrl: String? = null
|
||||
private var httpDnsCache: HttpDnsSimpleLocation? = null
|
||||
|
||||
init {
|
||||
defaultUrl = builder.getDefaultUrl()
|
||||
L.d(TAG, "init===")
|
||||
checkParams()
|
||||
isInit = true
|
||||
workThread.start()
|
||||
handler = Handler(workThread.looper, this)
|
||||
apiManager = ApiManager(builder.getSn()!!, builder.getEnv(), builder.getAppKey())
|
||||
handler.sendEmptyMessage(MSG_REQUEST_IP_PORT)
|
||||
netWorkUtil.registerStatusCallback(builder.getContext()!!) {
|
||||
if (it && !localConnectStateCache) {
|
||||
// 网络状态可用,且本地记录的连接状态为false,开始请求
|
||||
handler.removeMessages(MSG_REQUEST_IP_PORT)
|
||||
// 立即执行
|
||||
handler.sendEmptyMessage(MSG_REQUEST_IP_PORT)
|
||||
}
|
||||
localConnectStateCache = it
|
||||
}
|
||||
httpDnsCache = builder.getCurrentLocation()?.getCurrentLocation()
|
||||
}
|
||||
|
||||
private fun getHttpDnsAddressFromNet() {
|
||||
val nAddress = apiManager.requestHttpDns(builder.getCurrentLocation()!!)
|
||||
if (addressChangedListener == null) {
|
||||
L.d(TAG, "addressChangeList is null")
|
||||
}
|
||||
if (nAddress == null || nAddress.isEmpty()) {
|
||||
return
|
||||
}
|
||||
if (addressMap == null) {
|
||||
addressMap = nAddress
|
||||
addressChangedListener?.onAddressChanged(httpDnsCache!!.cityCode, addressMap)
|
||||
} else {
|
||||
addressMap = nAddress
|
||||
addressChangedListener?.onAddressChanged(httpDnsCache!!.cityCode, mapDiff(nAddress, addressMap!!))
|
||||
}
|
||||
}
|
||||
|
||||
private val requestLock = Any()
|
||||
|
||||
override fun addressChangedListener(addressChangedListener: OnAddressChangedListener) {
|
||||
this.addressChangedListener = addressChangedListener
|
||||
}
|
||||
|
||||
override fun syncGetHttpDns(host: String, type: Int, useCache: Boolean): String? {
|
||||
return if (useCache) {
|
||||
getHttpDnsCachedAddress(type, host)
|
||||
} else {
|
||||
getHttpDnsAddress(type, host)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getHttpDnsAddress(type: Int, _host: String): String? {
|
||||
val host = _host.toLowerCase(Locale.getDefault())
|
||||
if (isInit) {
|
||||
synchronized(requestLock) {
|
||||
getHttpDnsAddressFromNet()
|
||||
}
|
||||
addressMap?.let {
|
||||
val builder = StringBuilder()
|
||||
for (key in it.keys) {
|
||||
builder.append(key).append(" : ").append(it[key]).append("\n")
|
||||
}
|
||||
L.d(TAG, "getHttpDnsAddress over $type-$host $builder")
|
||||
return if (it["$type-$host"] == null) {
|
||||
defaultUrl ?: host
|
||||
} else {
|
||||
it["$type-$host"]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw IllegalStateException("Http dns not init")
|
||||
}
|
||||
return defaultUrl ?: host
|
||||
}
|
||||
|
||||
override fun getHttpDnsCachedAddress(type: Int, _host: String): String {
|
||||
val host = _host.toLowerCase(Locale.getDefault())
|
||||
httpDnsCache?.let {
|
||||
val currentLoc = builder.getCurrentLocation()?.getCurrentLocation()
|
||||
currentLoc?.let { cur ->
|
||||
if (it.cityCode.isNotEmpty()
|
||||
&& cur.cityCode.isNotEmpty()
|
||||
&& !TextUtils.equals(
|
||||
it.cityCode,
|
||||
cur.cityCode
|
||||
)
|
||||
) {
|
||||
L.d(
|
||||
TAG,
|
||||
"getHttpDnsCachedAddress : $type-$host , httpDnsCache: ${httpDnsCache.toString()} , currentLoc: $currentLoc"
|
||||
)
|
||||
httpDnsCache = currentLoc
|
||||
getHttpDnsAddress(type, _host)
|
||||
}
|
||||
}
|
||||
}
|
||||
val default = defaultUrl ?: host
|
||||
return addressMap?.get("$type-$host") ?: default
|
||||
}
|
||||
|
||||
override fun getAllAddress(): Map<String, String>? {
|
||||
return addressMap
|
||||
}
|
||||
|
||||
override fun handleMessage(msg: Message): Boolean {
|
||||
if (msg.what == MSG_REQUEST_IP_PORT) {
|
||||
if (isInit) {
|
||||
// 网络接口请求
|
||||
getHttpDnsAddressFromNet()
|
||||
handler.sendEmptyMessageDelayed(MSG_REQUEST_IP_PORT, builder.getLoopCheckDelay())
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun release() {
|
||||
netWorkUtil.release()
|
||||
}
|
||||
|
||||
private fun mapDiff(new: Map<String, String>, old: Map<String, String>): Map<String, String> {
|
||||
val diff = ArrayMap<String, String>()
|
||||
for (key in new.keys) {
|
||||
if (old[key] == null) {
|
||||
diff[key] = new[key]
|
||||
} else if (old[key] != new[key]) {
|
||||
diff[key] = new[key]
|
||||
}
|
||||
}
|
||||
for (key in old.keys) {
|
||||
if (!new.containsKey(key)) {
|
||||
diff[key] = null
|
||||
}
|
||||
}
|
||||
return diff
|
||||
}
|
||||
|
||||
private fun checkParams(): Boolean {
|
||||
if (builder.getContext() == null) {
|
||||
throw IllegalArgumentException("can not find context in builder")
|
||||
}
|
||||
if (builder.getSn() == null) {
|
||||
throw IllegalArgumentException("can not find sn in builder")
|
||||
}
|
||||
if (builder.getCurrentLocation() == null) {
|
||||
throw IllegalArgumentException("can not find currentLocation in builder")
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package com.mogo.cloud.httpdns
|
||||
|
||||
import com.mogo.cloud.httpdns.listener.IMogoHttpDns
|
||||
import com.mogo.cloud.httpdns.listener.OnAddressChangedListener
|
||||
|
||||
|
||||
object MogoHttpDnsClient : IMogoHttpDns {
|
||||
private var httpDnsHelper: HttpDnsHelper? = null
|
||||
|
||||
fun init(config: MogoHttpDnsConfig) {
|
||||
// httpDns init
|
||||
if (httpDnsHelper == null) {
|
||||
httpDnsHelper = HttpDnsHelper(config)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 先从本地缓存中根据type和host获取ip:port,如果本地缓存中没有,再通过网络获取
|
||||
*/
|
||||
fun getHttpDnsAddressUseCacheIfNecessary(type: Int, _host: String): String? {
|
||||
return getHttpDnsCachedAddress(type, _host)
|
||||
}
|
||||
|
||||
override fun addressChangedListener(addressChangedListener: OnAddressChangedListener) {
|
||||
if (httpDnsHelper == null) {
|
||||
throw IllegalStateException("MogoHttpDnsClient init error")
|
||||
}
|
||||
return httpDnsHelper!!.addressChangedListener(addressChangedListener)
|
||||
}
|
||||
|
||||
override fun syncGetHttpDns(host: String, type: Int, useCache: Boolean): String? {
|
||||
if (httpDnsHelper == null) {
|
||||
throw IllegalStateException("MogoHttpDnsClient init error")
|
||||
}
|
||||
return httpDnsHelper!!.syncGetHttpDns(host, type, useCache)
|
||||
}
|
||||
|
||||
override fun getHttpDnsAddress(type: Int, _host: String): String? {
|
||||
if (httpDnsHelper == null) {
|
||||
throw IllegalStateException("MogoHttpDnsClient init error")
|
||||
}
|
||||
return httpDnsHelper!!.getHttpDnsAddress(type, _host)
|
||||
}
|
||||
|
||||
override fun getHttpDnsCachedAddress(type: Int, _host: String): String? {
|
||||
if (httpDnsHelper == null) {
|
||||
throw IllegalStateException("MogoHttpDnsClient init error")
|
||||
}
|
||||
return httpDnsHelper!!.getHttpDnsCachedAddress(type, _host)
|
||||
}
|
||||
|
||||
override fun getAllAddress(): Map<String, String>? {
|
||||
if (httpDnsHelper == null) {
|
||||
throw IllegalStateException("MogoHttpDnsClient init error")
|
||||
}
|
||||
return httpDnsHelper!!.getAllAddress()
|
||||
}
|
||||
|
||||
override fun release() {
|
||||
if (httpDnsHelper == null) {
|
||||
throw IllegalStateException("MogoHttpDnsClient init error")
|
||||
}
|
||||
httpDnsHelper!!.release()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
package com.mogo.cloud.httpdns
|
||||
|
||||
import android.content.Context
|
||||
import com.mogo.cloud.httpdns.listener.IHttpDnsCurrentLocation
|
||||
|
||||
class MogoHttpDnsConfig {
|
||||
|
||||
companion object{
|
||||
/**
|
||||
* 研发环境
|
||||
*/
|
||||
const val HTTP_DNS_ENV_DEV = 1
|
||||
|
||||
/**
|
||||
* 测试环境
|
||||
*/
|
||||
const val HTTP_DNS_ENV_QA = 2
|
||||
|
||||
/**
|
||||
* 线上环境
|
||||
*/
|
||||
const val HTTP_DNS_ENV_RELEASE = 3
|
||||
|
||||
/**
|
||||
* 演示环境
|
||||
*/
|
||||
const val HTTP_DNS_ENV_DEMO = 4
|
||||
|
||||
}
|
||||
private var mSn: String? = null
|
||||
private var mCurrentLocation: IHttpDnsCurrentLocation? = null
|
||||
private var mShowDebugLog: Boolean = false
|
||||
private var mLoopCheckDelay: Long = 15 * 60 * 1000
|
||||
private var mContext: Context? = null
|
||||
private var mEnv = HTTP_DNS_ENV_RELEASE
|
||||
private var mDefaultUrl:String? = null
|
||||
|
||||
private var mAppKey:String? = null
|
||||
|
||||
fun setContext(context: Context): MogoHttpDnsConfig {
|
||||
mContext = context
|
||||
return this
|
||||
}
|
||||
|
||||
fun getContext(): Context? {
|
||||
return mContext
|
||||
}
|
||||
|
||||
fun setSn(sn: String): MogoHttpDnsConfig {
|
||||
mSn = sn
|
||||
return this
|
||||
}
|
||||
|
||||
fun getSn(): String? {
|
||||
return mSn
|
||||
}
|
||||
|
||||
fun setShowDebugLog(showDebugLog: Boolean): MogoHttpDnsConfig {
|
||||
mShowDebugLog = showDebugLog
|
||||
return this
|
||||
}
|
||||
|
||||
fun showDebugLog(): Boolean {
|
||||
return mShowDebugLog
|
||||
}
|
||||
|
||||
fun setLoopCheckDelay(loopCheckDelay: Long): MogoHttpDnsConfig {
|
||||
mLoopCheckDelay = loopCheckDelay
|
||||
return this
|
||||
}
|
||||
|
||||
fun getLoopCheckDelay(): Long {
|
||||
return mLoopCheckDelay
|
||||
}
|
||||
|
||||
fun setCurrentLocation(currentLocation: IHttpDnsCurrentLocation): MogoHttpDnsConfig {
|
||||
mCurrentLocation = currentLocation
|
||||
return this
|
||||
}
|
||||
|
||||
fun getCurrentLocation(): IHttpDnsCurrentLocation? {
|
||||
return mCurrentLocation
|
||||
}
|
||||
|
||||
fun setEnv(env:Int):MogoHttpDnsConfig{
|
||||
mEnv = env
|
||||
return this
|
||||
}
|
||||
|
||||
fun getEnv():Int{
|
||||
return mEnv
|
||||
}
|
||||
|
||||
fun setDefaultUrl(defaultUrl:String):MogoHttpDnsConfig{
|
||||
mDefaultUrl = defaultUrl
|
||||
return this
|
||||
}
|
||||
|
||||
fun getDefaultUrl():String?{
|
||||
return mDefaultUrl
|
||||
}
|
||||
|
||||
fun setAppKey(appKey: String): MogoHttpDnsConfig {
|
||||
mAppKey = appKey
|
||||
return this
|
||||
}
|
||||
|
||||
fun getAppKey():String{
|
||||
return mAppKey ?: ""
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.mogo.cloud.httpdns.bean
|
||||
|
||||
/**
|
||||
* httpDns需要的定位信息,需要使用高德定位的经纬度坐标和cityCode
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
data class HttpDnsSimpleLocation(val cityCode:String,val lat:Double,val lon:Double)
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.mogo.cloud.httpdns.listener
|
||||
|
||||
import com.mogo.cloud.httpdns.bean.HttpDnsSimpleLocation
|
||||
|
||||
interface IHttpDnsCurrentLocation {
|
||||
fun getCurrentLocation(): HttpDnsSimpleLocation?
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.mogo.cloud.httpdns.listener
|
||||
|
||||
import com.mogo.cloud.httpdns.HttpDnsHelper.Companion.HTTP_DNS_TYPE_HTTP
|
||||
|
||||
interface IMogoHttpDns {
|
||||
|
||||
/**
|
||||
* 地址变更回调
|
||||
*/
|
||||
fun addressChangedListener(addressChangedListener: OnAddressChangedListener);
|
||||
|
||||
/**
|
||||
* 同步进行dns解析,无需回调
|
||||
* @param host
|
||||
* @param type
|
||||
* @param useCache
|
||||
*
|
||||
* @return ip:port
|
||||
*/
|
||||
fun syncGetHttpDns(host: String, type: Int, useCache: Boolean): String?
|
||||
|
||||
/**
|
||||
* 根据类型和host获取IP,直接通过网络请求获取全部路由表
|
||||
* 同时多线程多次请求会忽略部分网络请求,一定程度减少接口请求次数
|
||||
*
|
||||
* @param type [HTTP_DNS_TYPE_HTTP]用于请求http接口
|
||||
* [HTTP_DNS_TYPE_WS]用于webSocket长连接
|
||||
* 若增加新类型,可自行设置
|
||||
* @return 类型对应的ip:port,不带协议头以及path,请自行补齐
|
||||
* 特别注意,若此type没有对应的ip:port,本方法会返回null
|
||||
*/
|
||||
fun getHttpDnsAddress(type: Int, _host: String): String?
|
||||
|
||||
/**
|
||||
* 根据类型和host获取本地cache的路由表
|
||||
*
|
||||
* @param type [HTTP_DNS_TYPE_HTTP]用于请求http接口
|
||||
* [HTTP_DNS_TYPE_WS]用于webSocket长连接
|
||||
* 若增加新类型,可自行设置
|
||||
*
|
||||
* @return 类型对应的ip:port,不带协议头以及path,请自行补齐
|
||||
* 特别注意,若此type没有对应的ip:port,本方法会返回null
|
||||
*/
|
||||
fun getHttpDnsCachedAddress(type: Int, _host: String): String?
|
||||
|
||||
/**
|
||||
* 获取全部路由表
|
||||
*
|
||||
* @return 返回本地缓存全部路由表,如果没有则返回null
|
||||
*/
|
||||
fun getAllAddress(): Map<String, String>?
|
||||
|
||||
fun release()
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.mogo.cloud.httpdns.listener
|
||||
|
||||
interface OnAddressChangedListener {
|
||||
fun onAddressChanged(cityCode: String, address: Map<String, String>?)
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
package com.mogo.cloud.httpdns.util
|
||||
|
||||
import android.util.ArrayMap
|
||||
import com.mogo.cloud.httpdns.listener.IHttpDnsCurrentLocation
|
||||
import org.json.JSONObject
|
||||
import java.io.BufferedReader
|
||||
import java.io.InputStreamReader
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
import java.util.*
|
||||
|
||||
private const val TAG = "ApiManager"
|
||||
|
||||
/**
|
||||
* 接口请求管理类
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
class ApiManager(private val sn:String,private val env:Int,private val appKey:String) {
|
||||
|
||||
fun requestHttpDns(_location: IHttpDnsCurrentLocation):Map<String,String>? {
|
||||
val location = _location.getCurrentLocation() ?: return null
|
||||
var client: HttpURLConnection? = null
|
||||
var bufferedReader: BufferedReader? = null
|
||||
try {
|
||||
client =
|
||||
URL("http://dzt.zhidaozhixing.com/yycp-httpdns-service/api/httpDns/getIpAndPort").openConnection() as HttpURLConnection
|
||||
client.requestMethod = "POST"
|
||||
client.doInput = true
|
||||
client.doOutput = true
|
||||
client.useCaches = false
|
||||
client.setRequestProperty("Content-type", "application/json")
|
||||
client.setRequestProperty("Charset", "UTF-8")
|
||||
client.setRequestProperty("app-key", appKey)
|
||||
client.readTimeout = 1000
|
||||
client.connectTimeout = 1000
|
||||
client.connect()
|
||||
val params =
|
||||
"{\"sn\":\"$sn\",\"cityCode\":\"${location.cityCode}\",\"lat\":${location.lat},\"lon\":${location.lon},\"env\":$env}"
|
||||
L.d(TAG, "params: $params")
|
||||
client.outputStream.write(params.toByteArray())
|
||||
client.outputStream.flush()
|
||||
client.outputStream.close()
|
||||
L.d(TAG, "response: ${client.responseCode}")
|
||||
bufferedReader = BufferedReader(InputStreamReader(client.inputStream))
|
||||
val builder = StringBuilder()
|
||||
while (true) {
|
||||
val line = bufferedReader.readLine()
|
||||
if (line != null) {
|
||||
builder.append(line)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
val msg = builder.toString()
|
||||
bufferedReader.close()
|
||||
client.disconnect()
|
||||
L.d(TAG, msg)
|
||||
val json = JSONObject(msg)
|
||||
val jsonArray = json.optJSONObject("result")?.optJSONArray("urls")
|
||||
jsonArray?.apply {
|
||||
val map = ArrayMap<String, String>(length())
|
||||
for (i in 0 until length()) {
|
||||
val item = optJSONObject(i)
|
||||
val type = item.optInt("type")
|
||||
val url = item.optString("url")
|
||||
val host = item.optString("domain").toLowerCase(Locale.getDefault())
|
||||
|
||||
map["$type-$host"] = url
|
||||
}
|
||||
return map
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
L.e(TAG, e.message ?: "exception===")
|
||||
bufferedReader?.close()
|
||||
client?.disconnect()
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.mogo.cloud.httpdns.util
|
||||
|
||||
import com.elegant.log.simplelog.Logger
|
||||
|
||||
|
||||
/**
|
||||
* 简单实现日志工具类
|
||||
*/
|
||||
object L {
|
||||
fun d(tag: String, msg: String) {
|
||||
Logger.d(tag, msg)
|
||||
}
|
||||
|
||||
fun e(tag: String, msg: String) {
|
||||
Logger.e(tag, msg)
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package com.mogo.cloud.httpdns.util
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.net.ConnectivityManager
|
||||
|
||||
/**
|
||||
* 网络状态工具类
|
||||
* 监听和获取网络状态
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
class NetWorkUtil {
|
||||
private var statusCallback: ((Boolean) -> Unit)? = null
|
||||
private var connectivityManager: ConnectivityManager? = null
|
||||
|
||||
private var context: Context? = null
|
||||
|
||||
fun registerStatusCallback(context: Context, statusCallback: (Boolean) -> Unit) {
|
||||
this.statusCallback = statusCallback
|
||||
this.context = context
|
||||
connectivityManager =
|
||||
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
val intentFilter = IntentFilter()
|
||||
intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE")
|
||||
context.registerReceiver(receiver, intentFilter)
|
||||
}
|
||||
|
||||
|
||||
private val receiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
connectivityManager?.apply {
|
||||
if (activeNetworkInfo == null) {
|
||||
statusCallback?.invoke(false)
|
||||
} else {
|
||||
if (activeNetworkInfo!!.type == -1) {
|
||||
statusCallback?.invoke(false)
|
||||
} else {
|
||||
//L.d(TAG, "activityNetworkInfo.type: ${activeNetworkInfo!!.type}")
|
||||
statusCallback?.invoke(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun release() {
|
||||
context?.unregisterReceiver(receiver)
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,5 @@
|
||||
package com.mogo.cloud.live.manager;
|
||||
|
||||
import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_DEMO;
|
||||
import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_DEV;
|
||||
import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_QA;
|
||||
import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_RELEASE;
|
||||
import static im.zego.zegoexpress.constants.ZegoRemoteDeviceState.OPEN;
|
||||
import static im.zego.zegoexpress.constants.ZegoRoomState.DISCONNECTED;
|
||||
|
||||
@@ -494,12 +490,12 @@ public class MoGoLiveManager {
|
||||
// 未上线的开发者 isTestEnvironment 为 true, application 为安卓应用的上下文
|
||||
boolean isTestEnv = false;
|
||||
switch (MoGoAiCloudClientConfig.getInstance().getNetMode()) {
|
||||
case HTTP_DNS_ENV_DEV:
|
||||
case HTTP_DNS_ENV_QA:
|
||||
case MoGoAiCloudClientConfig.HTTP_DNS_ENV_DEV:
|
||||
case MoGoAiCloudClientConfig.HTTP_DNS_ENV_QA:
|
||||
isTestEnv = true;
|
||||
break;
|
||||
case HTTP_DNS_ENV_RELEASE:
|
||||
case HTTP_DNS_ENV_DEMO:
|
||||
case MoGoAiCloudClientConfig.HTTP_DNS_ENV_RELEASE:
|
||||
case MoGoAiCloudClientConfig.HTTP_DNS_ENV_DEMO:
|
||||
isTestEnv = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.mogo.cloud.network.NetConstants.Companion.WRITE_TIMEOUT
|
||||
import com.mogo.cloud.network.SSLSocketFactoryUtils.createSSLSocketFactory
|
||||
import com.mogo.cloud.network.SSLSocketFactoryUtils.createTrustAllManager
|
||||
import com.mogo.cloud.network.interceptor.HttpHeaderInterceptor
|
||||
import com.mogo.cloud.network.interceptor.HttpDnsInterceptor
|
||||
import com.mogo.cloud.network.interceptor.HttpLoggingInterceptor
|
||||
import com.mogo.cloud.network.interceptor.HttpPassportInterceptor
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.mogo.cloud.network.interceptor
|
||||
|
||||
import com.elegant.log.simplelog.Logger
|
||||
import com.mogo.cloud.httpdns.MogoHttpDnsClient
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import java.lang.Exception
|
||||
|
||||
/**
|
||||
* created by wujifei on 2021/1/27 15:57
|
||||
* describe:
|
||||
*/
|
||||
class HttpDnsInterceptor : Interceptor {
|
||||
override fun intercept(chain: Interceptor.Chain): Response {
|
||||
val request: Request = chain.request()
|
||||
var url = request.url().toString()
|
||||
val host = request.url().host()
|
||||
try {
|
||||
MogoHttpDnsClient.getHttpDnsAddressUseCacheIfNecessary(0, request.url().host())?.let {
|
||||
url = url.replace(host, it)
|
||||
//Logger.d("DomainExchange", """oriHost: ${host} newHost: $it newUrl: $url""")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
Logger.e("DomainExchange", e.toString())
|
||||
}
|
||||
return chain.proceed(request.newBuilder().url(url).build())
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.mogo.cloud.network.interceptor
|
||||
|
||||
import com.mogo.cloud.httpdns.MogoHttpDnsConfig
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.Response
|
||||
@@ -14,9 +13,9 @@ class HttpHeaderInterceptor : Interceptor {
|
||||
val original = chain.request()
|
||||
val request = original.newBuilder()
|
||||
.header("token", MoGoAiCloudClient.getInstance().aiCloudClientConfig.token)
|
||||
.header("cityCode", MoGoAiCloudClient.getInstance().aiCloudClientConfig.iHttpDnsCurrentLocation.getCurrentLocation()?.cityCode.toString())
|
||||
.header("lat",MoGoAiCloudClient.getInstance().aiCloudClientConfig.iHttpDnsCurrentLocation.getCurrentLocation()?.lat.toString())
|
||||
.header("lon",MoGoAiCloudClient.getInstance().aiCloudClientConfig.iHttpDnsCurrentLocation.getCurrentLocation()?.lon.toString())
|
||||
.header("cityCode", MoGoAiCloudClient.getInstance().aiCloudClientConfig.iHttpCurrentLocation.currentLocation?.cityCode.toString())
|
||||
.header("lat",MoGoAiCloudClient.getInstance().aiCloudClientConfig.iHttpCurrentLocation.currentLocation?.lat.toString())
|
||||
.header("lon",MoGoAiCloudClient.getInstance().aiCloudClientConfig.iHttpCurrentLocation.currentLocation?.lon.toString())
|
||||
.header("env",MoGoAiCloudClient.getInstance().aiCloudClientConfig.netMode.toString())
|
||||
.header("sn",MoGoAiCloudClient.getInstance().aiCloudClientConfig.sn)
|
||||
.method(original.method(), original.body())
|
||||
|
||||
@@ -28,17 +28,10 @@ android {
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
// passport-for-sdk 外部SDK版本
|
||||
api 'com.zhidao.thirdlogin:third-login:1.0.8'
|
||||
api 'com.zhidao.thirdlogin:third-login:1.0.9'
|
||||
// passport-for-internal 内部SDK版本
|
||||
implementation 'com.zhidao.accountservice:account-sdk:1.0.18'
|
||||
|
||||
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
api "com.mogo.cloud:httpdns:${MOGO_HTTPDNS_VERSION}"
|
||||
} else {
|
||||
api project(':foudations:mogo-httpdns')
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
@@ -38,19 +38,3 @@
|
||||
-keepclassmembers,allowobfuscation class * {
|
||||
@com.google.gson.annotations.SerializedName <fields>;
|
||||
}
|
||||
|
||||
#-----Glide-----
|
||||
-keep public class * implements com.bumptech.glide.module.GlideModule
|
||||
-keep public class * extends com.bumptech.glide.module.AppGlideModule {
|
||||
<init>(...);
|
||||
}
|
||||
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
|
||||
**[] $VALUES;
|
||||
public *;
|
||||
}
|
||||
-keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder {
|
||||
*** rewind();
|
||||
}
|
||||
|
||||
#如果你的 target API 低于 Android API 27,请添加:
|
||||
-dontwarn com.bumptech.glide.load.resource.bitmap.VideoDecoder
|
||||
@@ -5,8 +5,6 @@ import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
import com.mogo.cloud.httpdns.MogoHttpDnsConfig;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -21,7 +19,6 @@ public class MoGoAiCloudClient {
|
||||
private static volatile MoGoAiCloudClient sInstance;
|
||||
|
||||
private MoGoAiCloudClientConfig mAiCloudClientConfig;
|
||||
private MogoHttpDnsConfig mHttpDnsConfig;
|
||||
private Context mContext;
|
||||
|
||||
private final List<IMoGoTokenCallback> mTokenCallbacks;
|
||||
@@ -81,7 +78,6 @@ public class MoGoAiCloudClient {
|
||||
public void onSuccess(String token, String sn) {
|
||||
com.zhidao.account.sdk.utils.Logger.i(TAG, "═════════════════════════════════════");
|
||||
com.zhidao.account.sdk.utils.Logger.i(TAG, "║ PassportVersion:" + com.mogo.cloud.passport.BuildConfig.VERSION_NAME);
|
||||
com.zhidao.account.sdk.utils.Logger.i(TAG, "║ HttpDnsVersion:" + com.mogo.cloud.httpdns.BuildConfig.VERSION_NAME);
|
||||
com.zhidao.account.sdk.utils.Logger.i(TAG, "║ ThirdLoginVersion:" + com.zhidao.thirdlogin.BuildConfig.VERSION_NAME);
|
||||
com.zhidao.account.sdk.utils.Logger.i(TAG, "║ MoGo鉴权成功 ");
|
||||
com.zhidao.account.sdk.utils.Logger.i(TAG, "║ SN:" + sn);
|
||||
|
||||
@@ -4,8 +4,7 @@ import android.text.TextUtils;
|
||||
|
||||
import com.elegant.log.simplelog.LogLevel;
|
||||
import com.elegant.log.simplelog.Logger;
|
||||
import com.mogo.cloud.httpdns.MogoHttpDnsConfig;
|
||||
import com.mogo.cloud.httpdns.listener.IHttpDnsCurrentLocation;
|
||||
import com.mogo.cloud.passport.location.ICurrentLocation;
|
||||
|
||||
/**
|
||||
* SDK 中的参数
|
||||
@@ -13,27 +12,41 @@ import com.mogo.cloud.httpdns.listener.IHttpDnsCurrentLocation;
|
||||
public class MoGoAiCloudClientConfig {
|
||||
private static final String TAG = "MoGoAiCloudClientConfig";
|
||||
|
||||
private static MoGoAiCloudClientConfig mMoGoAiCloudClientConfig;
|
||||
|
||||
private MoGoAiCloudClientConfig() {
|
||||
}
|
||||
|
||||
public static MoGoAiCloudClientConfig getInstance() {
|
||||
if (mMoGoAiCloudClientConfig == null) {
|
||||
synchronized (MoGoAiCloudClientConfig.class) {
|
||||
if (mMoGoAiCloudClientConfig == null) {
|
||||
mMoGoAiCloudClientConfig = new MoGoAiCloudClientConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
return mMoGoAiCloudClientConfig;
|
||||
private static final class MMoGoAiCloudClientConfigHolder {
|
||||
static final MoGoAiCloudClientConfig mMoGoAiCloudClientConfig = new MoGoAiCloudClientConfig();
|
||||
}
|
||||
|
||||
public static MoGoAiCloudClientConfig getInstance() {
|
||||
return MMoGoAiCloudClientConfigHolder.mMoGoAiCloudClientConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* 研发环境
|
||||
*/
|
||||
public static final int HTTP_DNS_ENV_DEV = 1;
|
||||
|
||||
/**
|
||||
* 测试环境
|
||||
*/
|
||||
public static final int HTTP_DNS_ENV_QA = 2;
|
||||
|
||||
/**
|
||||
* 线上环境
|
||||
*/
|
||||
public static final int HTTP_DNS_ENV_RELEASE = 3;
|
||||
|
||||
/**
|
||||
* 演示环境
|
||||
*/
|
||||
public static final int HTTP_DNS_ENV_DEMO = 4;
|
||||
|
||||
/**
|
||||
* 网络模式
|
||||
*/
|
||||
private int sNetMode = MogoHttpDnsConfig.HTTP_DNS_ENV_RELEASE;
|
||||
private int sNetMode = HTTP_DNS_ENV_RELEASE;
|
||||
|
||||
/**
|
||||
* 设备ID
|
||||
@@ -107,11 +120,6 @@ public class MoGoAiCloudClientConfig {
|
||||
*/
|
||||
private String sn = "";
|
||||
|
||||
/**
|
||||
* 循环检测延时时间
|
||||
*/
|
||||
private long mLoopCheckDelay;
|
||||
|
||||
/**
|
||||
* 是否为高精定位设备
|
||||
*/
|
||||
@@ -128,9 +136,9 @@ public class MoGoAiCloudClientConfig {
|
||||
private boolean isUseOriginSocket = false;
|
||||
|
||||
/**
|
||||
* 设置HttpDns的位置监听
|
||||
* 设置位置监听
|
||||
*/
|
||||
private IHttpDnsCurrentLocation mIHttpDnsCurrentLocation;
|
||||
private ICurrentLocation mIHttpCurrentLocation;
|
||||
|
||||
/**
|
||||
* 获取三方设备唯一ID
|
||||
@@ -199,7 +207,7 @@ public class MoGoAiCloudClientConfig {
|
||||
/**
|
||||
* 设置长链接公钥匙
|
||||
*
|
||||
* @param authPubKey 授权公钥匙
|
||||
* @param secretKey 授权公钥匙
|
||||
*/
|
||||
public void setSecretKey(String secretKey) {
|
||||
this.secretKey = secretKey;
|
||||
@@ -269,10 +277,10 @@ public class MoGoAiCloudClientConfig {
|
||||
* 获取当前网络环境
|
||||
*
|
||||
* @return 当前的网络环境是那个
|
||||
* @see MogoHttpDnsConfig#HTTP_DNS_ENV_DEV 研发环境
|
||||
* @see MogoHttpDnsConfig#HTTP_DNS_ENV_QA 测试环境
|
||||
* @see MogoHttpDnsConfig#HTTP_DNS_ENV_RELEASE 线上环境
|
||||
* @see MogoHttpDnsConfig#HTTP_DNS_ENV_DEMO 演示环境
|
||||
* @see #HTTP_DNS_ENV_DEV 研发环境
|
||||
* @see #HTTP_DNS_ENV_QA 测试环境
|
||||
* @see #HTTP_DNS_ENV_RELEASE 线上环境
|
||||
* @see #HTTP_DNS_ENV_DEMO 演示环境
|
||||
*/
|
||||
public int getNetMode() {
|
||||
return sNetMode;
|
||||
@@ -282,10 +290,10 @@ public class MoGoAiCloudClientConfig {
|
||||
* 设置当前网络环境
|
||||
*
|
||||
* @param sNetMode 当前的网络环境
|
||||
* @see MogoHttpDnsConfig#HTTP_DNS_ENV_DEV 研发环境
|
||||
* @see MogoHttpDnsConfig#HTTP_DNS_ENV_QA 测试环境
|
||||
* @see MogoHttpDnsConfig#HTTP_DNS_ENV_RELEASE 线上环境
|
||||
* @see MogoHttpDnsConfig#HTTP_DNS_ENV_DEMO 演示环境
|
||||
* @see #HTTP_DNS_ENV_DEV 研发环境
|
||||
* @see #HTTP_DNS_ENV_QA 测试环境
|
||||
* @see #HTTP_DNS_ENV_RELEASE 线上环境
|
||||
* @see #HTTP_DNS_ENV_DEMO 演示环境
|
||||
*/
|
||||
public void setNetMode(int sNetMode) {
|
||||
this.sNetMode = sNetMode;
|
||||
@@ -403,24 +411,6 @@ public class MoGoAiCloudClientConfig {
|
||||
isShowToastLog = showToastLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取HttpDns检查时间间隔
|
||||
*
|
||||
* @return 时间间隔,毫秒
|
||||
*/
|
||||
public long getLoopCheckDelay() {
|
||||
return mLoopCheckDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置HttpDns检查时间间隔
|
||||
*
|
||||
* @param loopCheckDelay 时间间隔,毫秒
|
||||
*/
|
||||
public void setLoopCheckDelay(long loopCheckDelay) {
|
||||
mLoopCheckDelay = loopCheckDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取是否为高精定位设备
|
||||
*
|
||||
@@ -474,21 +464,21 @@ public class MoGoAiCloudClientConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回HttpDns的位置信息,必须设置,否则将无法使用网络请求
|
||||
* 返回位置信息,必须设置,否则将无法使用网络请求
|
||||
*
|
||||
* @return 返回位置信息的回调
|
||||
*/
|
||||
public IHttpDnsCurrentLocation getIHttpDnsCurrentLocation() {
|
||||
return mIHttpDnsCurrentLocation;
|
||||
public ICurrentLocation getIHttpCurrentLocation() {
|
||||
return mIHttpCurrentLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回HttpDns的位置信息,必须设置,否则将无法使用网络请求
|
||||
* 返回位置信息,必须设置,否则将无法使用网络请求
|
||||
*
|
||||
* @param IHttpDnsCurrentLocation 返回位置信息的回调
|
||||
* @param IHttpCurrentLocation 返回位置信息的回调
|
||||
*/
|
||||
public void setIHttpDnsCurrentLocation(IHttpDnsCurrentLocation IHttpDnsCurrentLocation) {
|
||||
mIHttpDnsCurrentLocation = IHttpDnsCurrentLocation;
|
||||
public void setIHttpCurrentLocation(ICurrentLocation IHttpCurrentLocation) {
|
||||
mIHttpCurrentLocation = IHttpCurrentLocation;
|
||||
}
|
||||
|
||||
public boolean isUseOriginSocket() {
|
||||
@@ -518,11 +508,10 @@ public class MoGoAiCloudClientConfig {
|
||||
", isAnchor=" + isAnchor +
|
||||
", token='" + token + '\'' +
|
||||
", sn='" + sn + '\'' +
|
||||
", mLoopCheckDelay=" + mLoopCheckDelay +
|
||||
", mIsAccuracyDevice=" + mIsAccuracyDevice +
|
||||
", mServiceAppId='" + mServiceAppId + '\'' +
|
||||
", isUseOriginSocket=" + isUseOriginSocket +
|
||||
", mIHttpDnsCurrentLocation=" + mIHttpDnsCurrentLocation +
|
||||
", mIHttpCurrentLocation=" + mIHttpCurrentLocation +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.elegant.log.simplelog.Logger;
|
||||
import com.mogo.cloud.httpdns.MogoHttpDnsConfig;
|
||||
import com.mogo.cloud.passport.IPassport;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
@@ -15,6 +14,8 @@ import com.zhidao.account.sdk.Environment;
|
||||
import com.zhidao.account.sdk.callback.TicketInfoCallback;
|
||||
|
||||
import static com.mogo.cloud.passport.MoGoAiCloudClient.TAG;
|
||||
import static com.mogo.cloud.passport.MoGoAiCloudClientConfig.HTTP_DNS_ENV_DEV;
|
||||
import static com.mogo.cloud.passport.MoGoAiCloudClientConfig.HTTP_DNS_ENV_QA;
|
||||
|
||||
public class InternalPassportManager {
|
||||
|
||||
@@ -70,10 +71,10 @@ public class InternalPassportManager {
|
||||
int mode = mAiCloudClientConfig.getNetMode();
|
||||
Environment environment;
|
||||
switch (mode) {
|
||||
case MogoHttpDnsConfig.HTTP_DNS_ENV_DEV:
|
||||
case HTTP_DNS_ENV_DEV:
|
||||
environment = Environment.dev;
|
||||
break;
|
||||
case MogoHttpDnsConfig.HTTP_DNS_ENV_QA:
|
||||
case HTTP_DNS_ENV_QA:
|
||||
environment = Environment.qa;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.mogo.cloud.passport.location;
|
||||
|
||||
public interface ICurrentLocation {
|
||||
|
||||
SimpleLocation getCurrentLocation();
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.mogo.cloud.passport.location;
|
||||
|
||||
public class SimpleLocation {
|
||||
|
||||
private String cityCode;
|
||||
private double lat;
|
||||
private double lon;
|
||||
|
||||
public SimpleLocation(String cityCode, double lat, double lon) {
|
||||
this.cityCode = cityCode;
|
||||
this.lat = lat;
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public String getCityCode() {
|
||||
return cityCode;
|
||||
}
|
||||
|
||||
public void setCityCode(String cityCode) {
|
||||
this.cityCode = cityCode;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SimpleLocation{" +
|
||||
"cityCode='" + cityCode + '\'' +
|
||||
", lat=" + lat +
|
||||
", lon=" + lon +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package com.mogo.cloud.passport.third;
|
||||
import android.content.Context;
|
||||
|
||||
import com.elegant.log.simplelog.Logger;
|
||||
import com.mogo.cloud.httpdns.MogoHttpDnsConfig;
|
||||
import com.mogo.cloud.passport.IPassport;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
@@ -14,6 +13,8 @@ import com.zhidao.thirdlogin.model.TokenData;
|
||||
import com.zhidao.thirdlogin.network.LoginCallback;
|
||||
|
||||
import static com.mogo.cloud.passport.MoGoAiCloudClient.TAG;
|
||||
import static com.mogo.cloud.passport.MoGoAiCloudClientConfig.HTTP_DNS_ENV_DEV;
|
||||
import static com.mogo.cloud.passport.MoGoAiCloudClientConfig.HTTP_DNS_ENV_QA;
|
||||
|
||||
public class ThirdPassportManager {
|
||||
|
||||
@@ -70,10 +71,10 @@ public class ThirdPassportManager {
|
||||
*/
|
||||
Environment environment;
|
||||
switch (mAiCloudClientConfig.getNetMode()) {
|
||||
case MogoHttpDnsConfig.HTTP_DNS_ENV_DEV:
|
||||
case HTTP_DNS_ENV_DEV:
|
||||
environment = Environment.dev;
|
||||
break;
|
||||
case MogoHttpDnsConfig.HTTP_DNS_ENV_QA:
|
||||
case HTTP_DNS_ENV_QA:
|
||||
environment = Environment.qa;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.mogo.cloud.socket;
|
||||
|
||||
|
||||
import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_DEV;
|
||||
import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_QA;
|
||||
|
||||
import static com.mogo.cloud.passport.MoGoAiCloudClientConfig.HTTP_DNS_ENV_DEV;
|
||||
import static com.mogo.cloud.passport.MoGoAiCloudClientConfig.HTTP_DNS_ENV_QA;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
|
||||
@@ -36,26 +36,24 @@ PASSWORD=xintai2018
|
||||
RELEASE=true
|
||||
# AI CLOUD 云平台
|
||||
# 工具类
|
||||
MOGO_UTILS_VERSION=1.4.4.9
|
||||
MOGO_UTILS_VERSION=1.4.5.6
|
||||
# 网络请求
|
||||
MOGO_NETWORK_VERSION=1.4.4.9
|
||||
# 网络DNS
|
||||
MOGO_HTTPDNS_VERSION=1.4.4.9
|
||||
MOGO_NETWORK_VERSION=1.4.5.6
|
||||
# 鉴权
|
||||
MOGO_PASSPORT_VERSION=1.4.4.9
|
||||
MOGO_PASSPORT_VERSION=1.4.5.6
|
||||
# 常链接
|
||||
MOGO_SOCKET_VERSION=1.4.4.9
|
||||
MOGO_SOCKET_VERSION=1.4.5.6
|
||||
# 数据采集
|
||||
MOGO_REALTIME_VERSION=1.4.4.9
|
||||
MOGO_REALTIME_VERSION=1.4.5.6
|
||||
# 探路,道路事件发布,获取
|
||||
MOGO_TANLU_VERSION=1.4.4.9
|
||||
MOGO_TANLU_VERSION=1.4.5.6
|
||||
# 直播推流
|
||||
MOGO_LIVE_VERSION=1.4.4.9
|
||||
MOGO_LIVE_VERSION=1.4.5.6
|
||||
# 直播拉流
|
||||
MOGO_TRAFFICLIVE_VERSION=1.4.4.9
|
||||
MOGO_TRAFFICLIVE_VERSION=1.4.5.6
|
||||
# 定位服务
|
||||
MOGO_LOCATION_VERSION=1.4.4.9
|
||||
MOGO_LOCATION_VERSION=1.4.5.6
|
||||
# 远程通讯模块
|
||||
MOGO_TELEMATIC_VERSION=1.4.4.9
|
||||
MOGO_TELEMATIC_VERSION=1.4.5.6
|
||||
# v2x
|
||||
MOGO_V2X_VERSION=1.4.4.9
|
||||
MOGO_V2X_VERSION=1.4.5.6
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
:libraries:mogo-telematic
|
||||
:foudations:mogo-httpdns
|
||||
:foudations:mogo-passport
|
||||
:foudations:mogo-network
|
||||
:foudations:mogo-socket
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.realtime.core;
|
||||
|
||||
import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_DEMO;
|
||||
|
||||
import static com.mogo.cloud.passport.MoGoAiCloudClientConfig.HTTP_DNS_ENV_DEMO;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
@@ -41,7 +42,7 @@ public class SnapshotUploadInTime implements UploadInTimeHandler.IUploadInTimeLi
|
||||
*/
|
||||
public void start(Context context, String appId) {
|
||||
//开启长链服务
|
||||
SocketHandler.getInstance().initSocket(context, appId,0,0);
|
||||
SocketHandler.getInstance().initSocket(context, appId, 0, 0);
|
||||
//上传数据服务启动,定时上报
|
||||
UploadInTimeHandler.getInstance().start();
|
||||
UploadInTimeHandler.getInstance().setUploadInTimeListener(this);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.mogo.realtime.socket;
|
||||
|
||||
import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_DEMO;
|
||||
import static com.mogo.cloud.passport.MoGoAiCloudClientConfig.HTTP_DNS_ENV_DEMO;
|
||||
import static com.mogo.cloud.socket.SocketMsgType.MSG_TYPE_DOWNLINK_CAR_DATA;
|
||||
import static com.mogo.realtime.constant.RealTimeConstant.TAG;
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ include ':foudations:mogo-location'
|
||||
include ':foudations:mogo-live'
|
||||
include ':foudations:mogo-socket'
|
||||
include ':foudations:mogo-network'
|
||||
include ':foudations:mogo-httpdns'
|
||||
include ':foudations:mogo-passport'
|
||||
|
||||
include ':modules:mogo-trafficlive'
|
||||
|
||||
Reference in New Issue
Block a user