@@ -27,13 +27,10 @@ import com.mogo.module.main.service.MogoMainService;
import com.mogo.module.push.base.PushUIConstants ;
import com.mogo.module.service.ServiceConst ;
import com.mogo.module.share.constant.ShareConstants ;
import com.mogo.realtime.api.MoGoAiCloudRealTime ;
import com.mogo.service.map.IMogoSmallMapProvider ;
import com.mogo.module.v2x.V2XConst ;
import com.mogo.module.v2x.utils.ObuConfig ;
import com.mogo.service.IMogoServiceApis ;
import com.mogo.service.MogoServicePaths ;
import com.mogo.service.passport.IMogoTicketCallback ;
import com.mogo.test.crashreport.ITestCrashReportProvider ;
import com.mogo.utils.ProcessUtils ;
import com.mogo.utils.UiThreadHandler ;
@@ -59,100 +56,103 @@ public class MogoApplication extends AbsMogoApplication {
public void onCreate ( ) {
initDebugConfig ( ) ;
super . onCreate ( ) ;
if ( ! shouldInit ( ) ) {
if ( ! shouldInit ( ) ) {
return ;
}
// Crash 日志收集
final long start = System . currentTimeMillis ( ) ;
CrashSystem crashSystem = CrashSystem . getInstance ( this ) ;
CrashSystem crashSystem = CrashSystem . getInstance ( this ) ;
crashSystem . init ( ) ;
//设置debug模式, 日志不上传
crashSystem . setDebug ( BuildConfig . DEBUG ) ;
Logger . init ( BuildConfig . DEBUG ? LogLevel . DEBUG : LogLevel . OFF ) ;
crashSystem . setDebug ( BuildConfig . DEBUG ) ;
Logger . init ( BuildConfig . DEBUG ? LogLevel . DEBUG : LogLevel . OFF ) ;
if ( DebugConfig . isNeedLoadGuideModule ( ) ) {
MogoModulePaths . addModule ( new MogoModule ( MogoModulePaths . PATH_GUIDE , MogoModulePaths . PATH_GUIDE ) ) ;
if ( DebugConfig . isNeedLoadGuideModule ( ) ) {
MogoModulePaths . addModule ( new MogoModule ( MogoModulePaths . PATH_GUIDE , MogoModulePaths . PATH_GUIDE ) ) ;
}
MogoModulePaths . addModule ( new MogoModule ( MogoServicePaths . PATH_AGREEMENT , AuthorizeConstant . PATH_AGREEMENT_MODULE_NAME ) ) ;
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 ) ) ;
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 ) ) ;
MogoModulePaths . addModule ( new MogoModule ( ServiceConst . PATH_TTS_CONFIG , ServiceConst . PATH_TTS_CONFIG ) ) ;
MogoModulePaths . addBaseModule ( new MogoModule ( MogoServicePaths . PATH_WIDGETS , MogoServicePaths . PATH_WIDGETS ) ) ;
if ( DebugConfig . isMapBased ( ) ) {
MogoModulePaths . addModule ( new MogoModule ( CallChatConstant . PROVIDER , CallChatConstant . MODULE_NAME ) ) ;
MogoModulePaths . addBaseModule ( new MogoModule ( MogoServicePaths . PATH_WIDGETS , MogoServicePaths . PATH_WIDGETS ) ) ;
if ( DebugConfig . isMapBased ( ) ) {
MogoModulePaths . addModule ( new MogoModule ( CallChatConstant . PROVIDER , CallChatConstant . MODULE_NAME ) ) ;
}
MogoModulePaths . addBaseModule ( new MogoModule ( ShareConstants . TAG , ShareConstants . MODEL_NAME ) ) ;
MogoModulePaths . addModule ( new MogoModule ( MogoServicePaths . PATH_TANLU_API , " TanluApi " ) ) ;
MogoModulePaths . addModule ( new MogoModule ( MogoServicePaths . PATH_SHARE , " ShareControl " ) ) ;
MogoModulePaths . addModule ( new MogoModule ( MogoServicePaths . PATH_TRAFFIC_UPLOAD , " TrafficUpload " ) ) ;
MogoModulePaths . addBaseModule ( new MogoModule ( ShareConstants . TAG , ShareConstants . MODEL_NAME ) ) ;
MogoModulePaths . addModule ( new MogoModule ( MogoServicePaths . PATH_TANLU_API , " TanluApi " ) ) ;
MogoModulePaths . addModule ( new MogoModule ( MogoServicePaths . PATH_SHARE , " ShareControl " ) ) ;
MogoModulePaths . addModule ( new MogoModule ( MogoServicePaths . PATH_TRAFFIC_UPLOAD , " TrafficUpload " ) ) ;
MogoModulePaths . addModule ( new MogoModule ( LeftPanelConst . PATH_NAME , LeftPanelConst . MODULE_NAME ) ) ;
MogoModulePaths . addModule ( new MogoModule ( LeftPanelConst . PATH_NAME , LeftPanelConst . MODULE_NAME ) ) ;
MogoModulePaths . addBaseModule ( new MogoModule ( ServiceConst . PATH_REFRESH_STRATEGY , ServiceConst . PATH_REFRESH_STRATEGY ) ) ;
MogoModulePaths . addBaseModule ( new MogoModule ( V2XConst . PATH_V2X_UI , V2XConst . MODULE_NAME ) ) ;
MogoModulePaths . addBaseModule ( new MogoModule ( MogoServicePaths . PATH_STRATEGY_SHARE , " StrategyShare " ) ) ;
MogoModulePaths . addBaseModule ( new MogoModule ( MogoServicePaths . PATH_GAODE_AIMLESS_SHARE , " GaoDeAimlessShare " ) ) ;
MogoModulePaths . addBaseModule ( new MogoModule ( MogoServicePaths . PATH_MOGO_MONITOR , " MogoMonitor " ) ) ;
MogoModulePaths . addModule ( new MogoModule ( PushUIConstants . PATH , PushUIConstants . NAME ) ) ;
MogoModulePaths . addBaseModule ( new MogoModule ( ServiceConst . PATH_REFRESH_STRATEGY , ServiceConst . PATH_REFRESH_STRATEGY ) ) ;
MogoModulePaths . addBaseModule ( new MogoModule ( V2XConst . PATH_V2X_UI , V2XConst . MODULE_NAME ) ) ;
MogoModulePaths . addBaseModule ( new MogoModule ( MogoServicePaths . PATH_STRATEGY_SHARE , " StrategyShare " ) ) ;
MogoModulePaths . addBaseModule ( new MogoModule ( MogoServicePaths . PATH_GAODE_AIMLESS_SHARE , " GaoDeAimlessShare " ) ) ;
MogoModulePaths . addBaseModule ( new MogoModule ( MogoServicePaths . PATH_MOGO_MONITOR , " MogoMonitor " ) ) ;
MogoModulePaths . addModule ( new MogoModule ( PushUIConstants . PATH , PushUIConstants . NAME ) ) ;
// 碰撞报警模块
MogoModulePaths . addModule ( new MogoModule ( MogoServicePaths . PATH_CRASH_WARNING , " CrashWarning " ) ) ;
MogoModulePaths . addModule ( new MogoModule ( MogoServicePaths . PATH_CRASH_WARNING , " CrashWarning " ) ) ;
// MogoModulePaths.addModule( new MogoModule( IMogoMachineVisionProvider.path, "IMogoMachineVisionProvider" ) );
// 小地图模块
MogoModulePaths . addModule ( new MogoModule ( MogoServicePaths . PATH_SMALL_MAP , " IMogoSmallMapProvider " ) ) ;
MogoModulePaths . addModule ( new MogoModule ( MogoServicePaths . PATH_SMALL_MAP , " IMogoSmallMapProvider " ) ) ;
//前方碰撞预警
MogoModulePaths . addModule ( new MogoModule ( MogoServicePaths . PATH_V2X_FRONT_CRASH_WARNING , " IV2XManagerProvider " ) ) ;
MogoModulePaths . addModule ( new MogoModule ( MogoServicePaths . PATH_V2X_FRONT_CRASH_WARNING , " IV2XManagerProvider " ) ) ;
MogoModulePaths . addBaseModule ( new MogoModule ( MogoServicePaths . PATH_GLOBAL_UNWAKE , " GlobalUnwake " ) ) ;
MogoModulePaths . addBaseModule ( new MogoModule ( MogoServicePaths . PATH_GLOBAL_UNWAKE , " GlobalUnwake " ) ) ;
if ( ! DebugConfig . isLauncher ( ) ) {
PersistentManager . getInstance ( ) . initManager ( this ) ;
Intent intent = new Intent ( this , MogoMainService . class ) ;
startService ( intent ) ;
if ( ! DebugConfig . isLauncher ( ) ) {
PersistentManager . getInstance ( ) . initManager ( this ) ;
Intent intent = new Intent ( this , MogoMainService . class ) ;
startService ( intent ) ;
}
LeakCanary . install ( this ) ;
LeakCanary . install ( this ) ;
// debug 下初始化 bugly 上报
if ( DebugConfig . isDebug ( ) ) {
ARouter . getInstance ( ) . navigation ( ITestCrashReportProvider . class ) ;
if ( DebugConfig . isDebug ( ) ) {
ARouter . getInstance ( ) . navigation ( ITestCrashReportProvider . class ) ;
}
Log . i ( " timer " , " cost " + ( System . currentTimeMillis ( ) - start ) + " ms " ) ;
Log . i ( " timer " , " cost " + ( System . currentTimeMillis ( ) - start ) + " ms " ) ;
}
@Override
protected boolean shouldInit ( ) {
Logger . w ( TAG , " evaluate shouldInit() with: %s " , ProcessUtils . getProcessName ( Process . myPid ( ) ) ) ;
return ProcessUtils . isMainProcess ( this ) ;
Logger . w ( TAG , " evaluate shouldInit() with: %s " , ProcessUtils . getProcessName ( Process . myPid ( ) ) ) ;
return ProcessUtils . isMainProcess ( this ) ;
}
/**
* BuildConfig中渠道配置赋值
*/
private void initDebugConfig ( ) {
DebugConfig . setNetMode ( BuildConfig . NET_ENV ) ;
DebugConfig . setDebug ( BuildConfig . DEBUG ) ;
DebugConfig . setLaunchLocationService ( BuildConfig . LAUNCH_LOCATION_SERVICE ) ;
DebugConfig . setUseCustomNavi ( BuildConfig . USE_CUSTOM_NAVI ) ;
DebugConfig . setLauncher ( BuildConfig . IS_LAUNCHER ) ;
DebugConfig . setActiveAIAssistFlag ( BuildConfig . AI_ASSIST_ACTIVE_STAUTS ) ;
DebugConfig . setUseMockObuData ( false ) ;
DebugConfig . setNetMode ( BuildConfig . NET_ENV ) ;
DebugConfig . setDebug ( BuildConfig . DEBUG ) ;
DebugConfig . setLaunchLocationService ( BuildConfig . LAUNCH_LOCATION_SERVICE ) ;
DebugConfig . setUseCustomNavi ( BuildConfig . USE_CUSTOM_NAVI ) ;
DebugConfig . setLauncher ( BuildConfig . IS_LAUNCHER ) ;
DebugConfig . setActiveAIAssistFlag ( BuildConfig . AI_ASSIST_ACTIVE_STAUTS ) ;
DebugConfig . setUseMockObuData ( false ) ;
ObuConfig . useObuLocation = false ;
DebugConfig . setCarMachineType ( BuildConfig . CAR_MACHINE_TYPE ) ;
DebugConfig . setProductFlavor ( BuildConfig . FLAVOR_product ) ;
DebugConfig . setSocketAppId ( BuildConfig . SOCKET_APP_ID ) ;
DebugConfig . setRoadEventAnimated ( BuildConfig . ROAD_EVENT_ANIMATED ) ;
DebugConfig . setSkinSupported ( BuildConfig . IS_SKIN_SUPPORTED ) ;
DebugConfig . setSupportedSearchDestinationOnlineCarList ( BuildConfig . IS_SUPPORTED_SEARCH_DESTINATION_ONLINE_CAR_LIST ) ;
DebugConfig . setScheduleCalculateNotHomeCompanyDistanceForPush ( BuildConfig . IS_SUPPORT_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH ) ;
DebugConfig . setSupportLauncherCardRefreshStrategy ( BuildConfig . IS_SUPPORT_LAUNCHER_CARD_REFRESH_STRATEGY ) ;
DebugConfig . setMapBased ( BuildConfig . IS_MAP_BASED ) ;
DebugConfig . setNeedLoadGuideModule ( BuildConfig . IS_NEED_LOAD_GUIDE_MODULE ) ;
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 . setCarMachineType ( BuildConfig . CAR_MACHINE_TYPE ) ;
DebugConfig . setProductFlavor ( BuildConfig . FLAVOR_product ) ;
DebugConfig . setSocketAppId ( BuildConfig . SOCKET_APP_ID ) ;
DebugConfig . setRoadEventAnimated ( BuildConfig . ROAD_EVENT_ANIMATED ) ;
DebugConfig . setSkinSupported ( BuildConfig . IS_SKIN_SUPPORTED ) ;
DebugConfig . setSupportedSearchDestinationOnlineCarList ( BuildConfig . IS_SUPPORTED_SEARCH_DESTINATION_ONLINE_CAR_LIST ) ;
DebugConfig . setScheduleCalculateNotHomeCompanyDistanceForPush ( BuildConfig . IS_SUPPORT_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH ) ;
DebugConfig . setSupportLauncherCardRefreshStrategy ( BuildConfig . IS_SUPPORT_LAUNCHER_CARD_REFRESH_STRATEGY ) ;
DebugConfig . setMapBased ( BuildConfig . IS_MAP_BASED ) ;
DebugConfig . setNeedLoadGuideModule ( BuildConfig . IS_NEED_LOAD_GUIDE_MODULE ) ;
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 . setObuType ( SharedPrefsMgr . getInstance ( this ) . getInt ( " OBU_TYPE " , DebugConfig . OBU_TYPE_CIDI ) ) ;
}
@@ -165,7 +165,7 @@ public class MogoApplication extends AbsMogoApplication {
protected void init ( ) {
super . init ( ) ;
final IMogoServiceApis apis = MogoApisHandler . getInstance ( ) . getApis ( ) ;
prepareBaseService ( apis , 0L ) ;
prepareBaseService ( apis , 0L ) ;
}
@Override
@@ -173,7 +173,7 @@ public class MogoApplication extends AbsMogoApplication {
MogoLocation location = MogoApisHandler . getInstance ( ) . getApis ( ) . getMapServiceApi ( ) . getSingletonLocationClient ( this ) . getLastKnowLocation ( ) ;
if ( location = = null ) {
return null ;
} else {
} else {
return new HttpSimpleLocation ( location . getCityCode ( ) , location . getLatitude ( ) , location . getLongitude ( ) ) ;
}
}
@@ -181,26 +181,26 @@ public class MogoApplication extends AbsMogoApplication {
/**
* 基础服务: passport、location、socket
*/
private void prepareBaseService ( IMogoServiceApis apis , long delay ) {
private void prepareBaseService ( IMogoServiceApis apis , long delay ) {
UiThreadHandler . postDelayed ( ( ) - > {
UiThreadHandler . postDelayed ( ( ) - > {
// 第三方平台的sn是服务端生成的, 所以必须在返回后才能开启
if ( TextUtils . isEmpty ( Utils . getSn ( ) ) ) {
preparePassportEnvironment ( apis , ( ) - > {
prepareSocketAndLocationServices ( apis ) ;
} ) ;
if ( TextUtils . isEmpty ( Utils . getSn ( ) ) ) {
preparePassportEnvironment ( apis , ( ) - > {
prepareSocketAndLocationServices ( apis ) ;
} ) ;
} else {
preparePassportEnvironment ( apis , null ) ;
prepareSocketAndLocationServices ( apis ) ;
preparePassportEnvironment ( apis , null ) ;
prepareSocketAndLocationServices ( apis ) ;
}
} , delay ) ;
} , delay ) ;
}
private void preparePassportEnvironment ( IMogoServiceApis apis , Runnable after ) {
private void preparePassportEnvironment ( IMogoServiceApis apis , Runnable after ) {
// 配置云服务API
MoGoAiCloudClientConfig clientConfig = MoGoAiCloudClientConfig . getInstance ( ) ;
// 设置网络环境: HTTP_DNS_ENV_QA、HTTP_DNS_ENV_RELEASE、HTTP_DNS_ENV_DEV
switch ( DebugConfig . getNetMode ( ) ) {
switch ( DebugConfig . getNetMode ( ) ) {
case DebugConfig . NET_MODE_DEV :
clientConfig . setNetMode ( MogoHttpDnsConfig . HTTP_DNS_ENV_DEV ) ;
break ;
@@ -256,19 +256,19 @@ public class MogoApplication extends AbsMogoApplication {
MoGoAiCloudClient . getInstance ( ) . init ( this , clientConfig ) ;
}
private void prepareSocketAndLocationServices ( IMogoServiceApis apis ) {
apis . getSocketManagerApi ( getApplicationContext ( ) ) . init ( getApplicationContext ( ) , DebugConfig . getSocketAppId ( ) ) ;
if ( DebugConfig . getCarMachineType ( ) ! = DebugConfig . CAR_MACHINE_TYPE_SELF_INNOVATE ) {
private void prepareSocketAndLocationServices ( IMogoServiceApis apis ) {
apis . getSocketManagerApi ( getApplicationContext ( ) ) . init ( getApplicationContext ( ) , DebugConfig . getSocketAppId ( ) ) ;
if ( DebugConfig . getCarMachineType ( ) ! = DebugConfig . CAR_MACHINE_TYPE_SELF_INNOVATE ) {
apis . getLocationInfoApi ( ) . start ( ) ;
apis . getMapServiceApi ( ) . getSingletonLocationClient ( getApplicationContext ( ) ) . addLocationListener ( location - > {
apis . getLocationInfoApi ( ) . provideLocation ( location ) ;
} ) ;
apis . getMapServiceApi ( ) . getSingletonLocationClient ( getApplicationContext ( ) ) . addLocationListener ( location - > {
apis . getLocationInfoApi ( ) . provideLocation ( location ) ;
} ) ;
}
}
@Override
protected void attachBaseContext ( Context base ) {
super . attachBaseContext ( base ) ;
BoostMultiDex . install ( base ) ;
protected void attachBaseContext ( Context base ) {
super . attachBaseContext ( base ) ;
BoostMultiDex . install ( base ) ;
}
}