Skip to content

Commit 5727e3a

Browse files
committed
Add checks for more references to session
1 parent 2632859 commit 5727e3a

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,11 @@ public void onReceived(RPCMessage message) {
401401
VehicleType vehicleType = raiResponse.getVehicleType();
402402
String systemSoftwareVersion = raiResponse.getSystemSoftwareVersion();
403403
if (vehicleType != null || systemSoftwareVersion != null) {
404-
saveVehicleType(session.getActiveTransports(), vehicleType);
404+
List<TransportRecord> activeTransports = null;
405+
if (session != null) {
406+
activeTransports = session.getActiveTransports();
407+
}
408+
saveVehicleType(activeTransports, vehicleType);
405409
SystemInfo systemInfo = new SystemInfo(vehicleType, systemSoftwareVersion, null);
406410
boolean validSystemInfo = lifecycleListener.onSystemInfoReceived(systemInfo);
407411
if (!validSystemInfo) {
@@ -944,19 +948,27 @@ public void onSessionStarted(int sessionID, Version version, SystemInfo systemIn
944948
DebugTool.logInfo(TAG, "on protocol session started");
945949
if (minimumProtocolVersion != null && minimumProtocolVersion.isNewerThan(version) == 1) {
946950
DebugTool.logWarning(TAG, String.format("Disconnecting from head unit, the configured minimum protocol version %s is greater than the supported protocol version %s", minimumProtocolVersion, getProtocolVersion()));
947-
session.endService(SessionType.RPC);
951+
if (session != null) {
952+
session.endService(SessionType.RPC);
953+
}
948954
clean();
949955
onClose("Protocol version not supported: " + version, null, SdlDisconnectedReason.MINIMUM_PROTOCOL_VERSION_HIGHER_THAN_SUPPORTED);
950956
return;
951957
}
952958

953959
if (systemInfo != null && lifecycleListener != null) {
954960
didCheckSystemInfo = true;
955-
saveVehicleType(session.getActiveTransports(), systemInfo.getVehicleType());
961+
List<TransportRecord> activeTransports = null;
962+
if (session != null) {
963+
activeTransports = session.getActiveTransports();
964+
}
965+
saveVehicleType(activeTransports, systemInfo.getVehicleType());
956966
boolean validSystemInfo = lifecycleListener.onSystemInfoReceived(systemInfo);
957967
if (!validSystemInfo) {
958968
DebugTool.logWarning(TAG, "Disconnecting from head unit, the system info was not accepted.");
959-
session.endService(SessionType.RPC);
969+
if (session != null) {
970+
session.endService(SessionType.RPC);
971+
}
960972
clean();
961973
onClose("System not supported", null, SdlDisconnectedReason.DEFAULT);
962974
return;

0 commit comments

Comments
 (0)