summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLitvinenko Ira <LitvinenkoIra@luxoft.com>2018-02-15 13:35:10 +0000
committerIra Lytvynenko (GitHub) <ILytvynenko@luxoft.com>2018-06-26 12:01:45 +0300
commitc8c46e8a07a7817db63b8cfed6c8834f43296715 (patch)
tree8a657b407a19e94cce297abf03d5a3eec9778b0c
parent6fe8d9e3a7a29bf060fe20d42d0aae3662393432 (diff)
downloadsdl_core-c8c46e8a07a7817db63b8cfed6c8834f43296715.tar.gz
SetInteriorVehicleData implementation and some fixes
Remove unused code
-rw-r--r--src/appMain/life_cycle.h3
-rw-r--r--src/components/application_manager/include/application_manager/application_manager_impl.h6
-rw-r--r--src/components/application_manager/include/application_manager/core_service.h214
-rw-r--r--src/components/application_manager/include/application_manager/service.h183
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h3
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h5
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h13
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h63
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h5
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc10
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_request.cc10
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_response.cc12
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc7
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc288
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_response.cc10
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc80
-rw-r--r--src/components/application_manager/src/core_service.cc232
-rw-r--r--src/components/include/application_manager/application_manager.h5
-rw-r--r--src/components/include/application_manager/policies/policy_handler_interface.h1
-rw-r--r--src/components/include/test/application_manager/mock_application_manager.h3
20 files changed, 386 insertions, 767 deletions
diff --git a/src/appMain/life_cycle.h b/src/appMain/life_cycle.h
index 154f427d98..69f4b987f5 100644
--- a/src/appMain/life_cycle.h
+++ b/src/appMain/life_cycle.h
@@ -46,9 +46,6 @@
#include "hmi_message_handler/messagebroker_adapter.h"
#endif // #if ( defined (MESSAGEBROKER_HMIADAPTER) || defined(PASA_HMI) )
#include "application_manager/application_manager_impl.h"
-#ifdef SDL_REMOTE_CONTROL
-#include "application_manager/core_service.h"
-#endif // SDL_REMOTE_CONTROL
#include "connection_handler/connection_handler_impl.h"
#include "protocol_handler/protocol_handler_impl.h"
#include "transport_manager/transport_manager.h"
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 69a87d8017..3f8c33713b 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
@@ -628,8 +628,7 @@ class ApplicationManagerImpl
void StartDevicesDiscovery();
- void RemoveHMIFakeParameters(
- application_manager::MessagePtr& message) OVERRIDE;
+ void RemoveHMIFakeParameters(application_manager::commands::MessageSharedPtr &message) OVERRIDE;
/**
* @brief TerminateRequest forces termination of request
@@ -1163,9 +1162,6 @@ bool IsSOStructValid(const hmi_apis::StructIdentifiers::eType struct_id,
bool ConvertSOtoMessage(const smart_objects::SmartObject& message,
Message& output);
- MessageValidationResult ValidateMessageBySchema(
- const Message& message) OVERRIDE;
-
template <typename ApplicationList>
void PrepareApplicationListSO(ApplicationList app_list,
smart_objects::SmartObject& applications,
diff --git a/src/components/application_manager/include/application_manager/core_service.h b/src/components/application_manager/include/application_manager/core_service.h
deleted file mode 100644
index 5e95ecd245..0000000000
--- a/src/components/application_manager/include/application_manager/core_service.h
+++ /dev/null
@@ -1,214 +0,0 @@
-/**
- * Copyright (c) 2013, 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_CORE_SERVICE_H_
-#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_CORE_SERVICE_H_
-
-#include <string>
-#include <vector>
-#include "application_manager/service.h"
-#include "application_manager/application.h"
-#include "policy/policy_types.h"
-
-namespace Json {
-class Value;
-}
-
-namespace application_manager {
-
-struct CommandParametersPermissions;
-
-/**
- * @brief Class through which the plug-in can interact with the core
- */
-class CoreService : public Service {
- public:
- /**
- * @brief CoreService class destructor
- */
- explicit CoreService(ApplicationManager& application_manager);
-
- /**
- * @brief CoreService class destructor
- */
- virtual ~CoreService();
-
- /**
- * @brief Checks message permissions and cuts parameters according
- * to policy table permissions
- * @param msg message to cut disallowed parameters
- * @return result according by mobile API
- */
- mobile_apis::Result::eType CheckPolicyPermissions(MessagePtr msg) FINAL;
-
- /**
- * Checks if module for application is present in policy table
- * @param app_id id of application
- * @param module type
- * @return true if module is present, otherwise - false
- */
- bool CheckModule(const ApplicationId& app_id,
- const std::string& module) FINAL;
-
- /**
- * Checks if application has remote control functions
- * @param app application
- * @return true if application has remote control functions
- */
- bool IsRemoteControlApplication(ApplicationSharedPtr app) const FINAL;
-
- /**
- * @brief Gets current state of the specified interface
- * @param interface which state to get
- * @return true if specified interface available otherwise false
- */
- bool IsInterfaceAvailable(
- const HmiInterfaces::InterfaceID interface) const FINAL;
-
- /**
- * Removes fake parameters from request to HMI
- * @param message message to handle
- */
- void RemoveHMIFakeParameters(application_manager::MessagePtr& message) FINAL;
-
- /**
- * @brief Get pointer to application by application id
- * @param app_id application id
- * return pointer to application
- */
- ApplicationSharedPtr GetApplication(ApplicationId app_id) FINAL;
-
- /**
- * @brief Send message to HMI
- * @param message Message to HMI
- */
- void SendMessageToHMI(const MessagePtr& message) FINAL;
-
- /**
- * @brief Send message to mobile device
- * @param message Message to mobile
- */
- void SendMessageToMobile(const MessagePtr& message) FINAL;
-
- /**
- * @brief Returns unique correlation ID for next HMI request
- *
- * @return Unique correlation ID
- */
- uint32_t GetNextCorrelationID() FINAL;
-
- /**
- * @brief Returns all applications
- *
- * @return List with shared pointers to applications
- */
- std::vector<ApplicationSharedPtr> GetApplications(AppExtensionUID uid) FINAL;
-
- /**
- * @brief Change hmi level of app and notify it
- * @param app Application to be changed and notified
- * @param level New HMI level of app
- */
- void ChangeNotifyHMILevel(ApplicationSharedPtr app,
- mobile_apis::HMILevel::eType level) FINAL;
-
- const smart_objects::SmartObject* GetRCCapabilities() const FINAL;
- /**
- * @brief Notify HMI about app changing HMI Level
- * only NONE, BACKGROUND and LIMITED levels are sent
- * @param app Application to be changed and notified
- * @param level New HMI level of app
- */
- void NotifyHMIAboutHMILevel(ApplicationSharedPtr app,
- mobile_apis::HMILevel::eType level) FINAL;
-
- /**
- * Gets all allowed module types
- * @param app_id unique identifier of application
- * @param list of allowed module types
- * @return true if application has allowed modules
- */
- bool GetModuleTypes(const std::string& policy_app_id,
- std::vector<std::string>* modules) const FINAL;
-
- /**
- * @brief ValidateMessageBySchema Checks whether message is valid according
- * to API
- * @param message Message to check
- * @return Check result
- */
- MessageValidationResult ValidateMessageBySchema(const Message& message) FINAL;
-
- /**
- * @brief Gets application manager settings structure
- * @return reference to application manager settings structure
- */
- const ApplicationManagerSettings& GetSettings() const FINAL;
-
- private:
- /**
- * @brief AreParametersAllowed Checks message parameters across current policy
- * permissions
- * @param msg Message having parameters
- * @param params Parameters sorted by permissions
- * @return True if allowed, otherwise - false
- */
- bool AreParametersAllowed(MessagePtr msg,
- const CommandParametersPermissions& params);
-
- /**
- * @brief CheckParams Checks object params with allowed parameters received
- * from policy
- * @param object Message object
- * @param allowed_params Parameters allowed by policy
- * @return True if all parameters allowed, otherwise - false
- */
- bool CheckParams(const Json::Value& object,
- const policy::RPCParams& allowed_params);
-
- /**
- * @brief IsAllowed Checks particular parameter among allowed list
- * @param name Parameter name
- * @param allowed_params List of allowed parameters
- * @return True if found, otherwise - false
- */
- bool IsAllowed(const std::string& name,
- const policy::RPCParams& allowed_params);
-
- ApplicationManager& application_manager_;
-
- DISALLOW_COPY_AND_ASSIGN(CoreService);
-};
-
-} // namespace application_manager
-
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_CORE_SERVICE_H_
diff --git a/src/components/application_manager/include/application_manager/service.h b/src/components/application_manager/include/application_manager/service.h
deleted file mode 100644
index da08957afa..0000000000
--- a/src/components/application_manager/include/application_manager/service.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright (c) 2017, 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_SERVICE_H_
-#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_SERVICE_H_
-
-#include <string>
-#include <sstream>
-#include <vector>
-#include "application_manager/application.h"
-#include "application_manager/application_manager_settings.h"
-#include "application_manager/message.h"
-#include "application_manager/hmi_interfaces.h"
-
-namespace application_manager {
-
-enum TypeAccess { kDisallowed, kAllowed };
-
-enum MessageValidationResult {
- SUCCESS = 0,
- INVALID_JSON,
- INVALID_METADATA,
- SCHEMA_MISMATCH,
- UNSUPPORTED_PROTOCOL
-};
-
-typedef std::string PluginFunctionID;
-
-/**
- * @brief Interface to core service
- */
-class Service {
- public:
- virtual ~Service() {}
-
- /**
- * @brief Checks message permissions and cuts parameters according
- * to policy table permissions
- * @param msg message to cut disallowed parameters
- * @return result according by mobile API
- */
- virtual mobile_apis::Result::eType CheckPolicyPermissions(MessagePtr msg) = 0;
-
- /**
- * Checks if module for application is present in policy table
- * @param app_id id of application
- * @param module type
- * @return true if module is present, otherwise - false
- */
- virtual bool CheckModule(const ApplicationId& app_id,
- const std::string& module) = 0;
-
- /**
- * @brief Get pointer to application by application id
- * @param app_id application id
- * return pointer to application
- */
- virtual ApplicationSharedPtr GetApplication(ApplicationId app_id) = 0;
-
- /**
- * Removes parameters not listed in HMI API from HMI request
- * @param message message to handle
- */
- virtual void RemoveHMIFakeParameters(
- application_manager::MessagePtr& message) = 0;
- /**
- * @brief Send message to HMI
- * @param message Message to HMI
- */
- virtual void SendMessageToHMI(const MessagePtr& message) = 0;
-
- /**
- * @brief Send message to mobile device
- * @param message Message to mobile
- */
- virtual void SendMessageToMobile(const MessagePtr& message) = 0;
-
- /**
- * @brief Returns unique correlation ID for next HMI request
- *
- * @return Unique correlation ID
- */
- virtual uint32_t GetNextCorrelationID() = 0;
-
- /**
- * @brief Returns all applications related to plugin
- * @param uid ID provided by plugin to its extension to app.
- * @return List with shared pointers to applications
- */
- virtual std::vector<ApplicationSharedPtr> GetApplications(
- AppExtensionUID uid) = 0;
-
- /**
- * @brief Change hmi level of app and notify it
- * @param app Application to be changed and notified
- * @param level New HMI level of app
- */
- virtual void ChangeNotifyHMILevel(ApplicationSharedPtr app,
- mobile_apis::HMILevel::eType level) = 0;
-
- /**
- * @brief Notify HMI about app changing HMI Level
- * only NONE, BACKGROUND and LIMITED levels are sent
- * @param app Application to be changed and notified
- * @param level New HMI level of app
- */
- virtual void NotifyHMIAboutHMILevel(ApplicationSharedPtr app,
- mobile_apis::HMILevel::eType level) = 0;
-
- virtual const smart_objects::SmartObject* GetRCCapabilities() const = 0;
- /**
- * Checks if application has remote control functions
- * @param app application
- * @return true if application has remote control functions
- */
- virtual bool IsRemoteControlApplication(ApplicationSharedPtr app) const = 0;
-
- /**
- * @brief Gets current state of the specified interface
- * @param interface which state to get
- * @return true if specified interface available otherwise false
- */
- virtual bool IsInterfaceAvailable(
- const HmiInterfaces::InterfaceID interface) const = 0;
-
- /**
- * Gets all allowed module types
- * @param app_id unique identifier of application
- * @param list of allowed module types
- * @return true if application has allowed modules
- */
- virtual bool GetModuleTypes(const std::string& policy_app_id,
- std::vector<std::string>* modules) const = 0;
-
- /**
- * @brief ValidateMessageBySchema validates message by xml schema
- * @param message message for validation
- * @return true if message is valid according to schema, otherwise false
- */
- virtual MessageValidationResult ValidateMessageBySchema(
- const Message& message) = 0;
-
- /**
- * @brief Gets application manager settings structure
- * @return reference to application manager settings structure
- */
- virtual const ApplicationManagerSettings& GetSettings() const = 0;
-};
-
-typedef utils::SharedPtr<Service> ServicePtr;
-
-} // namespace application_manager
-
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_SERVICE_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h
index d558926b7c..29c02186a5 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h
@@ -17,9 +17,8 @@ class RCSetInteriorVehicleDataRequest
app_mngr::rpc_service::RPCService& rpc_service,
app_mngr::HMICapabilities& hmi_capabilities,
policy::PolicyHandlerInterface& policy_handle);
- bool Init() OVERRIDE;
void Run() OVERRIDE;
- void on_event(const application_manager::event_engine::Event& event);
+ virtual ~RCSetInteriorVehicleDataRequest();
};
} // namespace commands
} // namespace rc_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h
index 339d040bd3..d5e95421ce 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h
@@ -17,9 +17,10 @@ class RCSetInteriorVehicleDataResponse
app_mngr::rpc_service::RPCService& rpc_service,
app_mngr::HMICapabilities& hmi_capabilities,
policy::PolicyHandlerInterface& policy_handle);
- bool Init() OVERRIDE;
+
void Run() OVERRIDE;
- void on_event(const application_manager::event_engine::Event& event);
+
+ virtual ~RCSetInteriorVehicleDataResponse();
};
} // namespace commands
} // namespace rc_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h
index 748da8eb57..76330b50d3 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h
@@ -28,6 +28,13 @@ class GetInteriorVehicleDataRequest : public RCCommandRequest {
*/
void on_event(const app_mngr::event_engine::Event& event) FINAL;
+
+ /**
+ * @brief GetInteriorVehicleDataRequest class destructor
+ */
+ virtual ~GetInteriorVehicleDataRequest();
+
+ private:
/**
* @brief Check if app wants to proceed with already setup subscription
* @param request_params request parameters to check
@@ -38,12 +45,6 @@ class GetInteriorVehicleDataRequest : public RCCommandRequest {
bool HasRequestExcessiveSubscription();
/**
- * @brief GetInteriorVehicleDataRequest class destructor
- */
- virtual ~GetInteriorVehicleDataRequest();
-
- private:
- /**
* @brief Handle subscription to vehicle data
* @param hmi_response json message with response from HMI
*/
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h
index 180220cb15..4a1704bab4 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h
@@ -2,7 +2,6 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_SET_INTERIOR_VEHICLE_DATA_REQUEST_H
#include "rc_rpc_plugin/commands/rc_command_request.h"
-#include "utils/macro.h"
namespace rc_rpc_plugin {
namespace app_mngr = application_manager;
@@ -17,9 +16,65 @@ class SetInteriorVehicleDataRequest : public RCCommandRequest {
app_mngr::rpc_service::RPCService& rpc_service,
app_mngr::HMICapabilities& hmi_capabilities,
policy::PolicyHandlerInterface& policy_handle);
- bool Init() OVERRIDE;
- void Run() OVERRIDE;
- void on_event(const application_manager::event_engine::Event& event) OVERRIDE;
+
+ /**
+ * @brief Execute command
+ */
+ void Execute() FINAL;
+
+ /**
+ * @brief AcquireResource proxy AcquireResource to Resource allocation manager
+ * @param message message of requires contatin module types
+ * @return result of acauiring resources
+ */
+ AcquireResult::eType AcquireResource(
+ const app_mngr::commands::MessageSharedPtr& message) FINAL;
+
+ /**
+ * @brief IsResourceFree check resource state
+ * @param module_type Resource name
+ * @return True if free, otherwise - false
+ */
+ bool IsResourceFree(const std::string& module_type) const FINAL;
+
+ /**
+ * @brief SetResourceState changes state of resource
+ * @param state State to set for resource
+ */
+ void SetResourceState(const std::string& module_type,
+ const ResourceState::eType state) FINAL;
+
+ /**
+ * @brief Interface method that is called whenever new event received
+ *
+ * @param event The received event
+ */
+ void on_event(const app_mngr::event_engine::Event& event) FINAL;
+
+ /**
+ * @brief Method that check if READ_ONLY parameters present
+ * @param request_params params from received message
+ * @return true if present , false - otherwise
+ */
+ bool AreReadOnlyParamsPresent(const smart_objects::SmartObject& module_data);
+
+ /**
+ * @brief Method that check if all request parameters are READ_ONLY
+ * @param request_params params from received message
+ * @return true if all are read only , false - otherwise
+ */
+ bool AreAllParamsReadOnly(const smart_objects::SmartObject& module_data);
+
+ /**
+ * @brief Method that cuts-off READ_ONLY parameters
+ * @param request_params params to handle
+ */
+ void CutOffReadOnlyParams(smart_objects::SmartObject& module_data);
+
+ /**
+ * @brief SetInteriorVehicleDataRequest class destructor
+ */
+virtual ~SetInteriorVehicleDataRequest();
};
} // namespace commands
} // namespace rc_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h
index ffc6dc23bb..24505d90f2 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h
@@ -17,9 +17,10 @@ class SetInteriorVehicleDataResponse
app_mngr::rpc_service::RPCService& rpc_service,
app_mngr::HMICapabilities& hmi_capabilities,
policy::PolicyHandlerInterface& policy_handle);
- bool Init() OVERRIDE;
+
void Run() OVERRIDE;
- void on_event(const application_manager::event_engine::Event& event);
+
+ virtual ~SetInteriorVehicleDataResponse();
};
} // namespace commands
} // namespace rc_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc
index b52d235f04..77607a791f 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc
@@ -16,12 +16,12 @@ RCGetInteriorVehicleDataResponse::RCGetInteriorVehicleDataResponse(
hmi_capabilities,
policy_handle) {}
void RCGetInteriorVehicleDataResponse::Run() {
- LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_AUTO_TRACE(logger_);
- app_mngr::event_engine::Event event(
- hmi_apis::FunctionID::Buttons_ButtonPress);
- event.set_smart_object(*message_);
- event.raise(application_manager_.event_dispatcher());
+ app_mngr::event_engine::Event event(
+ hmi_apis::FunctionID::RC_GetInteriorVehicleData);
+ event.set_smart_object(*message_);
+ event.raise(application_manager_.event_dispatcher());
}
RCGetInteriorVehicleDataResponse::~RCGetInteriorVehicleDataResponse() {}
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_request.cc
index 3bd8723efb..e122a02fc1 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_request.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_request.cc
@@ -15,12 +15,12 @@ RCSetInteriorVehicleDataRequest::RCSetInteriorVehicleDataRequest(
rpc_service,
hmi_capabilities,
policy_handle) {}
-bool RCSetInteriorVehicleDataRequest::Init() {
- return true;
+RCSetInteriorVehicleDataRequest::~RCSetInteriorVehicleDataRequest(){}
+
+void RCSetInteriorVehicleDataRequest::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ SendRequest();
}
-void RCSetInteriorVehicleDataRequest::Run() {}
-void RCSetInteriorVehicleDataRequest::on_event(
- const application_manager::event_engine::Event& event) {}
} // namespace commands
} // namespace rc_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_response.cc
index 4c4df1248f..6bc8b1fb9e 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_response.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_response.cc
@@ -16,13 +16,15 @@ RCSetInteriorVehicleDataResponse::RCSetInteriorVehicleDataResponse(
hmi_capabilities,
policy_handle) {}
-bool RCSetInteriorVehicleDataResponse::Init() {
- return true;
+void RCSetInteriorVehicleDataResponse::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ app_mngr::event_engine::Event event(hmi_apis::FunctionID::RC_SetInteriorVehicleData);
+ event.set_smart_object(*message_);
+ event.raise(application_manager_.event_dispatcher());
}
-void RCSetInteriorVehicleDataResponse::Run() {}
-void RCSetInteriorVehicleDataResponse::on_event(
- const application_manager::event_engine::Event& event) {}
+RCSetInteriorVehicleDataResponse::~RCSetInteriorVehicleDataResponse(){}
} // namespace commands
} // namespace rc_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc
index 606f460394..2f2a1f87d2 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc
@@ -142,9 +142,8 @@ void GetInteriorVehicleDataRequest::ProccessSubscription(
LOG4CXX_TRACE(logger_, "request_subscribe = " << request_subscribe);
LOG4CXX_TRACE(logger_, "response_subscribe = " << response_subscribe);
if (request_subscribe == response_subscribe) {
- const std::string module_type =
- (*message_)[app_mngr::strings::msg_params][message_params::kModuleType]
- .asString();
+ const std::string module_type =
+ (*message_)[app_mngr::strings::msg_params][message_params::kModuleData][message_params::kModuleType].asString();
if (response_subscribe) {
LOG4CXX_DEBUG(logger_,
"SubscribeToInteriorVehicleData " << app->app_id() << " "
@@ -174,7 +173,7 @@ bool GetInteriorVehicleDataRequest::HasRequestExcessiveSubscription() {
const bool is_app_already_subscribed =
extension->IsSubscibedToInteriorVehicleData(
(*message_)[app_mngr::strings::msg_params]
- [message_params::kModuleType].asString());
+ [message_params::kModuleData][message_params::kModuleType].asString());
const bool app_wants_to_subscribe =
(*message_)[app_mngr::strings::msg_params][message_params::kSubscribe]
.asBool();
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc
index 5c01588ce1..738f51df54 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc
@@ -1,9 +1,64 @@
#include "rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h"
+#include "rc_rpc_plugin/rc_module_constants.h"
#include "utils/macro.h"
+#include "json/json.h"
+#include "utils/helpers.h"
+#include "interfaces/MOBILE_API.h"
namespace rc_rpc_plugin {
namespace commands {
+using namespace json_keys;
+using namespace message_params;
+
+namespace {
+std::vector<std::string> GetModuleReadOnlyParams(
+ const std::string& module_type) {
+ std::vector<std::string> module_ro_params;
+ if (enums_value::kClimate == module_type) {
+ module_ro_params.push_back(kCurrentTemperature);
+ } else if (enums_value::kRadio == module_type) {
+ module_ro_params.push_back(kRdsData);
+ module_ro_params.push_back(kAvailableHDs);
+ module_ro_params.push_back(kSignalStrength);
+ module_ro_params.push_back(kSignalChangeThreshold);
+ module_ro_params.push_back(kState);
+ }
+ return module_ro_params;
+}
+
+const std::map<std::string, std::string> GetModuleDataToCapabilitiesMapping() {
+ std::map<std::string, std::string> mapping;
+ // climate
+ mapping["fanSpeed"] = "fanSpeedAvailable";
+ mapping["currentTemperature"] = "currentTemperatureAvailable";
+ mapping["desiredTemperature"] = "desiredTemperatureAvailable";
+ mapping["acEnable"] = "acEnableAvailable";
+ mapping["circulateAirEnable"] = "circulateAirEnableAvailable";
+ mapping["autoModeEnable"] = "autoModeEnableAvailable";
+ mapping["defrostZone"] = "defrostZoneAvailable";
+ mapping["dualModeEnable"] = "dualModeEnableAvailable";
+ mapping["acMaxEnable"] = "acMaxEnableAvailable";
+ mapping["ventilationMode"] = "ventilationModeAvailable";
+
+ // radio
+ mapping["band"] = "radioBandAvailable";
+ mapping["frequencyInteger"] = "radioFrequencyAvailable";
+ mapping["frequencyFraction"] = "radioFrequencyAvailable";
+ mapping["rdsData"] = "rdsDataAvailable";
+ mapping["availableHDs"] = "availableHDsAvailable";
+ mapping["hdChannel"] = "availableHDsAvailable";
+ mapping["signalStrength"] = "signalStrengthAvailable";
+ mapping["signalChangeThreshold"] = "signalChangeThresholdAvailable";
+ mapping["radioEnable"] = "radioEnableAvailable";
+ mapping["state"] = "stateAvailable";
+
+ return mapping;
+}
+} // namespace
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule")
+
SetInteriorVehicleDataRequest::SetInteriorVehicleDataRequest(
ResourceAllocationManager& resource_allocation_manager,
const app_mngr::commands::MessageSharedPtr& message,
@@ -18,12 +73,237 @@ SetInteriorVehicleDataRequest::SetInteriorVehicleDataRequest(
hmi_capabilities,
policy_handle) {}
-bool SetInteriorVehicleDataRequest::Init() {
+SetInteriorVehicleDataRequest::~SetInteriorVehicleDataRequest() {}
+
+bool CheckControlDataByCapabilities(
+ const smart_objects::SmartObject& module_caps,
+ const smart_objects::SmartObject& control_data) {
+ std::map<std::string, std::string> mapping =
+ GetModuleDataToCapabilitiesMapping();
+
+ auto it = control_data.map_begin();
+ for (; it != control_data.map_end(); ++it) {
+ const std::string& request_parameter = it->first;
+ const std::string& caps_key = mapping[request_parameter];
+ const smart_objects::SmartObject& capabilities_status = module_caps[0];
+ LOG4CXX_DEBUG(logger_,
+ "Checking request parameter "
+ << request_parameter
+ << " with capabilities. Appropriate key is " << caps_key);
+ if (!capabilities_status.keyExists(caps_key)) {
+ LOG4CXX_DEBUG(logger_,
+ "Capability "
+ << caps_key
+ << " is missed in RemoteControl capabilities");
+ return false;
+ }
+ if (!capabilities_status[caps_key].asBool()) {
+ LOG4CXX_DEBUG(logger_,
+ "Capability "
+ << caps_key
+ << " is switched off in RemoteControl capabilities");
+ return false;
+ }
+ }
+ return true;
+}
+
+bool CheckIfModuleDataExistInCapabilities(
+ const smart_objects::SmartObject& rc_capabilities,
+ const smart_objects::SmartObject& module_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ bool is_radio_data_valid = true;
+ bool is_climate_data_valid = true;
+ if (module_data.keyExists(message_params::kRadioControlData)) {
+ if (!rc_capabilities.keyExists(strings::kradioControlCapabilities)) {
+ LOG4CXX_DEBUG(logger_, " Radio control capabilities not present");
+ return false;
+ }
+ const smart_objects::SmartObject& radio_caps =
+ rc_capabilities[strings::kradioControlCapabilities];
+ is_radio_data_valid = CheckControlDataByCapabilities(
+ radio_caps, module_data[strings::kRadioControlData]);
+ }
+ if (module_data.keyExists(message_params::kClimateControlData)) {
+ if (!rc_capabilities.keyExists(strings::kclimateControlCapabilities)) {
+ LOG4CXX_DEBUG(logger_, " Climate control capabilities not present");
+ return false;
+ }
+ const smart_objects::SmartObject& climate_caps =
+ rc_capabilities[strings::kclimateControlCapabilities];
+ is_climate_data_valid = CheckControlDataByCapabilities(
+ climate_caps, module_data[strings::kClimateControlData]);
+ }
+
+ return is_radio_data_valid && is_climate_data_valid;
+}
+
+
+
+void SetInteriorVehicleDataRequest::Execute() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ auto module_data =
+ (*message_)[app_mngr::strings::msg_params][message_params::kModuleData];
+ const std::string module_type = module_data[message_params::kModuleType].asString();
+ bool module_type_and_data_match = true;
+
+ if (enums_value::kRadio == module_type) {
+ module_type_and_data_match = !(module_data.keyExists(message_params::kClimateControlData));
+ }
+
+ if (enums_value::kClimate == module_type) {
+ module_type_and_data_match = !(module_data.keyExists(message_params::kRadioControlData));
+ }
+
+ if (module_type_and_data_match) {
+ const smart_objects::SmartObject* rc_capabilities =
+ application_manager_.hmi_capabilities().rc_capability();
+ if (rc_capabilities &&
+ !CheckIfModuleDataExistInCapabilities(*rc_capabilities, module_data)) {
+ LOG4CXX_WARN(logger_, "Accessing not supported module data");
+ SendResponse(false,
+ mobile_apis::Result::UNSUPPORTED_RESOURCE,
+ "Accessing not supported module data");
+ return;
+ }
+ if (AreAllParamsReadOnly(module_data)) {
+ LOG4CXX_WARN(logger_, "All request params in module type are READ ONLY!");
+ SendResponse(false,
+ mobile_apis::Result::READ_ONLY,
+ "All request params in module type are READ ONLY!");
+ return;
+ }
+ if (AreReadOnlyParamsPresent(module_data)) {
+ LOG4CXX_DEBUG(logger_, "Request module type has READ ONLY parameters");
+ LOG4CXX_DEBUG(logger_, "Cutting-off READ ONLY parameters... ");
+ CutOffReadOnlyParams(module_data);
+ }
+ application_manager_.RemoveHMIFakeParameters(message_);
+ SendHMIRequest(hmi_apis::FunctionID::RC_SetInteriorVehicleData,
+ &(*message_)[app_mngr::strings::msg_params], true);
+ } else {
+ LOG4CXX_WARN(logger_, "Request module type & data mismatch!");
+ SendResponse(false,
+ mobile_apis::Result::INVALID_DATA,
+ "Request module type & data mismatch!");
+ }
+}
+
+void SetInteriorVehicleDataRequest::on_event(const app_mngr::event_engine::Event& event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (hmi_apis::FunctionID::RC_SetInteriorVehicleData != event.id()){
+ return;
+ }
+
+ const smart_objects::SmartObject& hmi_response = event.smart_object();
+ mobile_apis::Result::eType result_code =
+ GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
+ hmi_response[app_mngr::strings::params][app_mngr::hmi_response::code]
+ .asUInt()));
+
+ bool result =
+ helpers::Compare<mobile_apis::Result::eType, helpers::EQ, helpers::ONE>(
+ result_code,
+ mobile_apis::Result::SUCCESS,
+ mobile_apis::Result::WARNINGS);
+
+// if (result) {
+// response_params_[message_params::kModuleData] =
+// value[json_keys::kResult][message_params::kModuleData];
+// }
+ std::string info;
+ GetInfo(hmi_response, info);
+ SendResponse(result, result_code, info.c_str());
+}
+
+const smart_objects::SmartObject& ControlData(const smart_objects::SmartObject& module_data) {
+ const std::string module = module_data[message_params::kModuleType].asString();
+
+ if (enums_value::kRadio == module) {
+ return module_data[message_params::kRadioControlData];
+ }
+ else {
+ return module_data[message_params::kClimateControlData];
+ }
+}
+
+bool SetInteriorVehicleDataRequest::AreAllParamsReadOnly(
+ const smart_objects::SmartObject& module_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const smart_objects::SmartObject& module_type_params =
+ ControlData(module_data);
+ auto it = module_type_params.map_begin();
+ std::vector<std::string> ro_params =
+ GetModuleReadOnlyParams(module_data[message_params::kModuleType].asString());
+ for (; it != module_type_params.map_end(); ++it) {
+ if (!helpers::in_range(ro_params, it->first)) {
+ return false;
+ }
+ }
return true;
}
-void SetInteriorVehicleDataRequest::Run() {}
-void SetInteriorVehicleDataRequest::on_event(
- const application_manager::event_engine::Event& event) {}
+
+bool SetInteriorVehicleDataRequest::AreReadOnlyParamsPresent(
+ const smart_objects::SmartObject& module_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const smart_objects::SmartObject& module_type_params =
+ ControlData(module_data);
+ auto it = module_type_params.map_begin();
+ std::vector<std::string> ro_params =
+ GetModuleReadOnlyParams(module_data[message_params::kModuleType].asString());
+ for (; it != module_type_params.map_end(); ++it) {
+ if (helpers::in_range(ro_params, it->first)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+void SetInteriorVehicleDataRequest::CutOffReadOnlyParams(
+ smart_objects::SmartObject& module_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const smart_objects::SmartObject& module_type_params =
+ ControlData(module_data);
+ auto it = module_type_params.map_begin();
+ const std::string module_type = module_data[message_params::kModuleType].asString();
+ std::vector<std::string> ro_params = GetModuleReadOnlyParams(module_type);
+ for (; it != module_type_params.map_end(); ++it) {
+ if (helpers::in_range(ro_params, it->first)) {
+ if (enums_value::kClimate == module_type) {
+ module_data[message_params::kClimateControlData].erase(it->first);
+ LOG4CXX_DEBUG(logger_, "Cutting-off READ ONLY parameter: " << it->first);
+ } else if (enums_value::kRadio == module_type) {
+ module_data[message_params::kRadioControlData].erase(it->first);
+ LOG4CXX_DEBUG(logger_, "Cutting-off READ ONLY parameter: " << it->first);
+ }
+ }
+ }
+}
+
+AcquireResult::eType SetInteriorVehicleDataRequest::AcquireResource(
+ const app_mngr::commands::MessageSharedPtr& message) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const std::string module_type =
+ (*message_)[app_mngr::strings::msg_params][message_params::kModuleData][message_params::kModuleType]
+ .asString();
+ app_mngr::ApplicationSharedPtr app =
+ application_manager_.application(CommandRequestImpl::connection_key());
+ return resource_allocation_manager_.AcquireResource(module_type, app->app_id());
+}
+
+bool SetInteriorVehicleDataRequest::IsResourceFree(
+ const std::string& module_type) const {
+ return resource_allocation_manager_.IsResourceFree(module_type);
+}
+
+void SetInteriorVehicleDataRequest::SetResourceState( const std::string& module_type,
+ const ResourceState::eType state) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ app_mngr::ApplicationSharedPtr app =
+ application_manager_.application(CommandRequestImpl::connection_key());
+ resource_allocation_manager_.SetResourceState(module_type, app->app_id(), state);
+}
} // namespace commands
} // namespace rc_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_response.cc
index 8f45d55908..a09d41aca1 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_response.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_response.cc
@@ -15,12 +15,12 @@ SetInteriorVehicleDataResponse::SetInteriorVehicleDataResponse(
rpc_service,
hmi_capabilities,
policy_handle) {}
-bool SetInteriorVehicleDataResponse::Init() {
- return true;
+SetInteriorVehicleDataResponse::~SetInteriorVehicleDataResponse(){}
+
+void SetInteriorVehicleDataResponse::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ application_manager_.GetRPCService().SendMessageToMobile(message_);
}
-void SetInteriorVehicleDataResponse::Run() {}
-void SetInteriorVehicleDataResponse::on_event(
- const application_manager::event_engine::Event& event) {}
} // namespace commands
} // namespace rc_rpc_plugin
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index f05ce9ed09..7c32609c1a 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -161,9 +161,6 @@ ApplicationManagerImpl::ApplicationManagerImpl(
, navi_end_stream_timeout_(am_settings.stop_streaming_timeout())
, stopping_application_mng_lock_(true)
, state_ctrl_(*this)
-#ifdef TELEMETRY_MONITOR
- , metric_observer_(NULL)
-#endif // TELEMETRY_MONITOR
, application_list_update_timer_(
"AM ListUpdater",
new TimerTaskImpl<ApplicationManagerImpl>(
@@ -1710,22 +1707,10 @@ void ApplicationManagerImpl::TerminateRequest(const uint32_t connection_key,
}
void ApplicationManagerImpl::RemoveHMIFakeParameters(
- application_manager::MessagePtr& message) {
+ application_manager::commands::MessageSharedPtr& message) {
LOG4CXX_AUTO_TRACE(logger_);
- using namespace NsSmartDeviceLink::NsSmartObjects;
- using namespace NsSmartDeviceLink::NsJSONHandler;
- SmartObject so;
-
- Formatters::FormatterJsonRpc::FromString<hmi_apis::FunctionID::eType,
- hmi_apis::messageType::eType>(
- message->json_message(), so);
-
- std::string formatted_message;
- namespace Formatters = NsSmartDeviceLink::NsJSONHandler::Formatters;
hmi_apis::HMI_API factory;
- factory.attachSchema(so, true);
- Formatters::FormatterJsonRpc::ToString(so, formatted_message);
- message->set_json_message(formatted_message);
+ factory.attachSchema(*message, true);
}
bool ApplicationManagerImpl::Init(resumption::LastState& last_state,
@@ -1915,67 +1900,6 @@ bool ApplicationManagerImpl::ConvertSOtoMessage(
return true;
}
-MessageValidationResult ApplicationManagerImpl::ValidateMessageBySchema(
- const Message& message) {
- LOG4CXX_AUTO_TRACE(logger_);
- smart_objects::SmartObject so;
- using namespace protocol_handler;
- switch (message.protocol_version()) {
- case MajorProtocolVersion::PROTOCOL_VERSION_5:
- case MajorProtocolVersion::PROTOCOL_VERSION_4:
- case MajorProtocolVersion::PROTOCOL_VERSION_3:
- case MajorProtocolVersion::PROTOCOL_VERSION_2: {
- const bool conversion_result =
- formatters::CFormatterJsonSDLRPCv2::fromString(
- message.json_message(),
- so,
- message.function_id(),
- message.type(),
- message.correlation_id());
- if (!conversion_result) {
- return INVALID_JSON;
- }
-
- if (!mobile_so_factory().attachSchema(so, true)) {
- return INVALID_METADATA;
- }
- rpc::ValidationReport report("RPC");
- if (so.validate(&report) != smart_objects::Errors::OK) {
- LOG4CXX_WARN(logger_,
- "validate() failed for Mobile message - "
- << rpc::PrettyFormat(report));
- return SCHEMA_MISMATCH;
- }
- break;
- }
- case MajorProtocolVersion::PROTOCOL_VERSION_HMI: {
- const int32_t conversion_result = formatters::FormatterJsonRpc::
- FromString<hmi_apis::FunctionID::eType, hmi_apis::messageType::eType>(
- message.json_message(), so);
- if (0 != conversion_result) {
- LOG4CXX_WARN(logger_,
- "Failed to parse json from HMI: " << conversion_result);
- return INVALID_JSON;
- }
-
- if (!hmi_so_factory().attachSchema(so, true)) {
- return INVALID_METADATA;
- }
-
- rpc::ValidationReport report("RPC");
- if (so.validate(&report) != smart_objects::Errors::OK) {
- LOG4CXX_WARN(logger_,
- "validate() failed for HMI message - "
- << rpc::PrettyFormat(report));
- return SCHEMA_MISMATCH;
- }
- break;
- }
- default: { return UNSUPPORTED_PROTOCOL; }
- }
- return SUCCESS;
-}
-
hmi_apis::HMI_API& ApplicationManagerImpl::hmi_so_factory() {
if (!hmi_so_factory_) {
hmi_so_factory_ = new hmi_apis::HMI_API;
diff --git a/src/components/application_manager/src/core_service.cc b/src/components/application_manager/src/core_service.cc
deleted file mode 100644
index 61e510696e..0000000000
--- a/src/components/application_manager/src/core_service.cc
+++ /dev/null
@@ -1,232 +0,0 @@
-/**
- * Copyright (c) 2013, 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 <vector>
-#include <algorithm>
-#include "application_manager/core_service.h"
-#include "application_manager/application_manager_impl.h"
-#include "application_manager/rpc_service.h"
-#include "application_manager/policies/policy_handler.h"
-#include "application_manager/message_helper.h"
-#include "json/json.h"
-#include "interfaces/HMI_API.h"
-
-namespace application_manager {
-
-namespace {
-struct AppExtensionPredicate {
- AppExtensionUID uid;
- bool operator()(const ApplicationSharedPtr app) {
- return app ? app->QueryInterface(uid).valid() : false;
- }
-};
-}
-
-CoreService::CoreService(ApplicationManager& application_manager)
- : application_manager_(application_manager) {}
-
-CoreService::~CoreService() {}
-
-mobile_apis::Result::eType CoreService::CheckPolicyPermissions(MessagePtr msg) {
- ApplicationSharedPtr app = GetApplication(msg->connection_key());
- if (!app) {
- return mobile_apis::Result::eType::APPLICATION_NOT_REGISTERED;
- }
-
-#ifdef SDL_REMOTE_CONTROL
- const RPCParams rpc_params;
- CommandParametersPermissions params;
- const mobile_apis::Result::eType ret =
- application_manager_.CheckPolicyPermissions(
- app, msg->function_name(), rpc_params, &params);
-
- if (ret != mobile_apis::Result::eType::SUCCESS) {
- return ret;
- }
-
- if (!AreParametersAllowed(msg, params)) {
- return mobile_apis::Result::eType::DISALLOWED;
- }
-
- return ret;
-#else
- return mobile_apis::Result::eType::SUCCESS;
-#endif // SDL_REMOTE_CONTROL
-}
-
-bool CoreService::CheckModule(const ApplicationId& app_id,
- const std::string& module) {
-#ifdef SDL_REMOTE_CONTROL
- ApplicationSharedPtr app = GetApplication(app_id);
- if (app) {
- return application_manager_.GetPolicyHandler().CheckModule(
- app->policy_app_id(), module);
- }
-#endif // SDL_REMOTE_CONTROL
- return false;
-}
-
-bool CoreService::IsRemoteControlApplication(ApplicationSharedPtr app) const {
-#ifdef SDL_REMOTE_CONTROL
- DCHECK_OR_RETURN(app, false);
- return application_manager_.GetPolicyHandler().CheckHMIType(
- app->policy_app_id(),
- mobile_apis::AppHMIType::eType::REMOTE_CONTROL,
- app->app_types());
-#endif // SDL_REMOTE_CONTROL
- return false;
-}
-
-bool CoreService::IsInterfaceAvailable(
- const HmiInterfaces::InterfaceID interface) const {
-#ifdef SDL_REMOTE_CONTROL
- HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces();
- const HmiInterfaces::InterfaceState state =
- hmi_interfaces.GetInterfaceState(interface);
- return HmiInterfaces::STATE_NOT_AVAILABLE != state;
-#endif // SDL_REMOTE_CONTROL
- return false;
-}
-
-void CoreService::RemoveHMIFakeParameters(
- application_manager::MessagePtr& message) {
- application_manager_.RemoveHMIFakeParameters(message);
-}
-
-ApplicationSharedPtr CoreService::GetApplication(ApplicationId app_id) {
- return application_manager_.application(app_id);
-}
-
-void CoreService::SendMessageToHMI(const MessagePtr& message) {
- application_manager_.GetRPCService().SendPostMessageToHMI(message);
-}
-
-void CoreService::SendMessageToMobile(const MessagePtr& message) {
- application_manager_.GetRPCService().SendPostMessageToMobile(message);
-}
-
-uint32_t CoreService::GetNextCorrelationID() {
- return application_manager_.GetNextHMICorrelationID();
-}
-
-std::vector<ApplicationSharedPtr> CoreService::GetApplications(
- AppExtensionUID uid) {
- ApplicationSet accessor = application_manager_.applications().GetData();
- AppExtensionPredicate predicate;
- predicate.uid = uid;
-
- std::vector<ApplicationSharedPtr> result;
- ApplicationSetConstIt it =
- std::find_if(accessor.begin(), accessor.end(), predicate);
- while (it != accessor.end()) {
- result.push_back(*it);
- it = std::find_if(++it, accessor.end(), predicate);
- }
- return result;
-}
-
-void CoreService::ChangeNotifyHMILevel(ApplicationSharedPtr app,
- mobile_apis::HMILevel::eType level) {
- DCHECK_OR_RETURN_VOID(app);
- application_manager_.ChangeAppsHMILevel(app->app_id(), level);
-}
-
-const smart_objects::SmartObject* CoreService::GetRCCapabilities() const {
- return application_manager_.hmi_capabilities().rc_capability();
-}
-
-void CoreService::NotifyHMIAboutHMILevel(ApplicationSharedPtr app,
- mobile_apis::HMILevel::eType level) {
- DCHECK_OR_RETURN_VOID(app);
- if (app->hmi_level() != mobile_apis::HMILevel::eType::HMI_FULL) {
- MessageHelper::SendActivateAppToHMI(
- app->app_id(),
- application_manager_,
- static_cast<hmi_apis::Common_HMILevel::eType>(level),
- true);
- }
-}
-
-bool CoreService::AreParametersAllowed(
- MessagePtr msg, const CommandParametersPermissions& params) {
- Json::Reader reader;
- Json::Value json;
- bool ret = reader.parse(msg->json_message(), json);
- if (ret) {
- return CheckParams(json.get(strings::params, Json::Value(Json::nullValue)),
- params.allowed_params);
- }
- return false;
-}
-
-bool CoreService::CheckParams(const Json::Value& object,
- const RPCParams& allowed_params) {
- if (!object.isObject()) {
- return true;
- }
- for (Json::Value::iterator i = object.begin(); i != object.end(); ++i) {
- std::string name = i.memberName();
- if (!IsAllowed(name, allowed_params)) {
- return false;
- }
- }
- return true;
-}
-
-bool CoreService::IsAllowed(const std::string& name,
- const RPCParams& allowed_params) {
- return std::find(allowed_params.begin(), allowed_params.end(), name) !=
- allowed_params.end();
-}
-
-bool CoreService::GetModuleTypes(const std::string& policy_app_id,
- std::vector<std::string>* modules) const {
-#ifdef SDL_REMOTE_CONTROL
- return application_manager_.GetPolicyHandler().GetModuleTypes(policy_app_id,
- modules);
-#endif // SDL_REMOTE_CONTROL
- return false;
-}
-
-MessageValidationResult CoreService::ValidateMessageBySchema(
- const Message& message) {
- const MessageValidationResult result =
- application_manager_.ValidateMessageBySchema(message);
- LOG4CXX_DEBUG(logger_, "Validation result : " << result);
- return result;
-}
-
-const ApplicationManagerSettings& CoreService::GetSettings() const {
- return application_manager_.get_settings();
-}
-
-} // namespace application_manager
diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h
index 6e942533c8..163fe447c0 100644
--- a/src/components/include/application_manager/application_manager.h
+++ b/src/components/include/application_manager/application_manager.h
@@ -320,10 +320,7 @@ class ApplicationManager {
virtual const std::set<int32_t> GetAppsSubscribedForWayPoints() const = 0;
virtual void RemoveHMIFakeParameters(
- application_manager::MessagePtr& message) = 0;
-
- virtual MessageValidationResult ValidateMessageBySchema(
- const Message& message) = 0;
+ application_manager::commands::MessageSharedPtr& message) = 0;
virtual mobile_api::HMILevel::eType GetDefaultHmiLevel(
ApplicationConstSharedPtr application) const = 0;
diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h
index d48c7307b9..9211268893 100644
--- a/src/components/include/application_manager/policies/policy_handler_interface.h
+++ b/src/components/include/application_manager/policies/policy_handler_interface.h
@@ -40,7 +40,6 @@
#include <queue>
#include "interfaces/MOBILE_API.h"
#include "application_manager/policies/policy_handler_observer.h"
-#include "application_manager/core_service.h"
#include "application_manager/application.h"
#include "policy/usage_statistics/statistics_manager.h"
#include "utils/custom_string.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 dd2d604d3b..c771c48b40 100644
--- a/src/components/include/test/application_manager/mock_application_manager.h
+++ b/src/components/include/test/application_manager/mock_application_manager.h
@@ -311,9 +311,6 @@ class MockApplicationManager : public application_manager::ApplicationManager {
protocol_handler::ServiceType service_type,
bool result,
std::vector<std::string>& rejected_params));
- MOCK_METHOD1(ValidateMessageBySchema,
- application_manager::MessageValidationResult(
- const application_manager::Message& message));
MOCK_METHOD2(ProcessReconnection,
void(application_manager::ApplicationSharedPtr application,
const uint32_t connection_key));