diff options
author | Joey Grover <joeygrover@gmail.com> | 2018-09-21 10:27:51 -0400 |
---|---|---|
committer | Joey Grover <joeygrover@gmail.com> | 2018-09-21 10:27:51 -0400 |
commit | 3a4a0e30709934faafdca26cd3e2f581252ec113 (patch) | |
tree | f296559b88f0305c0fd4e78f99d44ddea2f127fd | |
parent | 8461d18a3022726bb393c189a074c777815e725c (diff) | |
download | sdl_android-3a4a0e30709934faafdca26cd3e2f581252ec113.tar.gz |
Add check to prevent NPE in SdlProtocol
-rw-r--r-- | sdl_android/src/main/java/com/smartdevicelink/protocol/SdlProtocol.java | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlProtocol.java b/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlProtocol.java index dfff53ca3..a3a515e8d 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlProtocol.java +++ b/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlProtocol.java @@ -347,22 +347,24 @@ public class SdlProtocol { if(connectedPrimaryTransport == null){ //If there is no connected primary then there is no transport available for any service return false; - }else if(activeTransports.containsKey(serviceType)){ + }else if(activeTransports!= null && activeTransports.containsKey(serviceType)){ //There is an active transport that this service can be used on //This should catch RPC, Bulk, and Control service types return true; } - List<Integer> transportPriority = transportPriorityForServiceMap.get(serviceType); - - if(transportPriority != null && !transportPriority.isEmpty()) { - if (transportPriority.contains(PRIMARY_TRANSPORT_ID)) { - //If the transport priority for this service type contains primary then - // the service can be used/started - return true; - }else if(transportPriority.contains(SECONDARY_TRANSPORT_ID)) { - //This would mean only secondary transport is supported for this service - return isSecondaryTransportAvailable(false); + if(transportPriorityForServiceMap != null) { + List<Integer> transportPriority = transportPriorityForServiceMap.get(serviceType); + + if (transportPriority != null && !transportPriority.isEmpty()) { + if (transportPriority.contains(PRIMARY_TRANSPORT_ID)) { + //If the transport priority for this service type contains primary then + // the service can be used/started + return true; + } else if (transportPriority.contains(SECONDARY_TRANSPORT_ID)) { + //This would mean only secondary transport is supported for this service + return isSecondaryTransportAvailable(false); + } } } @@ -391,7 +393,7 @@ public class SdlProtocol { if (transportManager.isConnected(supportedSecondary, null)) { //A supported secondary transport is already connected return true; - } else if (secondaryTransportParams.containsKey(supportedSecondary)) { + } else if (secondaryTransportParams != null && secondaryTransportParams.containsKey(supportedSecondary)) { //A secondary transport is available to connect to return true; } |