summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/appMain/life_cycle.cc6
-rw-r--r--src/components/application_manager/include/application_manager/application_manager_impl.h84
-rw-r--r--src/components/application_manager/include/application_manager/rpc_handler_impl.h175
-rw-r--r--src/components/application_manager/include/application_manager/rpc_service_impl.h5
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc349
-rw-r--r--src/components/application_manager/src/rpc_handler_impl.cc389
-rw-r--r--src/components/application_manager/src/rpc_service_impl.cc29
-rw-r--r--src/components/application_manager/test/application_manager_impl_mock_hmi_test.cc9
-rw-r--r--src/components/application_manager/test/application_manager_impl_test.cc9
-rw-r--r--src/components/application_manager/test/command_holder_test.cc19
-rw-r--r--src/components/application_manager/test/commands/hmi/get_urls_test.cc2
-rw-r--r--src/components/application_manager/test/commands/hmi/sdl_activate_app_request_test.cc1
-rw-r--r--src/components/application_manager/test/commands/mobile/alert_request_test.cc2
-rw-r--r--src/components/application_manager/test/commands/mobile/create_interaction_choice_set_test.cc25
-rw-r--r--src/components/application_manager/test/commands/mobile/delete_command_request_test.cc4
-rw-r--r--src/components/application_manager/test/commands/mobile/delete_interaction_choice_set_test.cc54
-rw-r--r--src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc34
-rw-r--r--src/components/application_manager/test/commands/mobile/on_button_notification_commands_test.cc3
-rw-r--r--src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc2
-rw-r--r--src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc13
-rw-r--r--src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc38
-rw-r--r--src/components/application_manager/test/commands/mobile/send_location_request_test.cc6
-rw-r--r--src/components/application_manager/test/commands/mobile/set_global_properties_test.cc20
-rw-r--r--src/components/application_manager/test/commands/mobile/simple_response_commands_test.cc1
-rw-r--r--src/components/application_manager/test/commands/mobile/subscribe_button_request_test.cc7
-rw-r--r--src/components/include/application_manager/application_manager.h6
-rw-r--r--src/components/include/application_manager/rpc_handler.h60
-rw-r--r--src/components/include/test/application_manager/mock_application_manager.h3
28 files changed, 846 insertions, 509 deletions
diff --git a/src/appMain/life_cycle.cc b/src/appMain/life_cycle.cc
index 0ecbb4a02e..e42032a5cb 100644
--- a/src/appMain/life_cycle.cc
+++ b/src/appMain/life_cycle.cc
@@ -109,7 +109,7 @@ bool LifeCycle::StartComponents() {
DCHECK(!hmi_handler_);
hmi_handler_ = new hmi_message_handler::HMIMessageHandlerImpl(profile_);
- hmi_handler_->set_message_observer(app_manager_);
+ hmi_handler_->set_message_observer(&(app_manager_->GetRPCHandler()));
app_manager_->set_hmi_message_handler(hmi_handler_);
media_manager_ = new media_manager::MediaManagerImpl(*app_manager_, profile_);
@@ -148,7 +148,7 @@ bool LifeCycle::StartComponents() {
transport_manager_->AddEventListener(connection_handler_);
protocol_handler_->AddProtocolObserver(media_manager_);
- protocol_handler_->AddProtocolObserver(app_manager_);
+ protocol_handler_->AddProtocolObserver(&(app_manager_->GetRPCHandler()));
media_manager_->SetProtocolHandler(protocol_handler_);
@@ -254,7 +254,7 @@ void LifeCycle::StopComponents() {
connection_handler_->set_connection_handler_observer(NULL);
DCHECK_OR_RETURN_VOID(protocol_handler_);
- protocol_handler_->RemoveProtocolObserver(app_manager_);
+ protocol_handler_->RemoveProtocolObserver(&(app_manager_->GetRPCHandler()));
DCHECK_OR_RETURN_VOID(app_manager_);
app_manager_->Stop();
diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h
index b9a6ded087..eb2ac30f17 100644
--- a/src/components/application_manager/include/application_manager/application_manager_impl.h
+++ b/src/components/application_manager/include/application_manager/application_manager_impl.h
@@ -55,6 +55,7 @@
#include "application_manager/hmi_interfaces_impl.h"
#include "application_manager/command_holder.h"
#include "application_manager/rpc_service.h"
+#include "application_manager/rpc_handler.h"
#include "protocol_handler/protocol_observer.h"
#include "protocol_handler/protocol_handler.h"
@@ -119,41 +120,6 @@ typedef std::map<std::string, hmi_apis::Common_TransportType::eType>
namespace impl {
using namespace threads;
-/*
- * These dummy classes are here to locally impose strong typing on different
- * kinds of messages
- * Currently there is no type difference between incoming and outgoing messages
- * And due to ApplicationManagerImpl works as message router it has to
- * distinguish
- * messages passed from it's different connection points
- * TODO(ik): replace these with globally defined message types
- * when we have them.
- */
-struct MessageFromMobile : public utils::SharedPtr<Message> {
- MessageFromMobile() {}
- explicit MessageFromMobile(const utils::SharedPtr<Message>& message)
- : utils::SharedPtr<Message>(message) {}
- // PrioritizedQueue requres this method to decide which priority to assign
- size_t PriorityOrder() const {
- return (*this)->Priority().OrderingValue();
- }
-};
-struct MessageFromHmi : public utils::SharedPtr<Message> {
- MessageFromHmi() {}
- explicit MessageFromHmi(const utils::SharedPtr<Message>& message)
- : utils::SharedPtr<Message>(message) {}
- // PrioritizedQueue requres this method to decide which priority to assign
- size_t PriorityOrder() const {
- return (*this)->Priority().OrderingValue();
- }
-};
-
-// Short type names for prioritized message queues
-typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageFromMobile> >
- FromMobileQueue;
-typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageFromHmi> >
- FromHmiQueue;
-
// AudioPassThru
typedef struct {
std::vector<uint8_t> binary_data;
@@ -167,15 +133,11 @@ typedef utils::SharedPtr<timer::Timer> TimerSPtr;
class ApplicationManagerImpl
: public ApplicationManager,
- public hmi_message_handler::HMIMessageObserver,
- public protocol_handler::ProtocolObserver,
public connection_handler::ConnectionHandlerObserver,
public policy::PolicyHandlerObserver,
#ifdef ENABLE_SECURITY
public security_manager::SecurityManagerListener,
#endif // ENABLE_SECURITY
- public impl::FromMobileQueue::Handler,
- public impl::FromHmiQueue::Handler,
public impl::AudioPassThruQueue::Handler
#ifdef TELEMETRY_MONITOR
,
@@ -700,17 +662,6 @@ class ApplicationManagerImpl
void TerminateRequest(const uint32_t connection_key,
const uint32_t corr_id,
const int32_t function_id) OVERRIDE;
- // Overriden ProtocolObserver method
- void OnMessageReceived(
- const ::protocol_handler::RawMessagePtr message) OVERRIDE;
- void OnMobileMessageSent(
- const ::protocol_handler::RawMessagePtr message) OVERRIDE;
-
- // Overriden HMIMessageObserver method
- void OnMessageReceived(
- hmi_message_handler::MessageSharedPointer message) OVERRIDE;
- void OnErrorSending(
- hmi_message_handler::MessageSharedPointer message) OVERRIDE;
// Overriden ConnectionHandlerObserver method
void OnDeviceListUpdated(
@@ -1020,6 +971,12 @@ class ApplicationManagerImpl
virtual rpc_service::RPCService& GetRPCService() const OVERRIDE {
return *rpc_service_;
}
+
+ virtual rpc_handler::RPCHandler& GetRPCHandler() const OVERRIDE {
+ return *rpc_handler_;
+ }
+
+ bool is_stopping() const OVERRIDE;
/*
* @brief Function Should be called when Low Voltage is occured
*/
@@ -1220,31 +1177,12 @@ bool IsSOStructValid(const hmi_apis::StructIdentifiers::eType struct_id,
hmi_apis::HMI_API& hmi_so_factory();
mobile_apis::MOBILE_API& mobile_so_factory();
- bool ConvertMessageToSO(const Message& message,
- smart_objects::SmartObject& output);
bool ConvertSOtoMessage(const smart_objects::SmartObject& message,
Message& output);
MessageValidationResult ValidateMessageBySchema(
const Message& message) OVERRIDE;
- utils::SharedPtr<Message> ConvertRawMsgToMessage(
- const ::protocol_handler::RawMessagePtr message);
-
- void ProcessMessageFromMobile(const utils::SharedPtr<Message> message);
- void ProcessMessageFromHMI(const utils::SharedPtr<Message> message);
-
- // threads::MessageLoopThread<*>::Handler implementations
- /*
- * @brief Handles for threads pumping different types
- * of messages. Beware, each is called on different thread!
- */
- // CALLED ON messages_from_mobile_ thread!
- void Handle(const impl::MessageFromMobile message) OVERRIDE;
-
- // CALLED ON messages_from_hmi_ thread!
- void Handle(const impl::MessageFromHmi message) OVERRIDE;
-
// CALLED ON audio_pass_thru_messages_ thread!
void Handle(const impl::AudioData message) OVERRIDE;
@@ -1584,11 +1522,6 @@ bool IsSOStructValid(const hmi_apis::StructIdentifiers::eType struct_id,
static const uint32_t max_corelation_id_;
// Construct message threads when everything is already created
-
- // Thread that pumps messages coming from mobile side.
- impl::FromMobileQueue messages_from_mobile_;
- // Thread that pumps messages coming from HMI.
- impl::FromHmiQueue messages_from_hmi_;
// Thread that pumps messages audio pass thru to mobile.
impl::AudioPassThruQueue audio_pass_thru_messages_;
@@ -1614,7 +1547,7 @@ bool IsSOStructValid(const hmi_apis::StructIdentifiers::eType struct_id,
std::vector<TimerSPtr> timer_pool_;
sync_primitives::Lock timer_pool_lock_;
- sync_primitives::Lock stopping_application_mng_lock_;
+ mutable sync_primitives::Lock stopping_application_mng_lock_;
StateControllerImpl state_ctrl_;
std::auto_ptr<app_launch::AppLaunchData> app_launch_dto_;
std::auto_ptr<app_launch::AppLaunchCtrl> app_launch_ctrl_;
@@ -1644,6 +1577,7 @@ bool IsSOStructValid(const hmi_apis::StructIdentifiers::eType struct_id,
std::unique_ptr<CommandHolder> commands_holder_;
std::unique_ptr<rpc_service::RPCService> rpc_service_;
+ std::unique_ptr<rpc_handler::RPCHandler> rpc_handler_;
#ifdef BUILD_TESTS
public:
diff --git a/src/components/application_manager/include/application_manager/rpc_handler_impl.h b/src/components/application_manager/include/application_manager/rpc_handler_impl.h
new file mode 100644
index 0000000000..0dfff294c2
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/rpc_handler_impl.h
@@ -0,0 +1,175 @@
+/*
+ * 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.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RPC_HANDLER_IMPL_H
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RPC_HANDLER_IMPL_H
+
+#include "application_manager/application_manager.h"
+#include "application_manager/message_helper.h"
+#include "application_manager/rpc_handler.h"
+#include "application_manager/rpc_service.h"
+#include "application_manager/mobile_message_handler.h"
+#include "application_manager/policies/policy_handler_observer.h"
+
+#include "protocol_handler/protocol_observer.h"
+#include "hmi_message_handler/hmi_message_observer.h"
+#include "hmi_message_handler/hmi_message_sender.h"
+
+#include "formatters/formatter_json_rpc.h"
+#include "formatters/CFormatterJsonSDLRPCv2.h"
+#include "formatters/CFormatterJsonSDLRPCv1.h"
+#ifdef SDL_REMOTE_CONTROL
+#include "functional_module/plugin_manager.h"
+#endif
+#include "interfaces/HMI_API_schema.h"
+#include "interfaces/MOBILE_API_schema.h"
+#ifdef TELEMETRY_MONITOR
+#include "telemetry_observer.h"
+#endif // TELEMETRY_MONITOR
+
+#include "interfaces/v4_protocol_v1_2_no_extra.h"
+#include "interfaces/v4_protocol_v1_2_no_extra_schema.h"
+
+#include "utils/threads/message_loop_thread.h"
+#include "utils/shared_ptr.h"
+#include "utils/make_shared.h"
+
+namespace application_manager {
+namespace rpc_handler {
+
+namespace impl {
+struct MessageFromMobile : public utils::SharedPtr<Message> {
+ MessageFromMobile() {}
+ explicit MessageFromMobile(const utils::SharedPtr<Message>& message)
+ : utils::SharedPtr<Message>(message) {}
+ // PrioritizedQueue requres this method to decide which priority to assign
+ size_t PriorityOrder() const {
+ return (*this)->Priority().OrderingValue();
+ }
+};
+struct MessageFromHmi : public utils::SharedPtr<Message> {
+ MessageFromHmi() {}
+ explicit MessageFromHmi(const utils::SharedPtr<Message>& message)
+ : utils::SharedPtr<Message>(message) {}
+ // PrioritizedQueue requres this method to decide which priority to assign
+ size_t PriorityOrder() const {
+ return (*this)->Priority().OrderingValue();
+ }
+};
+
+// Short type names for prioritized message queues
+typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageFromMobile> >
+ FromMobileQueue;
+typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageFromHmi> >
+ FromHmiQueue;
+}
+
+class RPCHandlerImpl : public RPCHandler,
+ public impl::FromMobileQueue::Handler,
+ public impl::FromHmiQueue::Handler {
+ public:
+ RPCHandlerImpl(ApplicationManager& app_manager);
+ ~RPCHandlerImpl();
+
+ // CALLED ON messages_from_mobile_ thread!
+ void Handle(const impl::MessageFromMobile message) OVERRIDE;
+ // CALLED ON messages_from_hmi_ thread!
+ void Handle(const impl::MessageFromHmi message) OVERRIDE;
+
+ // Overriden HMIMessageObserver method
+ /**
+ * @brief OnMessageReceived overriden HMIMessageObserver method,
+ * process message from HMI
+ * @param message pointer to received message
+ */
+ void OnMessageReceived(
+ hmi_message_handler::MessageSharedPointer message) OVERRIDE;
+
+ /**
+ * @brief OnErrorSending overriden HMIMessageObserver method
+ * @param message pointer to received message
+ */
+ void OnErrorSending(
+ hmi_message_handler::MessageSharedPointer message) OVERRIDE;
+
+ // Overriden ProtocolObserver method
+ /**
+ * @brief OnMessageReceived overriden ProtocolObserver method,
+ * process message from mobile
+ * @param message pointer to received message
+ */
+ void OnMessageReceived(
+ const ::protocol_handler::RawMessagePtr message) OVERRIDE;
+
+ /**
+ * @brief OnMobileMessageSent overriden ProtocolObserver method,
+ * post message to mobile
+ * @param message pointer to received message
+ */
+ void OnMobileMessageSent(
+ const ::protocol_handler::RawMessagePtr message) OVERRIDE;
+
+#ifdef TELEMETRY_MONITOR
+ /**
+ * @brief Setup observer for time metric.
+ *
+ * @param observer - pointer to observer
+ */
+ void SetTelemetryObserver(AMTelemetryObserver* observer) OVERRIDE;
+#endif // TELEMETRY_MONITOR
+
+ private:
+ void ProcessMessageFromMobile(const utils::SharedPtr<Message> message);
+ void ProcessMessageFromHMI(const utils::SharedPtr<Message> message);
+ bool ConvertMessageToSO(const Message& message,
+ smart_objects::SmartObject& output);
+ utils::SharedPtr<Message> ConvertRawMsgToMessage(
+ const ::protocol_handler::RawMessagePtr message);
+ hmi_apis::HMI_API& hmi_so_factory();
+ mobile_apis::MOBILE_API& mobile_so_factory();
+
+ ApplicationManager& app_manager_;
+ // Thread that pumps messages coming from mobile side.
+ impl::FromMobileQueue messages_from_mobile_;
+ // Thread that pumps messages coming from HMI.
+ impl::FromHmiQueue messages_from_hmi_;
+
+ hmi_apis::HMI_API hmi_so_factory_;
+ mobile_apis::MOBILE_API mobile_so_factory_;
+#ifdef TELEMETRY_MONITOR
+ AMTelemetryObserver* metric_observer_;
+#endif // TELEMETRY_MONITOR
+};
+
+} // namespace rpc_handler
+} // namespace application_manager
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RPC_HANDLER_IMPL_H
diff --git a/src/components/application_manager/include/application_manager/rpc_service_impl.h b/src/components/application_manager/include/application_manager/rpc_service_impl.h
index 8264459b7a..1fa3612daf 100644
--- a/src/components/application_manager/include/application_manager/rpc_service_impl.h
+++ b/src/components/application_manager/include/application_manager/rpc_service_impl.h
@@ -42,6 +42,7 @@
#include "application_manager/usage_statistics.h"
#include "application_manager/mobile_message_handler.h"
#include "hmi_message_handler/hmi_message_handler.h"
+#include "application_manager/command_holder_impl.h"
#include "formatters/formatter_json_rpc.h"
#include "formatters/CFormatterJsonSDLRPCv2.h"
@@ -96,7 +97,8 @@ class RPCServiceImpl : public RPCService,
RPCServiceImpl(ApplicationManager& app_manager,
request_controller::RequestController& request_ctrl,
protocol_handler::ProtocolHandler* protocol_handler,
- hmi_message_handler::HMIMessageHandler* hmi_handler);
+ hmi_message_handler::HMIMessageHandler* hmi_handler,
+ CommandHolder& commands_holder);
~RPCServiceImpl();
bool ManageMobileCommand(const commands::MessageSharedPtr message,
@@ -127,6 +129,7 @@ class RPCServiceImpl : public RPCService,
request_controller::RequestController& request_ctrl_;
protocol_handler::ProtocolHandler* protocol_handler_;
hmi_message_handler::HMIMessageHandler* hmi_handler_;
+ CommandHolder& commands_holder_;
// Thread that pumps messages being passed to mobile side.
impl::ToMobileQueue messages_to_mobile_;
// Thread that pumps messages being passed to HMI.
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index e68e2e4b62..f23600f46b 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -44,6 +44,7 @@
#include "application_manager/commands/command_notification_impl.h"
#include "application_manager/message_helper.h"
#include "application_manager/rpc_service_impl.h"
+#include "application_manager/rpc_handler_impl.h"
#include "application_manager/mobile_message_handler.h"
#include "application_manager/policies/policy_handler.h"
#include "application_manager/hmi_capabilities_impl.h"
@@ -158,8 +159,6 @@ ApplicationManagerImpl::ApplicationManagerImpl(
, request_ctrl_(am_settings)
, hmi_so_factory_(NULL)
, mobile_so_factory_(NULL)
- , messages_from_mobile_("AM FromMobile", this)
- , messages_from_hmi_("AM FromHMI", this)
, audio_pass_thru_messages_("AudioPassThru", this)
, hmi_capabilities_(new HMICapabilitiesImpl(*this))
, unregister_reason_(
@@ -198,6 +197,7 @@ ApplicationManagerImpl::ApplicationManagerImpl(
const uint32_t timeout_ms = 10000u;
clearing_timer->Start(timeout_ms, timer::kSingleShot);
timer_pool_.push_back(clearing_timer);
+ rpc_handler_.reset(new rpc_handler::RPCHandlerImpl(*this));
commands_holder_.reset(new CommandHolderImpl(*this));
}
@@ -941,43 +941,6 @@ ApplicationManagerImpl::GetDeviceTransportType(
return result;
}
-void ApplicationManagerImpl::OnMessageReceived(
- const ::protocol_handler::RawMessagePtr message) {
- LOG4CXX_AUTO_TRACE(logger_);
-
- if (!message) {
- LOG4CXX_ERROR(logger_, "Null-pointer message received.");
- NOTREACHED();
- return;
- }
-
- utils::SharedPtr<Message> outgoing_message = ConvertRawMsgToMessage(message);
-
- if (outgoing_message) {
- LOG4CXX_DEBUG(logger_, "Posting new Message");
- messages_from_mobile_.PostMessage(
- impl::MessageFromMobile(outgoing_message));
- }
-}
-
-void ApplicationManagerImpl::OnMobileMessageSent(
- const ::protocol_handler::RawMessagePtr message) {
- LOG4CXX_AUTO_TRACE(logger_);
-}
-
-void ApplicationManagerImpl::OnMessageReceived(
- hmi_message_handler::MessageSharedPointer message) {
- LOG4CXX_AUTO_TRACE(logger_);
-
- if (!message) {
- LOG4CXX_ERROR(logger_, "Null-pointer message received.");
- NOTREACHED();
- return;
- }
-
- messages_from_hmi_.PostMessage(impl::MessageFromHmi(message));
-}
-
ApplicationConstSharedPtr ApplicationManagerImpl::WaitingApplicationByID(
const uint32_t hmi_id) const {
AppsWaitRegistrationSet app_list = AppsWaitingForRegistration().GetData();
@@ -1751,8 +1714,11 @@ 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_));
+ rpc_service_.reset(new rpc_service::RPCServiceImpl(*this,
+ request_ctrl_,
+ protocol_handler_,
+ hmi_handler_,
+ *commands_holder_));
}
void ApplicationManagerImpl::StartDevicesDiscovery() {
@@ -1878,156 +1844,6 @@ bool ApplicationManagerImpl::Stop() {
return true;
}
-bool ApplicationManagerImpl::ConvertMessageToSO(
- const Message& message, smart_objects::SmartObject& output) {
- LOG4CXX_AUTO_TRACE(logger_);
- LOG4CXX_DEBUG(logger_,
- "\t\t\tMessage to convert: protocol "
- << message.protocol_version() << "; json "
- << message.json_message());
-
- switch (message.protocol_version()) {
- case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5:
- case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4:
- case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_3:
- case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_2: {
- const bool conversion_result =
- formatters::CFormatterJsonSDLRPCv2::fromString(
- message.json_message(),
- output,
- message.function_id(),
- message.type(),
- message.correlation_id());
-
- rpc::ValidationReport report("RPC");
-
- if (!conversion_result ||
- !mobile_so_factory().attachSchema(output, true) ||
- ((output.validate(&report) != smart_objects::Errors::OK))) {
- LOG4CXX_WARN(logger_,
- "Failed to parse string to smart object :"
- << message.json_message());
- utils::SharedPtr<smart_objects::SmartObject> response(
- MessageHelper::CreateNegativeResponse(
- message.connection_key(),
- message.function_id(),
- message.correlation_id(),
- mobile_apis::Result::INVALID_DATA));
-
- (*response)[strings::msg_params][strings::info] =
- rpc::PrettyFormat(report);
- rpc_service_->ManageMobileCommand(response, commands::Command::ORIGIN_SDL);
- return false;
- }
- LOG4CXX_DEBUG(logger_,
- "Convertion result for sdl object is true function_id "
- << output[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt());
-
- output[strings::params][strings::connection_key] =
- message.connection_key();
- output[strings::params][strings::protocol_version] =
- message.protocol_version();
- if (message.binary_data()) {
- if (message.payload_size() < message.data_size()) {
- LOG4CXX_ERROR(logger_,
- "Incomplete binary"
- << " binary size should be " << message.data_size()
- << " payload data size is "
- << message.payload_size());
- utils::SharedPtr<smart_objects::SmartObject> response(
- MessageHelper::CreateNegativeResponse(
- message.connection_key(),
- message.function_id(),
- message.correlation_id(),
- mobile_apis::Result::INVALID_DATA));
- rpc_service_->ManageMobileCommand(response,
- commands::Command::ORIGIN_SDL);
- return false;
- }
- output[strings::params][strings::binary_data] =
- *(message.binary_data());
- }
- break;
- }
- case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_HMI: {
-#ifdef ENABLE_LOG
- int32_t result =
-#endif
- formatters::FormatterJsonRpc::FromString<
- hmi_apis::FunctionID::eType,
- hmi_apis::messageType::eType>(message.json_message(), output);
- LOG4CXX_DEBUG(logger_,
- "Convertion result: "
- << result << " function id "
- << output[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt());
- if (!hmi_so_factory().attachSchema(output, false)) {
- LOG4CXX_WARN(logger_, "Failed to attach schema to object.");
- return false;
- }
-
- rpc::ValidationReport report("RPC");
-
- if (output.validate(&report) != smart_objects::Errors::OK) {
- LOG4CXX_ERROR(logger_,
- "Incorrect parameter from HMI"
- << rpc::PrettyFormat(report));
-
- output.erase(strings::msg_params);
- output[strings::params][hmi_response::code] =
- hmi_apis::Common_Result::INVALID_DATA;
- output[strings::msg_params][strings::info] = rpc::PrettyFormat(report);
- return false;
- }
- break;
- }
- case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_1: {
- static NsSmartDeviceLinkRPC::V1::v4_protocol_v1_2_no_extra v1_shema;
-
- if (message.function_id() == 0 || message.type() == kUnknownType) {
- LOG4CXX_ERROR(logger_, "Message received: UNSUPPORTED_VERSION");
-
- int32_t conversation_result =
- formatters::CFormatterJsonSDLRPCv1::fromString<
- NsSmartDeviceLinkRPC::V1::FunctionID::eType,
- NsSmartDeviceLinkRPC::V1::messageType::eType>(
- message.json_message(), output);
-
- if (formatters::CFormatterJsonSDLRPCv1::kSuccess ==
- conversation_result) {
- smart_objects::SmartObject params = smart_objects::SmartObject(
- smart_objects::SmartType::SmartType_Map);
-
- output[strings::params][strings::message_type] =
- NsSmartDeviceLinkRPC::V1::messageType::response;
- output[strings::params][strings::connection_key] =
- message.connection_key();
-
- output[strings::msg_params] = smart_objects::SmartObject(
- smart_objects::SmartType::SmartType_Map);
- output[strings::msg_params][strings::success] = false;
- output[strings::msg_params][strings::result_code] =
- NsSmartDeviceLinkRPC::V1::Result::UNSUPPORTED_VERSION;
-
- smart_objects::SmartObjectSPtr msg_to_send =
- new smart_objects::SmartObject(output);
- v1_shema.attachSchema(*msg_to_send, false);
- rpc_service_->SendMessageToMobile(msg_to_send);
- return false;
- }
- }
- break;
- }
- default:
- LOG4CXX_WARN(logger_,
- "Application used unsupported protocol :"
- << message.protocol_version() << ".");
- return false;
- }
-
- LOG4CXX_DEBUG(logger_, "Successfully parsed message into smart object");
- return true;
-}
-
bool ApplicationManagerImpl::ConvertSOtoMessage(
const smart_objects::SmartObject& message, Message& output) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -2188,102 +2004,6 @@ MessageValidationResult ApplicationManagerImpl::ValidateMessageBySchema(
return SUCCESS;
}
-utils::SharedPtr<Message> ApplicationManagerImpl::ConvertRawMsgToMessage(
- const ::protocol_handler::RawMessagePtr message) {
- LOG4CXX_AUTO_TRACE(logger_);
- DCHECK(message);
- utils::SharedPtr<Message> outgoing_message;
-
- LOG4CXX_DEBUG(logger_, "Service type." << message->service_type());
- if (message->service_type() != protocol_handler::kRpc &&
- message->service_type() != protocol_handler::kBulk) {
- // skip this message, not under handling of ApplicationManager
- LOG4CXX_TRACE(logger_, "Skipping message; not the under AM handling.");
- return outgoing_message;
- }
-
- Message* convertion_result =
- MobileMessageHandler::HandleIncomingMessageProtocol(message);
-
- if (convertion_result) {
- outgoing_message = convertion_result;
- } else {
- LOG4CXX_ERROR(logger_, "Received invalid message");
- }
- return outgoing_message;
-}
-
-void ApplicationManagerImpl::ProcessMessageFromMobile(
- const utils::SharedPtr<Message> message) {
- LOG4CXX_AUTO_TRACE(logger_);
-#ifdef TELEMETRY_MONITOR
- AMTelemetryObserver::MessageMetricSharedPtr metric(
- new AMTelemetryObserver::MessageMetric());
- metric->begin = date_time::DateTime::getCurrentTime();
-#endif // TELEMETRY_MONITOR
- smart_objects::SmartObjectSPtr so_from_mobile =
- utils::MakeShared<smart_objects::SmartObject>();
-
- DCHECK_OR_RETURN_VOID(so_from_mobile);
- if (!so_from_mobile) {
- LOG4CXX_ERROR(logger_, "Null pointer");
- return;
- }
-
- if (!ConvertMessageToSO(*message, *so_from_mobile)) {
- LOG4CXX_ERROR(logger_, "Cannot create smart object from message");
- return;
- }
-#ifdef TELEMETRY_MONITOR
- metric->message = so_from_mobile;
-#endif // TELEMETRY_MONITOR
-
- if (!rpc_service_->ManageMobileCommand(so_from_mobile,
- commands::Command::ORIGIN_MOBILE)) {
- LOG4CXX_ERROR(logger_, "Received command didn't run successfully");
- }
-#ifdef TELEMETRY_MONITOR
- metric->end = date_time::DateTime::getCurrentTime();
- if (metric_observer_) {
- metric_observer_->OnMessage(metric);
- }
-#endif // TELEMETRY_MONITOR
-}
-
-void ApplicationManagerImpl::ProcessMessageFromHMI(
- const utils::SharedPtr<Message> message) {
- LOG4CXX_AUTO_TRACE(logger_);
- smart_objects::SmartObjectSPtr smart_object(new smart_objects::SmartObject);
-
- if (!smart_object) {
- LOG4CXX_ERROR(logger_, "Null pointer");
- return;
- }
-
-#ifdef HMI_DBUS_API
- *smart_object = message->smart_object();
-#else
- if (!ConvertMessageToSO(*message, *smart_object)) {
- if (application_manager::MessageType::kResponse ==
- (*smart_object)[strings::params][strings::message_type].asInt()) {
- (*smart_object).erase(strings::msg_params);
- (*smart_object)[strings::params][hmi_response::code] =
- hmi_apis::Common_Result::INVALID_DATA;
- (*smart_object)[strings::msg_params][strings::info] =
- std::string("Received invalid data on HMI response");
- } else {
- LOG4CXX_ERROR(logger_, "Cannot create smart object from message");
- return;
- }
- }
-#endif // HMI_DBUS_API
-
- LOG4CXX_DEBUG(logger_, "Converted message, trying to create hmi command");
- if (!rpc_service_->ManageHMICommand(smart_object)) {
- LOG4CXX_ERROR(logger_, "Received command didn't run successfully");
- }
-}
-
hmi_apis::HMI_API& ApplicationManagerImpl::hmi_so_factory() {
if (!hmi_so_factory_) {
hmi_so_factory_ = new hmi_apis::HMI_API;
@@ -2509,7 +2229,7 @@ bool ApplicationManagerImpl::is_attenuated_supported() const {
#ifdef TELEMETRY_MONITOR
void ApplicationManagerImpl::SetTelemetryObserver(
AMTelemetryObserver* observer) {
- metric_observer_ = observer;
+ rpc_handler_->SetTelemetryObserver(observer);
}
#endif // TELEMETRY_MONITOR
@@ -2878,54 +2598,6 @@ void ApplicationManagerImpl::OnAppUnauthorized(const uint32_t& app_id) {
connection_handler::kUnauthorizedApp);
}
-void ApplicationManagerImpl::Handle(const impl::MessageFromMobile message) {
- LOG4CXX_AUTO_TRACE(logger_);
-
- if (!message) {
- LOG4CXX_ERROR(logger_, "Null-pointer message received.");
- return;
- }
- sync_primitives::AutoLock lock(stopping_application_mng_lock_);
- if (is_stopping_) {
- LOG4CXX_INFO(logger_, "Application manager is stopping");
- return;
- }
-#ifdef SDL_REMOTE_CONTROL
- if (plugin_manager_.IsMessageForPlugin(message)) {
- if (functional_modules::ProcessResult::PROCESSED ==
- plugin_manager_.ProcessMessage(message)) {
- LOG4CXX_INFO(logger_, "Message is processed by plugin.");
- return;
- }
- }
-#endif
- ProcessMessageFromMobile(message);
-}
-
-
-void ApplicationManagerImpl::Handle(const impl::MessageFromHmi message) {
- LOG4CXX_AUTO_TRACE(logger_);
-
- if (!message) {
- LOG4CXX_ERROR(logger_, "Null-pointer message received.");
- return;
- }
-
-#ifdef SDL_REMOTE_CONTROL
- if (plugin_manager_.IsHMIMessageForPlugin(message)) {
- functional_modules::ProcessResult result =
- plugin_manager_.ProcessHMIMessage(message);
- if (functional_modules::ProcessResult::PROCESSED == result ||
- functional_modules::ProcessResult::FAILED == result) {
- LOG4CXX_INFO(logger_, "Message is processed by plugin.");
- return;
- }
- }
-#endif
-
- ProcessMessageFromHMI(message);
-}
-
void ApplicationManagerImpl::Handle(const impl::AudioData message) {
LOG4CXX_AUTO_TRACE(logger_);
smart_objects::SmartObjectSPtr on_audio_pass =
@@ -3019,6 +2691,11 @@ mobile_apis::Result::eType ApplicationManagerImpl::CheckPolicyPermissions(
return mobile_api::Result::SUCCESS;
}
+bool ApplicationManagerImpl::is_stopping() const {
+ sync_primitives::AutoLock lock(stopping_application_mng_lock_);
+ return is_stopping_;
+}
+
void ApplicationManagerImpl::OnLowVoltage() {
LOG4CXX_AUTO_TRACE(logger_);
is_low_voltage_ = true;
diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc
new file mode 100644
index 0000000000..af03e704eb
--- /dev/null
+++ b/src/components/application_manager/src/rpc_handler_impl.cc
@@ -0,0 +1,389 @@
+/*
+ * 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_handler_impl.h"
+
+namespace application_manager {
+namespace rpc_handler {
+
+CREATE_LOGGERPTR_LOCAL(logger_, "RPCHandlerImpl")
+namespace formatters = NsSmartDeviceLink::NsJSONHandler::Formatters;
+namespace jhs = NsSmartDeviceLink::NsJSONHandler::strings;
+
+RPCHandlerImpl::RPCHandlerImpl(ApplicationManager& app_manager)
+ : app_manager_(app_manager)
+ , messages_from_mobile_("AM FromMobile", this)
+ , messages_from_hmi_("AM FromHMI", this)
+ , hmi_so_factory_(hmi_apis::HMI_API())
+ , mobile_so_factory_(mobile_apis::MOBILE_API())
+#ifdef TELEMETRY_MONITOR
+ , metric_observer_(NULL)
+#endif // TELEMETRY_MONITOR
+{
+}
+
+RPCHandlerImpl::~RPCHandlerImpl() {}
+
+void RPCHandlerImpl::ProcessMessageFromMobile(
+ const utils::SharedPtr<Message> message) {
+ LOG4CXX_AUTO_TRACE(logger_);
+#ifdef TELEMETRY_MONITOR
+ AMTelemetryObserver::MessageMetricSharedPtr metric(
+ new AMTelemetryObserver::MessageMetric());
+ metric->begin = date_time::DateTime::getCurrentTime();
+#endif // TELEMETRY_MONITOR
+ smart_objects::SmartObjectSPtr so_from_mobile =
+ utils::MakeShared<smart_objects::SmartObject>();
+
+ DCHECK_OR_RETURN_VOID(so_from_mobile);
+ if (!so_from_mobile) {
+ LOG4CXX_ERROR(logger_, "Null pointer");
+ return;
+ }
+
+ if (!ConvertMessageToSO(*message, *so_from_mobile)) {
+ LOG4CXX_ERROR(logger_, "Cannot create smart object from message");
+ return;
+ }
+#ifdef TELEMETRY_MONITOR
+ metric->message = so_from_mobile;
+#endif // TELEMETRY_MONITOR
+
+ if (!app_manager_.GetRPCService().ManageMobileCommand(
+ so_from_mobile, commands::Command::ORIGIN_MOBILE)) {
+ LOG4CXX_ERROR(logger_, "Received command didn't run successfully");
+ }
+#ifdef TELEMETRY_MONITOR
+ metric->end = date_time::DateTime::getCurrentTime();
+ if (metric_observer_) {
+ metric_observer_->OnMessage(metric);
+ }
+#endif // TELEMETRY_MONITOR
+}
+
+void RPCHandlerImpl::ProcessMessageFromHMI(
+ const utils::SharedPtr<Message> message) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ smart_objects::SmartObjectSPtr smart_object(new smart_objects::SmartObject);
+
+ if (!smart_object) {
+ LOG4CXX_ERROR(logger_, "Null pointer");
+ return;
+ }
+
+#ifdef HMI_DBUS_API
+ *smart_object = message->smart_object();
+#else
+ if (!ConvertMessageToSO(*message, *smart_object)) {
+ if (application_manager::MessageType::kResponse ==
+ (*smart_object)[strings::params][strings::message_type].asInt()) {
+ (*smart_object).erase(strings::msg_params);
+ (*smart_object)[strings::params][hmi_response::code] =
+ hmi_apis::Common_Result::INVALID_DATA;
+ (*smart_object)[strings::msg_params][strings::info] =
+ std::string("Received invalid data on HMI response");
+ } else {
+ LOG4CXX_ERROR(logger_, "Cannot create smart object from message");
+ return;
+ }
+ }
+#endif // HMI_DBUS_API
+
+ LOG4CXX_DEBUG(logger_, "Converted message, trying to create hmi command");
+ if (!app_manager_.GetRPCService().ManageHMICommand(smart_object)) {
+ LOG4CXX_ERROR(logger_, "Received command didn't run successfully");
+ }
+}
+void RPCHandlerImpl::Handle(const impl::MessageFromMobile message) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (!message) {
+ LOG4CXX_ERROR(logger_, "Null-pointer message received.");
+ return;
+ }
+ if (app_manager_.is_stopping()) {
+ LOG4CXX_INFO(logger_, "Application manager is stopping");
+ return;
+ }
+#ifdef SDL_REMOTE_CONTROL
+ if (app_manager_.GetPluginManager().IsMessageForPlugin(message)) {
+ if (functional_modules::ProcessResult::PROCESSED ==
+ app_manager_.GetPluginManager().ProcessMessage(message)) {
+ LOG4CXX_INFO(logger_, "Message is processed by plugin.");
+ return;
+ }
+ }
+#endif
+ ProcessMessageFromMobile(message);
+}
+
+void RPCHandlerImpl::Handle(const impl::MessageFromHmi message) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (!message) {
+ LOG4CXX_ERROR(logger_, "Null-pointer message received.");
+ return;
+ }
+
+#ifdef SDL_REMOTE_CONTROL
+ if (app_manager_.GetPluginManager().IsHMIMessageForPlugin(message)) {
+ functional_modules::ProcessResult result =
+ app_manager_.GetPluginManager().ProcessHMIMessage(message);
+ if (functional_modules::ProcessResult::PROCESSED == result ||
+ functional_modules::ProcessResult::FAILED == result) {
+ LOG4CXX_INFO(logger_, "Message is processed by plugin.");
+ return;
+ }
+ }
+#endif
+
+ ProcessMessageFromHMI(message);
+}
+
+void RPCHandlerImpl::OnMessageReceived(
+ const protocol_handler::RawMessagePtr message) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (!message) {
+ LOG4CXX_ERROR(logger_, "Null-pointer message received.");
+ NOTREACHED();
+ return;
+ }
+
+ utils::SharedPtr<Message> outgoing_message = ConvertRawMsgToMessage(message);
+
+ if (outgoing_message) {
+ LOG4CXX_DEBUG(logger_, "Posting new Message");
+ messages_from_mobile_.PostMessage(
+ impl::MessageFromMobile(outgoing_message));
+ }
+}
+
+void RPCHandlerImpl::OnMobileMessageSent(
+ const protocol_handler::RawMessagePtr message) {
+ LOG4CXX_AUTO_TRACE(logger_);
+}
+
+void RPCHandlerImpl::OnMessageReceived(
+ hmi_message_handler::MessageSharedPointer message) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (!message) {
+ LOG4CXX_ERROR(logger_, "Null-pointer message received.");
+ NOTREACHED();
+ return;
+ }
+
+ messages_from_hmi_.PostMessage(impl::MessageFromHmi(message));
+}
+
+void RPCHandlerImpl::OnErrorSending(
+ hmi_message_handler::MessageSharedPointer message) {
+ return;
+}
+
+#ifdef TELEMETRY_MONITOR
+void RPCHandlerImpl::SetTelemetryObserver(AMTelemetryObserver* observer) {
+ metric_observer_ = observer;
+}
+#endif // TELEMETRY_MONITOR
+
+bool RPCHandlerImpl::ConvertMessageToSO(
+ const Message& message,
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& output) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_DEBUG(logger_,
+ "\t\t\tMessage to convert: protocol "
+ << message.protocol_version() << "; json "
+ << message.json_message());
+
+ switch (message.protocol_version()) {
+ case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5:
+ case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4:
+ case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_3:
+ case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_2: {
+ const bool conversion_result =
+ formatters::CFormatterJsonSDLRPCv2::fromString(
+ message.json_message(),
+ output,
+ message.function_id(),
+ message.type(),
+ message.correlation_id());
+ if (!conversion_result ||
+ !mobile_so_factory().attachSchema(output, true) ||
+ ((output.validate() != smart_objects::Errors::OK))) {
+ LOG4CXX_WARN(logger_,
+ "Failed to parse string to smart object :"
+ << message.json_message());
+ utils::SharedPtr<smart_objects::SmartObject> response(
+ MessageHelper::CreateNegativeResponse(
+ message.connection_key(),
+ message.function_id(),
+ message.correlation_id(),
+ mobile_apis::Result::INVALID_DATA));
+ app_manager_.GetRPCService().ManageMobileCommand(
+ response, commands::Command::ORIGIN_SDL);
+ return false;
+ }
+ LOG4CXX_DEBUG(logger_,
+ "Convertion result for sdl object is true function_id "
+ << output[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt());
+
+ output[strings::params][strings::connection_key] =
+ message.connection_key();
+ output[strings::params][strings::protocol_version] =
+ message.protocol_version();
+ if (message.binary_data()) {
+ if (message.payload_size() < message.data_size()) {
+ LOG4CXX_ERROR(logger_,
+ "Incomplete binary"
+ << " binary size should be " << message.data_size()
+ << " payload data size is "
+ << message.payload_size());
+ utils::SharedPtr<smart_objects::SmartObject> response(
+ MessageHelper::CreateNegativeResponse(
+ message.connection_key(),
+ message.function_id(),
+ message.correlation_id(),
+ mobile_apis::Result::INVALID_DATA));
+ app_manager_.GetRPCService().ManageMobileCommand(
+ response, commands::Command::ORIGIN_SDL);
+ return false;
+ }
+ output[strings::params][strings::binary_data] =
+ *(message.binary_data());
+ }
+ break;
+ }
+ case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_HMI: {
+#ifdef ENABLE_LOG
+ int32_t result =
+#endif
+ formatters::FormatterJsonRpc::FromString<
+ hmi_apis::FunctionID::eType,
+ hmi_apis::messageType::eType>(message.json_message(), output);
+ LOG4CXX_DEBUG(logger_,
+ "Convertion result: "
+ << result << " function id "
+ << output[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt());
+ if (!hmi_so_factory().attachSchema(output, false)) {
+ LOG4CXX_WARN(logger_, "Failed to attach schema to object.");
+ return false;
+ }
+ if (output.validate() != smart_objects::Errors::OK) {
+ LOG4CXX_ERROR(logger_, "Incorrect parameter from HMI");
+ return false;
+ }
+ break;
+ }
+ case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_1: {
+ static NsSmartDeviceLinkRPC::V1::v4_protocol_v1_2_no_extra v1_shema;
+
+ if (message.function_id() == 0 || message.type() == kUnknownType) {
+ LOG4CXX_ERROR(logger_, "Message received: UNSUPPORTED_VERSION");
+
+ int32_t conversation_result =
+ formatters::CFormatterJsonSDLRPCv1::fromString<
+ NsSmartDeviceLinkRPC::V1::FunctionID::eType,
+ NsSmartDeviceLinkRPC::V1::messageType::eType>(
+ message.json_message(), output);
+
+ if (formatters::CFormatterJsonSDLRPCv1::kSuccess ==
+ conversation_result) {
+ smart_objects::SmartObject params = smart_objects::SmartObject(
+ smart_objects::SmartType::SmartType_Map);
+
+ output[strings::params][strings::message_type] =
+ NsSmartDeviceLinkRPC::V1::messageType::response;
+ output[strings::params][strings::connection_key] =
+ message.connection_key();
+
+ output[strings::msg_params] = smart_objects::SmartObject(
+ smart_objects::SmartType::SmartType_Map);
+ output[strings::msg_params][strings::success] = false;
+ output[strings::msg_params][strings::result_code] =
+ NsSmartDeviceLinkRPC::V1::Result::UNSUPPORTED_VERSION;
+
+ smart_objects::SmartObjectSPtr msg_to_send =
+ new smart_objects::SmartObject(output);
+ v1_shema.attachSchema(*msg_to_send, false);
+ app_manager_.GetRPCService().SendMessageToMobile(msg_to_send);
+ return false;
+ }
+ }
+ break;
+ }
+ default:
+ LOG4CXX_WARN(logger_,
+ "Application used unsupported protocol :"
+ << message.protocol_version() << ".");
+ return false;
+ }
+
+ LOG4CXX_DEBUG(logger_, "Successfully parsed message into smart object");
+ return true;
+}
+
+utils::SharedPtr<Message> RPCHandlerImpl::ConvertRawMsgToMessage(
+ const protocol_handler::RawMessagePtr message) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK(message);
+ utils::SharedPtr<Message> outgoing_message;
+
+ LOG4CXX_DEBUG(logger_, "Service type." << message->service_type());
+ if (message->service_type() != protocol_handler::kRpc &&
+ message->service_type() != protocol_handler::kBulk) {
+ // skip this message, not under handling of ApplicationManager
+ LOG4CXX_TRACE(logger_, "Skipping message; not the under AM handling.");
+ return outgoing_message;
+ }
+
+ Message* convertion_result =
+ MobileMessageHandler::HandleIncomingMessageProtocol(message);
+
+ if (convertion_result) {
+ outgoing_message = convertion_result;
+ } else {
+ LOG4CXX_ERROR(logger_, "Received invalid message");
+ }
+ return outgoing_message;
+}
+
+hmi_apis::HMI_API& RPCHandlerImpl::hmi_so_factory() {
+ return hmi_so_factory_;
+}
+
+mobile_apis::MOBILE_API& RPCHandlerImpl::mobile_so_factory() {
+ return mobile_so_factory_;
+}
+}
+}
diff --git a/src/components/application_manager/src/rpc_service_impl.cc b/src/components/application_manager/src/rpc_service_impl.cc
index a6c99c08ba..3be10a75f8 100644
--- a/src/components/application_manager/src/rpc_service_impl.cc
+++ b/src/components/application_manager/src/rpc_service_impl.cc
@@ -43,11 +43,13 @@ RPCServiceImpl::RPCServiceImpl(
ApplicationManager& app_manager,
request_controller::RequestController& request_ctrl,
protocol_handler::ProtocolHandler* protocol_handler,
- hmi_message_handler::HMIMessageHandler* hmi_handler)
+ hmi_message_handler::HMIMessageHandler* hmi_handler,
+ CommandHolder& commands_holder)
: app_manager_(app_manager)
, request_ctrl_(request_ctrl)
, protocol_handler_(protocol_handler)
, hmi_handler_(hmi_handler)
+ , commands_holder_(commands_holder)
, messages_to_mobile_("AM ToMobile", this)
, messages_to_hmi_("AM ToHMI", this)
, hmi_so_factory_(hmi_apis::HMI_API())
@@ -83,6 +85,15 @@ bool RPCServiceImpl::ManageMobileCommand(
return false;
}
+ const uint32_t connection_key = static_cast<uint32_t>(
+ (*message)[strings::params][strings::connection_key].asUInt());
+
+ auto app_ptr = app_manager_.application(connection_key);
+ if (app_ptr && app_manager_.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());
@@ -93,9 +104,6 @@ bool RPCServiceImpl::ManageMobileCommand(
? (*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();
@@ -253,6 +261,19 @@ bool RPCServiceImpl::ManageHMICommand(
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 = app_manager_.application(static_cast<uint32_t>(connection_key));
+ if (app && app_manager_.IsAppInReconnectMode(app->policy_app_id())) {
+ commands_holder_.Suspend(
+ app, CommandHolder::CommandType::kHmiCommand, message);
+ return true;
+ }
+ }
+
int32_t message_type =
(*(message.get()))[strings::params][strings::message_type].asInt();
diff --git a/src/components/application_manager/test/application_manager_impl_mock_hmi_test.cc b/src/components/application_manager/test/application_manager_impl_mock_hmi_test.cc
index b9437d55e0..3594d21113 100644
--- a/src/components/application_manager/test/application_manager_impl_mock_hmi_test.cc
+++ b/src/components/application_manager/test/application_manager_impl_mock_hmi_test.cc
@@ -49,6 +49,7 @@
#include "policy/mock_policy_settings.h"
#include "policy/usage_statistics/mock_statistics_manager.h"
#include "protocol_handler/mock_session_observer.h"
+#include "protocol_handler/mock_protocol_handler.h"
namespace test {
namespace components {
@@ -113,6 +114,7 @@ class ApplicationManagerImplMockHmiTest : public ::testing::Test {
app_manager_impl_->set_connection_handler(&mock_connection_handler_);
app_manager_impl_->resume_controller().set_resumption_storage(
mock_storage_);
+ app_manager_impl_->set_protocol_handler(&mock_protocol_handler_);
}
void SetCommonExpectationOnAppReconnection(
@@ -149,6 +151,7 @@ class ApplicationManagerImplMockHmiTest : public ::testing::Test {
mock_connection_handler_;
NiceMock<protocol_handler_test::MockSessionObserver> mock_session_observer_;
NiceMock<MockApplicationManagerSettings> mock_application_manager_settings_;
+ NiceMock<protocol_handler_test::MockProtocolHandler> mock_protocol_handler_;
std::unique_ptr<am::ApplicationManagerImpl> app_manager_impl_;
};
@@ -222,9 +225,9 @@ TEST_F(ApplicationManagerImplMockHmiTest,
EXPECT_CALL(*cmd_3, Init()).Times(0);
// Act
- app_manager_impl_->ManageHMICommand(hmi_msg_1);
- app_manager_impl_->ManageHMICommand(hmi_msg_2);
- app_manager_impl_->ManageHMICommand(hmi_msg_3);
+ app_manager_impl_->GetRPCService().ManageHMICommand(hmi_msg_1);
+ app_manager_impl_->GetRPCService().ManageHMICommand(hmi_msg_2);
+ app_manager_impl_->GetRPCService().ManageHMICommand(hmi_msg_3);
EXPECT_CALL(*mock_hmi_factory, CreateCommand(_, _))
.WillOnce(Return(cmd_1))
diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc
index e910ee2e15..c7bf7139ff 100644
--- a/src/components/application_manager/test/application_manager_impl_test.cc
+++ b/src/components/application_manager/test/application_manager_impl_test.cc
@@ -53,6 +53,7 @@
#include "policy/usage_statistics/mock_statistics_manager.h"
#include "protocol/bson_object_keys.h"
#include "protocol_handler/mock_session_observer.h"
+#include "protocol_handler/mock_protocol_handler.h"
#include "utils/custom_string.h"
#include "utils/file_system.h"
#include "utils/lock.h"
@@ -146,7 +147,7 @@ class ApplicationManagerImplTest : public ::testing::Test {
app_manager_impl_.reset(new am::ApplicationManagerImpl(
mock_application_manager_settings_, mock_policy_settings_));
mock_app_ptr_ = utils::SharedPtr<MockApplication>(new MockApplication());
-
+ app_manager_impl_->set_protocol_handler(&mock_protocol_handler_);
ASSERT_TRUE(app_manager_impl_.get());
ASSERT_TRUE(mock_app_ptr_.get());
}
@@ -192,10 +193,10 @@ class ApplicationManagerImplTest : public ::testing::Test {
application_manager::MockMessageHelper* mock_message_helper_;
uint32_t app_id_;
utils::SharedPtr<MockApplication> mock_app_ptr_;
- MockRPCService rpc_service_;
+ NiceMock<protocol_handler_test::MockProtocolHandler> mock_protocol_handler_;
};
-TEST_F(ApplicationManagerImplTest, DISABLED_ProcessQueryApp_ExpectSuccess) {
+TEST_F(ApplicationManagerImplTest, ProcessQueryApp_ExpectSuccess) {
using namespace NsSmartDeviceLink::NsSmartObjects;
SmartObject app_data;
const uint32_t connection_key = 65537u;
@@ -212,7 +213,6 @@ TEST_F(ApplicationManagerImplTest, DISABLED_ProcessQueryApp_ExpectSuccess) {
.WillByDefault(Return(sptr));
ON_CALL(*mock_message_helper_, CreateNegativeResponse(_, _, _, _))
.WillByDefault(Return(sptr));
- ON_CALL(rpc_service_, ManageHMICommand(_));
app_manager_impl_->ProcessQueryApp(sm_object, connection_key);
}
@@ -791,7 +791,6 @@ TEST_F(ApplicationManagerImplTest,
EXPECT_CALL(*mock_message_helper_, CreateDeviceListSO(_, _, _))
.WillOnce(Return(smart_objects::SmartObjectSPtr()));
-
app_manager_impl_->OnDeviceSwitchingStart(switching_device,
non_switching_device);
diff --git a/src/components/application_manager/test/command_holder_test.cc b/src/components/application_manager/test/command_holder_test.cc
index e10cd5d008..64d65111c7 100644
--- a/src/components/application_manager/test/command_holder_test.cc
+++ b/src/components/application_manager/test/command_holder_test.cc
@@ -40,6 +40,7 @@
#include "application_manager/mock_application_manager.h"
#include "application_manager/mock_application.h"
+#include "application_manager/mock_rpc_service.h"
namespace test {
namespace components {
@@ -47,6 +48,7 @@ namespace application_manager_test {
using testing::_;
using testing::Return;
+using ::testing::ReturnRef;
namespace am = application_manager;
@@ -65,6 +67,8 @@ class CommandHolderImplTest : public testing::Test {
.WillByDefault(Return(kHmiApplicationId_));
ON_CALL(*mock_app_ptr_, policy_app_id())
.WillByDefault(Return(kPolicyAppId_));
+ ON_CALL(mock_app_manager_, GetRPCService())
+ .WillByDefault(ReturnRef(rpc_service_));
}
MockApplicationManager mock_app_manager_;
@@ -73,6 +77,7 @@ class CommandHolderImplTest : public testing::Test {
const uint32_t kConnectionKey_;
utils::SharedPtr<smart_objects::SmartObject> cmd_ptr_;
utils::SharedPtr<MockApplication> mock_app_ptr_;
+ application_manager_test::MockRPCService rpc_service_;
};
TEST_F(CommandHolderImplTest, HoldOne_ExpectReleaseOne) {
@@ -81,7 +86,7 @@ TEST_F(CommandHolderImplTest, HoldOne_ExpectReleaseOne) {
mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_);
// Act
- EXPECT_CALL(mock_app_manager_, ManageHMICommand(cmd_ptr_));
+ EXPECT_CALL(rpc_service_, ManageHMICommand(cmd_ptr_));
cmd_holder.Resume(mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand);
}
@@ -96,7 +101,7 @@ TEST_F(CommandHolderImplTest, HoldMany_ExpectReleaseSame) {
} while (iterations < 5);
// Act
- EXPECT_CALL(mock_app_manager_, ManageHMICommand(cmd_ptr_)).Times(iterations);
+ EXPECT_CALL(rpc_service_, ManageHMICommand(cmd_ptr_)).Times(iterations);
cmd_holder.Resume(mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand);
}
@@ -109,7 +114,7 @@ TEST_F(CommandHolderImplTest, Hold_Drop_ExpectNoReleased) {
// Act
cmd_holder.Clear(mock_app_ptr_);
- EXPECT_CALL(mock_app_manager_, ManageHMICommand(cmd_ptr_)).Times(0);
+ EXPECT_CALL(rpc_service_, ManageHMICommand(cmd_ptr_)).Times(0);
cmd_holder.Resume(mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand);
}
@@ -124,7 +129,7 @@ TEST_F(CommandHolderImplTest, Hold_ReleaseAnotherId_ExpectNoReleased) {
utils::SharedPtr<MockApplication> another_app =
utils::MakeShared<MockApplication>();
- EXPECT_CALL(mock_app_manager_, ManageHMICommand(cmd_ptr_)).Times(0);
+ EXPECT_CALL(rpc_service_, ManageHMICommand(cmd_ptr_)).Times(0);
cmd_holder.Resume(another_app, am::CommandHolder::CommandType::kHmiCommand);
}
@@ -143,7 +148,7 @@ TEST_F(CommandHolderImplTest, Hold_DropAnotherId_ExpectReleased) {
utils::MakeShared<MockApplication>();
cmd_holder.Clear(another_app);
- EXPECT_CALL(mock_app_manager_, ManageHMICommand(cmd_ptr_)).Times(iterations);
+ EXPECT_CALL(rpc_service_, ManageHMICommand(cmd_ptr_)).Times(iterations);
cmd_holder.Resume(mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand);
}
@@ -157,11 +162,11 @@ TEST_F(CommandHolderImplTest, Hold_Mobile_and_HMI_commands_ExpectReleased) {
mock_app_ptr_, am::CommandHolder::CommandType::kMobileCommand, cmd_ptr_);
// Act
- EXPECT_CALL(mock_app_manager_, ManageHMICommand(cmd_ptr_));
+ EXPECT_CALL(rpc_service_, ManageHMICommand(cmd_ptr_));
cmd_holder.Resume(mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand);
EXPECT_CALL(
- mock_app_manager_,
+ rpc_service_,
ManageMobileCommand(cmd_ptr_,
am::commands::Command::CommandOrigin::ORIGIN_MOBILE));
cmd_holder.Resume(mock_app_ptr_,
diff --git a/src/components/application_manager/test/commands/hmi/get_urls_test.cc b/src/components/application_manager/test/commands/hmi/get_urls_test.cc
index 864b5356ee..4344e03256 100644
--- a/src/components/application_manager/test/commands/hmi/get_urls_test.cc
+++ b/src/components/application_manager/test/commands/hmi/get_urls_test.cc
@@ -107,6 +107,7 @@ class GetUrlsTest : public CommandRequestTest<CommandsTestMocks::kIsNice> {
TEST_F(GetUrlsTest, RUN_SUCCESS) {
EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true));
+ ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
request_command_->Run();
}
@@ -328,6 +329,7 @@ TEST_F(GetUrlsTest, ProcessServiceURLs_PolicyDefaultId_SUCCESS) {
MockAppPtr mock_app = CreateMockApp();
EXPECT_CALL(app_mngr_, application_by_policy_id(_))
.WillOnce(Return(mock_app));
+ ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
request_command_->Run();
EXPECT_FALSE((*command_msg_)[am::strings::msg_params].keyExists(
diff --git a/src/components/application_manager/test/commands/hmi/sdl_activate_app_request_test.cc b/src/components/application_manager/test/commands/hmi/sdl_activate_app_request_test.cc
index b2c730d57b..4f59199006 100644
--- a/src/components/application_manager/test/commands/hmi/sdl_activate_app_request_test.cc
+++ b/src/components/application_manager/test/commands/hmi/sdl_activate_app_request_test.cc
@@ -245,6 +245,7 @@ TEST_F(SDLActivateAppRequestTest, DevicesAppsEmpty_SUCCESS) {
EXPECT_CALL(app_mngr_, state_controller())
.WillOnce(ReturnRef(mock_state_controller_));
+ EXPECT_CALL(app_mngr_, GetRPCService()).WillOnce(ReturnRef(rpc_service_));
EXPECT_CALL(mock_state_controller_,
IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI))
.WillOnce(Return(false));
diff --git a/src/components/application_manager/test/commands/mobile/alert_request_test.cc b/src/components/application_manager/test/commands/mobile/alert_request_test.cc
index 518ae39811..58fef38fbc 100644
--- a/src/components/application_manager/test/commands/mobile/alert_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/alert_request_test.cc
@@ -244,6 +244,7 @@ TEST_F(AlertRequestTest, OnEvent_UI_HmiSendSuccess_UNSUPPORTED_RESOURCE) {
hmi_apis::Common_Result::SUCCESS;
Event event_vr(hmi_apis::FunctionID::TTS_Speak);
event_vr.set_smart_object(*msg_tts);
+ ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
command->on_event(event_vr);
@@ -251,7 +252,6 @@ TEST_F(AlertRequestTest, OnEvent_UI_HmiSendSuccess_UNSUPPORTED_RESOURCE) {
event.set_smart_object(*msg);
MessageSharedPtr ui_command_result;
- ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
EXPECT_CALL(
rpc_service_,
ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
diff --git a/src/components/application_manager/test/commands/mobile/create_interaction_choice_set_test.cc b/src/components/application_manager/test/commands/mobile/create_interaction_choice_set_test.cc
index 61f7ef608b..223070b6af 100644
--- a/src/components/application_manager/test/commands/mobile/create_interaction_choice_set_test.cc
+++ b/src/components/application_manager/test/commands/mobile/create_interaction_choice_set_test.cc
@@ -262,6 +262,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest, Run_InvalidApp_UNSUCCESS) {
MockAppPtr invalid_app;
EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(invalid_app));
EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0);
+ ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
command_->Run();
}
@@ -276,6 +277,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest, Run_VerifyImageFail_UNSUCCESS) {
EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::INVALID_DATA));
EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0);
+ ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
command_->Run();
}
@@ -298,6 +300,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest, Run_FindChoiceSetFail_UNSUCCESS) {
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(invalid_choice_set_id));
EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0);
+ ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
command_->Run();
}
@@ -331,6 +334,8 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
+ ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
+
EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0);
command_->Run();
}
@@ -363,6 +368,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
.WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
+ ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
if ((*message_)[am::strings::msg_params][am::strings::choice_set][0]
.keyExists(am::strings::menu_name)) {
@@ -443,6 +449,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
.Times(AtLeast(2))
.WillOnce(Return(kConnectionKey))
.WillOnce(Return(kConnectionKey));
+ ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
command_->Run();
}
@@ -477,6 +484,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
.WillOnce(Return(choice_set_id));
EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
+ ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
command_->Run();
}
@@ -526,6 +534,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_ValidVrNoError_SUCCESS) {
EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
+ ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
command_->Run();
EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _));
@@ -559,6 +568,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
+ ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
command_->Run();
EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _));
EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)).Times(0);
@@ -593,6 +603,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
+ EXPECT_CALL(app_mngr_, GetRPCService())
+ .Times(3)
+ .WillRepeatedly(ReturnRef(rpc_service_));
command_->Run();
FillMessageFieldsItem2(message_);
@@ -640,6 +653,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
+ EXPECT_CALL(app_mngr_, GetRPCService())
+ .Times(3)
+ .WillRepeatedly(ReturnRef(rpc_service_));
command_->Run();
FillMessageFieldsItem2(message_);
@@ -682,6 +698,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnTimeOut_InvalidApp_UNSUCCESS) {
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
+ EXPECT_CALL(app_mngr_, GetRPCService())
+ .Times(3)
+ .WillRepeatedly(ReturnRef(rpc_service_));
command_->Run();
FillMessageFieldsItem2(message_);
@@ -726,6 +745,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
.WillOnce(Return(choice_set_id));
EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
+ EXPECT_CALL(app_mngr_, GetRPCService())
+ .Times(6)
+ .WillRepeatedly(ReturnRef(rpc_service_));
command_->Run();
FillMessageFieldsItem2(message_);
@@ -796,6 +818,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest, Run_ErrorFromHmiFalse_UNSUCCESS) {
EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)).Times(2);
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
+ EXPECT_CALL(app_mngr_, GetRPCService())
+ .Times(3)
+ .WillRepeatedly(ReturnRef(rpc_service_));
command_->Run();
FillMessageFieldsItem2(message_);
diff --git a/src/components/application_manager/test/commands/mobile/delete_command_request_test.cc b/src/components/application_manager/test/commands/mobile/delete_command_request_test.cc
index 07f0a01dda..c6daa1c779 100644
--- a/src/components/application_manager/test/commands/mobile/delete_command_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/delete_command_request_test.cc
@@ -129,6 +129,7 @@ class DeleteCommandRequestTest
ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
ON_CALL(app_mngr_, hmi_interfaces())
.WillByDefault(ReturnRef(hmi_interfaces_));
+ ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
}
NiceMock<MockHmiInterfaces> hmi_interfaces_;
@@ -161,7 +162,6 @@ TEST_F(DeleteCommandRequestTest,
ON_CALL(*mock_app_, FindCommand(kCommandId))
.WillByDefault(Return(test_msg.get()));
ON_CALL(*mock_app_, get_grammar_id()).WillByDefault(Return(kConnectionKey));
-
MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map));
(*msg)[am::strings::params][am::hmi_response::code] =
hmi_apis::Common_Result::SUCCESS;
@@ -184,7 +184,6 @@ TEST_F(DeleteCommandRequestTest,
EXPECT_CALL(*mock_app_, UpdateHash());
MessageSharedPtr vr_command_result;
- ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
EXPECT_CALL(
rpc_service_,
ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
@@ -221,7 +220,6 @@ TEST_F(DeleteCommandRequestTest,
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
ON_CALL(*app, FindCommand(kCommandId)).WillByDefault(Return(test_msg.get()));
ON_CALL(*app, get_grammar_id()).WillByDefault(Return(kConnectionKey));
-
MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map));
(*msg)[am::strings::params][am::hmi_response::code] =
hmi_apis::Common_Result::SUCCESS;
diff --git a/src/components/application_manager/test/commands/mobile/delete_interaction_choice_set_test.cc b/src/components/application_manager/test/commands/mobile/delete_interaction_choice_set_test.cc
index 7e7d1f6350..bb1a5c168b 100644
--- a/src/components/application_manager/test/commands/mobile/delete_interaction_choice_set_test.cc
+++ b/src/components/application_manager/test/commands/mobile/delete_interaction_choice_set_test.cc
@@ -194,19 +194,22 @@ TEST_F(DeleteInteractionChoiceSetRequestTest,
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillRepeatedly(Return(app_));
- InSequence seq;
+ {
+ InSequence seq;
- EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
- .WillOnce(Return(choice_set_id));
- EXPECT_CALL(*app_, is_perform_interaction_active()).WillOnce(Return(false));
- EXPECT_CALL(*app_, performinteraction_choice_set_map()).Times(0);
+ EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
+ .WillOnce(Return(choice_set_id));
+ EXPECT_CALL(*app_, is_perform_interaction_active()).WillOnce(Return(false));
+ EXPECT_CALL(*app_, performinteraction_choice_set_map()).Times(0);
- EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
- .WillOnce(Return(invalid_choice_set_id));
+ EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
+ .WillOnce(Return(invalid_choice_set_id));
- EXPECT_CALL(*app_, app_id()).WillOnce(Return(kConnectionKey));
- EXPECT_CALL(*app_, RemoveChoiceSet(kChoiceSetId));
- EXPECT_CALL(*app_, UpdateHash());
+ EXPECT_CALL(*app_, app_id()).WillOnce(Return(kConnectionKey));
+ EXPECT_CALL(*app_, RemoveChoiceSet(kChoiceSetId));
+ EXPECT_CALL(*app_, UpdateHash());
+ }
+ ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
DeleteInteractionChoiceSetRequestPtr command =
CreateCommand<DeleteInteractionChoiceSetRequest>(message_);
@@ -229,21 +232,28 @@ TEST_F(DeleteInteractionChoiceSetRequestTest, Run_SendVrDeleteCommand_SUCCESS) {
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillRepeatedly(Return(app_));
- InSequence seq;
+ {
+ InSequence seq;
- EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
- .WillOnce(Return(choice_set_id));
- EXPECT_CALL(*app_, is_perform_interaction_active()).WillOnce(Return(false));
- EXPECT_CALL(*app_, performinteraction_choice_set_map()).Times(0);
+ EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
+ .WillOnce(Return(choice_set_id));
+ EXPECT_CALL(*app_, is_perform_interaction_active()).WillOnce(Return(false));
+ EXPECT_CALL(*app_, performinteraction_choice_set_map()).Times(0);
- EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
- .WillOnce(Return(choice_set_id));
+ EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId))
+ .WillOnce(Return(choice_set_id));
- EXPECT_CALL(*app_, app_id())
- .WillOnce(Return(kConnectionKey))
- .WillOnce(Return(kConnectionKey));
- EXPECT_CALL(*app_, RemoveChoiceSet(kChoiceSetId));
- EXPECT_CALL(*app_, UpdateHash());
+ EXPECT_CALL(*app_, app_id())
+ .WillOnce(Return(kConnectionKey))
+ .WillOnce(Return(kConnectionKey));
+ EXPECT_CALL(*app_, RemoveChoiceSet(kChoiceSetId));
+ EXPECT_CALL(*app_, UpdateHash());
+ }
+ EXPECT_CALL(app_mngr_, GetRPCService())
+ .Times(2)
+ .WillRepeatedly(ReturnRef(rpc_service_));
+ EXPECT_CALL(rpc_service_, ManageHMICommand(_)).WillOnce(Return(true));
+ EXPECT_CALL(rpc_service_, ManageMobileCommand(_, _));
DeleteInteractionChoiceSetRequestPtr command =
CreateCommand<DeleteInteractionChoiceSetRequest>(message_);
diff --git a/src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc b/src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc
index 353e6e2310..39d54aa442 100644
--- a/src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc
+++ b/src/components/application_manager/test/commands/mobile/delete_sub_menu_test.cc
@@ -217,7 +217,11 @@ TEST_F(DeleteSubMenuRequestTest, Run_SendHMIRequest_SUCCESS) {
EXPECT_CALL(*app_, app_id()).WillOnce(Return(kConnectionKey));
EXPECT_CALL(app_mngr_, GetNextHMICorrelationID())
.WillOnce(Return(kCorrelationId));
-
+ ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
+ EXPECT_CALL(
+ rpc_service_,
+ ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteSubMenu)))
+ .WillOnce(Return(true));
command_->Run();
}
@@ -262,14 +266,26 @@ TEST_F(DeleteSubMenuRequestTest, OnEvent_DeleteSubmenu_SUCCESS) {
EXPECT_CALL(*app_, commands_map()).WillOnce(Return(accessor_));
EXPECT_CALL(*app_, app_id()).WillOnce(Return(kConnectionKey));
EXPECT_CALL(*app_, get_grammar_id()).WillOnce(Return(kGrammarId));
+ ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
+ EXPECT_CALL(
+ rpc_service_,
+ ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::VR_DeleteCommand)))
+ .WillOnce(Return(true));
EXPECT_CALL(*app_, commands_map()).WillOnce(Return(accessor_));
EXPECT_CALL(*app_, app_id()).WillOnce(Return(kConnectionKey));
EXPECT_CALL(*app_, RemoveCommand(_)).WillOnce(DeleteCommand(&commands_map_));
+ EXPECT_CALL(
+ rpc_service_,
+ ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteCommand)))
+ .WillOnce(Return(true));
EXPECT_CALL(*app_, RemoveSubMenu(_));
+ EXPECT_CALL(
+ rpc_service_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS),
+ am::commands::Command::ORIGIN_SDL));
EXPECT_CALL(*app_, UpdateHash());
-
DeleteSubMenuRequestPtr command =
CreateCommand<DeleteSubMenuRequest>(message_);
@@ -304,11 +320,14 @@ TEST_F(DeleteSubMenuRequestTest,
std::make_pair(0, &((*message_)[am::strings::msg_params])));
EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app_));
- EXPECT_CALL(app_mngr_, GetRPCService()).Times(0);
EXPECT_CALL(rpc_service_, ManageHMICommand(_)).Times(0);
EXPECT_CALL(*app_, commands_map()).Times(2).WillRepeatedly(Return(accessor_));
EXPECT_CALL(*app_, RemoveCommand(_)).Times(0);
-
+ ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
+ EXPECT_CALL(
+ rpc_service_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS),
+ am::commands::Command::ORIGIN_SDL));
command_->on_event(event);
}
@@ -328,11 +347,14 @@ TEST_F(DeleteSubMenuRequestTest,
std::make_pair(0, &((*message_)[am::strings::msg_params])));
EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app_));
- EXPECT_CALL(app_mngr_, GetRPCService()).Times(0);
EXPECT_CALL(rpc_service_, ManageHMICommand(_)).Times(0);
EXPECT_CALL(*app_, commands_map()).Times(2).WillRepeatedly(Return(accessor_));
EXPECT_CALL(*app_, RemoveCommand(_)).Times(0);
-
+ ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
+ EXPECT_CALL(
+ rpc_service_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS),
+ am::commands::Command::ORIGIN_SDL));
command_->on_event(event);
}
diff --git a/src/components/application_manager/test/commands/mobile/on_button_notification_commands_test.cc b/src/components/application_manager/test/commands/mobile/on_button_notification_commands_test.cc
index ace2b0f628..a08a43c97e 100644
--- a/src/components/application_manager/test/commands/mobile/on_button_notification_commands_test.cc
+++ b/src/components/application_manager/test/commands/mobile/on_button_notification_commands_test.cc
@@ -132,8 +132,7 @@ TYPED_TEST(OnButtonNotificationCommandsTest,
SharedPtr<Notification> command(
this->template CreateCommand<Notification>(notification_msg));
- EXPECT_CALL(this->app_mngr_, GetRPCService())
- .WillOnce(ReturnRef(this->rpc_service_));
+ EXPECT_CALL(this->app_mngr_, GetRPCService()).Times(0);
EXPECT_CALL(this->rpc_service_, SendMessageToMobile(_, _)).Times(0);
command->Run();
diff --git a/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc b/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc
index 3727e03d6b..fab59fbed2 100644
--- a/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc
+++ b/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc
@@ -394,7 +394,7 @@ TEST_F(PerformAudioPassThruRequestTest,
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_TTS));
ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
- EXPECT_CALL(app_mngr_, GetRPCService()).Times(0);
+ ON_CALL(app_mngr_, GetRPCService());
EXPECT_CALL(rpc_service_, ManageMobileCommand(_, _)).Times(0);
CallOnEvent on_event_caller(*command_sptr_, event);
diff --git a/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc b/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc
index 6f7ab7d149..22c6dd77ab 100644
--- a/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc
@@ -188,6 +188,7 @@ class RegisterAppInterfaceRequestTest
mock_hmi_interfaces_,
GetInterfaceFromFunction(hmi_apis::FunctionID::UI_ChangeRegistration))
.WillByDefault(Return(am::HmiInterfaces::HMI_INTERFACE_UI));
+ ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
}
void SetCommonExpectionsOnSwitchedApplication(
@@ -195,28 +196,28 @@ class RegisterAppInterfaceRequestTest
EXPECT_CALL(mock_policy_handler_, AddApplication(_, _)).Times(0);
EXPECT_CALL(
- app_mngr_,
+ rpc_service_,
ManageMobileCommand(MobileResultCodeIs(response_result_code), _));
- EXPECT_CALL(app_mngr_,
+ EXPECT_CALL(rpc_service_,
ManageHMICommand(HMIResultCodeIs(
hmi_apis::FunctionID::BasicCommunication_OnAppRegistered)))
.Times(0);
- EXPECT_CALL(app_mngr_,
+ EXPECT_CALL(rpc_service_,
ManageHMICommand(HMIResultCodeIs(
hmi_apis::FunctionID::Buttons_OnButtonSubscription)))
.Times(0);
- EXPECT_CALL(app_mngr_,
+ EXPECT_CALL(rpc_service_,
ManageHMICommand(HMIResultCodeIs(
hmi_apis::FunctionID::UI_ChangeRegistration))).Times(0);
- EXPECT_CALL(app_mngr_,
+ EXPECT_CALL(rpc_service_,
ManageHMICommand(HMIResultCodeIs(
hmi_apis::FunctionID::TTS_ChangeRegistration))).Times(0);
- EXPECT_CALL(app_mngr_,
+ EXPECT_CALL(rpc_service_,
ManageHMICommand(HMIResultCodeIs(
hmi_apis::FunctionID::VR_ChangeRegistration))).Times(0);
diff --git a/src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc b/src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc
index 85d8594d7b..d450881af3 100644
--- a/src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc
+++ b/src/components/application_manager/test/commands/mobile/reset_global_properties_test.cc
@@ -95,6 +95,7 @@ class ResetGlobalPropertiesRequestTest
.WillByDefault(Return(mock_app_));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
+ ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
}
MessageSharedPtr msg_;
@@ -110,7 +111,6 @@ TEST_F(ResetGlobalPropertiesRequestTest, Run_InvalidApp_UNSUCCESS) {
EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(invalid_app));
MessageSharedPtr command_result;
- ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
EXPECT_CALL(
rpc_service_,
ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
@@ -172,7 +172,6 @@ TEST_F(ResetGlobalPropertiesRequestTest, Run_InvalidVrHelp_UNSUCCESS) {
EXPECT_CALL(mock_message_helper_, CreateAppVrHelp(_))
.WillOnce(Return(vr_help));
- ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
EXPECT_CALL(rpc_service_, ManageHMICommand(_)).Times(0);
command_->Run();
@@ -240,8 +239,6 @@ TEST_F(ResetGlobalPropertiesRequestTest, Run_SUCCESS) {
EXPECT_CALL(*mock_app_, timeout_prompt())
.WillOnce(Return(so_help_prompt.get()));
- EXPECT_CALL(app_mngr_, GetRPCService())
- .WillRepeatedly(ReturnRef(rpc_service_));
EXPECT_CALL(rpc_service_,
ManageHMICommand(HMIResultCodeIs(
hmi_apis::FunctionID::UI_SetGlobalProperties)))
@@ -256,7 +253,7 @@ TEST_F(ResetGlobalPropertiesRequestTest, Run_SUCCESS) {
TEST_F(ResetGlobalPropertiesRequestTest, OnEvent_InvalidEventId_UNSUCCESS) {
Event event(hmi_apis::FunctionID::INVALID_ENUM);
- EXPECT_CALL(app_mngr_, GetRPCService()).Times(0);
+ // EXPECT_CALL(app_mngr_, GetRPCService()).Times(0);
EXPECT_CALL(rpc_service_, ManageMobileCommand(_, _)).Times(0);
command_->on_event(event);
}
@@ -280,11 +277,14 @@ TEST_F(ResetGlobalPropertiesRequestTest,
smart_objects::SmartType_Map);
EXPECT_CALL(mock_message_helper_, CreateAppVrHelp(_))
.WillOnce(Return(vr_help));
+ EXPECT_CALL(rpc_service_,
+ ManageHMICommand(HMIResultCodeIs(
+ hmi_apis::FunctionID::UI_SetGlobalProperties)))
+ .WillOnce(Return(true));
command_->Run();
event.set_smart_object(*msg_);
- ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
EXPECT_CALL(rpc_service_,
ManageMobileCommand(
MobileResultCodeIs(mobile_apis::Result::eType::SUCCESS),
@@ -323,14 +323,20 @@ TEST_F(ResetGlobalPropertiesRequestTest,
(*ui_msg)[am::strings::params][am::strings::correlation_id] = kCorrelationId;
(*ui_msg)[am::strings::params][am::hmi_response::code] =
hmi_apis::Common_Result::eType::SUCCESS;
-
+ EXPECT_CALL(rpc_service_,
+ ManageHMICommand(HMIResultCodeIs(
+ hmi_apis::FunctionID::UI_SetGlobalProperties)))
+ .WillOnce(Return(true));
+ EXPECT_CALL(rpc_service_,
+ ManageHMICommand(HMIResultCodeIs(
+ hmi_apis::FunctionID::TTS_SetGlobalProperties)))
+ .WillOnce(Return(true));
Event ui_event(hmi_apis::FunctionID::UI_SetGlobalProperties);
ui_event.set_smart_object(*ui_msg);
command_->Run();
command_->on_event(ui_event);
event.set_smart_object(*msg_);
- ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
EXPECT_CALL(
rpc_service_,
ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::WARNINGS),
@@ -359,7 +365,10 @@ TEST_F(ResetGlobalPropertiesRequestTest, OnEvent_InvalidApp_NoHashUpdate) {
EXPECT_CALL(*mock_app_, reset_vr_help());
EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true));
-
+ EXPECT_CALL(rpc_service_,
+ ManageHMICommand(HMIResultCodeIs(
+ hmi_apis::FunctionID::UI_SetGlobalProperties)))
+ .WillOnce(Return(true));
smart_objects::SmartObjectSPtr vr_help =
::utils::MakeShared<smart_objects::SmartObject>(
smart_objects::SmartType_Map);
@@ -371,7 +380,6 @@ TEST_F(ResetGlobalPropertiesRequestTest, OnEvent_InvalidApp_NoHashUpdate) {
ResetGlobalPropertiesRequestPtr command =
CreateCommand<ResetGlobalPropertiesRequest>(msg_);
command->Run();
- ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
EXPECT_CALL(rpc_service_,
ManageMobileCommand(
MobileResultCodeIs(mobile_apis::Result::eType::SUCCESS),
@@ -407,12 +415,10 @@ TEST_F(ResetGlobalPropertiesRequestTest,
EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true));
- ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
EXPECT_CALL(rpc_service_,
ManageHMICommand(HMIResultCodeIs(
hmi_apis::FunctionID::UI_SetGlobalProperties)))
.WillOnce(Return(true));
- ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
EXPECT_CALL(rpc_service_,
ManageHMICommand(HMIResultCodeIs(
hmi_apis::FunctionID::TTS_SetGlobalProperties)))
@@ -441,7 +447,6 @@ TEST_F(ResetGlobalPropertiesRequestTest,
EXPECT_CALL(mock_message_helper_, CreateNegativeResponse(_, _, _, _))
.WillOnce(Return(response));
const std::string info = "TTS component does not respond";
- ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
EXPECT_CALL(
rpc_service_,
ManageMobileCommand(
@@ -475,8 +480,6 @@ TEST_F(ResetGlobalPropertiesRequestTest,
EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true));
- EXPECT_CALL(app_mngr_, GetRPCService())
- .WillRepeatedly(ReturnRef(rpc_service_));
EXPECT_CALL(rpc_service_,
ManageHMICommand(HMIResultCodeIs(
hmi_apis::FunctionID::UI_SetGlobalProperties)))
@@ -507,7 +510,6 @@ TEST_F(ResetGlobalPropertiesRequestTest,
.WillOnce(Return(response));
const std::string info = "UI component does not respond";
- ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
EXPECT_CALL(
rpc_service_,
ManageMobileCommand(
@@ -542,8 +544,6 @@ TEST_F(ResetGlobalPropertiesRequestTest,
EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true));
- EXPECT_CALL(app_mngr_, GetRPCService())
- .WillRepeatedly(ReturnRef(rpc_service_));
EXPECT_CALL(rpc_service_,
ManageHMICommand(HMIResultCodeIs(
hmi_apis::FunctionID::UI_SetGlobalProperties)))
@@ -562,7 +562,7 @@ TEST_F(ResetGlobalPropertiesRequestTest,
mobile_apis::Result::GENERIC_ERROR;
EXPECT_CALL(mock_message_helper_, CreateNegativeResponse(_, _, _, _))
.WillOnce(Return(response));
- ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
+
EXPECT_CALL(
rpc_service_,
ManageMobileCommand(
diff --git a/src/components/application_manager/test/commands/mobile/send_location_request_test.cc b/src/components/application_manager/test/commands/mobile/send_location_request_test.cc
index 07978a24f2..0cff846f31 100644
--- a/src/components/application_manager/test/commands/mobile/send_location_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/send_location_request_test.cc
@@ -355,7 +355,11 @@ TEST_F(SendLocationRequestTest, OnEvent_Success) {
MockAppPtr app(CreateMockApp());
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillRepeatedly(Return(app));
-
+ ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
+ EXPECT_CALL(
+ rpc_service_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _))
+ .WillOnce(Return(false));
command_->on_event(event);
}
diff --git a/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc b/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc
index 897ce752c2..90703c8eb0 100644
--- a/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc
+++ b/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc
@@ -183,7 +183,6 @@ class SetGlobalPropertiesRequestTest
}
void ExpectInvalidData() {
- ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
EXPECT_CALL(rpc_service_,
ManageMobileCommand(
MobileResultCodeIs(mobile_apis::Result::INVALID_DATA),
@@ -220,6 +219,7 @@ class SetGlobalPropertiesRequestTest
ON_CALL(mock_hmi_interfaces_,
GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
+ ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
}
void ResultCommandExpectations(MessageSharedPtr msg,
@@ -292,13 +292,19 @@ TEST_F(SetGlobalPropertiesRequestTest,
ON_CALL(mock_message_helper_, VerifyImage(_, _, _))
.WillByDefault(Return(mobile_apis::Result::SUCCESS));
-
EXPECT_CALL(
mock_message_helper_,
VerifyTtsFiles(
(*msg_vr)[am::strings::msg_params][am::strings::help_prompt], _, _))
.WillOnce(Return(mobile_apis::Result::SUCCESS));
-
+ EXPECT_CALL(rpc_service_,
+ ManageHMICommand(HMIResultCodeIs(
+ hmi_apis::FunctionID::UI_SetGlobalProperties)))
+ .WillOnce(Return(true));
+ EXPECT_CALL(rpc_service_,
+ ManageHMICommand(HMIResultCodeIs(
+ hmi_apis::FunctionID::TTS_SetGlobalProperties)))
+ .WillOnce(Return(true));
(*msg_vr)[am::strings::params][am::hmi_response::code] =
hmi_apis::Common_Result::SUCCESS;
Event event_vr(hmi_apis::FunctionID::TTS_SetGlobalProperties);
@@ -308,7 +314,6 @@ TEST_F(SetGlobalPropertiesRequestTest,
command->on_event(event_vr);
MessageSharedPtr ui_command_result;
- ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
EXPECT_CALL(
rpc_service_,
ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
@@ -333,7 +338,6 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_SUCCESS_Expect_MessageNotSend) {
MockAppPtr mock_app(CreateMockApp());
ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app));
- ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
EXPECT_CALL(
rpc_service_,
ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
@@ -363,7 +367,6 @@ TEST_F(SetGlobalPropertiesRequestTest,
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
MessageSharedPtr response_to_mobile;
- ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
EXPECT_CALL(
rpc_service_,
ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
@@ -626,7 +629,6 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_VRCouldNotGenerate_INVALID_DATA) {
SharedPtr<SetGlobalPropertiesRequest> command(
CreateCommand<SetGlobalPropertiesRequest>(msg));
- ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
EXPECT_CALL(
rpc_service_,
ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::INVALID_DATA),
@@ -1081,7 +1083,6 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_UIAndSuccessResultCode_SUCCESS) {
EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
EXPECT_CALL(rpc_service_,
ManageMobileCommand(_, am::commands::Command::ORIGIN_SDL))
.WillOnce(Return(true));
@@ -1114,7 +1115,6 @@ TEST_F(SetGlobalPropertiesRequestTest, OnEvent_UIAndWarningResultCode_SUCCESS) {
EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
EXPECT_CALL(rpc_service_,
ManageMobileCommand(_, am::commands::Command::ORIGIN_SDL))
.WillOnce(Return(true));
@@ -1186,7 +1186,6 @@ TEST_F(SetGlobalPropertiesRequestTest,
OnEventTTSSetupHelper(msg, command);
EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
- ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
EXPECT_CALL(rpc_service_,
ManageMobileCommand(_, am::commands::Command::ORIGIN_SDL))
.WillOnce(Return(true));
@@ -1222,7 +1221,6 @@ TEST_F(SetGlobalPropertiesRequestTest,
.WillRepeatedly(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE));
MessageSharedPtr ui_command_result;
- ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
EXPECT_CALL(
rpc_service_,
ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL))
diff --git a/src/components/application_manager/test/commands/mobile/simple_response_commands_test.cc b/src/components/application_manager/test/commands/mobile/simple_response_commands_test.cc
index 06dd81e879..c2e776ca1e 100644
--- a/src/components/application_manager/test/commands/mobile/simple_response_commands_test.cc
+++ b/src/components/application_manager/test/commands/mobile/simple_response_commands_test.cc
@@ -192,6 +192,7 @@ TEST_F(ScrollableMessageResponseTest, Run_SUCCESS) {
SharedPtr<am::commands::ScrollableMessageResponse> command(
CreateCommand<am::commands::ScrollableMessageResponse>(message));
EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app));
+ ON_CALL(app_mngr_, GetRPCService()).WillByDefault(ReturnRef(rpc_service_));
EXPECT_CALL(*app, UnsubscribeFromSoftButtons(_));
command->Run();
}
diff --git a/src/components/application_manager/test/commands/mobile/subscribe_button_request_test.cc b/src/components/application_manager/test/commands/mobile/subscribe_button_request_test.cc
index 9b738e0f56..453bcc06a5 100644
--- a/src/components/application_manager/test/commands/mobile/subscribe_button_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/subscribe_button_request_test.cc
@@ -184,8 +184,11 @@ TEST_F(SubscribeButtonRequestTest, Run_SUCCESS) {
EXPECT_CALL(rpc_service_, ManageHMICommand(_))
.WillOnce(DoAll(SaveArg<0>(&hmi_result_msg), Return(true)));
- MessageSharedPtr mobile_result_msg(
- CatchMobileCommandResult(CallRun(*command)));
+ MessageSharedPtr mobile_result_msg;
+ EXPECT_CALL(this->rpc_service_, ManageMobileCommand(_, _))
+ .WillOnce(DoAll(SaveArg<0>(&mobile_result_msg), Return(true)));
+ ASSERT_TRUE(command->Init());
+ command->Run();
EXPECT_EQ(hmi_apis::FunctionID::Buttons_OnButtonSubscription,
static_cast<hmi_apis::FunctionID::eType>(
diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h
index 069e2261e8..ba76aac719 100644
--- a/src/components/include/application_manager/application_manager.h
+++ b/src/components/include/application_manager/application_manager.h
@@ -85,6 +85,9 @@ class EventDispatcher;
namespace rpc_service {
class RPCService;
}
+namespace rpc_handler {
+class RPCHandler;
+}
class Application;
class StateControllerImpl;
@@ -97,7 +100,6 @@ struct ApplicationsAppIdSorter {
return lhs->app_id() < rhs->app_id();
}
};
-
struct ApplicationsPolicyAppIdSorter {
bool operator()(const ApplicationSharedPtr lhs,
const ApplicationSharedPtr rhs) {
@@ -376,6 +378,8 @@ class ApplicationManager {
virtual policy::PolicyHandlerInterface& GetPolicyHandler() = 0;
virtual const policy::PolicyHandlerInterface& GetPolicyHandler() const = 0;
virtual rpc_service::RPCService& GetRPCService() const = 0;
+ virtual rpc_handler::RPCHandler& GetRPCHandler() const = 0;
+ virtual bool is_stopping() const = 0;
virtual uint32_t GetNextHMICorrelationID() = 0;
virtual uint32_t GenerateNewHMIAppID() = 0;
diff --git a/src/components/include/application_manager/rpc_handler.h b/src/components/include/application_manager/rpc_handler.h
new file mode 100644
index 0000000000..9b6428f32d
--- /dev/null
+++ b/src/components/include/application_manager/rpc_handler.h
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+
+#ifndef SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_RPC_HANDLER_H
+#define SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_RPC_HANDLER_H
+
+#include "protocol_handler/protocol_observer.h"
+#include "hmi_message_handler/hmi_message_handler.h"
+
+#ifdef TELEMETRY_MONITOR
+#include "application_manager/telemetry_observer.h"
+#endif // TELEMETRY_MONITOR
+
+namespace application_manager {
+namespace rpc_handler {
+
+class RPCHandler
+ : public hmi_message_handler::HMIMessageObserver,
+ public protocol_handler::ProtocolObserver
+#ifdef TELEMETRY_MONITOR
+ ,
+ public telemetry_monitor::TelemetryObservable<AMTelemetryObserver>
+#endif // TELEMETRY_MONITOR
+ {
+ public:
+ virtual ~RPCHandler() {}
+};
+
+} // namespace rpc_handler
+} // namespace application_manager
+#endif // SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_RPC_HANDLER_H
diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h
index 759e106a56..3a9afbfbdf 100644
--- a/src/components/include/test/application_manager/mock_application_manager.h
+++ b/src/components/include/test/application_manager/mock_application_manager.h
@@ -144,6 +144,9 @@ class MockApplicationManager : public application_manager::ApplicationManager {
MOCK_CONST_METHOD0(GetPolicyHandler, const policy::PolicyHandlerInterface&());
MOCK_CONST_METHOD0(GetRPCService,
application_manager::rpc_service::RPCService&());
+ MOCK_CONST_METHOD0(GetRPCHandler,
+ application_manager::rpc_handler::RPCHandler&());
+ MOCK_CONST_METHOD0(is_stopping, bool());
MOCK_METHOD0(GetNextHMICorrelationID, uint32_t());
MOCK_METHOD0(GenerateNewHMIAppID, uint32_t());
MOCK_METHOD1(EndNaviServices, void(uint32_t app_id));