-
Notifications
You must be signed in to change notification settings - Fork 12
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
[SDL-0293] Enable OEM exclusive apps support #374
Changes from 4 commits
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 |
---|---|---|
|
@@ -38,14 +38,14 @@ import { _FrameType } from './enums/_FrameType.js'; | |
import { _MessageFrameAssembler } from './_MessageFrameAssembler.js'; | ||
import { _SdlPacket } from './_SdlPacket.js'; | ||
import { _ControlFrameTags } from './enums/_ControlFrameTags.js'; | ||
import { _BitConverter } from './../util/_BitConverter.js'; | ||
import { _BitConverter } from '../util/_BitConverter.js'; | ||
|
||
import { _SdlPacketFactory } from './_SdlPacketFactory.js'; | ||
import { RpcCreator } from './../rpc/RpcCreator.js'; | ||
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'; | ||
import { VehicleType } from '../rpc/structs/VehicleType.js'; | ||
|
||
/** | ||
* Base implementation of sdl protocol. | ||
|
@@ -272,32 +272,29 @@ class _SdlProtocolBase { | |
|
||
/** | ||
* Gets the Vehicle details received in StartService ACK protocol message | ||
* @returns {Number} - A new numeric message ID. | ||
* @returns {VehicleType|null} - A RPC VehicleType struct received from the packet if exists null otherwise. | ||
*/ | ||
_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({ | ||
// TODO: awaiting 0293 revisions to process those fields | ||
const systemHardwareVersion = sdlPacket.getTag(_ControlFrameTags.RPC.StartServiceACK.VEHICLE_SYSTEM_HARDWARE_VERSION); | ||
const systemSoftwareVersion = sdlPacket.getTag(_ControlFrameTags.RPC.StartServiceACK.VEHICLE_SYSTEM_SOFTWARE_VERSION); | ||
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. This method seems unfinished since these values are never used. 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. @renonick87 no, the method is finished and reflects the current state of the proposal. Without revisions, we receive those fields here but never use or process them. The TODO was added to reflect that the processing needs to be added after accepting the revisions. |
||
|
||
// if no any VehicleType tags in the packet just return null | ||
if (!make && !model && !modelYear && !trim) { | ||
return null; | ||
} | ||
|
||
return 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, | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -438,15 +435,15 @@ 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); | ||
// check if vehicleType data exists then fire onVehicleTypeReceived protocol listener event | ||
const vehicleType = this._getVehicleType(sdlPacket); | ||
if ( | ||
vehicleTypeFromPacket | ||
vehicleType | ||
&& 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)'); | ||
if (!this._sdlProtocolListener.onVehicleTypeReceived(vehicleType)) { | ||
console.warn('(ACK) Disconnecting from head unit, the vehicle is not supported'); | ||
this.endService(serviceType, sdlPacket.getSessionID()); | ||
if (serviceType === _ServiceType.RPC && this._transportManager !== null) { | ||
this._transportManager.stop(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ class _SdlSession { | |
this._sdlProtocolListener = this._setupSdlProtocolListener(); | ||
|
||
this._sdlProtocol = new _SdlProtocol(baseTransportConfig, this._sdlProtocolListener); | ||
this._didReceiveVehicleType = false; | ||
} | ||
|
||
/** | ||
|
@@ -169,16 +170,24 @@ class _SdlSession { | |
this._sdlSessionListener.onAuthTokenReceived(authToken, this._sessionId); | ||
} | ||
|
||
/** | ||
* A way to determine if VehicleType already received | ||
* @returns {Boolean} Return true if received | ||
*/ | ||
didReceiveVehicleType() { | ||
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. There needs to be a space before the function parentheses on line 177. Use the command 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. Fixed |
||
return this._didReceiveVehicleType; | ||
} | ||
|
||
/** | ||
* 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); | ||
onVehicleTypeReceived (vehicleType) { | ||
// set the flag as this event fires only once if VehicleType was received | ||
this._didReceiveVehicleType = true; | ||
return this._sdlSessionListener.onVehicleTypeReceived(vehicleType); | ||
} | ||
|
||
/** ********************************************************************************************************************************************************************** | ||
|
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 @vladmu Do you need unit tests for this? For example, sdl java suite has
SdlProtocolTests
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 we don't need the test for this particular line as this is just a shortenest path identical to previous but aligned with the style of other imports.
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.
@vladmu I meant do you need unit tests overall for the changes made to this file?
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 it is hard to define expectations of such tests in the order of the library and this class as we don't have any tests of previous functionality covered here. We appreciate any help in this case.
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.
@vladmu Ok no problem. It was an optional request, as these were not existing before.