Merge branch 'master' into live_sdk

# Conflicts:
#	app/src/main/AndroidManifest.xml
#	app/src/main/java/com/mogo/cloud/MainActivity.java
#	modules/mogo-realtime/src/main/java/com/mogo/realtime/socket/SocketHandler.java
This commit is contained in:
董宏宇
2021-02-04 11:34:40 +08:00
12 changed files with 182 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="12" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@@ -32,6 +32,10 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ConfigInfoActivity"
android:label="配置信息"/>
<activity
android:name=".LivePushActivity"
android:label="直播播放" />

View File

@@ -0,0 +1,26 @@
package com.mogo.cloud;
import android.os.Bundle;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.utils.network.utils.GsonUtil;
/**
* 查看配置信息
*/
public class ConfigInfoActivity extends AppCompatActivity {
private TextView tvConfigInfo;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.actitity_config_info);
tvConfigInfo = findViewById(R.id.tvConfigInfo);
tvConfigInfo.setText(GsonUtil.jsonFromObject(MoGoAiCloudClientConfig.getInstance()));
}
}

View File

@@ -15,6 +15,7 @@ import com.mogo.cloud.passport.MoGoAiCloudClient;
public class MainActivity extends AppCompatActivity {
private Button btnJumpPassPort;
private Button btnJumpConfigInfo;
private Button btnJumpNetWorkPort;
private Button btnJumpRealTime;
private Button btnJumpRoadCondition;
@@ -59,6 +60,12 @@ public class MainActivity extends AppCompatActivity {
startActivity(intent);
});
btnJumpConfigInfo = findViewById(R.id.btnJumpConfigInfo);
btnJumpConfigInfo.setOnClickListener(v -> {
Intent intent = new Intent(MainActivity.this, ConfigInfoActivity.class);
startActivity(intent);
});
btnJumpLivePush = findViewById(R.id.btnJumpLivePush);
btnJumpLivePush.setOnClickListener(v -> {
Intent intent = new Intent(MainActivity.this, LivePushActivity.class);

View File

@@ -35,7 +35,7 @@ public class MoGoApplication extends MultiDexApplication {
* BYDbydauto
*/
// 配置云服务API
MoGoAiCloudClientConfig clientConfig = new MoGoAiCloudClientConfig();
MoGoAiCloudClientConfig clientConfig = MoGoAiCloudClientConfig.getInstance();
// 设置网络环境HTTP_DNS_ENV_QA、HTTP_DNS_ENV_RELEASE、HTTP_DNS_ENV_DEV
clientConfig.setNetMode(MogoHttpDnsConfig.HTTP_DNS_ENV_QA);
// 设置是否是第三APP登录
@@ -59,8 +59,7 @@ public class MoGoApplication extends MultiDexApplication {
});
// 初始化SDK可以设置状态回调来监听
MoGoAiCloudClient.getInstance().init(
this, clientConfig);
MoGoAiCloudClient.getInstance().init(this, clientConfig);
}
}

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tvConfigInfo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:lineHeight="30dp"
android:textColor="#000000"
android:textSize="20dp"
tools:text="测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -48,6 +48,12 @@
android:layout_height="match_parent"
android:text="刷新令牌" />
<Button
android:id="@+id/btnJumpConfigInfo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="查看配置信息" />
<Button
android:id="@+id/btnJumpNetWorkPort"
android:layout_width="match_parent"

View File

