summaryrefslogtreecommitdiff
path: root/src/components/application_manager
diff options
context:
space:
mode:
authorJackLivio <jack@livio.io>2018-08-15 11:33:26 -0400
committerJackLivio <jack@livio.io>2018-08-15 11:33:26 -0400
commit9c18b2f1bb5194f0f1c8d1b1e34aa8db69f2d186 (patch)
tree24c3092b302dbe600f2963013f7611287ab6249f /src/components/application_manager
parent26bc93ce70dfad33d8e367e4fddcea1c0c0d34fd (diff)
parent406f491b7db0123351e3851d130bb334cf275023 (diff)
downloadsdl_core-9c18b2f1bb5194f0f1c8d1b1e34aa8db69f2d186.tar.gz
Merge remote-tracking branch 'origin/develop' into feature/choice_vr_optionalfeature/choice_vr_optional
Diffstat (limited to 'src/components/application_manager')
-rw-r--r--src/components/application_manager/include/application_manager/rpc_handler_impl.h10
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc6
-rw-r--r--src/components/application_manager/src/rpc_handler_impl.cc42
3 files changed, 46 insertions, 12 deletions
diff --git a/src/components/application_manager/include/application_manager/rpc_handler_impl.h b/src/components/application_manager/include/application_manager/rpc_handler_impl.h
index 7f61c7b034..8f1d454c3b 100644
--- a/src/components/application_manager/include/application_manager/rpc_handler_impl.h
+++ b/src/components/application_manager/include/application_manager/rpc_handler_impl.h
@@ -143,6 +143,16 @@ class RPCHandlerImpl : public RPCHandler,
void SetTelemetryObserver(AMTelemetryObserver* observer) OVERRIDE;
#endif // TELEMETRY_MONITOR
+ /**
+ * @brief Extracts and validates the syncMsgVersion included in
+ * a RegisterAppInterfaceRequest
+ *
+ * @param output - SmartObject Message received from mobile
+ * @param messageVersion - message version to be updated
+ */
+ void GetMessageVersion(NsSmartDeviceLink::NsSmartObjects::SmartObject& output,
+ utils::SemanticVersion& message_version);
+
private:
void ProcessMessageFromMobile(const std::shared_ptr<Message> message);
void ProcessMessageFromHMI(const std::shared_ptr<Message> message);
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
index 4284b97786..164c854f18 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
@@ -621,11 +621,11 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
utils::SemanticVersion negotiated_version = application->msg_version();
response_params[strings::sync_msg_version][strings::major_version] =
- negotiated_version.major_version;
+ negotiated_version.major_version_;
response_params[strings::sync_msg_version][strings::minor_version] =
- negotiated_version.minor_version;
+ negotiated_version.minor_version_;
response_params[strings::sync_msg_version][strings::patch_version] =
- negotiated_version.patch_version;
+ negotiated_version.patch_version_;
const smart_objects::SmartObject& msg_params =
(*message_)[strings::msg_params];
diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc
index 37319738f9..bf1ff78d36 100644
--- a/src/components/application_manager/src/rpc_handler_impl.cc
+++ b/src/components/application_manager/src/rpc_handler_impl.cc
@@ -194,6 +194,36 @@ void RPCHandlerImpl::SetTelemetryObserver(AMTelemetryObserver* observer) {
#endif // TELEMETRY_MONITOR
+void RPCHandlerImpl::GetMessageVersion(
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& output,
+ utils::SemanticVersion& message_version) {
+ if (output.keyExists(
+ NsSmartDeviceLink::NsJSONHandler::strings::S_MSG_PARAMS) &&
+ output[NsSmartDeviceLink::NsJSONHandler::strings::S_MSG_PARAMS].keyExists(
+ strings::sync_msg_version)) {
+ // SyncMsgVersion exists, check if it is valid.
+ auto sync_msg_version =
+ output[NsSmartDeviceLink::NsJSONHandler::strings::S_MSG_PARAMS]
+ [strings::sync_msg_version];
+ uint16_t major = 0;
+ uint16_t minor = 0;
+ uint16_t patch = 0;
+ if (sync_msg_version.keyExists(strings::major_version)) {
+ major = sync_msg_version[strings::major_version].asUInt();
+ }
+ if (sync_msg_version.keyExists(strings::minor_version)) {
+ minor = sync_msg_version[strings::minor_version].asUInt();
+ }
+ if (sync_msg_version.keyExists(strings::patch_version)) {
+ patch = sync_msg_version[strings::patch_version].asUInt();
+ }
+ utils::SemanticVersion temp_version(major, minor, patch);
+ if (temp_version.isValid()) {
+ message_version = temp_version;
+ }
+ }
+}
+
bool RPCHandlerImpl::ConvertMessageToSO(
const Message& message,
NsSmartDeviceLink::NsSmartObjects::SmartObject& output) {
@@ -220,26 +250,20 @@ bool RPCHandlerImpl::ConvertMessageToSO(
// Attach RPC version to SmartObject if it does not exist yet.
auto app_ptr = app_manager_.application(message.connection_key());
- utils::SemanticVersion msg_version(2, 0, 0);
+ utils::SemanticVersion msg_version(0, 0, 0);
if (app_ptr &&
(output[NsSmartDeviceLink::NsJSONHandler::strings::S_PARAMS]
.keyExists(NsSmartDeviceLink::NsJSONHandler::strings::
S_RPC_MSG_VERSION) == false)) {
msg_version = app_ptr->msg_version();
- output[NsSmartDeviceLink::NsJSONHandler::strings::S_PARAMS]
- [NsSmartDeviceLink::NsJSONHandler::strings::S_RPC_MSG_VERSION] =
- msg_version.toString();
} else if (mobile_apis::FunctionID::RegisterAppInterfaceID ==
static_cast<mobile_apis::FunctionID::eType>(
output[strings::params][strings::function_id].asInt())) {
- // Assume default version 1.0.0 until properly set in RAI
- output[NsSmartDeviceLink::NsJSONHandler::strings::S_PARAMS]
- [NsSmartDeviceLink::NsJSONHandler::strings::S_RPC_MSG_VERSION] =
- msg_version.toString();
+ GetMessageVersion(output, msg_version);
}
if (!conversion_result ||
- !mobile_so_factory().attachSchema(output, true) ||
+ !mobile_so_factory().attachSchema(output, true, msg_version) ||
((output.validate(&report, msg_version) !=
smart_objects::Errors::OK))) {
LOG4CXX_WARN(logger_,