diff options
author | Andrey Oleynik <aoleynik@luxoft.com> | 2015-08-27 14:19:42 +0300 |
---|---|---|
committer | Andrey Oleynik <aoleynik@luxoft.com> | 2015-08-28 13:42:52 +0300 |
commit | 9994e7431284ce9a21f088b40cb7531023e1164d (patch) | |
tree | b9449d8e81dca9ab042846cd8e4698ee3510f233 | |
parent | f261a06bbfb133d1662943e3b269906fa1fc0a5a (diff) | |
download | smartdevicelink-9994e7431284ce9a21f088b40cb7531023e1164d.tar.gz |
Fixes sending of OnHashChange notification
By requirements SDL has to send OnHashChange only for successful
responses
Fixes: APPLINK-13033
Conflicts:
src/appMain/life_cycle.cc
src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc
src/components/application_manager/src/commands/mobile/set_global_properties_request.cc
src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc
8 files changed, 90 insertions, 47 deletions
diff --git a/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc b/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc index 7e0e6aeca..f01645079 100644 --- a/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc +++ b/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc @@ -120,7 +120,9 @@ void AddSubMenuRequest::on_event(const event_engine::Event& event) { (*message_)[strings::msg_params]); } SendResponse(result, result_code, NULL, &(message[strings::msg_params])); - application->UpdateHash(); + if (result) { + application->UpdateHash(); + } break; } default: { diff --git a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc index 9908756cf..813f55091 100644 --- a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc +++ b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc @@ -423,6 +423,7 @@ void CreateInteractionChoiceSetRequest::DeleteChoices() { ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(connection_key()); if (!application) { + LOG4CXX_ERROR(logger_, "NULL pointer"); return; } application->RemoveChoiceSet(choice_set_id_); @@ -454,9 +455,11 @@ void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() { ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(connection_key()); - if (application) { - application->UpdateHash(); + if (!application) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + return; } + application->UpdateHash(); } else { DeleteChoices(); } diff --git a/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc b/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc index 35c8b96d2..18c6b3b08 100644 --- a/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc +++ b/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc @@ -86,9 +86,12 @@ void DeleteInteractionChoiceSetRequest::Run() { app->RemoveChoiceSet(choise_set_id); - SendResponse(true, mobile_apis::Result::SUCCESS); - /*CreateHMIRequest(hmi_apis::FunctionID::UI_DeleteInteractionChoiceSet, - msg_params, true);*/ + // Checking of HMI responses will be implemented with APPLINK-14600 + const bool result = true; + SendResponse(result, mobile_apis::Result::SUCCESS); + if (result) { + app->UpdateHash(); + } } bool DeleteInteractionChoiceSetRequest::ChoiceSetInUse(ApplicationConstSharedPtr app) { diff --git a/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc b/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc index f6dc53f59..7472324ed 100644 --- a/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc +++ b/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc @@ -240,34 +240,34 @@ void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { - case hmi_apis::FunctionID::UI_SetGlobalProperties: { - LOG4CXX_INFO(logger_, "Received UI_SetGlobalProperties event"); - is_ui_received_ = true; - ui_result_ = static_cast<hmi_apis::Common_Result::eType>( - message[strings::params][hmi_response::code].asInt()); - break; - } - case hmi_apis::FunctionID::TTS_SetGlobalProperties: { - LOG4CXX_INFO(logger_, "Received TTS_SetGlobalProperties event"); - is_tts_received_ = true; - tts_result_ = static_cast<hmi_apis::Common_Result::eType>( - message[strings::params][hmi_response::code].asInt()); - break; - } - default: { - LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); - return; - } + case hmi_apis::FunctionID::UI_SetGlobalProperties: { + LOG4CXX_INFO(logger_, "Received UI_SetGlobalProperties event"); + is_ui_received_ = true; + ui_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + break; + } + case hmi_apis::FunctionID::TTS_SetGlobalProperties: { + LOG4CXX_INFO(logger_, "Received TTS_SetGlobalProperties event"); + is_tts_received_ = true; + tts_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } } if (!IsPendingResponseExist()) { bool result = ((hmi_apis::Common_Result::SUCCESS == ui_result_) - && (hmi_apis::Common_Result::SUCCESS == tts_result_ || - hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_)) - || ((hmi_apis::Common_Result::SUCCESS == ui_result_) - && (hmi_apis::Common_Result::INVALID_ENUM == tts_result_)) - || ((hmi_apis::Common_Result::INVALID_ENUM == ui_result_) - && (hmi_apis::Common_Result::SUCCESS == tts_result_)); + && (hmi_apis::Common_Result::SUCCESS == tts_result_ || + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_)) + || ((hmi_apis::Common_Result::SUCCESS == ui_result_) + && (hmi_apis::Common_Result::INVALID_ENUM == tts_result_)) + || ((hmi_apis::Common_Result::INVALID_ENUM == ui_result_) + && (hmi_apis::Common_Result::SUCCESS == tts_result_)); mobile_apis::Result::eType result_code; const char* return_info = NULL; @@ -278,25 +278,33 @@ void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { return_info = std::string("Unsupported phoneme type sent in a prompt").c_str(); } else { result_code = static_cast<mobile_apis::Result::eType>( - std::max(ui_result_, tts_result_)); + std::max(ui_result_, tts_result_)); } } else { result_code = static_cast<mobile_apis::Result::eType>( - std::max(ui_result_, tts_result_)); + std::max(ui_result_, tts_result_)); } + SendResponse(result, static_cast<mobile_apis::Result::eType>(result_code), + return_info, &(message[strings::msg_params])); + ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(connection_key()); - if (application) { - SendResponse(result, static_cast<mobile_apis::Result::eType>(result_code), - return_info, &(message[strings::msg_params])); + + if (!application) { + LOG4CXX_DEBUG(logger_, "NULL pointer"); + return; + } + + if (result) { application->UpdateHash(); - } else { - LOG4CXX_WARN(logger_, "unable to find application: " << connection_key()); } + } else { + LOG4CXX_WARN(logger_, "unable to find application: " << connection_key()); } } + bool ResetGlobalPropertiesRequest::IsPendingResponseExist() { return is_ui_send_ != is_ui_received_ || is_tts_send_ != is_tts_received_; } diff --git a/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc index ff46e041f..784fa1cbf 100644 --- a/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc +++ b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc @@ -359,11 +359,20 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { std::max(ui_result_, tts_result_)); } + + SendResponse(result, result_code, return_info, + &(message[strings::msg_params])); + ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(connection_key()); - SendResponse(result, static_cast<mobile_apis::Result::eType>(result_code), - return_info, &(message[strings::msg_params])); - application->UpdateHash(); + if (!application) { + LOG4CXX_DEBUG(logger_, "NULL pointer."); + return; + } + + if (result) { + application->UpdateHash(); + } } } diff --git a/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc index ece7c8332..22bc57620 100644 --- a/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc +++ b/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc @@ -85,9 +85,13 @@ void SubscribeButtonRequest::Run() { app->SubscribeToButton(static_cast<mobile_apis::ButtonName::eType>(btn_id)); SendSubscribeButtonNotification(); - SendResponse(true, mobile_apis::Result::SUCCESS); - app->UpdateHash(); + const bool is_succedeed = true; + SendResponse(is_succedeed, mobile_apis::Result::SUCCESS); + + if (is_succedeed) { + app->UpdateHash(); + } } bool SubscribeButtonRequest::IsSubscriptionAllowed( diff --git a/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc index 1640f0b49..f00527037 100644 --- a/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc +++ b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc @@ -179,6 +179,11 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( CommandRequestImpl::connection_key()); + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer."); + return; + } + #ifdef HMI_DBUS_API for (HmiRequests::iterator it = hmi_requests_.begin(); it != hmi_requests_.end(); ++it) { @@ -224,9 +229,12 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { response_params[it->str] = it->value; } } - LOG4CXX_INFO(logger_, "All HMI requests are complete"); + LOG4CXX_DEBUG(logger_, "All HMI requests are complete"); + const bool result = any_arg_success; SendResponse(any_arg_success, status, NULL, &response_params); - app->UpdateHash(); + if (result) { + app->UpdateHash(); + } } #else hmi_apis::Common_Result::eType hmi_result = @@ -255,7 +263,10 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { result_code, return_info, &(message[strings::msg_params])); - app->UpdateHash(); + + if (result) { + app->UpdateHash(); + } #endif // #ifdef HMI_DBUS_API } diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc index af1faa9e6..a2958342e 100644 --- a/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc +++ b/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc @@ -73,8 +73,11 @@ void UnsubscribeButtonRequest::Run() { app->UnsubscribeFromButton(static_cast<mobile_apis::ButtonName::eType>(btn_id)); SendUnsubscribeButtonNotification(); - SendResponse(true, mobile_apis::Result::SUCCESS); - app->UpdateHash(); + const bool is_succedeed = true; + SendResponse(is_succedeed, mobile_apis::Result::SUCCESS); + if (is_succedeed) { + app->UpdateHash(); + } } void UnsubscribeButtonRequest::SendUnsubscribeButtonNotification() { |