@@ -19,6 +19,7 @@ import java.util.List;
/**
* 蘑菇AI云平台SDK入口
* @author donghongyu
*/
@Keep
public class MoGoAiCloudClient {
@@ -72,7 +73,9 @@ public class MoGoAiCloudClient {
}
public void refreshToken() {
Log.i(TAG, "═══════════════刷新Token═════════════");
if (mAiCloudClientConfig.isShowDebugLog()) {
Log.i(TAG, "═══════════════刷新Token═════════════");
}
if (mAiCloudClientConfig != null) {
ThirdLoginParam thirdLoginParam = ThirdLoginParam.of(
@@ -83,14 +86,16 @@ public class MoGoAiCloudClient {
LoginCallback loginCallback = new LoginCallback() {
@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);
Log.i(TAG, "═════════════════════════════════════");
if (mAiCloudClientConfig.isShowDebugLog()) {
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);
Log.i(TAG, "═════════════════════════════════════");
}
// 变量赋值
if (mAiCloudClientConfig != null) {
@@ -117,12 +122,14 @@ public class MoGoAiCloudClient {
@Override
public void onFailure(int code, String msg) {
Toast.makeText(mContext, "MoGo鉴权失败", Toast.LENGTH_SHORT).show();
Log.e(TAG, "═════════════════════════════════════");
Log.e(TAG, "║ MoGo鉴权失败 ");
Log.e(TAG, "ErrorCode" + code);
Log.e(TAG, "║ ErrorMessage" + msg);
Log.e(TAG, "═════════════════════════════════════");
if (mAiCloudClientConfig.isShowDebugLog()) {
Toast.makeText(mContext, "MoGo鉴权失败", Toast.LENGTH_SHORT).show();
Log.e(TAG, "═════════════════════════════════════");
Log.e(TAG, "MoGo鉴权失败 ");
Log.e(TAG, "║ ErrorCode" + code);
Log.e(TAG, "║ ErrorMessage" + msg);
Log.e(TAG, "═════════════════════════════════════");
}
// 变量赋值
if (mAiCloudClientConfig != null) {
mAiCloudClientConfig.setSn("");
@@ -134,7 +141,9 @@ public class MoGoAiCloudClient {
}
};
Log.w(TAG, "loginCallback" + loginCallback);
if (mAiCloudClientConfig.isShowDebugLog()) {
Log.w(TAG, "loginCallback" + loginCallback);
}
Environment environment;
switch (mAiCloudClientConfig.getNetMode()) {

View File

@@ -12,6 +12,23 @@ import com.mogo.utils.logger.Logger;
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;
}
/**
* 网络模式
*/

View File

@@ -5,6 +5,7 @@ import android.os.SystemClock;
import androidx.annotation.Keep;
import com.mogo.cloud.commons.utils.CoordinateUtils;
import com.mogo.cloud.passport.MoGoAiCloudClient;
import com.mogo.realtime.entity.CloudLocationInfo;
import com.mogo.realtime.util.MogoLatLng;
import com.mogo.utils.logger.Logger;
@@ -39,7 +40,9 @@ public class SimpleLocationCorrectStrategy {
private final List<CloudLocationInfo> errList = new ArrayList<>();
public CloudLocationInfo correct(CloudLocationInfo info) {
Logger.d(TAG, "info: " + info.print());
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "info: " + info.print());
}
if (isLocationValid(info)) {
if (recordLocation()) {
historyList.add(info);
@@ -48,29 +51,36 @@ public class SimpleLocationCorrectStrategy {
if (lastLocation == null) {
lastLocation = info;
anchorTime = SystemClock.elapsedRealtime();
Logger.d(TAG, "第一条数据");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "第一条数据");
}
if (recordLocation()) {
validList.add(lastLocation);
}
return info;
}
if (lastLocation.equals(info)) {
Logger.d(TAG, "相同坐标点==");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "相同坐标点==");
}
return info;
}
try {
float targetDistance =
(float) (lastLocation.getSpeed() * (SystemClock.elapsedRealtime() - anchorTime) / 1000) + TARGET_DISTANCE_DEVIATION;
float distance = CoordinateUtils.calculateLineDistance(lastLocation.getLon(), lastLocation.getLat(), info.getLon(), info.getLat());
Logger.d(TAG,
"准备计算{ lastInfo: " + lastLocation.print() + " info: " + info.print() + " targetDistance: " + targetDistance + " distance : " + distance + "}");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG,
"准备计算{ lastInfo: " + lastLocation.print() + " info: " + info.print() + " targetDistance: " + targetDistance + " distance : " + distance + "}");
}
if (distance <= targetDistance) {
// 新的定位点在目标距离范围内,认为此数据有效
lastLocation = info;
anchorTime = SystemClock.elapsedRealtime();
errCount = 0;
Logger.d(TAG, "在范围内,为有效点");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "在范围内,为有效点");
}
if (recordLocation()) {
validList.add(lastLocation);
}
@@ -86,7 +96,9 @@ public class SimpleLocationCorrectStrategy {
lastLocation = info;
anchorTime = SystemClock.elapsedRealtime();
errCount = 0;
Logger.d(TAG, "出错次数超限,异常点变有效点");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "出错次数超限,异常点变有效点");
}
return info;
} else {
// 按照上一个点的方向和速度,计算下一个点的位置,下一个点除坐标点外,其余数据与上一个点相同
@@ -102,7 +114,9 @@ public class SimpleLocationCorrectStrategy {
lastLocation = nextInfo;
anchorTime = SystemClock.elapsedRealtime();
errCount++;
Logger.d(TAG, "异常点纠偏 info: " + lastLocation);
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "异常点纠偏 info: " + lastLocation);
}
if (recordLocation()) {
correctList.add(nextInfo);
}
@@ -110,11 +124,15 @@ public class SimpleLocationCorrectStrategy {
}
}
} catch (Exception e) {
Logger.e(TAG, e, "纠偏异常");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.e(TAG, e, "纠偏异常");
}
e.printStackTrace();
}
} else {
Logger.d(TAG, "定位点异常");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "定位点异常");
}
if (lastLocation == null) {
return null;
} else {
@@ -122,8 +140,10 @@ public class SimpleLocationCorrectStrategy {
float targetDistance =
(float) (lastLocation.getSpeed() * (SystemClock.elapsedRealtime() - anchorTime) / 1000) + TARGET_DISTANCE_DEVIATION;
float distance = CoordinateUtils.calculateLineDistance(lastLocation.getLon(), lastLocation.getLat(), info.getLon(), info.getLat());
Logger.d(TAG,
"异常定位点\n准备计算{ lastInfo: " + lastLocation.print() + " info: " + info.print() + " targetDistance: " + targetDistance + " distance : " + distance + "}");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG,
"异常定位点\n准备计算{ lastInfo: " + lastLocation.print() + " info: " + info.print() + " targetDistance: " + targetDistance + " distance : " + distance + "}");
}
// 按照上一个点的方向和速度,计算下一个点的位置,下一个点除坐标点外,其余数据与上一个点相同
CloudLocationInfo nextInfo = new CloudLocationInfo(lastLocation);
MogoLatLng nextLatLon = computerThatLonLat(lastLocation.getLon(),
@@ -137,13 +157,17 @@ public class SimpleLocationCorrectStrategy {
lastLocation = nextInfo;
anchorTime = SystemClock.elapsedRealtime();
errCount++;
Logger.d(TAG, "异常点纠偏 info: " + lastLocation);
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "异常点纠偏 info: " + lastLocation);
}
if (recordLocation()) {
correctList.add(nextInfo);
}
return nextInfo;
} catch (Exception e) {
Logger.e(TAG, e, "纠偏异常");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.e(TAG, e, "纠偏异常");
}
e.printStackTrace();
}
}

