summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Grover <joeygrover@gmail.com>2018-09-21 10:27:51 -0400
committerJoey Grover <joeygrover@gmail.com>2018-09-21 10:27:51 -0400
commit3a4a0e30709934faafdca26cd3e2f581252ec113 (patch)
treef296559b88f0305c0fd4e78f99d44ddea2f127fd
parent8461d18a3022726bb393c189a074c777815e725c (diff)
downloadsdl_android-3a4a0e30709934faafdca26cd3e2f581252ec113.tar.gz
Add check to prevent NPE in SdlProtocol
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/protocol/SdlProtocol.java26
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;
}