implementation base service: location, socket, passport
This commit is contained in:
3
.idea/gradle.xml
generated
3
.idea/gradle.xml
generated
@@ -12,8 +12,9 @@
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
<option value="$PROJECT_DIR$/foudations" />
|
||||
<option value="$PROJECT_DIR$/foudations/mogo-base-services-apk" />
|
||||
<option value="$PROJECT_DIR$/foudations/mogo-base-services-sdk" />
|
||||
<option value="$PROJECT_DIR$/foudations/mogo-commons" />
|
||||
<option value="$PROJECT_DIR$/foudations/mogo-connection" />
|
||||
<option value="$PROJECT_DIR$/foudations/mogo-utils" />
|
||||
<option value="$PROJECT_DIR$/libraries" />
|
||||
<option value="$PROJECT_DIR$/libraries/map-amap" />
|
||||
|
||||
@@ -318,6 +318,8 @@ dependencies {
|
||||
f8xxImplementation project(':modules:mogo-module-left-panel-noop')
|
||||
em3Implementation project(':modules:mogo-module-left-panel-noop')
|
||||
}
|
||||
|
||||
apply from: "./functions/baseservices.gradle"
|
||||
}
|
||||
|
||||
//android.applicationVariants.all { variant ->
|
||||
|
||||
1
app/functions/README.md
Normal file
1
app/functions/README.md
Normal file
@@ -0,0 +1 @@
|
||||
# 不同渠道,依赖的实现不一样,需要各个渠道都去依赖各自需要的实现,渠道太多导致build.gradle 文件臃肿,可以通过分gradle文件方式减少臃肿
|
||||
26
app/functions/baseservices.gradle
Normal file
26
app/functions/baseservices.gradle
Normal file
@@ -0,0 +1,26 @@
|
||||
// 基础服务:仅比亚迪渠道用sdk方式实现,其他都基于apk基础服务
|
||||
|
||||
project.dependencies {
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
bydImplementation rootProject.ext.dependencies.mogobaseservicesdk
|
||||
|
||||
d82xImplementation rootProject.ext.dependencies.mogobaseserviceapk
|
||||
em1Implementation rootProject.ext.dependencies.mogobaseserviceapk
|
||||
d8xxImplementation rootProject.ext.dependencies.mogobaseserviceapk
|
||||
em4Implementation rootProject.ext.dependencies.mogobaseserviceapk
|
||||
e8xxImplementation rootProject.ext.dependencies.mogobaseserviceapk
|
||||
e8xxImplementation rootProject.ext.dependencies.mogobaseserviceapk
|
||||
f8xxImplementation rootProject.ext.dependencies.mogobaseserviceapk
|
||||
em3Implementation rootProject.ext.dependencies.mogobaseserviceapk
|
||||
} else {
|
||||
bydImplementation project(':foudations:mogo-base-services-sdk')
|
||||
|
||||
d82xImplementation project(':foudations:mogo-base-services-apk')
|
||||
em1Implementation project(':foudations:mogo-base-services-apk')
|
||||
d8xxImplementation project(':foudations:mogo-base-services-apk')
|
||||
em4Implementation project(':foudations:mogo-base-services-apk')
|
||||
e8xxImplementation project(':foudations:mogo-base-services-apk')
|
||||
f8xxImplementation project(':foudations:mogo-base-services-apk')
|
||||
em3Implementation project(':foudations:mogo-base-services-apk')
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,8 @@ import com.auto.zhidao.logsdk.CrashSystem;
|
||||
import com.bytedance.boost_multidex.BoostMultiDex;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.module.authorize.authprovider.invoke.AuthorizeConstant;
|
||||
import com.mogo.module.carchatting.card.CallChatConstant;
|
||||
import com.mogo.module.common.MogoModule;
|
||||
@@ -19,8 +21,12 @@ import com.mogo.module.push.base.PushUIConstants;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.mogo.module.tanlu.constant.TanluConstants;
|
||||
import com.mogo.module.v2x.V2XConst;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.connection.IMogoSocketManager;
|
||||
import com.mogo.service.passport.IMogoPassportManager;
|
||||
import com.mogo.service.passport.IMogoTicketCallback;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.logger.LogLevel;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.boot.persistent.lib.PersistentManager;
|
||||
@@ -43,66 +49,79 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
super.onCreate();
|
||||
// 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 );
|
||||
|
||||
// MogoModulePaths.addModule(new MogoModule(PATH_GUIDE_FRAGMENT, PATH_GUIDE_MODULE_NAME));
|
||||
MogoModulePaths.addModule(new MogoModule(AuthorizeConstant.PATH_AGREEMENT_FRAGMENT, AuthorizeConstant.PATH_AGREEMENT_MODULE_NAME));
|
||||
MogoModulePaths.addModule( new MogoModule( AuthorizeConstant.PATH_AGREEMENT_FRAGMENT, AuthorizeConstant.PATH_AGREEMENT_MODULE_NAME ) );
|
||||
|
||||
//运营位卡片,需要默认显示,放在第一个加载
|
||||
if (DebugConfig.isLauncher()) {
|
||||
MogoModulePaths.addModule(new MogoModule(MediaConstants.TAG, MediaConstants.MODULE_TYPE));
|
||||
if ( DebugConfig.isLauncher() ) {
|
||||
MogoModulePaths.addModule( new MogoModule( MediaConstants.TAG, MediaConstants.MODULE_TYPE ) );
|
||||
}
|
||||
|
||||
MogoModulePaths.addModule(new MogoModule(CallChatConstant.PROVIDER, CallChatConstant.MODULE_NAME));
|
||||
MogoModulePaths.addModule(new MogoModule(TanluConstants.TAG, TanluConstants.MODEL_NAME));
|
||||
MogoModulePaths.addModule(new MogoModule(MogoServicePaths.PATH_SHARE, "ShareControl"));
|
||||
MogoModulePaths.addModule( new MogoModule( CallChatConstant.PROVIDER, CallChatConstant.MODULE_NAME ) );
|
||||
MogoModulePaths.addModule( new MogoModule( TanluConstants.TAG, TanluConstants.MODEL_NAME ) );
|
||||
MogoModulePaths.addModule( new MogoModule( MogoServicePaths.PATH_SHARE, "ShareControl" ) );
|
||||
|
||||
MogoModulePaths.addModule(new MogoModule(EventPanelConstants.PATH_NAME,
|
||||
EventPanelConstants.MODULE_NAME));
|
||||
MogoModulePaths.addModule(new MogoModule(LeftPanelConst.PATH_NAME,
|
||||
LeftPanelConst.MODULE_NAME));
|
||||
MogoModulePaths.addModule( new MogoModule( EventPanelConstants.PATH_NAME,
|
||||
EventPanelConstants.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.PATH_V2X_UI ) );
|
||||
MogoModulePaths.addModule(new MogoModule( PushUIConstants.PATH, PushUIConstants.NAME));
|
||||
MogoModulePaths.addModule( new MogoModule( PushUIConstants.PATH, PushUIConstants.NAME ) );
|
||||
|
||||
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 );
|
||||
}
|
||||
Log.i("timer", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
Log.i( "timer", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
}
|
||||
|
||||
private void initDebugConfig(){
|
||||
DebugConfig.setNetMode(BuildConfig.NET_ENV);
|
||||
DebugConfig.setDebug(BuildConfig.DEBUG);
|
||||
DebugConfig.setAIType(BuildConfig.AIType);
|
||||
DebugConfig.setLaunchLocationService(BuildConfig.LAUNCH_LOCATION_SERVICE);
|
||||
DebugConfig.setUseCustomNavi(BuildConfig.USE_CUSTOM_NAVI);
|
||||
DebugConfig.setLauncher(BuildConfig.IS_LAUNCHER);
|
||||
private void initDebugConfig() {
|
||||
DebugConfig.setNetMode( BuildConfig.NET_ENV );
|
||||
DebugConfig.setDebug( BuildConfig.DEBUG );
|
||||
DebugConfig.setAIType( BuildConfig.AIType );
|
||||
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.setCarMachineType(BuildConfig.CAR_MACHINE_TYPE);
|
||||
DebugConfig.setCarMachineType( BuildConfig.CAR_MACHINE_TYPE );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
IMogoSocketManager mMogoSocketManager = ARouter.getInstance().navigation(IMogoSocketManager.class);
|
||||
if (mMogoSocketManager != null) {
|
||||
mMogoSocketManager.init(getApplicationContext(), "com.mogo.launcher");
|
||||
} else {
|
||||
Logger.e(TAG, "init socket server error.");
|
||||
}
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
final IMogoServiceApis apis = ARouter.getInstance().navigation( IMogoServiceApis.class );
|
||||
apis.getSocketManagerApi( getApplicationContext() ).init( getApplicationContext(), "com.mogo.launcher" );
|
||||
apis.getPassportManagerApi().requestTicket( new IMogoTicketCallback() {
|
||||
@Override
|
||||
public void onSuccess( String ticket ) {
|
||||
Logger.d( TAG, "ticket = %s", ticket );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError( int code, String msg ) {
|
||||
Logger.w( TAG, "code = %s, msg = %s", code, msg );
|
||||
}
|
||||
} );
|
||||
apis.getLocationInfoApi().start();
|
||||
apis.getMapServiceApi().getSingletonLocationClient( getApplicationContext() ).addLocationListener( location -> {
|
||||
apis.getLocationInfoApi().provideLocation( location );
|
||||
} );
|
||||
}, 2_000L );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
super.attachBaseContext(base);
|
||||
BoostMultiDex.install(base);
|
||||
protected void attachBaseContext( Context base ) {
|
||||
super.attachBaseContext( base );
|
||||
BoostMultiDex.install( base );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@ ext {
|
||||
android = [
|
||||
// applicationId : "com.mogo.launcher",
|
||||
// zhidadoApplicationId: "com.zhidao.launcher",
|
||||
launcherApplicationId : "com.mogo.launcher",
|
||||
independentApplicationId: "com.mogo.launcher.app",
|
||||
compileSdkVersion : 28,
|
||||
buildToolsVersion : "29.0.2",
|
||||
minSdkVersion : 19,
|
||||
targetSdkVersion : 22,
|
||||
launcherApplicationId : "com.mogo.launcher",
|
||||
independentApplicationId: "com.mogo.launcher.app",
|
||||
compileSdkVersion : 28,
|
||||
buildToolsVersion : "29.0.2",
|
||||
minSdkVersion : 19,
|
||||
targetSdkVersion : 22,
|
||||
]
|
||||
|
||||
dependencies = [
|
||||
@@ -172,5 +172,9 @@ ext {
|
||||
moduleleftpanelnoop : "com.mogo.module:module-left-panel-noop:${MOGO_MODULE_LEFT_PANEL_VERSION}",
|
||||
// 闪屏页
|
||||
modulesplash : "com.mogo.module:module-splash:${MOGO_MODULE_SPLASH_VERSION}",
|
||||
|
||||
// 基础服务实现
|
||||
mogobaseservicesdk : "com.mogo.base:services-apk:${MOGO_BASE_SERVICES_SDK_VERSION}",
|
||||
mogobaseserviceapk : "com.mogo.base:services-sdk:${MOGO_BASE_SERVICES_APK_VERSION}",
|
||||
]
|
||||
}
|
||||
1
foudations/mogo-base-services-apk/.gitignore
vendored
Normal file
1
foudations/mogo-base-services-apk/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
7
foudations/mogo-base-services-apk/README.md
Normal file
7
foudations/mogo-base-services-apk/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
## 基实现功能
|
||||
|
||||
基础服务apk实现对应功能:位置上报、长连接、passport
|
||||
|
||||
位置上报:com.zhidao.locationinfo
|
||||
长链:com.zhidao.socketservice
|
||||
passport:
|
||||
51
foudations/mogo-base-services-apk/build.gradle
Normal file
51
foudations/mogo-base-services-apk/build.gradle
Normal file
@@ -0,0 +1,51 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
// buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode Integer.valueOf(VERSION_CODE)
|
||||
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles "consumer-rules.pro"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
|
||||
api rootProject.ext.dependencies.socketsdk
|
||||
api rootProject.ext.dependencies.socketsdkconnsvrprotoco
|
||||
api rootProject.ext.dependencies.socketsdkprotobufjava
|
||||
implementation rootProject.ext.dependencies.accountsdk
|
||||
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
implementation rootProject.ext.dependencies.mogoutils
|
||||
implementation rootProject.ext.dependencies.mogocommons
|
||||
implementation rootProject.ext.dependencies.mogoserviceapi
|
||||
} else {
|
||||
implementation project(":foudations:mogo-utils")
|
||||
implementation project(":foudations:mogo-commons")
|
||||
implementation project(":services:mogo-service-api")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
3
foudations/mogo-base-services-apk/gradle.properties
Normal file
3
foudations/mogo-base-services-apk/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
GROUP=com.mogo.base
|
||||
POM_ARTIFACT_ID=services-apk
|
||||
VERSION_CODE=1
|
||||
21
foudations/mogo-base-services-apk/proguard-rules.pro
vendored
Normal file
21
foudations/mogo-base-services-apk/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.mogo.base.services.apk;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith( AndroidJUnit4.class )
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals( "com.mogo.base.services.apk.test", appContext.getPackageName() );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.base.services.apk">
|
||||
|
||||
/
|
||||
</manifest>
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.mogo.base.services.locationinfo;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.service.locationinfo.IMogoLocationInfoService;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/7/16
|
||||
*
|
||||
* 位置服务
|
||||
*/
|
||||
@Keep
|
||||
class MogoLocationInfoServices implements IMogoLocationInfoService {
|
||||
|
||||
private static final String TAG = "MogoLocationInfoServices";
|
||||
|
||||
private static volatile MogoLocationInfoServices sInstance;
|
||||
|
||||
private MogoLocationInfoServices() {
|
||||
}
|
||||
|
||||
@Keep
|
||||
public static MogoLocationInfoServices getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( MogoLocationInfoServices.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new MogoLocationInfoServices();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void provideLocation( MogoLocation location ) {
|
||||
Logger.d( TAG, "apk - provideLocation" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
Logger.d( TAG, "apk - start" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
Logger.d( TAG, "apk - stop" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
Logger.d( TAG, "apk - init" );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.mogo.base.services.passport;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.storage.SpStorage;
|
||||
import com.mogo.service.passport.IMogoPassportManager;
|
||||
import com.mogo.service.passport.IMogoTicketCallback;
|
||||
import com.zhidao.account.sdk.AccountClientManager;
|
||||
import com.zhidao.account.sdk.callback.TicketInfoCallback;
|
||||
import com.zhidao.account.sdk.network.NetEnvironManager;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/7/16
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class PassportManager implements IMogoPassportManager {
|
||||
|
||||
private static final String TAG = "PassportManager";
|
||||
|
||||
private static volatile PassportManager sInstance;
|
||||
|
||||
private PassportManager(){}
|
||||
|
||||
public static PassportManager getInstance(){
|
||||
if( sInstance == null ){
|
||||
synchronized( PassportManager.class ) {
|
||||
if( sInstance == null ){
|
||||
sInstance = new PassportManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release(){
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestTicket( final IMogoTicketCallback callback ) {
|
||||
getTicket( new TicketInfoCallback() {
|
||||
@Override
|
||||
public void onSuccess( String ticket ) {
|
||||
SpStorage.setTicket( ticket );
|
||||
if ( callback != null ) {
|
||||
callback.onSuccess( ticket );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure( int code, String msg ) {
|
||||
if ( callback != null ) {
|
||||
callback.onError( code, msg );
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private static void getTicket( TicketInfoCallback callback ) {
|
||||
if ( DebugConfig.isLauncher() ) {
|
||||
AccountClientManager.getTicket( callback );
|
||||
} else {
|
||||
AccountClientManager.getAppTicket( callback );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
int mode = DebugConfig.getNetMode();
|
||||
if ( mode == DebugConfig.NET_MODE_DEMO ) {
|
||||
// 演示环境用 qa 的
|
||||
mode = DebugConfig.NET_MODE_QA;
|
||||
}
|
||||
AccountClientManager.init( context.getApplicationContext(), mode, NetEnvironManager.OS_2C, "os2.0-launcher" );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
package com.mogo.base.services.socket;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.mogo.service.connection.IMogoMsgAckListener;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.service.connection.IMogoSocketManager;
|
||||
import com.mogo.service.connection.MsgBody;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
import com.zhidao.ptech.connsvr.commom.protocol.MogoCommon;
|
||||
import com.zhidao.ptech.connsvr.protocol.MogoConnsvr;
|
||||
import com.zhidao.socketsdk.manager.OnSocketAckCallback;
|
||||
import com.zhidao.socketsdk.manager.OnSocketReceiveCallback;
|
||||
import com.zhidao.socketsdk.manager.SocketConnManager;
|
||||
import com.zhidao.socketsdk.manager.SocketConnManagerImpl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-31
|
||||
* <p>
|
||||
* 长链实现:基于 netty
|
||||
*/
|
||||
|
||||
public class SocketManager implements IMogoSocketManager, OnSocketReceiveCallback, OnSocketAckCallback {
|
||||
|
||||
private static final String TAG = "SocketManager";
|
||||
|
||||
public static final int MSG_PRODUCT_LINE = MogoCommon.Product.mogoBussiness_VALUE;
|
||||
private static final int MSG_HEADER_TYPE = MogoConnsvr.MsgType.mogoMsgTypeDispatchSvrNoRspReq_VALUE;
|
||||
|
||||
private static volatile SocketManager sInstance;
|
||||
|
||||
private SocketManager( Context context ) {
|
||||
mSocketConnManager = SocketConnManagerImpl.getInstance( context );
|
||||
mSocketConnManager.addSocketMessageCallback( this );
|
||||
mSocketConnManager.addSocketAckCallback( this );
|
||||
}
|
||||
|
||||
public static SocketManager getInstance( Context context ) {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( SocketManager.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new SocketManager( context );
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理消息分发
|
||||
* <p>
|
||||
* key - msgType
|
||||
*/
|
||||
private Map< Integer, List< IMogoOnMessageListener > > mListeners = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 管理消息回执
|
||||
* <p>
|
||||
* key - msgId
|
||||
*/
|
||||
private Map< Long, IMogoMsgAckListener > mAckListeners = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
private SocketConnManager mSocketConnManager;
|
||||
public static final int MAX_CAP = 64; //保证充足的容量应对非常延时的推送
|
||||
private ArrayList< Long > mReceivedMsgId = new ArrayList<>( MAX_CAP );
|
||||
private int mCurrentIndex = 0;
|
||||
|
||||
@Override
|
||||
public void init( Context context, String appId ) {
|
||||
if ( mSocketConnManager != null ) {
|
||||
mSocketConnManager.init( appId );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessageReceived( byte[] content, long msgId ) {
|
||||
try {
|
||||
MogoConnsvr.Payload payload = MogoConnsvr.Payload.parseFrom( content );
|
||||
int msgType = payload.getMsgType();
|
||||
Logger.d( TAG, "received msg type = %d", msgType );
|
||||
List< IMogoOnMessageListener > listeners = mListeners.get( msgType );
|
||||
if ( listeners != null && !listeners.isEmpty() ) {
|
||||
Iterator< IMogoOnMessageListener > iterator = listeners.iterator();
|
||||
if ( msgId != 0 ) { //兼容老版本
|
||||
if ( mReceivedMsgId.contains( msgId ) ) { // 避免消息重发
|
||||
return;
|
||||
}
|
||||
cacheLastReceivedMsgId( msgId );
|
||||
}
|
||||
Object object = null;
|
||||
while ( iterator.hasNext() ) {
|
||||
IMogoOnMessageListener listener = iterator.next();
|
||||
if ( object == null ) {
|
||||
object = GsonUtil.objectFromJson( payload.getPayload().toStringUtf8(), listener.target() );
|
||||
}
|
||||
if ( listener != null ) {
|
||||
Logger.d( TAG, "received msgId = %s, content = %s", msgId, payload.getPayload().toStringUtf8() );
|
||||
listener.onMsgReceived( object );
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch ( InvalidProtocolBufferException e ) {
|
||||
Logger.e( TAG, e, "parse msg error." );
|
||||
}
|
||||
}
|
||||
|
||||
private void cacheLastReceivedMsgId( long msgId ) {
|
||||
if ( msgId == 0 ) {
|
||||
return;
|
||||
}
|
||||
synchronized ( this ){
|
||||
mReceivedMsgId.add( mCurrentIndex % MAX_CAP, msgId );
|
||||
mCurrentIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAck( byte[] headerBytes, byte[] payloadBytes ) {
|
||||
try {
|
||||
MogoConnsvr.Header header = MogoConnsvr.Header.parseFrom( headerBytes );
|
||||
int msgType = header.getMsgType();
|
||||
String appId = header.getAppId();
|
||||
int productLine = header.getProductLine();
|
||||
long msgId = header.getMsgId();
|
||||
IMogoMsgAckListener listener = mAckListeners.remove( msgId );
|
||||
if ( listener != null ) {
|
||||
listener.onAck( msgId );
|
||||
}
|
||||
Logger.d( TAG, "send message success: msgType = %d, appId = %s, productLine = %d", msgType, appId, productLine );
|
||||
} catch ( InvalidProtocolBufferException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerOnMessageListener( int msgType, IMogoOnMessageListener listener ) {
|
||||
if ( mListeners.containsKey( msgType ) ) {
|
||||
Logger.w( TAG, "msgType %d is exist.", msgType );
|
||||
}
|
||||
if ( !mListeners.containsKey( msgType ) ) {
|
||||
mListeners.put( msgType, new ArrayList< IMogoOnMessageListener >() );
|
||||
}
|
||||
mListeners.get( msgType ).add( listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterOnMessageListener( int msgType ) {
|
||||
mListeners.remove( msgType );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterOnMessageListener( int msgType, IMogoOnMessageListener listener ) {
|
||||
if ( listener == null ) {
|
||||
return;
|
||||
}
|
||||
if ( !mListeners.containsKey( msgType ) ) {
|
||||
return;
|
||||
}
|
||||
List< IMogoOnMessageListener > listeners = mListeners.get( msgType );
|
||||
if ( listeners != null && listeners.contains( listener ) ) {
|
||||
listeners.remove( listener );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMsg( MsgBody body, IMogoMsgAckListener listener ) {
|
||||
Logger.d( TAG, "sendMsg." );
|
||||
if ( mSocketConnManager != null ) {
|
||||
if ( mSocketConnManager.isConnected() ) {
|
||||
Logger.d( TAG, "isConnected." );
|
||||
final byte[] pb = convertToPBBytes( body.getMsgType(), objectToBytes( body.getContent() ) );
|
||||
mSocketConnManager.sendPayload(
|
||||
MSG_PRODUCT_LINE,
|
||||
pb,
|
||||
MSG_HEADER_TYPE,
|
||||
body.isAck(),
|
||||
body.getMsgId()
|
||||
);
|
||||
mAckListeners.put( body.getMsgId(), listener );
|
||||
} else {
|
||||
Logger.e( TAG, "sendMsg error, connect is lost." );
|
||||
}
|
||||
} else {
|
||||
Logger.e( TAG, "sendMsg error, client is null." );
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] objectToBytes( Object obj ) {
|
||||
String jsonStr = GsonUtil.jsonFromObject( obj );
|
||||
return jsonStr.getBytes();
|
||||
}
|
||||
|
||||
private byte[] convertToPBBytes( int msgType, byte[] payloadBytes ) {
|
||||
MogoConnsvr.Payload payloadData = MogoConnsvr.Payload.newBuilder()
|
||||
.setMsgType( msgType )
|
||||
.setPayload( ByteString.copyFrom( payloadBytes ) ).build();
|
||||
return payloadData.toByteArray();
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
mListeners.clear();
|
||||
mListeners = null;
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mogo.base.services.apk;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals( 4, 2 + 2 );
|
||||
}
|
||||
}
|
||||
1
foudations/mogo-base-services-sdk/.gitignore
vendored
Normal file
1
foudations/mogo-base-services-sdk/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
3
foudations/mogo-base-services-sdk/README.md
Normal file
3
foudations/mogo-base-services-sdk/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
## sdk实现功能
|
||||
|
||||
脱离基础服务apk实现对应功能:位置上报、长连接、passport
|
||||
53
foudations/mogo-base-services-sdk/build.gradle
Normal file
53
foudations/mogo-base-services-sdk/build.gradle
Normal file
@@ -0,0 +1,53 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
// buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode Integer.valueOf(VERSION_CODE)
|
||||
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles "consumer-rules.pro"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
// 上报位置
|
||||
implementation 'com.zhidao.locupload:loc-upload-sdk:1.0.6'
|
||||
// 长链
|
||||
implementation 'com.zhidao.socket:built-in-socket:1.0.11'
|
||||
// passport
|
||||
implementation 'com.zhidao.tcloginsdk:tclogin:1.0.6'
|
||||
|
||||
annotationProcessor 'com.elegant.spi:compiler:1.0.3'
|
||||
|
||||
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
implementation rootProject.ext.dependencies.mogoutils
|
||||
implementation rootProject.ext.dependencies.mogocommons
|
||||
implementation rootProject.ext.dependencies.mogoserviceapi
|
||||
} else {
|
||||
implementation project(":foudations:mogo-utils")
|
||||
implementation project(":foudations:mogo-commons")
|
||||
implementation project(":services:mogo-service-api")
|
||||
}
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
3
foudations/mogo-base-services-sdk/gradle.properties
Normal file
3
foudations/mogo-base-services-sdk/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
GROUP=com.mogo.connection
|
||||
POM_ARTIFACT_ID=mogo-base-services-sdk
|
||||
VERSION_CODE=1
|
||||
21
foudations/mogo-base-services-sdk/proguard-rules.pro
vendored
Normal file
21
foudations/mogo-base-services-sdk/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.mogo.base.services;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith( AndroidJUnit4.class )
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals( "com.mogo.base.services.test", appContext.getPackageName() );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.base.services">
|
||||
|
||||
/
|
||||
</manifest>
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.mogo.base.services.locationinfo;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.elegant.spi.annotations.Service;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.service.locationinfo.IMogoLocationInfoService;
|
||||
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
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/7/16
|
||||
*
|
||||
* 位置服务
|
||||
*/
|
||||
class MogoLocationInfoServices implements IMogoLocationInfoService {
|
||||
|
||||
private static final String TAG = "MogoLocationInfoServices";
|
||||
|
||||
private static volatile MogoLocationInfoServices sInstance;
|
||||
private MogoLocation mLocation;
|
||||
|
||||
private MogoLocationInfoServices() {
|
||||
}
|
||||
|
||||
public static MogoLocationInfoServices getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( MogoLocationInfoServices.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new MogoLocationInfoServices();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void provideLocation( MogoLocation location ) {
|
||||
mLocation = location;
|
||||
Logger.d(TAG, "sdk - provideLocation");
|
||||
}
|
||||
|
||||
public MogoLocation getLocation() {
|
||||
return mLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
LocUploadManager.getInstance().startUpload();
|
||||
Logger.d(TAG, "sdk - start");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
LocUploadManager.getInstance().stopUpload();
|
||||
Logger.d(TAG, "sdk - stop");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
LocUploadConfig.instance().
|
||||
setAppId( "dataCrawler" ).
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package com.mogo.base.services.locationinfo;
|
||||
|
||||
import com.elegant.spi.annotations.Service;
|
||||
import com.zhidao.locupload.location.LocationServiceProvider;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/7/16
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
@Service( value = LocationServiceProvider.class )
|
||||
class MogoLocationSource extends LocationServiceProvider {
|
||||
|
||||
@Override
|
||||
public float getBearing() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getBearing();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAccuracy() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getAccuracy();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProvider() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getProvider();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSpeed() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getSpeed();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAltitude() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getAltitude();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAdCode() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getAdCode();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLocType() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getLocType();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getLatitude() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getLatitude();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getLongitude() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getLongitude();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTime() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getTime();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCityCode() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getCityCode();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCityName() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getCityName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGpsAccuracyStatus() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getGpsAccuracyStatus();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSatellites() {
|
||||
if ( MogoLocationInfoServices.getInstance().getLocation() != null ) {
|
||||
return MogoLocationInfoServices.getInstance().getLocation().getSatellite();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCarStatus() {
|
||||
// 常开状态
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.mogo.base.services.passport;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.storage.SpStorage;
|
||||
import com.mogo.service.passport.IMogoPassportManager;
|
||||
import com.mogo.service.passport.IMogoTicketCallback;
|
||||
import com.zhidao.accountsdk.manager.CarPadClientManagerImpl;
|
||||
import com.zhidao.accountsdk.manager.TicketInfoCallback;
|
||||
import com.zhidao.accountsdk.network.NetEnvironManager;
|
||||
import com.zhidao.tcloginsdk.ToCLoginManagerImpl;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/7/16
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class PassportManager implements IMogoPassportManager {
|
||||
|
||||
private static final String TAG = "PassportManager";
|
||||
private Context mContext;
|
||||
|
||||
private static volatile PassportManager sInstance;
|
||||
|
||||
private PassportManager(){}
|
||||
|
||||
public static PassportManager getInstance(){
|
||||
if( sInstance == null ){
|
||||
synchronized( PassportManager.class ) {
|
||||
if( sInstance == null ){
|
||||
sInstance = new PassportManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release(){
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestTicket( final IMogoTicketCallback callback ) {
|
||||
getTicket( new TicketInfoCallback() {
|
||||
@Override
|
||||
public void onSuccess( String ticket ) {
|
||||
SpStorage.setTicket( ticket );
|
||||
if ( callback != null ) {
|
||||
callback.onSuccess( ticket );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure( int code ) {
|
||||
if ( callback != null ) {
|
||||
callback.onError( code, "error." );
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private void getTicket( TicketInfoCallback callback ) {
|
||||
CarPadClientManagerImpl.getInstance( mContext ).getTicket( "os2.0-launcher", new TicketInfoCallback() {
|
||||
@Override
|
||||
public void onSuccess( String ticket ) {
|
||||
if ( callback != null ) {
|
||||
callback.onSuccess( ticket );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure( int code ) {
|
||||
if ( callback != null ) {
|
||||
callback.onFailure( code );
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
mContext = context;
|
||||
int mode = DebugConfig.getNetMode();
|
||||
if ( mode == DebugConfig.NET_MODE_DEMO ) {
|
||||
// 演示环境用 qa 的
|
||||
mode = DebugConfig.NET_MODE_QA;
|
||||
}
|
||||
ToCLoginManagerImpl.getInstance( context ).setNetEnviron( mode );
|
||||
ToCLoginManagerImpl.getInstance( context ).showLoginView();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
package com.mogo.base.services.socket;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.service.connection.IMogoMsgAckListener;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.service.connection.IMogoSocketManager;
|
||||
import com.mogo.service.connection.MsgBody;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
import com.zhidao.locupload.Platform;
|
||||
import com.zhidao.ptech.connsvr.protocol.MogoConnsvr;
|
||||
import com.zhidao.socket.Callback;
|
||||
import com.zhidao.socket.CallbackManager;
|
||||
import com.zhidao.socket.Environment;
|
||||
import com.zhidao.socket.SocketConfig;
|
||||
import com.zhidao.socket.SocketMessageDispatcher;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/7/16
|
||||
*
|
||||
* 长链
|
||||
*/
|
||||
class SocketManager implements IMogoSocketManager, Callback {
|
||||
|
||||
private static final String TAG = "SocketManager";
|
||||
|
||||
private static volatile SocketManager sInstance;
|
||||
|
||||
public SocketManager( Context context ) {
|
||||
CallbackManager.getInstance().register( this );
|
||||
}
|
||||
|
||||
public static SocketManager getInstance( Context context ) {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( SocketManager.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new SocketManager( context );
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理消息分发
|
||||
* <p>
|
||||
* key - msgType
|
||||
*/
|
||||
private Map< Integer, List< IMogoOnMessageListener > > mListeners = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 管理消息回执
|
||||
* <p>
|
||||
* key - msgId
|
||||
*/
|
||||
private Map< Long, IMogoMsgAckListener > mAckListeners = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
public static final int MAX_CAP = 64; //保证充足的容量应对非常延时的推送
|
||||
private ArrayList< Long > mReceivedMsgId = new ArrayList<>( MAX_CAP );
|
||||
private int mCurrentIndex = 0;
|
||||
|
||||
@Override
|
||||
public void init( Context context, String appId ) {
|
||||
SocketConfig.instance()
|
||||
.setAppContext( context.getApplicationContext() )
|
||||
.setEnvironment( getEnvironment() )
|
||||
.setClient( Platform.getClient( Platform.car ) )
|
||||
.setAppId( appId )
|
||||
.setDebug( DebugConfig.isDebug() );
|
||||
SocketMessageDispatcher.getInstance().start( context );
|
||||
}
|
||||
|
||||
private Environment getEnvironment() {
|
||||
switch ( DebugConfig.getNetMode() ) {
|
||||
case 1:
|
||||
return Environment.dev;
|
||||
case 2:
|
||||
case 4:
|
||||
return Environment.qa;
|
||||
case 3:
|
||||
default:
|
||||
return Environment.release;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update( @NonNull CallbackManager manager, @NonNull byte[] content, String appId, long msgId ) {
|
||||
try {
|
||||
MogoConnsvr.Payload payload = MogoConnsvr.Payload.parseFrom( content );
|
||||
int msgType = payload.getMsgType();
|
||||
Logger.d( TAG, "received msg type = %d", msgType );
|
||||
List< IMogoOnMessageListener > listeners = mListeners.get( msgType );
|
||||
if ( listeners != null && !listeners.isEmpty() ) {
|
||||
Iterator< IMogoOnMessageListener > iterator = listeners.iterator();
|
||||
if ( msgId != 0 ) { //兼容老版本
|
||||
if ( mReceivedMsgId.contains( msgId ) ) { // 避免消息重发
|
||||
return;
|
||||
}
|
||||
cacheLastReceivedMsgId( msgId );
|
||||
}
|
||||
Object object = null;
|
||||
while ( iterator.hasNext() ) {
|
||||
IMogoOnMessageListener listener = iterator.next();
|
||||
if ( object == null ) {
|
||||
object = GsonUtil.objectFromJson( payload.getPayload().toStringUtf8(), listener.target() );
|
||||
}
|
||||
if ( listener != null ) {
|
||||
Logger.d( TAG, "received msgId = %s, content = %s", msgId, payload.getPayload().toStringUtf8() );
|
||||
listener.onMsgReceived( object );
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch ( InvalidProtocolBufferException e ) {
|
||||
Logger.e( TAG, e, "parse msg error." );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAck( @NonNull CallbackManager manager, @NonNull byte[] headerBytes, byte[] content ) {
|
||||
try {
|
||||
MogoConnsvr.Header header = MogoConnsvr.Header.parseFrom( headerBytes );
|
||||
int msgType = header.getMsgType();
|
||||
String appId = header.getAppId();
|
||||
int productLine = header.getProductLine();
|
||||
long msgId = header.getMsgId();
|
||||
IMogoMsgAckListener listener = mAckListeners.remove( msgId );
|
||||
if ( listener != null ) {
|
||||
listener.onAck( msgId );
|
||||
}
|
||||
Logger.d( TAG, "send message success: msgType = %d, appId = %s, productLine = %d", msgType, appId, productLine );
|
||||
} catch ( InvalidProtocolBufferException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void cacheLastReceivedMsgId( long msgId ) {
|
||||
if ( msgId == 0 ) {
|
||||
return;
|
||||
}
|
||||
synchronized ( this ) {
|
||||
mReceivedMsgId.add( mCurrentIndex % MAX_CAP, msgId );
|
||||
mCurrentIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerOnMessageListener( int msgType, IMogoOnMessageListener listener ) {
|
||||
if ( mListeners.containsKey( msgType ) ) {
|
||||
Logger.w( TAG, "msgType %d is exist.", msgType );
|
||||
}
|
||||
if ( !mListeners.containsKey( msgType ) ) {
|
||||
mListeners.put( msgType, new ArrayList< IMogoOnMessageListener >() );
|
||||
}
|
||||
mListeners.get( msgType ).add( listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterOnMessageListener( int msgType ) {
|
||||
mListeners.remove( msgType );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterOnMessageListener( int msgType, IMogoOnMessageListener listener ) {
|
||||
if ( listener == null ) {
|
||||
return;
|
||||
}
|
||||
if ( !mListeners.containsKey( msgType ) ) {
|
||||
return;
|
||||
}
|
||||
List< IMogoOnMessageListener > listeners = mListeners.get( msgType );
|
||||
if ( listeners != null && listeners.contains( listener ) ) {
|
||||
listeners.remove( listener );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMsg( MsgBody body, IMogoMsgAckListener listener ) {
|
||||
Logger.d( TAG, "sendMsg." );
|
||||
// if ( mSocketConnManager != null ) {
|
||||
// if ( mSocketConnManager.isConnected() ) {
|
||||
// Logger.d( TAG, "isConnected." );
|
||||
// final byte[] pb = convertToPBBytes( body.getMsgType(), objectToBytes( body.getContent() ) );
|
||||
// mSocketConnManager.sendPayload(
|
||||
// MSG_PRODUCT_LINE,
|
||||
// pb,
|
||||
// MSG_HEADER_TYPE,
|
||||
// body.isAck(),
|
||||
// body.getMsgId()
|
||||
// );
|
||||
// mAckListeners.put( body.getMsgId(), listener );
|
||||
// } else {
|
||||
// Logger.e( TAG, "sendMsg error, connect is lost." );
|
||||
// }
|
||||
// } else {
|
||||
// Logger.e( TAG, "sendMsg error, client is null." );
|
||||
// }
|
||||
}
|
||||
|
||||
public byte[] objectToBytes( Object obj ) {
|
||||
String jsonStr = GsonUtil.jsonFromObject( obj );
|
||||
return jsonStr.getBytes();
|
||||
}
|
||||
|
||||
private byte[] convertToPBBytes( int msgType, byte[] payloadBytes ) {
|
||||
MogoConnsvr.Payload payloadData = MogoConnsvr.Payload.newBuilder()
|
||||
.setMsgType( msgType )
|
||||
.setPayload( ByteString.copyFrom( payloadBytes ) ).build();
|
||||
return payloadData.toByteArray();
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
mListeners.clear();
|
||||
mListeners = null;
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mogo.base.services;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals( 4, 2 + 2 );
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.mogo.commons;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
@@ -20,11 +18,7 @@ import com.mogo.commons.network.X509TrustManagerImpl;
|
||||
import com.mogo.commons.storage.SpStorage;
|
||||
import com.mogo.utils.ThreadPoolService;
|
||||
import com.mogo.utils.TipToast;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.NetConfig;
|
||||
import com.zhidao.account.sdk.AccountClientManager;
|
||||
import com.zhidao.account.sdk.callback.TicketInfoCallback;
|
||||
import com.zhidao.account.sdk.network.NetEnvironManager;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.SecureRandom;
|
||||
@@ -98,7 +92,6 @@ public class AbsMogoApplication extends Application {
|
||||
private void asyncInit() {
|
||||
ThreadPoolService.execute( () -> {
|
||||
initNetConfig();
|
||||
initAccountSdk();
|
||||
// 初始化toast
|
||||
// 初始化埋点
|
||||
Analytics.getInstance().start( sApp );
|
||||
@@ -109,37 +102,42 @@ public class AbsMogoApplication extends Application {
|
||||
AnalyticsConfig.getInstance( sApp ).shouldLog( DebugConfig.isDebug() );
|
||||
Devices.init( getApp() );
|
||||
Devices.checkBindState();
|
||||
asyncInitImpl();
|
||||
} );
|
||||
}
|
||||
|
||||
private static void initAccountSdk() {
|
||||
int mode = DebugConfig.getNetMode();
|
||||
if ( mode == DebugConfig.NET_MODE_DEMO ) {
|
||||
// 演示环境用 qa 的
|
||||
mode = DebugConfig.NET_MODE_QA;
|
||||
}
|
||||
AccountClientManager.init( sApp, mode, NetEnvironManager.OS_2C, "os2.0-launcher" );
|
||||
getTicket( new TicketInfoCallback() {
|
||||
@Override
|
||||
public void onSuccess( String ticket ) {
|
||||
SpStorage.setTicket( ticket );
|
||||
Logger.w( TAG, "request ticket success" );
|
||||
}
|
||||
protected void asyncInitImpl(){
|
||||
|
||||
@Override
|
||||
public void onFailure( int code, String msg ) {
|
||||
Logger.w( TAG, "request ticket error code = %d, msg = %s", code, msg );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private static void getTicket( TicketInfoCallback callback ) {
|
||||
if ( DebugConfig.isLauncher() ) {
|
||||
AccountClientManager.getTicket( callback );
|
||||
} else {
|
||||
AccountClientManager.getAppTicket( callback );
|
||||
}
|
||||
}
|
||||
// private static void initAccountSdk() {
|
||||
// int mode = DebugConfig.getNetMode();
|
||||
// if ( mode == DebugConfig.NET_MODE_DEMO ) {
|
||||
// // 演示环境用 qa 的
|
||||
// mode = DebugConfig.NET_MODE_QA;
|
||||
// }
|
||||
// AccountClientManager.init( sApp, mode, NetEnvironManager.OS_2C, "os2.0-launcher" );
|
||||
// getTicket( new TicketInfoCallback() {
|
||||
// @Override
|
||||
// public void onSuccess( String ticket ) {
|
||||
// SpStorage.setTicket( ticket );
|
||||
// Logger.w( TAG, "request ticket success" );
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onFailure( int code, String msg ) {
|
||||
// Logger.w( TAG, "request ticket error code = %d, msg = %s", code, msg );
|
||||
// }
|
||||
// } );
|
||||
// }
|
||||
//
|
||||
// private static void getTicket( TicketInfoCallback callback ) {
|
||||
// if ( DebugConfig.isLauncher() ) {
|
||||
// AccountClientManager.getTicket( callback );
|
||||
// } else {
|
||||
// AccountClientManager.getAppTicket( callback );
|
||||
// }
|
||||
// }
|
||||
|
||||
private static void initNetConfig() {
|
||||
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
package com.mogo.connection.socket;
|
||||
|
||||
import com.zhidao.ptech.connsvr.commom.protocol.MogoCommon;
|
||||
import com.zhidao.ptech.connsvr.protocol.MogoConnsvr;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-31
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class MsgBody {
|
||||
|
||||
private int mMsgType;
|
||||
|
||||
/**
|
||||
* 服务端分发,业务线
|
||||
*/
|
||||
private int mProductLine = MogoCommon.Product.mogoBussiness_VALUE;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private int mHeaderType = MogoConnsvr.MsgType.mogoMsgTypeDispatchSvrNoRspReq_VALUE;
|
||||
|
||||
/**
|
||||
* 是否回执
|
||||
*/
|
||||
private boolean mAck = false;
|
||||
|
||||
/**
|
||||
* 消息ID
|
||||
*/
|
||||
private final long mMsgId = System.currentTimeMillis();
|
||||
|
||||
private Object mContent;
|
||||
|
||||
public MsgBody msgType( int msgType ) {
|
||||
this.mMsgType = msgType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MsgBody ack( boolean ack ) {
|
||||
this.mAck = ack;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MsgBody content( Object content ) {
|
||||
this.mContent = content;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getMsgType() {
|
||||
return mMsgType;
|
||||
}
|
||||
|
||||
public int getProductLine() {
|
||||
return mProductLine;
|
||||
}
|
||||
|
||||
public int getHeaderType() {
|
||||
return mHeaderType;
|
||||
}
|
||||
|
||||
public boolean ismAck() {
|
||||
return mAck;
|
||||
}
|
||||
|
||||
public long getMsgId() {
|
||||
return mMsgId;
|
||||
}
|
||||
|
||||
public Object getContent() {
|
||||
return mContent;
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ MOGO_MODULE_ONLINECAR_VERSION=1.0.3.2
|
||||
# v2x
|
||||
MOGO_MODULE_V2X_VERSION=1.2.8
|
||||
# 推送
|
||||
MOGO_MODULE_PUSH_VERSION=1.1.5.6
|
||||
MOGO_MODULE_PUSH_VERSION=1.1.5.7
|
||||
MOGO_MODULE_PUSH_BASE_VERSION=1.1.5.5
|
||||
MOGO_MODULE_PUSH_NOOP_VERSION=1.1.5.5
|
||||
# 广告资源位
|
||||
@@ -96,6 +96,10 @@ MOGO_MODULE_OBU_VERSION = 1.2.1.10-SNAPSHOT
|
||||
MOGO_MODULE_SPLASH_VERSION = 1.0.0-SNAPSHOT
|
||||
MOGO_MODULE_SPLASH_NOOP_VERSION = 1.0.0-SNAPSHOT
|
||||
|
||||
# 基础服务实现:passport、socket、location
|
||||
MOGO_BASE_SERVICES_APK_VERSION = 1.0.0
|
||||
MOGO_BASE_SERVICES_SDK_VERSION = 1.0.0
|
||||
|
||||
## 产品库必备配置
|
||||
applicationId=com.mogo.launcer
|
||||
applicationName=IntelligentPilot
|
||||
|
||||
@@ -50,7 +50,6 @@ dependencies {
|
||||
api rootProject.ext.dependencies.mogoservice
|
||||
api rootProject.ext.dependencies.moduleservice
|
||||
api rootProject.ext.dependencies.moduleapps
|
||||
api rootProject.ext.dependencies.mogoconnection
|
||||
api rootProject.ext.dependencies.moduleextensions
|
||||
api rootProject.ext.dependencies.mogomoduleback
|
||||
} else {
|
||||
@@ -62,7 +61,6 @@ dependencies {
|
||||
api project(':services:mogo-service-api')
|
||||
api project(':services:mogo-service')
|
||||
api project(':modules:mogo-module-apps')
|
||||
api project(':foudations:mogo-connection')
|
||||
api project(':modules:mogo-module-extensions')
|
||||
api project(':modules:mogo-module-back')
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.imageloader.IMogoImageloader;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.service.launcher.IMogoLauncher;
|
||||
import com.mogo.service.locationinfo.IMogoLocationInfoService;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoActionManager;
|
||||
import com.mogo.service.module.IMogoAddressManager;
|
||||
@@ -23,6 +24,7 @@ import com.mogo.service.module.IMogoSearchManager;
|
||||
import com.mogo.service.module.IMogoSettingManager;
|
||||
import com.mogo.service.network.IMogoNetwork;
|
||||
import com.mogo.service.obu.IMogoObuManager;
|
||||
import com.mogo.service.passport.IMogoPassportManager;
|
||||
import com.mogo.service.share.IMogoShareManager;
|
||||
import com.mogo.service.statusmanager.IMogoMsgCenter;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
@@ -188,31 +190,50 @@ public interface IMogoServiceApis extends IProvider {
|
||||
|
||||
/**
|
||||
* 获取顶部1/2屏界面管理类
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoTopViewManager getTopViewManager();
|
||||
|
||||
/**
|
||||
* 其他模块调用公共的marker打点
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoMarkerService getMarkerService();
|
||||
|
||||
/**
|
||||
* 其他模块调用分享框的显示和隐藏
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoShareManager getShareManager();
|
||||
|
||||
/**
|
||||
* 获取obuManager
|
||||
*
|
||||
* @return obuManager
|
||||
*/
|
||||
IMogoObuManager getObuManager();
|
||||
|
||||
/**
|
||||
* 获取事件面板manager
|
||||
*
|
||||
* @return eventPanelProvider
|
||||
*/
|
||||
IEventPanelProvider getEventPanelManager();
|
||||
|
||||
/**
|
||||
* 获取位置上报服务接口
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoLocationInfoService getLocationInfoApi();
|
||||
|
||||
/**
|
||||
* 获取位置上报服务接口
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoPassportManager getPassportManagerApi();
|
||||
}
|
||||
|
||||
@@ -208,4 +208,16 @@ public class MogoServicePaths {
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PATH_SPLASH = "/splash/api";
|
||||
|
||||
/**
|
||||
* 位置上报
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PATH_LOCATION_INFO = "/locationinfo/api";
|
||||
|
||||
/**
|
||||
* passport
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String PATH_PASSPORT = "/passport/api";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.mogo.service.locationinfo;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/7/16
|
||||
*
|
||||
* 位置服务:上报位置信息和车机状态
|
||||
*/
|
||||
interface IMogoLocationInfoService extends IProvider {
|
||||
|
||||
/**
|
||||
* 提供位置信息
|
||||
*
|
||||
* @param location
|
||||
*/
|
||||
void provideLocation( MogoLocation location );
|
||||
|
||||
void start();
|
||||
|
||||
void stop();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.mogo.service.passport;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/7/16
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
interface IMogoPassportManager extends IProvider {
|
||||
|
||||
void requestTicket( IMogoTicketCallback callback );
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.mogo.service.passport;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/7/16
|
||||
* <p>
|
||||
* ticket 回调
|
||||
*/
|
||||
interface IMogoTicketCallback {
|
||||
|
||||
void onSuccess( String ticket );
|
||||
|
||||
void onError( int code, String msg );
|
||||
}
|
||||
@@ -47,7 +47,6 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.mogoutils
|
||||
implementation rootProject.ext.dependencies.mogocommons
|
||||
implementation rootProject.ext.dependencies.mogoserviceapi
|
||||
implementation rootProject.ext.dependencies.mogoconnection
|
||||
implementation rootProject.ext.dependencies.modulecommon
|
||||
} else {
|
||||
api project(":libraries:mogo-map")
|
||||
@@ -55,7 +54,6 @@ dependencies {
|
||||
implementation project(":foudations:mogo-utils")
|
||||
implementation project(":foudations:mogo-commons")
|
||||
implementation project(":services:mogo-service-api")
|
||||
implementation project(":foudations:mogo-connection")
|
||||
implementation project(":modules:mogo-module-common")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import android.content.Context;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.connection.socket.SocketManager;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.adas.IMogoADASController;
|
||||
@@ -23,6 +22,7 @@ import com.mogo.service.impl.intent.IntentManager;
|
||||
import com.mogo.service.impl.singleton.SingletonsHolder;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.service.launcher.IMogoLauncher;
|
||||
import com.mogo.service.locationinfo.IMogoLocationInfoService;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoActionManager;
|
||||
import com.mogo.service.module.IMogoAddressManager;
|
||||
@@ -32,6 +32,7 @@ import com.mogo.service.module.IMogoSearchManager;
|
||||
import com.mogo.service.module.IMogoSettingManager;
|
||||
import com.mogo.service.network.IMogoNetwork;
|
||||
import com.mogo.service.obu.IMogoObuManager;
|
||||
import com.mogo.service.passport.IMogoPassportManager;
|
||||
import com.mogo.service.share.IMogoShareManager;
|
||||
import com.mogo.service.statusmanager.IMogoMsgCenter;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
@@ -61,7 +62,7 @@ public class MogoServiceApis implements IMogoServiceApis {
|
||||
|
||||
@Override
|
||||
public IMogoSocketManager getSocketManagerApi( Context context ) {
|
||||
return SocketManager.getInstance( context );
|
||||
return getApiInstance( IMogoSocketManager.class, MogoServicePaths.PATH_SOCKET_MANAGER );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -176,20 +177,30 @@ public class MogoServiceApis implements IMogoServiceApis {
|
||||
|
||||
@Override
|
||||
public IMogoShareManager getShareManager() {
|
||||
return getApiInstance(IMogoShareManager.class,MogoServicePaths.PATH_SHARE);
|
||||
return getApiInstance( IMogoShareManager.class, MogoServicePaths.PATH_SHARE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoObuManager getObuManager() {
|
||||
return getApiInstance(IMogoObuManager.class, MogoServicePaths.PATH_OBU);
|
||||
return getApiInstance( IMogoObuManager.class, MogoServicePaths.PATH_OBU );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEventPanelProvider getEventPanelManager() {
|
||||
return getApiInstance(IEventPanelProvider.class, MogoServicePaths.PATH_EVENT_PANEL);
|
||||
return getApiInstance( IEventPanelProvider.class, MogoServicePaths.PATH_EVENT_PANEL );
|
||||
}
|
||||
|
||||
private static < T extends IProvider > T getApiInstance(Class< T > clazz, String path ) {
|
||||
@Override
|
||||
public IMogoLocationInfoService getLocationInfoApi() {
|
||||
return getApiInstance( IMogoLocationInfoService.class, MogoServicePaths.PATH_LOCATION_INFO );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoPassportManager getPassportManagerApi() {
|
||||
return getApiInstance( IMogoPassportManager.class, MogoServicePaths.PATH_PASSPORT );
|
||||
}
|
||||
|
||||
private static < T extends IProvider > T getApiInstance( Class< T > clazz, String path ) {
|
||||
T inst = SingletonsHolder.get( clazz );
|
||||
if ( inst == null ) {
|
||||
synchronized ( sLock ) {
|
||||
|
||||
@@ -3,12 +3,14 @@ package com.mogo.service.impl.connection;
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.connection.socket.SocketManager;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.connection.IMogoMsgAckListener;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.service.connection.IMogoSocketManager;
|
||||
import com.mogo.service.connection.MsgBody;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -19,6 +21,7 @@ import com.mogo.service.connection.MsgBody;
|
||||
@Route( path = MogoServicePaths.PATH_SOCKET_MANAGER )
|
||||
public class MogoSocketManager implements IMogoSocketManager {
|
||||
|
||||
private static final String TAG = "MogoSocketManager";
|
||||
private IMogoSocketManager mDelegate;
|
||||
|
||||
@Override
|
||||
@@ -58,6 +61,14 @@ public class MogoSocketManager implements IMogoSocketManager {
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
mDelegate = SocketManager.getInstance( context );
|
||||
|
||||
try {
|
||||
Class< ? > clazz = Class.forName( "com.mogo.base.services.socket.SocketManager" );
|
||||
Method getInstanceMethod = clazz.getMethod( "getInstance", Context.class );
|
||||
getInstanceMethod.setAccessible( true );
|
||||
mDelegate = ( IMogoSocketManager ) getInstanceMethod.invoke( null, context );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.mogo.service.impl.locationinfo;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.locationinfo.IMogoLocationInfoService;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/7/16
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
@Route( path = MogoServicePaths.PATH_LOCATION_INFO )
|
||||
class MogoLocationInfoService implements IMogoLocationInfoService {
|
||||
|
||||
private static final String TAG = "MogoLocationInfoService";
|
||||
|
||||
private IMogoLocationInfoService mDelegate;
|
||||
|
||||
@Override
|
||||
public void provideLocation( MogoLocation location ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.provideLocation( location );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
|
||||
try {
|
||||
Class< ? > clazz = Class.forName( "com.mogo.base.services.locationinfo.MogoLocationInfoServices" );
|
||||
Method getInstanceMethod = clazz.getMethod( "getInstance" );
|
||||
getInstanceMethod.setAccessible( true );
|
||||
mDelegate = ( IMogoLocationInfoService ) getInstanceMethod.invoke( null );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.init( context );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.mogo.service.impl.passport;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.connection.IMogoSocketManager;
|
||||
import com.mogo.service.passport.IMogoPassportManager;
|
||||
import com.mogo.service.passport.IMogoTicketCallback;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/7/16
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
@Route( path = MogoServicePaths.PATH_PASSPORT )
|
||||
class MogoPassportManager implements IMogoPassportManager {
|
||||
|
||||
private static final String TAG = "MogoPassportManager";
|
||||
|
||||
private IMogoPassportManager mDelegate;
|
||||
|
||||
@Override
|
||||
public void requestTicket( IMogoTicketCallback callback ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.requestTicket( callback );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
try {
|
||||
Class< ? > clazz = Class.forName( "com.mogo.base.services.passport.PassportManager" );
|
||||
Method getInstanceMethod = clazz.getMethod( "getInstance" );
|
||||
getInstanceMethod.setAccessible( true );
|
||||
mDelegate = ( IMogoPassportManager ) getInstanceMethod.invoke( null );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.init( context );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
include ':foudations:mogo-base-services-apk'
|
||||
include ':foudations:mogo-base-services-sdk'
|
||||
include ':modules:mogo-module-splash-noop'
|
||||
include ':modules:mogo-module-splash'
|
||||
include ':modules:mogo-module-left-panel-noop'
|
||||
@@ -25,7 +27,7 @@ include ':libraries:map-amap'
|
||||
include ':libraries:mogo-map-api'
|
||||
include ':modules:mogo-module-apps'
|
||||
include ':modules:mogo-module-extensions'
|
||||
include ':foudations:mogo-connection'
|
||||
//include ':foudations:mogo-connection'
|
||||
include ':modules:mogo-module-gps-simulator'
|
||||
include ':modules:mogo-module-gps-simulator-debug'
|
||||
include ':modules:mogo-module-gps-simulator-noop'
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
./gradlew :foudations:mogo-commons:clean :foudations:mogo-commons:uploadArchives
|
||||
./gradlew :libraries:mogo-map-api:clean :libraries:mogo-map-api:uploadArchives
|
||||
./gradlew :services:mogo-service-api:clean :services:mogo-service-api:uploadArchives
|
||||
./gradlew :foudations:mogo-connection:clean :foudations:mogo-connection:uploadArchives
|
||||
./gradlew :libraries:map-amap:clean :libraries:map-amap:uploadArchives
|
||||
./gradlew :libraries:map-autonavi:clean :libraries:map-autonavi:uploadArchives
|
||||
./gradlew :libraries:mogo-map:clean :libraries:mogo-map:uploadArchives
|
||||
@@ -32,4 +31,6 @@
|
||||
./gradlew :modules:mogo-module-left-panel:clean :modules:mogo-module-left-panel:uploadArchives
|
||||
./gradlew :modules:mogo-module-left-panel-noop:clean :modules:mogo-module-left-panel-noop:uploadArchives
|
||||
./gradlew :modules:mogo-module-byd:clean :modules:mogo-module-byd:uploadArchives
|
||||
./gradlew :foudations:mogo-base-services-apk:clean :foudations:mogo-base-services-apk:uploadArchives
|
||||
./gradlew :foudations:mogo-base-services-sdk:clean :foudations:mogo-base-services-sdk:uploadArchives
|
||||
|
||||
|
||||
Reference in New Issue
Block a user