diff --git a/gradle.properties b/gradle.properties index 62ba842c5b..885d56c24a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -33,8 +33,8 @@ MAP_AMAP_VERSION=1.2.1.5 MAP_AUTONAVI_VERSION=1.2.1.5 MOGO_MAP_VERSION=1.2.1.5 MOGO_MAP_API_VERSION=1.2.1.5 -MOGO_SERVICE_VERSION=1.2.1.5 -MOGO_SERVICE_API_VERSION=1.2.1.5 +MOGO_SERVICE_VERSION=1.2.1.6 +MOGO_SERVICE_API_VERSION=1.2.1.6 MOGO_CONNECTION_VERSION=1.2.1.5 MOGO_MODULE_APPS_VERSION=1.2.1.5 MOGO_MODULE_NAVI_VERSION=1.2.1.5 @@ -59,11 +59,11 @@ MOGO_MODULE_MAIN_INDEPENDENT_VERSION = 1.2.1.5 ## 工程外部模块 # 探路 -MOGO_MODULE_TANLU_VERSION=1.1.0.1-SNAPSHOT +MOGO_MODULE_TANLU_VERSION=1.2.1.1 # 车聊聊 -CARCHATTING_VERSION=1.0.6 +CARCHATTING_VERSION=1.0.7 # 车聊聊接口 -CARCHATTINGPROVIDER_VERSION=1.0.6 +CARCHATTINGPROVIDER_VERSION=1.0.7 # 视频引导 MOGO_MODULE_GUIDESHOW_VERSION=1.0.2-SNAPSHOT # 视频引导接口 @@ -71,13 +71,13 @@ MOGO_MODULE_GUIDESHOW_PROVIDER_VERSION=1.0.2-SNAPSHOT # 在线车辆F MOGO_MODULE_ONLINECAR_VERSION=1.0.3.2 # v2x -MOGO_MODULE_V2X_VERSION=1.1.24 +MOGO_MODULE_V2X_VERSION=1.1.25 # 推送 MOGO_MODULE_PUSH_VERSION=1.0.1 # 广告资源位 MOGO_MODULE_AD_CARD_VERSION=1.0.1 # 探路上报和分享模块 -TANLULIB_VERSION=1.0.2-SNAPSHOT +TANLULIB_VERSION=1.2.1.1 ## 产品库必备配置 applicationId=com.mogo.launcer diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppsModel.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppsModel.java index a7be4b8197..7235c69ed9 100644 --- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppsModel.java +++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppsModel.java @@ -36,7 +36,6 @@ public class AppsModel { private AppsModel( Context context ) { mContext = context; - mAppFilter = new AppFilterImpl( context ); } public static AppsModel getInstance( Context context ) { @@ -69,6 +68,9 @@ public class AppsModel { } return; } + if ( mAppFilter == null ) { + mAppFilter = new AppFilterImpl( mContext ); + } final PackageManager packageManager = mContext.getPackageManager(); List< PackageInfo > packages = packageManager.getInstalledPackages( 0 ); int counter = 0; diff --git a/modules/mogo-module-authorize/src/main/res/layout/module_authorize_fragment.xml b/modules/mogo-module-authorize/src/main/res/layout/module_authorize_fragment.xml index 5e5992f151..c8b7f7aa56 100644 --- a/modules/mogo-module-authorize/src/main/res/layout/module_authorize_fragment.xml +++ b/modules/mogo-module-authorize/src/main/res/layout/module_authorize_fragment.xml @@ -151,6 +151,8 @@ android:layout_height="0px" android:layout_marginBottom="@dimen/dp_160" android:scrollbarSize="@dimen/dp_207" + android:layout_marginTop="@dimen/dp_54" + android:scrollbarTrackHorizontal="@drawable/module_authorize_scrollbar" android:scrollbarThumbVertical="@drawable/module_authorize_scrollbar" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/EventDispatchCenter.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/EventDispatchCenter.java index 937548ba6e..f3fec2a330 100644 --- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/EventDispatchCenter.java +++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/EventDispatchCenter.java @@ -1,6 +1,5 @@ package com.mogo.module.main; -import android.content.Intent; import android.location.Location; import android.view.MotionEvent; @@ -21,10 +20,6 @@ import com.mogo.map.navi.MogoNaviInfo; import com.mogo.map.navi.MogoTraffic; import com.mogo.map.uicontroller.EnumMapUI; import com.mogo.module.main.registercenter.MogoRegisterCenterHandler; -import com.mogo.module.service.receiver.MogoReceiver; -import com.mogo.service.intent.IMogoIntentListener; -import com.mogo.service.intent.IMogoIntentManager; -import com.mogo.service.module.IMogoModuleLifecycle; import com.mogo.utils.logger.Logger; import java.util.Iterator; @@ -42,8 +37,7 @@ public class EventDispatchCenter implements IMogoCarLocationChangedListener2, IMogoMapListener, IMogoNaviListener2, - IMogoLocationListener, - IMogoIntentListener { + IMogoLocationListener { private static volatile EventDispatchCenter sInstance; @@ -65,12 +59,6 @@ public class EventDispatchCenter implements private static final String TAG = "DispatchCenter"; - public void registerReceiver( IMogoIntentManager intentManager ) { - intentManager.registerIntentListener( Intent.ACTION_POWER_CONNECTED, this ); - intentManager.registerIntentListener( Intent.ACTION_POWER_DISCONNECTED, this ); - intentManager.registerIntentListener( MogoReceiver.ACTION_NWD_ACC, this ); - } - @Override public boolean onMarkerClicked( IMogoMarker marker ) { IMogoMarkerClickListener listener = MogoRegisterCenterHandler.getInstance().getMarkerListener( marker.getOwner() ); @@ -436,32 +424,6 @@ public class EventDispatchCenter implements Logger.i( TAG, "onLocationChanged event cost " + ( System.currentTimeMillis() - start ) + "ms" ); } - @Override - public void onIntentReceived( String intentStr, Intent intent ) { - - Iterator< IMogoModuleLifecycle > iterator = MogoRegisterCenterHandler.getInstance().getLifecycleListeners(); - if ( Intent.ACTION_POWER_CONNECTED.equals( intentStr ) ) { - while ( iterator.hasNext() ) { - IMogoModuleLifecycle lifecycle = iterator.next(); - if ( lifecycle != null ) { - lifecycle.accOn(); - } - } - } else if ( Intent.ACTION_POWER_DISCONNECTED.equals( intentStr ) ) { - } else if ( MogoReceiver.ACTION_NWD_ACC.equals( intentStr ) ) { - int state = intent.getByteExtra( MogoReceiver.PARAM_ACC_STATUS, ( byte ) 0 ); - if ( state == 1 ) { - while ( iterator.hasNext() ) { - IMogoModuleLifecycle lifecycle = iterator.next(); - if ( lifecycle != null ) { - lifecycle.accOn(); - } - } - } - } - } - - @Override public void onArriveDestination() { Iterator< IMogoNaviListener > iterator = MogoRegisterCenterHandler.getInstance().getNaviListeners(); diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesManager.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesManager.java index 876d4c01d2..71d7303ea9 100644 --- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesManager.java +++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesManager.java @@ -60,7 +60,6 @@ public class MogoModulesManager implements MogoModulesHandler { throw new NullPointerException( "activity can't be null." ); } this.mActivity = activity; - EventDispatchCenter.getInstance().registerReceiver( apis.getIntentManagerApi() ); } private Context getContext() { diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/service/MogoMainService.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/service/MogoMainService.java index ce556acb4c..3a979612ae 100644 --- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/service/MogoMainService.java +++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/service/MogoMainService.java @@ -27,7 +27,7 @@ public * * 描述 */ -@Route( path = "/service/base/info" ) +@Route(path = "/service/base/info") class MogoMainService extends Service implements IMogoLocationListener { private static final String TAG = "MogoMainService"; @@ -40,11 +40,11 @@ class MogoMainService extends Service implements IMogoLocationListener { @Override public void onCreate() { - Logger.d( TAG, "基本服务启动" ); - mServiceApis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation(); + Logger.d(TAG, "基本服务启动"); + mServiceApis = (IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(); initAndStartLocation(); initGpsSimulatorListener(); - UiThreadHandler.postDelayed( () -> { + UiThreadHandler.postDelayed(() -> { loadBaseModules(); startTanluService(); initADAS(); @@ -54,49 +54,53 @@ class MogoMainService extends Service implements IMogoLocationListener { @Nullable @Override - public IBinder onBind( Intent intent ) { + public IBinder onBind(Intent intent) { return null; } @Override - public int onStartCommand( Intent intent, int flags, int startId ) { + public int onStartCommand(Intent intent, int flags, int startId) { return START_STICKY; } private void initAndStartLocation() { - Logger.d( TAG, "开始定位" ); - mLocationClient = mServiceApis.getMapServiceApi().getSingletonLocationClient( AbsMogoApplication.getApp() ); - mLocationClient.addLocationListener( this ); - mLocationClient.start( 2_000L ); + Logger.d(TAG, "开始定位"); + mLocationClient = mServiceApis.getMapServiceApi().getSingletonLocationClient(AbsMogoApplication.getApp()); + mLocationClient.addLocationListener(this); + mLocationClient.start(2_000L); } private void initGpsSimulatorListener() { - mServiceApis.getMapServiceApi().getNavi( this ).registerCarLocationChangedListener( EventDispatchCenter.getInstance() ); + mServiceApis.getMapServiceApi().getNavi(this).registerCarLocationChangedListener(EventDispatchCenter.getInstance()); } private void loadBaseModules() { - Logger.d( TAG, "加载基本模块" ); + Logger.d(TAG, "加载基本模块"); MogoModulesManager.getInstance().loadBaseModule(); } private void startTanluService() { - MainService.Companion.launchService( getApplicationContext(), "0" ); + UiThreadHandler.postDelayed(() -> { + Logger.d(TAG, "startTanluService ---------- "); + MainService.Companion.launchService(getApplicationContext(), "0"); + }, 58_000L + ); } private void initADAS() { - mServiceApis.getAdasControllerApi().init( AbsMogoApplication.getApp() ); + mServiceApis.getAdasControllerApi().init(AbsMogoApplication.getApp()); } @Override - public void onLocationChanged( MogoLocation location ) { - EventDispatchCenter.getInstance().onLocationChanged( location ); + public void onLocationChanged(MogoLocation location) { + EventDispatchCenter.getInstance().onLocationChanged(location); } @Override public void onDestroy() { super.onDestroy(); - if ( mLocationClient != null ) { - mLocationClient.removeLocationListener( this ); + if (mLocationClient != null) { + mLocationClient.removeLocationListener(this); mLocationClient.stop(); mLocationClient.destroy(); mLocationClient = null; diff --git a/modules/mogo-module-service/src/main/AndroidManifest.xml b/modules/mogo-module-service/src/main/AndroidManifest.xml index 3ef5034430..8eb5a9dd2c 100644 --- a/modules/mogo-module-service/src/main/AndroidManifest.xml +++ b/modules/mogo-module-service/src/main/AndroidManifest.xml @@ -1,2 +1,15 @@ + package="com.mogo.module.service" > + + + + + + + + + + + diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java index c76e7b3193..cb7fa6a938 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java @@ -65,7 +65,12 @@ public class MarkerServiceHandler { private static MapMarkerManager sMapMarkerManager; - public static void init( final Context context ) { + public static synchronized void init( final Context context ) { + + if ( sGpsSimulatorManager != null ) { + return; + } + sApis = ( IMogoServiceApis ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation( context ); sMapService = sApis.getMapServiceApi(); sImageloader = sApis.getImageLoaderApi(); @@ -85,7 +90,7 @@ public class MarkerServiceHandler { sLauncher = sApis.getLauncherApi(); sFragmentManager = sApis.getFragmentManagerApi(); - sCarChatting = (ICarsChattingProvider)ARouter.getInstance().build( CallChattingProviderConstant.CAR_CALL_PROVIDER ).navigation( context ); + sCarChatting = ( ICarsChattingProvider ) ARouter.getInstance().build( CallChattingProviderConstant.CAR_CALL_PROVIDER ).navigation( context ); sMapMarkerManager = MapMarkerManager.getInstance(); sMapMarkerManager.init( context ); @@ -93,7 +98,7 @@ public class MarkerServiceHandler { sGpsSimulatorManager = ARouter.getInstance().navigation( IMogoGpsSimulatorManager.class ); } - public static IMogoServiceApis getApis(){ + public static IMogoServiceApis getApis() { return sApis; } diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java index 9837155cae..9d6c450152 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java @@ -302,9 +302,6 @@ public class MogoServices implements IMogoMapListener, mIntentManager = MarkerServiceHandler.getIntentManager(); mIntentManager.registerIntentListener( MogoReceiver.ACTIION_ADAS, this ); - mIntentManager.registerIntentListener( Intent.ACTION_POWER_CONNECTED, this ); - mIntentManager.registerIntentListener( Intent.ACTION_POWER_DISCONNECTED, this ); - mIntentManager.registerIntentListener( MogoReceiver.ACTION_NWD_ACC, this ); mIntentManager.registerIntentListener( MogoReceiver.ACTION_VOICE_UI, this ); mIntentManager.registerIntentListener( ServiceConst.COMMAND_NEXT, this ); mIntentManager.registerIntentListener( ServiceConst.COMMAND_PREVIOUS, this ); @@ -403,10 +400,6 @@ public class MogoServices implements IMogoMapListener, } filter.addAction( MogoReceiver.VOICE_ACTION ); filter.addAction( MogoReceiver.ACTIION_ADAS ); - filter.addAction( MogoReceiver.ACTION_NWD_ACC ); - // acc On - filter.addAction( Intent.ACTION_POWER_CONNECTED ); - filter.addAction( Intent.ACTION_POWER_DISCONNECTED ); // 小智语音 filter.addAction( MogoReceiver.ACTION_VOICE_UI ); filter.addAction( MogoReceiver.ACTION_ADAS_STATUS ); @@ -856,7 +849,7 @@ public class MogoServices implements IMogoMapListener, @Override public void onTransaction( int size ) { if ( size == 0 ) { - mUiController.showMyLocation( !mNavi.isNaviing() ); + mUiController.showMyLocation( true ); AIAssist.getInstance( mContext ).unregisterUnWakeupCommand( ServiceConst.CMD_BACK ); if ( mStatusManager.isSearchUIShow() ) { mStatusManager.setSearchUIShow( TAG, false ); diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/AccStatusIntentHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/AccStatusIntentHandler.java index b9f14e92da..5a9def8162 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/AccStatusIntentHandler.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/AccStatusIntentHandler.java @@ -5,6 +5,7 @@ import android.content.Intent; import com.mogo.module.service.MarkerServiceHandler; import com.mogo.module.service.ServiceConst; +import com.mogo.module.service.receiver.AccStatusReceiver; import com.mogo.module.service.receiver.MogoReceiver; import com.mogo.utils.logger.Logger; @@ -47,8 +48,8 @@ class AccStatusIntentHandler implements IntentHandler { } else if ( Intent.ACTION_POWER_DISCONNECTED.equals( action ) ) { MarkerServiceHandler.getMogoStatusManager().setAccStatus( ServiceConst.TYPE, false ); Logger.d( TAG, "acc status: %s", false ); - } else if ( MogoReceiver.ACTION_NWD_ACC.equals( action ) ) { - int state = intent.getByteExtra( MogoReceiver.PARAM_ACC_STATUS, ( byte ) 0 ); + } else if ( AccStatusReceiver.ACTION_NWD_ACC.equals( action ) ) { + int state = intent.getByteExtra( AccStatusReceiver.PARAM_ACC_STATUS, ( byte ) 0 ); Logger.d( TAG, "acc status: %s", state == 1 ); MarkerServiceHandler.getMogoStatusManager().setAccStatus( ServiceConst.TYPE, state == 1 ); } diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/IntentHandlerFactory.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/IntentHandlerFactory.java index d67957cb8f..ea84b182e2 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/IntentHandlerFactory.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/IntentHandlerFactory.java @@ -4,6 +4,7 @@ import android.content.Context; import android.content.Intent; import com.mogo.module.service.ServiceConst; +import com.mogo.module.service.receiver.AccStatusReceiver; import com.mogo.module.service.receiver.MogoReceiver; import java.util.HashMap; @@ -31,7 +32,7 @@ public class IntentHandlerFactory { mHandlers.put( MogoReceiver.ACTION_VOICE_UI, new VoiceUiIntentHandler() ); mHandlers.put( Intent.ACTION_POWER_CONNECTED, AccStatusIntentHandler.getInstance() ); mHandlers.put( Intent.ACTION_POWER_DISCONNECTED, AccStatusIntentHandler.getInstance() ); - mHandlers.put( MogoReceiver.ACTION_NWD_ACC, AccStatusIntentHandler.getInstance() ); + mHandlers.put( AccStatusReceiver.ACTION_NWD_ACC, AccStatusIntentHandler.getInstance() ); mHandlers.put( MogoReceiver.ACTION_ADAS_STATUS, ADASStatusIntentHandler.getInstance() ); mHandlers.put( MogoReceiver.ACTIION_ADAS, ADASStatusIntentHandler.getInstance() ); mHandlers.put( MogoReceiver.ACTION_VOICE_READY, new AIAssistIntentHandler() ); diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/receiver/AccStatusReceiver.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/receiver/AccStatusReceiver.java new file mode 100644 index 0000000000..a5d1c55c1c --- /dev/null +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/receiver/AccStatusReceiver.java @@ -0,0 +1,30 @@ +package com.mogo.module.service.receiver; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + +import com.mogo.module.service.MarkerServiceHandler; +import com.mogo.module.service.intent.IntentHandlerFactory; + +public +/** + * @author congtaowang + * @since 2020/6/19 + * + * 描述 + */ +class AccStatusReceiver extends BroadcastReceiver { + + // 诺威达 acc 状态 + public static final String PARAM_ACC_STATUS = "extra_mcu_state"; + + // 诺威达 acc 状态 + public static final String ACTION_NWD_ACC = "com.nwd.action.ACTION_MCU_STATE_CHANGE"; + + @Override + public void onReceive( Context context, Intent intent ) { + MarkerServiceHandler.init( context ); + IntentHandlerFactory.getInstance().handle( context, intent.getAction(), intent ); + } +} diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/receiver/MogoReceiver.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/receiver/MogoReceiver.java index ede5636b6e..42f9bef659 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/receiver/MogoReceiver.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/receiver/MogoReceiver.java @@ -7,6 +7,7 @@ import android.text.TextUtils; import com.alibaba.android.arouter.launcher.ARouter; import com.mogo.commons.voice.VoiceIntentTrack; +import com.mogo.module.service.MarkerServiceHandler; import com.mogo.service.MogoServicePaths; import com.mogo.service.intent.IMogoIntentManager; import com.mogo.utils.logger.Logger; @@ -34,12 +35,6 @@ public class MogoReceiver extends BroadcastReceiver { // ADAS 状态 0 - 关闭 1 - 打开 public static final String PARAM_ADAS_STATUS = "adas_drawer_status"; - // 诺威达 acc 状态 - public static final String ACTION_NWD_ACC = "com.nwd.action.ACTION_MCU_STATE_CHANGE"; - - // 诺威达 acc 状态 - public static final String PARAM_ACC_STATUS = "extra_mcu_state"; - // 小智语音唤醒UI public static final String ACTION_VOICE_UI = "com.zhidao.xiaozhi.wake.status"; public static final String PARRAM_WAKE_STATUS = "WAKE_STATUS"; @@ -61,7 +56,7 @@ public class MogoReceiver extends BroadcastReceiver { private IMogoIntentManager mMogoIntentManager; public MogoReceiver(Context context) { - mMogoIntentManager = (IMogoIntentManager) ARouter.getInstance().build(MogoServicePaths.PATH_INTENT_MANAGER).navigation(context); + mMogoIntentManager = MarkerServiceHandler.getIntentManager(); } @Override diff --git a/services/mogo-service-api/build.gradle b/services/mogo-service-api/build.gradle index 8dc15e3ab2..1dd01dd7ee 100644 --- a/services/mogo-service-api/build.gradle +++ b/services/mogo-service-api/build.gradle @@ -27,6 +27,11 @@ android { } } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + } dependencies { diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/module/IMogoModuleLifecycle.java b/services/mogo-service-api/src/main/java/com/mogo/service/module/IMogoModuleLifecycle.java index 7234996fbe..cde9743e80 100644 --- a/services/mogo-service-api/src/main/java/com/mogo/service/module/IMogoModuleLifecycle.java +++ b/services/mogo-service-api/src/main/java/com/mogo/service/module/IMogoModuleLifecycle.java @@ -6,6 +6,7 @@ package com.mogo.service.module; *

