From 97806312bc0df88d74fadc0c9c620599545b0887 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 26 Feb 2019 15:45:55 -0500 Subject: Add capability updates for NAVIGATION service type Also revise name of `timeStamp` parameter in NavigationServiceData --- .../application_manager/app_service_manager.h | 23 +++--- .../include/application_manager/message_helper.h | 3 + .../application_manager/smart_object_keys.h | 2 + ...on_bc_system_capability_updated_notification.cc | 20 ++++- .../mobile/get_system_capability_request.cc | 14 +++- .../on_system_capability_updated_notification.cc | 20 ++++- .../application_manager/src/app_service_manager.cc | 85 +++++++++++++++------- .../src/message_helper/message_helper.cc | 24 ++++++ .../application_manager/src/smart_object_keys.cc | 2 + .../application_manager/mock_message_helper.h | 3 + .../test/mock_message_helper.cc | 6 ++ src/components/interfaces/HMI_API.xml | 2 +- src/components/interfaces/MOBILE_API.xml | 2 +- 13 files changed, 164 insertions(+), 42 deletions(-) (limited to 'src') 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 253ed2a439..8510c78fee 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 @@ -92,14 +92,6 @@ class AppServiceManager { */ void UnpublishServices(const uint32_t connection_key); - /** - * @brief TODO - * @param service_id - * @param service_published - */ - void SetServicePublished(const std::string service_id, - bool service_published); - /** * @brief TODO * @param service_id @@ -140,12 +132,25 @@ class AppServiceManager { std::string DefaultServiceByType(std::string service_type); + /** + * @brief TODO + * @param service_id + * @param service_published + */ + void SetServicePublished(const std::string service_id, + bool service_published); + + /** + * @brief TODO + * @param out_params + */ + bool UpdateNavigationCapabilities(smart_objects::SmartObject& out_params); + private: ApplicationManager& app_manager_; resumption::LastState& last_state_; std::map published_services_; - void BroadcastAppServiceUpdate(smart_objects::SmartObject& msg_params); void AppServiceUpdated( const smart_objects::SmartObject& service_record, const mobile_apis::ServiceUpdateReason::eType update_reason, diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index fd16d57740..8a8e50bf1c 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -881,6 +881,9 @@ class MessageHelper { static smart_objects::SmartObject CreateAppServiceCapabilities( std::vector& all_services); + static void BroadcastCapabilityUpdate(smart_objects::SmartObject& msg_params, + ApplicationManager& app_mngr); + private: /** * @brief Allows to fill SO according to the current permissions. diff --git a/src/components/application_manager/include/application_manager/smart_object_keys.h b/src/components/application_manager/include/application_manager/smart_object_keys.h index 615b8ab767..f67d5ff121 100644 --- a/src/components/application_manager/include/application_manager/smart_object_keys.h +++ b/src/components/application_manager/include/application_manager/smart_object_keys.h @@ -391,6 +391,8 @@ extern const char* const keyboard_layout_supported; extern const char* const keypress_mode_supported; extern const char* const limited_characters_list_supported; extern const char* const auto_complete_text_supported; +extern const char* const send_location_enabled; +extern const char* const get_way_points_enabled; extern const char* const entity_type; extern const char* const entity_id; extern const char* const status; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc index d0c33e76d9..73ec1137a8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc @@ -70,9 +70,21 @@ void OnBCSystemCapabilityUpdatedNotification::Run() { [strings::system_capability_type].asInt()); switch (system_capability_type) { case hmi_apis::Common_SystemCapabilityType::NAVIGATION: { + smart_objects::SmartObject nav_capability(smart_objects::SmartType_Map); + bool has_nav_capability = false; if (hmi_capabilities_.navigation_capability()) { + has_nav_capability = true; + nav_capability = *hmi_capabilities_.navigation_capability(); + } + has_nav_capability = application_manager_.GetAppServiceManager() + .UpdateNavigationCapabilities(nav_capability) || + has_nav_capability; + + if (has_nav_capability) { msg_params[strings::system_capability][strings::navigation_capability] = - *hmi_capabilities_.navigation_capability(); + nav_capability; + } else { + return; } break; } @@ -80,6 +92,8 @@ void OnBCSystemCapabilityUpdatedNotification::Run() { if (hmi_capabilities_.phone_capability()) { msg_params[strings::system_capability][strings::phone_capability] = *hmi_capabilities_.phone_capability(); + } else { + return; } break; } @@ -90,6 +104,8 @@ void OnBCSystemCapabilityUpdatedNotification::Run() { if (hmi_capabilities_.rc_capability()) { msg_params[strings::system_capability][strings::rc_capability] = *hmi_capabilities_.rc_capability(); + } else { + return; } break; } @@ -98,6 +114,8 @@ void OnBCSystemCapabilityUpdatedNotification::Run() { msg_params[strings::system_capability] [strings::video_streaming_capability] = *hmi_capabilities_.video_streaming_capability(); + } else { + return; } break; case hmi_apis::Common_SystemCapabilityType::APP_SERVICES: { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc index b551db0008..63a4416139 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc @@ -83,10 +83,20 @@ void GetSystemCapabilityRequest::Run() { switch (response_type) { case mobile_apis::SystemCapabilityType::NAVIGATION: { + smart_objects::SmartObject nav_capability(smart_objects::SmartType_Map); + bool has_nav_capability = false; if (hmi_capabilities.navigation_capability()) { + has_nav_capability = true; + auto nav_capability = *hmi_capabilities.navigation_capability(); + } + + has_nav_capability = application_manager_.GetAppServiceManager() + .UpdateNavigationCapabilities(nav_capability) || + has_nav_capability; + + if (has_nav_capability) { response_params[strings::system_capability] - [strings::navigation_capability] = - *hmi_capabilities.navigation_capability(); + [strings::navigation_capability] = nav_capability; } else { SendResponse(false, mobile_apis::Result::DATA_NOT_AVAILABLE); return; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc index 0745bc08dc..b5e3a73ee4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc @@ -36,9 +36,21 @@ void OnSystemCapabilityUpdatedNotification::Run() { switch (system_capability_type) { case mobile_apis::SystemCapabilityType::NAVIGATION: { + smart_objects::SmartObject nav_capability(smart_objects::SmartType_Map); + bool has_nav_capability = false; if (hmi_capabilities_.navigation_capability()) { + has_nav_capability = true; + nav_capability = *hmi_capabilities_.navigation_capability(); + } + has_nav_capability = application_manager_.GetAppServiceManager() + .UpdateNavigationCapabilities(nav_capability) || + has_nav_capability; + + if (has_nav_capability) { msg_params[strings::system_capability][strings::navigation_capability] = - *hmi_capabilities_.navigation_capability(); + nav_capability; + } else { + return; } break; } @@ -46,6 +58,8 @@ void OnSystemCapabilityUpdatedNotification::Run() { if (hmi_capabilities_.phone_capability()) { msg_params[strings::system_capability][strings::phone_capability] = *hmi_capabilities_.phone_capability(); + } else { + return; } break; } @@ -56,6 +70,8 @@ void OnSystemCapabilityUpdatedNotification::Run() { if (hmi_capabilities_.rc_capability()) { msg_params[strings::system_capability][strings::rc_capability] = *hmi_capabilities_.rc_capability(); + } else { + return; } break; } @@ -64,6 +80,8 @@ void OnSystemCapabilityUpdatedNotification::Run() { msg_params[strings::system_capability] [strings::video_streaming_capability] = *hmi_capabilities_.video_streaming_capability(); + } else { + return; } break; case mobile_apis::SystemCapabilityType::APP_SERVICES: { diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index bc9d363839..e2a9f41deb 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -37,13 +37,13 @@ #include "application_manager/app_service_manager.h" #include "application_manager/application.h" -#include "application_manager/app_service_manager.h" #include "application_manager/application_manager.h" #include "application_manager/commands/command_impl.h" #include "application_manager/message_helper.h" #include "application_manager/smart_object_keys.h" #include "encryption/hashing.h" #include "resumption/last_state.h" +#include "smart_objects/enum_schema_item.h" #include "utils/logger.h" CREATE_LOGGERPTR_GLOBAL(logger_, "AppServiceManager") @@ -96,9 +96,12 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( std::pair(service_id, app_service)); smart_objects::SmartObject msg_params; + msg_params[strings::system_capability][strings::system_capability_type] = + mobile_apis::SystemCapabilityType::APP_SERVICES; AppServiceUpdated( service_record, mobile_apis::ServiceUpdateReason::PUBLISHED, msg_params); - BroadcastAppServiceUpdate(msg_params); + + MessageHelper::BroadcastCapabilityUpdate(msg_params, app_manager_); // Activate the new service if it is the default for its service type, or if // no service is active of its service type @@ -123,6 +126,8 @@ bool AppServiceManager::UnpublishAppService(const std::string service_id) { SetServicePublished(service_id, false); smart_objects::SmartObject msg_params; + msg_params[strings::system_capability][strings::system_capability_type] = + mobile_apis::SystemCapabilityType::APP_SERVICES; auto record = it->second.record; if (record[strings::service_active].asBool()) { @@ -140,7 +145,7 @@ bool AppServiceManager::UnpublishAppService(const std::string service_id) { } AppServiceUpdated( it->second.record, mobile_apis::ServiceUpdateReason::REMOVED, msg_params); - BroadcastAppServiceUpdate(msg_params); + MessageHelper::BroadcastCapabilityUpdate(msg_params, app_manager_); published_services_.erase(it); return true; @@ -244,6 +249,8 @@ bool AppServiceManager::ActivateAppService(const std::string service_id) { } smart_objects::SmartObject msg_params; + msg_params[strings::system_capability][strings::system_capability_type] = + mobile_apis::SystemCapabilityType::APP_SERVICES; const std::string service_type = service[strings::service_manifest][strings::service_type].asString(); @@ -258,7 +265,18 @@ bool AppServiceManager::ActivateAppService(const std::string service_id) { AppServiceUpdated( service, mobile_apis::ServiceUpdateReason::ACTIVATED, msg_params); - BroadcastAppServiceUpdate(msg_params); + MessageHelper::BroadcastCapabilityUpdate(msg_params, app_manager_); + + std::string navi_service_type; + ns_smart_device_link::ns_smart_objects:: + EnumConversionHelper::EnumToString( + mobile_apis::AppServiceType::NAVIGATION, &navi_service_type); + if (service_type == navi_service_type) { + smart_objects::SmartObject msg_params; + msg_params[strings::system_capability][strings::system_capability_type] = + mobile_apis::SystemCapabilityType::NAVIGATION; + MessageHelper::BroadcastCapabilityUpdate(msg_params, app_manager_); + } return true; } @@ -292,7 +310,9 @@ bool AppServiceManager::DeactivateAppService(const std::string service_id) { } if (send_update) { - BroadcastAppServiceUpdate(msg_params); + msg_params[strings::system_capability][strings::system_capability_type] = + mobile_apis::SystemCapabilityType::APP_SERVICES; + MessageHelper::BroadcastCapabilityUpdate(msg_params, app_manager_); } return true; } @@ -362,30 +382,41 @@ void AppServiceManager::SetServicePublished(const std::string service_id, it->second.record[strings::service_published] = service_published; } -void AppServiceManager::BroadcastAppServiceUpdate( - smart_objects::SmartObject& msg_params) { +bool AppServiceManager::UpdateNavigationCapabilities( + smart_objects::SmartObject& out_params) { LOG4CXX_AUTO_TRACE(logger_); - smart_objects::SmartObject message(smart_objects::SmartType_Map); + std::string navi_service_type; + ns_smart_device_link::ns_smart_objects:: + EnumConversionHelper::EnumToString( + mobile_apis::AppServiceType::NAVIGATION, &navi_service_type); + auto service = ActiveServiceByType(navi_service_type); + if (service.first.empty()) { + return false; + } - msg_params[strings::system_capability][strings::system_capability_type] = - mobile_apis::SystemCapabilityType::APP_SERVICES; - message[strings::params][strings::message_type] = MessageType::kNotification; - message[strings::msg_params] = msg_params; - - // Construct and send mobile notification - message[strings::params][strings::function_id] = - mobile_apis::FunctionID::OnSystemCapabilityUpdatedID; - smart_objects::SmartObjectSPtr notification = - std::make_shared(message); - app_manager_.GetRPCService().ManageMobileCommand( - notification, commands::Command::CommandSource::SOURCE_SDL); - - // Construct and send HMI notification - message[strings::params][strings::function_id] = - hmi_apis::FunctionID::BasicCommunication_OnSystemCapabilityUpdated; - smart_objects::SmartObjectSPtr hmi_notification = - std::make_shared(message); - app_manager_.GetRPCService().ManageHMICommand(hmi_notification); + if (!out_params.keyExists(strings::send_location_enabled)) { + out_params[strings::send_location_enabled] = false; + } + if (!out_params.keyExists(strings::get_way_points_enabled)) { + out_params[strings::get_way_points_enabled] = false; + } + + if (!service.second.record[strings::service_manifest].keyExists( + strings::handled_rpcs)) { + return true; + } + + smart_objects::SmartObject& handled_rpcs = + service.second.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::SendLocationID) { + out_params[strings::send_location_enabled] = true; + } else if (handled_rpcs[i].asInt() == + mobile_apis::FunctionID::GetWayPointsID) { + out_params[strings::get_way_points_enabled] = true; + } + } + return true; } void AppServiceManager::AppServiceUpdated( diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 124ec80312..7db2308c2c 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -327,6 +327,30 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateMessageForHMI( return message; } +void MessageHelper::BroadcastCapabilityUpdate( + smart_objects::SmartObject& msg_params, ApplicationManager& app_mngr) { + LOG4CXX_AUTO_TRACE(logger_); + smart_objects::SmartObject message(smart_objects::SmartType_Map); + + message[strings::params][strings::message_type] = MessageType::kNotification; + message[strings::msg_params] = msg_params; + + // Construct and send mobile notification + message[strings::params][strings::function_id] = + mobile_apis::FunctionID::OnSystemCapabilityUpdatedID; + smart_objects::SmartObjectSPtr notification = + std::make_shared(message); + app_mngr.GetRPCService().ManageMobileCommand( + notification, commands::Command::CommandSource::SOURCE_SDL); + + // Construct and send HMI notification + message[strings::params][strings::function_id] = + hmi_apis::FunctionID::BasicCommunication_OnSystemCapabilityUpdated; + smart_objects::SmartObjectSPtr hmi_notification = + std::make_shared(message); + app_mngr.GetRPCService().ManageHMICommand(hmi_notification); +} + smart_objects::SmartObject MessageHelper::CreateAppServiceCapabilities( std::vector& all_services) { smart_objects::SmartObject app_service_capabilities( diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 59499818d3..e07f9732e4 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -351,6 +351,8 @@ const char* const keypress_mode_supported = "keypressModeSupported"; const char* const limited_characters_list_supported = "limitedCharactersListSupported"; const char* const auto_complete_text_supported = "autoCompleteTextSupported"; +const char* const send_location_enabled = "sendLocationEnabled"; +const char* const get_way_points_enabled = "getWayPointsEnabled"; const char* const entity_type = "entityType"; const char* const entity_id = "entityID"; const char* const status = "status"; diff --git a/src/components/application_manager/test/include/application_manager/mock_message_helper.h b/src/components/application_manager/test/include/application_manager/mock_message_helper.h index 8d9cf9d7ef..7889774fae 100644 --- a/src/components/application_manager/test/include/application_manager/mock_message_helper.h +++ b/src/components/application_manager/test/include/application_manager/mock_message_helper.h @@ -311,6 +311,9 @@ class MockMessageHelper { MOCK_METHOD1(CreateAppServiceCapabilities, smart_objects::SmartObject( std::vector& all_services)); + MOCK_METHOD2(BroadcastCapabilityUpdate, + void(smart_objects::SmartObject& msg_params, + ApplicationManager& app_mngr)); static MockMessageHelper* message_helper_mock(); }; diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc index 0fe82e0dfb..b3b3327ca9 100644 --- a/src/components/application_manager/test/mock_message_helper.cc +++ b/src/components/application_manager/test/mock_message_helper.cc @@ -577,4 +577,10 @@ smart_objects::SmartObject MessageHelper::CreateAppServiceCapabilities( return MockMessageHelper::message_helper_mock()->CreateAppServiceCapabilities( all_services); } + +void MessageHelper::BroadcastCapabilityUpdate( + smart_objects::SmartObject& msg_params, ApplicationManager& app_mngr) { + MockMessageHelper::message_helper_mock()->BroadcastCapabilityUpdate( + msg_params, app_mngr); +} } // namespace application_manager diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 1976f7c742..2f299d4026 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -3636,7 +3636,7 @@ This data is related to what a navigation service would provide. - + This is the timestamp of when the data was generated. This is to ensure any time or distance given in the data can accurately be adjusted if necessary. diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 8a3766c5fa..a516e03542 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -3968,7 +3968,7 @@ This data is related to what a navigation service would provide. - + This is the timestamp of when the data was generated. This is to ensure any time or distance given in the data can accurately be adjusted if necessary. -- cgit v1.2.1