View File

@@ -58,20 +58,28 @@ public class MogoRTKLocation {
public void init() {
locationManager = (LocationManager) MoGoAiCloudClient.getInstance().getContext().getSystemService(Context.LOCATION_SERVICE);
String provider = locationManager.getBestProvider(getCriteria(), true);
Logger.d(TAG, "init provider : " + provider);
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "init provider : " + provider);
}
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
try {
locationManager.requestLocationUpdates(provider, 0, 0, locationListener);
Location location = locationManager.getLastKnownLocation(provider);
if (location != null) {
Logger.i(TAG, "location : " + location.toString());
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.i(TAG, "location : " + location.toString());
}
}
} catch (Exception e) {
e.printStackTrace();
Logger.d(TAG, "RTK LocationManager requestLocationUpdates has Exception : " + e.getMessage());
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "RTK LocationManager requestLocationUpdates has Exception : " + e.getMessage());
}
}
} else {
Logger.d(TAG, "RTK LocationManager Provider GPS_PROVIDER unable");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "RTK LocationManager Provider GPS_PROVIDER unable");
}
}
}
@@ -102,23 +110,31 @@ public class MogoRTKLocation {
locInfo = cloudLocationInfo;
cacheList.add(cloudLocationInfo);
} else {
Logger.e(TAG, "location == null");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.e(TAG, "location == null");
}
}
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
Logger.d(TAG, "onStatusChanged status: " + status);
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "onStatusChanged status: " + status);
}
}
@Override
public void onProviderEnabled(String provider) {
Logger.d(TAG, "onProviderEnabled");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "onProviderEnabled");
}
}
@Override
public void onProviderDisabled(String provider) {
Logger.d(TAG, "onProviderEnabled");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "onProviderEnabled");
}
}
};
@@ -126,11 +142,15 @@ public class MogoRTKLocation {
* 关闭定位服务
*/
public void stop() {
Logger.d(TAG, "stop RTK Location");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "stop RTK Location");
}
if (locationManager != null && locationListener != null) {
locationManager.removeUpdates(locationListener);
} else {
Logger.d(TAG, "stop failed , reason : loc" + locationManager + " , or loc listener: " + locationListener + " is null");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Logger.d(TAG, "stop failed , reason : loc" + locationManager + " , or loc listener: " + locationListener + " is null");
}
}
}

View File

@@ -115,7 +115,9 @@ public class SocketHandler {
if (msgType == MSG_TYPE_DOWNLINK_CAR_DATA.getMsgType()) {
MogoSnapshotSetData data = GsonUtil.objectFromJson(webSocketData.getData(), MogoSnapshotSetData.class);
if (data == null) {
Log.e(TAG, "onMsgReceived MogoSnapshotSetData == null ");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Log.e(TAG, "onMsgReceived MogoSnapshotSetData == null ");
}
return;
}
for (IMogoCloudOnMsgListener listener : onMsgListenerList) {
@@ -134,7 +136,9 @@ public class SocketHandler {
*/
public void sendMsg(List<CloudLocationInfo> cloudLocationInfo) {
if (cloudLocationInfo == null) {
Log.e(TAG, "请检查传入数组对象为Null");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Log.e(TAG, "请检查传入数组对象为Null");
}
return;
}
CloudLocationInfo lastInfo = null;
@@ -166,7 +170,9 @@ public class SocketHandler {
if (content.self == null &&
(content.adas == null || content.adas.isEmpty())) {
Log.d(TAG, "no information to sent");
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
Log.d(TAG, "no information to sent");
}
return;
}