Merge remote-tracking branch 'origin/qa_byd' into qa_byd

This commit is contained in:
董宏宇
2020-07-23 19:14:34 +08:00
3 changed files with 14 additions and 27 deletions

View File

@@ -99,25 +99,25 @@ public class MogoApplication extends AbsMogoApplication {
@Override
protected void init() {
super.init();
prepareBaseService();
prepareBaseService(2_000L);
}
/**
* 基础服务passport、location、socket
*/
private void prepareBaseService(){
UiThreadHandler.postDelayed( ()->{
private void prepareBaseService(long delay) {
UiThreadHandler.postDelayed( () -> {
final IMogoServiceApis apis = ARouter.getInstance().navigation( IMogoServiceApis.class );
// 第三方平台的sn是服务端生成的所以必须在返回后才能开启
if ( TextUtils.isEmpty( Utils.getSn() ) ) {
preparePassportEnvironment( apis, ()->{
preparePassportEnvironment( apis, () -> {
prepareSocketAndLocationServices( apis );
} );
} else {
preparePassportEnvironment( apis, null );
prepareSocketAndLocationServices( apis );
}
}, 2_000L );
}, delay );
}
private void preparePassportEnvironment( IMogoServiceApis apis, Runnable after ) {
@@ -134,11 +134,18 @@ public class MogoApplication extends AbsMogoApplication {
@Override
public void onError( int code, String msg ) {
Logger.w( TAG, "code = %s, msg = %s", code, msg );
if ( !TextUtils.isEmpty( Utils.getSn() ) ) {
if ( after != null ) {
after.run();
}
} else {
prepareBaseService(1_000L);
}
}
} );
}
private void prepareSocketAndLocationServices(IMogoServiceApis apis){
private void prepareSocketAndLocationServices( IMogoServiceApis apis ) {
apis.getSocketManagerApi( getApplicationContext() ).init( getApplicationContext(), DebugConfig.getSocketAppId() );
apis.getLocationInfoApi().start();
apis.getMapServiceApi().getSingletonLocationClient( getApplicationContext() ).addLocationListener( location -> {

View File

@@ -30,7 +30,7 @@ dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation rootProject.ext.dependencies.arouter
// 上报位置
implementation 'com.zhidao.locupload:loc-upload-sdk:1.1.1'
implementation 'com.zhidao.locupload:loc-upload-sdk:1.1.2'
// 长链
implementation 'com.zhidao.socket:built-in-socket:1.0.15'
// passport

View File

@@ -4,8 +4,6 @@ import android.content.Context;
import androidx.annotation.Keep;
import com.elegant.spi.annotations.Service;
import com.mogo.base.services.BaseServicesConstants;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.map.location.MogoLocation;
import com.mogo.service.locationinfo.IMogoLocationInfoService;
@@ -13,8 +11,6 @@ import com.mogo.utils.logger.Logger;
import com.zhidao.locupload.LocEnvironment;
import com.zhidao.locupload.LocUploadConfig;
import com.zhidao.locupload.LocUploadManager;
import com.zhidao.locupload.Platform;
import com.zhidao.locupload.location.LocationServiceProvider;
public
/**
@@ -76,25 +72,9 @@ class MogoLocationInfoServices implements IMogoLocationInfoService {
public void init( Context context ) {
LocUploadConfig.instance().
setAppId( DebugConfig.getSocketAppId() ).
setSocketChannelId( BaseServicesConstants.SOCKET_CHANNEL_ID ).
setContext( context.getApplicationContext() ).
setLocEnvironment( getEnvironment() ).
setLoggable( DebugConfig.isDebug() ).
setPlatform( Platform.car ).
setLocInterval( 2000L );
Logger.d( TAG, "sdk - init" );
}
private LocEnvironment getEnvironment() {
switch ( DebugConfig.getNetMode() ) {
case 1:
return LocEnvironment.dev;
case 2:
case 4:
return LocEnvironment.qa;
case 3:
default:
return LocEnvironment.release;
}
}
}