This commit is contained in:
zhongchao
2021-01-25 17:24:26 +08:00
27 changed files with 155 additions and 112 deletions

View File

@@ -11,7 +11,7 @@ android {
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
packagingOptions {
//解决编译时com.android.builder.merge.DuplicateRelativeFileException: More than one file was found with OS independent path 'META-INF/rxjava.properties'这个错误
exclude 'META-INF/rxjava.properties'
@@ -32,13 +32,21 @@ android {
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'com.android.support:multidex:1.0.3'
implementation rootProject.ext.dependencies.androidxappcompat
implementation rootProject.ext.dependencies.androidxconstraintlayout
implementation project(path: ':foudations:mogo-passport')
implementation project(path: ':foudations:mogo-commons')
implementation project(path: ':modules:mogo-tanlu')
// implementation 'com.mogo.cloud:passport:1.0.0'
if (Boolean.valueOf(RELEASE)) {
implementation "com.mogo.cloud:commons:${MOGO_COMMONS_VERSION}"
implementation "com.mogo.cloud:socket:${MOGO_SOCKET_VERSION}"
implementation "com.mogo.cloud:tanlu:${MOGO_TANLU_VERSION}"
} else {
implementation project(":foudations:mogo-socket")
implementation project(":foudations:mogo-commons")
implementation project(path: ':modules:mogo-tanlu')
}
implementation rootProject.ext.dependencies.rxjava
implementation rootProject.ext.dependencies.rxandroid
}

View File

@@ -2,6 +2,8 @@ package com.mogo.cloud;
import android.app.Application;
import androidx.multidex.MultiDexApplication;
import com.mogo.cloud.httpdns.MogoHttpDnsConfig;
import com.mogo.cloud.httpdns.bean.HttpDnsSimpleLocation;
import com.mogo.cloud.httpdns.listener.IHttpDnsCurrentLocation;
@@ -15,7 +17,7 @@ import java.util.Random;
/**
*
*/
public class MoGoApplication extends Application {
public class MoGoApplication extends MultiDexApplication {
@Override
public void onCreate() {
super.onCreate();
@@ -41,7 +43,7 @@ public class MoGoApplication extends Application {
}
});
MoGoAiCloudClient.getInstance().init(this, clientConfig);
MoGoAiCloudClient.getInstance().init(this, clientConfig, null);
}
}

View File

@@ -37,6 +37,7 @@ public class NetworkActivity extends AppCompatActivity {
private Button btn;
private TextView tvResult;
private ApiService apiService;
private static final String TAG = "NetworkActivity";
@Override
@@ -55,7 +56,9 @@ public class NetworkActivity extends AppCompatActivity {
queryRoadData("ZD802C1938L10797");
// queryHelpSignal("ZD802C1938L10797");
//上报路况到服务端
// uploadRoadInfo();
//查询路况
// queryRoad();
}
});
@@ -72,17 +75,18 @@ public class NetworkActivity extends AppCompatActivity {
UploadManager.getInstance(NetworkActivity.this).queryRoadInfoByLocationInfo(null , new IRoadInfoSearchCallback() {
@Override
public void onSuccess(RoadInfos result) {
Log.d("liyz", "queryRoad size() = " + result.getData().size());
Log.d(TAG, "queryRoad size() = " + result.getData().size());
tvResult.setText(new Gson().toJson(result));
}
@Override
public void onFailure(int code) {
Log.d("liyz", "queryRoad code = " + code);
Log.d(TAG, "queryRoad code = " + code);
}
@Override
public void onError(Throwable e) {
Log.d("liyz", "queryRoad e = " + e);
Log.d(TAG, "queryRoad e = " + e);
}
});
}
@@ -92,17 +96,18 @@ public class NetworkActivity extends AppCompatActivity {
UploadManager.getInstance(NetworkActivity.this).loadUpload(new InformationBody(), new ITanluUploadCallback() {
@Override
public void onSuccess(UploadResult result) {
Log.d("liyz", "uploadRoadInfo result.id = " + result.id);
Log.d(TAG, "uploadRoadInfo result.id = " + result.id);
tvResult.setText("onSuccess - " + result.id + "");
}
@Override
public void onFailure(int code) {
Log.d("liyz", " uploadRoadInfo code = " + code);
Log.d(TAG, " uploadRoadInfo code = " + code);
}
@Override
public void onError(Throwable e) {
Log.d("liyz", "uploadRoadInfo onError e = " + e);
Log.d(TAG, "uploadRoadInfo onError e = " + e);
}
});
}

