diff options
author | JackLivio <jack@livio.io> | 2019-02-24 14:28:12 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-24 14:28:12 -0500 |
commit | aa8ad39cc936c7de63818d4307d8ac6a4dff5530 (patch) | |
tree | a68556366fb073b1ee238e0a834835ff33ad09c0 /src/components/application_manager/include/application_manager/commands | |
parent | c1a903b5fe0831044b5e88dc4d27b0160b703955 (diff) | |
download | sdl_core-aa8ad39cc936c7de63818d4307d8ac6a4dff5530.tar.gz |
Get App Service Data With Subscribe (#2812)
* 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
* 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
* Address review comments
* Address comments
* Address comments
* Pass info from provider in GASD response
Diffstat (limited to 'src/components/application_manager/include/application_manager/commands')
7 files changed, 216 insertions, 6 deletions
diff --git a/src/components/application_manager/include/application_manager/commands/command.h b/src/components/application_manager/include/application_manager/commands/command.h index f8ea7db24d..d832995b8d 100644 --- a/src/components/application_manager/include/application_manager/commands/command.h +++ b/src/components/application_manager/include/application_manager/commands/command.h @@ -112,7 +112,12 @@ class Command { */ virtual void SetAllowedToTerminate(const bool allowed) = 0; - enum CommandSource { SOURCE_SDL, SOURCE_MOBILE, SOURCE_HMI }; + enum CommandSource { + SOURCE_SDL, + SOURCE_MOBILE, + SOURCE_HMI, + SOURCE_SDL_TO_HMI + }; }; typedef smart_objects::SmartObjectSPtr MessageSharedPtr; diff --git a/src/components/application_manager/include/application_manager/commands/command_notification_from_mobile_impl.h b/src/components/application_manager/include/application_manager/commands/command_notification_from_mobile_impl.h index 8741dae540..e8485a3abc 100644 --- a/src/components/application_manager/include/application_manager/commands/command_notification_from_mobile_impl.h +++ b/src/components/application_manager/include/application_manager/commands/command_notification_from_mobile_impl.h @@ -53,6 +53,11 @@ class CommandNotificationFromMobileImpl : public CommandImpl { virtual bool CleanUp(); virtual void Run(); void SendNotification(); + void SendNotificationToMobile(); + void SendNotificationToHMI( + const hmi_apis::FunctionID::eType& hmi_function_id); + void SendNotificationToConsumers( + const hmi_apis::FunctionID::eType& hmi_function_id); private: DISALLOW_COPY_AND_ASSIGN(CommandNotificationFromMobileImpl); diff --git a/src/components/application_manager/include/application_manager/commands/command_request_impl.h b/src/components/application_manager/include/application_manager/commands/command_request_impl.h index 27aa93d1d8..a5ecd7274b 100644 --- a/src/components/application_manager/include/application_manager/commands/command_request_impl.h +++ b/src/components/application_manager/include/application_manager/commands/command_request_impl.h @@ -149,6 +149,8 @@ class CommandRequestImpl : public CommandImpl, */ virtual void on_event(const event_engine::Event& event); + virtual void on_event(const event_engine::MobileEvent& event); + /* * @brief Creates Mobile response * @@ -170,6 +172,16 @@ class CommandRequestImpl : public CommandImpl, */ bool CheckSyntax(const std::string& str, bool allow_empty_line = false); + void SendProviderRequest( + const mobile_apis::FunctionID::eType& mobile_function_id, + const hmi_apis::FunctionID::eType& hmi_function_id, + const smart_objects::SmartObject* msg, + bool use_events = false); + + void SendMobileRequest(const mobile_apis::FunctionID::eType& function_id, + smart_objects::SmartObjectSPtr msg, + bool use_events = false); + /* * @brief Sends HMI request * @@ -235,6 +247,14 @@ class CommandRequestImpl : public CommandImpl, bool HasDisallowedParams() const; /** + * @brief Checks result code from Mobile for single RPC + * @param result_code contains result code from Mobile response + * @return true if result code complies successful result codes, + * false otherwise. + */ + bool IsMobileResultSuccess(mobile_apis::Result::eType result_code) const; + + /** * @brief Checks result code from HMI for single RPC * and returns parameter for sending to mobile app. * @param result_code contains result code from HMI response diff --git a/src/components/application_manager/include/application_manager/commands/command_request_to_mobile.h b/src/components/application_manager/include/application_manager/commands/command_request_to_mobile.h new file mode 100644 index 0000000000..a1e63561bf --- /dev/null +++ b/src/components/application_manager/include/application_manager/commands/command_request_to_mobile.h @@ -0,0 +1,73 @@ +/* + 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_COMMANDS_COMMAND_REQUEST_TO_MOBILE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_REQUEST_TO_MOBILE_H_ + +#include "application_manager/commands/command_impl.h" +#include "application_manager/application_manager.h" +#include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" + +namespace application_manager { + +namespace commands { + +class CommandRequestToMobile : public CommandImpl { + public: + CommandRequestToMobile(const MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + ~CommandRequestToMobile(); + bool Init() OVERRIDE; + bool CleanUp() OVERRIDE; + void Run() OVERRIDE; + void SendRequest(); + + /* + * @brief Retrieves application ID + */ + inline uint32_t application_id() const { + return (*message_)[strings::msg_params][strings::app_id].asUInt(); + } + + private: + DISALLOW_COPY_AND_ASSIGN(CommandRequestToMobile); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_REQUEST_TO_MOBILE_H_ diff --git a/src/components/application_manager/include/application_manager/commands/command_response_from_mobile.h b/src/components/application_manager/include/application_manager/commands/command_response_from_mobile.h new file mode 100644 index 0000000000..65983d82f8 --- /dev/null +++ b/src/components/application_manager/include/application_manager/commands/command_response_from_mobile.h @@ -0,0 +1,73 @@ +/* + 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_COMMANDS_COMMAND_RESPONSE_TO_MOBILE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_RESPONSE_TO_MOBILE_H_ + +#include "application_manager/commands/command_impl.h" +#include "application_manager/application_manager.h" +#include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" + +namespace application_manager { + +namespace commands { + +class CommandResponseFromMobile : public CommandImpl { + public: + CommandResponseFromMobile(const MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + ~CommandResponseFromMobile(); + bool Init() OVERRIDE; + bool CleanUp() OVERRIDE; + void Run() OVERRIDE; + void SendResponse(); + + /* + * @brief Retrieves application ID + */ + inline uint32_t application_id() const { + return (*message_)[strings::msg_params][strings::app_id].asUInt(); + } + + private: + DISALLOW_COPY_AND_ASSIGN(CommandResponseFromMobile); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_RESPONSE_TO_MOBILE_H_ diff --git a/src/components/application_manager/include/application_manager/commands/notification_from_hmi.h b/src/components/application_manager/include/application_manager/commands/notification_from_hmi.h index 8bbbd0e3de..25cfd7b207 100644 --- a/src/components/application_manager/include/application_manager/commands/notification_from_hmi.h +++ b/src/components/application_manager/include/application_manager/commands/notification_from_hmi.h @@ -53,8 +53,14 @@ class NotificationFromHMI : public CommandImpl { virtual bool CleanUp(); virtual void Run(); void SendNotificationToMobile(const MessageSharedPtr& message); + void SendNotificationToMobile( + const MessageSharedPtr& message, + const mobile_apis::FunctionID::eType& mobile_function_id); + void SendNotificationToHMI(MessageSharedPtr& message); void CreateHMIRequest(const hmi_apis::FunctionID::eType& function_id, const smart_objects::SmartObject& msg_params) const; + void SendNotificationToConsumers( + const mobile_apis::FunctionID::eType& mobile_function_id); private: DISALLOW_COPY_AND_ASSIGN(NotificationFromHMI); diff --git a/src/components/application_manager/include/application_manager/commands/request_from_hmi.h b/src/components/application_manager/include/application_manager/commands/request_from_hmi.h index d980e98576..0a5f5d7eee 100644 --- a/src/components/application_manager/include/application_manager/commands/request_from_hmi.h +++ b/src/components/application_manager/include/application_manager/commands/request_from_hmi.h @@ -55,17 +55,20 @@ class RequestFromHMI : public CommandImpl, public event_engine::EventObserver { virtual bool CleanUp(); virtual void Run(); virtual void on_event(const event_engine::Event& event); + void on_event(const event_engine::MobileEvent& event) OVERRIDE; /** * @brief SendResponse allows to send response to hmi * @param correlation_id the correlation id for the rfesponse. * @param function_id the function id for which response will be sent * @param result_code the result code. */ - void SendResponse(const bool success, - const uint32_t correlation_id, - const hmi_apis::FunctionID::eType function_id, - const hmi_apis::Common_Result::eType result_code, - const smart_objects::SmartObject* response_params = NULL); + void SendResponse( + const bool success, + const uint32_t correlation_id, + const hmi_apis::FunctionID::eType function_id, + const hmi_apis::Common_Result::eType result_code, + const smart_objects::SmartObject* response_params = NULL, + commands::Command::CommandSource source = commands::Command::SOURCE_HMI); /** * @brief SendResponse allows to send error response to hmi @@ -79,6 +82,25 @@ class RequestFromHMI : public CommandImpl, public event_engine::EventObserver { const hmi_apis::Common_Result::eType result_code, const std::string error_message); + void SendProviderRequest( + const mobile_apis::FunctionID::eType& mobile_function_id, + const hmi_apis::FunctionID::eType& hmi_function_id, + const smart_objects::SmartObject* msg, + bool use_events = false); + + void SendMobileRequest(const mobile_apis::FunctionID::eType& function_id, + const ApplicationSharedPtr app, + const smart_objects::SmartObject* msg_params, + bool use_events); + + void SendHMIRequest(const hmi_apis::FunctionID::eType& function_id, + const smart_objects::SmartObject* msg_params, + bool use_events); + + bool ProcessHMIInterfacesAvailability( + const uint32_t hmi_correlation_id, + const hmi_apis::FunctionID::eType& function_id); + private: /** * @brief Fills common parameters for SO @@ -91,6 +113,12 @@ class RequestFromHMI : public CommandImpl, public event_engine::EventObserver { const uint32_t correlation_id, const hmi_apis::FunctionID::eType function_id); + protected: + bool IsMobileResultSuccess(mobile_apis::Result::eType result_code) const; + + bool IsHMIResultSuccess(hmi_apis::Common_Result::eType result_code, + HmiInterfaces::InterfaceID interface) const; + private: DISALLOW_COPY_AND_ASSIGN(RequestFromHMI); }; |