diff options
author | Ashwin Karemore <akaremor@ford.com> | 2018-07-02 15:37:59 +0200 |
---|---|---|
committer | AKalinich-Luxoft <AKalinich@luxoft.com> | 2018-07-26 18:58:04 +0300 |
commit | 604057538b085ec79b766bdf6bdf8a25c9258013 (patch) | |
tree | 27829f598a6d5659a7eb6e0ced565856679f304a | |
parent | 58c57fed825fb73a01bceb17c2a2b48473fff6f2 (diff) | |
download | sdl_core-604057538b085ec79b766bdf6bdf8a25c9258013.tar.gz |
revert image check and return Warning or invalid data
17 files changed, 262 insertions, 70 deletions
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 9559c2007e..b1bf3bd567 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -615,7 +615,7 @@ class MessageHelper { * @param app current application * @return verification result */ - static mobile_apis::Result::eType VerifyImageApplyPath( + static void ApplyImagePath( smart_objects::SmartObject& image, ApplicationConstSharedPtr app, ApplicationManager& app_mngr); @@ -663,7 +663,7 @@ class MessageHelper { * @return returns FALSE if string contains incorrect character or * string is empty otherwise returns TRUE */ - static bool VerifySoftButtonString(const std::string& str); + static bool VerifyString(const std::string& str); static mobile_apis::Result::eType ProcessSoftButtons( smart_objects::SmartObject& message_params, diff --git a/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h b/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h index b3aa5d099c..17aabb6d60 100644 --- a/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h +++ b/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h @@ -399,6 +399,15 @@ class ResumeCtrlImpl : public ResumeCtrl, const smart_objects::SmartObject& saved_app); /** + * @brief CheckIcons allows to check application icons + * @param application application under resumtion application + * @param json_object + * @return true in case icons exists, false otherwise + */ + bool CheckIcons(app_mngr::ApplicationSharedPtr application, + smart_objects::SmartObject& obj); + + /** * @brief CheckDelayAfterIgnOn should check if SDL was started less * then N seconds ago. N will be readed from profile. * @return true if SDL started N seconds ago, otherwise return false diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc index ab9baea7ef..155f819761 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc @@ -90,6 +90,19 @@ void AddCommandRequest::Run() { return; } + if ((*message_)[strings::msg_params].keyExists(strings::cmd_icon)) { + mobile_apis::Result::eType verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::cmd_icon], + app, + application_manager_); + + if (mobile_apis::Result::INVALID_DATA == verification_result) { + LOG4CXX_ERROR( + logger_, "MessageHelper::VerifyImage return " << verification_result); + SendResponse(false, verification_result); + return; + } + } if (!((*message_)[strings::msg_params].keyExists(strings::cmd_id))) { LOG4CXX_ERROR(logger_, "INVALID_DATA"); 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 767a4e2c27..d36eda18e1 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 @@ -122,6 +122,11 @@ void CreateInteractionChoiceSetRequest::Run() { } if (verification_result_image == Result::INVALID_DATA || verification_result_secondary_image == Result::INVALID_DATA) { + LOG4CXX_ERROR(logger_, "Image verification failed."); + SendResponse(false, Result::INVALID_DATA); + return; + } else if (verification_result_image == Result::WARNINGS || + verification_result_secondary_image == Result::WARNINGS) { should_send_warnings = true; break; } @@ -437,18 +442,18 @@ void CreateInteractionChoiceSetRequest::DeleteChoices() { } void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() { - LOG4CXX_AUTO_TRACE(logger_); - - if (!error_from_hmi_ && should_send_warnings) { - SendResponse(true, mobile_apis::Result::WARNINGS,INVALID_IMG_WARNING_INFO); - } else if (!error_from_hmi_) { - SendResponse(true, mobile_apis::Result::SUCCESS); - } else { - DeleteChoices(); - } - - application_manager_.TerminateRequest( - connection_key(), correlation_id(), function_id()); + LOG4CXX_AUTO_TRACE(logger_); + + if (!error_from_hmi_ && should_send_warnings) { + SendResponse(true, mobile_apis::Result::WARNINGS,INVALID_IMG_WARNING_INFO); + } else if (!error_from_hmi_) { + SendResponse(true, mobile_apis::Result::SUCCESS); + } else { + DeleteChoices(); + } + + application_manager_.TerminateRequest( + connection_key(), correlation_id(), function_id()); } } // namespace commands 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 fb3516c24c..76dd30525a 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 @@ -164,6 +164,16 @@ void PerformInteractionRequest::Run() { return; } + if (msg_params.keyExists(strings::vr_help)) { + if (mobile_apis::Result::INVALID_DATA == + MessageHelper::VerifyImageVrHelpItems( + msg_params[strings::vr_help], app, application_manager_)) { + LOG4CXX_ERROR(logger_, + "Verification of " << strings::vr_help << " failed."); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + } if (IsWhiteSpaceExist()) { LOG4CXX_ERROR(logger_, diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc index e9e11b3f24..2719d0674d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc @@ -117,6 +117,19 @@ void SendLocationRequest::Run() { return; } + if (msg_params.keyExists(strings::location_image)) { + mobile_apis::Result::eType verification_result = + mobile_apis::Result::SUCCESS; + verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::location_image], + app, + application_manager_); + if (mobile_apis::Result::INVALID_DATA == verification_result) { + LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); + SendResponse(false, verification_result); + return; + } + } SmartObject request_msg_params = SmartObject(smart_objects::SmartType_Map); request_msg_params = msg_params; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc index 0e8c4fcbfc..0c217b6b4f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc @@ -88,6 +88,32 @@ void SetGlobalPropertiesRequest::Run() { return; } + mobile_apis::Result::eType verification_result = mobile_apis::Result::SUCCESS; + + if ((*message_)[strings::msg_params].keyExists(strings::menu_icon)) { + verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::menu_icon], + app, + application_manager_); + if (mobile_apis::Result::INVALID_DATA == verification_result) { + LOG4CXX_ERROR( + logger_, "MessageHelper::VerifyImage return " << verification_result); + SendResponse(false, verification_result); + return; + } + } + // Check for image file(s) in vrHelpItem + if ((*message_)[strings::msg_params].keyExists(strings::vr_help)) { + if (mobile_apis::Result::INVALID_DATA == + MessageHelper::VerifyImageVrHelpItems( + (*message_)[strings::msg_params][strings::vr_help], + app, + application_manager_)) { + LOG4CXX_ERROR(logger_, "MessageHelper::VerifyImage return INVALID_DATA!"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + } if (IsWhiteSpaceExist()) { LOG4CXX_ERROR(logger_, "White spaces found"); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc index 1e5767258d..3b2936e6cd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc @@ -101,6 +101,26 @@ void ShowConstantTBTRequest::Run() { return; } + mobile_apis::Result::eType verification_result = mobile_apis::Result::SUCCESS; + if (msg_params.keyExists(strings::turn_icon)) { + verification_result = MessageHelper::VerifyImage( + msg_params[strings::turn_icon], app, application_manager_); + if (mobile_apis::Result::INVALID_DATA == verification_result) { + LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); + SendResponse(false, verification_result); + return; + } + } + + if (msg_params.keyExists(strings::next_turn_icon)) { + verification_result = MessageHelper::VerifyImage( + msg_params[strings::next_turn_icon], app, application_manager_); + if (mobile_apis::Result::INVALID_DATA == verification_result) { + LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); + SendResponse(false, verification_result); + return; + } + } msg_params[strings::app_id] = app->app_id(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_request.cc index 25b96d6aab..e0c3e1da9a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_request.cc @@ -135,6 +135,32 @@ void ShowRequest::Run() { return; } + mobile_apis::Result::eType verification_result = mobile_apis::Result::SUCCESS; + if (((*message_)[strings::msg_params].keyExists(strings::graphic)) && + ((*message_)[strings::msg_params][strings::graphic][strings::value] + .asString()).length()) { + verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::graphic], + app, + application_manager_); + if (mobile_apis::Result::INVALID_DATA == verification_result) { + LOG4CXX_ERROR(logger_, "Image verification failed."); + SendResponse(false, verification_result); + return; + } + } + + if ((*message_)[strings::msg_params].keyExists(strings::secondary_graphic)) { + verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::secondary_graphic], + app, + application_manager_); + if (mobile_apis::Result::INVALID_DATA == verification_result) { + LOG4CXX_ERROR(logger_, "Image verification failed."); + SendResponse(false, verification_result); + return; + } + } smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc index f28656514f..c04ad34f5f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc @@ -95,6 +95,22 @@ void UpdateTurnListRequest::Run() { return; } + if ((*message_)[strings::msg_params].keyExists(strings::turn_list)) { + smart_objects::SmartObject& turn_list_array = + ((*message_)[strings::msg_params][strings::turn_list]); + for (uint32_t i = 0; i < turn_list_array.length(); ++i) { + if ((turn_list_array[i].keyExists(strings::turn_icon)) && + (mobile_apis::Result::INVALID_DATA == + MessageHelper::VerifyImage(turn_list_array[i][strings::turn_icon], + app, + application_manager_))) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyImage return INVALID_DATA"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + } + } smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc index 4a4fa88f33..ebbd633912 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc @@ -306,17 +306,27 @@ TEST_F(SendLocationRequestTest, Run_LocationImageValid_Success) { SmartObject(smart_objects::SmartType_Map); (*message_)[strings::msg_params][strings::location_image][strings::value] = "1"; + EXPECT_CALL( + mock_message_helper_, + VerifyImage( + (*message_)[strings::msg_params][strings::location_image], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); FinishSetup(); command_->Run(); } -TEST_F(SendLocationRequestTest, Run_LocationImageInvalid_Warnings) { +TEST_F(SendLocationRequestTest, Run_LocationImageInvalid_Cancelled) { InitialSetup(message_); (*message_)[strings::msg_params][strings::location_image] = SmartObject(smart_objects::SmartType_Map); (*message_)[strings::msg_params][strings::location_image][strings::value] = - "1"; - FinishSetup(); + " 1"; + EXPECT_CALL( + mock_message_helper_, + VerifyImage( + (*message_)[strings::msg_params][strings::location_image], _, _)) + .WillOnce(Return(mobile_apis::Result::INVALID_DATA)); + FinishSetupCancelled(mobile_apis::Result::INVALID_DATA); command_->Run(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc index 4ee5af8279..ae82f24b61 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc @@ -496,7 +496,7 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_VRBrokenMenuIcon_Canceled) { SmartObject vr_help_title("yes"); (*msg)[am::strings::msg_params][am::strings::vr_help_title] = vr_help_title; SmartObject menu_icon(smart_objects::SmartType_Map); - menu_icon[am::strings::value] = "1"; + menu_icon[am::strings::value] = " 1"; (*msg)[am::strings::msg_params][am::hmi_request::menu_icon] = menu_icon; EXPECT_CALL(app_mngr_, application(kConnectionKey)) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc index f582072398..ac2b59a613 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc @@ -339,6 +339,8 @@ TEST_F(ShowRequestTest, Run_Graphic_SUCCESS) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); msg_params[am::strings::app_id] = kAppId; @@ -351,7 +353,7 @@ TEST_F(ShowRequestTest, Run_Graphic_SUCCESS) { command->Run(); } -TEST_F(ShowRequestTest, Run_Graphic_Not_Verified) { +TEST_F(ShowRequestTest, Run_Graphic_Canceled) { MessageSharedPtr msg = CreateMsgParams(); SmartObject msg_params(smart_objects::SmartType_Map); @@ -365,16 +367,12 @@ TEST_F(ShowRequestTest, Run_Graphic_Not_Verified) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) - .Times(0); + .WillOnce(Return(mobile_apis::Result::INVALID_DATA)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); - EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); - - msg_params[am::strings::app_id] = kAppId; - msg_params[am::hmi_request::show_strings] = - smart_objects::SmartObject(smart_objects::SmartType_Array); + EXPECT_CALL(*mock_app_, app_id()).Times(0); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(*mock_app_, set_show_command(msg_params)).Times(0); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); - EXPECT_CALL(*mock_app_, set_show_command(msg_params)); command->Run(); } @@ -391,6 +389,7 @@ TEST_F(ShowRequestTest, Run_Graphic_WrongSyntax) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _)).Times(0); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); EXPECT_CALL(*mock_app_, app_id()).Times(0); @@ -413,6 +412,8 @@ TEST_F(ShowRequestTest, Run_SecondaryGraphic_SUCCESS) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); msg_params[am::strings::app_id] = kAppId; @@ -424,7 +425,7 @@ TEST_F(ShowRequestTest, Run_SecondaryGraphic_SUCCESS) { command->Run(); } -TEST_F(ShowRequestTest, Run_SecondaryGraphic_Not_Verified) { +TEST_F(ShowRequestTest, Run_SecondaryGraphic_Canceled) { MessageSharedPtr msg = CreateMsgParams(); SmartObject msg_params(smart_objects::SmartType_Map); @@ -438,15 +439,12 @@ TEST_F(ShowRequestTest, Run_SecondaryGraphic_Not_Verified) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) - .Times(0); + .WillOnce(Return(mobile_apis::Result::INVALID_DATA)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); - EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + EXPECT_CALL(*mock_app_, app_id()).Times(0); - msg_params[am::strings::app_id] = kAppId; - msg_params[am::hmi_request::show_strings] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); - EXPECT_CALL(*mock_app_, set_show_command(msg_params)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(*mock_app_, set_show_command(msg_params)).Times(0); command->Run(); } @@ -464,6 +462,7 @@ TEST_F(ShowRequestTest, Run_SecondaryGraphic_WrongSyntax) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)).Times(0); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); EXPECT_CALL(*mock_app_, app_id()).Times(0); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc index 043344f7d7..acb421af6b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc @@ -202,6 +202,13 @@ TEST_F(UpdateTurnListRequestTest, Run_ValidTurnList_SUCCESS) { Ref(app_mngr_))) .WillOnce(Return(mobile_result::SUCCESS)); + EXPECT_CALL( + mock_message_helper_, + VerifyImage( + (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0] + [am::strings::turn_icon], + Eq(mock_app), + Ref(app_mngr_))).WillOnce(Return(mobile_result::SUCCESS)); EXPECT_CALL(mock_message_helper_, SubscribeApplicationToSoftButton(_, _, kFunctionId)); 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 962fb767dc..58b3552e9f 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -94,7 +94,7 @@ bool ValidateSoftButtons(smart_objects::SmartObject& soft_buttons) { // Check if image parameter is valid if (button.keyExists(strings::image)) { SmartObject& buttonImage = button[strings::image]; - if (false == MessageHelper::VerifySoftButtonString( + if (false == MessageHelper::VerifyString( buttonImage[strings::value].asString())) { return false; } @@ -2598,27 +2598,17 @@ mobile_apis::Result::eType MessageHelper::VerifyImageFiles( return mobile_apis::Result::SUCCESS; } -mobile_apis::Result::eType MessageHelper::VerifyImageApplyPath( +void MessageHelper::ApplyImagePath( smart_objects::SmartObject& image, ApplicationConstSharedPtr app, ApplicationManager& app_mngr) { - // Checking image type first: if STATIC - skip existence check, since it is - // HMI related file and it should know it location - const uint32_t image_type = image[strings::image_type].asUInt(); - mobile_apis::ImageType::eType type = - static_cast<mobile_apis::ImageType::eType>(image_type); - if (mobile_apis::ImageType::STATIC == type) { - return mobile_apis::Result::SUCCESS; - } const std::string& file_name = image[strings::value].asString(); const std::string& full_file_path = GetAppFilePath(file_name, app, app_mngr); image[strings::value] = full_file_path; - if (file_system::FileExists(full_file_path)) { - return mobile_apis::Result::SUCCESS; - } - return mobile_apis::Result::INVALID_DATA; + + return; } std::string MessageHelper::GetAppFilePath(std::string file_name, @@ -2679,19 +2669,29 @@ mobile_apis::Result::eType MessageHelper::VerifyImage( smart_objects::SmartObject& image, ApplicationConstSharedPtr app, ApplicationManager& app_mngr) { - smart_objects::SmartObject temp_image = image; + const uint32_t image_type = image[strings::image_type].asUInt(); - const mobile_apis::ImageType::eType type = + mobile_apis::ImageType::eType type = static_cast<mobile_apis::ImageType::eType>(image_type); + const std::string& file_name = image[strings::value].asString(); - const mobile_apis::Result::eType result = - VerifyImageApplyPath(temp_image, app, app_mngr); - if ((mobile_apis::Result::SUCCESS == result) && - (mobile_apis::ImageType::DYNAMIC == type)) { - image[strings::value] = temp_image[strings::value]; + + if(!VerifyString(file_name)){ + return mobile_apis::Result::INVALID_DATA; } - return result; + if (mobile_apis::ImageType::STATIC == type) { + return mobile_apis::Result::SUCCESS; + } + + ApplyImagePath(image, app, app_mngr); + + const std::string& imagePath = image[strings::value].asString(); + + if (file_system::FileExists(imagePath)) { + return mobile_apis::Result::SUCCESS; + } + return mobile_apis::Result::WARNINGS; } mobile_apis::Result::eType MessageHelper::VerifyImageVrHelpItems( @@ -2704,21 +2704,21 @@ mobile_apis::Result::eType MessageHelper::VerifyImageVrHelpItems( if (message[i].keyExists(strings::image)) { verification_result_image = VerifyImage(message[i][strings::image], app, app_mngr); - if (mobile_apis::Result::SUCCESS != verification_result_image) { - return verification_result_image; + if (mobile_apis::Result::INVALID_DATA == verification_result_image) { + break; } } } - return mobile_apis::Result::SUCCESS; + return verification_result_image; } -bool MessageHelper::VerifySoftButtonString(const std::string& str) { +bool MessageHelper::VerifyString(const std::string& str) { if ((std::string::npos != str.find_first_of("\t\n")) || (std::string::npos != str.find("\\n")) || (std::string::npos != str.find("\\t")) || (std::string::npos == str.find_first_not_of(' '))) { LOG4CXX_ERROR(logger_, - "MessageHelper::VerifySoftButtonString" + "MessageHelper::VerifyString" "string contains incorrect character"); return false; } @@ -2775,6 +2775,13 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( if (request_soft_buttons[i].keyExists(strings::text)) { request_soft_buttons[i].erase(strings::text); } + + if ((!request_soft_buttons[i].keyExists(strings::image) || + (Result::INVALID_DATA == + VerifyImage( + request_soft_buttons[i][strings::image], app, app_mngr)))) { + return Result::INVALID_DATA; + } break; } case SoftButtonType::SBT_TEXT: { @@ -2782,7 +2789,7 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( request_soft_buttons[i].erase(strings::image); } if ((!request_soft_buttons[i].keyExists(strings::text)) || - (!VerifySoftButtonString( + (!VerifyString( request_soft_buttons[i][strings::text].asString()))) { return Result::INVALID_DATA; } @@ -2791,10 +2798,17 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( case SoftButtonType::SBT_BOTH: { if ((!request_soft_buttons[i].keyExists(strings::text)) || ((request_soft_buttons[i][strings::text].length()) && - (!VerifySoftButtonString( + (!VerifyString( request_soft_buttons[i][strings::text].asString())))) { return Result::INVALID_DATA; } + + if ((!request_soft_buttons[i].keyExists(strings::image) || + (Result::INVALID_DATA == + VerifyImage( + request_soft_buttons[i][strings::image], app, app_mngr)))) { + return Result::INVALID_DATA; + } break; } default: { diff --git a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc index caa04c1ada..42dc335878 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc @@ -478,7 +478,20 @@ bool ResumeCtrlImpl::CheckPersistenceFilesForResumption( const std::string& device_mac = application->mac_address(); bool result = resumption_storage_->GetSavedApplication( application->policy_app_id(), device_mac, saved_app); - return result; + if (result) { + if (saved_app.keyExists(strings::application_commands)) { + if (!CheckIcons(application, saved_app[strings::application_commands])) { + return false; + } + } + if (saved_app.keyExists(strings::application_choice_sets)) { + if (!CheckIcons(application, + saved_app[strings::application_choice_sets])) { + return false; + } + } + } + return true; } bool ResumeCtrlImpl::CheckApplicationHash(ApplicationSharedPtr application, @@ -766,6 +779,15 @@ bool ResumeCtrlImpl::CheckAppRestrictions( return result; } +bool ResumeCtrlImpl::CheckIcons(ApplicationSharedPtr application, + smart_objects::SmartObject& obj) { + using namespace smart_objects; + LOG4CXX_AUTO_TRACE(logger_); + const mobile_apis::Result::eType verify_images = + MessageHelper::VerifyImageFiles(obj, application, application_manager_); + return mobile_apis::Result::INVALID_DATA != verify_images; +} + bool ResumeCtrlImpl::CheckDelayAfterIgnOn() { using namespace date_time; LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/test/message_helper/message_helper_test.cc b/src/components/application_manager/test/message_helper/message_helper_test.cc index 1e8a5f5a40..338c359bbe 100644 --- a/src/components/application_manager/test/message_helper/message_helper_test.cc +++ b/src/components/application_manager/test/message_helper/message_helper_test.cc @@ -715,7 +715,7 @@ TEST_F(MessageHelperTest, VerifySoftButtonString_WrongStrings_False) { "soft_button1\\n", "soft_button1\\t"}; for (size_t i = 0; i < wrong_strings.size(); ++i) { - EXPECT_FALSE(MessageHelper::VerifySoftButtonString(wrong_strings[i])); + EXPECT_FALSE(MessageHelper::VerifyString(wrong_strings[i])); } } @@ -726,7 +726,7 @@ TEST_F(MessageHelperTest, VerifySoftButtonString_CorrectStrings_True) { "soft_button1??....asd", "soft_button12313fcvzxc./.,"}; for (size_t i = 0; i < wrong_strings.size(); ++i) { - EXPECT_TRUE(MessageHelper::VerifySoftButtonString(wrong_strings[i])); + EXPECT_TRUE(MessageHelper::VerifyString(wrong_strings[i])); } } @@ -771,6 +771,7 @@ TEST_F(MessageHelperTest, VerifyImage_ImageTypeIsStatic_Success) { // Creating input data for method smart_objects::SmartObject image; image[strings::image_type] = mobile_apis::ImageType::STATIC; + image[strings::value] = "static_icon"; // Method call mobile_apis::Result::eType result = MessageHelper::VerifyImage( image, appSharedMock, mock_application_manager); @@ -801,10 +802,9 @@ TEST_F(MessageHelperTest, VerifyImageApplyPath_ImageTypeIsStatic_Success) { image[strings::image_type] = mobile_apis::ImageType::STATIC; image[strings::value] = "icon.png"; // Method call - mobile_apis::Result::eType result = MessageHelper::VerifyImageApplyPath( + MessageHelper::ApplyImagePath( image, appSharedMock, mock_application_manager); // EXPECT - EXPECT_EQ(mobile_apis::Result::SUCCESS, result); EXPECT_EQ("icon.png", image[strings::value].asString()); } @@ -817,7 +817,7 @@ TEST_F(MessageHelperTest, VerifyImageApplyPath_ImageValueNotValid_InvalidData) { // Invalid value image[strings::value] = " "; // Method call - mobile_apis::Result::eType result = MessageHelper::VerifyImageApplyPath( + mobile_apis::Result::eType result = MessageHelper::VerifyImage( image, appSharedMock, mock_application_manager); // EXPECT EXPECT_EQ(mobile_apis::Result::INVALID_DATA, result); @@ -830,6 +830,8 @@ TEST_F(MessageHelperTest, VerifyImageFiles_SmartObjectWithValidData_Success) { smart_objects::SmartObject images; images[0][strings::image_type] = mobile_apis::ImageType::STATIC; images[1][strings::image_type] = mobile_apis::ImageType::STATIC; + images[0][strings::value] = "static_icon"; + images[1][strings::value] = "static_icon"; // Method call mobile_apis::Result::eType result = MessageHelper::VerifyImageFiles( images, appSharedMock, mock_application_manager); |