Merge branch 'dev/dev_eagle_architecture_upgrade' into dev/dev_eagle_check

# Conflicts:
#	app/build.gradle
#	app/src/main/java/com/mogo/launcher/MogoApplication.java
#	gradle.properties
#	modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java
#	modules/mogo-module-service/src/main/java/com/mogo/module/service/status/EnvStatusManager.java
#	services/mogo-service-api/src/main/java/com/mogo/service/IMogoServiceApis.java
#	services/mogo-service-api/src/main/java/com/mogo/service/MogoServicePaths.java
#	services/mogo-service/src/main/java/com/mogo/service/impl/MogoServiceApis.java
This commit is contained in:
liujing
2021-09-15 18:09:27 +08:00
1270 changed files with 23741 additions and 379701 deletions

View File

@@ -1,6 +1,5 @@
package com.mogo.launcher;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Process;
@@ -11,11 +10,11 @@ import com.auto.zhidao.logsdk.CrashSystem;
import com.bytedance.boost_multidex.BoostMultiDex;
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.IMoGoTokenCallback;
import com.mogo.cloud.passport.MoGoAiCloudClient;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.FunctionBuildConfig;
import com.mogo.commons.constants.SharedPrefsConstants;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.network.Utils;
@@ -25,6 +24,7 @@ import com.mogo.module.carchatting.card.CallChatConstant;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.MogoModule;
import com.mogo.module.common.MogoModulePaths;
import com.mogo.module.common.constants.HostConst;
import com.mogo.module.main.service.MogoMainService;
import com.mogo.module.push.base.PushUIConstants;
import com.mogo.module.service.ServiceConst;
@@ -36,7 +36,6 @@ import com.mogo.service.MogoServicePaths;
import com.mogo.test.crashreport.ITestCrashReportProvider;
import com.mogo.test.crashreport.upgrade.UpgradeReportProvider;
import com.mogo.utils.ProcessUtils;
import com.mogo.utils.httpdns.HttpSimpleLocation;
import com.mogo.utils.logger.LogLevel;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.storage.SharedPrefsMgr;
@@ -57,6 +56,7 @@ public class MogoApplication extends AbsMogoApplication {
private long start;
private volatile static RefWatcher refWatcher;
@Override
public void onCreate() {
initDebugConfig();
@@ -69,9 +69,9 @@ public class MogoApplication extends AbsMogoApplication {
CrashSystem crashSystem = CrashSystem.getInstance(this);
crashSystem.init();
//设置debug模式日志不上传
// crashSystem.setDebug(BuildConfig.DEBUG);
// crashSystem.setDebug(BuildConfig.DEBUG);
Logger.init(BuildConfig.DEBUG ? LogLevel.DEBUG : LogLevel.OFF);
initMogoHttpDns();
initTipToast();
initModules();
}
@@ -106,7 +106,10 @@ public class MogoApplication extends AbsMogoApplication {
DebugConfig.setNeedHideAdasWhenShare(BuildConfig.IS_NEED_HIDE_ADAS_WHEN_SHARE);
DebugConfig.setNeedUploadCoordinatesInTime(BuildConfig.IS_NEED_UPLOAD_COORDINATES_IN_TIME);
DebugConfig.setUseAdasRtkLocationInfo(BuildConfig.IS_USE_ADAS_RTK_LOCATION_INFO);
DebugConfig.setNeedRequestFloatPermission(BuildConfig.IS_NEED_REQUEST_FLOAT_PERMISSION);
DebugConfig.setObuType(SharedPrefsMgr.getInstance(this).getInt("OBU_TYPE", DebugConfig.OBU_TYPE_CIDI));
FunctionBuildConfig.gpsProvider = BuildConfig.GPS_PROVIDER;
}
@Override
@@ -120,16 +123,6 @@ public class MogoApplication extends AbsMogoApplication {
prepareBaseService();
}
@Override
protected HttpSimpleLocation getCurrentLocation() {
MogoLocation location = MogoApisHandler.getInstance().getApis().getMapServiceApi().getSingletonLocationClient(this).getLastKnowLocation();
if (location == null) {
return null;
} else {
return new HttpSimpleLocation(location.getCityCode(), location.getLatitude(), location.getLongitude());
}
}
/**
* 基础服务passport、location、socket
*/
@@ -177,55 +170,51 @@ public class MogoApplication extends AbsMogoApplication {
break;
}
// 设置应用服务AppId 长链、鉴权
if(DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE){
if (DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE) {
clientConfig.setServiceAppId("com_mogo_launcher");
}else{
} else {
clientConfig.setServiceAppId("com.mogo.launcher");
}
// 设置AI云平台分配给三方应用的签名密钥需要从AI云平台申请
// 设置车机设备的唯一标识(这些表识必须是通过后台录入的设备)
clientConfig.setThirdPartyDeviceId(Utils.getDevicesId());
// 设置循环检测间隔时间
clientConfig.setLoopCheckDelay(15 * 1000);
clientConfig.setLoopCheckDelay(5 * 1000);
// 设置DNS经纬度位置
clientConfig.setIHttpDnsCurrentLocation(new IHttpDnsCurrentLocation() {
@Override
public HttpDnsSimpleLocation getCurrentLocation() {
MogoLocation mogoLocation =
MogoApisHandler.getInstance()
.getApis().getMapServiceApi()
.getSingletonLocationClient(getApp())
.getLastKnowLocation();
HttpDnsSimpleLocation httpDnsSimpleLocation;
if (mogoLocation != null
&& mogoLocation.getLatitude() != 0
&& mogoLocation.getLongitude() != 0) {
clientConfig.setIHttpDnsCurrentLocation(() -> {
MogoLocation mogoLocation =
MogoApisHandler.getInstance()
.getApis().getMapServiceApi()
.getSingletonLocationClient(getApp())
.getLastKnowLocation();
HttpDnsSimpleLocation httpDnsSimpleLocation;
if (mogoLocation != null
&& mogoLocation.getLatitude() != 0
&& mogoLocation.getLongitude() != 0) {
httpDnsSimpleLocation = new HttpDnsSimpleLocation(
mogoLocation.getCityCode(),
mogoLocation.getLatitude(),
mogoLocation.getLongitude());
Logger.i(TAG, "使用实时GPS信息" + httpDnsSimpleLocation);
} else {
String ciyCode = SharedPrefsMgr.getInstance(getApp())
.getString(SharedPrefsConstants.LOCATION_CITY_CODE);
String latitude = SharedPrefsMgr.getInstance(getApp())
.getString(SharedPrefsConstants.LOCATION_LATITUDE);
String longitude = SharedPrefsMgr.getInstance(getApp())
.getString(SharedPrefsConstants.LOCATION_LONGITUDE);
try {
httpDnsSimpleLocation = new HttpDnsSimpleLocation(
mogoLocation.getCityCode(),
mogoLocation.getLatitude(),
mogoLocation.getLongitude());
Logger.i(TAG, "使用实时GPS信息" + httpDnsSimpleLocation);
} else {
String ciyCode = SharedPrefsMgr.getInstance(getApp())
.getString(SharedPrefsConstants.LOCATION_CITY_CODE);
String latitude = SharedPrefsMgr.getInstance(getApp())
.getString(SharedPrefsConstants.LOCATION_LATITUDE);
String longitude = SharedPrefsMgr.getInstance(getApp())
.getString(SharedPrefsConstants.LOCATION_LONGITUDE);
try {
httpDnsSimpleLocation = new HttpDnsSimpleLocation(
ciyCode,
Double.parseDouble(latitude),
Double.parseDouble(longitude));
} catch (NumberFormatException e) {
e.printStackTrace();
httpDnsSimpleLocation = new HttpDnsSimpleLocation("010", 1, 1);
}
Logger.i(TAG, "使用缓存GPS信息" + httpDnsSimpleLocation);
ciyCode,
Double.parseDouble(latitude),
Double.parseDouble(longitude));
} catch (NumberFormatException e) {
e.printStackTrace();
httpDnsSimpleLocation = new HttpDnsSimpleLocation("010", 1, 1);
}
return httpDnsSimpleLocation;
Logger.i(TAG, "使用缓存GPS信息" + httpDnsSimpleLocation);
}
return httpDnsSimpleLocation;
});
// 初始化SDK可以设置状态回调来监听
@@ -233,23 +222,26 @@ public class MogoApplication extends AbsMogoApplication {
new IMoGoTokenCallback() {
@Override
public void onTokenGot(String token, String sn) {
// 鉴权成功后开启socket长链服务
prepareSocketAndLocationServices();
Logger.d("TEST-SOCKET", "onTokenGot ");
// 异步初始化NetConfig
asyncInit();
// HttpDns ttl回调 --- socketTTL
registerSocketHttpDnsTTL(HostConst.SOCKET_CENTER_DOMAIN);
// 开启每5s/次定位上报
uploadLocPerFiveSecond();
}
@Override
public void onError(int code, String msg) {
Log.d(TAG,"初始化MogoAiCloudSdk failed ,reason : " + msg + " , 未能开启长链服务和初始化Modules服务");
Log.d(TAG, "初始化MogoAiCloudSdk failed ,reason : " + msg + " , 未能开启长链服务和初始化Modules服务");
}
}
);
}
private void prepareSocketAndLocationServices() {
//开启Socket长链服务
IMogoServiceApis apis = MogoApisHandler.getInstance().getApis();
apis.getSocketManagerApi(getApplicationContext()).init(getApplicationContext(), DebugConfig.getSocketAppId());
private void uploadLocPerFiveSecond() {
if (DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_SELF_INNOVATE) {
IMogoServiceApis apis = MogoApisHandler.getInstance().getApis();
apis.getLocationInfoApi().start();
apis.getMapServiceApi().getSingletonLocationClient(getApplicationContext()).addLocationListener(location -> {
apis.getLocationInfoApi().provideLocation(location);
@@ -257,16 +249,26 @@ public class MogoApplication extends AbsMogoApplication {
}
}
private void initModules(){
Logger.d(TAG,"initModules");
if (DebugConfig.isNeedLoadGuideModule()) {
MogoModulePaths.addModule(new MogoModule(MogoModulePaths.PATH_GUIDE, MogoModulePaths.PATH_GUIDE));
}
private void startSocketService() {
IMogoServiceApis apis = MogoApisHandler.getInstance().getApis();
// 关闭长链服务
apis.getSocketManagerApi(getApplicationContext()).destroy();
// 开启Socket长链服务
apis.getSocketManagerApi(getApplicationContext()).init(getApplicationContext(), DebugConfig.getSocketAppId());
}
@Override
protected void socketTTL() {
// 鉴权成功后开启socket长链服务
startSocketService();
}
private void initModules() {
Logger.d(TAG, "initModules");
MogoModulePaths.addModule(new MogoModule(MogoServicePaths.PATH_AGREEMENT, AuthorizeConstant.PATH_AGREEMENT_MODULE_NAME));
if (DebugConfig.isLauncher()) {
MogoModulePaths.addModule(new MogoModule(MogoServicePaths.PATH_BACK, MogoServicePaths.PATH_BACK));
MogoModulePaths.addModule(new MogoModule(MogoModulePaths.PATH_MEDIA, MogoModulePaths.PATH_MEDIA));
}
MogoModulePaths.addModule(new MogoModule(ServiceConst.PATH_TTS_CONFIG, ServiceConst.PATH_TTS_CONFIG));
@@ -293,6 +295,10 @@ public class MogoApplication extends AbsMogoApplication {
MogoModulePaths.addModule(new MogoModule(PushUIConstants.PATH, PushUIConstants.NAME));
// 碰撞报警模块
MogoModulePaths.addModule(new MogoModule(MogoServicePaths.PATH_CRASH_WARNING, "CrashWarning"));
// OBU 模块
MogoModulePaths.addModule(new MogoModule(MogoServicePaths.PATH_V2X_OBU_MOGO, "IMoGoObuProvider"));
// widgets 模块
MogoModulePaths.addModule(new MogoModule(MogoServicePaths.PATH_V2X_WARNING, "IMoGoWaringProvider"));
// 小地图模块
MogoModulePaths.addModule(new MogoModule(MogoServicePaths.PATH_SMALL_MAP, "IMogoSmallMapProvider"));
// ADAS模块
@@ -308,15 +314,13 @@ public class MogoApplication extends AbsMogoApplication {
startService(intent);
}
if (refWatcher == null){
refWatcher = LeakCanary.install(this);
if (refWatcher == null) {
refWatcher = LeakCanary.install(this);
}
// 初始化 bugly 升级
ARouter.getInstance().navigation(UpgradeReportProvider.class);
// debug 下初始化 bugly 上报
// if (DebugConfig.isDebug()) {
// }
// 初始化 bugly 日志采集
ARouter.getInstance().navigation(ITestCrashReportProvider.class);
Log.i("timer", "cost " + (System.currentTimeMillis() - start) + "ms");
}