View File

@@ -54,12 +54,15 @@ dependencies {
implementation rootProject.ext.dependencies.androidxccorektx
implementation rootProject.ext.dependencies.androidxappcompat
implementation rootProject.ext.dependencies.okhttpinterceptor
api rootProject.ext.dependencies.retrofit
api rootProject.ext.dependencies.retrofitadapter
api rootProject.ext.dependencies.retrofitconvertergson
api rootProject.ext.dependencies.retrofitconverterscalars
api project(path: ':foudations:mogo-httpdns')
api project(path: ':foudations:mogo-passport')
implementation rootProject.ext.dependencies.retrofit
implementation rootProject.ext.dependencies.retrofitadapter
implementation rootProject.ext.dependencies.retrofitconvertergson
implementation rootProject.ext.dependencies.retrofitconverterscalars
if (Boolean.valueOf(RELEASE)) {
api "com.mogo.cloud:passport:${MOGO_PASSPORT_VERSION}"
} else {
api project(path: ':foudations:mogo-passport')
}
}

View File

@@ -1,4 +1,4 @@
GROUP=com.mogo.cloud
POM_ARTIFACT_ID=commons
VERSION_CODE=1
VERSION_NAME=1.0.1-SNAPSHOT
VERSION_NAME=1.0.2-SNAPSHOT

View File

@@ -1,4 +1,4 @@
GROUP=com.mogo.cloud
POM_ARTIFACT_ID=httpdns
VERSION_CODE=1
VERSION_NAME=1.0.0
VERSION_NAME=1.0.0-SNAPSHOT

View File

@@ -31,10 +31,13 @@ dependencies {
implementation rootProject.ext.dependencies.androidxappcompat
api rootProject.ext.dependencies.mogoutils
// passport
implementation 'com.zhidao.thirdlogin:third-login:1.0.1'
implementation 'com.zhidao.account:accountsdk:1.0.16.1'
api project(path: ':foudations:mogo-httpdns')
// api 'com.mogo.cloud:httpdns:1.0.0'
implementation 'com.zhidao.thirdlogin:third-login:1.0.2'
if (Boolean.valueOf(RELEASE)) {
api "com.mogo.cloud:httpdns:${MOGO_HTTPDNS_VERSION}"
} else {
api project(path: ':foudations:mogo-httpdns')
}
}

View File

@@ -1,4 +1,4 @@
GROUP=com.mogo.cloud
POM_ARTIFACT_ID=passport
VERSION_CODE=1
VERSION_NAME=1.0.0-SNAPSHOT
VERSION_NAME=1.0.2-SNAPSHOT

View File

