diff options
Diffstat (limited to 'src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile')
10 files changed, 180 insertions, 101 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc index 98e26e1aa9..70f462c05d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc @@ -156,6 +156,11 @@ void CreateInteractionChoiceSetRequest::Run() { // we have VR commands SendVRAddCommandRequests(app); } else { + if (MessageHelper::ChoiceSetVRCommandsStatus::NONE == vr_status) { + // Because on_event will not be called for this choice, we set is allowed + // right after added. + app->set_choice_set_allow_mode(choice_set_id_, true); + } // we have none, just return with success SendResponse(true, Result::SUCCESS); } @@ -462,6 +467,14 @@ void CreateInteractionChoiceSetRequest::DeleteChoices() { void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() { SDL_LOG_AUTO_TRACE(); + ApplicationSharedPtr application = + application_manager_.application(connection_key()); + if (!error_from_hmi_) { + application->set_choice_set_allow_mode(choice_set_id_, true); + SDL_LOG_DEBUG("Choice set with id " << choice_set_id_ + << " is allowed to perform."); + } + if (!error_from_hmi_ && should_send_warnings_) { SendResponse(true, mobile_apis::Result::WARNINGS, kInvalidImageWarningInfo); } else if (!error_from_hmi_) { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc index eac43bb22b..dccf2e9fdd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc @@ -173,6 +173,7 @@ void DeleteInteractionChoiceSetRequest::SendVrDeleteCommand( return; } + app->set_choice_set_allow_mode(choice_set_id, false); smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); msg_params[strings::app_id] = app->app_id(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc index a690c0bc9b..dc46bd7f7c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc @@ -175,6 +175,7 @@ void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) { hmi_apis::Common_Result::WRONG_LANGUAGE, hmi_apis::Common_Result::RETRY, hmi_apis::Common_Result::SAVED, + hmi_apis::Common_Result::TRUNCATED_DATA, hmi_apis::Common_Result::UNSUPPORTED_RESOURCE); if (is_tts_speak_success_unsuported) { @@ -198,7 +199,7 @@ void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) { return; } - const ResponseParams response_params = PrepareResponseParameters(); + ResponseParams response_params = PrepareResponseParameters(); SendResponse( response_params.success, @@ -220,7 +221,9 @@ PerformAudioPassThruRequest::PrepareResponseParameters() { response_params_.success = PrepareResultForMobileResponse(ui_perform_info, tts_perform_info); - if (ui_perform_info.is_ok && tts_perform_info.is_unsupported_resource && + + if ((ui_perform_info.result_code == hmi_apis::Common_Result::SUCCESS) && + ui_perform_info.is_ok && tts_perform_info.is_unsupported_resource && HmiInterfaces::STATE_AVAILABLE == tts_perform_info.interface_state) { response_params_.result_code = mobile_apis::Result::WARNINGS; response_params_.info = app_mngr::commands::MergeInfos( @@ -231,12 +234,13 @@ PerformAudioPassThruRequest::PrepareResponseParameters() { if (IsResultCodeUnsupported(ui_perform_info, tts_perform_info)) { response_params_.result_code = mobile_apis::Result::UNSUPPORTED_RESOURCE; - } else { - AudioPassThruResults results = PrepareAudioPassThruResultCodeForResponse( - ui_perform_info, tts_perform_info); - response_params_.success = results.second; - response_params_.result_code = results.first; } + + AudioPassThruResults results = PrepareAudioPassThruResultCodeForResponse( + ui_perform_info, tts_perform_info); + response_params_.success = results.second; + response_params_.result_code = results.first; + response_params_.info = app_mngr::commands::MergeInfos( ui_perform_info, ui_info_, tts_perform_info, tts_info_); @@ -407,23 +411,19 @@ PerformAudioPassThruRequest::PrepareAudioPassThruResultCodeForResponse( const hmi_apis::Common_Result::eType tts_result = tts_response.result_code; bool result = false; - if ((ui_result == hmi_apis::Common_Result::SUCCESS) && - (tts_result == hmi_apis::Common_Result::SUCCESS)) { - result = true; - } - - if ((ui_result == hmi_apis::Common_Result::SUCCESS) && - (tts_result == hmi_apis::Common_Result::INVALID_ENUM)) { + if ((application_manager::commands::IsHMIResultSuccess(ui_result) || + (ui_result == hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)) && + (application_manager::commands::IsHMIResultSuccess(tts_result) || + (tts_result == hmi_apis::Common_Result::UNSUPPORTED_RESOURCE) || + (tts_result == hmi_apis::Common_Result::INVALID_ENUM))) { result = true; } if ((ui_result == hmi_apis::Common_Result::SUCCESS) && - (tts_result != hmi_apis::Common_Result::SUCCESS) && - (tts_result != hmi_apis::Common_Result::INVALID_ENUM)) { - common_result = hmi_apis::Common_Result::WARNINGS; - result = true; - } else if (ui_response.is_ok && - tts_result == hmi_apis::Common_Result::WARNINGS) { + (((tts_result != hmi_apis::Common_Result::SUCCESS) && + (tts_result != hmi_apis::Common_Result::INVALID_ENUM)) || + (ui_response.is_ok && + tts_result == hmi_apis::Common_Result::WARNINGS))) { common_result = hmi_apis::Common_Result::WARNINGS; result = true; } else if (ui_result == hmi_apis::Common_Result::INVALID_ENUM) { @@ -431,6 +431,7 @@ PerformAudioPassThruRequest::PrepareAudioPassThruResultCodeForResponse( } else { common_result = ui_result; } + result_code = MessageHelper::HMIToMobileResult(common_result); return std::make_pair(result_code, result); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc index bf0f05ba32..a11f123337 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc @@ -173,6 +173,27 @@ void PerformInteractionRequest::Run() { return; } + auto choice_sets_are_disallowed_to_perform = + [](ApplicationSharedPtr app, + const smart_objects::SmartObject& choice_set_id_list) { + auto choice_set_id_array = choice_set_id_list.asArray(); + + return std::any_of( + choice_set_id_array->begin(), + choice_set_id_array->end(), + [app](smart_objects::SmartObject& choice_set_id) { + return !app->is_choice_set_allowed(choice_set_id.asInt()); + }); + }; + + if (choice_sets_are_disallowed_to_perform( + app, msg_params[strings::interaction_choice_set_id_list])) { + const std::string message = "One of choice sets is not available yet"; + SDL_LOG_WARN(message); + SendResponse(false, mobile_apis::Result::REJECTED, message.c_str()); + return; + } + if (msg_params.keyExists(strings::vr_help)) { if (mobile_apis::Result::INVALID_DATA == MessageHelper::VerifyImageVrHelpItems( @@ -225,6 +246,8 @@ void PerformInteractionRequest::Run() { // increment amount of active requests ++pi_requests_count_; + SDL_LOG_DEBUG("Send PerformInteraction requests"); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); @@ -348,16 +371,10 @@ bool PerformInteractionRequest::ProcessVRResponse( SDL_LOG_DEBUG("Update timeout for UI"); application_manager_.UpdateRequestTimeout( - connection_key(), correlation_id(), default_timeout_); return false; } - if (IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_UI) && - InteractionMode::MANUAL_ONLY != interaction_mode_) { - SendClosePopupRequestToHMI(); - } - const SmartObject& hmi_msg_params = message[strings::msg_params]; if (hmi_msg_params.keyExists(strings::choice_id)) { const int choice_id = hmi_msg_params[strings::choice_id].asInt(); @@ -371,6 +388,26 @@ bool PerformInteractionRequest::ProcessVRResponse( vr_choice_id_received_ = choice_id; } + const bool is_vr_result_successful = CommandImpl::IsHMIResultSuccess( + vr_result_code_, HmiInterfaces::HMI_INTERFACE_VR); + + if (IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_UI) && + is_vr_result_successful) { + switch (interaction_mode_) { + case mobile_apis::InteractionMode::BOTH: + // Close UI popup only if choice ID was included in VR + if (vr_choice_id_received_ != INVALID_CHOICE_ID) { + SendClosePopupRequestToHMI(); + } + break; + case mobile_apis::InteractionMode::VR_ONLY: + SendClosePopupRequestToHMI(); + break; + default: + break; + } + } + if (mobile_apis::InteractionMode::BOTH == interaction_mode_ || mobile_apis::InteractionMode::MANUAL_ONLY == interaction_mode_) { SDL_LOG_DEBUG("Update timeout for UI"); @@ -378,17 +415,6 @@ bool PerformInteractionRequest::ProcessVRResponse( connection_key(), correlation_id(), default_timeout_); } - const bool is_vr_result_success = Compare<Common_Result::eType, EQ, ONE>( - vr_result_code_, Common_Result::SUCCESS, Common_Result::WARNINGS); - - if (is_vr_result_success && - InteractionMode::MANUAL_ONLY == interaction_mode_) { - SDL_LOG_DEBUG("VR response is successfull in MANUAL_ONLY mode " - << "Wait for UI response"); - // in case MANUAL_ONLY mode VR.PI SUCCESS just return - return false; - } - return false; } @@ -880,7 +906,10 @@ bool PerformInteractionRequest::IsWhiteSpaceExist() { void PerformInteractionRequest::TerminatePerformInteraction() { SDL_LOG_AUTO_TRACE(); - SendClosePopupRequestToHMI(); + if (IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_UI)) { + SendClosePopupRequestToHMI(); + } + DisablePerformInteraction(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc index 9a9aa0c533..519d70e1d8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc @@ -274,6 +274,11 @@ bool RegisterAppInterfaceRequest::ApplicationDataShouldBeResumed( const uint32_t key = connection_key(); ApplicationSharedPtr application = application_manager_.application(key); + if (!application) { + SDL_LOG_DEBUG("Application not found, no resumption required"); + return false; + } + const bool hash_id_present = msg_params.keyExists(strings::hash_id); const std::string hash_id = msg_params[strings::hash_id].asString(); const bool resumption = hash_id_present && !hash_id.empty(); @@ -348,9 +353,8 @@ policy::StatusNotifier RegisterAppInterfaceRequest::AddApplicationDataToPolicy( application->mac_address(), application->policy_app_id(), hmi_types); } -void RegisterAppInterfaceRequest::CheckLanguage() { - ApplicationSharedPtr application = - application_manager_.application(connection_key()); +void RegisterAppInterfaceRequest::CheckLanguage( + ApplicationSharedPtr application) { DCHECK_OR_RETURN_VOID(application); const auto& msg_params = (*message_)[strings::msg_params]; if (msg_params[strings::language_desired].asInt() != @@ -430,6 +434,9 @@ void FinishSendingResponseToMobile(const smart_objects::SmartObject& msg_params, policy::StatusNotifier notify_upd_manager) { resumption::ResumeCtrl& resume_ctrl = app_manager.resume_controller(); auto application = app_manager.application(connection_key); + if (!application) { + return; + } policy::PolicyHandlerInterface& policy_handler = app_manager.GetPolicyHandler(); @@ -440,8 +447,6 @@ void FinishSendingResponseToMobile(const smart_objects::SmartObject& msg_params, &(msg_params[strings::app_hmi_type])); } - application->MarkRegistered(); - // Default HMI level should be set before any permissions validation, since // it relies on HMI level. app_manager.OnApplicationRegistered(application); @@ -733,7 +738,8 @@ void RegisterAppInterfaceRequest::Run() { return; } - CheckLanguage(); + CheckLanguage(application); + SendRegisterAppInterfaceResponseToMobile( ApplicationType::kNewApplication, status_notifier, add_info); } @@ -875,6 +881,11 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( const uint32_t key = connection_key(); ApplicationSharedPtr application = application_manager_.application(key); + + if (!application) { + return; + } + utils::SemanticVersion negotiated_version = application->msg_version(); response_params[strings::sync_msg_version][strings::major_version] = diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc index 0c74105e56..6e751a9b91 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc @@ -96,7 +96,7 @@ void RegisterAppInterfaceResponse::Run() { } SendResponse(success, result_code, last_message); - if (success) { + if (app && success) { app->set_is_ready(true); } event_engine::MobileEvent event( diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_request.cc index ba0a20b459..98f2a2a247 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_request.cc @@ -53,7 +53,9 @@ SetDisplayLayoutRequest::SetDisplayLayoutRequest( application_manager, rpc_service, hmi_capabilities, - policy_handler) {} + policy_handler) { + subscribe_on_event(hmi_apis::FunctionID::UI_Show); +} SetDisplayLayoutRequest::~SetDisplayLayoutRequest() {} @@ -73,8 +75,14 @@ void SetDisplayLayoutRequest::Run() { std::string old_layout = app->display_layout(); std::string new_layout = ""; + smart_objects::SmartObject show_msg_params(smart_objects::SmartType_Map); + show_msg_params[hmi_request::show_strings] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + if (msg_params.keyExists(strings::display_layout)) { new_layout = msg_params[strings::display_layout].asString(); + show_msg_params[strings::template_configuration][strings::template_layout] = + new_layout; } if (new_layout != old_layout && !new_layout.empty()) { @@ -109,18 +117,22 @@ void SetDisplayLayoutRequest::Run() { if (msg_params.keyExists(strings::day_color_scheme)) { SDL_LOG_DEBUG("Allow Day Color Scheme Change"); app->set_day_color_scheme(msg_params[strings::day_color_scheme]); + show_msg_params[strings::template_configuration] + [strings::day_color_scheme] = + msg_params[strings::day_color_scheme]; } if (msg_params.keyExists(strings::night_color_scheme)) { SDL_LOG_DEBUG("Allow Night Color Scheme Change"); app->set_night_color_scheme(msg_params[strings::night_color_scheme]); + show_msg_params[strings::template_configuration] + [strings::night_color_scheme] = + msg_params[strings::night_color_scheme]; } - (*message_)[strings::msg_params][strings::app_id] = app->app_id(); + show_msg_params[strings::app_id] = app->app_id(); StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); - SendHMIRequest(hmi_apis::FunctionID::UI_SetDisplayLayout, - &((*message_)[strings::msg_params]), - true); + SendHMIRequest(hmi_apis::FunctionID::UI_Show, &show_msg_params, true); } void SetDisplayLayoutRequest::on_event(const event_engine::Event& event) { @@ -136,8 +148,8 @@ void SetDisplayLayoutRequest::on_event(const event_engine::Event& event) { const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { - case hmi_apis::FunctionID::UI_SetDisplayLayout: { - SDL_LOG_INFO("Received UI_SetDisplayLayout event"); + case hmi_apis::FunctionID::UI_Show: { + SDL_LOG_INFO("Received UI_Show event (in set display layout)"); EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( @@ -150,20 +162,16 @@ void SetDisplayLayoutRequest::on_event(const event_engine::Event& event) { if (response_success) { HMICapabilities& hmi_capabilities = hmi_capabilities_; - // In case templates_available is empty copy from hmi capabilities - if (msg_params.keyExists(hmi_response::display_capabilities)) { - if (0 == msg_params[hmi_response::display_capabilities] - [hmi_response::templates_available] - .length()) { - auto display_capabilities = hmi_capabilities.display_capabilities(); - if (display_capabilities) { - msg_params[hmi_response::display_capabilities] - [hmi_response::templates_available] = - display_capabilities->getElement( - hmi_response::templates_available); - } - } - } + // Add HMI capabilities to response + msg_params[hmi_response::display_capabilities] = + *hmi_capabilities.display_capabilities(); + msg_params[hmi_response::button_capabilities] = + *hmi_capabilities.button_capabilities(); + msg_params[hmi_response::soft_button_capabilities] = + *hmi_capabilities.soft_button_capabilities(); + msg_params[hmi_response::preset_bank_capabilities] = + *hmi_capabilities.preset_bank_capabilities(); + const Version& app_version = app->version(); if (app_version.max_supported_api_version >= APIVersion::kAPIV6) { // In case of successful response warn user that this RPC is diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_response.cc index a2362a74bc..7d546079e8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_response.cc @@ -60,8 +60,6 @@ ShowConstantTBTResponse::~ShowConstantTBTResponse() {} void ShowConstantTBTResponse::Run() { SDL_LOG_AUTO_TRACE(); - application_manager_.UnsubscribeAppFromSoftButtons(message_); - rpc_service_.SendMessageToMobile(message_); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc index 10be518409..1ddb41704f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc @@ -75,34 +75,37 @@ const unsigned int kLanguageArraySizeMax = 100U; typedef std::set<std::string> SynonymsSet; typedef std::map<std::string, SynonymsSet> SynonymsMap; -bool ValidateSynonymsAtLanguage(const smart_objects::SmartObject& language, - const std::string& language_name, - SynonymsMap& synonyms_map) { +enum class ValidateSynonymsResult { OK, NOT_EXIST, INVALID }; + +ValidateSynonymsResult ValidateSynonymsAtLanguage( + const smart_objects::SmartObject& language, + const std::string& language_name, + SynonymsMap& synonyms_map) { if (!language[language_name].keyExists(json::vrSynonyms)) { SDL_LOG_WARN(kQueryAppsValidationFailedPrefix << "'languages.vrSynonyms' doesn't exist"); - return false; + return ValidateSynonymsResult::NOT_EXIST; } const smart_objects::SmartArray* synonyms_array = language[language_name][json::vrSynonyms].asArray(); if (!synonyms_array) { SDL_LOG_WARN(kQueryAppsValidationFailedPrefix << "vrSynonyms is not array."); - return false; + return ValidateSynonymsResult::INVALID; } const size_t synonyms_array_size = synonyms_array->size(); if (synonyms_array_size < kVrArraySizeMin) { SDL_LOG_WARN(kQueryAppsValidationFailedPrefix << "vrSynomyms array has [" << synonyms_array_size << "] size < allowed min size [" << kVrArraySizeMin << "]"); - return false; + return ValidateSynonymsResult::INVALID; } if (synonyms_array_size > kVrArraySizeMax) { SDL_LOG_WARN(kQueryAppsValidationFailedPrefix << "vrSynomyms array size [" << synonyms_array_size << "] exceeds maximum allowed size [" << kVrArraySizeMax << "]"); - return false; + return ValidateSynonymsResult::INVALID; } for (std::size_t idx = 0; idx < synonyms_array_size; ++idx) { @@ -113,14 +116,14 @@ bool ValidateSynonymsAtLanguage(const smart_objects::SmartObject& language, << "vrSYnomym item [" << idx << "] exceeds max length [" << vrSynonym.length() << "]>[" << kVrSynonymLengthMax << "]"); - return false; + return ValidateSynonymsResult::INVALID; } if (vrSynonym.length() < kVrSynonymLengthMin) { SDL_LOG_WARN(kQueryAppsValidationFailedPrefix << "vrSYnomym item [" << idx << "] length [" << vrSynonym.length() << "] is less then min length [" << kVrSynonymLengthMin << "] allowed."); - return false; + return ValidateSynonymsResult::INVALID; } // Verify duplicates SynonymsMap::iterator synonyms_map_iter = synonyms_map.find(language_name); @@ -129,11 +132,11 @@ bool ValidateSynonymsAtLanguage(const smart_objects::SmartObject& language, SDL_LOG_WARN(kQueryAppsValidationFailedPrefix << "vrSYnomym item already defined [" << vrSynonym.c_str() << "] for language [" << language_name << "]"); - return false; + return ValidateSynonymsResult::INVALID; } } } - return true; + return ValidateSynonymsResult::OK; } bool CheckMandatoryParametersPresent( @@ -278,6 +281,7 @@ class QueryAppsDataValidator { } bool ValidateAppIdAndAppName(const smart_objects::SmartObject& app_data) { + SDL_LOG_AUTO_TRACE(); // Verify appid length const std::string app_id(app_data[json::appId].asString()); if (app_id.length() > kAppIdLengthMax) { @@ -315,6 +319,7 @@ class QueryAppsDataValidator { bool ValidateLanguages(const smart_objects::SmartObject& languages, SynonymsMap& synonyms_map) const { + SDL_LOG_AUTO_TRACE(); bool default_language_found = false; const size_t languages_array_size = languages.length(); if (languages_array_size > kLanguageArraySizeMax) { @@ -351,32 +356,37 @@ class QueryAppsDataValidator { if (synonyms_map.find(language_name) == synonyms_map.end()) { synonyms_map[language_name] = SynonymsSet(); } - // ttsName verification - if (!language[language_name].keyExists(json::ttsName)) { - SDL_LOG_WARN(kQueryAppsValidationFailedPrefix - << "'languages.ttsName' doesn't exist"); - return false; - } - const smart_objects::SmartObject& ttsNameObject = - language[language_name][json::ttsName]; - // ttsName is string - if (smart_objects::SmartType_String == ttsNameObject.getType()) { - const std::string ttsName = - language[language_name][json::ttsName].asString(); - if (ttsName.length() > kTtsNameLengthMax) { + + const bool ttsNameExist = + language[language_name].keyExists(json::ttsName); + + if (ttsNameExist) { + const smart_objects::SmartObject& ttsNameObject = + language[language_name][json::ttsName]; + // ttsName is string + if (smart_objects::SmartType_String == ttsNameObject.getType()) { + const std::string ttsName = + language[language_name][json::ttsName].asString(); + if (ttsName.length() > kTtsNameLengthMax) { + SDL_LOG_WARN(kQueryAppsValidationFailedPrefix + << "ttsName string exceeds max length [" + << ttsName.length() << "]>[" << kTtsNameLengthMax + << "]"); + return false; + } + } else { SDL_LOG_WARN(kQueryAppsValidationFailedPrefix - << "ttsName string exceeds max length [" - << ttsName.length() << "]>[" << kTtsNameLengthMax - << "]"); + << "ttsName is not the string type."); return false; } } else { - SDL_LOG_WARN(kQueryAppsValidationFailedPrefix - << "ttsName is not the string type."); - return false; + SDL_LOG_WARN("ttsName does not exist."); } - if (!ValidateSynonymsAtLanguage(language, language_name, synonyms_map)) { + const auto result = + ValidateSynonymsAtLanguage(language, language_name, synonyms_map); + + if (result == ValidateSynonymsResult::INVALID) { return false; } } @@ -570,6 +580,16 @@ void SystemRequest::Run() { SDL_LOG_DEBUG("Binary data ok."); + if (mobile_apis::RequestType::PROPRIETARY == request_type || + mobile_apis::RequestType::HTTP == request_type) { + auto app_id = application->app_id(); + if (!policy_handler_.IsPTUSystemRequestAllowed(app_id)) { + SDL_LOG_DEBUG("Rejected PTU SystemRequest from app " << app_id); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + } + if (mobile_apis::RequestType::ICON_URL == request_type) { application_manager_.SetIconFileFromSystemRequest(file_name); SendResponse(true, mobile_apis::Result::SUCCESS); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_response.cc index bf2658128d..bedf91b45c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_response.cc @@ -59,8 +59,6 @@ UpdateTurnListResponse::~UpdateTurnListResponse() {} void UpdateTurnListResponse::Run() { SDL_LOG_AUTO_TRACE(); - application_manager_.UnsubscribeAppFromSoftButtons(message_); - rpc_service_.SendMessageToMobile(message_); } |