-
Notifications
You must be signed in to change notification settings - Fork 12
[SDL-0293] Enable OEM exclusive apps support #374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
0496013
c0f1b38
0497c80
a2d7ab1
af981f8
8f4069d
f855ca4
76c5350
cccb753
8317fb6
59ac61a
b874414
a0a9ed0
66edef5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,8 @@ import { RpcCreator } from './../rpc/RpcCreator.js'; | |
| import { ImageResolution } from '../rpc/structs/ImageResolution.js'; | ||
| import { VideoStreamingFormat } from '../rpc/structs/VideoStreamingFormat.js'; | ||
|
|
||
| import { VehicleType } from './../rpc/structs/VehicleType.js'; | ||
|
|
||
| /** | ||
| * Base implementation of sdl protocol. | ||
| * Should be able to handle basic control frames and be able to | ||
|
|
@@ -268,6 +270,36 @@ class _SdlProtocolBase { | |
| return this._messageID++; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the Vehicle details received in StartService ACK protocol message | ||
| * @returns {Number} - A new numeric message ID. | ||
| */ | ||
| _getVehicleType(sdlPacket) { | ||
| const make = sdlPacket.getTag(_ControlFrameTags.RPC.StartServiceACK.VEHICLE_MAKE); | ||
| if (!make) { | ||
| return null; | ||
| } | ||
| const model = sdlPacket.getTag(_ControlFrameTags.RPC.StartServiceACK.VEHICLE_MODEL); | ||
| const modelYear = sdlPacket.getTag(_ControlFrameTags.RPC.StartServiceACK.VEHICLE_MODEL_YEAR); | ||
| const trim = sdlPacket.getTag(_ControlFrameTags.RPC.StartServiceACK.VEHICLE_TRIM); | ||
|
|
||
| const vehicleType = new VehicleType({ | ||
| make, | ||
| model, | ||
| modelYear, | ||
| trim, | ||
| }); | ||
|
|
||
| const systemHardwareVersion = sdlPacket.getTag(_ControlFrameTags.RPC.StartServiceACK.VEHICLE_SYSTEM_HARDWARE_VERSION); | ||
| const systemSoftwareVersion = sdlPacket.getTag(_ControlFrameTags.RPC.StartServiceACK.VEHICLE_SYSTEM_SOFTWARE_VERSION); | ||
|
|
||
| return { | ||
| vehicleType, | ||
| systemHardwareVersion, | ||
| systemSoftwareVersion, | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Takes an rpc message and sends a single or multi frame packets. | ||
| * @param {RpcMessage} rpcMessage - Converts an RpcMessage into an _SdlPacket and sends it. | ||
|
|
@@ -406,6 +438,23 @@ class _SdlProtocolBase { | |
| const version = sdlPacket.getVersion(); | ||
| const serviceType = sdlPacket.getServiceType(); | ||
| if (version >= 5) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ymalovanyi On line 440, does this need to be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Our initial implementation was exactly with |
||
| const vehicleTypeFromPacket = this._getVehicleType(sdlPacket); | ||
| if ( | ||
| vehicleTypeFromPacket | ||
| && this._sdlProtocolListener !== null | ||
| && typeof this._sdlProtocolListener.onVehicleTypeReceived === 'function' | ||
| ) { | ||
| const {vehicleType, systemSoftwareVersion, systemHardwareVersion } = vehicleTypeFromPacket; | ||
| if (!this._sdlProtocolListener.onVehicleTypeReceived(vehicleType, systemSoftwareVersion, systemHardwareVersion)) { | ||
| console.warn('Disconnecting from head unit, the vehicle is not supported (ACK)'); | ||
| this.endService(serviceType, sdlPacket.getSessionID()); | ||
| if (serviceType === _ServiceType.RPC && this._transportManager !== null) { | ||
| this._transportManager.stop(); | ||
| } | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| let mtuTag = null; | ||
| if (serviceType === _ServiceType.RPC) { | ||
| mtuTag = _ControlFrameTags.RPC.StartServiceACK.MTU; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,6 +57,7 @@ class _SdlProtocolListener { | |
| this._onProtocolSessionEnded = null; | ||
| this._onProtocolSessionEndedNACKed = null; | ||
| this._onAuthTokenReceived = null; | ||
| this._onVehicleTypeReceived = null; | ||
| this._getSessionId = null; | ||
| this._onTransportConnected = null; | ||
| } | ||
|
|
@@ -189,6 +190,30 @@ class _SdlProtocolListener { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Set the OnVehicleTypeReceived function callback. | ||
| * @param {function} listener - A function to be invoked when the event occurs. | ||
| * @returns {_SdlProtocolListener} - A reference to this instance to support method chaining. | ||
| */ | ||
| setOnVehicleTypeReceived (listener) { | ||
| this._onVehicleTypeReceived = listener; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Safely attempts to invoke the onVehicleTypeReceived event. | ||
| * @param {VehicleType} vehicleType - the type of vehicle that this session is currently active on. | ||
| * @param {String} systemSoftwareVersion - software version of the system. | ||
| * @param {String} systemHardwareVersion - hardware version of the system. | ||
| * @returns {Boolean} Return true if this session should continue, false if the session should end | ||
| */ | ||
| onVehicleTypeReceived (vehicleType, systemSoftwareVersion, systemHardwareVersion) { | ||
|
||
| if (typeof this._onVehicleTypeReceived === 'function') { | ||
| return !!this._onVehicleTypeReceived(vehicleType, systemSoftwareVersion, systemHardwareVersion); | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| /** | ||
| * Set the GetSessionId function. | ||
| * @param {function} getter - A function to be invoked to retrieve the session ID. | ||
|
|
@@ -254,4 +279,4 @@ class _SdlProtocolListener { | |
| } | ||
| } | ||
|
|
||
| export { _SdlProtocolListener }; | ||
| export { _SdlProtocolListener }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,6 +72,12 @@ _ControlFrameTags.RPC = Object.freeze({ | |
| VIDEO_SERVICE_TRANSPORTS: 'videoServiceTransports', | ||
| /** Auth token to be used for log in into services **/ | ||
| AUTH_TOKEN: 'authToken', | ||
| VEHICLE_MAKE: 'make', | ||
| VEHICLE_MODEL: 'model', | ||
| VEHICLE_MODEL_YEAR: 'modelYear', | ||
|
||
| VEHICLE_TRIM: 'trim', | ||
| VEHICLE_SYSTEM_SOFTWARE_VERSION: 'systemSoftwareVersion', | ||
| VEHICLE_SYSTEM_HARDWARE_VERSION: 'systemHardwareVersion', | ||
| }, StartServiceACKBase, StartServiceProtocolVersion, StartServiceHashId), | ||
|
|
||
| StartServiceNAK: NAKBase, | ||
|
|
@@ -128,4 +134,4 @@ _ControlFrameTags.Video = Object.freeze({ | |
| EndServiceNAK: NAKBase, | ||
| }); | ||
|
|
||
| export { _ControlFrameTags }; | ||
| export { _ControlFrameTags }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| /* eslint-disable camelcase */ | ||
| /* | ||
| * Copyright (c) 2020, SmartDeviceLink Consortium, Inc. | ||
| * Copyright (c) 2021, SmartDeviceLink Consortium, Inc. | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
|
|
@@ -431,6 +431,26 @@ class RegisterAppInterfaceResponse extends RpcResponse { | |
| return this.getParameter(RegisterAppInterfaceResponse.KEY_SYSTEM_SOFTWARE_VERSION); | ||
| } | ||
|
|
||
| /** | ||
| * Set the SystemHardwareVersion | ||
| * @since SmartDeviceLink 7.1.0 | ||
| * @param {String} version - The hardware version of the system - The desired SystemHardwareVersion. | ||
| * {'string_min_length': 1, 'string_max_length': 500} | ||
|
||
| * @returns {RegisterAppInterfaceResponse} - The class instance for method chaining. | ||
| */ | ||
| setSystemHardwareVersion (version) { | ||
| this.setParameter(RegisterAppInterfaceResponse.KEY_SYSTEM_HARDWARE_VERSION, version); | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Get the SystemHardwareVersion | ||
| * @returns {String} - the KEY_SYSTEM_HARDWARE_VERSION value | ||
| */ | ||
| getSystemHardwareVersion () { | ||
| return this.getParameter(RegisterAppInterfaceResponse.KEY_SYSTEM_HARDWARE_VERSION); | ||
| } | ||
|
|
||
| /** | ||
| * Set the IconResumed | ||
| * @since SmartDeviceLink 5.0.0 | ||
|
|
@@ -469,6 +489,7 @@ RegisterAppInterfaceResponse.KEY_SUPPORTED_DIAG_MODES = 'supportedDiagModes'; | |
| RegisterAppInterfaceResponse.KEY_HMI_CAPABILITIES = 'hmiCapabilities'; | ||
| RegisterAppInterfaceResponse.KEY_SDL_VERSION = 'sdlVersion'; | ||
| RegisterAppInterfaceResponse.KEY_SYSTEM_SOFTWARE_VERSION = 'systemSoftwareVersion'; | ||
| RegisterAppInterfaceResponse.KEY_SYSTEM_HARDWARE_VERSION = 'systemHardwareVersion'; | ||
| RegisterAppInterfaceResponse.KEY_ICON_RESUMED = 'iconResumed'; | ||
|
|
||
| export { RegisterAppInterfaceResponse }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,6 +77,7 @@ class _SdlSession { | |
| sdlProtocolListener.setOnRpcMessageReceived(this.onRpcMessageReceived.bind(this)); | ||
| sdlProtocolListener.setOnTransportConnected(this.onTransportConnected.bind(this)); | ||
| sdlProtocolListener.setOnAuthTokenReceived(this.onAuthTokenReceived.bind(this)); | ||
| sdlProtocolListener.setOnVehicleTypeReceived(this.onVehicleTypeReceived.bind(this)); | ||
|
|
||
| sdlProtocolListener.setGetDesiredVideoParams(this.getDesiredVideoParams.bind(this)); | ||
| sdlProtocolListener.setSetAcceptedVideoParams(this.setAcceptedVideoParams.bind(this)); | ||
|
|
@@ -168,6 +169,17 @@ class _SdlSession { | |
| this._sdlSessionListener.onAuthTokenReceived(authToken, this._sessionId); | ||
| } | ||
|
|
||
| /** | ||
| * A way to determine if this SDL session should continue to be active while | ||
| * connected to the determined vehicle type. | ||
| * @param {VehicleType} vehicleType - the type of vehicle that this session is currently active on. | ||
| * @param {String} systemSoftwareVersion - software version of the system. | ||
| * @param {String} systemHardwareVersion - hardware version of the system. | ||
| * @returns {Boolean} Return true if this session should continue, false if the session should end | ||
| */ | ||
| onVehicleTypeReceived (vehicleType, systemSoftwareVersion, systemHardwareVersion) { | ||
|
||
| return this._sdlSessionListener.onVehicleTypeReceived(vehicleType, systemSoftwareVersion, systemHardwareVersion); | ||
| } | ||
|
|
||
| /** ********************************************************************************************************************************************************************** | ||
| * END: _SdlProtocolListener implemented methods | ||
|
|
@@ -324,4 +336,4 @@ class _SdlSession { | |
| } | ||
| } | ||
|
|
||
| export { _SdlSession }; | ||
| export { _SdlSession }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ymalovanyi Do the unit tests in
LifecycleManagerTests.jsneed to be updated?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@santhanamk Added tests for new methods.