diff options
author | Joey Grover <joeygrover@gmail.com> | 2021-02-11 14:48:21 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-11 14:48:21 -0500 |
commit | 3a84cea88ad75f1fa72152ac513f7198c758ab06 (patch) | |
tree | 0da6d6266253b22d933e490ca7c8ff7057526cc1 | |
parent | a9dd49ada852755d67ca7c08c028a1ac199d250a (diff) | |
download | sdl_android-3a84cea88ad75f1fa72152ac513f7198c758ab06.tar.gz |
[SDL-0293] OEM Exclusive App Support - Protocol & Manager layers (#1618)
* Implement 0293
Does not include android specific implementaiton pieces
* Update hello world apps
* Update unit tests
* Increase max protocol version
* Add missing nullable tag in SystemInfo
* Add missing nullable tag to method in SystemInfo
* Apply suggestions from code review
Correctly format if statement
Co-authored-by: Julian Kast <Julian.kast@livio.io>
Co-authored-by: Julian Kast <Julian.kast@livio.io>
17 files changed, 246 insertions, 9 deletions
diff --git a/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java b/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java index 0b83e0842..8767b70fa 100755 --- a/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java +++ b/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java @@ -47,6 +47,7 @@ import com.smartdevicelink.transport.BaseTransportConfig; import com.smartdevicelink.transport.MultiplexTransportConfig; import com.smartdevicelink.transport.TCPTransportConfig; import com.smartdevicelink.util.DebugTool; +import com.smartdevicelink.util.SystemInfo; import java.util.ArrayList; import java.util.Arrays; @@ -239,6 +240,12 @@ public class SdlService extends Service { return null; } } + + @Override + public boolean onSystemInfoReceived(SystemInfo systemInfo) { + //Check the SystemInfo object to ensure that the connection to the device should continue + return true; + } }; // Create App Icon, this is set in the SdlManager builder diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/SdlManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/SdlManagerTests.java index c263db59d..ca941fab6 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/SdlManagerTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/SdlManagerTests.java @@ -23,6 +23,7 @@ import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener; import com.smartdevicelink.test.TestValues; import com.smartdevicelink.transport.BaseTransportConfig; import com.smartdevicelink.transport.TCPTransportConfig; +import com.smartdevicelink.util.SystemInfo; import org.junit.Before; import org.junit.Test; @@ -114,6 +115,11 @@ public class SdlManagerTests { public LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language, Language hmiLanguage) { return null; } + + @Override + public boolean onSystemInfoReceived(SystemInfo systemInfo) { + return true; + } }; // build manager object - use all setters, will test using getters below diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockInterfaceBroker.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockInterfaceBroker.java index 364e6c976..57d2fa1b2 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockInterfaceBroker.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockInterfaceBroker.java @@ -3,6 +3,7 @@ package com.smartdevicelink.test.streaming; import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.session.ISdlSessionListener; import com.smartdevicelink.transport.BaseTransportConfig; +import com.smartdevicelink.util.SystemInfo; import com.smartdevicelink.util.Version; /** @@ -24,7 +25,7 @@ public class MockInterfaceBroker implements ISdlSessionListener { } @Override - public void onSessionStarted(int sessionID, Version version) { + public void onSessionStarted(int sessionID, Version version, SystemInfo systemInfo) { } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java index 99af62a74..fe06561ee 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java @@ -34,6 +34,7 @@ package com.smartdevicelink.managers; import com.smartdevicelink.managers.lifecycle.LifecycleConfigurationUpdate; import com.smartdevicelink.proxy.rpc.enums.Language; +import com.smartdevicelink.util.SystemInfo; public interface SdlManagerListener extends BaseSdlManagerListener { @@ -68,4 +69,12 @@ public interface SdlManagerListener extends BaseSdlManagerListener { * otherwise null to indicate that the language is not supported. */ LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language, Language hmiLanguage); + + /** + * A way to determine if this SDL session should continue to be active while + * connected to the determined system information of the vehicle. + * @param systemInfo systemInfo - the system information of the vehicle that this session is currently active on. + * @return Return true if this session should continue, false if the session should end + */ + boolean onSystemInfoReceived(SystemInfo systemInfo); } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/session/SdlSession.java b/android/sdl_android/src/main/java/com/smartdevicelink/session/SdlSession.java index 480f4cdbb..74701c867 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/session/SdlSession.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/session/SdlSession.java @@ -41,12 +41,15 @@ import com.smartdevicelink.protocol.ISdlServiceListener; import com.smartdevicelink.protocol.SdlPacket; import com.smartdevicelink.protocol.SdlProtocol; import com.smartdevicelink.protocol.SdlProtocolBase; +import com.smartdevicelink.protocol.enums.ControlFrameTags; import com.smartdevicelink.protocol.enums.SessionType; +import com.smartdevicelink.proxy.rpc.VehicleType; import com.smartdevicelink.transport.MultiplexTransportConfig; import com.smartdevicelink.transport.TCPTransportConfig; import com.smartdevicelink.transport.enums.TransportType; import com.smartdevicelink.util.DebugTool; import com.smartdevicelink.util.MediaStreamingStatus; +import com.smartdevicelink.util.SystemInfo; import com.smartdevicelink.util.Version; import java.lang.ref.WeakReference; @@ -152,7 +155,11 @@ public class SdlSession extends BaseSdlSession { if (serviceType != null && serviceType.eq(SessionType.RPC) && this.sessionId == -1) { this.sessionId = sessionID; - this.sessionListener.onSessionStarted(sessionID, version); + SystemInfo systemInfo = null; + if (version != null && version.isNewerThan(new Version(5, 4, 0)) >= 0) { + systemInfo = extractSystemInfo(packet); + } + this.sessionListener.onSessionStarted(sessionID, version, systemInfo); } if (isEncrypted) { diff --git a/base/src/main/java/com/smartdevicelink/managers/BaseSdlManager.java b/base/src/main/java/com/smartdevicelink/managers/BaseSdlManager.java index 261525b29..6730ee3eb 100644 --- a/base/src/main/java/com/smartdevicelink/managers/BaseSdlManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/BaseSdlManager.java @@ -63,6 +63,7 @@ import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener; import com.smartdevicelink.security.SdlSecurityBase; import com.smartdevicelink.transport.BaseTransportConfig; import com.smartdevicelink.util.DebugTool; +import com.smartdevicelink.util.SystemInfo; import com.smartdevicelink.util.Version; import org.json.JSONException; @@ -149,6 +150,15 @@ abstract class BaseSdlManager { public void onError(LifecycleManager lifeCycleManager, String info, Exception e) { } + + @Override + public boolean onSystemInfoReceived(SystemInfo systemInfo) { + if (managerListener != null) { + return managerListener.onSystemInfoReceived(systemInfo); + } else { + return true; + } + } }; // Sub manager listener diff --git a/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java b/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java index 619e48081..e3b7a90a2 100644 --- a/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java @@ -87,6 +87,7 @@ import com.smartdevicelink.transport.BaseTransportConfig; import com.smartdevicelink.util.CorrelationIdGenerator; import com.smartdevicelink.util.DebugTool; import com.smartdevicelink.util.FileUtls; +import com.smartdevicelink.util.SystemInfo; import com.smartdevicelink.util.Version; import java.util.HashMap; @@ -128,6 +129,7 @@ abstract class BaseLifecycleManager { final Version minimumRPCVersion; BaseTransportConfig _transportConfig; private Taskmaster taskmaster; + private boolean didCheckSystemInfo = false; BaseLifecycleManager(AppConfig appConfig, BaseTransportConfig config, LifecycleListener listener) { this.appConfig = appConfig; @@ -382,6 +384,23 @@ abstract class BaseLifecycleManager { clean(); return; } + if (!didCheckSystemInfo && lifecycleListener != null) { + didCheckSystemInfo = true; + VehicleType vehicleType = raiResponse.getVehicleType(); + String systemSoftwareVersion = raiResponse.getSystemSoftwareVersion(); + if (vehicleType != null || systemSoftwareVersion != null) { + SystemInfo systemInfo = new SystemInfo(vehicleType, systemSoftwareVersion, null); + boolean validSystemInfo = lifecycleListener.onSystemInfoReceived(systemInfo); + if (!validSystemInfo) { + DebugTool.logWarning(TAG, "Disconnecting from head unit, the system info was not accepted."); + UnregisterAppInterface msg = new UnregisterAppInterface(); + msg.setCorrelationID(UNREGISTER_APP_INTERFACE_CORRELATION_ID); + sendRPCMessagePrivate(msg, true); + clean(); + return; + } + } + } processRaiResponse(raiResponse); systemCapabilityManager.parseRAIResponse(raiResponse); break; @@ -882,7 +901,7 @@ abstract class BaseLifecycleManager { @Override - public void onSessionStarted(int sessionID, Version version) { + public void onSessionStarted(int sessionID, Version version, SystemInfo systemInfo) { DebugTool.logInfo(TAG, "on protocol session started"); if (minimumProtocolVersion != null && minimumProtocolVersion.isNewerThan(version) == 1) { 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())); @@ -890,6 +909,18 @@ abstract class BaseLifecycleManager { clean(); return; } + + if (systemInfo != null && lifecycleListener != null) { + didCheckSystemInfo = true; + boolean validSystemInfo = lifecycleListener.onSystemInfoReceived(systemInfo); + if (!validSystemInfo) { + DebugTool.logWarning(TAG, "Disconnecting from head unit, the system info was not accepted."); + session.endService(SessionType.RPC); + clean(); + return; + } + } + if (appConfig != null) { appConfig.prepare(); @@ -1245,6 +1276,8 @@ abstract class BaseLifecycleManager { void onServiceEnded(SessionType sessionType); void onError(LifecycleManager lifeCycleManager, String info, Exception e); + + boolean onSystemInfoReceived(SystemInfo systemInfo); } public static class AppConfig { diff --git a/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java b/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java index 0b42fcc15..d9e437548 100644 --- a/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java +++ b/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java @@ -85,7 +85,7 @@ public class SdlProtocolBase { public static final int V2_HEADER_SIZE = 12; //If increasing MAX PROTOCOL VERSION major version, make sure to alter it in SdlPsm - private static final Version MAX_PROTOCOL_VERSION = new Version(5, 3, 0); + private static final Version MAX_PROTOCOL_VERSION = new Version(5, 4, 0); public static final int V1_V2_MTU_SIZE = 1500; public static final int V3_V4_MTU_SIZE = 131072; diff --git a/base/src/main/java/com/smartdevicelink/protocol/enums/ControlFrameTags.java b/base/src/main/java/com/smartdevicelink/protocol/enums/ControlFrameTags.java index 992dccfb3..a6656fa09 100644 --- a/base/src/main/java/com/smartdevicelink/protocol/enums/ControlFrameTags.java +++ b/base/src/main/java/com/smartdevicelink/protocol/enums/ControlFrameTags.java @@ -85,6 +85,19 @@ public class ControlFrameTags { * Auth token to be used for log in into services **/ public static final String AUTH_TOKEN = "authToken"; + /** + * Vehicle info to describe connected device + */ + public static final String MAKE = "make"; + public static final String MODEL = "model"; + public static final String MODEL_YEAR = "modelYear"; + public static final String TRIM = "trim"; + + /** + * System specifics for hardware and software versions of connected device + */ + public static final String SYSTEM_SOFTWARE_VERSION = "systemSoftwareVersion"; + public static final String SYSTEM_HARDWARE_VERSION = "systemHardwareVersion"; } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/RegisterAppInterfaceResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/RegisterAppInterfaceResponse.java index c18cbd38b..d4ae5a706 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/RegisterAppInterfaceResponse.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/RegisterAppInterfaceResponse.java @@ -53,6 +53,7 @@ import java.util.List; * @since SmartDeviceLink 1.0
*/
public class RegisterAppInterfaceResponse extends RPCResponse {
+ @Deprecated
public static final String KEY_VEHICLE_TYPE = "vehicleType";
public static final String KEY_SPEECH_CAPABILITIES = "speechCapabilities";
public static final String KEY_VR_CAPABILITIES = "vrCapabilities";
@@ -73,6 +74,7 @@ public class RegisterAppInterfaceResponse extends RPCResponse { public static final String KEY_PRESET_BANK_CAPABILITIES = "presetBankCapabilities";
public static final String KEY_HMI_CAPABILITIES = "hmiCapabilities"; //As of v4.0
public static final String KEY_SDL_VERSION = "sdlVersion"; //As of v4.0
+ @Deprecated
public static final String KEY_SYSTEM_SOFTWARE_VERSION = "systemSoftwareVersion"; //As of v4.0
public static final String KEY_ICON_RESUMED = "iconResumed";
public static final String KEY_PCM_STREAM_CAPABILITIES = "pcmStreamCapabilities";
@@ -382,18 +384,20 @@ public class RegisterAppInterfaceResponse extends RPCResponse { /**
* Gets getVehicleType set when application interface is registered.
- *
+ * @deprecated in SmartDeviceLink 7.1.0
* @return vehicleType
*/
+ @Deprecated
public VehicleType getVehicleType() {
return (VehicleType) getObject(VehicleType.class, KEY_VEHICLE_TYPE);
}
/**
* Sets vehicleType
- *
+ * @deprecated in SmartDeviceLink 7.1.0
* @param vehicleType
*/
+ @Deprecated
public RegisterAppInterfaceResponse setVehicleType(VehicleType vehicleType) {
setParameters(KEY_VEHICLE_TYPE, vehicleType);
return this;
@@ -466,11 +470,24 @@ public class RegisterAppInterfaceResponse extends RPCResponse { return getString(KEY_SDL_VERSION);
}
+ /**
+ * The software version of the connected device.
+ * @param systemSoftwareVersion the version of software on the connected device
+ * @return RegisterAppInterface
+ * @deprecated in SmartDeviceLink 7.1.0
+ */
+ @Deprecated
public RegisterAppInterfaceResponse setSystemSoftwareVersion(String systemSoftwareVersion) {
setParameters(KEY_SYSTEM_SOFTWARE_VERSION, systemSoftwareVersion);
return this;
}
+ /**
+ * The software version of the connected device.
+ * @return String the version of software on the connected device
+ * @deprecated in SmartDeviceLink 7.1.0
+ */
+ @Deprecated
public String getSystemSoftwareVersion() {
return getString(KEY_SYSTEM_SOFTWARE_VERSION);
}
diff --git a/base/src/main/java/com/smartdevicelink/session/BaseSdlSession.java b/base/src/main/java/com/smartdevicelink/session/BaseSdlSession.java index ed4957b78..8b35541b4 100644 --- a/base/src/main/java/com/smartdevicelink/session/BaseSdlSession.java +++ b/base/src/main/java/com/smartdevicelink/session/BaseSdlSession.java @@ -41,8 +41,10 @@ import com.smartdevicelink.protocol.ISdlServiceListener; import com.smartdevicelink.protocol.ProtocolMessage; import com.smartdevicelink.protocol.SdlPacket; import com.smartdevicelink.protocol.SdlProtocolBase; +import com.smartdevicelink.protocol.enums.ControlFrameTags; import com.smartdevicelink.protocol.enums.SessionType; import com.smartdevicelink.proxy.RPCMessage; +import com.smartdevicelink.proxy.rpc.VehicleType; import com.smartdevicelink.proxy.rpc.VideoStreamingFormat; import com.smartdevicelink.proxy.rpc.enums.VideoStreamingProtocol; import com.smartdevicelink.security.ISecurityInitializedListener; @@ -51,6 +53,7 @@ import com.smartdevicelink.streaming.video.VideoStreamingParameters; import com.smartdevicelink.transport.BaseTransportConfig; import com.smartdevicelink.transport.enums.TransportType; import com.smartdevicelink.util.DebugTool; +import com.smartdevicelink.util.SystemInfo; import com.smartdevicelink.util.Version; import java.util.HashMap; @@ -209,6 +212,38 @@ public abstract class BaseSdlSession implements ISdlProtocol, ISecurityInitializ sendMessage(protocolMessage); } + /** + * Extracts the SystemInfo out of a packet + * @param packet should be a StartServiceACK for the RPC service + * @return an instance of SystemInfo if the information is available, null otherwise + */ + protected SystemInfo extractSystemInfo(SdlPacket packet) { + SystemInfo systemInfo = null; + if (packet != null && packet.getFrameInfo() == SdlPacket.FRAME_INFO_START_SERVICE_ACK) { + VehicleType vehicleType = null; + + String make = (String) packet.getTag(ControlFrameTags.RPC.StartServiceACK.MAKE); + String model = (String) packet.getTag(ControlFrameTags.RPC.StartServiceACK.MODEL); + String modelYear = (String) packet.getTag(ControlFrameTags.RPC.StartServiceACK.MODEL_YEAR); + String trim = (String) packet.getTag(ControlFrameTags.RPC.StartServiceACK.TRIM); + String softwareVersion = (String) packet.getTag(ControlFrameTags.RPC.StartServiceACK.SYSTEM_SOFTWARE_VERSION); + String hardwareVersion = (String) packet.getTag(ControlFrameTags.RPC.StartServiceACK.SYSTEM_HARDWARE_VERSION); + + if (make != null || model != null || modelYear != null || trim != null) { + vehicleType = new VehicleType() + .setMake(make) + .setModel(model) + .setModelYear(modelYear) + .setTrim(trim); + } + + if (vehicleType != null || softwareVersion != null || hardwareVersion != null) { + systemInfo = new SystemInfo(vehicleType, softwareVersion, hardwareVersion); + } + } + + return systemInfo; + } public boolean isServiceProtected(SessionType sType) { return encryptedServices.contains(sType); diff --git a/base/src/main/java/com/smartdevicelink/session/ISdlSessionListener.java b/base/src/main/java/com/smartdevicelink/session/ISdlSessionListener.java index 180452997..2f754a30e 100644 --- a/base/src/main/java/com/smartdevicelink/session/ISdlSessionListener.java +++ b/base/src/main/java/com/smartdevicelink/session/ISdlSessionListener.java @@ -35,6 +35,7 @@ import androidx.annotation.RestrictTo; import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.transport.BaseTransportConfig; +import com.smartdevicelink.util.SystemInfo; import com.smartdevicelink.util.Version; @RestrictTo(RestrictTo.Scope.LIBRARY) @@ -63,8 +64,9 @@ public interface ISdlSessionListener { * * @param sessionID session ID associated with the session that was established * @param version the protocol version that has been negotiated for this session + * @param systemInfo info about the device that this service is started */ - void onSessionStarted(int sessionID, Version version); + void onSessionStarted(int sessionID, Version version, SystemInfo systemInfo); /** * Called to indicate that the session that was previously established has now ended. This means diff --git a/base/src/main/java/com/smartdevicelink/util/SystemInfo.java b/base/src/main/java/com/smartdevicelink/util/SystemInfo.java new file mode 100644 index 000000000..e622be04d --- /dev/null +++ b/base/src/main/java/com/smartdevicelink/util/SystemInfo.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2021 Livio, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Livio Inc. nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +package com.smartdevicelink.util; + +import androidx.annotation.Nullable; + +import com.smartdevicelink.proxy.rpc.VehicleType; + +public class SystemInfo { + + @Nullable + private VehicleType vehicleType; + @Nullable + private String systemSoftwareVersion; + @Nullable + private String systemHardwareVersion; + + public SystemInfo(@Nullable VehicleType vehicleType, @Nullable String systemSoftwareVersion, @Nullable String systemHardwareVersion) { + this.vehicleType = vehicleType; + this.systemSoftwareVersion = systemSoftwareVersion; + this.systemHardwareVersion = systemHardwareVersion; + } + + @Nullable + public VehicleType getVehicleType() { + return vehicleType; + } + + @Nullable + public String getSystemSoftwareVersion() { + return systemSoftwareVersion; + } + + @Nullable + public String getSystemHardwareVersion() { + return systemHardwareVersion; + } +} diff --git a/javaEE/hello_sdl_java_ee/src/main/java/com/smartdevicelink/SdlService.java b/javaEE/hello_sdl_java_ee/src/main/java/com/smartdevicelink/SdlService.java index 87bbf4c67..3e1b5ba0a 100644 --- a/javaEE/hello_sdl_java_ee/src/main/java/com/smartdevicelink/SdlService.java +++ b/javaEE/hello_sdl_java_ee/src/main/java/com/smartdevicelink/SdlService.java @@ -55,6 +55,8 @@ import com.smartdevicelink.proxy.rpc.enums.*; import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener; import com.smartdevicelink.transport.BaseTransportConfig; import com.smartdevicelink.util.DebugTool; +import com.smartdevicelink.util.SystemInfo; + import java.util.*; @@ -154,6 +156,12 @@ public class SdlService { return new LifecycleConfigurationUpdate(appName, null, TTSChunkFactory.createSimpleTTSChunks(appName), null); } + + @Override + public boolean onSystemInfoReceived(SystemInfo systemInfo) { + //Check the SystemInfo object to ensure that the connection to the device should continue + return true; + } }; diff --git a/javaSE/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java b/javaSE/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java index 176d6010e..d4eef253b 100644 --- a/javaSE/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java +++ b/javaSE/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java @@ -52,6 +52,7 @@ import com.smartdevicelink.proxy.rpc.enums.*; import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener; import com.smartdevicelink.transport.BaseTransportConfig; import com.smartdevicelink.util.DebugTool; +import com.smartdevicelink.util.SystemInfo; import java.util.*; @@ -170,6 +171,12 @@ public class SdlService { return null; } } + + @Override + public boolean onSystemInfoReceived(SystemInfo systemInfo) { + //Check the SystemInfo object to ensure that the connection to the device should continue + return true; + } }; diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java index cf3e7d04c..fbe236f08 100644 --- a/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/managers/SdlManagerListener.java @@ -33,6 +33,7 @@ package com.smartdevicelink.managers; import com.smartdevicelink.managers.lifecycle.LifecycleConfigurationUpdate; import com.smartdevicelink.proxy.rpc.enums.Language; +import com.smartdevicelink.util.SystemInfo; public interface SdlManagerListener extends BaseSdlManagerListener { @@ -67,4 +68,12 @@ public interface SdlManagerListener extends BaseSdlManagerListener { * otherwise null to indicate that the language is not supported. */ LifecycleConfigurationUpdate managerShouldUpdateLifecycle(Language language, Language hmiLanguage); + + /** + * A way to determine if this SDL session should continue to be active while + * connected to the determined system information of the vehicle. + * @param systemInfo systemInfo - the system information of the vehicle that this session is currently active on. + * @return Return true if this session should continue, false if the session should end + */ + boolean onSystemInfoReceived(SystemInfo systemInfo); } diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/session/SdlSession.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/session/SdlSession.java index 3fa84ed27..91df403f9 100644 --- a/javaSE/javaSE/src/main/java/com/smartdevicelink/session/SdlSession.java +++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/session/SdlSession.java @@ -42,6 +42,7 @@ import com.smartdevicelink.protocol.SdlProtocolBase; import com.smartdevicelink.protocol.enums.SessionType; import com.smartdevicelink.transport.BaseTransportConfig; import com.smartdevicelink.util.DebugTool; +import com.smartdevicelink.util.SystemInfo; import com.smartdevicelink.util.Version; import java.util.concurrent.CopyOnWriteArrayList; @@ -67,7 +68,11 @@ public class SdlSession extends BaseSdlSession { if (serviceType != null && serviceType.eq(SessionType.RPC) && this.sessionId == -1) { this.sessionId = sessionID; - this.sessionListener.onSessionStarted(sessionID, version); + SystemInfo systemInfo = null; + if (version != null && version.isNewerThan(new Version(5, 4, 0)) >= 0) { + systemInfo = extractSystemInfo(packet); + } + this.sessionListener.onSessionStarted(sessionID, version, systemInfo); } if (isEncrypted) { @@ -109,4 +114,4 @@ public class SdlSession extends BaseSdlSession { } } -}
\ No newline at end of file +} |