diff options
author | jacobkeeler <jacob.keeler@livioradio.com> | 2020-07-20 16:49:20 -0400 |
---|---|---|
committer | jacobkeeler <jacob.keeler@livioradio.com> | 2020-07-20 16:49:20 -0400 |
commit | 2ce74a7dff5146b5cee07e94e83cbffd85570ec4 (patch) | |
tree | c14ae434761f0f5c05c5cfc0705e5e7b9eb3e5d7 | |
parent | b614088d2549ac2b59bdaa521543905546c1f639 (diff) | |
download | sdl_core-2ce74a7dff5146b5cee07e94e83cbffd85570ec4.tar.gz |
Add OnSubtleAlertPressed implementation
7 files changed, 320 insertions, 0 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_subtle_alert_pressed_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_subtle_alert_pressed_notification.h new file mode 100644 index 0000000000..fd6aa2e837 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_subtle_alert_pressed_notification.h @@ -0,0 +1,80 @@ +/* + 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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_SUBTLE_ALERT_PRESSED_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_SUBTLE_ALERT_PRESSED_NOTIFICATION_H_ + +#include "application_manager/commands/notification_from_hmi.h" +#include "sdl_rpc_plugin/sdl_rpc_plugin.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnUISubtleAlertPressedNotification command class + **/ +class OnUISubtleAlertPressedNotification + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnUISubtleAlertPressedNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnUISubtleAlertPressedNotification( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief OnUISubtleAlertPressedNotification class destructor + **/ + ~OnUISubtleAlertPressedNotification() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(OnUISubtleAlertPressedNotification); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_SUBTLE_ALERT_PRESSED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_subtle_alert_pressed_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_subtle_alert_pressed_notification.h new file mode 100644 index 0000000000..7836e48054 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_subtle_alert_pressed_notification.h @@ -0,0 +1,80 @@ +/* + 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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_SUBTLE_ALERT_PRESSED_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_SUBTLE_ALERT_PRESSED_NOTIFICATION_H_ + +#include "application_manager/commands/command_notification_impl.h" +#include "sdl_rpc_plugin/sdl_rpc_plugin.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnSubtleAlertPressedNotification command class + **/ +class OnSubtleAlertPressedNotification + : public app_mngr::commands::CommandNotificationImpl { + public: + /** + * @brief OnSubtleAlertPressedNotification class constructor + * + * @param message Incoming SmartObject message + **/ + OnSubtleAlertPressedNotification( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief OnSubtleAlertPressedNotification class destructor + **/ + ~OnSubtleAlertPressedNotification() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(OnSubtleAlertPressedNotification); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_SUBTLE_ALERT_PRESSED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_subtle_alert_pressed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_subtle_alert_pressed_notification.cc new file mode 100644 index 0000000000..e720a4b4a8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_subtle_alert_pressed_notification.cc @@ -0,0 +1,62 @@ +/* + 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. + */ + +#include "sdl_rpc_plugin/commands/hmi/on_ui_subtle_alert_pressed_notification.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +OnUISubtleAlertPressedNotification::OnUISubtleAlertPressedNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +OnUISubtleAlertPressedNotification::~OnUISubtleAlertPressedNotification() {} + +void OnUISubtleAlertPressedNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + (*message_)[strings::params][strings::function_id] = static_cast<int32_t>( + mobile_apis::FunctionID::eType::OnSubtleAlertPressedID); + SendNotificationToMobile(message_); +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_subtle_alert_pressed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_subtle_alert_pressed_notification.cc new file mode 100644 index 0000000000..279de2f1c6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_subtle_alert_pressed_notification.cc @@ -0,0 +1,74 @@ +/* + 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. + */ + +#include "sdl_rpc_plugin/commands/mobile/on_subtle_alert_pressed_notification.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +OnSubtleAlertPressedNotification::OnSubtleAlertPressedNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandNotificationImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +OnSubtleAlertPressedNotification::~OnSubtleAlertPressedNotification() {} + +void OnSubtleAlertPressedNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application_manager_.application( + (*message_)[strings::msg_params][strings::app_id].asInt()); + + if (!app) { + LOG4CXX_ERROR(logger_, "No application associated with session key"); + return; + } + + (*message_)[strings::params][strings::connection_key] = app->app_id(); + // remove app_id from notification + (*message_)[strings::msg_params].erase(strings::app_id); + + SendNotification(); +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc index c12abfce43..0289a92290 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc @@ -231,6 +231,7 @@ #include "sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_subtle_alert_pressed_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.h" @@ -930,6 +931,9 @@ CommandCreator& HMICommandFactory::get_creator_factory( case hmi_apis::FunctionID::BasicCommunication_OnAppPropertiesChange: { return factory.GetCreator<commands::OnAppPropertiesChangeNotification>(); } + case hmi_apis::FunctionID::UI_OnSubtleAlertPressed: { + return factory.GetCreator<commands::OnUISubtleAlertPressedNotification>(); + } default: { return factory.GetCreator<InvalidCommand>(); } } } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc index 0853187b21..5855309f80 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc @@ -88,6 +88,7 @@ #include "sdl_rpc_plugin/commands/mobile/on_keyboard_input_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_language_change_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_permissions_change_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_subtle_alert_pressed_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_system_capability_updated_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_system_request_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_tbt_client_state_notification.h" @@ -466,6 +467,9 @@ CommandCreator& MobileCommandFactory::get_notification_creator( case mobile_apis::FunctionID::OnWayPointChangeID: { return factory.GetCreator<commands::OnWayPointChangeNotification>(); } + case mobile_apis::FunctionID::OnSubtleAlertPressedID: { + return factory.GetCreator<commands::OnSubtleAlertPressedNotification>(); + } default: {} } return factory.GetCreator<InvalidCommand>(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc index 26f7a63872..0dda938b75 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc @@ -79,6 +79,7 @@ #include "sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_subtle_alert_pressed_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h" @@ -479,6 +480,21 @@ TEST_F(HMICommandsNotificationsTest, OnUITouchEventSendNotificationToMobile) { } TEST_F(HMICommandsNotificationsTest, + OnUISubtleAlertPressedSendNotificationToMobile) { + MessageSharedPtr message = CreateMessage(); + std::shared_ptr<Command> command = + CreateCommand<OnUISubtleAlertPressedNotification>(message); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); + command->Run(); + EXPECT_EQ( + static_cast<int32_t>(mobile_apis::FunctionID::OnSubtleAlertPressedID), + (*message)[am::strings::params][am::strings::function_id].asInt()); + EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), + (*message)[am::strings::params][am::strings::message_type].asInt()); +} + +TEST_F(HMICommandsNotificationsTest, OnAppRegisteredNotificationSendNotificationToHmi) { int32_t event_id = hmi_apis::FunctionID::INVALID_ENUM; MessageSharedPtr message = CreateMessage(); |