diff options
author | Ira Lytvynenko <ILytvynenko@luxoft.com> | 2018-01-26 13:29:38 +0200 |
---|---|---|
committer | Ira Lytvynenko (GitHub) <ILytvynenko@luxoft.com> | 2018-06-26 12:01:42 +0300 |
commit | f83d4759add793398b24cca0ae1dd157d03f648c (patch) | |
tree | 6b949862b639f0ab1cb536109377ae77f62177ba /src/components/application_manager/src | |
parent | a79341d7a35b7d97e239d4908a34b72978d5a821 (diff) | |
download | sdl_core-f83d4759add793398b24cca0ae1dd157d03f648c.tar.gz |
RPCService implementation
Fix commands UTs
Diffstat (limited to 'src/components/application_manager/src')
75 files changed, 861 insertions, 643 deletions
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 3f0bc20873..e68e2e4b62 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -43,6 +43,7 @@ #include "application_manager/commands/command_impl.h" #include "application_manager/commands/command_notification_impl.h" #include "application_manager/message_helper.h" +#include "application_manager/rpc_service_impl.h" #include "application_manager/mobile_message_handler.h" #include "application_manager/policies/policy_handler.h" #include "application_manager/hmi_capabilities_impl.h" @@ -158,9 +159,7 @@ ApplicationManagerImpl::ApplicationManagerImpl( , hmi_so_factory_(NULL) , mobile_so_factory_(NULL) , messages_from_mobile_("AM FromMobile", this) - , messages_to_mobile_("AM ToMobile", this) , messages_from_hmi_("AM FromHMI", this) - , messages_to_hmi_("AM ToHMI", this) , audio_pass_thru_messages_("AudioPassThru", this) , hmi_capabilities_(new HMICapabilitiesImpl(*this)) , unregister_reason_( @@ -490,7 +489,7 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( mobile_apis::FunctionID::RegisterAppInterfaceID, message[strings::params][strings::correlation_id].asUInt(), mobile_apis::Result::GENERIC_ERROR)); - ManageMobileCommand(response, commands::Command::ORIGIN_SDL); + rpc_service_->ManageMobileCommand(response, commands::Command::ORIGIN_SDL); return ApplicationSharedPtr(); } @@ -522,7 +521,7 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( mobile_apis::FunctionID::RegisterAppInterfaceID, message[strings::params][strings::correlation_id].asUInt(), mobile_apis::Result::DISALLOWED)); - ManageMobileCommand(response, commands::Command::ORIGIN_SDL); + rpc_service_->ManageMobileCommand(response, commands::Command::ORIGIN_SDL); return ApplicationSharedPtr(); } @@ -541,7 +540,7 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( mobile_apis::FunctionID::RegisterAppInterfaceID, message[strings::params][strings::correlation_id].asUInt(), mobile_apis::Result::OUT_OF_MEMORY)); - ManageMobileCommand(response, commands::Command::ORIGIN_SDL); + rpc_service_->ManageMobileCommand(response, commands::Command::ORIGIN_SDL); return ApplicationSharedPtr(); } @@ -736,45 +735,45 @@ void ApplicationManagerImpl::OnHMIStartedCooperation() { utils::SharedPtr<smart_objects::SmartObject> is_vr_ready( MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::VR_IsReady, *this)); - ManageHMICommand(is_vr_ready); + rpc_service_->ManageHMICommand(is_vr_ready); utils::SharedPtr<smart_objects::SmartObject> is_tts_ready( MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::TTS_IsReady, *this)); - ManageHMICommand(is_tts_ready); + rpc_service_->ManageHMICommand(is_tts_ready); utils::SharedPtr<smart_objects::SmartObject> is_ui_ready( MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::UI_IsReady, *this)); - ManageHMICommand(is_ui_ready); + rpc_service_->ManageHMICommand(is_ui_ready); utils::SharedPtr<smart_objects::SmartObject> is_navi_ready( MessageHelper::CreateModuleInfoSO( hmi_apis::FunctionID::Navigation_IsReady, *this)); - ManageHMICommand(is_navi_ready); + rpc_service_->ManageHMICommand(is_navi_ready); utils::SharedPtr<smart_objects::SmartObject> is_ivi_ready( MessageHelper::CreateModuleInfoSO( hmi_apis::FunctionID::VehicleInfo_IsReady, *this)); - ManageHMICommand(is_ivi_ready); + rpc_service_->ManageHMICommand(is_ivi_ready); #ifdef SDL_REMOTE_CONTROL utils::SharedPtr<smart_objects::SmartObject> is_rc_ready( MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::RC_IsReady, *this)); - ManageHMICommand(is_rc_ready); + rpc_service_->ManageHMICommand(is_rc_ready); #endif utils::SharedPtr<smart_objects::SmartObject> button_capabilities( MessageHelper::CreateModuleInfoSO( hmi_apis::FunctionID::Buttons_GetCapabilities, *this)); - ManageHMICommand(button_capabilities); + rpc_service_->ManageHMICommand(button_capabilities); utils::SharedPtr<smart_objects::SmartObject> mixing_audio_supported_request( MessageHelper::CreateModuleInfoSO( hmi_apis::FunctionID::BasicCommunication_MixingAudioSupported, *this)); - ManageHMICommand(mixing_audio_supported_request); + rpc_service_->ManageHMICommand(mixing_audio_supported_request); resume_controller().ResetLaunchTime(); } @@ -1077,7 +1076,7 @@ void ApplicationManagerImpl::OnDeviceListUpdated( so_to_send[jhs::S_PARAMS][jhs::S_PROTOCOL_TYPE] = 1; so_to_send[jhs::S_PARAMS][jhs::S_CORRELATION_ID] = GetNextHMICorrelationID(); so_to_send[jhs::S_MSG_PARAMS] = *msg_params; - ManageHMICommand(update_list); + rpc_service_->ManageHMICommand(update_list); } void ApplicationManagerImpl::OnFindNewApplicationsRequest() { @@ -1106,7 +1105,7 @@ void ApplicationManagerImpl::SendUpdateAppList() { PrepareApplicationListSO(applications_, applications, *this); PrepareApplicationListSO(apps_to_register_, applications, *this); - ManageHMICommand(request); + rpc_service_->ManageHMICommand(request); } void ApplicationManagerImpl::RemoveDevice( @@ -1164,7 +1163,7 @@ void ApplicationManagerImpl::OnDeviceSwitchingStart( so_to_send[jhs::S_PARAMS][jhs::S_PROTOCOL_TYPE] = 1; so_to_send[jhs::S_PARAMS][jhs::S_CORRELATION_ID] = GetNextHMICorrelationID(); so_to_send[jhs::S_MSG_PARAMS] = *msg_params; - ManageHMICommand(update_list); + rpc_service_->ManageHMICommand(update_list); } void ApplicationManagerImpl::OnDeviceSwitchingFinish( @@ -1632,7 +1631,7 @@ void ApplicationManagerImpl::OnServiceEndedCallback( is_resuming = true; is_unexpected_disconnect = false; - ManageMobileCommand( + rpc_service_->ManageMobileCommand( MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( session_key, AppInterfaceUnregisteredReason::TOO_MANY_REQUESTS), commands::Command::ORIGIN_SDL); @@ -1752,327 +1751,20 @@ protocol_handler::ProtocolHandler& ApplicationManagerImpl::protocol_handler() void ApplicationManagerImpl::set_protocol_handler( protocol_handler::ProtocolHandler* handler) { protocol_handler_ = handler; + rpc_service_.reset(new rpc_service::RPCServiceImpl( + *this, request_ctrl_, protocol_handler_, hmi_handler_)); } void ApplicationManagerImpl::StartDevicesDiscovery() { connection_handler().get_device_discovery_starter().StartDevicesDiscovery(); } -void ApplicationManagerImpl::SendMessageToMobile( - const commands::MessageSharedPtr message, bool final_message) { - LOG4CXX_AUTO_TRACE(logger_); - - if (!message) { - LOG4CXX_ERROR(logger_, "Null-pointer message received."); - NOTREACHED(); - return; - } - - if (!protocol_handler_) { - LOG4CXX_WARN(logger_, "No Protocol Handler set"); - return; - } - - ApplicationSharedPtr app = application( - (*message)[strings::params][strings::connection_key].asUInt()); - - const bool is_result_code_exists = - (*message)[strings::msg_params].keyExists(strings::result_code); - - if (!app) { - LOG4CXX_ERROR(logger_, "No application associated with connection key"); - if (is_result_code_exists && - ((*message)[strings::msg_params][strings::result_code] == - NsSmartDeviceLinkRPC::V1::Result::UNSUPPORTED_VERSION)) { - (*message)[strings::params][strings::protocol_version] = - protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_1; - } else { - (*message)[strings::params][strings::protocol_version] = - SupportedSDLVersion(); - } - } else { - (*message)[strings::params][strings::protocol_version] = - app->protocol_version(); - } - - if (app && is_result_code_exists && - (*message)[strings::msg_params][strings::result_code] == - mobile_apis::Result::OUT_OF_MEMORY) { - app->usage_report().RecordRejectionsSyncOutOfMemory(); - } - - mobile_so_factory().attachSchema(*message, false); - LOG4CXX_DEBUG( - logger_, - "Attached schema to message, result if valid: " << message->isValid()); - - // Messages to mobile are not yet prioritized so use default priority value - utils::SharedPtr<Message> message_to_send( - new Message(protocol_handler::MessagePriority::kDefault)); - if (!ConvertSOtoMessage((*message), (*message_to_send))) { - LOG4CXX_WARN(logger_, "Can't send msg to Mobile: failed to create string"); - return; - } - - smart_objects::SmartObject& msg_to_mobile = *message; - // If correlation_id is not present, it is from-HMI message which should be - // checked against policy permissions - if (msg_to_mobile[strings::params].keyExists(strings::correlation_id)) { - request_ctrl_.OnMobileResponse( - msg_to_mobile[strings::params][strings::correlation_id].asUInt(), - msg_to_mobile[strings::params][strings::connection_key].asUInt(), - msg_to_mobile[strings::params][strings::function_id].asInt()); -#ifdef SDL_REMOTE_CONTROL - const mobile_apis::FunctionID::eType function_id = - static_cast<mobile_apis::FunctionID::eType>( - (*message)[strings::params][strings::function_id].asUInt()); - if (function_id == mobile_apis::FunctionID::RegisterAppInterfaceID && - (*message)[strings::msg_params][strings::success].asBool()) { - LOG4CXX_INFO(logger_, - "Registered app " - << app->app_id() << " is " - << (plugin_manager_.IsAppForPlugins(app) ? "" : "not ") - << "for plugins."); - } -#endif // SDL_REMOTE_CONTROL - } else if (app) { - mobile_apis::FunctionID::eType function_id = - static_cast<mobile_apis::FunctionID::eType>( - (*message)[strings::params][strings::function_id].asUInt()); - RPCParams params; - - const smart_objects::SmartObject& s_map = (*message)[strings::msg_params]; - if (smart_objects::SmartType_Map == s_map.getType()) { - smart_objects::SmartMap::iterator iter = s_map.map_begin(); - smart_objects::SmartMap::iterator iter_end = s_map.map_end(); - - for (; iter != iter_end; ++iter) { - if (true == iter->second.asBool()) { - LOG4CXX_INFO(logger_, "Request's param: " << iter->first); - params.insert(iter->first); - } - } - } - const std::string string_functionID = - MessageHelper::StringifiedFunctionID(function_id); - const mobile_apis::Result::eType check_result = - CheckPolicyPermissions(app, string_functionID, params); - if (mobile_apis::Result::SUCCESS != check_result) { - LOG4CXX_WARN(logger_, - "Function \"" << string_functionID << "\" (#" << function_id - << ") not allowed by policy"); - return; - } - -#ifdef EXTERNAL_PROPRIETARY_MODE - if (function_id == mobile_apis::FunctionID::OnSystemRequestID) { - mobile_apis::RequestType::eType request_type = - static_cast<mobile_apis::RequestType::eType>( - (*message)[strings::msg_params][strings::request_type].asUInt()); - if (mobile_apis::RequestType::PROPRIETARY == request_type || - mobile_apis::RequestType::HTTP == request_type) { - GetPolicyHandler().OnUpdateRequestSentToMobile(); - } - } -#endif // EXTERNAL_PROPRIETARY_MODE - } - - if (message_to_send->binary_data()) { - LOG4CXX_DEBUG( - logger_, - "Binary data size: " << message_to_send->binary_data()->size()); - } - messages_to_mobile_.PostMessage( - impl::MessageToMobile(message_to_send, final_message)); -} - void ApplicationManagerImpl::TerminateRequest(const uint32_t connection_key, const uint32_t corr_id, const int32_t function_id) { request_ctrl_.TerminateRequest(corr_id, connection_key, function_id, true); } -bool ApplicationManagerImpl::ManageMobileCommand( - const commands::MessageSharedPtr message, - commands::Command::CommandOrigin origin) { - LOG4CXX_AUTO_TRACE(logger_); - if (!message) { - LOG4CXX_WARN(logger_, "Null-pointer message received."); - return false; - } - - if (IsLowVoltage()) { - LOG4CXX_WARN(logger_, "Low Voltage is active"); - return false; - } -#ifdef DEBUG - MessageHelper::PrintSmartObject(*message); -#endif - - LOG4CXX_DEBUG(logger_, "Trying to create message in mobile factory."); - utils::SharedPtr<commands::Command> command( - MobileCommandFactory::CreateCommand(message, origin, *this)); - - if (!command) { - LOG4CXX_WARN(logger_, - "RET Failed to create mobile command from smart object"); - return false; - } - - const uint32_t connection_key = static_cast<uint32_t>( - (*message)[strings::params][strings::connection_key].asUInt()); - - auto app_ptr = application(connection_key); - if (app_ptr && IsAppInReconnectMode(app_ptr->policy_app_id())) { - commands_holder_->Suspend( - app_ptr, CommandHolder::CommandType::kMobileCommand, message); - return true; - } - - mobile_apis::FunctionID::eType function_id = - static_cast<mobile_apis::FunctionID::eType>( - (*message)[strings::params][strings::function_id].asInt()); - - // Notifications from HMI have no such parameter - uint32_t correlation_id = - (*message)[strings::params].keyExists(strings::correlation_id) - ? (*message)[strings::params][strings::correlation_id].asUInt() - : 0; - - int32_t protocol_type = - (*message)[strings::params][strings::protocol_type].asUInt(); - - ApplicationSharedPtr app; - int32_t message_type = - (*message)[strings::params][strings::message_type].asInt(); - - if (((mobile_apis::FunctionID::RegisterAppInterfaceID != function_id) && - (protocol_type == commands::CommandImpl::mobile_protocol_type_)) && - (mobile_apis::FunctionID::UnregisterAppInterfaceID != function_id)) { - app = application(connection_key); - if (!app) { - LOG4CXX_ERROR(logger_, "RET APPLICATION_NOT_REGISTERED"); - smart_objects::SmartObjectSPtr response = - MessageHelper::CreateNegativeResponse( - connection_key, - static_cast<int32_t>(function_id), - correlation_id, - static_cast<int32_t>( - mobile_apis::Result::APPLICATION_NOT_REGISTERED)); - - SendMessageToMobile(response); - return false; - } - - // Message for "CheckPermission" must be with attached schema - mobile_so_factory().attachSchema(*message, false); - } - - if (message_type == mobile_apis::messageType::response) { - if (command->Init()) { - command->Run(); - command->CleanUp(); - } - return true; - } - if (message_type == mobile_apis::messageType::notification) { - request_ctrl_.addNotification(command); - if (command->Init()) { - command->Run(); - if (command->CleanUp()) { - request_ctrl_.removeNotification(command.get()); - } - // If CleanUp returned false notification should remove it self. - } - return true; - } - - if (message_type == mobile_apis::messageType::request) { - // commands will be launched from requesr_ctrl - mobile_apis::HMILevel::eType app_hmi_level = - mobile_apis::HMILevel::INVALID_ENUM; - if (app) { - app_hmi_level = app->hmi_level(); - } - - // commands will be launched from request_ctrl - - const request_controller::RequestController::TResult result = - request_ctrl_.addMobileRequest(command, app_hmi_level); - - if (result == request_controller::RequestController::SUCCESS) { - LOG4CXX_DEBUG(logger_, "Perform request"); - } else if (result == request_controller::RequestController:: - TOO_MANY_PENDING_REQUESTS) { - LOG4CXX_ERROR(logger_, - "RET Unable top perform request: " - << "TOO_MANY_PENDING_REQUESTS"); - - smart_objects::SmartObjectSPtr response = - MessageHelper::CreateNegativeResponse( - connection_key, - static_cast<int32_t>(function_id), - correlation_id, - static_cast<int32_t>( - mobile_apis::Result::TOO_MANY_PENDING_REQUESTS)); - ApplicationSharedPtr app_ptr = application(connection_key); - if (app_ptr) { - app_ptr->usage_report().RecordRemovalsForBadBehavior(); - } - - SendMessageToMobile(response); - return false; - } else if (result == - request_controller::RequestController::TOO_MANY_REQUESTS) { - LOG4CXX_ERROR(logger_, - "RET Unable to perform request: " - << "TOO_MANY_REQUESTS"); - - ManageMobileCommand( - MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( - connection_key, - mobile_api::AppInterfaceUnregisteredReason::TOO_MANY_REQUESTS), - commands::Command::ORIGIN_SDL); - - UnregisterApplication(connection_key, - mobile_apis::Result::TOO_MANY_PENDING_REQUESTS, - false); - ApplicationSharedPtr app_ptr = application(connection_key); - if (app_ptr) { - app_ptr->usage_report().RecordRemovalsForBadBehavior(); - } - return false; - } else if (result == request_controller::RequestController:: - NONE_HMI_LEVEL_MANY_REQUESTS) { - LOG4CXX_ERROR(logger_, - "RET Unable to perform request: " - << "REQUEST_WHILE_IN_NONE_HMI_LEVEL"); - - ManageMobileCommand( - MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( - connection_key, - mobile_api::AppInterfaceUnregisteredReason:: - REQUEST_WHILE_IN_NONE_HMI_LEVEL), - commands::Command::ORIGIN_SDL); - - ApplicationSharedPtr app_ptr = application(connection_key); - if (app_ptr) { - app_ptr->usage_report().RecordRemovalsForBadBehavior(); - } - UnregisterApplication( - connection_key, mobile_apis::Result::INVALID_ENUM, false); - return false; - } else { - LOG4CXX_ERROR(logger_, "RET Unable to perform request: Unknown case"); - return false; - } - return true; - } - - LOG4CXX_ERROR(logger_, "RET UNKNOWN MESSAGE TYPE " << message_type); - return false; -} - void ApplicationManagerImpl::RemoveHMIFakeParameters( application_manager::MessagePtr& message) { LOG4CXX_AUTO_TRACE(logger_); @@ -2092,104 +1784,6 @@ void ApplicationManagerImpl::RemoveHMIFakeParameters( message->set_json_message(formatted_message); } -void ApplicationManagerImpl::SendMessageToHMI( - const commands::MessageSharedPtr message) { - LOG4CXX_AUTO_TRACE(logger_); - - if (!message) { - LOG4CXX_WARN(logger_, "Null-pointer message received."); - NOTREACHED(); - return; - } - - if (!hmi_handler_) { - LOG4CXX_WARN(logger_, "No HMI Handler set"); - return; - } - - // SmartObject |message| has no way to declare priority for now - utils::SharedPtr<Message> message_to_send( - new Message(protocol_handler::MessagePriority::kDefault)); - if (!message_to_send) { - LOG4CXX_ERROR(logger_, "Null pointer"); - return; - } - - hmi_so_factory().attachSchema(*message, false); - LOG4CXX_INFO( - logger_, - "Attached schema to message, result if valid: " << message->isValid()); - -#ifdef HMI_DBUS_API - message_to_send->set_smart_object(*message); -#else - if (!ConvertSOtoMessage(*message, *message_to_send)) { - LOG4CXX_WARN(logger_, - "Cannot send message to HMI: failed to create string"); - return; - } -#endif // HMI_DBUS_API - - messages_to_hmi_.PostMessage(impl::MessageToHmi(message_to_send)); -} - -bool ApplicationManagerImpl::ManageHMICommand( - const commands::MessageSharedPtr message) { - LOG4CXX_AUTO_TRACE(logger_); - - if (!message) { - LOG4CXX_WARN(logger_, "Null-pointer message received."); - return false; - } - - if (IsLowVoltage()) { - LOG4CXX_WARN(logger_, "Low Voltage is active"); - return false; - } - - MessageHelper::PrintSmartObject(*message); - - CommandSharedPtr command = HMICommandFactory::CreateCommand(message, *this); - if (!command) { - LOG4CXX_WARN(logger_, "Failed to create command from smart object"); - return false; - } - - if ((*message).keyExists(strings::msg_params) && - (*message)[strings::msg_params].keyExists(strings::app_id)) { - const auto connection_key = - (*message)[strings::msg_params][strings::app_id].asUInt(); - - auto app = application(static_cast<uint32_t>(connection_key)); - if (app && IsAppInReconnectMode(app->policy_app_id())) { - commands_holder_->Suspend( - app, CommandHolder::CommandType::kHmiCommand, message); - return true; - } - } - - int32_t message_type = - (*message)[strings::params][strings::message_type].asInt(); - - if (kRequest == message_type) { - LOG4CXX_DEBUG(logger_, "ManageHMICommand"); - request_ctrl_.addHMIRequest(command); - } - - if (command->Init()) { - command->Run(); - if (kResponse == message_type) { - const uint32_t correlation_id = - (*message)[strings::params][strings::correlation_id].asUInt(); - const int32_t function_id = - (*message)[strings::params][strings::function_id].asInt(); - request_ctrl_.OnHMIResponse(correlation_id, function_id); - } - return true; - } - return false; -} - bool ApplicationManagerImpl::Init(resumption::LastState& last_state, media_manager::MediaManager* media_manager) { LOG4CXX_TRACE(logger_, "Init application manager"); @@ -2322,7 +1916,7 @@ bool ApplicationManagerImpl::ConvertMessageToSO( (*response)[strings::msg_params][strings::info] = rpc::PrettyFormat(report); - ManageMobileCommand(response, commands::Command::ORIGIN_SDL); + rpc_service_->ManageMobileCommand(response, commands::Command::ORIGIN_SDL); return false; } LOG4CXX_DEBUG(logger_, @@ -2346,7 +1940,8 @@ bool ApplicationManagerImpl::ConvertMessageToSO( message.function_id(), message.correlation_id(), mobile_apis::Result::INVALID_DATA)); - ManageMobileCommand(response, commands::Command::ORIGIN_SDL); + rpc_service_->ManageMobileCommand(response, + commands::Command::ORIGIN_SDL); return false; } output[strings::params][strings::binary_data] = @@ -2416,7 +2011,7 @@ bool ApplicationManagerImpl::ConvertMessageToSO( smart_objects::SmartObjectSPtr msg_to_send = new smart_objects::SmartObject(output); v1_shema.attachSchema(*msg_to_send, false); - SendMessageToMobile(msg_to_send); + rpc_service_->SendMessageToMobile(msg_to_send); return false; } } @@ -2643,7 +2238,8 @@ void ApplicationManagerImpl::ProcessMessageFromMobile( metric->message = so_from_mobile; #endif // TELEMETRY_MONITOR - if (!ManageMobileCommand(so_from_mobile, commands::Command::ORIGIN_MOBILE)) { + if (!rpc_service_->ManageMobileCommand(so_from_mobile, + commands::Command::ORIGIN_MOBILE)) { LOG4CXX_ERROR(logger_, "Received command didn't run successfully"); } #ifdef TELEMETRY_MONITOR @@ -2683,7 +2279,7 @@ void ApplicationManagerImpl::ProcessMessageFromHMI( #endif // HMI_DBUS_API LOG4CXX_DEBUG(logger_, "Converted message, trying to create hmi command"); - if (!ManageHMICommand(smart_object)) { + if (!rpc_service_->ManageHMICommand(smart_object)) { LOG4CXX_ERROR(logger_, "Received command didn't run successfully"); } } @@ -3113,7 +2709,7 @@ void ApplicationManagerImpl::UnregisterAllApplications() { ApplicationSetConstIt it = accessor.GetData().begin(); while (it != accessor.GetData().end()) { ApplicationSharedPtr app_to_remove = *it; - ManageMobileCommand( + rpc_service_->ManageMobileCommand( MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( app_to_remove->app_id(), unregister_reason_), commands::Command::ORIGIN_SDL); @@ -3306,39 +2902,6 @@ void ApplicationManagerImpl::Handle(const impl::MessageFromMobile message) { ProcessMessageFromMobile(message); } -void ApplicationManagerImpl::Handle(const impl::MessageToMobile message) { - if (!protocol_handler_) { - LOG4CXX_WARN(logger_, - "Protocol Handler is not set; cannot send message to mobile."); - return; - } - - utils::SharedPtr<protocol_handler::RawMessage> rawMessage = - MobileMessageHandler::HandleOutgoingMessageProtocol(message); - - if (!rawMessage) { - LOG4CXX_ERROR(logger_, "Failed to create raw message."); - return; - } - - bool is_final = message.is_final; - bool close_session = false; - if (is_final) { - if (1 < connection_handler().GetConnectionSessionsCount( - message->connection_key())) { - is_final = false; - close_session = true; - } - } - - protocol_handler_->SendMessageToMobileApp(rawMessage, is_final); - LOG4CXX_INFO(logger_, "Message for mobile given away"); - - if (close_session) { - connection_handler().CloseSession(message->connection_key(), - connection_handler::kCommon); - } -} void ApplicationManagerImpl::Handle(const impl::MessageFromHmi message) { LOG4CXX_AUTO_TRACE(logger_); @@ -3363,17 +2926,6 @@ void ApplicationManagerImpl::Handle(const impl::MessageFromHmi message) { ProcessMessageFromHMI(message); } -void ApplicationManagerImpl::Handle(const impl::MessageToHmi message) { - LOG4CXX_AUTO_TRACE(logger_); - if (!hmi_handler_) { - LOG4CXX_ERROR(logger_, "Observer is not set for HMIMessageHandler"); - return; - } - - hmi_handler_->SendMessageToHMI(message); - LOG4CXX_INFO(logger_, "Message for HMI given away"); -} - void ApplicationManagerImpl::Handle(const impl::AudioData message) { LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObjectSPtr on_audio_pass = @@ -3562,7 +3114,7 @@ void ApplicationManagerImpl::ForbidStreaming(uint32_t app_id) { } } if (unregister) { - ManageMobileCommand( + rpc_service_->ManageMobileCommand( MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( app_id, PROTOCOL_VIOLATION), commands::Command::ORIGIN_SDL); @@ -3757,7 +3309,8 @@ void ApplicationManagerImpl::SendHMIStatusNotification( message[strings::msg_params][strings::system_context] = static_cast<int32_t>(app->system_context()); - ManageMobileCommand(notification, commands::Command::ORIGIN_SDL); + rpc_service_->ManageMobileCommand(notification, + commands::Command::ORIGIN_SDL); } void ApplicationManagerImpl::ClearTimerPool() { @@ -3800,7 +3353,7 @@ void ApplicationManagerImpl::CloseNaviApp() { if (unregister) { LOG4CXX_INFO(logger_, "App haven't answered for EndService. Unregister it."); - ManageMobileCommand( + rpc_service_->ManageMobileCommand( MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( app_id, PROTOCOL_VIOLATION), commands::Command::ORIGIN_SDL); @@ -4575,15 +4128,6 @@ void ApplicationManagerImpl::ChangeAppsHMILevel( } } -void ApplicationManagerImpl::SendPostMessageToMobile( - const MessagePtr& message) { - messages_to_mobile_.PostMessage(impl::MessageToMobile(message, false)); -} - -void ApplicationManagerImpl::SendPostMessageToHMI(const MessagePtr& message) { - messages_to_hmi_.PostMessage(impl::MessageToHmi(message)); -} - #endif // SDL_REMOTE_CONTROL } // namespace application_manager diff --git a/src/components/application_manager/src/command_holder_impl.cc b/src/components/application_manager/src/command_holder_impl.cc index afdaa2f1f4..525940c783 100644 --- a/src/components/application_manager/src/command_holder_impl.cc +++ b/src/components/application_manager/src/command_holder_impl.cc @@ -114,7 +114,7 @@ void CommandHolderImpl::ResumeHmiCommand(ApplicationSharedPtr application) { for (auto cmd : app_commands->second) { (*cmd)[strings::msg_params][strings::app_id] = application->hmi_app_id(); - app_manager_.ManageHMICommand(cmd); + app_manager_.GetRPCService().ManageHMICommand(cmd); } app_hmi_commands_.erase(app_commands); @@ -133,7 +133,7 @@ void CommandHolderImpl::ResumeMobileCommand(ApplicationSharedPtr application) { for (auto cmd : app_commands->second) { (*cmd)[strings::params][strings::connection_key] = application->app_id(); - app_manager_.ManageMobileCommand( + app_manager_.GetRPCService().ManageMobileCommand( cmd, commands::Command::CommandOrigin::ORIGIN_MOBILE); } diff --git a/src/components/application_manager/src/commands/command_notification_from_mobile_impl.cc b/src/components/application_manager/src/commands/command_notification_from_mobile_impl.cc index 5b44abeec9..440d24c79e 100644 --- a/src/components/application_manager/src/commands/command_notification_from_mobile_impl.cc +++ b/src/components/application_manager/src/commands/command_notification_from_mobile_impl.cc @@ -32,6 +32,7 @@ #include "application_manager/commands/command_notification_from_mobile_impl.h" #include "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" #include "application_manager/message_helper.h" namespace application_manager { @@ -63,7 +64,7 @@ void CommandNotificationFromMobileImpl::SendNotification() { LOG4CXX_INFO(logger_, "SendNotification"); MessageHelper::PrintSmartObject(*message_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/command_notification_impl.cc b/src/components/application_manager/src/commands/command_notification_impl.cc index b6b0e7d500..30381320d0 100644 --- a/src/components/application_manager/src/commands/command_notification_impl.cc +++ b/src/components/application_manager/src/commands/command_notification_impl.cc @@ -32,6 +32,7 @@ #include "application_manager/commands/command_notification_impl.h" #include "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" #include "application_manager/message_helper.h" namespace application_manager { @@ -63,7 +64,7 @@ void CommandNotificationImpl::SendNotification() { LOG4CXX_INFO(logger_, "SendNotification"); MessageHelper::PrintSmartObject(*message_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index 527d640c5c..69266b1b65 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -37,6 +37,7 @@ #include "utils/make_shared.h" #include "application_manager/commands/command_request_impl.h" #include "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" #include "application_manager/message_helper.h" #include "smart_objects/smart_object.h" @@ -242,7 +243,8 @@ void CommandRequestImpl::onTimeOut() { correlation_id(), mobile_api::Result::GENERIC_ERROR); AddTimeOutComponentInfoToMessage(*response); - application_manager_.ManageMobileCommand(response, ORIGIN_SDL); + application_manager_.GetRPCService().ManageMobileCommand(response, + ORIGIN_SDL); } void CommandRequestImpl::on_event(const event_engine::Event& event) {} @@ -305,7 +307,7 @@ void CommandRequestImpl::SendResponse( is_success_result_ = success; - application_manager_.ManageMobileCommand(result, ORIGIN_SDL); + application_manager_.GetRPCService().ManageMobileCommand(result, ORIGIN_SDL); } bool CommandRequestImpl::CheckSyntax(const std::string& str, @@ -433,7 +435,7 @@ uint32_t CommandRequestImpl::SendHMIRequest( subscribe_on_event(function_id, hmi_correlation_id); } if (ProcessHMIInterfacesAvailability(hmi_correlation_id, function_id)) { - if (!application_manager_.ManageHMICommand(result)) { + if (!application_manager_.GetRPCService().ManageHMICommand(result)) { LOG4CXX_ERROR(logger_, "Unable to send request"); SendResponse(false, mobile_apis::Result::OUT_OF_MEMORY); } @@ -462,7 +464,7 @@ void CommandRequestImpl::CreateHMINotification( notify[strings::params][strings::function_id] = function_id; notify[strings::msg_params] = msg_params; - if (!application_manager_.ManageHMICommand(result)) { + if (!application_manager_.GetRPCService().ManageHMICommand(result)) { LOG4CXX_ERROR(logger_, "Unable to send HMI notification"); } } @@ -627,7 +629,7 @@ bool CommandRequestImpl::CheckAllowedParameters() { correlation_id(), app->app_id()); - application_manager_.SendMessageToMobile(response); + application_manager_.GetRPCService().SendMessageToMobile(response); return false; } diff --git a/src/components/application_manager/src/commands/command_response_impl.cc b/src/components/application_manager/src/commands/command_response_impl.cc index c3265230a8..01eccf552e 100644 --- a/src/components/application_manager/src/commands/command_response_impl.cc +++ b/src/components/application_manager/src/commands/command_response_impl.cc @@ -32,6 +32,7 @@ #include "application_manager/commands/command_response_impl.h" #include "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -80,7 +81,8 @@ void CommandResponseImpl::SendResponse( } } - application_manager_.SendMessageToMobile(message_, final_message); + application_manager_.GetRPCService().SendMessageToMobile(message_, + final_message); } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/get_urls.cc b/src/components/application_manager/src/commands/hmi/get_urls.cc index bfcdf4985e..a229003eed 100644 --- a/src/components/application_manager/src/commands/hmi/get_urls.cc +++ b/src/components/application_manager/src/commands/hmi/get_urls.cc @@ -33,6 +33,7 @@ #include "application_manager/commands/hmi/get_urls.h" #include "application_manager/message.h" #include "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" #include "application_manager/policies/policy_handler.h" #include "utils/helpers.h" @@ -125,7 +126,7 @@ void GetUrls::ProcessServiceURLs(const policy::EndpointUrls& endpoints) { void GetUrls::SendResponseToHMI(hmi_apis::Common_Result::eType result) { (*message_)[strings::params][strings::message_type] = MessageType::kResponse; (*message_)[strings::params][hmi_response::code] = result; - application_manager_.ManageHMICommand(message_); + application_manager_.GetRPCService().ManageHMICommand(message_); } #ifdef PROPRIETARY_MODE diff --git a/src/components/application_manager/src/commands/hmi/get_urls_response.cc b/src/components/application_manager/src/commands/hmi/get_urls_response.cc index dd9686fbce..806c4ce8b0 100644 --- a/src/components/application_manager/src/commands/hmi/get_urls_response.cc +++ b/src/components/application_manager/src/commands/hmi/get_urls_response.cc @@ -31,6 +31,7 @@ */ #include "application_manager/commands/hmi/get_urls_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { namespace commands { @@ -46,7 +47,7 @@ void GetUrlsResponse::Run() { (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; (*message_)[strings::params][strings::protocol_version] = protocol_version_; - application_manager_.SendMessageToHMI(message_); + application_manager_.GetRPCService().SendMessageToHMI(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc b/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc index 3c2d73b10c..55ecfd6643 100644 --- a/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc @@ -32,6 +32,7 @@ #include "application_manager/commands/hmi/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" #include "smart_objects/smart_object.h" namespace application_manager { @@ -61,7 +62,7 @@ void NotificationFromHMI::SendNotificationToMobile( const MessageSharedPtr& message) { (*message)[strings::params][strings::message_type] = static_cast<int32_t>(application_manager::MessageType::kNotification); - application_manager_.ManageMobileCommand(message, ORIGIN_SDL); + application_manager_.GetRPCService().ManageMobileCommand(message, ORIGIN_SDL); } void NotificationFromHMI::CreateHMIRequest( @@ -90,7 +91,7 @@ void NotificationFromHMI::CreateHMIRequest( request[strings::msg_params] = msg_params; - if (!application_manager_.ManageHMICommand(result)) { + if (!application_manager_.GetRPCService().ManageHMICommand(result)) { LOG4CXX_ERROR(logger_, "Unable to send request"); return; } diff --git a/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc b/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc index d52df950c3..223111d40a 100644 --- a/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc @@ -32,6 +32,7 @@ #include "application_manager/commands/hmi/notification_to_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -57,7 +58,7 @@ void NotificationToHMI::Run() {} void NotificationToHMI::SendNotification() { (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; (*message_)[strings::params][strings::protocol_version] = protocol_version_; - application_manager_.SendMessageToHMI(message_); + application_manager_.GetRPCService().SendMessageToHMI(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc b/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc index cb68b21263..c9920e5d18 100644 --- a/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc @@ -37,6 +37,7 @@ #include <signal.h> #include "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" #include "application_manager/resumption/resume_ctrl.h" #include "interfaces/HMI_API.h" @@ -107,7 +108,7 @@ void OnExitAllApplicationsNotification::SendOnSDLPersistenceComplete() { (*message)[strings::params][strings::correlation_id] = application_manager_.GetNextHMICorrelationID(); - application_manager_.ManageHMICommand(message); + application_manager_.GetRPCService().ManageHMICommand(message); } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc b/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc index df9dc01eab..8e43fdfd01 100644 --- a/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc @@ -35,6 +35,7 @@ #include "application_manager/application_impl.h" #include "application_manager/state_controller.h" #include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" #include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" #ifdef SDL_REMOTE_CONTROL @@ -82,7 +83,7 @@ void OnExitApplicationNotification::Run() { break; } case Common_ApplicationExitReason::UNAUTHORIZED_TRANSPORT_REGISTRATION: { - application_manager_.ManageMobileCommand( + application_manager_.GetRPCService().ManageMobileCommand( MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( app_id, AppInterfaceUnregisteredReason::APP_UNAUTHORIZED), commands::Command::ORIGIN_SDL); @@ -91,7 +92,7 @@ void OnExitApplicationNotification::Run() { return; } case Common_ApplicationExitReason::UNSUPPORTED_HMI_RESOURCE: { - application_manager_.ManageMobileCommand( + application_manager_.GetRPCService().ManageMobileCommand( MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( app_id, AppInterfaceUnregisteredReason::UNSUPPORTED_HMI_RESOURCE), commands::Command::ORIGIN_SDL); diff --git a/src/components/application_manager/src/commands/hmi/on_tts_language_change_notification.cc b/src/components/application_manager/src/commands/hmi/on_tts_language_change_notification.cc index bd152c2af0..f7fe10f332 100644 --- a/src/components/application_manager/src/commands/hmi/on_tts_language_change_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_tts_language_change_notification.cc @@ -34,6 +34,7 @@ #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" #include "interfaces/MOBILE_API.h" namespace application_manager { @@ -77,7 +78,7 @@ void OnTTSLanguageChangeNotification::Run() { if (static_cast<int>(app->language()) != (*message_)[strings::msg_params][strings::language].asInt()) { - application_manager_.ManageMobileCommand( + application_manager_.GetRPCService().ManageMobileCommand( MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( app->app_id(), mobile_api::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE), diff --git a/src/components/application_manager/src/commands/hmi/on_ui_language_change_notification.cc b/src/components/application_manager/src/commands/hmi/on_ui_language_change_notification.cc index 6e8e38f757..caea874371 100644 --- a/src/components/application_manager/src/commands/hmi/on_ui_language_change_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_ui_language_change_notification.cc @@ -34,6 +34,7 @@ #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" #include "interfaces/MOBILE_API.h" namespace application_manager { @@ -76,7 +77,7 @@ void OnUILanguageChangeNotification::Run() { if (app->ui_language() != (*message_)[strings::msg_params][strings::hmi_display_language] .asInt()) { - application_manager_.ManageMobileCommand( + application_manager_.GetRPCService().ManageMobileCommand( MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( app->app_id(), mobile_api::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE), diff --git a/src/components/application_manager/src/commands/hmi/on_vr_language_change_notification.cc b/src/components/application_manager/src/commands/hmi/on_vr_language_change_notification.cc index bbdb55cde6..c94a341fcb 100644 --- a/src/components/application_manager/src/commands/hmi/on_vr_language_change_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_vr_language_change_notification.cc @@ -35,6 +35,7 @@ #include "application_manager/application_impl.h" #include "application_manager/state_controller.h" #include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" #include "interfaces/MOBILE_API.h" namespace application_manager { @@ -75,7 +76,7 @@ void OnVRLanguageChangeNotification::Run() { application_manager_.state_controller().SetRegularState( app, mobile_api::HMILevel::HMI_NONE, false); - application_manager_.ManageMobileCommand( + application_manager_.GetRPCService().ManageMobileCommand( MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( app->app_id(), mobile_api::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE), diff --git a/src/components/application_manager/src/commands/hmi/rc_is_ready_request.cc b/src/components/application_manager/src/commands/hmi/rc_is_ready_request.cc index a976ce1044..f2a638ae33 100644 --- a/src/components/application_manager/src/commands/hmi/rc_is_ready_request.cc +++ b/src/components/application_manager/src/commands/hmi/rc_is_ready_request.cc @@ -31,6 +31,7 @@ */ #include "application_manager/commands/hmi/rc_is_ready_request.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -91,7 +92,7 @@ void RCIsReadyRequest::SendMessageToHMI() { utils::SharedPtr<smart_objects::SmartObject> get_capabilities( MessageHelper::CreateModuleInfoSO( hmi_apis::FunctionID::RC_GetCapabilities, application_manager_)); - application_manager_.ManageHMICommand(get_capabilities); + application_manager_.GetRPCService().ManageHMICommand(get_capabilities); } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/request_from_hmi.cc b/src/components/application_manager/src/commands/hmi/request_from_hmi.cc index 5a4e7b149e..10e4ec5141 100644 --- a/src/components/application_manager/src/commands/hmi/request_from_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/request_from_hmi.cc @@ -32,6 +32,7 @@ #include "application_manager/commands/hmi/request_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" #include "utils/make_shared.h" namespace application_manager { @@ -74,7 +75,7 @@ void RequestFromHMI::SendResponse( (*message)[strings::msg_params][strings::success] = success; (*message)[strings::msg_params][strings::result_code] = result_code; - application_manager_.ManageHMICommand(message); + application_manager_.GetRPCService().ManageHMICommand(message); } void RequestFromHMI::SendErrorResponse( @@ -91,7 +92,7 @@ void RequestFromHMI::SendErrorResponse( (*message)[strings::params][hmi_response::code] = result_code; (*message)[strings::params][strings::error_msg] = error_message; - application_manager_.ManageHMICommand(message); + application_manager_.GetRPCService().ManageHMICommand(message); } void RequestFromHMI::FillCommonParametersOfSO( diff --git a/src/components/application_manager/src/commands/hmi/request_to_hmi.cc b/src/components/application_manager/src/commands/hmi/request_to_hmi.cc index 23c020bca2..d7e889c352 100644 --- a/src/components/application_manager/src/commands/hmi/request_to_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/request_to_hmi.cc @@ -31,6 +31,7 @@ */ #include "application_manager/commands/hmi/request_to_hmi.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -81,7 +82,7 @@ void RequestToHMI::Run() { void RequestToHMI::SendRequest() { (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; (*message_)[strings::params][strings::protocol_version] = protocol_version_; - application_manager_.SendMessageToHMI(message_); + application_manager_.GetRPCService().SendMessageToHMI(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/response_from_hmi.cc b/src/components/application_manager/src/commands/hmi/response_from_hmi.cc index d6d5d95d07..6ec83debb0 100644 --- a/src/components/application_manager/src/commands/hmi/response_from_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/response_from_hmi.cc @@ -31,7 +31,7 @@ */ #include "application_manager/commands/hmi/response_from_hmi.h" - +#include "application_manager/rpc_service.h" #include "smart_objects/smart_object.h" namespace application_manager { @@ -67,7 +67,7 @@ void ResponseFromHMI::SendResponseToMobile( const MessageSharedPtr& message, ApplicationManager& application_manager) { (*message)[strings::params][strings::message_type] = MessageType::kResponse; - application_manager_.ManageMobileCommand(message, ORIGIN_SDL); + application_manager_.GetRPCService().ManageMobileCommand(message, ORIGIN_SDL); } void ResponseFromHMI::CreateHMIRequest( @@ -95,7 +95,7 @@ void ResponseFromHMI::CreateHMIRequest( request[strings::msg_params] = msg_params; - if (!application_manager_.ManageHMICommand(result)) { + if (!application_manager_.GetRPCService().ManageHMICommand(result)) { LOG4CXX_ERROR(logger_, "Unable to send request"); return; } diff --git a/src/components/application_manager/src/commands/hmi/response_to_hmi.cc b/src/components/application_manager/src/commands/hmi/response_to_hmi.cc index de1e1e0fde..c662bd629c 100644 --- a/src/components/application_manager/src/commands/hmi/response_to_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/response_to_hmi.cc @@ -32,6 +32,7 @@ #include "application_manager/commands/hmi/response_to_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -56,7 +57,7 @@ void ResponseToHMI::Run() { (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; (*message_)[strings::params][strings::protocol_version] = protocol_version_; - application_manager_.SendMessageToHMI(message_); + application_manager_.GetRPCService().SendMessageToHMI(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/sdl_activate_app_response.cc b/src/components/application_manager/src/commands/hmi/sdl_activate_app_response.cc index 75a8c0b241..e63ec0f6ee 100644 --- a/src/components/application_manager/src/commands/hmi/sdl_activate_app_response.cc +++ b/src/components/application_manager/src/commands/hmi/sdl_activate_app_response.cc @@ -31,6 +31,7 @@ */ #include "application_manager/commands/hmi/sdl_activate_app_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -47,7 +48,7 @@ void SDLActivateAppResponse::Run() { (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; (*message_)[strings::params][strings::protocol_version] = protocol_version_; - application_manager_.SendMessageToHMI(message_); + application_manager_.GetRPCService().SendMessageToHMI(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/sdl_get_list_of_permissions_response.cc b/src/components/application_manager/src/commands/hmi/sdl_get_list_of_permissions_response.cc index 521b59a0ec..11a6f77ef0 100644 --- a/src/components/application_manager/src/commands/hmi/sdl_get_list_of_permissions_response.cc +++ b/src/components/application_manager/src/commands/hmi/sdl_get_list_of_permissions_response.cc @@ -31,6 +31,7 @@ */ #include "application_manager/commands/hmi/sdl_get_list_of_permissions_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -47,7 +48,7 @@ void SDLGetListOfPermissionsResponse::Run() { (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; (*message_)[strings::params][strings::protocol_version] = protocol_version_; - application_manager_.SendMessageToHMI(message_); + application_manager_.GetRPCService().SendMessageToHMI(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/sdl_get_status_update_response.cc b/src/components/application_manager/src/commands/hmi/sdl_get_status_update_response.cc index 0af7e0217a..b1d3ffec62 100644 --- a/src/components/application_manager/src/commands/hmi/sdl_get_status_update_response.cc +++ b/src/components/application_manager/src/commands/hmi/sdl_get_status_update_response.cc @@ -31,6 +31,7 @@ */ #include "application_manager/commands/hmi/sdl_get_status_update_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -47,7 +48,7 @@ void SDLGetStatusUpdateResponse::Run() { (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; (*message_)[strings::params][strings::protocol_version] = protocol_version_; - application_manager_.SendMessageToHMI(message_); + application_manager_.GetRPCService().SendMessageToHMI(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/sdl_get_user_friendly_message_response.cc b/src/components/application_manager/src/commands/hmi/sdl_get_user_friendly_message_response.cc index c693625dbb..5bf3527233 100644 --- a/src/components/application_manager/src/commands/hmi/sdl_get_user_friendly_message_response.cc +++ b/src/components/application_manager/src/commands/hmi/sdl_get_user_friendly_message_response.cc @@ -31,6 +31,7 @@ */ #include "application_manager/commands/hmi/sdl_get_user_friendly_message_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -47,7 +48,7 @@ void SDLGetUserFriendlyMessageResponse::Run() { (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; (*message_)[strings::params][strings::protocol_version] = protocol_version_; - application_manager_.SendMessageToHMI(message_); + application_manager_.GetRPCService().SendMessageToHMI(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/tts_is_ready_request.cc b/src/components/application_manager/src/commands/hmi/tts_is_ready_request.cc index 71e89dd9b9..85a6405196 100644 --- a/src/components/application_manager/src/commands/hmi/tts_is_ready_request.cc +++ b/src/components/application_manager/src/commands/hmi/tts_is_ready_request.cc @@ -31,6 +31,7 @@ */ #include "application_manager/commands/hmi/tts_is_ready_request.h" +#include "application_manager/rpc_service.h" #include "application_manager/message_helper.h" namespace application_manager { @@ -90,16 +91,16 @@ void TTSIsReadyRequest::SendMessageToHMI() { application_manager_)); HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities(); hmi_capabilities.set_handle_response_for(*get_language); - application_manager_.ManageHMICommand(get_language); + application_manager_.GetRPCService().ManageHMICommand(get_language); utils::SharedPtr<smart_objects::SmartObject> get_all_languages( MessageHelper::CreateModuleInfoSO( hmi_apis::FunctionID::TTS_GetSupportedLanguages, application_manager_)); - application_manager_.ManageHMICommand(get_all_languages); + application_manager_.GetRPCService().ManageHMICommand(get_all_languages); utils::SharedPtr<smart_objects::SmartObject> get_capabilities( MessageHelper::CreateModuleInfoSO( hmi_apis::FunctionID::TTS_GetCapabilities, application_manager_)); - application_manager_.ManageHMICommand(get_capabilities); + application_manager_.GetRPCService().ManageHMICommand(get_capabilities); } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/ui_is_ready_request.cc b/src/components/application_manager/src/commands/hmi/ui_is_ready_request.cc index 9e27e23d34..5d7f6d0f4e 100644 --- a/src/components/application_manager/src/commands/hmi/ui_is_ready_request.cc +++ b/src/components/application_manager/src/commands/hmi/ui_is_ready_request.cc @@ -32,6 +32,7 @@ #include "application_manager/commands/hmi/ui_is_ready_request.h" #include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -89,16 +90,16 @@ void UIIsReadyRequest::SendMessageToHMI() { application_manager_)); HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities(); hmi_capabilities.set_handle_response_for(*get_language); - application_manager_.ManageHMICommand(get_language); + application_manager_.GetRPCService().ManageHMICommand(get_language); utils::SharedPtr<smart_objects::SmartObject> get_all_languages( MessageHelper::CreateModuleInfoSO( hmi_apis::FunctionID::UI_GetSupportedLanguages, application_manager_)); - application_manager_.ManageHMICommand(get_all_languages); + application_manager_.GetRPCService().ManageHMICommand(get_all_languages); utils::SharedPtr<smart_objects::SmartObject> get_capabilities( MessageHelper::CreateModuleInfoSO( hmi_apis::FunctionID::UI_GetCapabilities, application_manager_)); - application_manager_.ManageHMICommand(get_capabilities); + application_manager_.GetRPCService().ManageHMICommand(get_capabilities); } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/update_sdl_response.cc b/src/components/application_manager/src/commands/hmi/update_sdl_response.cc index 0e8978fe89..f8fa188735 100644 --- a/src/components/application_manager/src/commands/hmi/update_sdl_response.cc +++ b/src/components/application_manager/src/commands/hmi/update_sdl_response.cc @@ -30,6 +30,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include "application_manager/commands/hmi/update_sdl_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -46,7 +47,7 @@ void UpdateSDLResponse::Run() { (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; (*message_)[strings::params][strings::protocol_version] = protocol_version_; - application_manager_.SendMessageToHMI(message_); + application_manager_.GetRPCService().SendMessageToHMI(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/vi_is_ready_request.cc b/src/components/application_manager/src/commands/hmi/vi_is_ready_request.cc index ddd08695a0..4d9f30baaa 100644 --- a/src/components/application_manager/src/commands/hmi/vi_is_ready_request.cc +++ b/src/components/application_manager/src/commands/hmi/vi_is_ready_request.cc @@ -31,6 +31,7 @@ */ #include "application_manager/commands/hmi/vi_is_ready_request.h" +#include "application_manager/rpc_service.h" #include "application_manager/message_helper.h" namespace application_manager { @@ -95,7 +96,7 @@ void VIIsReadyRequest::SendMessageToHMI() { MessageHelper::CreateModuleInfoSO( hmi_apis::FunctionID::VehicleInfo_GetVehicleType, application_manager_)); - application_manager_.ManageHMICommand(get_type); + application_manager_.GetRPCService().ManageHMICommand(get_type); } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/vr_is_ready_request.cc b/src/components/application_manager/src/commands/hmi/vr_is_ready_request.cc index 086b5d4490..a1509b153f 100644 --- a/src/components/application_manager/src/commands/hmi/vr_is_ready_request.cc +++ b/src/components/application_manager/src/commands/hmi/vr_is_ready_request.cc @@ -31,6 +31,7 @@ */ #include "application_manager/commands/hmi/vr_is_ready_request.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -89,16 +90,16 @@ void VRIsReadyRequest::SendMessageToHMI() { application_manager_)); HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities(); hmi_capabilities.set_handle_response_for(*get_language); - application_manager_.ManageHMICommand(get_language); + application_manager_.GetRPCService().ManageHMICommand(get_language); utils::SharedPtr<smart_objects::SmartObject> get_all_languages( MessageHelper::CreateModuleInfoSO( hmi_apis::FunctionID::VR_GetSupportedLanguages, application_manager_)); - application_manager_.ManageHMICommand(get_all_languages); + application_manager_.GetRPCService().ManageHMICommand(get_all_languages); utils::SharedPtr<smart_objects::SmartObject> get_capabilities( MessageHelper::CreateModuleInfoSO( hmi_apis::FunctionID::VR_GetCapabilities, application_manager_)); - application_manager_.ManageHMICommand(get_capabilities); + application_manager_.GetRPCService().ManageHMICommand(get_capabilities); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/add_command_response.cc b/src/components/application_manager/src/commands/mobile/add_command_response.cc index fc468f9c57..944b2883e8 100644 --- a/src/components/application_manager/src/commands/mobile/add_command_response.cc +++ b/src/components/application_manager/src/commands/mobile/add_command_response.cc @@ -32,6 +32,7 @@ */ #include "application_manager/commands/mobile/add_command_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -46,7 +47,7 @@ AddCommandResponse::~AddCommandResponse() {} void AddCommandResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/add_sub_menu_response.cc b/src/components/application_manager/src/commands/mobile/add_sub_menu_response.cc index 1fbdb4e66c..de8739d871 100644 --- a/src/components/application_manager/src/commands/mobile/add_sub_menu_response.cc +++ b/src/components/application_manager/src/commands/mobile/add_sub_menu_response.cc @@ -32,7 +32,7 @@ */ #include "application_manager/commands/mobile/add_sub_menu_response.h" - +#include "application_manager/rpc_service.h" #include "application_manager/application_impl.h" namespace application_manager { @@ -48,7 +48,7 @@ AddSubMenuResponse::~AddSubMenuResponse() {} void AddSubMenuResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/alert_maneuver_response.cc b/src/components/application_manager/src/commands/mobile/alert_maneuver_response.cc index 2f441594c2..852083e6ad 100644 --- a/src/components/application_manager/src/commands/mobile/alert_maneuver_response.cc +++ b/src/components/application_manager/src/commands/mobile/alert_maneuver_response.cc @@ -32,7 +32,7 @@ */ #include "application_manager/commands/mobile/alert_maneuver_response.h" - +#include "application_manager/rpc_service.h" #include "interfaces/HMI_API.h" namespace application_manager { @@ -48,7 +48,7 @@ AlertManeuverResponse::~AlertManeuverResponse() {} void AlertManeuverResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/alert_response.cc b/src/components/application_manager/src/commands/mobile/alert_response.cc index f8ca487eae..3b9e67fefa 100644 --- a/src/components/application_manager/src/commands/mobile/alert_response.cc +++ b/src/components/application_manager/src/commands/mobile/alert_response.cc @@ -32,7 +32,7 @@ */ #include "application_manager/commands/mobile/alert_response.h" - +#include "application_manager/rpc_service.h" #include "application_manager/application_impl.h" #include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" @@ -50,7 +50,7 @@ AlertResponse::~AlertResponse() {} void AlertResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/change_registration_response.cc b/src/components/application_manager/src/commands/mobile/change_registration_response.cc index 210cae64c5..77c063ac9d 100644 --- a/src/components/application_manager/src/commands/mobile/change_registration_response.cc +++ b/src/components/application_manager/src/commands/mobile/change_registration_response.cc @@ -32,6 +32,7 @@ */ #include "application_manager/commands/mobile/change_registration_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -46,7 +47,7 @@ ChangeRegistrationResponse::~ChangeRegistrationResponse() {} void ChangeRegistrationResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/delete_command_response.cc b/src/components/application_manager/src/commands/mobile/delete_command_response.cc index 7abc1c11d4..bbcdcfe57f 100644 --- a/src/components/application_manager/src/commands/mobile/delete_command_response.cc +++ b/src/components/application_manager/src/commands/mobile/delete_command_response.cc @@ -32,6 +32,7 @@ */ #include "application_manager/commands/mobile/delete_command_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -46,7 +47,7 @@ DeleteCommandResponse::~DeleteCommandResponse() {} void DeleteCommandResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/delete_sub_menu_response.cc b/src/components/application_manager/src/commands/mobile/delete_sub_menu_response.cc index ad9d2ad858..06a63c5bf5 100644 --- a/src/components/application_manager/src/commands/mobile/delete_sub_menu_response.cc +++ b/src/components/application_manager/src/commands/mobile/delete_sub_menu_response.cc @@ -32,6 +32,7 @@ */ #include "application_manager/commands/mobile/delete_sub_menu_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -46,7 +47,7 @@ DeleteSubMenuResponse::~DeleteSubMenuResponse() {} void DeleteSubMenuResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/diagnostic_message_response.cc b/src/components/application_manager/src/commands/mobile/diagnostic_message_response.cc index 8c59a97a8b..28c8fa512c 100644 --- a/src/components/application_manager/src/commands/mobile/diagnostic_message_response.cc +++ b/src/components/application_manager/src/commands/mobile/diagnostic_message_response.cc @@ -32,6 +32,7 @@ */ #include "application_manager/commands/mobile/diagnostic_message_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -46,7 +47,7 @@ DiagnosticMessageResponse::~DiagnosticMessageResponse() {} void DiagnosticMessageResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/dial_number_response.cc b/src/components/application_manager/src/commands/mobile/dial_number_response.cc index 750dcf25c4..ee9bbd0e08 100644 --- a/src/components/application_manager/src/commands/mobile/dial_number_response.cc +++ b/src/components/application_manager/src/commands/mobile/dial_number_response.cc @@ -31,6 +31,7 @@ */ #include "application_manager/commands/mobile/dial_number_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -45,7 +46,7 @@ DialNumberResponse::~DialNumberResponse() {} void DialNumberResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_response.cc b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_response.cc index bb477f5083..ca52aeee65 100644 --- a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_response.cc +++ b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_response.cc @@ -32,6 +32,7 @@ */ #include "application_manager/commands/mobile/end_audio_pass_thru_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -46,7 +47,7 @@ EndAudioPassThruResponse::~EndAudioPassThruResponse() {} void EndAudioPassThruResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/get_dtcs_response.cc b/src/components/application_manager/src/commands/mobile/get_dtcs_response.cc index ecaf5c3d8f..a8111b5e6e 100644 --- a/src/components/application_manager/src/commands/mobile/get_dtcs_response.cc +++ b/src/components/application_manager/src/commands/mobile/get_dtcs_response.cc @@ -32,6 +32,7 @@ */ #include "application_manager/commands/mobile/get_dtcs_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -46,7 +47,7 @@ GetDTCsResponse::~GetDTCsResponse() {} void GetDTCsResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/get_system_capability_response.cc b/src/components/application_manager/src/commands/mobile/get_system_capability_response.cc index 91c2562cd3..3ac0459e71 100644 --- a/src/components/application_manager/src/commands/mobile/get_system_capability_response.cc +++ b/src/components/application_manager/src/commands/mobile/get_system_capability_response.cc @@ -1,4 +1,5 @@ #include "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" #include "application_manager/commands/mobile/get_system_capability_response.h" namespace application_manager { @@ -14,7 +15,7 @@ GetSystemCapabilityResponse::~GetSystemCapabilityResponse() {} void GetSystemCapabilityResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/get_vehicle_data_response.cc b/src/components/application_manager/src/commands/mobile/get_vehicle_data_response.cc index 1e64746262..700c8adffb 100644 --- a/src/components/application_manager/src/commands/mobile/get_vehicle_data_response.cc +++ b/src/components/application_manager/src/commands/mobile/get_vehicle_data_response.cc @@ -32,7 +32,7 @@ */ #include "application_manager/commands/mobile/get_vehicle_data_response.h" - +#include "application_manager/rpc_service.h" #include "interfaces/HMI_API.h" namespace application_manager { @@ -48,7 +48,7 @@ GetVehicleDataResponse::~GetVehicleDataResponse() {} void GetVehicleDataResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/get_way_points_response.cc b/src/components/application_manager/src/commands/mobile/get_way_points_response.cc index 7956b34cae..92e7720d8a 100644 --- a/src/components/application_manager/src/commands/mobile/get_way_points_response.cc +++ b/src/components/application_manager/src/commands/mobile/get_way_points_response.cc @@ -1,5 +1,6 @@ #include "application_manager/application_manager.h" #include "application_manager/commands/mobile/get_way_points_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -14,7 +15,7 @@ GetWayPointsResponse::~GetWayPointsResponse() {} void GetWayPointsResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/list_files_response.cc b/src/components/application_manager/src/commands/mobile/list_files_response.cc index fde15a94ef..0b07605874 100644 --- a/src/components/application_manager/src/commands/mobile/list_files_response.cc +++ b/src/components/application_manager/src/commands/mobile/list_files_response.cc @@ -32,7 +32,7 @@ */ #include "application_manager/commands/mobile/list_files_response.h" - +#include "application_manager/rpc_service.h" #include "application_manager/application_impl.h" namespace application_manager { @@ -48,7 +48,7 @@ ListFilesResponse::~ListFilesResponse() {} void ListFilesResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_response.cc b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_response.cc index e8a638c076..1bda9f5096 100644 --- a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_response.cc +++ b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_response.cc @@ -32,6 +32,7 @@ */ #include "application_manager/commands/mobile/perform_audio_pass_thru_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -46,7 +47,7 @@ PerformAudioPassThruResponse::~PerformAudioPassThruResponse() {} void PerformAudioPassThruResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/perform_interaction_response.cc b/src/components/application_manager/src/commands/mobile/perform_interaction_response.cc index 6003751669..1a358e551c 100644 --- a/src/components/application_manager/src/commands/mobile/perform_interaction_response.cc +++ b/src/components/application_manager/src/commands/mobile/perform_interaction_response.cc @@ -32,6 +32,7 @@ */ #include "application_manager/commands/mobile/perform_interaction_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -46,7 +47,7 @@ PerformInteractionResponse::~PerformInteractionResponse() {} void PerformInteractionResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/put_file_request.cc b/src/components/application_manager/src/commands/mobile/put_file_request.cc index 269c9c814e..8a5e10b206 100644 --- a/src/components/application_manager/src/commands/mobile/put_file_request.cc +++ b/src/components/application_manager/src/commands/mobile/put_file_request.cc @@ -36,6 +36,7 @@ #include "application_manager/policies/policy_handler.h" #include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" #include "utils/file_system.h" #include <boost/crc.hpp> @@ -309,7 +310,7 @@ void PutFileRequest::SendOnPutFileNotification() { message[strings::msg_params][strings::length] = length_; message[strings::msg_params][strings::persistent_file] = is_persistent_file_; message[strings::msg_params][strings::file_type] = file_type_; - application_manager_.ManageHMICommand(notification); + application_manager_.GetRPCService().ManageHMICommand(notification); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/read_did_response.cc b/src/components/application_manager/src/commands/mobile/read_did_response.cc index e54c4ba005..f3cdc971aa 100644 --- a/src/components/application_manager/src/commands/mobile/read_did_response.cc +++ b/src/components/application_manager/src/commands/mobile/read_did_response.cc @@ -32,6 +32,7 @@ */ #include "application_manager/commands/mobile/read_did_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -46,7 +47,7 @@ ReadDIDResponse::~ReadDIDResponse() {} void ReadDIDResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index ff0d0d3622..41edfad205 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc @@ -47,6 +47,7 @@ #include "application_manager/resumption/resume_ctrl.h" #include "application_manager/policies/policy_handler.h" #include "application_manager/helpers/application_helper.h" +#include "application_manager/rpc_service.h" #include "config_profile/profile.h" #include "interfaces/MOBILE_API.h" #include "interfaces/generated_msg_version.h" @@ -396,7 +397,8 @@ void RegisterAppInterfaceRequest::Run() { SendRegisterAppInterfaceResponseToMobile(ApplicationType::kNewApplication); smart_objects::SmartObjectSPtr so = GetLockScreenIconUrlNotification(connection_key(), application); - application_manager_.ManageMobileCommand(so, commands::Command::ORIGIN_SDL); + application_manager_.GetRPCService().ManageMobileCommand( + so, commands::Command::ORIGIN_SDL); } smart_objects::SmartObjectSPtr @@ -968,7 +970,7 @@ void RegisterAppInterfaceRequest::SendOnAppRegisteredNotificationToHMI( application[strings::night_color_scheme] = *night_color_scheme; } - DCHECK(application_manager_.ManageHMICommand(notification)); + DCHECK(application_manager_.GetRPCService().ManageHMICommand(notification)); } mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence() { diff --git a/src/components/application_manager/src/commands/mobile/reset_global_properties_response.cc b/src/components/application_manager/src/commands/mobile/reset_global_properties_response.cc index c621977868..abee868769 100644 --- a/src/components/application_manager/src/commands/mobile/reset_global_properties_response.cc +++ b/src/components/application_manager/src/commands/mobile/reset_global_properties_response.cc @@ -32,6 +32,7 @@ */ #include "application_manager/commands/mobile/reset_global_properties_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -46,7 +47,7 @@ ResetGlobalPropertiesResponse::~ResetGlobalPropertiesResponse() {} void ResetGlobalPropertiesResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/scrollable_message_response.cc b/src/components/application_manager/src/commands/mobile/scrollable_message_response.cc index a5b16bdb70..d6c786b1ee 100644 --- a/src/components/application_manager/src/commands/mobile/scrollable_message_response.cc +++ b/src/components/application_manager/src/commands/mobile/scrollable_message_response.cc @@ -32,7 +32,7 @@ */ #include "application_manager/commands/mobile/scrollable_message_response.h" - +#include "application_manager/rpc_service.h" #include "interfaces/HMI_API.h" #include "interfaces/MOBILE_API.h" @@ -55,7 +55,7 @@ void ScrollableMessageResponse::Run() { application->UnsubscribeFromSoftButtons( (*message_)[strings::params][strings::function_id].asInt()); } - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/send_haptic_data_response.cc b/src/components/application_manager/src/commands/mobile/send_haptic_data_response.cc index c8649d34af..9860f89065 100644 --- a/src/components/application_manager/src/commands/mobile/send_haptic_data_response.cc +++ b/src/components/application_manager/src/commands/mobile/send_haptic_data_response.cc @@ -31,6 +31,7 @@ */ #include "application_manager/commands/mobile/send_haptic_data_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -45,7 +46,7 @@ SendHapticDataResponse::~SendHapticDataResponse() {} void SendHapticDataResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/send_location_response.cc b/src/components/application_manager/src/commands/mobile/send_location_response.cc index 167642e390..3968e566e3 100644 --- a/src/components/application_manager/src/commands/mobile/send_location_response.cc +++ b/src/components/application_manager/src/commands/mobile/send_location_response.cc @@ -32,7 +32,7 @@ */ #include "application_manager/commands/mobile/send_location_response.h" - +#include "application_manager/rpc_service.h" #include "application_manager/application_impl.h" #include "interfaces/HMI_API.h" @@ -49,7 +49,7 @@ SendLocationResponse::~SendLocationResponse() {} void SendLocationResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/set_app_icon_response.cc b/src/components/application_manager/src/commands/mobile/set_app_icon_response.cc index 29f3950ffc..57e4f5600d 100644 --- a/src/components/application_manager/src/commands/mobile/set_app_icon_response.cc +++ b/src/components/application_manager/src/commands/mobile/set_app_icon_response.cc @@ -32,6 +32,7 @@ */ #include "application_manager/commands/mobile/set_app_icon_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -46,7 +47,7 @@ SetAppIconResponse::~SetAppIconResponse() {} void SetAppIconResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/set_display_layout_response.cc b/src/components/application_manager/src/commands/mobile/set_display_layout_response.cc index b5e53803c8..fe5c73dd7d 100644 --- a/src/components/application_manager/src/commands/mobile/set_display_layout_response.cc +++ b/src/components/application_manager/src/commands/mobile/set_display_layout_response.cc @@ -33,6 +33,7 @@ #include "application_manager/commands/mobile/set_display_layout_response.h" #include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -47,7 +48,7 @@ SetDisplayLayoutResponse::~SetDisplayLayoutResponse() {} void SetDisplayLayoutResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/set_global_properties_response.cc b/src/components/application_manager/src/commands/mobile/set_global_properties_response.cc index 5cfbcb2d58..cea090f35b 100644 --- a/src/components/application_manager/src/commands/mobile/set_global_properties_response.cc +++ b/src/components/application_manager/src/commands/mobile/set_global_properties_response.cc @@ -32,6 +32,7 @@ */ #include "application_manager/commands/mobile/set_global_properties_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -46,7 +47,7 @@ SetGlobalPropertiesResponse::~SetGlobalPropertiesResponse() {} void SetGlobalPropertiesResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/set_icon_response.cc b/src/components/application_manager/src/commands/mobile/set_icon_response.cc index c140d04f51..524d4e3ad9 100644 --- a/src/components/application_manager/src/commands/mobile/set_icon_response.cc +++ b/src/components/application_manager/src/commands/mobile/set_icon_response.cc @@ -33,6 +33,7 @@ #include "application_manager/commands/mobile/set_icon_response.h" #include "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -47,7 +48,7 @@ SetIconResponse::~SetIconResponse() {} void SetIconResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/set_media_clock_timer_response.cc b/src/components/application_manager/src/commands/mobile/set_media_clock_timer_response.cc index 30e802a1db..d189891888 100644 --- a/src/components/application_manager/src/commands/mobile/set_media_clock_timer_response.cc +++ b/src/components/application_manager/src/commands/mobile/set_media_clock_timer_response.cc @@ -32,6 +32,7 @@ */ #include "application_manager/commands/mobile/set_media_clock_timer_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -46,7 +47,7 @@ SetMediaClockTimerResponse::~SetMediaClockTimerResponse() {} void SetMediaClockTimerResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/show_constant_tbt_response.cc b/src/components/application_manager/src/commands/mobile/show_constant_tbt_response.cc index 80a36129cf..d2cdc1689a 100644 --- a/src/components/application_manager/src/commands/mobile/show_constant_tbt_response.cc +++ b/src/components/application_manager/src/commands/mobile/show_constant_tbt_response.cc @@ -32,7 +32,7 @@ */ #include "application_manager/commands/mobile/show_constant_tbt_response.h" - +#include "application_manager/rpc_service.h" #include "interfaces/HMI_API.h" namespace application_manager { @@ -49,7 +49,7 @@ ShowConstantTBTResponse::~ShowConstantTBTResponse() {} void ShowConstantTBTResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/show_response.cc b/src/components/application_manager/src/commands/mobile/show_response.cc index 8027c908f1..b3a54ee2dd 100644 --- a/src/components/application_manager/src/commands/mobile/show_response.cc +++ b/src/components/application_manager/src/commands/mobile/show_response.cc @@ -32,7 +32,7 @@ */ #include "application_manager/commands/mobile/show_response.h" - +#include "application_manager/rpc_service.h" #include "application_manager/application_impl.h" #include "interfaces/HMI_API.h" @@ -49,7 +49,7 @@ ShowResponse::~ShowResponse() {} void ShowResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/slider_response.cc b/src/components/application_manager/src/commands/mobile/slider_response.cc index 2cfcaf48fd..4664689f0c 100644 --- a/src/components/application_manager/src/commands/mobile/slider_response.cc +++ b/src/components/application_manager/src/commands/mobile/slider_response.cc @@ -32,6 +32,7 @@ */ #include "application_manager/commands/mobile/slider_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -46,7 +47,7 @@ SliderResponse::~SliderResponse() {} void SliderResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/speak_response.cc b/src/components/application_manager/src/commands/mobile/speak_response.cc index 612d32c913..59b327e009 100644 --- a/src/components/application_manager/src/commands/mobile/speak_response.cc +++ b/src/components/application_manager/src/commands/mobile/speak_response.cc @@ -32,7 +32,7 @@ */ #include "application_manager/commands/mobile/speak_response.h" - +#include "application_manager/rpc_service.h" #include "application_manager/application_impl.h" #include "interfaces/HMI_API.h" @@ -49,7 +49,7 @@ SpeakResponse::~SpeakResponse() {} void SpeakResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_response.cc b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_response.cc index 7ed16407a5..2f2ddc5acf 100644 --- a/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_response.cc +++ b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_response.cc @@ -32,7 +32,7 @@ */ #include "application_manager/commands/mobile/subscribe_vehicle_data_response.h" - +#include "application_manager/rpc_service.h" #include "application_manager/application_impl.h" #include "interfaces/MOBILE_API.h" @@ -47,7 +47,7 @@ SubscribeVehicleDataResponse::~SubscribeVehicleDataResponse() {} void SubscribeVehicleDataResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/subscribe_way_points_response.cc b/src/components/application_manager/src/commands/mobile/subscribe_way_points_response.cc index c2e642619a..8e1e203e52 100644 --- a/src/components/application_manager/src/commands/mobile/subscribe_way_points_response.cc +++ b/src/components/application_manager/src/commands/mobile/subscribe_way_points_response.cc @@ -1,4 +1,5 @@ #include "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" #include "application_manager/commands/mobile/subscribe_way_points_response.h" namespace application_manager { @@ -14,7 +15,7 @@ SubscribeWayPointsResponse::~SubscribeWayPointsResponse() {} void SubscribeWayPointsResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/system_response.cc b/src/components/application_manager/src/commands/mobile/system_response.cc index f5bc03f4a5..0d994bb190 100644 --- a/src/components/application_manager/src/commands/mobile/system_response.cc +++ b/src/components/application_manager/src/commands/mobile/system_response.cc @@ -32,6 +32,7 @@ */ #include "application_manager/commands/mobile/system_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -46,7 +47,7 @@ SystemResponse::~SystemResponse() {} void SystemResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc index d40ad9c870..10cb54a8a1 100644 --- a/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc @@ -32,7 +32,7 @@ */ #include "application_manager/commands/mobile/unregister_app_interface_request.h" - +#include "application_manager/rpc_service.h" #include "application_manager/message_helper.h" namespace application_manager { @@ -48,7 +48,7 @@ void UnregisterAppInterfaceRequest::Run() { return; } - application_manager_.ManageMobileCommand( + application_manager_.GetRPCService().ManageMobileCommand( MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( connection_key(), mobile_api::AppInterfaceUnregisteredReason::INVALID_ENUM), diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_response.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_response.cc index f6430d1f0d..843a2fd5f0 100644 --- a/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_response.cc +++ b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_response.cc @@ -1,5 +1,6 @@ #include "application_manager/application_manager.h" #include "application_manager/commands/mobile/unsubscribe_way_points_response.h" +#include "application_manager/rpc_service.h" namespace application_manager { @@ -14,7 +15,7 @@ UnsubscribeWayPointsResponse::~UnsubscribeWayPointsResponse() {} void UnsubscribeWayPointsResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/update_turn_list_response.cc b/src/components/application_manager/src/commands/mobile/update_turn_list_response.cc index d40a4546fc..ca5e8c1b34 100644 --- a/src/components/application_manager/src/commands/mobile/update_turn_list_response.cc +++ b/src/components/application_manager/src/commands/mobile/update_turn_list_response.cc @@ -32,7 +32,7 @@ */ #include "application_manager/commands/mobile/update_turn_list_response.h" - +#include "application_manager/rpc_service.h" #include "interfaces/HMI_API.h" namespace application_manager { @@ -48,7 +48,7 @@ UpdateTurnListResponse::~UpdateTurnListResponse() {} void UpdateTurnListResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.SendMessageToMobile(message_); + application_manager_.GetRPCService().SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/core_service.cc b/src/components/application_manager/src/core_service.cc index 2a96502cde..61e510696e 100644 --- a/src/components/application_manager/src/core_service.cc +++ b/src/components/application_manager/src/core_service.cc @@ -34,6 +34,7 @@ #include <algorithm> #include "application_manager/core_service.h" #include "application_manager/application_manager_impl.h" +#include "application_manager/rpc_service.h" #include "application_manager/policies/policy_handler.h" #include "application_manager/message_helper.h" #include "json/json.h" @@ -126,11 +127,11 @@ ApplicationSharedPtr CoreService::GetApplication(ApplicationId app_id) { } void CoreService::SendMessageToHMI(const MessagePtr& message) { - application_manager_.SendPostMessageToHMI(message); + application_manager_.GetRPCService().SendPostMessageToHMI(message); } void CoreService::SendMessageToMobile(const MessagePtr& message) { - application_manager_.SendPostMessageToMobile(message); + application_manager_.GetRPCService().SendPostMessageToMobile(message); } uint32_t CoreService::GetNextCorrelationID() { diff --git a/src/components/application_manager/src/hmi_language_handler.cc b/src/components/application_manager/src/hmi_language_handler.cc index 4e5390a1b4..08ce26360e 100644 --- a/src/components/application_manager/src/hmi_language_handler.cc +++ b/src/components/application_manager/src/hmi_language_handler.cc @@ -33,6 +33,7 @@ #include "application_manager/hmi_language_handler.h" #include "application_manager/application_manager.h" #include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" #include "application_manager/hmi_capabilities.h" #include "utils/helpers.h" #include "resumption/last_state.h" @@ -236,8 +237,8 @@ void HMILanguageHandler::SendOnLanguageChangeToMobile( hmi_capabilities.active_ui_language(); message[strings::msg_params][strings::language] = hmi_capabilities.active_vr_language(); - if (application_manager_.ManageMobileCommand(notification, - commands::Command::ORIGIN_SDL)) { + if (application_manager_.GetRPCService().ManageMobileCommand( + notification, commands::Command::ORIGIN_SDL)) { LOG4CXX_INFO(logger_, "Mobile command sent"); } else { LOG4CXX_WARN(logger_, "Cannot send mobile command"); @@ -306,7 +307,7 @@ void HMILanguageHandler::HandleWrongLanguageApp(const Apps::value_type& app) { } } SendOnLanguageChangeToMobile(app.first); - application_manager_.ManageMobileCommand( + application_manager_.GetRPCService().ManageMobileCommand( MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( app.first, mobile_api::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE), diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index b854d83c6e..5eaa5a10fa 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -53,6 +53,7 @@ #include "application_manager/message_helper.h" #include "application_manager/policies/policy_handler_interface.h" #include "application_manager/resumption/resume_ctrl.h" +#include "application_manager/rpc_service.h" #include "connection_handler/connection_handler_impl.h" #include "transport_manager/common.h" #include "interfaces/MOBILE_API.h" @@ -365,7 +366,7 @@ void MessageHelper::SendDecryptCertificateToHMI(const std::string& file_name, msg_params[hmi_request::file_name] = file_name; object[strings::msg_params] = msg_params; - app_mngr.ManageHMICommand(message); + app_mngr.GetRPCService().ManageHMICommand(message); } void MessageHelper::SendGetSystemTimeRequest(const uint32_t correlation_id, @@ -392,7 +393,8 @@ void MessageHelper::SendHashUpdateNotification(const uint32_t app_id, } smart_objects::SmartObjectSPtr so = CreateHashUpdateNotification(app_id); PrintSmartObject(*so); - if (!app_mngr.ManageMobileCommand(so, commands::Command::ORIGIN_SDL)) { + if (!app_mngr.GetRPCService().ManageMobileCommand( + so, commands::Command::ORIGIN_SDL)) { LOG4CXX_ERROR(logger_, "Failed to send HashUpdate notification."); return; } @@ -444,7 +446,7 @@ void MessageHelper::SendDeleteCommandRequest(smart_objects::SmartObject* cmd, object[strings::msg_params] = msg_params; - app_mngr.ManageHMICommand(message); + app_mngr.GetRPCService().ManageHMICommand(message); } if ((*cmd).keyExists(strings::vr_commands)) { @@ -461,7 +463,7 @@ void MessageHelper::SendDeleteCommandRequest(smart_objects::SmartObject* cmd, object[strings::msg_params] = msg_params; - app_mngr.ManageHMICommand(message); + app_mngr.GetRPCService().ManageHMICommand(message); } } @@ -487,7 +489,7 @@ void MessageHelper::SendDeleteSubmenuRequest(smart_objects::SmartObject* cmd, object[strings::msg_params] = msg_params; - app_mngr.ManageHMICommand(message); + app_mngr.GetRPCService().ManageHMICommand(message); const DataAccessor<CommandsMap> accessor = application->commands_map(); const CommandsMap& commands = accessor.GetData(); @@ -516,7 +518,7 @@ void MessageHelper::SendDeleteSubmenuRequest(smart_objects::SmartObject* cmd, object[strings::msg_params] = msg_params; - app_mngr.ManageHMICommand(message); + app_mngr.GetRPCService().ManageHMICommand(message); } } } @@ -549,7 +551,7 @@ void MessageHelper::SendDeleteChoiceSetRequest(smart_objects::SmartObject* cmd, object[strings::msg_params] = msg_params; - app_mngr.ManageHMICommand(message); + app_mngr.GetRPCService().ManageHMICommand(message); } } @@ -586,7 +588,7 @@ void MessageHelper::SendResetPropertiesRequest(ApplicationSharedPtr application, object[strings::msg_params] = msg_params; - app_mngr.ManageHMICommand(message); + app_mngr.GetRPCService().ManageHMICommand(message); } { @@ -606,7 +608,7 @@ void MessageHelper::SendResetPropertiesRequest(ApplicationSharedPtr application, object[strings::msg_params] = msg_params; - app_mngr.ManageHMICommand(message); + app_mngr.GetRPCService().ManageHMICommand(message); } } @@ -632,7 +634,7 @@ void MessageHelper::SendUnsubscribeButtonNotification( object[strings::msg_params] = msg_params; - app_mngr.ManageHMICommand(message); + app_mngr.GetRPCService().ManageHMICommand(message); } void MessageHelper::SendUnsubscribeIVIRequest(int32_t ivi_id, @@ -666,7 +668,7 @@ void MessageHelper::SendUnsubscribeIVIRequest(int32_t ivi_id, object[strings::msg_params] = msg_params; - app_mngr.ManageHMICommand(message); + app_mngr.GetRPCService().ManageHMICommand(message); } const VehicleData& MessageHelper::vehicle_data() { @@ -765,8 +767,8 @@ void MessageHelper::SendHMIStatusNotification( message[strings::msg_params][strings::system_context] = static_cast<int32_t>(application_impl.system_context()); - application_manager.ManageMobileCommand(notification, - commands::Command::ORIGIN_SDL); + application_manager.GetRPCService().ManageMobileCommand( + notification, commands::Command::ORIGIN_SDL); } void MessageHelper::SendActivateAppToHMI( @@ -820,7 +822,7 @@ void MessageHelper::SendActivateAppToHMI( (*message)[strings::msg_params][strings::activate_app_hmi_level] = level; } - application_manager.ManageHMICommand(message); + application_manager.GetRPCService().ManageHMICommand(message); } #endif // SDL_REMOTE_CONTROL @@ -953,7 +955,7 @@ void MessageHelper::CreateGetVehicleDataRequest( commands::CommandImpl::hmi_protocol_type_; (*request)[strings::params][strings::function_id] = static_cast<int>(vehicle_data_args[*it]); - app_mngr.ManageHMICommand(request); + app_mngr.GetRPCService().ManageHMICommand(request); } #else @@ -976,7 +978,7 @@ void MessageHelper::CreateGetVehicleDataRequest( it++) { (*request)[strings::msg_params][*it] = true; } - app_mngr.ManageHMICommand(request); + app_mngr.GetRPCService().ManageHMICommand(request); #endif } @@ -1100,7 +1102,7 @@ bool MessageHelper::SendIVISubscriptions(const uint32_t app_id, for (smart_objects::SmartObjectList::const_iterator it = requests.begin(); it != requests.end(); ++it) { - if (!app_mngr.ManageHMICommand(*it)) { + if (!app_mngr.GetRPCService().ManageHMICommand(*it)) { result = false; } } @@ -1188,7 +1190,7 @@ void MessageHelper::SendOnButtonSubscriptionNotification( hmi_apis::FunctionID::Buttons_OnButtonSubscription; notification[strings::msg_params] = msg_params; - if (!app_mngr.ManageHMICommand(notification_ptr)) { + if (!app_mngr.GetRPCService().ManageHMICommand(notification_ptr)) { LOG4CXX_ERROR(logger_, "Unable to send HMI notification"); } } @@ -1240,7 +1242,7 @@ void MessageHelper::SendSetAppIcon( if (msg_params) { so_to_send[strings::msg_params] = *msg_params; } - application_manager.ManageHMICommand(set_app_icon); + application_manager.GetRPCService().ManageHMICommand(set_app_icon); } } @@ -1266,7 +1268,7 @@ void MessageHelper::SendGlobalPropertiesToHMI(ApplicationConstSharedPtr app, for (smart_objects::SmartObjectList::const_iterator it = requests.begin(); it != requests.end(); ++it) { - DCHECK(app_mngr.ManageHMICommand(*it)); + DCHECK(app_mngr.GetRPCService().ManageHMICommand(*it)); } } @@ -1385,7 +1387,7 @@ void MessageHelper::SendTTSGlobalProperties(ApplicationSharedPtr app, app->set_help_prompt(msg_params[strings::help_prompt]); msg_params[strings::app_id] = app->app_id(); so_to_send[strings::msg_params] = msg_params; - app_man.ManageHMICommand(tts_global_properties); + app_man.GetRPCService().ManageHMICommand(tts_global_properties); } } @@ -1453,7 +1455,7 @@ void MessageHelper::SendShowRequestToHMI(ApplicationConstSharedPtr app, for (smart_objects::SmartObjectList::const_iterator it = shows.begin(); it != shows.end(); ++it) { - DCHECK(app_mngr.ManageHMICommand(*it)); + DCHECK(app_mngr.GetRPCService().ManageHMICommand(*it)); } } @@ -1473,7 +1475,7 @@ void MessageHelper::SendShowConstantTBTRequestToHMI( static_cast<int>(hmi_apis::FunctionID::Navigation_ShowConstantTBT); (*navi_show_tbt)[strings::msg_params] = (*app->tbt_show_command()); - DCHECK(app_man.ManageHMICommand(navi_show_tbt)); + DCHECK(app_man.GetRPCService().ManageHMICommand(navi_show_tbt)); } } @@ -1487,7 +1489,7 @@ void MessageHelper::SendAddCommandRequestToHMI(ApplicationConstSharedPtr app, for (smart_objects::SmartObjectList::iterator it = requests.begin(); it != requests.end(); ++it) { - DCHECK(app_man.ManageHMICommand(*it)); + DCHECK(app_man.GetRPCService().ManageHMICommand(*it)); } } @@ -1629,7 +1631,7 @@ void MessageHelper::SendUIChangeRegistrationRequestToHMI( app_mngr); if (ui_command) { - app_mngr.ManageHMICommand(ui_command); + app_mngr.GetRPCService().ManageHMICommand(ui_command); } } } @@ -1641,7 +1643,7 @@ void MessageHelper::SendAddVRCommandToHMI( ApplicationManager& app_mngr) { smart_objects::SmartObjectSPtr request = CreateAddVRCommandToHMI(cmd_id, vr_commands, app_id, app_mngr); - DCHECK(app_mngr.ManageHMICommand(request)); + DCHECK(app_mngr.GetRPCService().ManageHMICommand(request)); } smart_objects::SmartObjectSPtr MessageHelper::CreateAddVRCommandToHMI( @@ -1768,7 +1770,7 @@ void MessageHelper::SendAddSubMenuRequestToHMI(ApplicationConstSharedPtr app, for (smart_objects::SmartObjectList::iterator it = requests.begin(); it != requests.end(); ++it) { - DCHECK(app_mngr.ManageHMICommand(*it)); + DCHECK(app_mngr.GetRPCService().ManageHMICommand(*it)); } } @@ -1824,7 +1826,7 @@ void MessageHelper::SendOnAppUnregNotificationToHMI( message[strings::msg_params][strings::app_id] = app->hmi_app_id(); message[strings::msg_params][strings::unexpected_disconnect] = is_unexpected_disconnect; - app_mngr.ManageHMICommand(notification); + app_mngr.GetRPCService().ManageHMICommand(notification); } smart_objects::SmartObjectSPtr MessageHelper::GetBCActivateAppRequestToHMI( @@ -1893,7 +1895,7 @@ void MessageHelper::SendOnResumeAudioSourceToHMI(const uint32_t app_id, app_mngr.GetNextHMICorrelationID(); (*message)[strings::msg_params][strings::app_id] = app_id; - app_mngr.ManageHMICommand(message); + app_mngr.GetRPCService().ManageHMICommand(message); } void MessageHelper::SendSDLActivateAppResponse( @@ -1944,7 +1946,7 @@ void MessageHelper::SendSDLActivateAppResponse( hmi_apis::Common_Result::REJECTED; } - app_mngr.ManageHMICommand(message); + app_mngr.GetRPCService().ManageHMICommand(message); } void MessageHelper::SendOnSDLConsentNeeded( @@ -1962,7 +1964,7 @@ void MessageHelper::SendOnSDLConsentNeeded( device_info.device_mac_address; (*message)[strings::msg_params]["device"]["name"] = device_info.device_name; - app_man.ManageHMICommand(message); + app_man.GetRPCService().ManageHMICommand(message); } void MessageHelper::SendPolicyUpdate(const std::string& file_path, @@ -1982,7 +1984,7 @@ void MessageHelper::SendPolicyUpdate(const std::string& file_path, for (size_t i = 0; i < retries.size(); ++i) { object[strings::msg_params][hmi_request::retry][i] = retries[i]; } - app_mngr.ManageHMICommand(message); + app_mngr.GetRPCService().ManageHMICommand(message); } void MessageHelper::SendGetUserFriendlyMessageResponse( const std::vector<policy::UserFriendlyMessage>& msg, @@ -2003,7 +2005,7 @@ void MessageHelper::SendGetUserFriendlyMessageResponse( // If no any messages found - skip sending of "messages" param if (msg.empty()) { - app_mngr.ManageHMICommand(message); + app_mngr.GetRPCService().ManageHMICommand(message); return; } @@ -2048,7 +2050,7 @@ void MessageHelper::SendGetUserFriendlyMessageResponse( #endif // EXTERNAL_PROPRIETARY_MODE } - app_mngr.ManageHMICommand(message); + app_mngr.GetRPCService().ManageHMICommand(message); } #ifdef EXTERNAL_PROPRIETARY_MODE @@ -2092,7 +2094,7 @@ void MessageHelper::SendGetListOfPermissionsResponse( external_consent_status.end(), external_consent_status_appender); - app_mngr.ManageHMICommand(message); + app_mngr.GetRPCService().ManageHMICommand(message); } #else void MessageHelper::SendGetListOfPermissionsResponse( @@ -2121,7 +2123,7 @@ void MessageHelper::SendGetListOfPermissionsResponse( GroupsAppender groups_appender(allowed_functions_array); std::for_each(permissions.begin(), permissions.end(), groups_appender); - app_mngr.ManageHMICommand(message); + app_mngr.GetRPCService().ManageHMICommand(message); } #endif // EXTERNAL_PROPRIETARY_MODE @@ -2163,7 +2165,7 @@ void MessageHelper::SendNaviSetVideoConfig( (*request)[strings::msg_params][strings::app_id] = app_id; (*request)[strings::msg_params][strings::config] = video_params; - app_mngr.ManageHMICommand(request); + app_mngr.GetRPCService().ManageHMICommand(request); } void MessageHelper::SendNaviStartStream(const int32_t app_id, @@ -2202,7 +2204,7 @@ void MessageHelper::SendNaviStartStream(const int32_t app_id, (*start_stream)[strings::msg_params][strings::app_id] = app_id; (*start_stream)[strings::msg_params][strings::url] = url; - app_mngr.ManageHMICommand(start_stream); + app_mngr.GetRPCService().ManageHMICommand(start_stream); } void MessageHelper::SendNaviStopStream(const int32_t app_id, @@ -2219,7 +2221,7 @@ void MessageHelper::SendNaviStopStream(const int32_t app_id, (*stop_stream)[strings::msg_params][strings::app_id] = app_id; - app_mngr.ManageHMICommand(stop_stream); + app_mngr.GetRPCService().ManageHMICommand(stop_stream); } void MessageHelper::SendAudioStartStream(const int32_t app_id, @@ -2259,7 +2261,7 @@ void MessageHelper::SendAudioStartStream(const int32_t app_id, (*start_stream)[strings::msg_params][strings::app_id] = app_id; (*start_stream)[strings::msg_params][strings::url] = url; - DCHECK(app_mngr.ManageHMICommand(start_stream)); + DCHECK(app_mngr.GetRPCService().ManageHMICommand(start_stream)); } void MessageHelper::SendAudioStopStream(const int32_t app_id, @@ -2277,7 +2279,7 @@ void MessageHelper::SendAudioStopStream(const int32_t app_id, (*stop_stream)[strings::msg_params][strings::app_id] = app_id; - app_mngr.ManageHMICommand(stop_stream); + app_mngr.GetRPCService().ManageHMICommand(stop_stream); } void MessageHelper::SendOnDataStreaming( @@ -2309,7 +2311,7 @@ void MessageHelper::SendOnDataStreaming( (*notification)[strings::msg_params]["available"] = available; - app_mngr.ManageHMICommand(notification); + app_mngr.GetRPCService().ManageHMICommand(notification); } bool MessageHelper::SendStopAudioPathThru(ApplicationManager& app_mngr) { @@ -2321,7 +2323,7 @@ bool MessageHelper::SendStopAudioPathThru(ApplicationManager& app_mngr) { (*result)[strings::params][strings::function_id] = hmi_apis::FunctionID::UI_EndAudioPassThru; - return app_mngr.ManageHMICommand(result); + return app_mngr.GetRPCService().ManageHMICommand(result); } bool MessageHelper::SendUnsubscribedWayPoints(ApplicationManager& app_mngr) { @@ -2333,7 +2335,7 @@ bool MessageHelper::SendUnsubscribedWayPoints(ApplicationManager& app_mngr) { (*result)[strings::params][strings::function_id] = hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints; - return app_mngr.ManageHMICommand(result); + return app_mngr.GetRPCService().ManageHMICommand(result); } void MessageHelper::SendPolicySnapshotNotification( @@ -2382,7 +2384,7 @@ void MessageHelper::SendSystemRequestNotification( PrintSmartObject(content); #endif - DCHECK(app_mngr.ManageMobileCommand( + DCHECK(app_mngr.GetRPCService().ManageMobileCommand( utils::MakeShared<smart_objects::SmartObject>(content), commands::Command::ORIGIN_SDL)); } @@ -2550,7 +2552,7 @@ void MessageHelper::SendOnPermissionsChangeNotification( } } - app_mngr.ManageMobileCommand( + app_mngr.GetRPCService().ManageMobileCommand( utils::MakeShared<smart_objects::SmartObject>(content), commands::Command::ORIGIN_SDL); } @@ -2635,7 +2637,7 @@ void MessageHelper::SendOnAppPermissionsChangedNotification( request_subtypes_array; } - app_mngr.ManageHMICommand( + app_mngr.GetRPCService().ManageHMICommand( utils::MakeShared<smart_objects::SmartObject>(message)); } @@ -2657,7 +2659,7 @@ void MessageHelper::SendGetStatusUpdateResponse(const std::string& status, (*message)[strings::msg_params]["status"] = status; - app_mngr.ManageHMICommand(message); + app_mngr.GetRPCService().ManageHMICommand(message); } void MessageHelper::SendUpdateSDLResponse(const std::string& result, @@ -2676,7 +2678,7 @@ void MessageHelper::SendUpdateSDLResponse(const std::string& result, (*message)[strings::msg_params]["result"] = result; - app_mngr.ManageHMICommand(message); + app_mngr.GetRPCService().ManageHMICommand(message); } void MessageHelper::SendOnStatusUpdate(const std::string& status, @@ -2695,7 +2697,7 @@ void MessageHelper::SendOnStatusUpdate(const std::string& status, (*message)[strings::msg_params]["status"] = status; - app_mngr.ManageHMICommand(message); + app_mngr.GetRPCService().ManageHMICommand(message); } void MessageHelper::SendGetSystemInfoRequest(ApplicationManager& app_mngr) { @@ -2708,7 +2710,7 @@ void MessageHelper::SendGetSystemInfoRequest(ApplicationManager& app_mngr) { (*message)[strings::params][strings::function_id] = hmi_apis::FunctionID::BasicCommunication_GetSystemInfo; - app_mngr.ManageHMICommand(message); + app_mngr.GetRPCService().ManageHMICommand(message); } mobile_apis::Result::eType MessageHelper::VerifyImageFiles( @@ -3074,4 +3076,4 @@ bool MessageHelper::PrintSmartObject(const smart_objects::SmartObject& object) { return true; } -} // namespace application_manager
\ No newline at end of file +} // namespace application_manager diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 67658c2809..964e17d8a5 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -42,6 +42,7 @@ #include "application_manager/application_manager.h" #include "application_manager/state_controller.h" #include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" #include "policy/policy_manager_impl.h" #include "connection_handler/connection_handler.h" #include "utils/macro.h" @@ -1018,7 +1019,7 @@ void PolicyHandler::OnPendingPermissionChange( MessageHelper::SendOnAppPermissionsChangedNotification( app->app_id(), permissions, application_manager_); } - application_manager_.ManageMobileCommand( + application_manager_.GetRPCService().ManageMobileCommand( MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( app->app_id(), mobile_api::AppInterfaceUnregisteredReason::APP_UNAUTHORIZED), diff --git a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc index e3fd423970..157aff7704 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc @@ -35,6 +35,7 @@ #include <algorithm> #include "application_manager/application_manager.h" +#include "application_manager/rpc_service.h" #include "utils/file_system.h" #include "connection_handler/connection_handler_impl.h" @@ -743,7 +744,7 @@ bool ResumeCtrlImpl::ProcessHMIRequest(smart_objects::SmartObjectSPtr request, (*request)[strings::correlation_id].asInt(); subscribe_on_event(function_id, hmi_correlation_id); } - if (!application_manager_.ManageHMICommand(request)) { + if (!application_manager_.GetRPCService().ManageHMICommand(request)) { LOG4CXX_ERROR(logger_, "Unable to send request"); return false; } diff --git a/src/components/application_manager/src/rpc_service_impl.cc b/src/components/application_manager/src/rpc_service_impl.cc new file mode 100644 index 0000000000..a6c99c08ba --- /dev/null +++ b/src/components/application_manager/src/rpc_service_impl.cc @@ -0,0 +1,612 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * 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 Ford Motor Company 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. + */ + +#include "application_manager/rpc_service_impl.h" + +namespace application_manager { +namespace rpc_service { + +CREATE_LOGGERPTR_LOCAL(logger_, "RPCServiceImpl") +namespace formatters = NsSmartDeviceLink::NsJSONHandler::Formatters; +namespace jhs = NsSmartDeviceLink::NsJSONHandler::strings; + +RPCServiceImpl::RPCServiceImpl( + ApplicationManager& app_manager, + request_controller::RequestController& request_ctrl, + protocol_handler::ProtocolHandler* protocol_handler, + hmi_message_handler::HMIMessageHandler* hmi_handler) + : app_manager_(app_manager) + , request_ctrl_(request_ctrl) + , protocol_handler_(protocol_handler) + , hmi_handler_(hmi_handler) + , messages_to_mobile_("AM ToMobile", this) + , messages_to_hmi_("AM ToHMI", this) + , hmi_so_factory_(hmi_apis::HMI_API()) + , mobile_so_factory_(mobile_apis::MOBILE_API()) {} + +RPCServiceImpl::~RPCServiceImpl() {} + +bool RPCServiceImpl::ManageMobileCommand( + const commands::MessageSharedPtr message, + commands::Command::CommandOrigin origin) { + LOG4CXX_AUTO_TRACE(logger_); + + if (!message) { + LOG4CXX_WARN(logger_, "Null-pointer message received."); + return false; + } + + if (app_manager_.IsLowVoltage()) { + LOG4CXX_WARN(logger_, "Low Voltage is active"); + return false; + } +#ifdef DEBUG + MessageHelper::PrintSmartObject(*message); +#endif + + LOG4CXX_DEBUG(logger_, "Trying to create message in mobile factory."); + utils::SharedPtr<commands::Command> command( + MobileCommandFactory::CreateCommand(message, origin, app_manager_)); + + if (!command) { + LOG4CXX_WARN(logger_, + "RET Failed to create mobile command from smart object"); + return false; + } + + mobile_apis::FunctionID::eType function_id = + static_cast<mobile_apis::FunctionID::eType>( + (*message)[strings::params][strings::function_id].asInt()); + + // Notifications from HMI have no such parameter + uint32_t correlation_id = + (*message)[strings::params].keyExists(strings::correlation_id) + ? (*message)[strings::params][strings::correlation_id].asUInt() + : 0; + + uint32_t connection_key = + (*message)[strings::params][strings::connection_key].asUInt(); + + int32_t protocol_type = + (*message)[strings::params][strings::protocol_type].asInt(); + + ApplicationSharedPtr app; + if (((mobile_apis::FunctionID::RegisterAppInterfaceID != function_id) && + (protocol_type == commands::CommandImpl::mobile_protocol_type_)) && + (mobile_apis::FunctionID::UnregisterAppInterfaceID != function_id)) { + app = app_manager_.application(connection_key); + if (!app) { + LOG4CXX_ERROR(logger_, "RET APPLICATION_NOT_REGISTERED"); + smart_objects::SmartObjectSPtr response = + MessageHelper::CreateNegativeResponse( + connection_key, + static_cast<int32_t>(function_id), + correlation_id, + static_cast<int32_t>( + mobile_apis::Result::APPLICATION_NOT_REGISTERED)); + + SendMessageToMobile(response); + return false; + } + + // Message for "CheckPermission" must be with attached schema + mobile_so_factory().attachSchema(*message, false); + } + + int32_t message_type = + (*message)[strings::params][strings::message_type].asInt(); + if (message_type == mobile_apis::messageType::response) { + if (command->Init()) { + command->Run(); + command->CleanUp(); + } + return true; + } + if (message_type == mobile_apis::messageType::notification) { + request_ctrl_.addNotification(command); + if (command->Init()) { + command->Run(); + if (command->CleanUp()) { + request_ctrl_.removeNotification(command.get()); + } + // If CleanUp returned false notification should remove it self. + } + return true; + } + + if (message_type == mobile_apis::messageType::request) { + // commands will be launched from requesr_ctrl + mobile_apis::HMILevel::eType app_hmi_level = + mobile_apis::HMILevel::INVALID_ENUM; + if (app) { + app_hmi_level = app->hmi_level(); + } + + // commands will be launched from request_ctrl + + const request_controller::RequestController::TResult result = + request_ctrl_.addMobileRequest(command, app_hmi_level); + + if (result == request_controller::RequestController::SUCCESS) { + LOG4CXX_DEBUG(logger_, "Perform request"); + } else if (result == request_controller::RequestController:: + TOO_MANY_PENDING_REQUESTS) { + LOG4CXX_ERROR(logger_, + "RET Unable top perform request: " + << "TOO_MANY_PENDING_REQUESTS"); + + smart_objects::SmartObjectSPtr response = + MessageHelper::CreateNegativeResponse( + connection_key, + static_cast<int32_t>(function_id), + correlation_id, + static_cast<int32_t>( + mobile_apis::Result::TOO_MANY_PENDING_REQUESTS)); + ApplicationSharedPtr app_ptr = app_manager_.application(connection_key); + if (app_ptr) { + app_ptr->usage_report().RecordRemovalsForBadBehavior(); + } + + SendMessageToMobile(response); + return false; + } else if (result == + request_controller::RequestController::TOO_MANY_REQUESTS) { + LOG4CXX_ERROR(logger_, + "RET Unable to perform request: " + << "TOO_MANY_REQUESTS"); + + ManageMobileCommand( + MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( + connection_key, + mobile_api::AppInterfaceUnregisteredReason::TOO_MANY_REQUESTS), + commands::Command::ORIGIN_SDL); + + app_manager_.UnregisterApplication( + connection_key, + mobile_apis::Result::TOO_MANY_PENDING_REQUESTS, + false); + ApplicationSharedPtr app_ptr = app_manager_.application(connection_key); + if (app_ptr) { + app_ptr->usage_report().RecordRemovalsForBadBehavior(); + } + return false; + } else if (result == request_controller::RequestController:: + NONE_HMI_LEVEL_MANY_REQUESTS) { + LOG4CXX_ERROR(logger_, + "RET Unable to perform request: " + << "REQUEST_WHILE_IN_NONE_HMI_LEVEL"); + + ManageMobileCommand( + MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( + connection_key, + mobile_api::AppInterfaceUnregisteredReason:: + REQUEST_WHILE_IN_NONE_HMI_LEVEL), + commands::Command::ORIGIN_SDL); + + ApplicationSharedPtr app_ptr = app_manager_.application(connection_key); + if (app_ptr) { + app_ptr->usage_report().RecordRemovalsForBadBehavior(); + } + app_manager_.UnregisterApplication( + connection_key, mobile_apis::Result::INVALID_ENUM, false); + return false; + } else { + LOG4CXX_ERROR(logger_, "RET Unable to perform request: Unknown case"); + return false; + } + return true; + } + + LOG4CXX_ERROR(logger_, "RET UNKNOWN MESSAGE TYPE " << message_type); + return false; +} + +bool RPCServiceImpl::ManageHMICommand( + const commands::MessageSharedPtr message) { + LOG4CXX_AUTO_TRACE(logger_); + + if (!message) { + LOG4CXX_WARN(logger_, "Null-pointer message received."); + return false; + } + + if (app_manager_.IsLowVoltage()) { + LOG4CXX_WARN(logger_, "Low Voltage is active"); + return false; + } + + MessageHelper::PrintSmartObject(*message); + + CommandSharedPtr command = + HMICommandFactory::CreateCommand(message, app_manager_); + if (!command) { + LOG4CXX_WARN(logger_, "Failed to create command from smart object"); + return false; + } + + int32_t message_type = + (*(message.get()))[strings::params][strings::message_type].asInt(); + + if (kRequest == message_type) { + LOG4CXX_DEBUG(logger_, "ManageHMICommand"); + request_ctrl_.addHMIRequest(command); + } + + if (command->Init()) { + command->Run(); + if (kResponse == message_type) { + const uint32_t correlation_id = + (*(message.get()))[strings::params][strings::correlation_id].asUInt(); + const int32_t function_id = + (*(message.get()))[strings::params][strings::function_id].asInt(); + request_ctrl_.OnHMIResponse(correlation_id, function_id); + } + return true; + } + return false; +} + +void RPCServiceImpl::Handle(const impl::MessageToHmi message) { + LOG4CXX_AUTO_TRACE(logger_); + if (!hmi_handler_) { + LOG4CXX_ERROR(logger_, "Observer is not set for HMIMessageHandler"); + return; + } + + hmi_handler_->SendMessageToHMI(message); + LOG4CXX_INFO(logger_, "Message for HMI given away"); +} + +void RPCServiceImpl::Handle(const impl::MessageToMobile message) { + if (!protocol_handler_) { + LOG4CXX_WARN(logger_, + "Protocol Handler is not set; cannot send message to mobile."); + return; + } + + utils::SharedPtr<protocol_handler::RawMessage> rawMessage = + MobileMessageHandler::HandleOutgoingMessageProtocol(message); + + if (!rawMessage) { + LOG4CXX_ERROR(logger_, "Failed to create raw message."); + return; + } + + bool is_final = message.is_final; + bool close_session = false; + if (is_final) { + if (1 < app_manager_.connection_handler().GetConnectionSessionsCount( + message->connection_key())) { + is_final = false; + close_session = true; + } + } + + protocol_handler_->SendMessageToMobileApp(rawMessage, is_final); + LOG4CXX_INFO(logger_, "Message for mobile given away"); + + if (close_session) { + app_manager_.connection_handler().CloseSession(message->connection_key(), + connection_handler::kCommon); + } +} + +void RPCServiceImpl::SendMessageToMobile( + const application_manager::commands::MessageSharedPtr message, + bool final_message) { + LOG4CXX_AUTO_TRACE(logger_); + + if (!message) { + LOG4CXX_ERROR(logger_, "Null-pointer message received."); + NOTREACHED(); + return; + } + + if (!protocol_handler_) { + LOG4CXX_WARN(logger_, "No Protocol Handler set"); + return; + } + + ApplicationSharedPtr app = app_manager_.application( + (*message)[strings::params][strings::connection_key].asUInt()); + + const bool is_result_code_exists = + (*message)[strings::msg_params].keyExists(strings::result_code); + + if (!app) { + LOG4CXX_ERROR(logger_, "No application associated with connection key"); + if (is_result_code_exists && + ((*message)[strings::msg_params][strings::result_code] == + NsSmartDeviceLinkRPC::V1::Result::UNSUPPORTED_VERSION)) { + (*message)[strings::params][strings::protocol_version] = + protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_1; + } else { + (*message)[strings::params][strings::protocol_version] = + app_manager_.SupportedSDLVersion(); + } + } else { + (*message)[strings::params][strings::protocol_version] = + app->protocol_version(); + } + + if (app && is_result_code_exists && + (*message)[strings::msg_params][strings::result_code] == + mobile_apis::Result::OUT_OF_MEMORY) { + app->usage_report().RecordRejectionsSyncOutOfMemory(); + } + + mobile_so_factory().attachSchema(*message, false); + LOG4CXX_DEBUG( + logger_, + "Attached schema to message, result if valid: " << message->isValid()); + + // Messages to mobile are not yet prioritized so use default priority value + utils::SharedPtr<Message> message_to_send( + new Message(protocol_handler::MessagePriority::kDefault)); + if (!ConvertSOtoMessage((*message), (*message_to_send))) { + LOG4CXX_WARN(logger_, "Can't send msg to Mobile: failed to create string"); + return; + } + + smart_objects::SmartObject& msg_to_mobile = *message; + // If correlation_id is not present, it is from-HMI message which should be + // checked against policy permissions + if (msg_to_mobile[strings::params].keyExists(strings::correlation_id)) { + request_ctrl_.OnMobileResponse( + msg_to_mobile[strings::params][strings::correlation_id].asUInt(), + msg_to_mobile[strings::params][strings::connection_key].asUInt(), + msg_to_mobile[strings::params][strings::function_id].asInt()); +#ifdef SDL_REMOTE_CONTROL + const mobile_apis::FunctionID::eType function_id = + static_cast<mobile_apis::FunctionID::eType>( + (*message)[strings::params][strings::function_id].asUInt()); + if (function_id == mobile_apis::FunctionID::RegisterAppInterfaceID && + (*message)[strings::msg_params][strings::success].asBool()) { + LOG4CXX_INFO(logger_, + "Registered app " + << app->app_id() << " is " + << (app_manager_.GetPluginManager().IsAppForPlugins(app) + ? "" + : "not ") << "for plugins."); + } +#endif // SDL_REMOTE_CONTROL + } else if (app) { + mobile_apis::FunctionID::eType function_id = + static_cast<mobile_apis::FunctionID::eType>( + (*message)[strings::params][strings::function_id].asUInt()); + RPCParams params; + + const smart_objects::SmartObject& s_map = (*message)[strings::msg_params]; + if (smart_objects::SmartType_Map == s_map.getType()) { + smart_objects::SmartMap::iterator iter = s_map.map_begin(); + smart_objects::SmartMap::iterator iter_end = s_map.map_end(); + + for (; iter != iter_end; ++iter) { + if (true == iter->second.asBool()) { + LOG4CXX_INFO(logger_, "Request's param: " << iter->first); + params.insert(iter->first); + } + } + } + const std::string string_functionID = + MessageHelper::StringifiedFunctionID(function_id); + const mobile_apis::Result::eType check_result = + app_manager_.CheckPolicyPermissions(app, string_functionID, params); + if (mobile_apis::Result::SUCCESS != check_result) { + LOG4CXX_WARN(logger_, + "Function \"" << string_functionID << "\" (#" << function_id + << ") not allowed by policy"); + return; + } + +#ifdef EXTERNAL_PROPRIETARY_MODE + if (function_id == mobile_apis::FunctionID::OnSystemRequestID) { + mobile_apis::RequestType::eType request_type = + static_cast<mobile_apis::RequestType::eType>( + (*message)[strings::msg_params][strings::request_type].asUInt()); + if (mobile_apis::RequestType::PROPRIETARY == request_type || + mobile_apis::RequestType::HTTP == request_type) { + app_manager_.GetPolicyHandler().OnUpdateRequestSentToMobile(); + } + } +#endif // EXTERNAL_PROPRIETARY_MODE + } + + if (message_to_send->binary_data()) { + LOG4CXX_DEBUG( + logger_, + "Binary data size: " << message_to_send->binary_data()->size()); + } + messages_to_mobile_.PostMessage( + impl::MessageToMobile(message_to_send, final_message)); +} + +void RPCServiceImpl::SendMessageToHMI( + const commands::MessageSharedPtr message) { + LOG4CXX_AUTO_TRACE(logger_); + + if (!message) { + LOG4CXX_WARN(logger_, "Null-pointer message received."); + NOTREACHED(); + return; + } + + if (!hmi_handler_) { + LOG4CXX_WARN(logger_, "No HMI Handler set"); + return; + } + + // SmartObject |message| has no way to declare priority for now + utils::SharedPtr<Message> message_to_send( + new Message(protocol_handler::MessagePriority::kDefault)); + if (!message_to_send) { + LOG4CXX_ERROR(logger_, "Null pointer"); + return; + } + + hmi_so_factory().attachSchema(*message, false); + LOG4CXX_INFO( + logger_, + "Attached schema to message, result if valid: " << message->isValid()); + +#ifdef HMI_DBUS_API + message_to_send->set_smart_object(*message); +#else + if (!ConvertSOtoMessage(*message, *message_to_send)) { + LOG4CXX_WARN(logger_, + "Cannot send message to HMI: failed to create string"); + return; + } +#endif // HMI_DBUS_API + + messages_to_hmi_.PostMessage(impl::MessageToHmi(message_to_send)); +} + +void RPCServiceImpl::SendPostMessageToMobile(const MessagePtr& message) { + messages_to_mobile_.PostMessage(impl::MessageToMobile(message, false)); +} + +void RPCServiceImpl::SendPostMessageToHMI(const MessagePtr& message) { + messages_to_hmi_.PostMessage(impl::MessageToHmi(message)); +} + +bool RPCServiceImpl::ConvertSOtoMessage( + const NsSmartDeviceLink::NsSmartObjects::SmartObject& message, + Message& output) { + LOG4CXX_AUTO_TRACE(logger_); + + if (smart_objects::SmartType_Null == message.getType() || + smart_objects::SmartType_Invalid == message.getType()) { + LOG4CXX_WARN(logger_, "Invalid smart object received."); + return false; + } + + LOG4CXX_DEBUG( + logger_, + "Message with protocol: " << message.getElement(jhs::S_PARAMS) + .getElement(jhs::S_PROTOCOL_TYPE) + .asInt()); + + std::string output_string; + const int64_t protocol_type = message.getElement(jhs::S_PARAMS) + .getElement(jhs::S_PROTOCOL_TYPE) + .asInt(); + const int64_t protocol_version = message.getElement(jhs::S_PARAMS) + .getElement(jhs::S_PROTOCOL_VERSION) + .asInt(); + switch (protocol_type) { + case 0: { + if (protocol_version == 1) { + if (!formatters::CFormatterJsonSDLRPCv1::toString(message, + output_string)) { + LOG4CXX_WARN(logger_, "Failed to serialize smart object"); + return false; + } + output.set_protocol_version( + protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_1); + } else { + if (!formatters::CFormatterJsonSDLRPCv2::toString(message, + output_string)) { + LOG4CXX_WARN(logger_, "Failed to serialize smart object"); + return false; + } + output.set_protocol_version( + static_cast<protocol_handler::MajorProtocolVersion>( + protocol_version)); + } + + break; + } + case 1: { + if (!formatters::FormatterJsonRpc::ToString(message, output_string)) { + LOG4CXX_WARN(logger_, "Failed to serialize smart object"); + return false; + } + output.set_protocol_version( + protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_HMI); + break; + } + default: + NOTREACHED(); + return false; + } + + LOG4CXX_DEBUG(logger_, "Convertion result: " << output_string); + + output.set_connection_key(message.getElement(jhs::S_PARAMS) + .getElement(strings::connection_key) + .asInt()); + + output.set_function_id( + message.getElement(jhs::S_PARAMS).getElement(jhs::S_FUNCTION_ID).asInt()); + + output.set_correlation_id(message.getElement(jhs::S_PARAMS) + .getElement(jhs::S_CORRELATION_ID) + .asInt()); + output.set_message_type( + static_cast<MessageType>(message.getElement(jhs::S_PARAMS) + .getElement(jhs::S_MESSAGE_TYPE) + .asInt())); + + // Currently formatter creates JSON = 3 bytes for empty SmartObject. + // workaround for notification. JSON must be empty + if (mobile_apis::FunctionID::OnAudioPassThruID != + message.getElement(jhs::S_PARAMS) + .getElement(strings::function_id) + .asInt()) { + output.set_json_message(output_string); + } + + if (message.getElement(jhs::S_PARAMS).keyExists(strings::binary_data)) { + const application_manager::BinaryData binaryData( + message.getElement(jhs::S_PARAMS) + .getElement(strings::binary_data) + .asBinary()); + + output.set_binary_data(&binaryData); + } + + LOG4CXX_DEBUG(logger_, "Successfully parsed smart object into message"); + return true; +} + +hmi_apis::HMI_API& RPCServiceImpl::hmi_so_factory() { + return hmi_so_factory_; +} + +mobile_apis::MOBILE_API& RPCServiceImpl::mobile_so_factory() { + return mobile_so_factory_; +} + +} // namespace rpc_service + +} // namespace application_manager diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc index 9615656675..1a1e5543df 100644 --- a/src/components/application_manager/src/state_controller_impl.cc +++ b/src/components/application_manager/src/state_controller_impl.cc @@ -33,6 +33,7 @@ #include "application_manager/state_controller_impl.h" #include <tuple> #include "application_manager/usage_statistics.h" +#include "application_manager/rpc_service.h" #include "utils/helpers.h" #include "utils/make_shared.h" #include "connection_handler/connection_handler.h" @@ -801,7 +802,7 @@ int64_t StateControllerImpl::SendBCActivateApp( LOG4CXX_ERROR(logger_, "Unable to create BC.ActivateAppRequest"); return -1; } - if (!app_mngr_.ManageHMICommand(bc_activate_app_request)) { + if (!app_mngr_.GetRPCService().ManageHMICommand(bc_activate_app_request)) { LOG4CXX_ERROR(logger_, "Unable to send BC.ActivateAppRequest"); return -1; } |