diff --git a/app/src/main/java/com/mogo/launcher/MogoApplication.java b/app/src/main/java/com/mogo/launcher/MogoApplication.java index 23b3058a00..41316c66a1 100644 --- a/app/src/main/java/com/mogo/launcher/MogoApplication.java +++ b/app/src/main/java/com/mogo/launcher/MogoApplication.java @@ -86,7 +86,6 @@ public class MogoApplication extends AbsMogoApplication { MogoModulePaths.addBaseModule( new MogoModule( V2XConst.PATH_V2X_UI, V2XConst.MODULE_NAME ) ); MogoModulePaths.addBaseModule( new MogoModule( MogoServicePaths.PATH_STRATEGY_SHARE, "StrategyShare" ) ); MogoModulePaths.addBaseModule( new MogoModule( MogoServicePaths.PATH_MOGO_MONITOR, "MogoMonitor" ) ); - MogoModulePaths.addModule( new MogoModule( V2XConst.PATH_EVENT_PANEL, V2XConst.MODULE_NAME_EVENT_PANEL ) ); MogoModulePaths.addModule( new MogoModule( PushUIConstants.PATH, PushUIConstants.NAME ) ); if ( !DebugConfig.isLauncher() ) { diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java index 9ee5089486..7cca05598b 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java @@ -48,6 +48,7 @@ import com.mogo.map.uicontroller.EnumMapUI; import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.map.uicontroller.MapCameraPosition; import com.mogo.map.uicontroller.MapControlResult; +import com.mogo.utils.NetworkUtils; import com.mogo.utils.WindowUtils; import com.mogo.utils.logger.Logger; @@ -163,7 +164,9 @@ public class AMapViewWrapper implements IMogoMapView, // mMapView.setRouteOverlayVisible( false ); // mMapView.setCarOverlayVisible( false ); changeMapMode( EnumMapUI.CarUp_2D ); - setTrafficEnabled( true ); + if ( NetworkUtils.isConnected( mMapView.getContext() ) ) { + setTrafficEnabled( true ); + } mMapView.getMap().moveCamera( CameraUpdateFactory.zoomTo( mDefaultZoomLevel ) ); } @@ -309,6 +312,7 @@ public class AMapViewWrapper implements IMogoMapView, @Override public void setTrafficEnabled( boolean visible ) { if ( checkMapView() ) { + Logger.d( TAG, "setTrafficEnabled" ); mMapView.getMap().setTrafficEnabled( true ); } } 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 11f2adf816..3cd8dc89bd 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 @@ -5,6 +5,8 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.location.Location; +import android.net.ConnectivityManager; +import android.net.wifi.WifiManager; import android.os.Handler; import android.os.Looper; import android.os.Message; @@ -64,6 +66,7 @@ import com.mogo.service.module.MogoAction; import com.mogo.service.statusmanager.IMogoStatusChangedListener; import com.mogo.service.statusmanager.IMogoStatusManager; import com.mogo.service.statusmanager.StatusDescriptor; +import com.mogo.utils.NetworkUtils; import com.mogo.utils.UiThreadHandler; import com.mogo.utils.WorkThreadHandler; import com.mogo.utils.logger.Logger; @@ -408,6 +411,7 @@ public class MogoServices implements IMogoMapListener, mIntentManager.registerIntentListener( MogoReceiver.ACTION_AUTO_NAVI_SEND, this ); mIntentManager.registerIntentListener( MogoReceiver.ACTION_MOGO, this ); mIntentManager.registerIntentListener( ServiceConst.COMMAND_ONLINE_CAR_PANEL, this ); + mIntentManager.registerIntentListener( ConnectivityManager.CONNECTIVITY_ACTION, this ); mADASController = MarkerServiceHandler.getADASController(); mLauncher = MarkerServiceHandler.getLauncher(); @@ -503,6 +507,7 @@ public class MogoServices implements IMogoMapListener, filter.addAction( MogoReceiver.ACTION_AUTO_NAVI_SEND ); filter.addAction( MogoReceiver.ACTION_MOGO ); filter.addAction( MogoReceiver.ACTION_TXZ_BLOCK_SEARCH ); + filter.addAction( ConnectivityManager.CONNECTIVITY_ACTION ); try { context.getApplicationContext().registerReceiver( mAIAssistReceiver, filter ); Logger.i( TAG, "register voice receiver." ); @@ -865,6 +870,10 @@ public class MogoServices implements IMogoMapListener, } else if ( ServiceConst.COMMAND_PREVIOUS.equals( command ) ) { onActionDone( MogoAction.Prev ); } else { + if ( TextUtils.equals( command, ConnectivityManager.CONNECTIVITY_ACTION ) + && NetworkUtils.isConnected( mContext ) ) { + mIntentManager.unregisterIntentListener( ConnectivityManager.CONNECTIVITY_ACTION, this ); + } IntentHandlerFactory.getInstance().handle( mContext, command, intent ); } } 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 0124379b5d..8139853b6e 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 @@ -2,6 +2,7 @@ package com.mogo.module.service.intent; import android.content.Context; import android.content.Intent; +import android.net.ConnectivityManager; import com.mogo.module.service.ServiceConst; import com.mogo.module.service.receiver.AccStatusReceiver; @@ -39,6 +40,7 @@ public class IntentHandlerFactory { mHandlers.put( ServiceConst.COMMAND_BACK, WholeVoiceCommandIntentHandler.getInstance() ); mHandlers.put( MogoReceiver.ACTION_MOGO, new MogoControllerIntentHandler() ); mHandlers.put( ServiceConst.COMMAND_ONLINE_CAR_PANEL, new OnlineCarPanelIntentHandler() ); + mHandlers.put( ConnectivityManager.CONNECTIVITY_ACTION, new NetworkChangedIntentHandler() ); } private static final class InstanceHolder { diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java index 89a0c1fb74..473261dc5b 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java @@ -345,6 +345,9 @@ public class MockIntentHandler implements IntentHandler { intent3.putExtra( "EXTRA_REQUEST_AUTO_STATE", 0 ); context.sendBroadcast( intent3 ); break; + case 32: + MarkerServiceHandler.getMapService().getMapUIController().setTrafficEnabled( true ); + break; } } diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/NetworkChangedIntentHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/NetworkChangedIntentHandler.java new file mode 100644 index 0000000000..c61ff760eb --- /dev/null +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/NetworkChangedIntentHandler.java @@ -0,0 +1,38 @@ +package com.mogo.module.service.intent; + +import android.content.Context; +import android.content.Intent; + +import com.mogo.module.common.MogoApisHandler; +import com.mogo.utils.NetworkUtils; +import com.mogo.utils.logger.LogLevel; +import com.mogo.utils.logger.Logger; +import com.mogo.utils.network.NetConfig; + +public +/** + * @author congtaowang + * @since 2020/8/17 + * + * 描述 + */ +class NetworkChangedIntentHandler implements IntentHandler { + + private static final String TAG = "NetworkChangedIntentHandler"; + + @Override + public void handle( Context context, Intent intent ) { + if ( NetworkUtils.isConnected( context ) ) { + try { + Logger.d( TAG, "setTrafficEnabled" ); + MogoApisHandler.getInstance() + .getApis() + .getMapServiceApi() + .getMapUIController() + .setTrafficEnabled( true ); + } catch ( Exception e ) { + e.printStackTrace(); + } + } + } +}