summaryrefslogtreecommitdiff
path: root/src/components/application_manager/include
diff options
context:
space:
mode:
authorShobhit Adlakha <ShobhitAd@users.noreply.github.com>2019-03-07 21:43:31 -0500
committerGitHub <noreply@github.com>2019-03-07 21:43:31 -0500
commit3be4d6a8384f5422a040121c11b448a7dd6901fc (patch)
treeeef53c493b759056158ac39b261fcd4e0519b7b3 /src/components/application_manager/include
parent5cc1ad073dd9a05a3bd65499acf0c6b079287a29 (diff)
downloadsdl_core-3be4d6a8384f5422a040121c11b448a7dd6901fc.tar.gz
RPC Passing and Handling unknown RPC parameters (#2821)
* Initial app service app extension * Add GetAppServiceData rpc templates. * Add request to mobile, and fix HMI GASD naming * Add Core->Mobile Requests and Responses * HMI GetAppService Request/Response to hmi and from hmi. * Add mobile on event handling * Fix GASD Response From Mobile * Add PerformAppServiceInteraction RPC * Fixes for GetAppServiceData subscribe, and OnAppServiceData Fixes allow for multiple consumers on a single app service type. Consumer/provider can be any combination of an ios app(s), android app(s), or an ivi HMI app(s). * Update AppServicetype to string and fix unit tests * Implemented RpcPassThroughTimeout param and IncreaseForwardedRequestTimeout function * Address review comments * Fixed build tests * Fix style * Address comments * Address comments * Pass info from provider in GASD response * Implemented boolean paramter to keep/remove unknown RPC paramaters * Added plugin keys * Implemented allowing unknown rpc params if function is handled by AS plugin or is related to SystemCapability * Implemented handling unknown params for OSCU notifications * Fixed build tests * Implemented handling unknown params for RPC Passing * Initial implementation of RPC Passing * fixed UNSUPPORTED_REQUEST case * Moved RPCPassing implementation into seperate class * Implemented passthrough request timeout * Addressed style and formatting comments * Put RPCPassingHandler in seperate file * Removed unused request/response file (based on review comment r263121367) * Fixed timeout implementation * Created functions for handling forwarding requests/responses to core and mobile * Moved Populating request queue functionality to seperate function * Changed implementation to use one map with the original request and a queue of app service information * Fixed timeout implementation * Seperated RPCPassing checks from IsAppServiceRPC checks * Added locks for request and timeout queues * Addressed review comments * Fixed rpc_passing_handler_ initializer and added comments * Reduced scope of locks for rpc_passing_queue
Diffstat (limited to 'src/components/application_manager/include')
-rw-r--r--src/components/application_manager/include/application_manager/app_service_manager.h6
-rw-r--r--src/components/application_manager/include/application_manager/application_manager_impl.h3
-rw-r--r--src/components/application_manager/include/application_manager/plugin_manager/plugin_keys.h48
-rw-r--r--src/components/application_manager/include/application_manager/rpc_handler_impl.h3
-rw-r--r--src/components/application_manager/include/application_manager/rpc_passing_handler.h113
-rw-r--r--src/components/application_manager/include/application_manager/rpc_service_impl.h6
6 files changed, 175 insertions, 4 deletions
diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h
index d6d13a209a..f7c46178c5 100644
--- a/src/components/application_manager/include/application_manager/app_service_manager.h
+++ b/src/components/application_manager/include/application_manager/app_service_manager.h
@@ -37,6 +37,7 @@
#include "interfaces/MOBILE_API.h"
#include "smart_objects/smart_object.h"
#include "application_manager/application.h"
+#include "application_manager/rpc_passing_handler.h"
namespace resumption {
class LastState;
@@ -52,7 +53,6 @@ struct AppService {
};
class ApplicationManager;
-
/**
* @brief The AppServiceManager is TODO.
*/
@@ -124,6 +124,7 @@ class AppServiceManager {
* @param manifest
*/
std::vector<smart_objects::SmartObject> GetAllServices();
+ std::vector<std::pair<std::string, AppService> > GetActiveServices();
void GetProviderByType(const std::string& service_type,
bool mobile_consumer,
@@ -159,12 +160,15 @@ class AppServiceManager {
*/
bool UpdateNavigationCapabilities(smart_objects::SmartObject& out_params);
+ RPCPassingHandler& GetRPCPassingHandler();
+
private:
ApplicationManager& app_manager_;
resumption::LastState& last_state_;
sync_primitives::RecursiveLock published_services_lock_;
std::map<std::string, AppService> published_services_;
+ RPCPassingHandler rpc_passing_handler_;
void AppServiceUpdated(
const smart_objects::SmartObject& service_record,
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 6161d6bbbf..12f2310d36 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
@@ -1118,7 +1118,8 @@ class ApplicationManagerImpl
mobile_apis::MOBILE_API& mobile_so_factory();
bool ConvertSOtoMessage(const smart_objects::SmartObject& message,
- Message& output);
+ Message& output,
+ const bool remove_unknown_parameters = true);
template <typename ApplicationList>
void PrepareApplicationListSO(ApplicationList app_list,
diff --git a/src/components/application_manager/include/application_manager/plugin_manager/plugin_keys.h b/src/components/application_manager/include/application_manager/plugin_manager/plugin_keys.h
new file mode 100644
index 0000000000..11a7d353f6
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/plugin_manager/plugin_keys.h
@@ -0,0 +1,48 @@
+/*
+ Copyright (c) 2019, Ford Motor Company, Livio
+ 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 the copyright holders nor the names of their
+ 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_PLUGIN_MANAGER_PLUGIN_KEYS_H
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_PLUGIN_KEYS_H
+
+namespace application_manager {
+namespace plugin_manager {
+
+namespace plugin_names {
+extern const char* vehicle_info_rpc_plugin;
+extern const char* app_service_rpc_plugin;
+extern const char* rc_rpc_plugin;
+extern const char* sdl_rpc_plugin;
+}
+
+} // namespace plugin_manager
+} // namespace application_manager
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_PLUGIN_KEYS_H
diff --git a/src/components/application_manager/include/application_manager/rpc_handler_impl.h b/src/components/application_manager/include/application_manager/rpc_handler_impl.h
index cc93e4213c..b7e74c5ab3 100644
--- a/src/components/application_manager/include/application_manager/rpc_handler_impl.h
+++ b/src/components/application_manager/include/application_manager/rpc_handler_impl.h
@@ -158,7 +158,8 @@ class RPCHandlerImpl : public RPCHandler,
void ProcessMessageFromMobile(const std::shared_ptr<Message> message);
void ProcessMessageFromHMI(const std::shared_ptr<Message> message);
bool ConvertMessageToSO(const Message& message,
- smart_objects::SmartObject& output);
+ smart_objects::SmartObject& output,
+ const bool remove_unknown_parameters = true);
std::shared_ptr<Message> ConvertRawMsgToMessage(
const ::protocol_handler::RawMessagePtr message);
hmi_apis::HMI_API& hmi_so_factory();
diff --git a/src/components/application_manager/include/application_manager/rpc_passing_handler.h b/src/components/application_manager/include/application_manager/rpc_passing_handler.h
new file mode 100644
index 0000000000..3ed10ff1e6
--- /dev/null
+++ b/src/components/application_manager/include/application_manager/rpc_passing_handler.h
@@ -0,0 +1,113 @@
+/*
+ * 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_PASSING_HANDLER_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RPC_PASSING_HANDLER_H_
+
+#include "application_manager/application.h"
+#include "interfaces/MOBILE_API.h"
+#include "smart_objects/smart_object.h"
+#include "application_manager/app_service_manager.h"
+#include <deque>
+#include "utils/timer.h"
+
+namespace application_manager {
+
+struct ServiceInfo {
+ std::string service_id;
+ uint32_t connection_key;
+};
+
+typedef std::shared_ptr<timer::Timer> TimerSPtr;
+
+class AppServiceManager;
+
+class RPCPassingHandler {
+ public:
+ RPCPassingHandler(AppServiceManager& asm_ref, ApplicationManager& am_ref);
+
+ /**
+ * @brief Class destructor
+ */
+ ~RPCPassingHandler();
+
+ /**
+ * @brief Check if function id is in the handled_rpcs list of an active app
+ * service
+ * @param function_id RPC function id
+ * @return true if function id exists in handled_rpcs list of an active app
+ * service
+ */
+ bool CanHandleFunctionID(int32_t function_id);
+
+ /**
+ * @brief Check if app services or core is being used to handle the RPC
+ * @param correlation_id correlation id of RPC response
+ * @return true if an app service was used to handle the RPC
+ */
+ bool IsPassThroughMessage(uint32_t correlation_id,
+ commands::Command::CommandSource source,
+ int32_t message_type);
+
+ /**
+ * @brief Function to handle sending and receiving RPC Passing
+ * requests/responses
+ * @param rpc_message RPC message SmartObject
+ * @return true if the request was forwarded, false otherwise
+ */
+ bool RPCPassThrough(smart_objects::SmartObject rpc_message);
+
+ private:
+ bool PerformNextRequest(uint32_t correlation_id);
+ void OnPassThroughRequestTimeout();
+ void AddRequestTimer(uint32_t correlation_id);
+ void RemoveRequestTimer(uint32_t correlation_id);
+ void ClearCompletedTimers();
+ void ForwardRequestToMobile(uint32_t correlation_id);
+ void ForwardRequestToCore(uint32_t correlation_id);
+ void ForwardResponseToMobile(uint32_t correlation_id,
+ smart_objects::SmartObject response_message);
+ void PopulateRPCRequestQueue(smart_objects::SmartObject request_message);
+
+ AppServiceManager& app_service_manager_;
+ ApplicationManager& app_manager_;
+ sync_primitives::RecursiveLock rpc_request_queue_lock_;
+ std::map<uint32_t,
+ std::pair<smart_objects::SmartObject, std::deque<ServiceInfo> > >
+ rpc_request_queue;
+ sync_primitives::RecursiveLock timeout_queue_lock_;
+ std::vector<std::pair<TimerSPtr, uint32_t> > timeout_queue_;
+};
+
+} // namespace application_manager
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RPC_PASSING_HANDLER_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 98767672ca..848e9645e7 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
@@ -121,6 +121,9 @@ class RPCServiceImpl : public RPCService,
bool final_message = false) OVERRIDE;
void SendMessageToHMI(const commands::MessageSharedPtr message) OVERRIDE;
+ bool IsAppServiceRPC(int32_t function_id,
+ commands::Command::CommandSource source);
+
void set_protocol_handler(
protocol_handler::ProtocolHandler* handler) OVERRIDE;
void set_hmi_message_handler(
@@ -128,7 +131,8 @@ class RPCServiceImpl : public RPCService,
private:
bool ConvertSOtoMessage(const smart_objects::SmartObject& message,
- Message& output);
+ Message& output,
+ const bool remove_unknown_parameters = true);
hmi_apis::HMI_API& hmi_so_factory();
mobile_apis::MOBILE_API& mobile_so_factory();