diff options
Diffstat (limited to 'src/components/application_manager/src/message_helper/message_helper.cc')
-rw-r--r-- | src/components/application_manager/src/message_helper/message_helper.cc | 113 |
1 files changed, 111 insertions, 2 deletions
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 e99db3bece..0e44a53c6f 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -176,6 +176,8 @@ std::pair<std::string, mobile_apis::VehicleDataType::VEHICLEDATA_FUELCONSUMPTION), std::make_pair(strings::fuel_range, mobile_apis::VehicleDataType::VEHICLEDATA_FUELRANGE), + std::make_pair(strings::cloud_app_vehicle_id, + mobile_apis::VehicleDataType::VEHICLEDATA_CLOUDAPPVEHICLEID), std::make_pair(strings::external_temp, mobile_apis::VehicleDataType::VEHICLEDATA_EXTERNTEMP), std::make_pair(strings::turn_signal, @@ -288,6 +290,17 @@ hmi_apis::Common_Language::eType MessageHelper::CommonLanguageFromString( return hmi_apis::Common_Language::INVALID_ENUM; } +hmi_apis::Common_LightName::eType MessageHelper::CommonLightNameFromString( + const std::string& lightName) { + using namespace ns_smart_device_link::ns_smart_objects; + hmi_apis::Common_LightName::eType value; + if (EnumConversionHelper<hmi_apis::Common_LightName::eType>::StringToEnum( + lightName, &value)) { + return value; + } + return hmi_apis::Common_LightName::INVALID_ENUM; +} + std::string MessageHelper::GetDeviceMacAddressForHandle( const transport_manager::DeviceHandle device_handle, const ApplicationManager& app_mngr) { @@ -325,6 +338,51 @@ 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<smart_objects::SmartObject>(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<smart_objects::SmartObject>(message); + app_mngr.GetRPCService().ManageHMICommand(hmi_notification); +} + +smart_objects::SmartObject MessageHelper::CreateAppServiceCapabilities( + std::vector<smart_objects::SmartObject>& all_services) { + smart_objects::SmartObject app_service_capabilities( + smart_objects::SmartType_Map); + smart_objects::SmartObject app_services(smart_objects::SmartType_Array); + + std::vector<smart_objects::SmartObject> service_records = all_services; + + int i = 0; + for (auto& record : service_records) { + smart_objects::SmartObject app_service_capability( + smart_objects::SmartType_Map); + app_service_capability[strings::updated_app_service_record] = record; + app_services[i] = app_service_capability; + i++; + } + + app_service_capabilities[strings::app_services] = app_services; + return app_service_capabilities; +} + smart_objects::SmartObjectSPtr MessageHelper::CreateHashUpdateNotification( const uint32_t app_id) { LOG4CXX_AUTO_TRACE(logger_); @@ -1540,15 +1598,20 @@ bool MessageHelper::CreateHMIApplicationStruct( message = smart_objects::SmartObject(smart_objects::SmartType_Map); message[strings::app_name] = app->name(); message[strings::app_id] = app->hmi_app_id(); + + const std::string policy_app_id = app->policy_app_id(); + message[hmi_response::policy_app_id] = policy_app_id; + const std::string icon_path = app->app_icon_path(); - if (!icon_path.empty()) { + + if (file_system::FileExists(app->app_icon_path())) { message[strings::icon] = icon_path; } if (app->IsRegistered()) { message[strings::hmi_display_language_desired] = app->ui_language(); message[strings::is_media_application] = app->is_media_application(); } else { - message[strings::greyOut] = app->is_greyed_out(); + message[strings::grey_out] = app->is_greyed_out(); } if (app->tts_name() && !app->tts_name()->empty()) { message[json::ttsName] = *(app->tts_name()); @@ -1564,6 +1627,46 @@ bool MessageHelper::CreateHMIApplicationStruct( message[strings::app_type] = *app_types; } + const policy::RequestType::State app_request_types_state = + policy_handler.GetAppRequestTypeState(policy_app_id); + if (policy::RequestType::State::AVAILABLE == app_request_types_state) { + const auto request_types = policy_handler.GetAppRequestTypes(policy_app_id); + message[strings::request_type] = + SmartObject(smart_objects::SmartType_Array); + smart_objects::SmartObject& request_types_array = + message[strings::request_type]; + + size_t index = 0; + for (auto it : request_types) { + request_types_array[index] = it; + ++index; + } + } else if (policy::RequestType::State::EMPTY == app_request_types_state) { + message[strings::request_type] = + SmartObject(smart_objects::SmartType_Array); + } + + const policy::RequestSubType::State app_request_subtypes_state = + policy_handler.GetAppRequestSubTypeState(policy_app_id); + if (policy::RequestSubType::State::AVAILABLE == app_request_subtypes_state) { + const auto request_subtypes = + policy_handler.GetAppRequestSubTypes(policy_app_id); + message[strings::request_subtype] = + SmartObject(smart_objects::SmartType_Array); + smart_objects::SmartObject& request_subtypes_array = + message[strings::request_subtype]; + + size_t index = 0; + for (auto it : request_subtypes) { + request_subtypes_array[index] = it; + ++index; + } + } else if (policy::RequestSubType::State::EMPTY == + app_request_subtypes_state) { + message[strings::request_subtype] = + SmartObject(smart_objects::SmartType_Array); + } + if (day_color_scheme) { message[strings::day_color_scheme] = *day_color_scheme; } @@ -1590,6 +1693,12 @@ bool MessageHelper::CreateHMIApplicationStruct( &secondary_device_info); } + message[strings::is_cloud_application] = app->is_cloud_app(); + if (app->is_cloud_app()) { + message[strings::cloud_connection_status] = + app_mngr.GetCloudAppConnectionStatus(app); + } + return true; } |