* 卡片生命周期 */ +@Deprecated public interface IMogoModuleLifecycle { /** diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/statusmanager/IMogoStatusChangedListener.java b/services/mogo-service-api/src/main/java/com/mogo/service/statusmanager/IMogoStatusChangedListener.java index 908af22c34..47a501fb53 100644 --- a/services/mogo-service-api/src/main/java/com/mogo/service/statusmanager/IMogoStatusChangedListener.java +++ b/services/mogo-service-api/src/main/java/com/mogo/service/statusmanager/IMogoStatusChangedListener.java @@ -13,4 +13,14 @@ public interface IMogoStatusChangedListener { * @param isTrue true - accOn、adas ui show、voice ui show、push ui show、v2x ui show */ void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ); + + /** + * 是否需要黏性状态: 先改变状态,后注册监听 + * + * @param descriptor 状态 + * @return 默认不需要 + */ + default boolean requestStickyStatus( StatusDescriptor descriptor ) { + return false; + } } diff --git a/services/mogo-service/src/main/java/com/mogo/service/impl/statusmanager/MogoStatusManager.java b/services/mogo-service/src/main/java/com/mogo/service/impl/statusmanager/MogoStatusManager.java index 06a9ce1779..b7e0eed831 100644 --- a/services/mogo-service/src/main/java/com/mogo/service/impl/statusmanager/MogoStatusManager.java +++ b/services/mogo-service/src/main/java/com/mogo/service/impl/statusmanager/MogoStatusManager.java @@ -227,14 +227,21 @@ public class MogoStatusManager implements IMogoStatusManager { } @Override - public void registerStatusChangedListener( String tag, StatusDescriptor descriptor, IMogoStatusChangedListener listeners ) { - if ( listeners == null || descriptor == null ) { + public void registerStatusChangedListener( String tag, StatusDescriptor descriptor, IMogoStatusChangedListener listener ) { + if ( listener == null || descriptor == null ) { return; } if ( !mListeners.containsKey( descriptor ) ) { mListeners.put( descriptor, new ArrayList<>() ); } - mListeners.get( descriptor ).add( listeners ); + mListeners.get( descriptor ).add( listener ); + + if ( listener.requestStickyStatus( descriptor ) ) { + Boolean val = mStatus.get( descriptor ); + if ( val != null ) { + listener.onStatusChanged( descriptor, get_bool_val( descriptor ) ); + } + } } @Override