diff options
author | Joey Grover <joeygrover@gmail.com> | 2016-03-23 17:00:37 -0400 |
---|---|---|
committer | Joey Grover <joeygrover@gmail.com> | 2016-03-23 17:00:37 -0400 |
commit | 99a3baee3ccfdd0935b21441179c733f86e14ce9 (patch) | |
tree | 1f474edd4f377042e470d385f2d12ddbc596b6bf | |
parent | 094387afbb3b1864e4d303c68b9898e503e048dc (diff) | |
download | sdl_android-99a3baee3ccfdd0935b21441179c733f86e14ce9.tar.gz |
Legacy mode enhancements
4 files changed, 29 insertions, 17 deletions
diff --git a/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java b/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java index 9da8c8357..dc8c0e191 100644 --- a/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java +++ b/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java @@ -50,7 +50,7 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt private CopyOnWriteArrayList<SdlSession> listenerList = new CopyOnWriteArrayList<SdlSession>();
private static TransportType legacyTransportRequest = null; private final static int BUFF_READ_SIZE = 1000000;
- private static MultiplexTransportConfig cachedMultiConfig = null;
+ protected static MultiplexTransportConfig cachedMultiConfig = null;
/**
* Constructor.
@@ -761,12 +761,17 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt }
}else if(_transport.getTransportType()==TransportType.BLUETOOTH
- && !_transport.getIsConnected() && cachedMultiConfig!=null){
- //We are in legacy mode, but just received a force connect. The router service should never be pointing us here if we are truely in legacy mode
- ComponentName tempCompName = SdlBroadcastReceiver.consumeQueuedRouterService();
- cachedMultiConfig.setService(tempCompName);
- //We are not connected yet so we should be able to close down
- _transport.disconnect(); //This will force us into the
+ && !_transport.getIsConnected()){
+ if(cachedMultiConfig!=null){
+ //We are in legacy mode, but just received a force connect. The router service should never be pointing us here if we are truely in legacy mode
+ ComponentName tempCompName = SdlBroadcastReceiver.consumeQueuedRouterService();
+ cachedMultiConfig.setService(tempCompName);
+ //We are not connected yet so we should be able to close down
+ _transport.disconnect(); //This will force us into the
+ }else{
+ Log.i(TAG, "No cached multiplexing config, transport error being called");
+ _transport.disconnect();
+ }
Log.w(TAG, "Using own transport, but not connected. Attempting to join multiplexing");
}else{
Log.w(TAG, "Currently in legacy mode connected to own transport service. Nothing will take place on trnasport cycle");
diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/MultiplexTransport.java b/sdl_android_lib/src/com/smartdevicelink/transport/MultiplexTransport.java index 89061be8f..3bbf3a8e3 100644 --- a/sdl_android_lib/src/com/smartdevicelink/transport/MultiplexTransport.java +++ b/sdl_android_lib/src/com/smartdevicelink/transport/MultiplexTransport.java @@ -287,19 +287,18 @@ public class MultiplexTransport extends SdlTransport{ } } } - + @Override - public void onFailedRouterRegistration(int reason) { - super.onFailedRouterRegistration(reason); + public void onLegacyModeEnabled() { + super.onLegacyModeEnabled(); SdlConnection.enableLegacyMode(isLegacyModeEnabled(), TransportType.BLUETOOTH); if(isLegacyModeEnabled()){ - Log.d(TAG, "Handle transport disconnect, legacy mode enabled"); + Log.d(TAG, "Handle on legacy mode enabled"); this.stop(); isDisconnecting = true; //handleTransportDisconnected(""); handleTransportError("",null); //This seems wrong, but it works } - } @Override diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/SdlRouterService.java b/sdl_android_lib/src/com/smartdevicelink/transport/SdlRouterService.java index e9992b432..4fecdd4d2 100644 --- a/sdl_android_lib/src/com/smartdevicelink/transport/SdlRouterService.java +++ b/sdl_android_lib/src/com/smartdevicelink/transport/SdlRouterService.java @@ -936,6 +936,10 @@ public class SdlRouterService extends Service{ } } private synchronized void initBluetoothSerialService(){ + if(legacyModeEnabled){ + Log.d(TAG, "Not starting own bluetooth during legacy mode"); + return; + } Log.i(TAG, "Iniitializing Bluetooth Serial Class"); //init serial service if(mSerialService ==null){ diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/TransportBroker.java b/sdl_android_lib/src/com/smartdevicelink/transport/TransportBroker.java index af7a09288..4fd5f4c2b 100644 --- a/sdl_android_lib/src/com/smartdevicelink/transport/TransportBroker.java +++ b/sdl_android_lib/src/com/smartdevicelink/transport/TransportBroker.java @@ -165,7 +165,7 @@ public class TransportBroker { enableLegacyMode(true); //We call this so we can start the process of legacy connection //onHardwareDisconnected(TransportType.BLUETOOTH); - onFailedRouterRegistration(msg.arg1); + onLegacyModeEnabled(); break; default: registeredWithRouterService = false; @@ -238,7 +238,11 @@ public class TransportBroker { if(bundle.containsKey(TransportConstants.HARDWARE_DISCONNECTED)){ //We should shut down, so call Log.d(TAG, "Hardware disconnected"); - onHardwareDisconnected(TransportType.valueOf(bundle.getString(TransportConstants.HARDWARE_DISCONNECTED))); + if(isLegacyModeEnabled()){ + onLegacyModeEnabled(); + }else{ + onHardwareDisconnected(TransportType.valueOf(bundle.getString(TransportConstants.HARDWARE_DISCONNECTED))); + } break; } @@ -350,7 +354,7 @@ public class TransportBroker { } public void onHardwareDisconnected(TransportType type){ - synchronized(INIT_LOCK){ + synchronized(INIT_LOCK){Log.d(TAG, "onHardwareDisconnect"); unBindFromRouterService(); routerServiceMessenger = null; routerConnection = null; @@ -372,8 +376,8 @@ public class TransportBroker { public void onPacketReceived(Parcelable packet){ } - - public void onFailedRouterRegistration(int reason){ + + public void onLegacyModeEnabled(){ } |