Merge remote-tracking branch 'origin/master'
This commit is contained in:
2
.idea/gradle.xml
generated
2
.idea/gradle.xml
generated
@@ -16,9 +16,11 @@
|
||||
<option value="$PROJECT_DIR$/foudations/mogo-commons" />
|
||||
<option value="$PROJECT_DIR$/foudations/mogo-httpdns" />
|
||||
<option value="$PROJECT_DIR$/foudations/mogo-passport" />
|
||||
<option value="$PROJECT_DIR$/foudations/mogo-socket" />
|
||||
<option value="$PROJECT_DIR$/modules" />
|
||||
<option value="$PROJECT_DIR$/modules/mogo-realtime" />
|
||||
<option value="$PROJECT_DIR$/modules/mogo-tanlu" />
|
||||
<option value="$PROJECT_DIR$/modules/realtime" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
|
||||
@@ -28,6 +28,7 @@ public class MoGoApplication extends Application {
|
||||
clientConfig.setNetMode(MogoHttpDnsConfig.HTTP_DNS_ENV_QA);
|
||||
clientConfig.setThirdLogin(true);
|
||||
clientConfig.setShowDebugLog(true);
|
||||
clientConfig.setNeedUploadCoordinatesDurationInTime(true);
|
||||
clientConfig.setThirdPartyAppKey("bydauto");
|
||||
clientConfig.setThirdPartyDeviceId("bydauto");
|
||||
clientConfig.setLoopCheckDelay(15 * 1000);
|
||||
|
||||
140
config.gradle
140
config.gradle
@@ -2,122 +2,122 @@ ext {
|
||||
time = ""
|
||||
kotlin_version = "1.4.10"
|
||||
android = [
|
||||
compileSdkVersion : 28,
|
||||
buildToolsVersion : "29.0.2",
|
||||
minSdkVersion : 19,
|
||||
targetSdkVersion : 22,
|
||||
compileSdkVersion: 28,
|
||||
buildToolsVersion: "29.0.2",
|
||||
minSdkVersion : 19,
|
||||
targetSdkVersion : 22,
|
||||
]
|
||||
dependencies = [
|
||||
// androidx
|
||||
androidxappcompat : "androidx.appcompat:appcompat:1.1.0",
|
||||
androidxccorektx : "androidx.core:core-ktx:1.3.2",
|
||||
androidxconstraintlayout : "androidx.constraintlayout:constraintlayout:1.1.3",
|
||||
boostmultidex : "com.bytedance.boost_multidex:boost_multidex:1.0.1",
|
||||
androidxviewpager2 : "androidx.viewpager2:viewpager2:1.0.0",
|
||||
androidxrecyclerview : "androidx.recyclerview:recyclerview:1.1.0",
|
||||
androidxcardview : "androidx.cardview:cardview:1.0.0",
|
||||
localbroadcastmanager : "androidx.localbroadcastmanager:localbroadcastmanager:1.0.0",
|
||||
androidxappcompat : "androidx.appcompat:appcompat:1.1.0",
|
||||
androidxccorektx : "androidx.core:core-ktx:1.3.2",
|
||||
androidxconstraintlayout : "androidx.constraintlayout:constraintlayout:1.1.3",
|
||||
boostmultidex : "com.bytedance.boost_multidex:boost_multidex:1.0.1",
|
||||
androidxviewpager2 : "androidx.viewpager2:viewpager2:1.0.0",
|
||||
androidxrecyclerview : "androidx.recyclerview:recyclerview:1.1.0",
|
||||
androidxcardview : "androidx.cardview:cardview:1.0.0",
|
||||
localbroadcastmanager : "androidx.localbroadcastmanager:localbroadcastmanager:1.0.0",
|
||||
// flexbox
|
||||
flexbox : 'com.google.android:flexbox:2.0.1',
|
||||
flexbox : 'com.google.android:flexbox:2.0.1',
|
||||
// 测试
|
||||
junit : "junit:junit:4.12",
|
||||
androidxjunit : "androidx.test.ext:junit:1.1.0",
|
||||
androidxespressocore : "androidx.test.espresso:espresso-core:3.1.1",
|
||||
junit : "junit:junit:4.12",
|
||||
androidxjunit : "androidx.test.ext:junit:1.1.0",
|
||||
androidxespressocore : "androidx.test.espresso:espresso-core:3.1.1",
|
||||
// 地图
|
||||
amapnavi3dmap : "com.amap.api:navi-3dmap:7.2.0_3dmap7.2.0",
|
||||
amapsearch : "com.amap.api:search:7.1.0",
|
||||
amaplocation : "com.amap.api:location:5.2.0",
|
||||
amapnavi3dmap : "com.amap.api:navi-3dmap:7.2.0_3dmap7.2.0",
|
||||
amapsearch : "com.amap.api:search:7.1.0",
|
||||
amaplocation : "com.amap.api:location:5.2.0",
|
||||
// json 转换
|
||||
gson : "com.google.code.gson:gson:2.8.4",
|
||||
gson : "com.google.code.gson:gson:2.8.4",
|
||||
// 内存泄漏检测
|
||||
debugleakcanary : "com.squareup.leakcanary:leakcanary-android:1.6.1",
|
||||
releaseleakcanary : "com.squareup.leakcanary:leakcanary-android-no-op:1.6.1",
|
||||
testleakcanary : "com.squareup.leakcanary:leakcanary-android-no-op:1.6.1",
|
||||
debugleakcanary : "com.squareup.leakcanary:leakcanary-android:1.6.1",
|
||||
releaseleakcanary : "com.squareup.leakcanary:leakcanary-android-no-op:1.6.1",
|
||||
testleakcanary : "com.squareup.leakcanary:leakcanary-android-no-op:1.6.1",
|
||||
//rxJava
|
||||
rxjava : "io.reactivex.rxjava2:rxjava:2.2.2",
|
||||
rxandroid : "io.reactivex.rxjava2:rxandroid:2.1.0",
|
||||
rxjava : "io.reactivex.rxjava2:rxjava:2.2.2",
|
||||
rxandroid : "io.reactivex.rxjava2:rxandroid:2.1.0",
|
||||
// arouter
|
||||
arouter : "com.alibaba:arouter-api:1.5.0",
|
||||
aroutercompiler : "com.alibaba:arouter-compiler:1.2.2",
|
||||
arouter : "com.alibaba:arouter-api:1.5.0",
|
||||
aroutercompiler : "com.alibaba:arouter-compiler:1.2.2",
|
||||
// glide
|
||||
glide : 'com.github.bumptech.glide:glide:4.8.0',
|
||||
glideokhttp3 : 'com.github.bumptech.glide:okhttp3-integration:4.8.0',
|
||||
glideanno : 'com.github.bumptech.glide:annotations:4.8.0',
|
||||
glidecompiler : 'com.github.bumptech.glide:compiler:4.8.0',
|
||||
supportannos : "com.android.support:support-annotations:28.0.0",
|
||||
okhttpinterceptor : "com.squareup.okhttp3:logging-interceptor:3.12.0",
|
||||
glide : 'com.github.bumptech.glide:glide:4.8.0',
|
||||
glideokhttp3 : 'com.github.bumptech.glide:okhttp3-integration:4.8.0',
|
||||
glideanno : 'com.github.bumptech.glide:annotations:4.8.0',
|
||||
glidecompiler : 'com.github.bumptech.glide:compiler:4.8.0',
|
||||
supportannos : "com.android.support:support-annotations:28.0.0",
|
||||
okhttpinterceptor : "com.squareup.okhttp3:logging-interceptor:3.12.0",
|
||||
// fresco
|
||||
fresco : 'com.facebook.fresco:fresco:1.9.0',
|
||||
fresco : 'com.facebook.fresco:fresco:1.9.0',
|
||||
// 公司服务 - 语音
|
||||
aiassist : "com.zhidaoauto.common:service:1.0.8.4",
|
||||
aiassist : "com.zhidaoauto.common:service:1.0.8.4",
|
||||
// 语音替换方案 暂时只用TTS 解决焦点问题
|
||||
aiassistReplace : "com.zhidao.mogoVoicesdk:voice:1.0.5",
|
||||
aiassistReplace : "com.zhidao.mogoVoicesdk:voice:1.0.5",
|
||||
// 公司服务 - 埋点
|
||||
analytics : "com.elegant.analytics:analytics:1.1.28",
|
||||
analytics : "com.elegant.analytics:analytics:1.1.28",
|
||||
|
||||
retrofit : "com.squareup.retrofit2:retrofit:2.6.0",
|
||||
retrofitadapter : "com.squareup.retrofit2:adapter-rxjava2:2.6.0",
|
||||
retrofitconvertergson : "com.squareup.retrofit2:converter-gson:2.6.0",
|
||||
retrofitconverterscalars : "com.squareup.retrofit2:converter-scalars:2.1.0",
|
||||
retrofit : "com.squareup.retrofit2:retrofit:2.6.0",
|
||||
retrofitadapter : "com.squareup.retrofit2:adapter-rxjava2:2.6.0",
|
||||
retrofitconvertergson : "com.squareup.retrofit2:converter-gson:2.6.0",
|
||||
retrofitconverterscalars : "com.squareup.retrofit2:converter-scalars:2.1.0",
|
||||
|
||||
|
||||
// leakcanary
|
||||
leakcanary : 'com.squareup.leakcanary:leakcanary-android:1.5.4',
|
||||
leakcanarynoop : 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4',
|
||||
leakcanary : 'com.squareup.leakcanary:leakcanary-android:1.5.4',
|
||||
leakcanarynoop : 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4',
|
||||
|
||||
// add for room
|
||||
room : "android.arch.persistence.room:runtime:1.1.1",
|
||||
roomAnnotationProcessor : 'android.arch.persistence.room:compiler:1.1.1',
|
||||
room : "android.arch.persistence.room:runtime:1.1.1",
|
||||
roomAnnotationProcessor : 'android.arch.persistence.room:compiler:1.1.1',
|
||||
|
||||
// rxjava2 with room
|
||||
roomRxjava : "android.arch.persistence.room:rxjava2:1.1.1",
|
||||
roomRxjava : "android.arch.persistence.room:rxjava2:1.1.1",
|
||||
|
||||
// material
|
||||
material : 'com.google.android.material:material:1.1.0',
|
||||
material : 'com.google.android.material:material:1.1.0',
|
||||
|
||||
indicator : 'com.github.zhpanvip:viewpagerindicator:1.0.4',
|
||||
indicator : 'com.github.zhpanvip:viewpagerindicator:1.0.4',
|
||||
|
||||
|
||||
//
|
||||
jetbrainsannotationsjava5 : "org.jetbrains:annotations-java5:15.0",
|
||||
jetbrainsannotationsjava5: "org.jetbrains:annotations-java5:15.0",
|
||||
|
||||
// 统一登录
|
||||
accountsdk : "com.zhidao.accountservice:account-sdk:1.0.18",
|
||||
accountsdk : "com.zhidao.accountservice:account-sdk:1.0.18",
|
||||
// crash
|
||||
crashSdk : "com.zhidaoauto.crash.log:library:1.0.5",
|
||||
crashSdk : "com.zhidaoauto.crash.log:library:1.0.5",
|
||||
|
||||
//探路
|
||||
videoarmv7 : "com.shuyu:gsyVideoPlayer-armv7a:7.1.2",
|
||||
videoarm64 : "com.shuyu:gsyVideoPlayer-arm64:7.1.2",
|
||||
videojava : "com.shuyu:gsyVideoPlayer-java:7.1.2",
|
||||
eventbus : "org.greenrobot:eventbus:3.1.1",
|
||||
videoprocessor : "com.zhidao.video:video-processor:1.0.2.1",
|
||||
livesdk : "com.tencent.liteavsdk:LiteAVSDK_Smart:7.4.9211",
|
||||
videoarmv7 : "com.shuyu:gsyVideoPlayer-armv7a:7.1.2",
|
||||
videoarm64 : "com.shuyu:gsyVideoPlayer-arm64:7.1.2",
|
||||
videojava : "com.shuyu:gsyVideoPlayer-java:7.1.2",
|
||||
eventbus : "org.greenrobot:eventbus:3.1.1",
|
||||
videoprocessor : "com.zhidao.video:video-processor:1.0.2.1",
|
||||
livesdk : "com.tencent.liteavsdk:LiteAVSDK_Smart:7.4.9211",
|
||||
|
||||
coroutinescore : "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3",
|
||||
coroutinesandroid : "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3",
|
||||
coroutinescore : "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3",
|
||||
coroutinesandroid : "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3",
|
||||
|
||||
aspectj : "org.aspectj:aspectjrt:1.8.9",
|
||||
aspectj : "org.aspectj:aspectjrt:1.8.9",
|
||||
|
||||
adasapi : "com.zhidao.autopilot.support:adas:1.0.6.6",
|
||||
adasconfigapi : "com.zhidao.adasconfig:adasconfig:1.1.5.2",
|
||||
adasapi : "com.zhidao.autopilot.support:adas:1.0.6.6",
|
||||
adasconfigapi : "com.zhidao.adasconfig:adasconfig:1.1.5.2",
|
||||
|
||||
// 个人中心的SDK
|
||||
personalsdk : "com.zhidaoauto.person.info:data:1.0.1",
|
||||
personalsdk : "com.zhidaoauto.person.info:data:1.0.1",
|
||||
|
||||
// obu sdk
|
||||
obusdk : "com.zhidao.enterprise.smartv2x:smartv2x:1.0.0.3",
|
||||
obusdk : "com.zhidao.enterprise.smartv2x:smartv2x:1.0.0.3",
|
||||
|
||||
// google
|
||||
googlezxing : "com.google.zxing:core:3.3.3",
|
||||
litezxing : "com.google.zxing:litezxing:1.0.29.8",
|
||||
googlezxing : "com.google.zxing:core:3.3.3",
|
||||
litezxing : "com.google.zxing:litezxing:1.0.29.8",
|
||||
|
||||
// android - room
|
||||
androidxroomruntime : "androidx.room:room-runtime:2.2.3",
|
||||
androidxroomcompiler : "androidx.room:room-compiler:2.2.3",
|
||||
androidxroomktx : "androidx.room:room-ktx:2.2.3",
|
||||
androidxroomruntime : "androidx.room:room-runtime:2.2.3",
|
||||
androidxroomcompiler : "androidx.room:room-compiler:2.2.3",
|
||||
androidxroomktx : "androidx.room:room-ktx:2.2.3",
|
||||
|
||||
mogoutils : "com.mogo.commons:mogo-utils:2.0.12",
|
||||
mogoutils : "com.mogo.commons:mogo-utils:2.0.12",
|
||||
|
||||
|
||||
]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
GROUP=com.mogo.cloud
|
||||
POM_ARTIFACT_ID=commons
|
||||
VERSION_CODE=1
|
||||
VERSION_NAME=1.0.1-snapshots
|
||||
VERSION_NAME=1.0.1-SNAPSHOT
|
||||
@@ -1,4 +1,4 @@
|
||||
GROUP=com.mogo.cloud
|
||||
POM_ARTIFACT_ID=passport
|
||||
VERSION_CODE=1
|
||||
VERSION_NAME=1.0.0
|
||||
VERSION_NAME=1.0.0-SNAPSHOT
|
||||
@@ -56,6 +56,11 @@ public class MoGoAiCloudClientConfig {
|
||||
*/
|
||||
private long mLoopCheckDelay;
|
||||
|
||||
/**
|
||||
* 是否上传当前位置信息
|
||||
*/
|
||||
private boolean isNeedUploadCoordinatesDurationInTime;
|
||||
|
||||
/**
|
||||
* 设置HttpDns的位置监听
|
||||
*/
|
||||
@@ -237,6 +242,14 @@ public class MoGoAiCloudClientConfig {
|
||||
mIHttpDnsCurrentLocation = IHttpDnsCurrentLocation;
|
||||
}
|
||||
|
||||
public boolean isNeedUploadCoordinatesDurationInTime() {
|
||||
return isNeedUploadCoordinatesDurationInTime;
|
||||
}
|
||||
|
||||
public void setNeedUploadCoordinatesDurationInTime(boolean needUploadCoordinatesDurationInTime) {
|
||||
isNeedUploadCoordinatesDurationInTime = needUploadCoordinatesDurationInTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MoGoAiCloudClientConfig{" +
|
||||
@@ -249,6 +262,7 @@ public class MoGoAiCloudClientConfig {
|
||||
", token='" + token + '\'' +
|
||||
", sn='" + sn + '\'' +
|
||||
", mLoopCheckDelay=" + mLoopCheckDelay +
|
||||
", isNeedUploadCoordinatesDurationInTime=" + isNeedUploadCoordinatesDurationInTime +
|
||||
", mIHttpDnsCurrentLocation=" + mIHttpDnsCurrentLocation +
|
||||
'}';
|
||||
}
|
||||
|
||||
1
foudations/mogo-socket/.gitignore
vendored
Normal file
1
foudations/mogo-socket/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
38
foudations/mogo-socket/build.gradle
Normal file
38
foudations/mogo-socket/build.gradle
Normal file
@@ -0,0 +1,38 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
// 长链
|
||||
implementation 'com.zhidao.socket:built-in-socket:1.0.17'
|
||||
// 上报位置
|
||||
implementation 'com.zhidao.locupload:loc-upload-sdk:1.1.7'
|
||||
implementation project(path: ':foudations:mogo-passport')
|
||||
api rootProject.ext.dependencies.mogoutils
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
0
foudations/mogo-socket/consumer-rules.pro
Normal file
0
foudations/mogo-socket/consumer-rules.pro
Normal file
4
foudations/mogo-socket/gradle.properties
Normal file
4
foudations/mogo-socket/gradle.properties
Normal file
@@ -0,0 +1,4 @@
|
||||
GROUP=com.mogo.cloud
|
||||
POM_ARTIFACT_ID=socket
|
||||
VERSION_CODE=1
|
||||
VERSION_NAME=1.0.0
|
||||
21
foudations/mogo-socket/proguard-rules.pro
vendored
Normal file
21
foudations/mogo-socket/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
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.realtime;
|
||||
package com.mogo.cloud.socket;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
@@ -21,6 +21,6 @@ public class ExampleInstrumentedTest {
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("com.mogo.realtime.test", appContext.getPackageName());
|
||||
assertEquals("com.mogo.cloud.socket.test", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
5
foudations/mogo-socket/src/main/AndroidManifest.xml
Normal file
5
foudations/mogo-socket/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.cloud.socket">
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.mogo.cloud.socket;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
|
||||
/**
|
||||
* socket 长链
|
||||
*/
|
||||
public interface IMogoCloudSocketManager {
|
||||
|
||||
/**
|
||||
* 初始化,各模块不用关心
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param appId 一般为包名,不参与通道的建立,一般用于发消息
|
||||
*/
|
||||
void init(Context context, String appId);
|
||||
|
||||
/**
|
||||
* 注册消息监听
|
||||
*
|
||||
* @param msgType 消息类型
|
||||
* @param listener 回调
|
||||
*/
|
||||
void registerOnMessageListener(int msgType, IMogoCloudSocketOnMessageListener listener);
|
||||
|
||||
/**
|
||||
* 注销消息监听
|
||||
*
|
||||
* @param msgType 消息类型
|
||||
* @param listener 回调
|
||||
*/
|
||||
void unregisterOnMessageListener(int msgType, IMogoCloudSocketOnMessageListener listener);
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param body 消息体
|
||||
* @param listener 回执监听
|
||||
*/
|
||||
void sendMsg(MsgBody body, IMogoCloudSocketMsgAckListener listener);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mogo.cloud.socket;
|
||||
|
||||
/**
|
||||
* 消息回执监听
|
||||
*/
|
||||
public interface IMogoCloudSocketMsgAckListener {
|
||||
|
||||
/**
|
||||
* 长连接消息回执
|
||||
* msgId: 消息id
|
||||
*/
|
||||
void onAck(long msgId);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.mogo.cloud.socket;
|
||||
|
||||
/**
|
||||
* 消息回调
|
||||
*/
|
||||
public interface IMogoCloudSocketOnMessageListener<T> {
|
||||
|
||||
Class<T> target();
|
||||
|
||||
void onMsgReceived(T obj);
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
package com.mogo.realtime.connect;
|
||||
package com.mogo.cloud.socket;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-31
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class MsgBody {
|
||||
@@ -13,16 +10,6 @@ public class MsgBody {
|
||||
*/
|
||||
private int mMsgType;
|
||||
|
||||
// /**
|
||||
// * 服务端分发,业务线
|
||||
// */
|
||||
// private int mProductLine = MogoCommon.Product.mogoBussiness_VALUE;
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// */
|
||||
// private int mHeaderType = MogoConnsvr.MsgType.mogoMsgTypeDispatchSvrNoRspReq_VALUE;
|
||||
|
||||
/**
|
||||
* 是否回执
|
||||
*/
|
||||
@@ -38,17 +25,17 @@ public class MsgBody {
|
||||
*/
|
||||
private Object mContent;
|
||||
|
||||
public MsgBody msgType( int msgType ) {
|
||||
public MsgBody msgType(int msgType) {
|
||||
this.mMsgType = msgType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MsgBody ack( boolean ack ) {
|
||||
public MsgBody ack(boolean ack) {
|
||||
this.mAck = ack;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MsgBody content( Object object ) {
|
||||
public MsgBody content(Object object) {
|
||||
this.mContent = object;
|
||||
return this;
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
package com.mogo.cloud.socket;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
import com.zhidao.locupload.Platform;
|
||||
import com.zhidao.ptech.connsvr.protocol.MogoConnsvr;
|
||||
import com.zhidao.socket.Callback;
|
||||
import com.zhidao.socket.CallbackManager;
|
||||
import com.zhidao.socket.Environment;
|
||||
import com.zhidao.socket.SocketClient;
|
||||
import com.zhidao.socket.SocketConfig;
|
||||
import com.zhidao.socket.utils.RequestUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class SocketManager implements IMogoCloudSocketManager, Callback {
|
||||
|
||||
private static final String TAG = "SocketManager";
|
||||
private static volatile SocketManager mInstance;
|
||||
private MoGoAiCloudClientConfig cloudClientConfig;
|
||||
private String mAppId;
|
||||
|
||||
private SocketManager() {
|
||||
CallbackManager.getInstance().register(this);
|
||||
cloudClientConfig = MoGoAiCloudClient.getInstance().getAiCloudClientConfig();
|
||||
}
|
||||
|
||||
public static SocketManager getInstance() {
|
||||
if (mInstance == null) {
|
||||
synchronized (SocketManager.class) {
|
||||
if (mInstance == null) {
|
||||
mInstance = new SocketManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理消息分发
|
||||
* <p>
|
||||
* key - msgType
|
||||
*/
|
||||
private Map<Integer, List<IMogoCloudSocketOnMessageListener>> mListeners = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 管理消息回执
|
||||
* <p>
|
||||
* key - msgId
|
||||
*/
|
||||
private Map<Long, IMogoCloudSocketMsgAckListener> mAckListeners = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
public static final int MAX_CAP = 64; //保证充足的容量应对非常延时的推送
|
||||
private final ArrayList<Long> mReceivedMsgId = new ArrayList<>(MAX_CAP);
|
||||
private int mCurrentIndex = 0;
|
||||
|
||||
@Override
|
||||
public void init(Context context, String appId) {
|
||||
mAppId = appId;
|
||||
SocketConfig.instance()
|
||||
.setAppContext(context.getApplicationContext())
|
||||
.setEnvironment(getEnvironment())
|
||||
.setClient(Platform.getClient(Platform.car))
|
||||
.setChannelId(SocketServicesConstants.SOCKET_CHANNEL_ID)
|
||||
.setOpenAnalytics(true)
|
||||
.setSn(cloudClientConfig.getSn())
|
||||
.setDebug(cloudClientConfig.isShowDebugLog());
|
||||
SocketClient.getInstance().start(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerOnMessageListener(int msgType, IMogoCloudSocketOnMessageListener listener) {
|
||||
if (mListeners.containsKey(msgType)) {
|
||||
Logger.w(TAG, "msgType %d is exist.", msgType);
|
||||
}
|
||||
if (!mListeners.containsKey(msgType)) {
|
||||
mListeners.put(msgType, new ArrayList<>());
|
||||
}
|
||||
mListeners.get(msgType).add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterOnMessageListener(int msgType, IMogoCloudSocketOnMessageListener listener) {
|
||||
if (listener == null) {
|
||||
return;
|
||||
}
|
||||
if (!mListeners.containsKey(msgType)) {
|
||||
return;
|
||||
}
|
||||
List<IMogoCloudSocketOnMessageListener> listeners = mListeners.get(msgType);
|
||||
if (listeners != null) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMsg(MsgBody body, IMogoCloudSocketMsgAckListener listener) {
|
||||
Logger.d(TAG, "sendMsg.");
|
||||
final byte[] pb = convertToPBBytes(body.getMsgType(), objectToBytes(body.getContent()));
|
||||
RequestUtil.sendPayloadData(mAppId, 2, pb, 1, true, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NonNull CallbackManager manager, @NonNull byte[] message, String appId, long msgId) {
|
||||
try {
|
||||
MogoConnsvr.Payload payload = MogoConnsvr.Payload.parseFrom(message);
|
||||
int msgType = payload.getMsgType();
|
||||
Logger.d(TAG, "received msg type = %d", msgType);
|
||||
List<IMogoCloudSocketOnMessageListener> listeners = mListeners.get(msgType);
|
||||
if (listeners != null && !listeners.isEmpty()) {
|
||||
Iterator<IMogoCloudSocketOnMessageListener> iterator = listeners.iterator();
|
||||
if (msgId != 0) { //兼容老版本
|
||||
if (mReceivedMsgId.contains(msgId)) { // 避免消息重发
|
||||
return;
|
||||
}
|
||||
cacheLastReceivedMsgId(msgId);
|
||||
}
|
||||
Object object = null;
|
||||
while (iterator.hasNext()) {
|
||||
IMogoCloudSocketOnMessageListener listener = iterator.next();
|
||||
if (object == null) {
|
||||
object = GsonUtil.objectFromJson(payload.getPayload().toStringUtf8(), listener.target());
|
||||
}
|
||||
if (listener != null) {
|
||||
Logger.d(TAG, "received msgId = %s, content = %s", msgId, payload.getPayload().toStringUtf8());
|
||||
listener.onMsgReceived(object);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
Logger.e(TAG, e, "parse msg error.");
|
||||
}
|
||||
}
|
||||
|
||||
private void cacheLastReceivedMsgId(long msgId) {
|
||||
if (msgId == 0) {
|
||||
return;
|
||||
}
|
||||
synchronized (this) {
|
||||
mReceivedMsgId.add(mCurrentIndex % MAX_CAP, msgId);
|
||||
mCurrentIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAck(@NonNull CallbackManager manager, @NonNull byte[] headerBytes, byte[] content) {
|
||||
try {
|
||||
MogoConnsvr.Header header = MogoConnsvr.Header.parseFrom(headerBytes);
|
||||
int msgType = header.getMsgType();
|
||||
String appId = header.getAppId();
|
||||
int productLine = header.getProductLine();
|
||||
long msgId = header.getMsgId();
|
||||
IMogoCloudSocketMsgAckListener listener = mAckListeners.remove(msgId);
|
||||
if (listener != null) {
|
||||
listener.onAck(msgId);
|
||||
}
|
||||
Logger.d(TAG, "send message success: msgType = %d, appId = %s, productLine = %d", msgType, appId, productLine);
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private Environment getEnvironment() {
|
||||
switch (cloudClientConfig.getNetMode()) {
|
||||
case 1:
|
||||
return Environment.dev;
|
||||
case 2:
|
||||
case 4:
|
||||
return Environment.qa;
|
||||
case 3:
|
||||
default:
|
||||
return Environment.release;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] objectToBytes(Object obj) {
|
||||
String jsonStr = GsonUtil.jsonFromObject(obj);
|
||||
return jsonStr.getBytes();
|
||||
}
|
||||
|
||||
private byte[] convertToPBBytes(int msgType, byte[] payloadBytes) {
|
||||
MogoConnsvr.Payload payloadData = MogoConnsvr.Payload.newBuilder()
|
||||
.setMsgType(msgType)
|
||||
.setPayload(ByteString.copyFrom(payloadBytes)).build();
|
||||
return payloadData.toByteArray();
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
mListeners.clear();
|
||||
mListeners = null;
|
||||
cloudClientConfig = null;
|
||||
mInstance = null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.mogo.cloud.socket;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
public class SocketServicesConstants {
|
||||
|
||||
/**
|
||||
* 建立长链的通道ID
|
||||
*/
|
||||
@Keep
|
||||
public static final String SOCKET_CHANNEL_ID = "dataCrawler";
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.realtime;
|
||||
package com.mogo.cloud.socket;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -17,9 +17,14 @@ org.gradle.jvmargs=-Xmx2048m
|
||||
android.useAndroidX=true
|
||||
# Automatically convert third-party libraries to use AndroidX
|
||||
android.enableJetifier=true
|
||||
|
||||
## maven 配置
|
||||
RELEASE_REPOSITORY_URL=http://nexus.zhidaoauto.com/repository/maven-releases/
|
||||
SNAPSHOT_REPOSITORY_URL=http://nexus.zhidaoauto.com/repository/maven-snapshots/
|
||||
USERNAME=xintai
|
||||
PASSWORD=xintai2018
|
||||
PASSWORD=xintai2018
|
||||
# AI CLOUD 云平台
|
||||
MOGO_CLOUD_COMMONS_VERSION= 1.0.0
|
||||
MOGO_CLOUD_HTTPDNS_VERSION= 1.0.0
|
||||
MOGO_CLOUD_PASSPORT_VERSION=1.0.0
|
||||
MOGO_CLOUD_TANLU_VERSION= 1.0.0
|
||||
MOGO_CLOUD_REALTIME_VERSION=1.0.0
|
||||
@@ -10,7 +10,6 @@ android {
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles "consumer-rules.pro"
|
||||
}
|
||||
|
||||
@@ -28,10 +27,7 @@ android {
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation project(path: ':foudations:mogo-passport')
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
implementation project(":foudations:mogo-commons")
|
||||
implementation project(":foudations:mogo-socket")
|
||||
}
|
||||
@@ -2,16 +2,11 @@ package com.mogo.realtime.Imp;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.cloud.socket.IMogoCloudSocketOnMessageListener;
|
||||
import com.mogo.realtime.Interface.RealTimeProvider;
|
||||
import com.mogo.realtime.connect.IMogoOnMessageListener;
|
||||
import com.mogo.realtime.connect.MsgBody;
|
||||
import com.mogo.realtime.constant.SnapshotUploadInTime;
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.realtime.location.MogoRTKLocation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
@@ -23,11 +18,17 @@ public class RealTimeProviderImp implements RealTimeProvider {
|
||||
|
||||
@Override
|
||||
public List<ADASRecognizedResult> getLastADASRecognizedResult() {
|
||||
if (mDelegate != null) {
|
||||
return mDelegate.getLastADASRecognizedResult();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDistanceBetweenTwoPoints() {
|
||||
if (mDelegate != null) {
|
||||
return mDelegate.getDistanceBetweenTwoPoints();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -39,16 +40,17 @@ public class RealTimeProviderImp implements RealTimeProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerOnMessageListener(int msgType, IMogoOnMessageListener listener) {
|
||||
public void registerOnMessageListener(int msgType, IMogoCloudSocketOnMessageListener listener) {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.registerOnMessageListener(msgType, listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMsg(MsgBody body, IMogoOnMessageListener listener) {
|
||||
public void sendMsg(Object body, IMogoCloudSocketOnMessageListener listener) {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.sendMsg(body, listener);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,13 @@ public final class RealTimeApisHandler {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public RealTimeServiceApis getApis(){
|
||||
if (sApis == null){
|
||||
synchronized (this){
|
||||
public void initRealTimeEnvironment() {
|
||||
//socketeinit locationinit rtkinit
|
||||
}
|
||||
|
||||
public RealTimeServiceApis getApis() {
|
||||
if (sApis == null) {
|
||||
synchronized (this) {
|
||||
// sApis = new RealTimeServiceApis();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,19 +2,17 @@ package com.mogo.realtime.Interface;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.realtime.connect.IMogoOnMessageListener;
|
||||
import com.mogo.realtime.connect.MsgBody;
|
||||
import com.mogo.cloud.socket.IMogoCloudSocketOnMessageListener;
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 描述
|
||||
* @since: 2021/1/21
|
||||
*/
|
||||
public interface RealTimeProvider {
|
||||
public interface RealTimeProvider<T> {
|
||||
/**
|
||||
* 获取 adas 识别列表
|
||||
*
|
||||
@@ -28,7 +26,7 @@ public interface RealTimeProvider {
|
||||
float getDistanceBetweenTwoPoints();
|
||||
|
||||
/**
|
||||
* 初始化,各模块不用关心
|
||||
* 初始化
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param appId 一般为包名,不参与通道的建立,一般用于发消息
|
||||
@@ -41,7 +39,7 @@ public interface RealTimeProvider {
|
||||
* @param msgType 消息类型
|
||||
* @param listener 回调
|
||||
*/
|
||||
void registerOnMessageListener(int msgType, IMogoOnMessageListener listener);
|
||||
void registerOnMessageListener(int msgType, IMogoCloudSocketOnMessageListener listener);
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
@@ -49,5 +47,5 @@ public interface RealTimeProvider {
|
||||
* @param body 消息体
|
||||
* @param listener 回执监听
|
||||
*/
|
||||
void sendMsg(MsgBody body, IMogoOnMessageListener listener );
|
||||
void sendMsg(T body, IMogoCloudSocketOnMessageListener listener );
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.mogo.realtime.connect;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-31
|
||||
* <p>
|
||||
* 消息回调
|
||||
*/
|
||||
public interface IMogoOnMessageListener< T > {
|
||||
|
||||
Class< T > target();
|
||||
|
||||
void onMsgReceived(T obj);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.mogo.realtime.connect;
|
||||
|
||||
public enum WebSocketMsgType {
|
||||
|
||||
MSG_TYPE_UPLINK_CAR_DATA(0,"自车与ADAS数据"),
|
||||
MSG_TYPE_DOWNLINK_CAR_DATA(1,"服务端下发车辆信息"),
|
||||
MSG_TYPE_ACK(3, "ACK");
|
||||
|
||||
private int msgType;
|
||||
private String msg;
|
||||
|
||||
WebSocketMsgType(int msgType, String msg) {
|
||||
this.msgType = msgType;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public int getMsgType() {
|
||||
return msgType;
|
||||
}
|
||||
|
||||
public void setMsgType(int msgType) {
|
||||
this.msgType = msgType;
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,10 @@ import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.realtime.entity.CloudLocationInfo;
|
||||
import com.mogo.realtime.location.LocationResult;
|
||||
import com.mogo.realtime.location.MogoRTKLocation;
|
||||
import com.mogo.realtime.entity.OnePerSecondSendContent;
|
||||
import com.mogo.realtime.util.MortonCode;
|
||||
import com.mogo.realtime.websocket.OnePerSecondSendContent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -70,7 +71,7 @@ public class SnapshotUploadInTime implements MogoRTKLocation.RTKLocationListener
|
||||
private void startSendCarLocationAndAdasRecognizedResult2Server(List<CloudLocationInfo> cloudLocationInfo) {
|
||||
CloudLocationInfo lastInfo = null;
|
||||
// 如果数组内容不为空,就用数组最后一个值
|
||||
if (cloudLocationInfo != null && !cloudLocationInfo.isEmpty()) {
|
||||
if (!cloudLocationInfo.isEmpty()) {
|
||||
lastInfo = cloudLocationInfo.get(cloudLocationInfo.size() - 1);
|
||||
mLastInfo = lastInfo;
|
||||
}
|
||||
@@ -86,13 +87,9 @@ public class SnapshotUploadInTime implements MogoRTKLocation.RTKLocationListener
|
||||
locationResult.lastCoordinate = lastInfo;
|
||||
locationResult.mortonCode = MortonCode.wrapEncodeMorton(lastInfo.getLon(), lastInfo.getLat());
|
||||
}
|
||||
// locationResult.coordinates = new ArrayList<>();
|
||||
locationResult.coordinates = new ArrayList<>();
|
||||
locationResult.sn = MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn();
|
||||
// if ( cloudLocationInfo == null ) {
|
||||
// locationResult.coordinates.addAll( new ArrayList<>() );
|
||||
// } else {
|
||||
// locationResult.coordinates.addAll( cloudLocationInfo );
|
||||
// }
|
||||
locationResult.coordinates.addAll(cloudLocationInfo);
|
||||
}
|
||||
List<ADASRecognizedResult> recognizedResults = RealTimeApisHandler.getInstance().getApis().getRecognizedResultManager().getLastADASRecognizedResult();//外显接口返回
|
||||
OnePerSecondSendContent content = new OnePerSecondSendContent();
|
||||
@@ -104,23 +101,7 @@ public class SnapshotUploadInTime implements MogoRTKLocation.RTKLocationListener
|
||||
Log.d(TAG, "no information 2 sent");
|
||||
return;
|
||||
}
|
||||
//todo 发送socket msg
|
||||
|
||||
//备注
|
||||
/*
|
||||
等钟超SocketManagerSDK
|
||||
*
|
||||
MarkerServiceHandler.getApis().getWebSocketManagerApi( mContext ).sendMsg( content, new IMogoOnWebSocketMessageListener() {
|
||||
@Override
|
||||
public WebSocketMsgType getDownLinkType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebSocketMsgType getUpLinkType() {
|
||||
return WebSocketMsgType.MSG_TYPE_UPLINK_CAR_DATA;
|
||||
}
|
||||
} );
|
||||
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.mogo.realtime.websocket;
|
||||
package com.mogo.realtime.entity;
|
||||
|
||||
|
||||
import com.mogo.realtime.entity.CloudLocationInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.mogo.realtime.websocket;
|
||||
package com.mogo.realtime.entity;
|
||||
|
||||
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.realtime.location.LocationResult;
|
||||
|
||||
import java.util.List;
|
||||
@@ -3,7 +3,6 @@ package com.mogo.realtime.location;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.location.Criteria;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
|
||||
@@ -5,19 +5,30 @@ import android.util.Log;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.mogo.cloud.commons.network.RetrofitFactory;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.cloud.tanlu.api.IRoadInfoSearchCallback;
|
||||
import com.mogo.cloud.tanlu.api.ITanluUploadCallback;
|
||||
import com.mogo.cloud.tanlu.bean.InformationBody;
|
||||
import com.mogo.cloud.tanlu.bean.RoadInfoRequest;
|
||||
import com.mogo.cloud.tanlu.bean.RoadInfos;
|
||||
import com.mogo.cloud.tanlu.bean.UploadResult;
|
||||
import com.mogo.cloud.tanlu.bean.location.Location;
|
||||
import com.mogo.cloud.tanlu.bean.location.MogoLocation;
|
||||
import com.mogo.cloud.tanlu.net.TanluApiService;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
|
||||
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.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.annotations.NonNull;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
@@ -94,8 +105,153 @@ public class UploadManager {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过经纬度信息查询 TanluModelData
|
||||
* @param roadInfoRequest
|
||||
* @param callback
|
||||
*/
|
||||
public void queryRoadInfoByLocationInfo(RoadInfoRequest roadInfoRequest, IRoadInfoSearchCallback callback) {
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("sn", "F803EB2046PZD00228");
|
||||
map.put("data", GsonUtil.jsonFromObject(roadInfoRequest));
|
||||
|
||||
apiService.queryRoadInfos(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<RoadInfos>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.d(TAG, "queryRoadInfos onSubscribe ----");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull RoadInfos roadInfos) {
|
||||
Log.d(TAG, "queryRoadInfos onNext roadInfos----" + roadInfos.getData());
|
||||
callback.onSuccess(roadInfos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.d(TAG, "queryRoadInfos onError ----");
|
||||
callback.onError(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.d(TAG, "queryRoadInfos onComplete ----");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// public void queryRoadInfoByCity(InformationBody informationBody, ITanluUploadCallback callback) {
|
||||
//
|
||||
// if (voiceCmdData.isHere()) { //TanluModelData
|
||||
// // 搜索附近路况,只需要拿到当前位置信息,就可以请求服务端
|
||||
// MogoLocation l = TanluServiceManager.getServiceApis().getMapServiceApi().getSingletonLocationClient(mContext).getLastKnowLocation();
|
||||
// Location location = new Location(l.getLatitude(), l.getLongitude());
|
||||
// RoadInfoRequest request;
|
||||
// if (voiceCmdData.getObj().equals(TYPE_NAME_BLOCK)) {
|
||||
// // 拥堵和路况同时查
|
||||
// request = new RoadInfoRequest(location, new String[]{TANLU_ROAD_CONGESTION_COMPAT, TANLU_ROAD_CURRENT}, false, false);
|
||||
// }else{
|
||||
// request = new RoadInfoRequest(location, new String[]{voiceCmdData.getType()}, false, false);
|
||||
// }
|
||||
//
|
||||
// Map<String, Object> map = new HashMap<>();
|
||||
// map.put("sn", "F803EB2046PZD00228");
|
||||
// map.put("data", "GsonUtil.jsonFromObject(request)");
|
||||
//
|
||||
// apiService.queryRoadInfos(map)
|
||||
// .subscribeOn(Schedulers.io())
|
||||
// .observeOn(AndroidSchedulers.mainThread())
|
||||
// .subscribe(new Observer<RoadInfos>() {
|
||||
// @Override
|
||||
// public void onSubscribe(@NonNull Disposable d) {
|
||||
// Log.d(TAG, "queryRoadInfos onSubscribe ----");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(@NonNull RoadInfos roadInfos) {
|
||||
// Log.d(TAG, "queryRoadInfos onNext roadInfos----" + roadInfos.getData());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(@NonNull Throwable e) {
|
||||
// Log.d(TAG, "queryRoadInfos onError ----");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// Log.d(TAG, "queryRoadInfos onComplete ----");
|
||||
// }
|
||||
// });
|
||||
// } else {
|
||||
// // 查询的不是附近的信息,所以需要查询一下目标地址的经纬度,然后再请求服务端
|
||||
// Observable.create(new ObservableOnSubscribe<MogoPoiResult>() {
|
||||
// @Override
|
||||
// public void subscribe(ObservableEmitter<MogoPoiResult> emitter) throws Exception {
|
||||
// // 根据传入的地址,转成经纬度
|
||||
// IMogoMapService mapService = TanluServiceManager.getServiceApis().getMapServiceApi();
|
||||
// String cityCode = mapService.getSingletonLocationClient(mContext).getLastKnowLocation().getCityCode();
|
||||
// MogoPoiSearchQuery poiSearchQuery = new MogoPoiSearchQuery(voiceCmdData.getLocation(), "", cityCode);
|
||||
// IMogoPoiSearch poiSearch = mapService.getPoiSearch(mContext, poiSearchQuery);
|
||||
// MogoPoiResult result = poiSearch.searchPOI();
|
||||
// if (result != null && result.getPois() != null && result.getPois().size() > 0) {
|
||||
// emitter.onNext(result);
|
||||
// } else {
|
||||
// emitter.onError(new IllegalArgumentException("没有根据地址查询到对应的经纬度"));
|
||||
// }
|
||||
// }
|
||||
// }).subscribeOn(Schedulers.io()).observeOn(Schedulers.io())
|
||||
// .flatMap(new Function<MogoPoiResult, Observable<BaseDataCompat<RoadInfos>>>() {
|
||||
// @Override
|
||||
// public Observable<BaseDataCompat<RoadInfos>> apply(MogoPoiResult mogoPoiResult) throws Exception {
|
||||
// // 转成经纬度后,整理参数,进行接口请求
|
||||
// Logger.d(TAG, "查询目标地址经纬度成功===" + Thread.currentThread().getName());
|
||||
// MogoPoiItem poiItem = mogoPoiResult.getPois().get(0);
|
||||
// Location location = new Location(poiItem.getPoint().lat, poiItem.getPoint().lon);
|
||||
// callback.onLocatSuccess(location.getLat(), location.getLon());
|
||||
// RoadInfoRequest request;
|
||||
// if (voiceCmdData.getObj().equals(TYPE_NAME_BLOCK)) {
|
||||
// // 拥堵和路况同时查
|
||||
// request = new RoadInfoRequest(location, new String[]{TANLU_ROAD_CONGESTION_COMPAT, TANLU_ROAD_CURRENT}, false, false);
|
||||
// }else{
|
||||
// request = new RoadInfoRequest(location, new String[]{voiceCmdData.getType()}, false, false);
|
||||
// }
|
||||
//
|
||||
// Map<String, Object> params = new ParamsProvider.Builder(mContext)
|
||||
// .append("sn", Utils.getSn())
|
||||
// .append("data", GsonUtil.jsonFromObject(request))
|
||||
// .build();
|
||||
// return mShareApiService.queryRoadInfos(params);
|
||||
// }
|
||||
// }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
// .subscribe(new SubscribeImpl<BaseDataCompat<RoadInfos>>(RequestOptions.create(mContext)) {
|
||||
// @Override
|
||||
// public void onError(Throwable e) {
|
||||
// super.onError(e);
|
||||
// callback.onQueryRoadInfoFail(e.getMessage(), -1);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onSuccess(BaseDataCompat<RoadInfos> o) {
|
||||
// super.onSuccess(o);
|
||||
// Logger.d(TAG, "当前线程为"+Thread.currentThread().getName()+" 搜索目标地址路况信息成功: " + o);
|
||||
// callback.onQueryRoadInfoSuccess(o.getResult().getData());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(String message, int code) {
|
||||
// super.onError(message, code);
|
||||
// callback.onQueryRoadInfoFail(message, code);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -55,4 +55,13 @@ public class RoadInfoRequest {
|
||||
this.onlySameCity = onlySameCity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RoadInfoRequest{" +
|
||||
"location=" + location +
|
||||
", poiTypes=" + poiTypes +
|
||||
", onlyFocus=" + onlyFocus +
|
||||
", onlySameCity=" + onlySameCity +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.List;
|
||||
* @description
|
||||
* @since 2021/1/20
|
||||
*/
|
||||
public class RoadInfos {
|
||||
public class RoadInfos{
|
||||
|
||||
private List<MarkerExploreWay> data;
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
include ':modules:mogo-realtime'
|
||||
include ':foudations:mogo-socket'
|
||||
include ':modules:mogo-cloud.realtime'
|
||||
include ':modules:cloud.realtime'
|
||||
include ':modules:mogo-tanlu'
|
||||
include ':foudations:mogo-commons'
|
||||
include ':foudations:mogo-httpdns'
|
||||
|
||||
Reference in New Issue
Block a user