From 26ca4e31a31d89c6c28a47f1252237b029e62c6a Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 2 Dec 2020 13:43:42 -0500 Subject: Handle omitted parameter permissions properly in OnVehicleData notification --- .../mobile/on_vehicle_data_notification.cc | 26 ++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc index 1799d7068c..cfa638de95 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc @@ -112,15 +112,23 @@ void OnVehicleDataNotification::Run() { mobile_api::FunctionID::OnVehicleDataID), appSO[idx].enumerate(), ¶ms_permissions); - - for (const auto& param : appSO[idx].enumerate()) { - const auto& allowed_params = params_permissions.allowed_params; - auto param_allowed = allowed_params.find(param); - if (allowed_params.end() == param_allowed) { - SDL_LOG_DEBUG("Param " << param << " is not allowed by policy for app " - << notify_apps[idx]->app_id() - << ". It will be ignored."); - appSO[idx].erase(param); + if (parameters_permissions_.allowed_params.empty() && + parameters_permissions_.disallowed_params.empty() && + parameters_permissions_.undefined_params.empty()) { + SDL_LOG_DEBUG( + "No parameter permissions provided, all params are allowed"); + } + else { + for (const auto& param : appSO[idx].enumerate()) { + const auto& allowed_params = params_permissions.allowed_params; + auto param_allowed = allowed_params.find(param); + if (allowed_params.end() == param_allowed) { + SDL_LOG_DEBUG("Param " << param + << " is not allowed by policy for app " + << notify_apps[idx]->app_id() + << ". It will be ignored."); + appSO[idx].erase(param); + } } } -- cgit v1.2.1 From 13dcd6f5f36d462f0b0892864340fb9e84ad5884 Mon Sep 17 00:00:00 2001 From: Jacob Keeler Date: Wed, 9 Dec 2020 13:09:25 -0500 Subject: Add OnWayPointChange handling for NAVIGATION app services (#3573) * Add OnWayPointChange handling for NAVIGATION app services * Only send OnWayPointChange to mobile from active waypoints provider --- src/appMain/sdl_preloaded_pt.json | 3 +- .../application_manager/app_service_manager.h | 7 ++ .../application_manager/application_manager_impl.h | 40 ++++------ .../on_way_point_change_notification_from_mobile.h | 75 ++++++++++++++++++ .../commands/mobile/subscribe_way_points_request.h | 2 + .../mobile/unsubscribe_way_points_request.h | 2 + .../hmi/on_navi_way_point_change_notification.cc | 8 +- .../mobile/on_way_point_change_notification.cc | 1 - ...on_way_point_change_notification_from_mobile.cc | 90 ++++++++++++++++++++++ .../mobile/subscribe_way_points_request.cc | 34 ++++++-- .../mobile/unsubscribe_way_points_request.cc | 35 +++++++-- .../sdl_rpc_plugin/src/mobile_command_factory.cc | 5 ++ .../src/waypoints_pending_resumption_handler.cc | 6 +- .../on_way_point_change_notification_test.cc | 1 - .../mobile/subscribe_way_points_request_test.cc | 7 +- .../mobile/unsubscribe_way_points_request_test.cc | 9 ++- .../application_manager/src/app_service_manager.cc | 19 +++++ .../src/application_manager_impl.cc | 72 ++++++++++++----- .../src/helpers/application_helper.cc | 8 +- .../test/application_helper_test.cc | 6 -- .../test/application_manager_impl_test.cc | 12 +-- .../test/resumption/resume_ctrl_test.cc | 6 +- .../application_manager/application_manager.h | 43 ++++++++--- .../application_manager/mock_application_manager.h | 17 ++-- 24 files changed, 406 insertions(+), 102 deletions(-) create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_way_point_change_notification_from_mobile.h create mode 100644 src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification_from_mobile.cc diff --git a/src/appMain/sdl_preloaded_pt.json b/src/appMain/sdl_preloaded_pt.json index eff433fd1e..cf3cc43fbb 100644 --- a/src/appMain/sdl_preloaded_pt.json +++ b/src/appMain/sdl_preloaded_pt.json @@ -854,8 +854,7 @@ "hmi_levels": [ "FULL", "LIMITED", - "BACKGROUND", - "NONE" + "BACKGROUND" ] }, "UnpublishAppService": { 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 d26598c1e9..94606909c6 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 @@ -214,6 +214,13 @@ class AppServiceManager { virtual bool UpdateNavigationCapabilities( smart_objects::SmartObject& out_params); + /** + * @brief Retrieve the active service for handling waypoints if available + * @return The active NAVIGATION service if it handles waypoints, nullptr + * otherwise + */ + virtual AppService* FindWayPointsHandler(); + /** * @brief Get the RPCPassingHandler tied to this object * @return The RPCPassingHandler tied to this object 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 bda1e5f49e..cb3be5fec6 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 @@ -286,32 +286,22 @@ class ApplicationManagerImpl */ bool IsAppSubscribedForWayPoints(Application& app) const OVERRIDE; - void SaveWayPointsMessage( - smart_objects::SmartObjectSPtr way_points_message) OVERRIDE; + void SaveWayPointsMessage(smart_objects::SmartObjectSPtr way_points_message, + uint32_t app_id = 0) OVERRIDE; - /** - * @brief Subscribe Application for way points - * @param Application id - */ - void SubscribeAppForWayPoints(uint32_t app_id) OVERRIDE; + void SubscribeAppForWayPoints(uint32_t app_id, + bool response_from_hmi = true) OVERRIDE; - /** - * @brief Subscribe Application for way points - * @param Application pointer - */ - void SubscribeAppForWayPoints(ApplicationSharedPtr app) OVERRIDE; + void SubscribeAppForWayPoints(ApplicationSharedPtr app, + bool response_from_hmi = true) OVERRIDE; - /** - * @brief Unsubscribe Application for way points - * @param Application id - */ - void UnsubscribeAppFromWayPoints(uint32_t app_id) OVERRIDE; + void UnsubscribeAppFromWayPoints(uint32_t app_id, + bool response_from_hmi = true) OVERRIDE; - /** - * @brief Unsubscribe Application for way points - * @param Application pointer - */ - void UnsubscribeAppFromWayPoints(ApplicationSharedPtr app) OVERRIDE; + void UnsubscribeAppFromWayPoints(ApplicationSharedPtr app, + bool response_from_hmi = true) OVERRIDE; + + bool IsSubscribedToHMIWayPoints() const OVERRIDE; /** * @brief Is Any Application is subscribed for way points @@ -1562,7 +1552,11 @@ class ApplicationManagerImpl */ std::set subscribed_way_points_apps_list_; - smart_objects::SmartObjectSPtr way_points_data_; + bool subscribed_to_hmi_way_points_; + + smart_objects::SmartObjectSPtr hmi_way_points_data_; + + std::map mobile_way_points_data_; /** * @brief Map contains applications which diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_way_point_change_notification_from_mobile.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_way_point_change_notification_from_mobile.h new file mode 100644 index 0000000000..2ad9a4c0af --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_way_point_change_notification_from_mobile.h @@ -0,0 +1,75 @@ +/* + * 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_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_WAY_POINT_CHANGE_NOTIFICATION_FROM_MOBILE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_WAY_POINT_CHANGE_NOTIFICATION_FROM_MOBILE_H_ + +#include "application_manager/commands/command_notification_from_mobile_impl.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +class OnWayPointChangeNotificationFromMobile + : public app_mngr::commands::CommandNotificationFromMobileImpl { + public: + /** + * @brief OnWayPointChangeNotificationFromMobile class constructor + * + * @param message Incoming SmartObject message + **/ + OnWayPointChangeNotificationFromMobile( + 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_handler); + + /** + * @brief OnWayPointChangeNotificationFromMobile class destructor + **/ + virtual ~OnWayPointChangeNotificationFromMobile(); + + /** + * @brief Execute command + **/ + virtual void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(OnWayPointChangeNotificationFromMobile); +}; + +} // namespace commands +} // namespace sdl_rpc_plugin +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_WAY_POINT_CHANGE_NOTIFICATION_FROM_MOBILE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h index 8b88a1c884..69154d7669 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h @@ -76,6 +76,8 @@ class SubscribeWayPointsRequest */ bool Init() FINAL; + void onTimeOut() FINAL; + private: DISALLOW_COPY_AND_ASSIGN(SubscribeWayPointsRequest); }; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h index e83e9b7509..c4357d7529 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h @@ -75,6 +75,8 @@ class UnsubscribeWayPointsRequest */ bool Init() FINAL; + void onTimeOut() FINAL; + private: DISALLOW_COPY_AND_ASSIGN(UnsubscribeWayPointsRequest); }; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_way_point_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_way_point_change_notification.cc index 2440e918b7..02c2ccf31b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_way_point_change_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_way_point_change_notification.cc @@ -32,6 +32,8 @@ #include "sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h" +#include "application_manager/app_service_manager.h" + namespace sdl_rpc_plugin { using namespace application_manager; @@ -56,8 +58,12 @@ void OnNaviWayPointChangeNotification::Run() { // prepare SmartObject for mobile factory (*message_)[strings::params][strings::function_id] = static_cast(mobile_apis::FunctionID::OnWayPointChangeID); + application_manager_.SaveWayPointsMessage(message_, 0); - SendNotificationToMobile(message_); + if (application_manager_.GetAppServiceManager().FindWayPointsHandler() == + nullptr) { + SendNotificationToMobile(message_); + } } } // namespace commands diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc index 33413f805d..4aa0d9c630 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc @@ -67,7 +67,6 @@ void OnWayPointChangeNotification::Run() { (*message_)[strings::params][strings::connection_key] = *app_id; SendNotification(); } - application_manager_.SaveWayPointsMessage(message_); } } // namespace commands } // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification_from_mobile.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification_from_mobile.cc new file mode 100644 index 0000000000..ad1b0c7ef7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification_from_mobile.cc @@ -0,0 +1,90 @@ +/* + Copyright (c) 2020, 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 "sdl_rpc_plugin/commands/mobile/on_way_point_change_notification_from_mobile.h" + +#include "application_manager/app_service_manager.h" +#include "application_manager/message.h" +#include "application_manager/message_helper.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +SDL_CREATE_LOG_VARIABLE("Commands") + +OnWayPointChangeNotificationFromMobile::OnWayPointChangeNotificationFromMobile( + 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) + : CommandNotificationFromMobileImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +OnWayPointChangeNotificationFromMobile:: + ~OnWayPointChangeNotificationFromMobile() {} + +void OnWayPointChangeNotificationFromMobile::Run() { + SDL_LOG_AUTO_TRACE(); + + (*message_)[strings::params][strings::message_type] = + static_cast(application_manager::MessageType::kNotification); + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (app.use_count() == 0) { + SDL_LOG_ERROR( + "OnWayPointChangeNotificationFromMobile application doesn't exist"); + return; + } + + auto service = + application_manager_.GetAppServiceManager().FindWayPointsHandler(); + if (!service || !service->mobile_service || + service->connection_key != connection_key()) { + SDL_LOG_ERROR("Application is not active NAVIGATION ASP"); + return; + } + + application_manager_.SaveWayPointsMessage(message_, connection_key()); + + (*message_)[strings::params][strings::message_type] = + static_cast(application_manager::MessageType::kNotification); + rpc_service_.ManageMobileCommand(message_, SOURCE_SDL); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_request.cc index 6e8ad05a74..11cbdac14a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_request.cc @@ -31,6 +31,8 @@ */ #include "sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h" + +#include "application_manager/app_service_manager.h" #include "application_manager/application_manager.h" #include "application_manager/message_helper.h" @@ -72,8 +74,8 @@ void SubscribeWayPointsRequest::Run() { return; } - if (application_manager_.IsAnyAppSubscribedForWayPoints()) { - application_manager_.SubscribeAppForWayPoints(app); + if (application_manager_.IsSubscribedToHMIWayPoints()) { + application_manager_.SubscribeAppForWayPoints(app, false); SendResponse(true, mobile_apis::Result::SUCCESS); return; } @@ -91,15 +93,20 @@ void SubscribeWayPointsRequest::on_event(const event_engine::Event& event) { case hmi_apis::FunctionID::Navigation_SubscribeWayPoints: { SDL_LOG_INFO("Received Navigation_SubscribeWayPoints event"); EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); - const hmi_apis::Common_Result::eType result_code = + hmi_apis::Common_Result::eType result_code = static_cast( message[strings::params][hmi_response::code].asInt()); std::string response_info; GetInfo(message, response_info); - const bool result = PrepareResultForMobileResponse( + bool result = PrepareResultForMobileResponse( result_code, HmiInterfaces::HMI_INTERFACE_Navigation); if (result) { - application_manager_.SubscribeAppForWayPoints(app); + application_manager_.SubscribeAppForWayPoints(app, true); + } else if (application_manager_.GetAppServiceManager() + .FindWayPointsHandler() != nullptr) { + application_manager_.SubscribeAppForWayPoints(app, false); + result = true; + result_code = hmi_apis::Common_Result::WARNINGS; } SendResponse(result, MessageHelper::HMIToMobileResult(result_code), @@ -114,6 +121,23 @@ void SubscribeWayPointsRequest::on_event(const event_engine::Event& event) { } } +void SubscribeWayPointsRequest::onTimeOut() { + SDL_LOG_AUTO_TRACE(); + if (application_manager_.GetAppServiceManager().FindWayPointsHandler() != + nullptr) { + ApplicationSharedPtr app = + application_manager_.application(connection_key()); + application_manager_.SubscribeAppForWayPoints(app, false); + SendResponse(true, + mobile_apis::Result::WARNINGS, + "HMI request timeout expired, waypoints are available through " + "NAVIGATION service"); + } else { + SendResponse( + false, mobile_apis::Result::GENERIC_ERROR, "Request timeout expired"); + } +} + bool SubscribeWayPointsRequest::Init() { hash_update_mode_ = HashUpdateMode::kDoHashUpdate; return true; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc index 545a36def8..7aa6e2b40a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc @@ -31,6 +31,8 @@ */ #include "sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h" + +#include "application_manager/app_service_manager.h" #include "application_manager/application_manager.h" #include "application_manager/message_helper.h" @@ -75,9 +77,10 @@ void UnsubscribeWayPointsRequest::Run() { std::set subscribed_apps = application_manager_.GetAppsSubscribedForWayPoints(); - if (subscribed_apps.size() > 1) { + if (subscribed_apps.size() > 1 || + !application_manager_.IsSubscribedToHMIWayPoints()) { // More than 1 subscribed app, don't send HMI unsubscribe request - application_manager_.UnsubscribeAppFromWayPoints(app); + application_manager_.UnsubscribeAppFromWayPoints(app, false); SendResponse(true, mobile_apis::Result::SUCCESS, NULL); return; } else { @@ -96,15 +99,20 @@ void UnsubscribeWayPointsRequest::on_event(const event_engine::Event& event) { case hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints: { SDL_LOG_INFO("Received Navigation_UnsubscribeWayPoints event"); EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); - const hmi_apis::Common_Result::eType result_code = + hmi_apis::Common_Result::eType result_code = static_cast( message[strings::params][hmi_response::code].asInt()); std::string response_info; GetInfo(message, response_info); - const bool result = PrepareResultForMobileResponse( + bool result = PrepareResultForMobileResponse( result_code, HmiInterfaces::HMI_INTERFACE_Navigation); if (result) { - application_manager_.UnsubscribeAppFromWayPoints(app); + application_manager_.UnsubscribeAppFromWayPoints(app, true); + } else if (application_manager_.GetAppServiceManager() + .FindWayPointsHandler() != nullptr) { + application_manager_.UnsubscribeAppFromWayPoints(app, false); + result = true; + result_code = hmi_apis::Common_Result::WARNINGS; } SendResponse(result, MessageHelper::HMIToMobileResult(result_code), @@ -119,6 +127,23 @@ void UnsubscribeWayPointsRequest::on_event(const event_engine::Event& event) { } } +void UnsubscribeWayPointsRequest::onTimeOut() { + SDL_LOG_AUTO_TRACE(); + if (application_manager_.GetAppServiceManager().FindWayPointsHandler() != + nullptr) { + ApplicationSharedPtr app = + application_manager_.application(connection_key()); + application_manager_.UnsubscribeAppFromWayPoints(app, false); + SendResponse(true, + mobile_apis::Result::WARNINGS, + "HMI request timeout expired, waypoints are available through " + "NAVIGATION service"); + } else { + SendResponse( + false, mobile_apis::Result::GENERIC_ERROR, "Request timeout expired"); + } +} + bool UnsubscribeWayPointsRequest::Init() { hash_update_mode_ = HashUpdateMode::kDoHashUpdate; return true; 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 d2f1325c82..9809a11a81 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 @@ -96,6 +96,7 @@ #include "sdl_rpc_plugin/commands/mobile/on_update_file_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_update_sub_menu_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_way_point_change_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_way_point_change_notification_from_mobile.h" #include "sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h" #include "sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_response.h" #include "sdl_rpc_plugin/commands/mobile/perform_interaction_request.h" @@ -491,6 +492,10 @@ CommandCreator& MobileCommandFactory::get_notification_from_mobile_creator( case mobile_apis::FunctionID::OnHMIStatusID: { return factory.GetCreator(); } + case mobile_apis::FunctionID::OnWayPointChangeID: { + return factory + .GetCreator(); + } default: {} } return factory.GetCreator(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/waypoints_pending_resumption_handler.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/waypoints_pending_resumption_handler.cc index 7aa6dd5273..5d44fe474e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/waypoints_pending_resumption_handler.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/waypoints_pending_resumption_handler.cc @@ -86,7 +86,7 @@ void WayPointsPendingResumptionHandler::HandleResumptionSubscriptionRequest( SDL_LOG_DEBUG( "Subscription to waypoint already exist, no need to send " "request to HMI"); - application_manager_.SubscribeAppForWayPoints(app.app_id()); + application_manager_.SubscribeAppForWayPoints(app.app_id(), false); return; } @@ -170,7 +170,7 @@ void WayPointsPendingResumptionHandler::on_event( if (resumption::IsResponseSuccessful(response)) { SDL_LOG_DEBUG("Resumption of waypoints is successful"); - application_manager_.SubscribeAppForWayPoints(app); + application_manager_.SubscribeAppForWayPoints(app, true); } ProcessNextPendingResumption(); } @@ -195,7 +195,7 @@ void WayPointsPendingResumptionHandler::ProcessNextPendingResumption() { auto pending_copy = pending; pending_requests_.pop_front(); auto app = application_manager_.application(pending_copy.app_id_); - application_manager_.SubscribeAppForWayPoints(app); + application_manager_.SubscribeAppForWayPoints(app, false); RaiseFakeSuccessfulResponse(pending_copy.corr_id_); ProcessNextPendingResumption(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc index ec401ae2a8..dc6f07f525 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc @@ -139,7 +139,6 @@ TEST_F(OnWayPointChangeNotificationTest, .WillOnce(Return(apps_subscribed_for_way_points)); EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(CheckMessageData(kApp1Id), _)); - EXPECT_CALL(app_mngr_, SaveWayPointsMessage(message_)); command_->Run(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_way_points_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_way_points_request_test.cc index 528f8a0700..44c5a7a3dd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_way_points_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_way_points_request_test.cc @@ -73,13 +73,12 @@ TEST_F(SubscribeWayPointsRequestTest, Run_SUCCESS) { ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); ON_CALL(app_mngr_, IsAppSubscribedForWayPoints(Ref(*app))) .WillByDefault(Return(false)); - ON_CALL(app_mngr_, IsAnyAppSubscribedForWayPoints()) - .WillByDefault(Return(true)); + ON_CALL(app_mngr_, IsSubscribedToHMIWayPoints()).WillByDefault(Return(true)); { InSequence dummy; EXPECT_CALL(app_mngr_, - SubscribeAppForWayPoints(A())); + SubscribeAppForWayPoints(A(), false)); EXPECT_CALL(*app, UpdateHash()); } @@ -112,7 +111,7 @@ TEST_F(SubscribeWayPointsRequestTest, OnEvent_SUCCESS) { { InSequence dummy; EXPECT_CALL(app_mngr_, - SubscribeAppForWayPoints(A())); + SubscribeAppForWayPoints(A(), true)); EXPECT_CALL(mock_message_helper_, HMIToMobileResult(result_code)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_way_points_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_way_points_request_test.cc index ec4d2420d6..9a6ff4d14e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_way_points_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_way_points_request_test.cc @@ -123,6 +123,8 @@ TEST_F(UnsubscribeWayPointsRequestTest, Run_AppSubscribedForWayPoints_SUCCESS) { EXPECT_CALL(app_mngr_, GetAppsSubscribedForWayPoints()) .WillOnce(Return(subscribed_apps)); + EXPECT_CALL(app_mngr_, IsSubscribedToHMIWayPoints()).WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand( HMIResultCodeIs( @@ -156,9 +158,10 @@ TEST_F(UnsubscribeWayPointsRequestTest, Event event(hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints); event.set_smart_object(*event_msg); - EXPECT_CALL(app_mngr_, - UnsubscribeAppFromWayPoints( - ::testing::Matcher(mock_app))); + EXPECT_CALL( + app_mngr_, + UnsubscribeAppFromWayPoints( + ::testing::Matcher(mock_app), true)); EXPECT_CALL( mock_rpc_service_, diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index 9b31d57ca0..4955c792c2 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -617,6 +617,25 @@ bool AppServiceManager::UpdateNavigationCapabilities( return true; } +AppService* AppServiceManager::FindWayPointsHandler() { + auto service = ActiveServiceForType( + EnumToString(mobile_apis::AppServiceType::NAVIGATION)); + if (!service || !service->mobile_service || + !service->record[strings::service_manifest].keyExists( + strings::handled_rpcs)) { + return nullptr; + } + + smart_objects::SmartObject& handled_rpcs = + service->record[strings::service_manifest][strings::handled_rpcs]; + for (size_t i = 0; i < handled_rpcs.length(); ++i) { + if (handled_rpcs[i].asInt() == mobile_apis::FunctionID::GetWayPointsID) { + return service; + } + } + return nullptr; +} + void AppServiceManager::AppServiceUpdated( const smart_objects::SmartObject& service_record, const mobile_apis::ServiceUpdateReason::eType update_reason, diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 94fd85d3d8..2418169ee0 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -162,6 +162,7 @@ ApplicationManagerImpl::ApplicationManagerImpl( std::make_shared()) , apps_to_register_list_lock_ptr_(std::make_shared()) , reregister_wait_list_lock_ptr_(std::make_shared()) + , subscribed_to_hmi_way_points_(false) , audio_pass_thru_active_(false) , audio_pass_thru_app_id_(0) , driver_distraction_state_(hmi_apis::Common_DriverDistractionState::DD_OFF) @@ -1720,11 +1721,11 @@ void ApplicationManagerImpl::SwitchApplication(ApplicationSharedPtr app, bool is_subscribed_to_way_points = IsAppSubscribedForWayPoints(*app); if (is_subscribed_to_way_points) { - UnsubscribeAppFromWayPoints(app); + UnsubscribeAppFromWayPoints(app, false); } SwitchApplicationParameters(app, connection_key, device_id, mac_address); if (is_subscribed_to_way_points) { - SubscribeAppForWayPoints(app); + SubscribeAppForWayPoints(app, false); } // Normally this is done during registration, however since switched apps are @@ -3250,7 +3251,7 @@ void ApplicationManagerImpl::UnregisterApplication( } if (IsAppSubscribedForWayPoints(app_id)) { - UnsubscribeAppFromWayPoints(app_id); + UnsubscribeAppFromWayPoints(app_id, true); if (!IsAnyAppSubscribedForWayPoints()) { SDL_LOG_DEBUG("Send UnsubscribeWayPoints"); auto request = MessageHelper::CreateUnsubscribeWayPointsRequest( @@ -4714,42 +4715,69 @@ bool ApplicationManagerImpl::IsAppSubscribedForWayPoints( return IsAppSubscribedForWayPoints(app.app_id()); } -void ApplicationManagerImpl::SubscribeAppForWayPoints(uint32_t app_id) { +void ApplicationManagerImpl::SubscribeAppForWayPoints(uint32_t app_id, + bool response_from_hmi) { SDL_LOG_AUTO_TRACE(); sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_); SDL_LOG_DEBUG("Subscribing " << app_id); subscribed_way_points_apps_list_.insert(app_id); + if (response_from_hmi) { + subscribed_to_hmi_way_points_ = true; + } SDL_LOG_DEBUG("There are applications subscribed: " << subscribed_way_points_apps_list_.size()); - if (way_points_data_) { - smart_objects::SmartObjectSPtr way_point_notification_ = - std::make_shared(*way_points_data_); - (*way_point_notification_)[strings::params][strings::connection_key] = + if (GetAppServiceManager().FindWayPointsHandler() != nullptr) { + auto service = GetAppServiceManager().ActiveServiceForType( + EnumToString(mobile_apis::AppServiceType::NAVIGATION)); + auto it = mobile_way_points_data_.find(service->connection_key); + if (mobile_way_points_data_.end() == it) { + SDL_LOG_DEBUG("No waypoint data provided by app service provider yet"); + return; + } + smart_objects::SmartObjectSPtr way_point_notification = + std::make_shared(it->second); + (*way_point_notification)[strings::params][strings::connection_key] = + app_id; + GetRPCService().SendMessageToMobile(way_point_notification); + } else if (hmi_way_points_data_) { + smart_objects::SmartObjectSPtr way_point_notification = + std::make_shared(*hmi_way_points_data_); + (*way_point_notification)[strings::params][strings::connection_key] = app_id; - GetRPCService().SendMessageToMobile(way_point_notification_); + GetRPCService().SendMessageToMobile(way_point_notification); } } -void ApplicationManagerImpl::SubscribeAppForWayPoints( - ApplicationSharedPtr app) { - SubscribeAppForWayPoints(app->app_id()); +void ApplicationManagerImpl::SubscribeAppForWayPoints(ApplicationSharedPtr app, + bool response_from_hmi) { + SubscribeAppForWayPoints(app->app_id(), response_from_hmi); } -void ApplicationManagerImpl::UnsubscribeAppFromWayPoints(uint32_t app_id) { +void ApplicationManagerImpl::UnsubscribeAppFromWayPoints( + uint32_t app_id, bool response_from_hmi) { SDL_LOG_AUTO_TRACE(); sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_); SDL_LOG_DEBUG("Unsubscribing " << app_id); subscribed_way_points_apps_list_.erase(app_id); + if (response_from_hmi) { + subscribed_to_hmi_way_points_ = false; + } SDL_LOG_DEBUG("There are applications subscribed: " << subscribed_way_points_apps_list_.size()); if (subscribed_way_points_apps_list_.empty()) { - way_points_data_.reset(); + hmi_way_points_data_.reset(); + mobile_way_points_data_.clear(); } } void ApplicationManagerImpl::UnsubscribeAppFromWayPoints( - ApplicationSharedPtr app) { - UnsubscribeAppFromWayPoints(app->app_id()); + ApplicationSharedPtr app, bool response_from_hmi) { + UnsubscribeAppFromWayPoints(app->app_id(), response_from_hmi); +} + +bool ApplicationManagerImpl::IsSubscribedToHMIWayPoints() const { + SDL_LOG_AUTO_TRACE(); + return subscribed_to_hmi_way_points_; } bool ApplicationManagerImpl::IsAnyAppSubscribedForWayPoints() const { @@ -4761,9 +4789,17 @@ bool ApplicationManagerImpl::IsAnyAppSubscribedForWayPoints() const { } void ApplicationManagerImpl::SaveWayPointsMessage( - std::shared_ptr way_points_message) { + std::shared_ptr way_points_message, + uint32_t app_id) { sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_); - way_points_data_ = way_points_message; + // Notification from HMI + if (0 == app_id) { + hmi_way_points_data_ = way_points_message; + } + // Notification from app service provider + else { + mobile_way_points_data_[app_id] = *way_points_message; + } } const std::set ApplicationManagerImpl::GetAppsSubscribedForWayPoints() diff --git a/src/components/application_manager/src/helpers/application_helper.cc b/src/components/application_manager/src/helpers/application_helper.cc index 488ee4aca0..c9a0d87aed 100644 --- a/src/components/application_manager/src/helpers/application_helper.cc +++ b/src/components/application_manager/src/helpers/application_helper.cc @@ -9,12 +9,16 @@ namespace { using namespace application_manager; void DeleteWayPoints(ApplicationSharedPtr app, ApplicationManager& app_manager) { - app_manager.UnsubscribeAppFromWayPoints(app); - if (!app_manager.IsAnyAppSubscribedForWayPoints()) { + std::set subscribed_apps = + app_manager.GetAppsSubscribedForWayPoints(); + bool send_unsubscribe = + subscribed_apps.size() <= 1 && app_manager.IsSubscribedToHMIWayPoints(); + if (send_unsubscribe) { auto request = MessageHelper::CreateUnsubscribeWayPointsRequest( app_manager.GetNextHMICorrelationID()); app_manager.GetRPCService().ManageHMICommand(request); } + app_manager.UnsubscribeAppFromWayPoints(app, send_unsubscribe); } void DeleteCommands(ApplicationSharedPtr app, ApplicationManager& app_manager) { diff --git a/src/components/application_manager/test/application_helper_test.cc b/src/components/application_manager/test/application_helper_test.cc index 4c451ab072..1633b9d29b 100644 --- a/src/components/application_manager/test/application_helper_test.cc +++ b/src/components/application_manager/test/application_helper_test.cc @@ -209,9 +209,6 @@ TEST_F(ApplicationHelperTest, RecallApplicationData_ExpectAppDataReset) { EXPECT_TRUE(NULL != file_ptr); EXPECT_TRUE(file_ptr->file_name == filename); - EXPECT_CALL(*mock_message_helper_, CreateUnsubscribeWayPointsRequest(_)) - .WillOnce(Return(std::make_shared())); - EXPECT_CALL(*mock_message_helper_, CreateDeleteUICommandRequest(_, _, _)) .WillOnce(Return(std::make_shared())); @@ -261,9 +258,6 @@ TEST_F(ApplicationHelperTest, RecallApplicationData_ExpectHMICleanupRequests) { app_impl_->AddChoiceSet(choice_set_id, cmd[strings::msg_params]); app_impl_->SubscribeToButton(mobile_apis::ButtonName::AC); - EXPECT_CALL(*mock_message_helper_, CreateUnsubscribeWayPointsRequest(_)) - .WillOnce(Return(std::make_shared())); - EXPECT_CALL(*mock_message_helper_, CreateDeleteUICommandRequest(_, _, _)) .WillOnce(Return(std::make_shared())); diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc index cf8aadb080..ab49e93e77 100644 --- a/src/components/application_manager/test/application_manager_impl_test.cc +++ b/src/components/application_manager/test/application_manager_impl_test.cc @@ -499,16 +499,16 @@ TEST_F(ApplicationManagerImplTest, ProcessQueryApp_ExpectSuccess) { TEST_F(ApplicationManagerImplTest, SubscribeAppForWayPoints_ExpectSubscriptionApp) { auto app_ptr = std::static_pointer_cast(mock_app_ptr_); - app_manager_impl_->SubscribeAppForWayPoints(app_ptr); + app_manager_impl_->SubscribeAppForWayPoints(app_ptr, true); EXPECT_TRUE(app_manager_impl_->IsAppSubscribedForWayPoints(*app_ptr)); } TEST_F(ApplicationManagerImplTest, - UnsubscribeAppForWayPoints_ExpectUnsubscriptionApp) { + UnsubscribeAppFromWayPoints_ExpectUnsubscriptionApp) { auto app_ptr = std::static_pointer_cast(mock_app_ptr_); - app_manager_impl_->SubscribeAppForWayPoints(app_ptr); + app_manager_impl_->SubscribeAppForWayPoints(app_ptr, true); EXPECT_TRUE(app_manager_impl_->IsAppSubscribedForWayPoints(*app_ptr)); - app_manager_impl_->UnsubscribeAppFromWayPoints(app_ptr); + app_manager_impl_->UnsubscribeAppFromWayPoints(app_ptr, true); EXPECT_FALSE(app_manager_impl_->IsAppSubscribedForWayPoints(*app_ptr)); const std::set result = app_manager_impl_->GetAppsSubscribedForWayPoints(); @@ -520,7 +520,7 @@ TEST_F( IsAnyAppSubscribedForWayPoints_SubcribeAppForWayPoints_ExpectCorrectResult) { EXPECT_FALSE(app_manager_impl_->IsAnyAppSubscribedForWayPoints()); auto app_ptr = std::static_pointer_cast(mock_app_ptr_); - app_manager_impl_->SubscribeAppForWayPoints(app_ptr); + app_manager_impl_->SubscribeAppForWayPoints(app_ptr, true); EXPECT_TRUE(app_manager_impl_->IsAnyAppSubscribedForWayPoints()); } @@ -528,7 +528,7 @@ TEST_F( ApplicationManagerImplTest, GetAppsSubscribedForWayPoints_SubcribeAppForWayPoints_ExpectCorrectResult) { auto app_ptr = std::static_pointer_cast(mock_app_ptr_); - app_manager_impl_->SubscribeAppForWayPoints(app_ptr); + app_manager_impl_->SubscribeAppForWayPoints(app_ptr, true); std::set result = app_manager_impl_->GetAppsSubscribedForWayPoints(); EXPECT_EQ(1u, result.size()); diff --git a/src/components/application_manager/test/resumption/resume_ctrl_test.cc b/src/components/application_manager/test/resumption/resume_ctrl_test.cc index 8d228240d2..a265b2b341 100644 --- a/src/components/application_manager/test/resumption/resume_ctrl_test.cc +++ b/src/components/application_manager/test/resumption/resume_ctrl_test.cc @@ -685,9 +685,9 @@ TEST_F(ResumeCtrlTest, extensions.insert(extensions.begin(), mock_app_extension_); EXPECT_CALL(*mock_app_, Extensions()).WillOnce(ReturnRef(extensions)); - EXPECT_CALL( - mock_app_mngr_, - SubscribeAppForWayPoints(A())); + EXPECT_CALL(mock_app_mngr_, + SubscribeAppForWayPoints( + A(), true)); const mobile_apis::HMILevel::eType hmi_test_level = mobile_apis::HMILevel::HMI_FULL; ON_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index 67f23956be..a0a19fc678 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -345,7 +345,7 @@ class ApplicationManager { /** * @brief Checks if Application is subscribed for way points - * @param Application id + * @param app_id Application id * @return true if Application is subscribed for way points * otherwise false */ @@ -353,7 +353,7 @@ class ApplicationManager { /** * @brief Checks if Application is subscribed for way points - * @param Application reference + * @param app Application reference * @return true if Application is subscribed for way points * otherwise false */ @@ -361,27 +361,45 @@ class ApplicationManager { /** * @brief Subscribe Application for way points - * @param Application id + * @param app_id Application id + * @param response_from_hmi True if a successful HMI response was received + * when subscribing */ - virtual void SubscribeAppForWayPoints(uint32_t id) = 0; + virtual void SubscribeAppForWayPoints(uint32_t app_id, + bool response_from_hmi = true) = 0; /** * @brief Subscribe Application for way points - * @param Application pointer + * @param app Application pointer + * @param response_from_hmi True if a successful HMI response was received + * when subscribing */ - virtual void SubscribeAppForWayPoints(ApplicationSharedPtr app) = 0; + virtual void SubscribeAppForWayPoints(ApplicationSharedPtr app, + bool response_from_hmi = true) = 0; /** * @brief Unsubscribe Application for way points - * @param Application id + * @param app_id Application id + * @param response_from_hmi True if a successful HMI response was received + * when unsubscribing */ - virtual void UnsubscribeAppFromWayPoints(uint32_t app_id) = 0; + virtual void UnsubscribeAppFromWayPoints(uint32_t app_id, + bool response_from_hmi = true) = 0; /** * @brief Unsubscribe Application for way points - * @param Application pointer + * @param app Application pointer + * @param response_from_hmi True if a successful HMI response was received + * when unsubscribing + */ + virtual void UnsubscribeAppFromWayPoints(ApplicationSharedPtr app, + bool response_from_hmi = true) = 0; + + /** + * @brief Is SDL Core subscribed to HMI waypoints + * @return true if SDL Core is subscribed to HMI waypoints, otherwise false */ - virtual void UnsubscribeAppFromWayPoints(ApplicationSharedPtr app) = 0; + virtual bool IsSubscribedToHMIWayPoints() const = 0; /** * @brief Is Any Application is subscribed for way points @@ -392,9 +410,12 @@ class ApplicationManager { /** * @brief Save message after OnWayPointsChangeNotification reception * @param way_points_message pointer to the smartobject + * @param app_id the app ID of the provider sending the way points update or 0 + * if the HMI is the provider */ virtual void SaveWayPointsMessage( - smart_objects::SmartObjectSPtr way_points_message) = 0; + smart_objects::SmartObjectSPtr way_points_message, + uint32_t app_id = 0) = 0; /** * @brief Get subscribed for way points 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 ee5d7f315a..eb76f44457 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -351,16 +351,17 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_CONST_METHOD1(IsAppSubscribedForWayPoints, bool(uint32_t)); MOCK_CONST_METHOD1(IsAppSubscribedForWayPoints, bool(application_manager::Application& app)); - MOCK_METHOD1(SubscribeAppForWayPoints, void(uint32_t)); - MOCK_METHOD1(SubscribeAppForWayPoints, - void(application_manager::ApplicationSharedPtr)); - MOCK_METHOD1(UnsubscribeAppFromWayPoints, void(uint32_t)); - MOCK_METHOD1(UnsubscribeAppFromWayPoints, - void(application_manager::ApplicationSharedPtr)); + MOCK_METHOD2(SubscribeAppForWayPoints, void(uint32_t, bool)); + MOCK_METHOD2(SubscribeAppForWayPoints, + void(application_manager::ApplicationSharedPtr, bool)); + MOCK_METHOD2(UnsubscribeAppFromWayPoints, void(uint32_t, bool)); + MOCK_METHOD2(UnsubscribeAppFromWayPoints, + void(application_manager::ApplicationSharedPtr, bool)); + MOCK_CONST_METHOD0(IsSubscribedToHMIWayPoints, bool()); MOCK_CONST_METHOD0(IsAnyAppSubscribedForWayPoints, bool()); MOCK_CONST_METHOD0(GetAppsSubscribedForWayPoints, const std::set()); - MOCK_METHOD1(SaveWayPointsMessage, - void(std::shared_ptr)); + MOCK_METHOD2(SaveWayPointsMessage, + void(std::shared_ptr, uint32_t)); MOCK_CONST_METHOD1( WaitingApplicationByID, application_manager::ApplicationConstSharedPtr(const uint32_t)); -- cgit v1.2.1 From 77120181e8ac427588734c9d798ce392b1c3c0bc Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 9 Dec 2020 14:45:40 -0500 Subject: Fix style --- .../src/commands/mobile/on_vehicle_data_notification.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc index cfa638de95..ef0f1614af 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc @@ -117,8 +117,7 @@ void OnVehicleDataNotification::Run() { parameters_permissions_.undefined_params.empty()) { SDL_LOG_DEBUG( "No parameter permissions provided, all params are allowed"); - } - else { + } else { for (const auto& param : appSO[idx].enumerate()) { const auto& allowed_params = params_permissions.allowed_params; auto param_allowed = allowed_params.find(param); -- cgit v1.2.1 From f5321f9ef8d91f012c324dcc6b08f9a23d2b4bfc Mon Sep 17 00:00:00 2001 From: JackLivio Date: Mon, 14 Dec 2020 16:13:15 -0500 Subject: Bind protocol version when app registers --- src/components/application_manager/src/application_manager_impl.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 2418169ee0..6418f47458 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -674,6 +674,8 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( static_cast( message[strings::params][strings::protocol_version].asInt()); application->set_protocol_version(protocol_version); + connection_handler_->BindProtocolVersionWithSession(connection_key, + protocol_version); // Keep HMI add id in case app is present in "waiting for registration" list apps_to_register_list_lock_ptr_->Acquire(); -- cgit v1.2.1 From dc867b0a5588decaf4a4f9ba6c8db720cc68aa73 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Mon, 14 Dec 2020 16:29:29 -0500 Subject: Fix unit tests in hmi_notifications_test --- .../rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt | 1 + .../test/commands/hmi/hmi_notifications_test.cc | 17 ++++++++++++++++- .../application_manager/mock_app_service_manager.h | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt index b21ab9dca8..b5bb139377 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt @@ -24,6 +24,7 @@ file(GLOB SOURCES set(LIBRARIES sdl_rpc_plugin_static + Resumption gmock ) 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 400481f506..5487da51a3 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 @@ -92,6 +92,7 @@ #include "utils/signals.h" #include "application_manager/hmi_capabilities_impl.h" +#include "application_manager/mock_app_service_manager.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" #include "application_manager/mock_event_dispatcher.h" @@ -106,6 +107,8 @@ #include "connection_handler/mock_connection_handler.h" #include "connection_handler/mock_connection_handler_settings.h" #include "protocol_handler/mock_session_observer.h" +#include "resumption/last_state_wrapper_impl.h" +#include "resumption/mock_last_state.h" #include "smart_objects/smart_object.h" #include "test/application_manager/mock_application_manager_settings.h" #include "transport_manager/mock_transport_manager.h" @@ -127,6 +130,7 @@ using ::test::components::application_manager_test::MockApplication; using ::test::components::application_manager_test::MockApplicationManager; using ::test::components::application_manager_test:: MockApplicationManagerSettings; +using ::test::components::application_manager_test::MockAppServiceManager; using ::test::components::event_engine_test::MockEventDispatcher; using ::testing::_; using ::testing::InSequence; @@ -216,7 +220,11 @@ class HMICommandsNotificationsTest HMICommandsNotificationsTest() : applications_lock_(std::make_shared()) , applications_(application_set_, applications_lock_) - , app_ptr_(NULL) {} + , app_ptr_(NULL) + , mock_last_state_(std::make_shared()) + , last_state_wrapper_(std::make_shared( + mock_last_state_)) + , mock_app_service_manager_(app_mngr_, last_state_wrapper_) {} ~HMICommandsNotificationsTest() { // Fix DataAccessor release and WinQt crash @@ -244,6 +252,9 @@ class HMICommandsNotificationsTest MockConnectionHandler mock_connection_handler_; MockSessionObserver mock_session_observer_; + std::shared_ptr mock_last_state_; + resumption::LastStateWrapperPtr last_state_wrapper_; + MockAppServiceManager mock_app_service_manager_; void InitCommand(const uint32_t& default_timeout) OVERRIDE { app_ = ConfigureApp(&app_ptr_, kAppId_, NOT_MEDIA, NOT_NAVI, NOT_VC); @@ -256,6 +267,8 @@ class HMICommandsNotificationsTest ON_CALL(app_mngr_, application_by_hmi_app(_)).WillByDefault(Return(app_)); ON_CALL(*app_ptr_, app_id()).WillByDefault(Return(kAppId_)); ON_CALL(app_mngr_, application(kConnectionKey)).WillByDefault(Return(app_)); + ON_CALL(app_mngr_, GetAppServiceManager()) + .WillByDefault(ReturnRef(mock_app_service_manager_)); ON_CALL(app_mngr_, connection_handler()) .WillByDefault(ReturnRef(mock_connection_handler_)); } @@ -428,6 +441,8 @@ TEST_F(HMICommandsNotificationsTest, MessageSharedPtr message = CreateMessage(); std::shared_ptr command = CreateCommand(message); + EXPECT_CALL(mock_app_service_manager_, FindWayPointsHandler()) + .WillOnce(Return(nullptr)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); command->Run(); diff --git a/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h b/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h index 60d2f90297..e3a47f412a 100644 --- a/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h +++ b/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h @@ -87,6 +87,7 @@ class MockAppServiceManager : public application_manager::AppServiceManager { const bool service_published)); MOCK_METHOD1(UpdateNavigationCapabilities, bool(smart_objects::SmartObject& out_params)); + MOCK_METHOD0(FindWayPointsHandler, application_manager::AppService*()); MOCK_METHOD0(GetRPCPassingHandler, application_manager::RPCPassingHandler&()); }; -- cgit v1.2.1