fix bug and add ack listener

This commit is contained in:
zhongchao
2021-01-26 14:05:11 +08:00
19 changed files with 104 additions and 48 deletions

2
.idea/misc.xml generated
View File

@@ -13,7 +13,7 @@
<option name="HEAP_SIZE" value="1024" />
<option name="LOCALE" value="zh_CN" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_12" default="true" project-jdk-name="12" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@@ -19,6 +19,7 @@ buildscript {
dependencies {
classpath "com.android.tools.build:gradle:4.0.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
// 对kotlin生成doc
classpath 'org.jetbrains.dokka:dokka-gradle-plugin:0.10.1'
// NOTE: Do not place your application dependencies here; they belong

View File

@@ -1,6 +1,7 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-android-extensions'
}
// 对kotlin生成doc
apply plugin: 'org.jetbrains.dokka'
@@ -12,7 +13,7 @@ android {
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode 1
versionName "1.0"
versionName "${MOGO_HTTPDNS_VERSION}"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"

View File

@@ -8,7 +8,7 @@ android {
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode 1
versionName "1.0"
versionName "${MOGO_PASSPORT_VERSION}"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"

View File

@@ -79,6 +79,9 @@ public class MoGoAiCloudClient {
@Override
public void onSuccess(TokenData.TokenResult result) {
Log.i(TAG, "═════════════════════════════════════");
Log.i(TAG, "║ PassportVersion" + com.mogo.cloud.passport.BuildConfig.VERSION_NAME);
Log.i(TAG, "║ HttpDnsVersion" + com.mogo.cloud.httpdns.BuildConfig.VERSION_NAME);
Log.i(TAG, "║ ThirdLoginVersion" + com.zhidao.thirdlogin.BuildConfig.VERSION_NAME);
Log.i(TAG, "║ MoGo鉴权成功 ");
Log.i(TAG, "║ SN" + result.sn);
Log.i(TAG, "║ Token" + result.token);

View File

@@ -59,7 +59,7 @@ public class MoGoAiCloudClientConfig {
/**
* 是否使用外部定位数据
*/
private long mIsUseExternalLocation;
private boolean mIsUseExternalLocation;
/**
* 是否上传当前位置信息
@@ -236,7 +236,7 @@ public class MoGoAiCloudClientConfig {
*
* @return true-使用false-使用sdk的定位数据
*/
public long getIsUseExternalLocation() {
public boolean getIsUseExternalLocation() {
return mIsUseExternalLocation;
}
@@ -245,7 +245,7 @@ public class MoGoAiCloudClientConfig {
*
* @param isUseExternalLocation true-使用false-使用sdk的定位数据
*/
public void setIsUseExternalLocation(long isUseExternalLocation) {
public void setIsUseExternalLocation(boolean isUseExternalLocation) {
mIsUseExternalLocation = isUseExternalLocation;
}

View File

@@ -7,7 +7,7 @@ android {
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode 1
versionName "1.0"
versionName "${MOGO_SOCKET_VERSION}"
consumerProguardFiles "consumer-rules.pro"
}

View File

@@ -23,11 +23,11 @@ SNAPSHOT_REPOSITORY_URL=http://nexus.zhidaoauto.com/repository/maven-snapshots/
USERNAME=xintai
PASSWORD=xintai2018
# 编译模式: false - 依赖本地版本, true - 依赖 maven 版本
RELEASE=false
RELEASE=true
# AI CLOUD 云平台
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
MOGO_COMMONS_VERSION=1.0.6-SNAPSHOT
MOGO_HTTPDNS_VERSION=1.0.6-SNAPSHOT
MOGO_PASSPORT_VERSION=1.0.6-SNAPSHOT
MOGO_SOCKET_VERSION=1.0.6-SNAPSHOT
MOGO_REALTIME_VERSION=1.0.6-SNAPSHOT
MOGO_TANLU_VERSION=1.0.6-SNAPSHOT

View File

@@ -8,7 +8,7 @@ android {
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode 1
versionName "1.0"
versionName "${MOGO_SOCKET_VERSION}"
consumerProguardFiles "consumer-rules.pro"
}

View File

@@ -1,8 +1,5 @@
package com.mogo.realtime.Imp;
import android.content.Context;
import com.mogo.cloud.socket.IMogoCloudSocketOnMessageListener;
import com.mogo.realtime.Interface.RealTimeProvider;
import com.mogo.realtime.entity.ADASRecognizedResult;
import com.mogo.realtime.entity.CloudLocationInfo;
@@ -11,12 +8,27 @@ import com.mogo.realtime.socket.IMogoCloudOnMsgListener;
import java.util.List;
/**
* @author liujing
* @description 描述
* @since: 2021/1/21
*
*/
public class RealTimeProviderImp implements RealTimeProvider {
private RealTimeProvider mDelegate;
private static volatile RealTimeProviderImp sInstance = null;
private final RealTimeProvider mDelegate;
public static RealTimeProviderImp getInstance() {
if (sInstance == null) {
synchronized (RealTimeProviderImp.class) {
if (sInstance == null) {
sInstance = new RealTimeProviderImp();
}
}
}
return sInstance;
}
public RealTimeProviderImp() {
mDelegate = (RealTimeProvider) RealTimeDelegateManager.getInstance();
}
@Override
public List<ADASRecognizedResult> getLastADASRecognizedResult() {
@@ -28,18 +40,27 @@ public class RealTimeProviderImp implements RealTimeProvider {
@Override
public void registerOnMessageListener(IMogoCloudOnMsgListener listener) {
if (mDelegate != null) {
mDelegate.registerOnMessageListener(listener);
}
}
@Override
public void unRegisterOnMessageListener(IMogoCloudOnMsgListener listener) {
if (listener == null) {
return;
}
if (mDelegate != null) {
mDelegate.unRegisterOnMessageListener(listener);
}
}
@Override
public List<CloudLocationInfo> getLocationMsg(int msgId) {
public List<CloudLocationInfo> getLocationMsg() {
if (mDelegate != null) {
mDelegate.getLocationMsg();
}
return null;
}
}

View File

@@ -32,8 +32,6 @@ public interface RealTimeProvider {
/**
* 发送消息
*
* @param msgId 发送消息ID
*/
public List<CloudLocationInfo> getLocationMsg(int msgId);
List<CloudLocationInfo> getLocationMsg();
}

View File

@@ -61,7 +61,7 @@ public class SimpleLocationCorrectStrategy {
try {
float targetDistance =
(float) (lastLocation.getSpeed() * (SystemClock.elapsedRealtime() - anchorTime) / 1000) + TARGET_DISTANCE_DEVIATION;
float distance = SocketHandler.getInstance().getRealTimeProvider().getDistanceBetweenTwoPoints();
float distance = 0;//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 = SocketHandler.getInstance().getRealTimeProvider().getDistanceBetweenTwoPoints();
float distance = 0;//SocketHandler.getInstance().getRealTimeProvider().getDistanceBetweenTwoPoints();
Logger.d(TAG,
"异常定位点\n准备计算{ lastInfo: " + lastLocation.print() + " info: " + info.print() + " targetDistance: " + targetDistance + " distance : " + distance + "}");
// 按照上一个点的方向和速度,计算下一个点的位置,下一个点除坐标点外,其余数据与上一个点相同

View File

@@ -35,12 +35,16 @@ public class SnapshotUploadInTime implements MogoRTKLocation.RTKLocationListener
sInstance = null;
}
//todo 检查是否需要配置 默认开始定位上报
public void start(Context context, boolean useInner, String appId, IMogoCloudOnMsgListener listener) {
MogoRTKLocation.getInstance().registerRTKLocationListener(this);
SocketHandler.getInstance().initSocket(context, useInner, appId, listener);
//todo 调用
public void start(Context context, String appId, IMogoCloudOnMsgListener listener) {
MogoRTKLocation.getInstance().registerRTKLocationListener(this); //todo 区分外部内部
SocketHandler.getInstance().initSocket(context, appId, listener);
SocketHandler.getInstance().resetUploadDelayListener(resetTime ->
MogoRTKLocation.getInstance().resetUploadDelay(resetTime)
);
}
//todo 调用
public void stop() {
SocketHandler.getInstance().stop();
}

View File

@@ -19,6 +19,7 @@ import com.mogo.utils.logger.Logger;
import java.util.ArrayList;
import java.util.List;
//todo 改造
public class MogoRTKLocation {
private static final String TAG = "MogoRTKLocation";

View File

@@ -0,0 +1,6 @@
package com.mogo.realtime.socket;
public interface IMogoCloudOnAckListener {
void onAck(long resetTime);
}

View File

@@ -4,5 +4,7 @@ import com.mogo.realtime.entity.MogoSnapshotSetData;
public interface IMogoCloudOnMsgListener {
void onAck(int msgId);
void onMsgReceived(MogoSnapshotSetData mogoSnapshotSetData);
}

View File

@@ -9,6 +9,7 @@ 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.Imp.RealTimeProviderImp;
import com.mogo.realtime.constant.SimpleLocationCorrectStrategy;
import com.mogo.realtime.entity.ADASRecognizedResult;
import com.mogo.realtime.entity.CloudLocationInfo;
@@ -36,7 +37,8 @@ public class SocketHandler {
private long serverTime = 0;
private long receiveMsgTime = 0;
private CloudLocationInfo mLastInfo;
private final List<IMogoCloudOnMsgListener> listenerList = new ArrayList<>();
private final List<IMogoCloudOnMsgListener> onMsgListenerList = new ArrayList<>();
private final List<IMogoCloudOnAckListener> onAckListenerList = new ArrayList<>();
public static SocketHandler getInstance() {
if (mInstance == null) {
@@ -52,12 +54,18 @@ public class SocketHandler {
/*
* useInner: 是否注册自己内部的监听
* */
public void initSocket(Context context, boolean useInner, String appId, IMogoCloudOnMsgListener listener) {
public void initSocket(Context context, String appId, IMogoCloudOnMsgListener listener) {
SocketManager.getInstance().init(context, appId);
SocketManager.getInstance().registerOnMessageListener(0x040002, onMessageListener);
SocketManager.getInstance().registerOnMessageListener(0x040003, onMessageListener);
if (listener != null && !listenerList.contains(listener)) {
listenerList.add(listener);
if (listener != null && !onMsgListenerList.contains(listener)) {
onMsgListenerList.add(listener);
}
}
public void resetUploadDelayListener(IMogoCloudOnAckListener onAckListener) {
if(onAckListener != null){
onAckListenerList.add(onAckListener);
}
}
@@ -76,8 +84,11 @@ public class SocketHandler {
receiveMsgTime = SystemClock.elapsedRealtime();
if (webSocketData.getUpUtcTime() > 0) {
long nextDelay = webSocketData.getUpUtcTime() - serverTime;
//todo
// MogoRTKLocation.getInstance().resetUploadDelay(nextDelay);
if (!MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getIsUseExternalLocation()) {
for (IMogoCloudOnAckListener ackListener:onAckListenerList) {
ackListener.onAck(nextDelay);
}
}
}
}
}
@@ -87,7 +98,7 @@ public class SocketHandler {
Log.e(TAG, "onMsgReceived MogoSnapshotSetData == null ");
return;
}
for (IMogoCloudOnMsgListener listener : listenerList) {
for (IMogoCloudOnMsgListener listener : onMsgListenerList) {
listener.onMsgReceived(data);
}
}
@@ -117,11 +128,10 @@ public class SocketHandler {
locationResult.sn = MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn();
locationResult.coordinates.addAll(cloudLocationInfo);
}
//todo 改造
// List<ADASRecognizedResult> recognizedResults = RealTimeApisHandler.getInstance().getApis().getRecognizedResultManager().getLastADASRecognizedResult();//外显接口返回
List<ADASRecognizedResult> recognizedResults = RealTimeProviderImp.getInstance().getLastADASRecognizedResult();//SPI接口返回
OnePerSecondSendContent content = new OnePerSecondSendContent();
content.self = locationResult;
// content.adas = recognizedResults;
content.adas = recognizedResults;
if (content.self == null &&
(content.adas == null || content.adas.isEmpty())) {
@@ -150,7 +160,8 @@ public class SocketHandler {
public void stop() {
SocketManager.getInstance().unregisterOnMessageListener(0x040002, onMessageListener);
SocketManager.getInstance().unregisterOnMessageListener(0x040003, onMessageListener);
listenerList.clear();
onMsgListenerList.clear();
onAckListenerList.clear();
}
/**

View File

@@ -9,7 +9,7 @@ android {
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode 1
versionName "1.0"
versionName "${MOGO_TANLU_VERSION}"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"

View File

@@ -1,3 +1,11 @@
#!/bin/bash
./gradlew :foudations:mogo-httpdns:clean :foudations:mogo-httpdns:uploadArchives
function upload(){
./gradlew $1:clean $1:uploadArchives
if [ $? -ne 0 ];then exit; fi
}
for module in `cat modules.txt`;
do
upload $module
done