@@ -47,14 +47,16 @@ public class MoGoAiCloudClient {
*
* @param context 上下文
* @param aiCloudClientConfig SDK配置信息
* @param tokenCallback 获取令牌回调,使用端可根据回调的方法判断是否获取令牌成功,可为空
*/
public MoGoAiCloudClient init(Context context,
MoGoAiCloudClientConfig aiCloudClientConfig
MoGoAiCloudClientConfig aiCloudClientConfig,
final IMoGoTokenCallback tokenCallback
) {
mContext = context;
mAiCloudClientConfig = aiCloudClientConfig;
// 刷新令牌
refreshToken(null);
refreshToken(tokenCallback);
return sInstance;
}

View File

@@ -27,11 +27,17 @@ android {
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
// 长链
api 'com.zhidao.socket:built-in-socket:1.0.17'
api 'com.zhidao.socket:built-in-socket:1.0.21'
// 上报位置
implementation 'com.zhidao.locupload:loc-upload-sdk:1.1.7'
implementation project(path: ':foudations:mogo-passport')
api rootProject.ext.dependencies.mogoutils
implementation 'com.zhidao.locupload:loc-upload-sdk:1.1.8'
if (Boolean.valueOf(RELEASE)) {
implementation "com.mogo.cloud:passport:${MOGO_PASSPORT_VERSION}"
} else {
implementation project(path: ':foudations:mogo-passport')
}
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()

View File

@@ -1,4 +1,4 @@
GROUP=com.mogo.cloud
POM_ARTIFACT_ID=socket
VERSION_CODE=1
VERSION_NAME=1.0.0
VERSION_NAME=1.0.2-SNAPSHOT

View File

@@ -83,6 +83,7 @@ public class SocketManager implements IMogoCloudSocketManager, Callback {
.setChannelId(SocketServicesConstants.SOCKET_CHANNEL_ID)
.setOpenAnalytics(true)
.setSn(cloudClientConfig.getSn())
.setToken(cloudClientConfig.getToken())
.setDebug(cloudClientConfig.isShowDebugLog());
SocketClient.getInstance().start(context);
}

View File

@@ -22,9 +22,12 @@ RELEASE_REPOSITORY_URL=http://nexus.zhidaoauto.com/repository/maven-releases/
SNAPSHOT_REPOSITORY_URL=http://nexus.zhidaoauto.com/repository/maven-snapshots/
USERNAME=xintai
PASSWORD=xintai2018
# 编译模式: false - 依赖本地版本, true - 依赖 maven 版本
RELEASE=false
# 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
MOGO_COMMONS_VERSION=1.0.4-SNAPSHOT
MOGO_HTTPDNS_VERSION=1.0.4-SNAPSHOT
MOGO_PASSPORT_VERSION=1.0.4-SNAPSHOT
MOGO_SOCKET_VERSION=1.0.4-SNAPSHOT
MOGO_REALTIME_VERSION=1.0.4-SNAPSHOT
MOGO_TANLU_VERSION=1.0.4-SNAPSHOT

View File

@@ -26,11 +26,20 @@ uploadArchives {
mavenDeployer {
println project.name
String versionNameKey = "${project.name.replace("-", "_").toUpperCase()}_VERSION"
String versionName = getVersionNameValue(versionNameKey)
println versionName
if (versionName == null || versionName.equals("")) {
project.logger.error("undefined versionName in root gradle.properties by ${versionNameKey}")
}
pom.project {
packaging = 'aar'
groupId = GROUP
artifactId = POM_ARTIFACT_ID
version = VERSION_NAME
version = versionName
}
repository(url: rootProject.RELEASE_REPOSITORY_URL) {
@@ -43,3 +52,19 @@ uploadArchives {
}
}
}
def getVersionNameValue(String key) {
File file = rootProject.file('gradle.properties')
String value = "";
if (file.exists()) {
//加载资源
InputStream inputStream = file.newDataInputStream();
Properties properties = new Properties()
properties.load(inputStream)
if (properties.containsKey(key)) {
value = properties.getProperty(key)
}
}
return value
}

6
modules.txt Normal file
View File

@@ -0,0 +1,6 @@
:foudations:mogo-httpdns
:foudations:mogo-passport
:foudations:mogo-commons
:foudations:mogo-socket
:modules:mogo-realtime
:modules:mogo-tanlu

View File

@@ -28,6 +28,13 @@ android {
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation project(path: ':foudations:mogo-passport')
implementation project(":foudations:mogo-commons")
implementation project(":foudations:mogo-socket")
if (Boolean.valueOf(RELEASE)) {
implementation "com.mogo.cloud:commons:${MOGO_COMMONS_VERSION}"
implementation "com.mogo.cloud:socket:${MOGO_SOCKET_VERSION}"
} else {
implementation project(":foudations:mogo-socket")
implementation project(":foudations:mogo-commons")
}
}

View File

@@ -0,0 +1,4 @@
GROUP=com.mogo.cloud
POM_ARTIFACT_ID=realtime
VERSION_CODE=1
VERSION_NAME=1.0.1-SNAPSHOT

View File

@@ -1,35 +0,0 @@
package com.mogo.realtime.Interface;
/**
* @author liujing
* @description 描述
* @since: 2021/1/21
*/
public final class RealTimeApisHandler {
private static volatile RealTimeApisHandler sInstance;
private static volatile RealTimeServiceApis sApis;
public static RealTimeApisHandler getInstance() {
if (sInstance == null) {
synchronized (RealTimeApisHandler.class) {
sInstance = new RealTimeApisHandler();
}
}
return sInstance;
}
public void initRealTimeEnvironment() {
//socketeinit locationinit rtkinit
}
public RealTimeServiceApis getApis() {
if (sApis == null) {
synchronized (this) {
// sApis = new RealTimeServiceApis();
}
}
return sApis;
}
}

View File

@@ -13,7 +13,7 @@ import java.util.List;
* @description 描述
* @since: 2021/1/21
*/
public interface RealTimeProvider<T> {
public interface RealTimeProvider<T> {
/**
* 获取 adas 识别列表
*
@@ -22,8 +22,8 @@ public interface RealTimeProvider<T> {
List<ADASRecognizedResult> getLastADASRecognizedResult();
/*
* 两个点之间的距离
* */
* 两个点之间的距离
* */
float getDistanceBetweenTwoPoints();
/**
@@ -48,5 +48,5 @@ public interface RealTimeProvider<T> {
* @param list 消息体
* @param listener 回执监听
*/
public void sendMsg(List <CloudLocationInfo> list, IMogoCloudSocketOnMessageListener listener);
public void sendMsg(List<CloudLocationInfo> list, IMogoCloudSocketOnMessageListener listener);
}

View File

@@ -1,11 +0,0 @@
package com.mogo.realtime.Interface;
/**
* @author liujing
* @description 描述
* @since: 2021/1/21
*/
public interface RealTimeServiceApis {
RealTimeProvider getRecognizedResultManager();
}

View File

@@ -2,8 +2,8 @@ package com.mogo.realtime.constant;
import android.os.SystemClock;
import com.mogo.realtime.Interface.RealTimeApisHandler;
import com.mogo.realtime.entity.CloudLocationInfo;
import com.mogo.realtime.socket.SocketHandler;
import com.mogo.realtime.util.MogoLatLng;
import com.mogo.utils.logger.Logger;
@@ -61,7 +61,7 @@ public class SimpleLocationCorrectStrategy {
try {
float targetDistance =
(float) (lastLocation.getSpeed() * (SystemClock.elapsedRealtime() - anchorTime) / 1000) + TARGET_DISTANCE_DEVIATION;
float distance = RealTimeApisHandler.getInstance().getApis().getRecognizedResultManager().getDistanceBetweenTwoPoints();
float distance = SocketHandler.getInstance().getRealTimeProvider().getDistanceBetweenTwoPoints();
Logger.d(TAG,
"准备计算{ lastInfo: " + lastLocation.print() + " info: " + info.print() + " targetDistance: " + targetDistance + " distance : " + distance + "}");
if (distance <= targetDistance) {
@@ -121,7 +121,7 @@ public class SimpleLocationCorrectStrategy {
try {
float targetDistance =
(float) (lastLocation.getSpeed() * (SystemClock.elapsedRealtime() - anchorTime) / 1000) + TARGET_DISTANCE_DEVIATION;
float distance = RealTimeApisHandler.getInstance().getApis().getRecognizedResultManager().getDistanceBetweenTwoPoints();
float distance = SocketHandler.getInstance().getRealTimeProvider().getDistanceBetweenTwoPoints();
Logger.d(TAG,
"异常定位点\n准备计算{ lastInfo: " + lastLocation.print() + " info: " + info.print() + " targetDistance: " + targetDistance + " distance : " + distance + "}");
// 按照上一个点的方向和速度,计算下一个点的位置,下一个点除坐标点外,其余数据与上一个点相同

View File

@@ -9,7 +9,6 @@ import com.mogo.cloud.socket.IMogoCloudSocketOnMessageListener;
import com.mogo.cloud.socket.MsgBody;
import com.mogo.cloud.socket.SocketManager;
import com.mogo.cloud.socket.WebSocketData;
import com.mogo.realtime.Interface.RealTimeApisHandler;
import com.mogo.realtime.constant.SimpleLocationCorrectStrategy;
import com.mogo.realtime.entity.ADASRecognizedResult;
import com.mogo.realtime.entity.CloudLocationInfo;
@@ -118,10 +117,11 @@ public class SocketHandler {
locationResult.sn = MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn();
locationResult.coordinates.addAll(cloudLocationInfo);
}
List<ADASRecognizedResult> recognizedResults = RealTimeApisHandler.getInstance().getApis().getRecognizedResultManager().getLastADASRecognizedResult();//外显接口返回
//todo 改造
// List<ADASRecognizedResult> recognizedResults = RealTimeApisHandler.getInstance().getApis().getRecognizedResultManager().getLastADASRecognizedResult();//外显接口返回
OnePerSecondSendContent content = new OnePerSecondSendContent();
content.self = locationResult;
content.adas = recognizedResults;
// content.adas = recognizedResults;
if (content.self == null &&
(content.adas == null || content.adas.isEmpty())) {

View File

@@ -37,6 +37,13 @@ dependencies {
implementation rootProject.ext.dependencies.rxjava
implementation rootProject.ext.dependencies.rxandroid
implementation project(path: ':foudations:mogo-commons')
}
if (Boolean.valueOf(RELEASE)) {
implementation "com.mogo.cloud:commons:${MOGO_COMMONS_VERSION}"
} else {
implementation project(path: ':foudations:mogo-commons')
}
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()

View File

@@ -1,4 +1,4 @@
GROUP=com.mogo.cloud
POM_ARTIFACT_ID=tanlu
VERSION_CODE=1
VERSION_NAME=1.0.0
VERSION_NAME=1.0.1-SNAPSHOT

View File

@@ -120,12 +120,16 @@ public class UploadManager {
Location location = new Location();
location.setLat(39.968317);
location.setLon(116.410892);
RoadInfoRequest request = new RoadInfoRequest(location, "", list, false, false);
RoadInfoRequest request = new RoadInfoRequest(location, "中关村", list, false, false);
Map<String, Object> map = new HashMap<>();
map.put("sn", "F803EB2046PZD00228");
map.put("data", GsonUtil.jsonFromObject(request));
// Map<String, Object> map = new HashMap<>();
// map.put("sn", MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn());
// map.put("data", GsonUtil.jsonFromObject(roadInfoRequest));
apiService.queryRoadInfos(map)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())

View File

@@ -11,8 +11,8 @@ import java.util.ArrayList;
*/
public class RoadInfoRequest {
private Location location; //没有定位信息,可传空对象。如果没有,服务端将更加文字逆序成经纬度查询
private String inputText;
private Location location; //没有定位信息,可传空对象。如果没有,服务端将根据文字逆序成经纬度查询
private String inputText; //必须是有效的地理信息,否则可能会报错
private ArrayList<String> poiTypes;
private boolean onlyFocus;
private boolean onlySameCity;
@@ -33,6 +33,14 @@ public class RoadInfoRequest {
this.location = location;
}
public String getInputText() {
return inputText;
}
public void setInputText(String inputText) {
this.inputText = inputText;
}
public ArrayList<String> getPoiTypes() {
return poiTypes;
}
@@ -57,13 +65,5 @@ public class RoadInfoRequest {
this.onlySameCity = onlySameCity;
}
@Override
public String toString() {
return "RoadInfoRequest{" +
"location=" + location +
", poiTypes=" + poiTypes +
", onlyFocus=" + onlyFocus +
", onlySameCity=" + onlySameCity +
'}';
}
}

3
upload.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
./gradlew :foudations:mogo-httpdns:clean :foudations:mogo-httpdns:uploadArchives