diff options
author | jacobkeeler <jacob.keeler@livioradio.com> | 2018-01-19 11:08:30 -0500 |
---|---|---|
committer | jacobkeeler <jacob.keeler@livioradio.com> | 2018-01-19 11:08:30 -0500 |
commit | 5a1667d8ff0eeb696bf842b2c11aaf74663ebf00 (patch) | |
tree | f3c59e3d09bdc457b0677811f7ef09417fd28167 /src/components/application_manager/src | |
parent | 273e26304efb215af3416f86ab86c1c7fd39f974 (diff) | |
parent | e8911d03dde016a29b01fe80533bc6ac56531678 (diff) | |
download | sdl_core-5a1667d8ff0eeb696bf842b2c11aaf74663ebf00.tar.gz |
Merge remote-tracking branch 'origin/develop' into feature/invalid_data_info
Diffstat (limited to 'src/components/application_manager/src')
59 files changed, 834 insertions, 327 deletions
diff --git a/src/components/application_manager/src/app_launch/app_launch_sql_queries.cc b/src/components/application_manager/src/app_launch/app_launch_sql_queries.cc index 950bcd44fa..cc4765e6c9 100644 --- a/src/components/application_manager/src/app_launch/app_launch_sql_queries.cc +++ b/src/components/application_manager/src/app_launch/app_launch_sql_queries.cc @@ -36,7 +36,7 @@ namespace app_launch { const std::string kCreateSchema = "CREATE TABLE IF NOT EXISTS `app_launch`( " " `deviceMac` TEXT, " - " `appID` TEXT," + " `appID` TEXT collate nocase," " `bundleID` TEXT," " `last_session` DATETIME, " " PRIMARY KEY(`deviceMac`, `appID`, `bundleID`)" diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 4a752febf8..0ba98d67f5 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -44,6 +44,7 @@ #include "utils/make_shared.h" #include "utils/timer_task_impl.h" #include "application_manager/policies/policy_handler_interface.h" +#include "application_manager/resumption/resume_ctrl.h" namespace { @@ -111,6 +112,7 @@ ApplicationImpl::ApplicationImpl( protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_3) , is_voice_communication_application_(false) , is_resuming_(false) + , is_hash_changed_during_suspend_(false) , video_stream_retry_number_(0) , audio_stream_retry_number_(0) , video_stream_suspend_timer_( @@ -720,19 +722,23 @@ bool ApplicationImpl::UnsubscribeFromButton( bool ApplicationImpl::SubscribeToIVI(uint32_t vehicle_info_type) { sync_primitives::AutoLock lock(vi_lock_); - return subscribed_vehicle_info_.insert(vehicle_info_type).second; + return subscribed_vehicle_info_ + .insert( + static_cast<mobile_apis::VehicleDataType::eType>(vehicle_info_type)) + .second; } bool ApplicationImpl::IsSubscribedToIVI(uint32_t vehicle_info_type) const { sync_primitives::AutoLock lock(vi_lock_); - VehicleInfoSubscriptions::const_iterator it = - subscribed_vehicle_info_.find(vehicle_info_type); + VehicleInfoSubscriptions::const_iterator it = subscribed_vehicle_info_.find( + static_cast<mobile_apis::VehicleDataType::eType>(vehicle_info_type)); return (subscribed_vehicle_info_.end() != it); } bool ApplicationImpl::UnsubscribeFromIVI(uint32_t vehicle_info_type) { sync_primitives::AutoLock lock(vi_lock_); - return subscribed_vehicle_info_.erase(vehicle_info_type); + return subscribed_vehicle_info_.erase( + static_cast<mobile_apis::VehicleDataType::eType>(vehicle_info_type)); } UsageStatistics& ApplicationImpl::usage_report() { @@ -868,7 +874,19 @@ void ApplicationImpl::UpdateHash() { utils::gen_hash(application_manager_.get_settings().hash_string_size()); set_is_application_data_changed(true); - MessageHelper::SendHashUpdateNotification(app_id(), application_manager_); + if (!application_manager_.resume_controller().is_suspended()) { + MessageHelper::SendHashUpdateNotification(app_id(), application_manager_); + } else { + is_hash_changed_during_suspend_ = true; + } +} + +bool ApplicationImpl::IsHashChangedDuringSuspend() const { + return is_hash_changed_during_suspend_; +} + +void ApplicationImpl::SetHashChangedDuringSuspend(const bool state) { + is_hash_changed_during_suspend_ = state; } void ApplicationImpl::CleanupFiles() { @@ -1045,7 +1063,7 @@ void ApplicationImpl::set_hmi_level( usage_report_.RecordHmiStateChanged(new_hmi_level); } -const std::set<uint32_t>& ApplicationImpl::SubscribesIVI() const { +const VehicleInfoSubscriptions& ApplicationImpl::SubscribesIVI() const { return subscribed_vehicle_info_; } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 5feb29e51d..d7b9f4c054 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -354,11 +354,11 @@ struct IsApplication { }; std::vector<ApplicationSharedPtr> ApplicationManagerImpl::IviInfoUpdated( - VehicleDataType vehicle_info, int value) { + mobile_apis::VehicleDataType::eType vehicle_info, int value) { // Notify Policy Manager if available about info it's interested in, // i.e. odometer etc switch (vehicle_info) { - case ODOMETER: + case mobile_apis::VehicleDataType::VEHICLEDATA_ODOMETER: GetPolicyHandler().KmsChanged(value); break; default: @@ -1166,7 +1166,6 @@ void ApplicationManagerImpl::ReplaceHMIByMobileAppId( } } -// DEPRECATED bool ApplicationManagerImpl::StartNaviService( uint32_t app_id, protocol_handler::ServiceType service_type) { using namespace protocol_handler; @@ -1227,8 +1226,22 @@ bool ApplicationManagerImpl::StartNaviService( if (service_type == ServiceType::kMobileNav) { smart_objects::SmartObject converted_params(smart_objects::SmartType_Map); ConvertVideoParamsToSO(converted_params, params); + std::vector<std::string> rejected_params; + if (converted_params.keyExists(strings::codec) && + converted_params[strings::codec] == + hmi_apis::Common_VideoStreamingCodec::INVALID_ENUM) { + rejected_params.push_back(strings::codec); + } + if (converted_params.keyExists(strings::protocol) && + converted_params[strings::protocol] == + hmi_apis::Common_VideoStreamingProtocol::INVALID_ENUM) { + rejected_params.push_back(strings::protocol); + } - if (!converted_params.empty()) { + if (!rejected_params.empty()) { + OnStreamingConfigured(app_id, service_type, false, rejected_params); + return false; + } else if (!converted_params.empty()) { LOG4CXX_INFO(logger_, "Sending video configuration params"); #ifdef DEBUG MessageHelper::PrintSmartObject(converted_params); @@ -1248,6 +1261,8 @@ bool ApplicationManagerImpl::StartNaviService( } else { LOG4CXX_WARN(logger_, "Refused navi service by HMI level"); } + std::vector<std::string> empty; + OnStreamingConfigured(app_id, service_type, false, empty); return false; } @@ -1322,7 +1337,9 @@ void ApplicationManagerImpl::StopNaviService( app->StopStreaming(service_type); } -// DEPRECATED +// Suppress warning for deprecated method used within another deprecated method +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" bool ApplicationManagerImpl::OnServiceStartedCallback( const connection_handler::DeviceHandle& device_handle, const int32_t& session_key, @@ -1358,6 +1375,7 @@ bool ApplicationManagerImpl::OnServiceStartedCallback( } return false; } +#pragma GCC diagnostic pop void ApplicationManagerImpl::OnServiceStartedCallback( const connection_handler::DeviceHandle& device_handle, @@ -1390,8 +1408,7 @@ void ApplicationManagerImpl::OnServiceStartedCallback( type, ServiceType::kMobileNav, ServiceType::kAudio)) { if (app->is_navi() || app->mobile_projection_enabled()) { if (!StartNaviService(session_key, type, params)) { - connection_handler().NotifyServiceStartedResult( - session_key, false, empty); + LOG4CXX_WARN(logger_, "Starting Navigation service failed"); } return; } else { @@ -1611,11 +1628,11 @@ void ApplicationManagerImpl::SendMessageToMobile( (*message)[strings::params][strings::function_id].asUInt()); if (function_id == mobile_apis::FunctionID::RegisterAppInterfaceID && (*message)[strings::msg_params][strings::success].asBool()) { - const bool is_for_plugin = plugin_manager_.IsAppForPlugins(app); LOG4CXX_INFO(logger_, - "Registered app " << app->app_id() << " is " - << (is_for_plugin ? "" : "not ") - << "for plugins."); + "Registered app " + << app->app_id() << " is " + << (plugin_manager_.IsAppForPlugins(app) ? "" : "not ") + << "for plugins."); } #endif // SDL_REMOTE_CONTROL } else if (app) { @@ -2284,7 +2301,7 @@ bool ApplicationManagerImpl::ConvertSOtoMessage( } if (message.getElement(jhs::S_PARAMS).keyExists(strings::binary_data)) { - application_manager::BinaryData binaryData( + const application_manager::BinaryData binaryData( message.getElement(jhs::S_PARAMS) .getElement(strings::binary_data) .asBinary()); @@ -2891,7 +2908,7 @@ void ApplicationManagerImpl::UnregisterAllApplications() { } } if (is_ignition_off) { - resume_controller().OnSuspend(); + resume_controller().OnIgnitionOff(); } request_ctrl_.terminateAllHMIRequests(); } @@ -4043,21 +4060,12 @@ void ApplicationManagerImpl::ConvertVideoParamsToSO( const char* protocol = bson_object_get_string(obj, protocol_handler::strings::video_protocol); if (protocol != NULL) { - hmi_apis::Common_VideoStreamingProtocol::eType protocol_enum = - ConvertVideoProtocol(protocol); - if (protocol_enum != - hmi_apis::Common_VideoStreamingProtocol::INVALID_ENUM) { - output[strings::protocol] = protocol_enum; - } + output[strings::protocol] = ConvertVideoProtocol(protocol); } const char* codec = bson_object_get_string(obj, protocol_handler::strings::video_codec); if (codec != NULL) { - hmi_apis::Common_VideoStreamingCodec::eType codec_enum = - ConvertVideoCodec(codec); - if (codec_enum != hmi_apis::Common_VideoStreamingCodec::INVALID_ENUM) { - output[strings::codec] = codec_enum; - } + output[strings::codec] = ConvertVideoCodec(codec); } BsonElement* element = bson_object_get(obj, protocol_handler::strings::height); diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index 3f9a1d13b3..09aa4169e5 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -33,6 +33,7 @@ #include <algorithm> #include <string> #include "utils/macro.h" +#include "utils/make_shared.h" #include "application_manager/commands/command_request_impl.h" #include "application_manager/application_manager.h" #include "application_manager/message_helper.h" @@ -105,20 +106,29 @@ const std::string CreateInfoForUnsupportedResult( } bool CheckResultCode(const ResponseInfo& first, const ResponseInfo& second) { - if (first.is_ok && second.is_unsupported_resource && - second.interface_state == HmiInterfaces::STATE_NOT_AVAILABLE) { + if (first.is_ok && second.is_unsupported_resource) { + return true; + } + if (first.is_ok && second.is_not_used) { + return true; + } + if (first.is_ok && second.is_ok) { return true; } return false; } -bool IsResultCodeUnsupported(const ResponseInfo& first, - const ResponseInfo& second) { - return ((first.is_ok || first.is_invalid_enum) && - second.is_unsupported_resource) || - ((second.is_ok || second.is_invalid_enum) && - first.is_unsupported_resource) || - (first.is_unsupported_resource && second.is_unsupported_resource); +bool IsResultCodeWarning(const ResponseInfo& first, + const ResponseInfo& second) { + const bool first_is_ok_second_is_warn = + (first.is_ok || first.is_not_used) && + hmi_apis::Common_Result::WARNINGS == second.result_code; + + const bool both_warnings = + hmi_apis::Common_Result::WARNINGS == first.result_code && + hmi_apis::Common_Result::WARNINGS == second.result_code; + + return first_is_ok_second_is_warn || both_warnings; } struct DisallowedParamsInserter { @@ -146,6 +156,42 @@ struct DisallowedParamsInserter { mobile_apis::VehicleDataResultCode::eType code_; }; +ResponseInfo::ResponseInfo() + : result_code(hmi_apis::Common_Result::INVALID_ENUM) + , interface(HmiInterfaces::HMI_INTERFACE_INVALID_ENUM) + , interface_state(HmiInterfaces::STATE_NOT_RESPONSE) + , is_ok(false) + , is_unsupported_resource(false) + , is_not_used(false) {} + +ResponseInfo::ResponseInfo(const hmi_apis::Common_Result::eType result, + const HmiInterfaces::InterfaceID hmi_interface, + ApplicationManager& application_manager) + : result_code(result) + , interface(hmi_interface) + , interface_state(HmiInterfaces::STATE_NOT_RESPONSE) + , is_ok(false) + , is_unsupported_resource(false) + , is_not_used(false) { + using namespace helpers; + + interface_state = + application_manager.hmi_interfaces().GetInterfaceState(hmi_interface); + + is_ok = Compare<hmi_apis::Common_Result::eType, EQ, ONE>( + result_code, + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::WARNINGS, + hmi_apis::Common_Result::WRONG_LANGUAGE, + hmi_apis::Common_Result::RETRY, + hmi_apis::Common_Result::SAVED); + + is_not_used = hmi_apis::Common_Result::INVALID_ENUM == result_code; + + is_unsupported_resource = + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == result_code; +} + CommandRequestImpl::CommandRequestImpl(const MessageSharedPtr& message, ApplicationManager& application_manager) : CommandImpl(message, application_manager) @@ -193,7 +239,7 @@ void CommandRequestImpl::onTimeOut() { function_id(), correlation_id(), mobile_api::Result::GENERIC_ERROR); - + AddTimeOutComponentInfoToMessage(*response); application_manager_.ManageMobileCommand(response, ORIGIN_SDL); } @@ -204,6 +250,7 @@ void CommandRequestImpl::SendResponse( const mobile_apis::Result::eType& result_code, const char* info, const smart_objects::SmartObject* response_params) { + LOG4CXX_AUTO_TRACE(logger_); { sync_primitives::AutoLock auto_lock(state_lock_); if (kTimedOut == current_state_) { @@ -214,11 +261,9 @@ void CommandRequestImpl::SendResponse( current_state_ = kCompleted; } - smart_objects::SmartObjectSPtr result = new smart_objects::SmartObject; - if (!result) { - LOG4CXX_ERROR(logger_, "Memory allocation failed."); - return; - } + smart_objects::SmartObjectSPtr result = + utils::MakeShared<smart_objects::SmartObject>(); + smart_objects::SmartObject& response = *result; response[strings::params][strings::message_type] = MessageType::kResponse; @@ -755,6 +800,7 @@ bool CommandRequestImpl::HasDisallowedParams() const { bool CommandRequestImpl::PrepareResultForMobileResponse( hmi_apis::Common_Result::eType result_code, HmiInterfaces::InterfaceID interface) const { + LOG4CXX_AUTO_TRACE(logger_); using namespace helpers; if (Compare<hmi_apis::Common_Result::eType, EQ, ONE>( result_code, @@ -777,48 +823,9 @@ bool CommandRequestImpl::PrepareResultForMobileResponse( bool CommandRequestImpl::PrepareResultForMobileResponse( ResponseInfo& out_first, ResponseInfo& out_second) const { - using namespace helpers; - - out_first.is_ok = Compare<hmi_apis::Common_Result::eType, EQ, ONE>( - out_first.result_code, - hmi_apis::Common_Result::SUCCESS, - hmi_apis::Common_Result::WARNINGS, - hmi_apis::Common_Result::WRONG_LANGUAGE, - hmi_apis::Common_Result::RETRY, - hmi_apis::Common_Result::SAVED); - - out_second.is_ok = Compare<hmi_apis::Common_Result::eType, EQ, ONE>( - out_second.result_code, - hmi_apis::Common_Result::SUCCESS, - hmi_apis::Common_Result::WARNINGS, - hmi_apis::Common_Result::WRONG_LANGUAGE, - hmi_apis::Common_Result::RETRY, - hmi_apis::Common_Result::SAVED); - - out_first.is_invalid_enum = - hmi_apis::Common_Result::INVALID_ENUM == out_first.result_code; - - out_second.is_invalid_enum = - hmi_apis::Common_Result::INVALID_ENUM == out_second.result_code; - - out_first.is_unsupported_resource = - hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == out_first.result_code; - - out_second.is_unsupported_resource = - hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == out_second.result_code; - - out_first.interface_state = - application_manager_.hmi_interfaces().GetInterfaceState( - out_first.interface); - out_second.interface_state = - application_manager_.hmi_interfaces().GetInterfaceState( - out_second.interface); - - bool result = (out_first.is_ok && out_second.is_ok) || - (out_second.is_invalid_enum && out_first.is_ok) || - (out_first.is_invalid_enum && out_second.is_ok); - result = result || CheckResultCode(out_first, out_second); - result = result || CheckResultCode(out_second, out_first); + LOG4CXX_AUTO_TRACE(logger_); + bool result = CheckResultCode(out_first, out_second) || + CheckResultCode(out_second, out_first); return result; } @@ -835,25 +842,30 @@ void CommandRequestImpl::GetInfo( mobile_apis::Result::eType CommandRequestImpl::PrepareResultCodeForResponse( const ResponseInfo& first, const ResponseInfo& second) { + LOG4CXX_AUTO_TRACE(logger_); mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; - if (IsResultCodeUnsupported(first, second)) { - result_code = mobile_apis::Result::UNSUPPORTED_RESOURCE; - } else { - // If response contains erroneous result code SDL need return erroneus - // result code. - hmi_apis::Common_Result::eType first_result = - hmi_apis::Common_Result::INVALID_ENUM; - hmi_apis::Common_Result::eType second_result = - hmi_apis::Common_Result::INVALID_ENUM; - if (!first.is_unsupported_resource) { - first_result = first.result_code; - } - if (!second.is_unsupported_resource) { - second_result = second.result_code; - } - result_code = - MessageHelper::HMIToMobileResult(std::max(first_result, second_result)); - } + if (IsResultCodeUnsupported(first, second) || + IsResultCodeUnsupported(second, first)) { + return mobile_apis::Result::UNSUPPORTED_RESOURCE; + } + if (IsResultCodeWarning(first, second) || + IsResultCodeWarning(second, first)) { + return mobile_apis::Result::WARNINGS; + } + // If response contains erroneous result code SDL need return erroneus + // result code. + hmi_apis::Common_Result::eType first_result = + hmi_apis::Common_Result::INVALID_ENUM; + hmi_apis::Common_Result::eType second_result = + hmi_apis::Common_Result::INVALID_ENUM; + if (!first.is_unsupported_resource) { + first_result = first.result_code; + } + if (!second.is_unsupported_resource) { + second_result = second.result_code; + } + result_code = + MessageHelper::HMIToMobileResult(std::max(first_result, second_result)); return result_code; } @@ -862,6 +874,100 @@ const CommandParametersPermissions& CommandRequestImpl::parameters_permissions() return parameters_permissions_; } +void CommandRequestImpl::StartAwaitForInterface( + const HmiInterfaces::InterfaceID interface_id) { + sync_primitives::AutoLock lock(awaiting_response_interfaces_lock_); + awaiting_response_interfaces_.insert(interface_id); +} + +bool CommandRequestImpl::IsInterfaceAwaited( + const HmiInterfaces::InterfaceID& interface_id) const { + sync_primitives::AutoLock lock(awaiting_response_interfaces_lock_); + std::set<HmiInterfaces::InterfaceID>::const_iterator it = + awaiting_response_interfaces_.find(interface_id); + return (it != awaiting_response_interfaces_.end()); +} + +void CommandRequestImpl::EndAwaitForInterface( + const HmiInterfaces::InterfaceID& interface_id) { + sync_primitives::AutoLock lock(awaiting_response_interfaces_lock_); + std::set<HmiInterfaces::InterfaceID>::const_iterator it = + awaiting_response_interfaces_.find(interface_id); + if (it != awaiting_response_interfaces_.end()) { + awaiting_response_interfaces_.erase(it); + } else { + LOG4CXX_WARN(logger_, + "EndAwaitForInterface called on interface \ + which was not put into await state: " + << interface_id); + } +} + +bool CommandRequestImpl::IsResultCodeUnsupported( + const ResponseInfo& first, const ResponseInfo& second) const { + const bool first_ok_second_unsupported = + (first.is_ok || first.is_not_used) && second.is_unsupported_resource; + const bool both_unsupported = + first.is_unsupported_resource && second.is_unsupported_resource; + return first_ok_second_unsupported || both_unsupported; +} + +std::string GetComponentNameFromInterface( + const HmiInterfaces::InterfaceID& interface) { + switch (interface) { + case HmiInterfaces::HMI_INTERFACE_Buttons: + return "Buttons"; + case HmiInterfaces::HMI_INTERFACE_BasicCommunication: + return "BasicCommunication"; + case HmiInterfaces::HMI_INTERFACE_VR: + return "VR"; + case HmiInterfaces::HMI_INTERFACE_TTS: + return "TTS"; + case HmiInterfaces::HMI_INTERFACE_UI: + return "UI"; + case HmiInterfaces::HMI_INTERFACE_Navigation: + return "Navigation"; + case HmiInterfaces::HMI_INTERFACE_VehicleInfo: + return "VehicleInfo"; + case HmiInterfaces::HMI_INTERFACE_SDL: + return "SDL"; + default: + return "Unknown type"; + } +} + +const std::string InfoInterfaceSeparator( + const std::string& sum, const HmiInterfaces::InterfaceID container_value) { + return sum.empty() + ? GetComponentNameFromInterface(container_value) + : sum + ", " + GetComponentNameFromInterface(container_value); +} + +void CommandRequestImpl::AddTimeOutComponentInfoToMessage( + smart_objects::SmartObject& response) const { + using NsSmartDeviceLink::NsSmartObjects::SmartObject; + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(awaiting_response_interfaces_lock_); + if (awaiting_response_interfaces_.empty()) { + LOG4CXX_ERROR(logger_, "No interfaces awaiting, info param is empty"); + return; + } + + const std::string not_responding_interfaces_string = + std::accumulate(awaiting_response_interfaces_.begin(), + awaiting_response_interfaces_.end(), + std::string(""), + InfoInterfaceSeparator); + LOG4CXX_DEBUG( + logger_, + "Not responding interfaces string: " << not_responding_interfaces_string); + if (!not_responding_interfaces_string.empty()) { + const std::string component_info = + not_responding_interfaces_string + " component does not respond"; + response[strings::msg_params][strings::info] = component_info; + } +} + } // namespace commands } // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc b/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc index 80b1edb5bb..c6c550a474 100644 --- a/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc +++ b/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Ford Motor Company + * Copyright (c) 2017, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,3 +29,45 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ + +#include "application_manager/commands/hmi/basic_communication_on_awake_sdl.h" +#include "application_manager/message_helper.h" +#include "application_manager/resumption/resume_ctrl.h" + +namespace application_manager { + +namespace commands { + +OnAwakeSDLNotification::OnAwakeSDLNotification( + const MessageSharedPtr& message, ApplicationManager& application_manager) + : NotificationFromHMI(message, application_manager) {} + +OnAwakeSDLNotification::~OnAwakeSDLNotification() {} + +void OnAwakeSDLNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + if (!application_manager_.resume_controller().is_suspended()) { + return; + } + + { + DataAccessor<ApplicationSet> accessor = application_manager_.applications(); + ApplicationSetIt itBegin = accessor.GetData().begin(); + ApplicationSetIt itEnd = accessor.GetData().end(); + for (; itBegin != itEnd; ++itBegin) { + const ApplicationSharedPtr app = *itBegin; + if (app && app->IsHashChangedDuringSuspend()) { + MessageHelper::SendHashUpdateNotification(app->app_id(), + application_manager_); + app->SetHashChangedDuringSuspend(false); + } + } + } + + application_manager_.resume_controller().OnAwake(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc index 0bcb26df8a..42b8c64fc0 100644 --- a/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc +++ b/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc @@ -109,6 +109,8 @@ void AudioStartStreamRequest::on_event(const event_engine::Event& event) { logger_, "StartAudioStreamRequest aborted. Application can not stream"); } + application_manager_.TerminateRequest( + connection_key(), correlation_id(), function_id()); break; } if (hmi_apis::Common_Result::REJECTED == code) { @@ -125,15 +127,16 @@ void AudioStartStreamRequest::on_event(const event_engine::Event& event) { } void AudioStartStreamRequest::onTimeOut() { + LOG4CXX_AUTO_TRACE(logger_); RetryStartSession(); - - application_manager_.TerminateRequest( - connection_key(), correlation_id(), function_id()); } void AudioStartStreamRequest::RetryStartSession() { LOG4CXX_AUTO_TRACE(logger_); + application_manager_.TerminateRequest( + connection_key(), correlation_id(), function_id()); + ApplicationSharedPtr app = application_manager_.application_by_hmi_app(application_id()); if (!app) { @@ -156,10 +159,11 @@ void AudioStartStreamRequest::RetryStartSession() { } uint32_t curr_retry_number = app->audio_stream_retry_number(); + LOG4CXX_DEBUG( + logger_, "Retry number " << curr_retry_number << " of " << retry_number_); + if (curr_retry_number < retry_number_) { - LOG4CXX_DEBUG( - logger_, - "Send AudioStartStream retry. retry_number = " << curr_retry_number); + LOG4CXX_DEBUG(logger_, "Send AudioStartStream retry"); MessageHelper::SendAudioStartStream(app->app_id(), application_manager_); app->set_audio_stream_retry_number(++curr_retry_number); } else { diff --git a/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc index b06c69e703..ffc325b5e4 100644 --- a/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc +++ b/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc @@ -109,6 +109,8 @@ void NaviStartStreamRequest::on_event(const event_engine::Event& event) { logger_, "NaviStartStreamRequest aborted. Application can not stream"); } + application_manager_.TerminateRequest( + connection_key(), correlation_id(), function_id()); break; } if (hmi_apis::Common_Result::REJECTED == code) { @@ -125,15 +127,16 @@ void NaviStartStreamRequest::on_event(const event_engine::Event& event) { } void NaviStartStreamRequest::onTimeOut() { + LOG4CXX_AUTO_TRACE(logger_); RetryStartSession(); - - application_manager_.TerminateRequest( - connection_key(), correlation_id(), function_id()); } void NaviStartStreamRequest::RetryStartSession() { LOG4CXX_AUTO_TRACE(logger_); + application_manager_.TerminateRequest( + connection_key(), correlation_id(), function_id()); + ApplicationSharedPtr app = application_manager_.application_by_hmi_app(application_id()); if (!app) { @@ -156,10 +159,11 @@ void NaviStartStreamRequest::RetryStartSession() { } uint32_t curr_retry_number = app->video_stream_retry_number(); + LOG4CXX_DEBUG( + logger_, "Retry number " << curr_retry_number << " of " << retry_number_); + if (curr_retry_number < retry_number_) { - LOG4CXX_DEBUG( - logger_, - "Send NaviStartStream retry. retry_number = " << curr_retry_number); + LOG4CXX_DEBUG(logger_, "Send NaviStartStream retry"); MessageHelper::SendNaviStartStream(app->app_id(), application_manager_); app->set_video_stream_retry_number(++curr_retry_number); } else { diff --git a/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc b/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc index 07a95adcea..cb68b21263 100644 --- a/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc @@ -75,6 +75,7 @@ void OnExitAllApplicationsNotification::Run() { break; } case hmi_apis::Common_ApplicationsCloseReason::SUSPEND: { + application_manager_.resume_controller().OnSuspend(); SendOnSDLPersistenceComplete(); return; } diff --git a/src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc index 5383876714..bba7e2f3ff 100644 --- a/src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc @@ -53,8 +53,9 @@ void OnVIVehicleDataNotification::Run() { const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; if (msg_params.keyExists(strings::odometer)) { - application_manager_.IviInfoUpdated(ODOMETER, - msg_params[strings::odometer].asInt()); + application_manager_.IviInfoUpdated( + mobile_apis::VehicleDataType::VEHICLEDATA_ODOMETER, + msg_params[strings::odometer].asInt()); } SendNotificationToMobile(message_); diff --git a/src/components/application_manager/src/commands/hmi/rc_get_capabilities_response.cc b/src/components/application_manager/src/commands/hmi/rc_get_capabilities_response.cc index 3ff6edd125..82cbd7f128 100644 --- a/src/components/application_manager/src/commands/hmi/rc_get_capabilities_response.cc +++ b/src/components/application_manager/src/commands/hmi/rc_get_capabilities_response.cc @@ -45,9 +45,14 @@ void RCGetCapabilitiesResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities(); - - hmi_capabilities.set_rc_capability( - (*message_)[strings::msg_params][strings::rc_capability]); + bool capability_exists = + (*message_)[strings::msg_params].keyExists(strings::rc_capability); + + if (capability_exists) { + hmi_capabilities.set_rc_capability( + (*message_)[strings::msg_params][strings::rc_capability]); + } + hmi_capabilities.set_rc_supported(capability_exists); } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/rc_is_ready_request.cc b/src/components/application_manager/src/commands/hmi/rc_is_ready_request.cc index 71b803d198..a976ce1044 100644 --- a/src/components/application_manager/src/commands/hmi/rc_is_ready_request.cc +++ b/src/components/application_manager/src/commands/hmi/rc_is_ready_request.cc @@ -62,10 +62,14 @@ void RCIsReadyRequest::on_event(const event_engine::Event& event) { HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities(); hmi_capabilities.set_is_rc_cooperating(is_available); + if (!is_available) { + hmi_capabilities.set_rc_supported(false); + } + if (!CheckAvailabilityHMIInterfaces(application_manager_, HmiInterfaces::HMI_INTERFACE_RC)) { LOG4CXX_INFO(logger_, - "HmiInterfaces::HMI_INTERFACE_VR isn't available"); + "HmiInterfaces::HMI_INTERFACE_RC isn't available"); return; } SendMessageToHMI(); diff --git a/src/components/application_manager/src/commands/mobile/add_command_request.cc b/src/components/application_manager/src/commands/mobile/add_command_request.cc index c748ddcbb6..69948b8122 100644 --- a/src/components/application_manager/src/commands/mobile/add_command_request.cc +++ b/src/components/application_manager/src/commands/mobile/add_command_request.cc @@ -192,10 +192,12 @@ void AddCommandRequest::Run() { } if (send_ui_) { + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_AddCommand, &ui_msg_params, true); } if (send_vr_) { + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); SendHMIRequest(hmi_apis::FunctionID::VR_AddCommand, &vr_msg_params, true); } } @@ -317,6 +319,7 @@ void AddCommandRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_AddCommand: { LOG4CXX_INFO(logger_, "Received UI_AddCommand event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); is_ui_received_ = true; ui_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); @@ -328,6 +331,7 @@ void AddCommandRequest::on_event(const event_engine::Event& event) { } case hmi_apis::FunctionID::VR_AddCommand: { LOG4CXX_INFO(logger_, "Received VR_AddCommand event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); is_vr_received_ = true; vr_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); 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 a5491481dc..fe44e5a41f 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 @@ -94,6 +94,7 @@ void AddSubMenuRequest::Run() { (*message_)[strings::msg_params][strings::menu_name]; msg_params[strings::app_id] = app->app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_AddSubMenu, &msg_params, true); } @@ -103,6 +104,7 @@ void AddSubMenuRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_AddSubMenu: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc index b151990289..d5767690d7 100644 --- a/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc +++ b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc @@ -111,6 +111,7 @@ void AlertManeuverRequest::Run() { } pending_requests_.Add(hmi_apis::FunctionID::Navigation_AlertManeuver); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); SendHMIRequest( hmi_apis::FunctionID::Navigation_AlertManeuver, &msg_params, true); @@ -123,6 +124,7 @@ void AlertManeuverRequest::Run() { msg_params[hmi_request::speak_type] = hmi_apis::Common_MethodName::ALERT_MANEUVER; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); SendHMIRequest(hmi_apis::FunctionID::TTS_Speak, &msg_params, true); } } @@ -134,6 +136,7 @@ void AlertManeuverRequest::on_event(const event_engine::Event& event) { switch (event_id) { case hmi_apis::FunctionID::Navigation_AlertManeuver: { LOG4CXX_INFO(logger_, "Received Navigation_AlertManeuver event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); pending_requests_.Remove(event_id); navi_alert_maneuver_result_code_ = static_cast<hmi_apis::Common_Result::eType>( @@ -143,6 +146,7 @@ void AlertManeuverRequest::on_event(const event_engine::Event& event) { } case hmi_apis::FunctionID::TTS_Speak: { LOG4CXX_INFO(logger_, "Received TTS_Speak event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); pending_requests_.Remove(event_id); tts_speak_result_code_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); @@ -191,10 +195,13 @@ bool AlertManeuverRequest::PrepareResponseParameters( application_manager::commands::ResponseInfo navigation_alert_info( navi_alert_maneuver_result_code_, - HmiInterfaces::HMI_INTERFACE_Navigation); + HmiInterfaces::HMI_INTERFACE_Navigation, + application_manager_); application_manager::commands::ResponseInfo tts_alert_info( - tts_speak_result_code_, HmiInterfaces::HMI_INTERFACE_TTS); + tts_speak_result_code_, + HmiInterfaces::HMI_INTERFACE_TTS, + application_manager_); const bool result = PrepareResultForMobileResponse(navigation_alert_info, tts_alert_info); @@ -216,23 +223,42 @@ bool AlertManeuverRequest::PrepareResponseParameters( bool AlertManeuverRequest::IsWhiteSpaceExist() { LOG4CXX_AUTO_TRACE(logger_); - const char* str = NULL; + using smart_objects::SmartArray; if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) { - const smart_objects::SmartArray* tc_array = + const SmartArray* tts_chunks_arr = (*message_)[strings::msg_params][strings::tts_chunks].asArray(); - smart_objects::SmartArray::const_iterator it_tc = tc_array->begin(); - smart_objects::SmartArray::const_iterator it_tc_end = tc_array->end(); + SmartArray::const_iterator it_tts_chunk = tts_chunks_arr->begin(); - for (; it_tc != it_tc_end; ++it_tc) { - str = (*it_tc)[strings::text].asCharArray(); - if (strlen(str) && !CheckSyntax(str)) { + for (; it_tts_chunk != tts_chunks_arr->end(); ++it_tts_chunk) { + const char* tts_chunk_text = (*it_tts_chunk)[strings::text].asCharArray(); + if (strlen(tts_chunk_text) && !CheckSyntax(tts_chunk_text)) { LOG4CXX_ERROR(logger_, "Invalid tts_chunks syntax check failed"); return true; } } } + if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { + DCHECK_OR_RETURN( + (*message_)[strings::msg_params][strings::soft_buttons].getType() == + smart_objects::SmartType_Array, + true); + const smart_objects::SmartArray* soft_button_array = + (*message_)[strings::msg_params][strings::soft_buttons].asArray(); + + SmartArray::const_iterator it_soft_button = soft_button_array->begin(); + + for (; it_soft_button != soft_button_array->end(); ++it_soft_button) { + const char* soft_button_text = + (*it_soft_button)[strings::text].asCharArray(); + if (!CheckSyntax(soft_button_text)) { + LOG4CXX_ERROR(logger_, "Invalid soft_buttons syntax check failed"); + return true; + } + } + } + return false; } diff --git a/src/components/application_manager/src/commands/mobile/alert_request.cc b/src/components/application_manager/src/commands/mobile/alert_request.cc index 3288870b92..3c42e43767 100644 --- a/src/components/application_manager/src/commands/mobile/alert_request.cc +++ b/src/components/application_manager/src/commands/mobile/alert_request.cc @@ -116,18 +116,6 @@ void AlertRequest::Run() { } } -void AlertRequest::onTimeOut() { - LOG4CXX_AUTO_TRACE(logger_); - if (false == - (*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { - CommandRequestImpl::onTimeOut(); - return; - } - LOG4CXX_INFO(logger_, - "Default timeout ignored. " - "AlertRequest with soft buttons wait timeout on HMI side"); -} - void AlertRequest::on_event(const event_engine::Event& event) { LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); @@ -148,6 +136,7 @@ void AlertRequest::on_event(const event_engine::Event& event) { case hmi_apis::FunctionID::UI_Alert: { LOG4CXX_INFO(logger_, "Received UI_Alert event"); // Unsubscribe from event to avoid unwanted messages + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); unsubscribe_from_event(hmi_apis::FunctionID::UI_Alert); awaiting_ui_alert_response_ = false; HmiInterfaces::InterfaceState ui_interface_state = @@ -157,6 +146,7 @@ void AlertRequest::on_event(const event_engine::Event& event) { if (awaiting_tts_speak_response_ && HmiInterfaces::STATE_NOT_AVAILABLE != ui_interface_state) { awaiting_tts_stop_speaking_response_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); SendHMIRequest(hmi_apis::FunctionID::TTS_StopSpeaking, NULL, true); } alert_result_ = static_cast<hmi_apis::Common_Result::eType>( @@ -170,6 +160,7 @@ void AlertRequest::on_event(const event_engine::Event& event) { case hmi_apis::FunctionID::TTS_Speak: { LOG4CXX_INFO(logger_, "Received TTS_Speak event"); // Unsubscribe from event to avoid unwanted messages + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); unsubscribe_from_event(hmi_apis::FunctionID::TTS_Speak); awaiting_tts_speak_response_ = false; tts_speak_result_ = static_cast<hmi_apis::Common_Result::eType>( @@ -179,6 +170,7 @@ void AlertRequest::on_event(const event_engine::Event& event) { } case hmi_apis::FunctionID::TTS_StopSpeaking: { LOG4CXX_INFO(logger_, "Received TTS_StopSpeaking event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); // Unsubscribe from event to avoid unwanted messages unsubscribe_from_event(hmi_apis::FunctionID::TTS_StopSpeaking); awaiting_tts_stop_speaking_response_ = false; @@ -204,9 +196,11 @@ void AlertRequest::on_event(const event_engine::Event& event) { bool AlertRequest::PrepareResponseParameters( mobile_apis::Result::eType& result_code, std::string& info) { - ResponseInfo ui_alert_info(alert_result_, HmiInterfaces::HMI_INTERFACE_UI); + ResponseInfo ui_alert_info( + alert_result_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); ResponseInfo tts_alert_info(tts_speak_result_, - HmiInterfaces::HMI_INTERFACE_TTS); + HmiInterfaces::HMI_INTERFACE_TTS, + application_manager_); bool result = PrepareResultForMobileResponse(ui_alert_info, tts_alert_info); @@ -219,7 +213,7 @@ bool AlertRequest::PrepareResponseParameters( result = false; } result_code = mobile_apis::Result::WARNINGS; - if ((ui_alert_info.is_ok || ui_alert_info.is_invalid_enum) && + if ((ui_alert_info.is_ok || ui_alert_info.is_not_used) && tts_alert_info.is_unsupported_resource && HmiInterfaces::STATE_AVAILABLE == tts_alert_info.interface_state) { tts_response_info_ = "Unsupported phoneme type sent in a prompt"; @@ -230,6 +224,10 @@ bool AlertRequest::PrepareResponseParameters( result_code = PrepareResultCodeForResponse(ui_alert_info, tts_alert_info); info = MergeInfos( ui_alert_info, ui_response_info_, tts_alert_info, tts_response_info_); + // Mobile Alert request is successful when UI_Alert is successful + if (is_ui_alert_sent_ && !ui_alert_info.is_ok) { + return false; + } return result; } @@ -346,6 +344,7 @@ void AlertRequest::SendAlertRequest(int32_t app_id) { msg_params.keyExists(hmi_request::soft_buttons)) { awaiting_ui_alert_response_ = true; is_ui_alert_sent_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_Alert, &msg_params, true); } } @@ -370,6 +369,7 @@ void AlertRequest::SendSpeakRequest(int32_t app_id, } msg_params[strings::app_id] = app_id; msg_params[hmi_request::speak_type] = Common_MethodName::ALERT; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); SendHMIRequest(FunctionID::TTS_Speak, &msg_params, true); } diff --git a/src/components/application_manager/src/commands/mobile/change_registration_request.cc b/src/components/application_manager/src/commands/mobile/change_registration_request.cc index f1f3b93e24..f55767c723 100644 --- a/src/components/application_manager/src/commands/mobile/change_registration_request.cc +++ b/src/components/application_manager/src/commands/mobile/change_registration_request.cc @@ -66,6 +66,73 @@ ChangeRegistrationRequest::ChangeRegistrationRequest( ChangeRegistrationRequest::~ChangeRegistrationRequest() {} +void ChangeRegistrationRequest::SendVRRequest( + ApplicationSharedPtr app, smart_objects::SmartObject& msg_params) { + const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces(); + auto function = hmi_apis::FunctionID::VR_ChangeRegistration; + pending_requests_.Add(function); + smart_objects::SmartObject vr_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + vr_params[strings::language] = msg_params[strings::language]; + + vr_params[strings::app_id] = app->app_id(); + if (msg_params.keyExists(strings::vr_synonyms)) { + vr_params[strings::vr_synonyms] = msg_params[strings::vr_synonyms]; + app->set_vr_synonyms(msg_params[strings::vr_synonyms]); + } + StartAwaitForInterface(hmi_interfaces.GetInterfaceFromFunction(function)); + SendHMIRequest(function, &vr_params, true); +} + +void ChangeRegistrationRequest::SendTTSRequest( + ApplicationSharedPtr app, smart_objects::SmartObject& msg_params) { + const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces(); + auto function = hmi_apis::FunctionID::TTS_ChangeRegistration; + pending_requests_.Add(function); + + smart_objects::SmartObject tts_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + tts_params[strings::language] = msg_params[strings::language]; + + tts_params[strings::app_id] = app->app_id(); + if (msg_params.keyExists(strings::tts_name)) { + tts_params[strings::tts_name] = msg_params[strings::tts_name]; + app->set_tts_name(msg_params[strings::tts_name]); + } + StartAwaitForInterface(hmi_interfaces.GetInterfaceFromFunction(function)); + SendHMIRequest(function, &tts_params, true); +} + +void ChangeRegistrationRequest::SendUIRequest( + ApplicationSharedPtr app, + smart_objects::SmartObject& msg_params, + const int32_t hmi_language) { + const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces(); + auto function = hmi_apis::FunctionID::UI_ChangeRegistration; + pending_requests_.Add(function); + // UI processing + smart_objects::SmartObject ui_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + ui_params[strings::language] = hmi_language; + ui_params[strings::app_id] = app->app_id(); + if (msg_params.keyExists(strings::app_name)) { + ui_params[strings::app_name] = msg_params[strings::app_name]; + app->set_name(msg_params[strings::app_name].asCustomString()); + } + if (msg_params.keyExists(strings::ngn_media_screen_app_name)) { + ui_params[strings::ngn_media_screen_app_name] = + msg_params[strings::ngn_media_screen_app_name]; + app->set_ngn_media_screen_name( + msg_params[strings::ngn_media_screen_app_name]); + } + + StartAwaitForInterface(hmi_interfaces.GetInterfaceFromFunction(function)); + SendHMIRequest(function, &ui_params, true); +} + void ChangeRegistrationRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); using namespace smart_objects; @@ -111,53 +178,42 @@ void ChangeRegistrationRequest::Run() { return; } - pending_requests_.Add(hmi_apis::FunctionID::UI_ChangeRegistration); - pending_requests_.Add(hmi_apis::FunctionID::VR_ChangeRegistration); - pending_requests_.Add(hmi_apis::FunctionID::TTS_ChangeRegistration); + const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces(); - // UI processing - SmartObject ui_params = SmartObject(SmartType_Map); + const HmiInterfaces::InterfaceState vr_state = + hmi_interfaces.GetInterfaceState( + HmiInterfaces::InterfaceID::HMI_INTERFACE_VR); + const HmiInterfaces::InterfaceState ui_state = + hmi_interfaces.GetInterfaceState( + HmiInterfaces::InterfaceID::HMI_INTERFACE_UI); + const HmiInterfaces::InterfaceState tts_state = + hmi_interfaces.GetInterfaceState( + HmiInterfaces::InterfaceID::HMI_INTERFACE_TTS); - ui_params[strings::language] = hmi_language; - ui_params[strings::app_id] = app->app_id(); - if (msg_params.keyExists(strings::app_name)) { - ui_params[strings::app_name] = msg_params[strings::app_name]; - app->set_name(msg_params[strings::app_name].asCustomString()); + using helpers::Compare; + using helpers::EQ; + using helpers::ALL; + + if (Compare<HmiInterfaces::InterfaceState, EQ, ALL>( + HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE, + vr_state, + tts_state, + ui_state)) { + SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE); + return; } - if (msg_params.keyExists(strings::ngn_media_screen_app_name)) { - ui_params[strings::ngn_media_screen_app_name] = - msg_params[strings::ngn_media_screen_app_name]; - app->set_ngn_media_screen_name( - msg_params[strings::ngn_media_screen_app_name]); + if (HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE != vr_state) { + // VR processing + SendVRRequest(app, msg_params); } - - SendHMIRequest(hmi_apis::FunctionID::UI_ChangeRegistration, &ui_params, true); - - // VR processing - SmartObject vr_params = SmartObject(SmartType_Map); - - vr_params[strings::language] = msg_params[strings::language]; - - vr_params[strings::app_id] = app->app_id(); - if (msg_params.keyExists(strings::vr_synonyms)) { - vr_params[strings::vr_synonyms] = msg_params[strings::vr_synonyms]; - app->set_vr_synonyms(msg_params[strings::vr_synonyms]); + if (HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE != tts_state) { + // TTS processing + SendTTSRequest(app, msg_params); } - SendHMIRequest(hmi_apis::FunctionID::VR_ChangeRegistration, &vr_params, true); - - // TTS processing - SmartObject tts_params = SmartObject(SmartType_Map); - tts_params[strings::language] = msg_params[strings::language]; - - tts_params[strings::app_id] = app->app_id(); - if (msg_params.keyExists(strings::tts_name)) { - tts_params[strings::tts_name] = msg_params[strings::tts_name]; - app->set_tts_name(msg_params[strings::tts_name]); + if (HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE != ui_state) { + SendUIRequest(app, msg_params, hmi_language); } - - SendHMIRequest( - hmi_apis::FunctionID::TTS_ChangeRegistration, &tts_params, true); } void ChangeRegistrationRequest::on_event(const event_engine::Event& event) { @@ -169,6 +225,7 @@ void ChangeRegistrationRequest::on_event(const event_engine::Event& event) { switch (event_id) { case hmi_apis::FunctionID::UI_ChangeRegistration: { LOG4CXX_INFO(logger_, "Received UI_ChangeRegistration event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); pending_requests_.Remove(event_id); ui_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); @@ -177,6 +234,7 @@ void ChangeRegistrationRequest::on_event(const event_engine::Event& event) { } case hmi_apis::FunctionID::VR_ChangeRegistration: { LOG4CXX_INFO(logger_, "Received VR_ChangeRegistration event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); pending_requests_.Remove(event_id); vr_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); @@ -185,6 +243,7 @@ void ChangeRegistrationRequest::on_event(const event_engine::Event& event) { } case hmi_apis::FunctionID::TTS_ChangeRegistration: { LOG4CXX_INFO(logger_, "Received TTS_ChangeRegistration event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); pending_requests_.Remove(event_id); tts_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); @@ -295,12 +354,14 @@ bool ChangeRegistrationRequest::PrepareResponseParameters( hmi_interfaces.GetInterfaceState( HmiInterfaces::InterfaceID::HMI_INTERFACE_UI); - ResponseInfo ui_properties_info(ui_result_, HmiInterfaces::HMI_INTERFACE_UI); + ResponseInfo ui_properties_info( + ui_result_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); - ResponseInfo tts_properties_info(tts_result_, - HmiInterfaces::HMI_INTERFACE_TTS); + ResponseInfo tts_properties_info( + tts_result_, HmiInterfaces::HMI_INTERFACE_TTS, application_manager_); - ResponseInfo vr_properties_info(ui_result_, HmiInterfaces::HMI_INTERFACE_VR); + ResponseInfo vr_properties_info( + ui_result_, HmiInterfaces::HMI_INTERFACE_VR, application_manager_); bool result = ((!is_tts_ui_vr_unsupported) && is_tts_succeeded_unsupported && is_ui_succeeded_unsupported && is_vr_succeeded_unsupported); @@ -338,6 +399,9 @@ bool ChangeRegistrationRequest::PrepareResponseParameters( } result_code = MessageHelper::HMIToMobileResult( std::max(std::max(ui_result, vr_result), tts_result)); + if (mobile_api::Result::INVALID_ENUM == result_code) { + result_code = mobile_api::Result::UNSUPPORTED_RESOURCE; + } } const bool is_tts_state_available = 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 e1148bd126..20387ef230 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 @@ -287,6 +287,7 @@ void CreateInteractionChoiceSetRequest::SendVRAddCommandRequests( sync_primitives::AutoLock commands_lock(vr_commands_lock_); const uint32_t vr_cmd_id = msg_params[strings::cmd_id].asUInt(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); const uint32_t vr_corr_id = SendHMIRequest(hmi_apis::FunctionID::VR_AddCommand, &msg_params, true); @@ -356,6 +357,7 @@ void CreateInteractionChoiceSetRequest::on_event( uint32_t corr_id = static_cast<uint32_t>( message[strings::params][strings::correlation_id].asUInt()); if (event.id() == hmi_apis::FunctionID::VR_AddCommand) { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); { sync_primitives::AutoLock commands_lock(vr_commands_lock_); if (is_no_error) { @@ -376,6 +378,7 @@ void CreateInteractionChoiceSetRequest::onTimeOut() { if (!error_from_hmi_) { SendResponse(false, mobile_apis::Result::GENERIC_ERROR); } + CommandRequestImpl::onTimeOut(); DeleteChoices(); // We have to keep request alive until receive all responses from HMI diff --git a/src/components/application_manager/src/commands/mobile/delete_command_request.cc b/src/components/application_manager/src/commands/mobile/delete_command_request.cc index cfc8e12144..f894ed452c 100644 --- a/src/components/application_manager/src/commands/mobile/delete_command_request.cc +++ b/src/components/application_manager/src/commands/mobile/delete_command_request.cc @@ -104,12 +104,14 @@ void DeleteCommandRequest::Run() { is_vr_send_ = true; } if (is_ui_send_) { + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params, true); } if (is_vr_send_) { // VR params msg_params[strings::grammar_id] = application->get_grammar_id(); msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params, true); } } @@ -117,8 +119,10 @@ void DeleteCommandRequest::Run() { bool DeleteCommandRequest::PrepareResponseParameters( mobile_apis::Result::eType& result_code, std::string& info) { using namespace helpers; - ResponseInfo ui_delete_info(ui_result_, HmiInterfaces::HMI_INTERFACE_UI); - ResponseInfo vr_delete_info(vr_result_, HmiInterfaces::HMI_INTERFACE_VR); + ResponseInfo ui_delete_info( + ui_result_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); + ResponseInfo vr_delete_info( + vr_result_, HmiInterfaces::HMI_INTERFACE_VR, application_manager_); const bool result = PrepareResultForMobileResponse(ui_delete_info, vr_delete_info); @@ -143,6 +147,7 @@ void DeleteCommandRequest::on_event(const event_engine::Event& event) { const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { case hmi_apis::FunctionID::UI_DeleteCommand: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); is_ui_received_ = true; ui_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); @@ -153,6 +158,7 @@ void DeleteCommandRequest::on_event(const event_engine::Event& event) { break; } case hmi_apis::FunctionID::VR_DeleteCommand: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); is_vr_received_ = true; vr_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc b/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc index 21c7ecce90..09f3139245 100644 --- a/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc +++ b/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc @@ -74,6 +74,7 @@ void DeleteSubMenuRequest::Run() { msg_params[strings::menu_id] = (*message_)[strings::msg_params][strings::menu_id]; msg_params[strings::app_id] = app->app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_DeleteSubMenu, &msg_params, true); } @@ -143,6 +144,7 @@ void DeleteSubMenuRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_DeleteSubMenu: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc b/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc index 5c5d250026..7704d700f9 100644 --- a/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc +++ b/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc @@ -83,6 +83,7 @@ void DiagnosticMessageRequest::Run() { // Add app_id for HMI request (*message_)[strings::msg_params][strings::app_id] = app->app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage, &(*message_)[strings::msg_params], true); @@ -94,6 +95,7 @@ void DiagnosticMessageRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/dial_number_request.cc b/src/components/application_manager/src/commands/mobile/dial_number_request.cc index 64685afe2e..d0ab42e266 100644 --- a/src/components/application_manager/src/commands/mobile/dial_number_request.cc +++ b/src/components/application_manager/src/commands/mobile/dial_number_request.cc @@ -87,6 +87,7 @@ void DialNumberRequest::Run() { (*message_)[strings::msg_params][strings::number].asString(); msg_params[strings::app_id] = application->hmi_app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_BasicCommunication); SendHMIRequest( hmi_apis::FunctionID::BasicCommunication_DialNumber, &msg_params, true); } @@ -106,6 +107,7 @@ void DialNumberRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::BasicCommunication_DialNumber: { LOG4CXX_INFO(logger_, "Received DialNumber event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_BasicCommunication); result_code = CommandRequestImpl::GetMobileResultCode( static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt())); diff --git a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc index f67d1f2434..0bd83078e5 100644 --- a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc +++ b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc @@ -47,6 +47,7 @@ EndAudioPassThruRequest::~EndAudioPassThruRequest() {} void EndAudioPassThruRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_EndAudioPassThru, NULL, true); } @@ -56,6 +57,7 @@ void EndAudioPassThruRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_EndAudioPassThru: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asUInt()); diff --git a/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc b/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc index d98207c772..88fd07234a 100644 --- a/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc +++ b/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc @@ -72,6 +72,7 @@ void GetDTCsRequest::Run() { msg_params[strings::app_id] = app->app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_GetDTCs, &msg_params, true); } @@ -81,6 +82,7 @@ void GetDTCsRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::VehicleInfo_GetDTCs: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc index 25e2da3eb6..84c6e0ba7c 100644 --- a/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc +++ b/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc @@ -250,6 +250,7 @@ void GetVehicleDataRequest::Run() { } } if (msg_params.length() > min_length_msg_params) { + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); SendHMIRequest( hmi_apis::FunctionID::VehicleInfo_GetVehicleData, &msg_params, true); return; @@ -266,6 +267,7 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::VehicleInfo_GetVehicleData: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/get_way_points_request.cc b/src/components/application_manager/src/commands/mobile/get_way_points_request.cc index c313d74d4b..da4ce38646 100644 --- a/src/components/application_manager/src/commands/mobile/get_way_points_request.cc +++ b/src/components/application_manager/src/commands/mobile/get_way_points_request.cc @@ -31,6 +31,7 @@ void GetWayPointsRequest::Run() { msg_params = (*message_)[strings::msg_params]; msg_params[strings::app_id] = app->app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); SendHMIRequest(hmi_apis::FunctionID::Navigation_GetWayPoints, msg_params.empty() ? NULL : &msg_params, true); @@ -48,6 +49,7 @@ void GetWayPointsRequest::on_event(const event_engine::Event& event) { } case hmi_apis::FunctionID::Navigation_GetWayPoints: { LOG4CXX_INFO(logger_, "Received Navigation_GetWayPoints event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); const hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc index 9f5fd937f9..a05d41c098 100644 --- a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc +++ b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc @@ -47,8 +47,6 @@ namespace str = strings; PerformAudioPassThruRequest::PerformAudioPassThruRequest( const MessageSharedPtr& message, ApplicationManager& application_manager) : CommandRequestImpl(message, application_manager) - , awaiting_tts_speak_response_(false) - , awaiting_ui_response_(false) , result_tts_speak_(hmi_apis::Common_Result::INVALID_ENUM) , result_ui_(hmi_apis::Common_Result::INVALID_ENUM) { subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout); @@ -97,7 +95,7 @@ void PerformAudioPassThruRequest::Run() { // According with new implementation processing of UNSUPPORTE_RESOURCE // need set flag before sending to hmi - awaiting_ui_response_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); if ((*message_)[str::msg_params].keyExists(str::initial_prompt) && (0 < (*message_)[str::msg_params][str::initial_prompt].length())) { // In case TTS Speak, subscribe on notification @@ -119,7 +117,7 @@ void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_PerformAudioPassThru: { LOG4CXX_TRACE(logger_, "Received UI_PerformAudioPassThru"); - awaiting_ui_response_ = false; + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); result_ui_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asUInt()); @@ -142,7 +140,7 @@ void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) { result_tts_speak_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asUInt()); GetInfo(message, tts_info_); - awaiting_tts_speak_response_ = false; + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); const bool is_tts_speak_success_unsuported = Compare<hmi_apis::Common_Result::eType, EQ, ONE>( result_tts_speak_, @@ -179,36 +177,58 @@ void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) { return; } - std::string return_info; - mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; - const bool result = PrepareResponseParameters(result_code, return_info); + const ResponseParams response_params = PrepareResponseParameters(); - SendResponse(result, - result_code, - return_info.empty() ? NULL : return_info.c_str(), - &(message[strings::msg_params])); + SendResponse( + response_params.success, + response_params.result_code, + response_params.info.empty() ? NULL : response_params.info.c_str(), + &(message[strings::msg_params])); } -bool PerformAudioPassThruRequest::PrepareResponseParameters( - mobile_apis::Result::eType& result_code, std::string& info) { +const PerformAudioPassThruRequest::ResponseParams& +PerformAudioPassThruRequest::PrepareResponseParameters() { LOG4CXX_AUTO_TRACE(logger_); - ResponseInfo ui_perform_info(result_ui_, HmiInterfaces::HMI_INTERFACE_UI); + ResponseInfo ui_perform_info( + result_ui_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); ResponseInfo tts_perform_info(result_tts_speak_, - HmiInterfaces::HMI_INTERFACE_TTS); - const bool result = - PrepareResultForMobileResponse(ui_perform_info, tts_perform_info); + HmiInterfaces::HMI_INTERFACE_TTS, + application_manager_); + // Note(dtrunov): According to requirment "WARNINGS, success:true on getting + // UNSUPPORTED_RESOURCE for "ttsChunks" if (ui_perform_info.is_ok && tts_perform_info.is_unsupported_resource && HmiInterfaces::STATE_AVAILABLE == tts_perform_info.interface_state) { - result_code = mobile_apis::Result::WARNINGS; + response_params_.result_code = mobile_apis::Result::WARNINGS; tts_info_ = "Unsupported phoneme type sent in a prompt"; - info = MergeInfos(ui_perform_info, ui_info_, tts_perform_info, tts_info_); - return result; + response_params_.info = + MergeInfos(ui_perform_info, ui_info_, tts_perform_info, tts_info_); + response_params_.success = true; + return response_params_; } - result_code = PrepareResultCodeForResponse(ui_perform_info, tts_perform_info); - info = MergeInfos(ui_perform_info, ui_info_, tts_perform_info, tts_info_); - return result; + + response_params_.success = + PrepareResultForMobileResponse(ui_perform_info, tts_perform_info); + 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; + } + response_params_.info = + MergeInfos(ui_perform_info, ui_info_, tts_perform_info, tts_info_); + + return response_params_; +} + +bool PerformAudioPassThruRequest::PrepareResponseParameters( + mobile_apis::Result::eType& result_code, std::string& info) { + LOG4CXX_AUTO_TRACE(logger_); + NOTREACHED(); + return false; } void PerformAudioPassThruRequest::SendSpeakRequest() { @@ -229,7 +249,7 @@ void PerformAudioPassThruRequest::SendSpeakRequest() { // app_id msg_params[strings::app_id] = connection_key(); msg_params[hmi_request::speak_type] = Common_MethodName::AUDIO_PASS_THRU; - awaiting_tts_speak_response_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); SendHMIRequest(FunctionID::TTS_Speak, &msg_params, true); } @@ -273,6 +293,7 @@ void PerformAudioPassThruRequest::SendPerformAudioPassThruRequest() { msg_params[str::mute_audio] = true; } + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest( hmi_apis::FunctionID::UI_PerformAudioPassThru, &msg_params, true); } @@ -353,16 +374,56 @@ void PerformAudioPassThruRequest::FinishTTSSpeak() { LOG4CXX_DEBUG(logger_, "Stop AudioPassThru."); application_manager_.StopAudioPassThru(connection_key()); } - if (!awaiting_tts_speak_response_) { + if (!IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_TTS)) { LOG4CXX_WARN(logger_, "TTS Speak is inactive."); return; } SendHMIRequest(hmi_apis::FunctionID::TTS_StopSpeaking, NULL); } +PerformAudioPassThruRequest::AudioPassThruResults +PerformAudioPassThruRequest::PrepareAudioPassThruResultCodeForResponse( + const ResponseInfo& ui_response, const ResponseInfo& tts_response) { + mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; + + hmi_apis::Common_Result::eType common_result = + hmi_apis::Common_Result::INVALID_ENUM; + const hmi_apis::Common_Result::eType ui_result = ui_response.result_code; + 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)) { + 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) { + common_result = hmi_apis::Common_Result::WARNINGS; + result = true; + } else if (ui_result == hmi_apis::Common_Result::INVALID_ENUM) { + common_result = tts_result; + } else { + common_result = ui_result; + } + result_code = MessageHelper::HMIToMobileResult(common_result); + return std::make_pair(result_code, result); +} + bool PerformAudioPassThruRequest::IsWaitingHMIResponse() { LOG4CXX_AUTO_TRACE(logger_); - return awaiting_tts_speak_response_ || awaiting_ui_response_; + return IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_TTS) || + IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_UI); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc b/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc index 007440e8e6..68940158b9 100644 --- a/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc +++ b/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc @@ -143,11 +143,10 @@ void PerformInteractionRequest::Run() { } } - if (choice_set_id_list_length && - (!CheckChoiceIDFromRequest( - app, - choice_set_id_list_length, - msg_params[strings::interaction_choice_set_id_list]))) { + if (!CheckChoiceIDFromRequest( + app, + choice_set_id_list_length, + msg_params[strings::interaction_choice_set_id_list])) { LOG4CXX_ERROR(logger_, "PerformInteraction has choice sets with " "duplicated IDs or application does not have choice sets"); @@ -227,6 +226,7 @@ void PerformInteractionRequest::on_event(const event_engine::Event& event) { } case hmi_apis::FunctionID::UI_PerformInteraction: { LOG4CXX_DEBUG(logger_, "Received UI_PerformInteraction event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); ui_response_received_ = true; unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction); ui_result_code_ = static_cast<hmi_apis::Common_Result::eType>( @@ -237,6 +237,7 @@ void PerformInteractionRequest::on_event(const event_engine::Event& event) { } case hmi_apis::FunctionID::VR_PerformInteraction: { LOG4CXX_DEBUG(logger_, "Received VR_PerformInteraction"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); vr_response_received_ = true; unsubscribe_from_event(hmi_apis::FunctionID::VR_PerformInteraction); vr_result_code_ = static_cast<hmi_apis::Common_Result::eType>( @@ -392,14 +393,14 @@ void PerformInteractionRequest::ProcessUIResponse( if (result) { if (is_pi_warning) { ui_result_code_ = hmi_apis::Common_Result::WARNINGS; - ui_info_ = "Unsupported phoneme type was sent in an item"; + ui_info_ = message[strings::msg_params][strings::info].asString(); if (message.keyExists(strings::params) && message[strings::params].keyExists(strings::data)) { msg_params = message[strings::params][strings::data]; } } else if (is_pi_unsupported) { ui_result_code_ = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; - ui_info_ = "Unsupported phoneme type was sent in an item"; + ui_info_ = message[strings::msg_params][strings::info].asString(); } else if (message.keyExists(strings::msg_params)) { msg_params = message[strings::msg_params]; } @@ -503,6 +504,7 @@ void PerformInteractionRequest::SendUIPerformInteractionRequest( (*message_)[strings::msg_params][hmi_request::interaction_layout] .asInt(); } + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest( hmi_apis::FunctionID::UI_PerformInteraction, &msg_params, true); } @@ -595,6 +597,7 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( msg_params[strings::timeout] = default_timeout_; } msg_params[strings::app_id] = app->app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); SendHMIRequest( hmi_apis::FunctionID::VR_PerformInteraction, &msg_params, true); } @@ -926,10 +929,10 @@ void PerformInteractionRequest::SendBothModeResponse( LOG4CXX_AUTO_TRACE(logger_); mobile_apis::Result::eType perform_interaction_result_code = mobile_apis::Result::INVALID_ENUM; - ResponseInfo ui_perform_info(ui_result_code_, - HmiInterfaces::HMI_INTERFACE_UI); - ResponseInfo vr_perform_info(vr_result_code_, - HmiInterfaces::HMI_INTERFACE_VR); + ResponseInfo ui_perform_info( + ui_result_code_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); + ResponseInfo vr_perform_info( + vr_result_code_, HmiInterfaces::HMI_INTERFACE_VR, application_manager_); const bool result = PrepareResultForMobileResponse(ui_perform_info, vr_perform_info); perform_interaction_result_code = diff --git a/src/components/application_manager/src/commands/mobile/read_did_request.cc b/src/components/application_manager/src/commands/mobile/read_did_request.cc index 0bf747bde3..c51f545e7e 100644 --- a/src/components/application_manager/src/commands/mobile/read_did_request.cc +++ b/src/components/application_manager/src/commands/mobile/read_did_request.cc @@ -87,6 +87,7 @@ void ReadDIDRequest::Run() { (*message_)[strings::msg_params][strings::ecu_name]; msg_params[strings::did_location] = (*message_)[strings::msg_params][strings::did_location]; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_ReadDID, &msg_params, true); } @@ -97,6 +98,7 @@ void ReadDIDRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::VehicleInfo_ReadDID: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index 74bc0c032e..1a60537874 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc @@ -217,9 +217,6 @@ void RegisterAppInterfaceRequest::Run() { return; } - const std::string mobile_app_id = - (*message_)[strings::msg_params][strings::app_id].asString(); - ApplicationSharedPtr application = application_manager_.application(connection_key()); @@ -231,7 +228,13 @@ void RegisterAppInterfaceRequest::Run() { const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; - const std::string& policy_app_id = msg_params[strings::app_id].asString(); + const std::string policy_app_id = msg_params[strings::app_id].asString(); + std::string new_policy_app_id = policy_app_id; + std::transform(policy_app_id.begin(), + policy_app_id.end(), + new_policy_app_id.begin(), + ::tolower); + (*message_)[strings::msg_params][strings::app_id] = new_policy_app_id; if (application_manager_.IsApplicationForbidden(connection_key(), policy_app_id)) { @@ -494,6 +497,8 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params, hmi_capabilities.phone_call_supported(); response_params[strings::hmi_capabilities][strings::video_streaming] = hmi_capabilities.video_streaming_supported(); + response_params[strings::hmi_capabilities][strings::remote_control] = + hmi_capabilities.rc_supported(); } void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() { 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 713d50e190..a7c2db0e65 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 @@ -46,10 +46,6 @@ namespace commands { ResetGlobalPropertiesRequest::ResetGlobalPropertiesRequest( const MessageSharedPtr& message, ApplicationManager& application_manager) : CommandRequestImpl(message, application_manager) - , is_ui_send_(false) - , is_tts_send_(false) - , is_ui_received_(false) - , is_tts_received_(false) , ui_result_(hmi_apis::Common_Result::INVALID_ENUM) , tts_result_(hmi_apis::Common_Result::INVALID_ENUM) {} @@ -111,11 +107,11 @@ void ResetGlobalPropertiesRequest::Run() { if (vr_help_title_items || menu_name || menu_icon || is_key_board_properties) { - is_ui_send_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); } if (timeout_prompt || helpt_promt) { - is_tts_send_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); } app->set_reset_global_properties_active(true); @@ -245,7 +241,7 @@ void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_SetGlobalProperties: { LOG4CXX_INFO(logger_, "Received UI_SetGlobalProperties event"); - is_ui_received_ = true; + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); ui_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); GetInfo(message, ui_response_info_); @@ -253,7 +249,7 @@ void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { } case hmi_apis::FunctionID::TTS_SetGlobalProperties: { LOG4CXX_INFO(logger_, "Received TTS_SetGlobalProperties event"); - is_tts_received_ = true; + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); tts_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); GetInfo(message, tts_response_info_); @@ -292,9 +288,10 @@ bool ResetGlobalPropertiesRequest::PrepareResponseParameters( using namespace helpers; bool result = false; - ResponseInfo ui_properties_info(ui_result_, HmiInterfaces::HMI_INTERFACE_UI); - ResponseInfo tts_properties_info(tts_result_, - HmiInterfaces::HMI_INTERFACE_TTS); + ResponseInfo ui_properties_info( + ui_result_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); + ResponseInfo tts_properties_info( + tts_result_, HmiInterfaces::HMI_INTERFACE_TTS, application_manager_); HmiInterfaces::InterfaceState tts_interface_state = application_manager_.hmi_interfaces().GetInterfaceState( @@ -321,7 +318,8 @@ bool ResetGlobalPropertiesRequest::PrepareResponseParameters( } bool ResetGlobalPropertiesRequest::IsPendingResponseExist() { - return is_ui_send_ != is_ui_received_ || is_tts_send_ != is_tts_received_; + return IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_TTS) || + IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_UI); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc b/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc index 0c770953fe..b0b2d5f464 100644 --- a/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc +++ b/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc @@ -109,7 +109,7 @@ void ScrollableMessageRequest::Run() { MessageHelper::SubscribeApplicationToSoftButton( (*message_)[strings::msg_params], app, function_id()); } - + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_ScrollableMessage, &msg_params, true); } @@ -126,6 +126,7 @@ void ScrollableMessageRequest::on_event(const event_engine::Event& event) { } case hmi_apis::FunctionID::UI_ScrollableMessage: { LOG4CXX_INFO(logger_, "Received UI_ScrollableMessage event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( diff --git a/src/components/application_manager/src/commands/mobile/send_location_request.cc b/src/components/application_manager/src/commands/mobile/send_location_request.cc index 9ec4ca3fcc..54664a8771 100644 --- a/src/components/application_manager/src/commands/mobile/send_location_request.cc +++ b/src/components/application_manager/src/commands/mobile/send_location_request.cc @@ -125,6 +125,7 @@ void SendLocationRequest::Run() { SmartObject request_msg_params = SmartObject(smart_objects::SmartType_Map); request_msg_params = msg_params; request_msg_params[strings::app_id] = app->hmi_app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); SendHMIRequest( hmi_apis::FunctionID::Navigation_SendLocation, &request_msg_params, true); } @@ -135,6 +136,7 @@ void SendLocationRequest::on_event(const event_engine::Event& event) { const smart_objects::SmartObject& message = event.smart_object(); if (hmi_apis::FunctionID::Navigation_SendLocation == event.id()) { LOG4CXX_INFO(logger_, "Received Navigation_SendLocation event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); const Common_Result::eType result_code = static_cast<Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); std::string response_info; diff --git a/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc b/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc index 5afddfb4d0..ee544e956a 100644 --- a/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc +++ b/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc @@ -114,7 +114,7 @@ void SetAppIconRequest::Run() { // for further use in on_event function (*message_)[strings::msg_params][strings::sync_file_name] = msg_params[strings::sync_file_name]; - + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_SetAppIcon, &msg_params, true); } @@ -242,6 +242,7 @@ void SetAppIconRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_SetAppIcon: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc b/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc index 984690384a..38b62ce731 100644 --- a/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc +++ b/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc @@ -58,6 +58,7 @@ void SetDisplayLayoutRequest::Run() { } (*message_)[strings::msg_params][strings::app_id] = app->app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_SetDisplayLayout, &((*message_)[strings::msg_params]), true); @@ -70,6 +71,7 @@ void SetDisplayLayoutRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_SetDisplayLayout: { LOG4CXX_INFO(logger_, "Received UI_SetDisplayLayout event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); 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 096c4ed783..e811f5d154 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 @@ -229,6 +229,7 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_SetGlobalProperties: { LOG4CXX_INFO(logger_, "Received UI_SetGlobalProperties event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); is_ui_received_ = true; ui_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); @@ -237,6 +238,7 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { } case hmi_apis::FunctionID::TTS_SetGlobalProperties: { LOG4CXX_INFO(logger_, "Received TTS_SetGlobalProperties event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); is_tts_received_ = true; tts_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); @@ -277,10 +279,11 @@ bool SetGlobalPropertiesRequest::PrepareResponseParameters( LOG4CXX_AUTO_TRACE(logger_); using namespace helpers; - ResponseInfo ui_properties_info(ui_result_, HmiInterfaces::HMI_INTERFACE_UI); + ResponseInfo ui_properties_info( + ui_result_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); - ResponseInfo tts_properties_info(tts_result_, - HmiInterfaces::HMI_INTERFACE_TTS); + ResponseInfo tts_properties_info( + tts_result_, HmiInterfaces::HMI_INTERFACE_TTS, application_manager_); const bool result = PrepareResultForMobileResponse(ui_properties_info, tts_properties_info); if (result && @@ -397,6 +400,7 @@ void SetGlobalPropertiesRequest::SendTTSRequest( const smart_objects::SmartObject& params, bool use_events) { LOG4CXX_AUTO_TRACE(logger_); is_tts_send_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); SendHMIRequest( hmi_apis::FunctionID::TTS_SetGlobalProperties, ¶ms, use_events); } @@ -405,6 +409,7 @@ void SetGlobalPropertiesRequest::SendUIRequest( const smart_objects::SmartObject& params, bool use_events) { LOG4CXX_AUTO_TRACE(logger_); is_ui_send_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest( hmi_apis::FunctionID::UI_SetGlobalProperties, ¶ms, use_events); } diff --git a/src/components/application_manager/src/commands/mobile/set_icon_request.cc b/src/components/application_manager/src/commands/mobile/set_icon_request.cc index 85f34aead9..037de54456 100644 --- a/src/components/application_manager/src/commands/mobile/set_icon_request.cc +++ b/src/components/application_manager/src/commands/mobile/set_icon_request.cc @@ -95,7 +95,7 @@ void SetIconRequest::Run() { // for further use in on_event function (*message_)[strings::msg_params][strings::sync_file_name] = msg_params[strings::sync_file_name]; - + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_SetAppIcon, &msg_params, true); } @@ -105,6 +105,7 @@ void SetIconRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_SetAppIcon: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); mobile_apis::Result::eType result_code = static_cast<mobile_apis::Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc b/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc index 1e0a00318d..54727abe01 100644 --- a/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc +++ b/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc @@ -71,6 +71,7 @@ void SetMediaClockRequest::Run() { // copy entirely msg msg_params = (*message_)[strings::msg_params]; msg_params[strings::app_id] = app->app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest( hmi_apis::FunctionID::UI_SetMediaClockTimer, &msg_params, true); @@ -85,6 +86,7 @@ void SetMediaClockRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_SetMediaClockTimer: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc b/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc index b1cc40009d..42bfea4864 100644 --- a/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc +++ b/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc @@ -172,6 +172,7 @@ void ShowConstantTBTRequest::Run() { } app->set_tbt_show_command(msg_params); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); SendHMIRequest( hmi_apis::FunctionID::Navigation_ShowConstantTBT, &msg_params, true); } @@ -184,6 +185,7 @@ void ShowConstantTBTRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::Navigation_ShowConstantTBT: { LOG4CXX_INFO(logger_, "Received Navigation_ShowConstantTBT event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); const Common_Result::eType result_code = static_cast<Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/show_request.cc b/src/components/application_manager/src/commands/mobile/show_request.cc index 5b8e98d7ea..ad598efc1d 100644 --- a/src/components/application_manager/src/commands/mobile/show_request.cc +++ b/src/components/application_manager/src/commands/mobile/show_request.cc @@ -263,6 +263,7 @@ void ShowRequest::Run() { (*message_)[strings::msg_params][strings::custom_presets]; } + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_Show, &msg_params, true); MessageSharedPtr persistentData = new smart_objects::SmartObject(msg_params); @@ -278,6 +279,7 @@ void ShowRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_Show: { LOG4CXX_DEBUG(logger_, "Received UI_Show event."); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); std::string response_info; hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( diff --git a/src/components/application_manager/src/commands/mobile/slider_request.cc b/src/components/application_manager/src/commands/mobile/slider_request.cc index 054d0ec16d..f98869b08f 100644 --- a/src/components/application_manager/src/commands/mobile/slider_request.cc +++ b/src/components/application_manager/src/commands/mobile/slider_request.cc @@ -107,6 +107,7 @@ void SliderRequest::Run() { msg_params[strings::timeout] = default_timeout_; } + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_Slider, &msg_params, true); } @@ -132,7 +133,7 @@ void SliderRequest::on_event(const event_engine::Event& event) { } LOG4CXX_DEBUG(logger_, "Received UI_Slider event"); - + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); const Common_Result::eType response_code = static_cast<Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/speak_request.cc b/src/components/application_manager/src/commands/mobile/speak_request.cc index 6cbb762102..1954cde181 100644 --- a/src/components/application_manager/src/commands/mobile/speak_request.cc +++ b/src/components/application_manager/src/commands/mobile/speak_request.cc @@ -72,6 +72,7 @@ void SpeakRequest::Run() { (*message_)[strings::msg_params][strings::app_id] = app->app_id(); (*message_)[strings::msg_params][hmi_request::speak_type] = hmi_apis::Common_MethodName::SPEAK; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); SendHMIRequest(hmi_apis::FunctionID::TTS_Speak, &message_->getElement(strings::msg_params), true); @@ -82,7 +83,7 @@ void SpeakRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::TTS_Speak: { LOG4CXX_INFO(logger_, "Received TTS_Speak event"); - + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); ProcessTTSSpeakResponse(event.smart_object()); break; } 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 fc839a43f4..28cf4c754c 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 @@ -149,6 +149,7 @@ void SubscribeVehicleDataRequest::Run() { ++it) SendHMIRequest(it->func_id, &msg_params, true); #else + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData, &msg_params, true); @@ -165,7 +166,7 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { LOG4CXX_ERROR(logger_, "Received unknown event."); return; } - + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); ApplicationSharedPtr app = application_manager_.application(CommandRequestImpl::connection_key()); @@ -250,6 +251,15 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { result_code = mobile_apis::Result::IGNORED; response_info = "Already subscribed on some provided VehicleData."; } + + if (!vi_waiting_for_subscribe_.empty()) { + LOG4CXX_DEBUG(logger_, "Subscribing to all pending VehicleData"); + VehicleInfoSubscriptions::const_iterator key = + vi_waiting_for_subscribe_.begin(); + for (; key != vi_waiting_for_subscribe_.end(); ++key) { + app->SubscribeToIVI(*key); + } + } } UnsubscribeFailedSubscriptions(app, message[strings::msg_params]); @@ -276,20 +286,33 @@ void SubscribeVehicleDataRequest::AddAlreadySubscribedVI( smart_objects::SmartObject& msg_params) const { LOG4CXX_AUTO_TRACE(logger_); using namespace mobile_apis; + auto vi_to_string = + [](const mobile_apis::VehicleDataType::eType vehicle_data) { + for (auto& vi_str_to_int_pair : MessageHelper::vehicle_data()) { + if (vehicle_data == vi_str_to_int_pair.second) { + return vi_str_to_int_pair.first; + } + } + return std::string(); + }; + VehicleInfoSubscriptions::const_iterator it_same_app = vi_already_subscribed_by_this_app_.begin(); for (; vi_already_subscribed_by_this_app_.end() != it_same_app; ++it_same_app) { - msg_params[*it_same_app][strings::result_code] = + msg_params[vi_to_string(*it_same_app)][strings::result_code] = VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED; + msg_params[vi_to_string(*it_same_app)][strings::data_type] = *it_same_app; } VehicleInfoSubscriptions::const_iterator it_another_app = vi_already_subscribed_by_another_apps_.begin(); for (; vi_already_subscribed_by_another_apps_.end() != it_another_app; ++it_another_app) { - msg_params[*it_another_app][strings::result_code] = + msg_params[vi_to_string(*it_another_app)][strings::result_code] = VehicleDataResultCode::VDRC_SUCCESS; + msg_params[vi_to_string(*it_another_app)][strings::data_type] = + *it_another_app; } } @@ -366,7 +389,7 @@ void SubscribeVehicleDataRequest::CheckVISubscribtions( ++items_to_subscribe; } if (!is_interface_not_available && is_key_enabled) { - VehicleDataType key_type = it->second; + mobile_apis::VehicleDataType::eType key_type = it->second; if (app->IsSubscribedToIVI(key_type)) { LOG4CXX_DEBUG(logger_, "App with connection key " @@ -407,12 +430,13 @@ void SubscribeVehicleDataRequest::CheckVISubscribtions( out_request_params[key_name] = is_key_enabled; - if (app->SubscribeToIVI(static_cast<uint32_t>(key_type))) { + if (is_key_enabled) { + vi_waiting_for_subscribe_.insert(key_type); LOG4CXX_DEBUG( logger_, "App with connection key " << connection_key() - << " have been subscribed for VehicleDataType: " << key_type); + << " will be subscribed for VehicleDataType: " << key_type); ++subscribed_items; } } diff --git a/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc index 0e0d760228..965741edf7 100644 --- a/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc +++ b/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc @@ -36,6 +36,7 @@ void SubscribeWayPointsRequest::Run() { return; } + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); SendHMIRequest( hmi_apis::FunctionID::Navigation_SubscribeWayPoints, NULL, true); } @@ -47,6 +48,7 @@ void SubscribeWayPointsRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::Navigation_SubscribeWayPoints: { LOG4CXX_INFO(logger_, "Received Navigation_SubscribeWayPoints event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); const hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/system_request.cc b/src/components/application_manager/src/commands/mobile/system_request.cc index e4706441ef..fe38b93732 100644 --- a/src/components/application_manager/src/commands/mobile/system_request.cc +++ b/src/components/application_manager/src/commands/mobile/system_request.cc @@ -535,19 +535,8 @@ void SystemRequest::Run() { if (!file || !file->is_download_complete || !file_system::MoveFile(app_full_file_path, file_dst_path)) { LOG4CXX_DEBUG(logger_, "Binary data not found."); - - std::string origin_file_name; - if ((*message_)[strings::msg_params].keyExists(strings::file_name)) { - origin_file_name = - (*message_)[strings::msg_params][strings::file_name].asString(); - } - if (!(mobile_apis::RequestType::HTTP == request_type && - 0 == origin_file_name.compare(kIVSU))) { - LOG4CXX_DEBUG(logger_, "Binary data required. Invalid data"); - SendResponse(false, mobile_apis::Result::INVALID_DATA); - return; - } - LOG4CXX_DEBUG(logger_, "IVSU does not require binary data. Continue"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; } processing_file_ = file_dst_path; } @@ -598,6 +587,7 @@ void SystemRequest::Run() { msg_params[strings::request_type] = (*message_)[strings::msg_params][strings::request_type]; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_BasicCommunication); SendHMIRequest(hmi_apis::FunctionID::BasicCommunication_SystemRequest, &msg_params, true); @@ -611,6 +601,7 @@ void SystemRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::BasicCommunication_SystemRequest: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_BasicCommunication); mobile_apis::Result::eType result_code = GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asUInt())); diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc index fa3a9ad400..f7317d72f9 100644 --- a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc +++ b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc @@ -134,7 +134,7 @@ void UnsubscribeVehicleDataRequest::Run() { if (is_key_enabled) { ++items_to_unsubscribe; - VehicleDataType key_type = it->second; + mobile_apis::VehicleDataType::eType key_type = it->second; if (!app->IsSubscribedToIVI(key_type)) { ++unsubscribed_items; vi_already_unsubscribed_by_this_app_.insert(key_type); @@ -234,6 +234,7 @@ void UnsubscribeVehicleDataRequest::Run() { ++it) SendHMIRequest(it->func_id, &msg_params, true); #else + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData, &msg_params, true); @@ -250,6 +251,7 @@ void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { LOG4CXX_ERROR(logger_, "Received unknown event."); return; } + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); #ifdef HMI_DBUS_API for (HmiRequests::iterator it = hmi_requests_.begin(); diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc index 953bbc7a12..88ed396250 100644 --- a/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc +++ b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc @@ -30,6 +30,7 @@ void UnSubscribeWayPointsRequest::Run() { return; } + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); SendHMIRequest( hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints, NULL, true); } @@ -41,6 +42,7 @@ void UnSubscribeWayPointsRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints: { LOG4CXX_INFO(logger_, "Received Navigation_UnSubscribeWayPoints event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); const hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc b/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc index becab175e9..44fe9d0d07 100644 --- a/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc +++ b/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc @@ -138,6 +138,7 @@ void UpdateTurnListRequest::Run() { if ((*message_)[strings::msg_params].keyExists(strings::turn_list) || (*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); SendHMIRequest( hmi_apis::FunctionID::Navigation_UpdateTurnList, &msg_params, true); } else { @@ -154,7 +155,7 @@ void UpdateTurnListRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::Navigation_UpdateTurnList: { LOG4CXX_INFO(logger_, "Received Navigation_UpdateTurnList event"); - + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); const hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc index 28049f8e35..e39b728155 100644 --- a/src/components/application_manager/src/hmi_capabilities_impl.cc +++ b/src/components/application_manager/src/hmi_capabilities_impl.cc @@ -391,6 +391,7 @@ HMICapabilitiesImpl::HMICapabilitiesImpl(ApplicationManager& app_mngr) , is_navigation_supported_(false) , is_phone_call_supported_(false) , is_video_streaming_supported_(false) + , is_rc_supported_(false) , navigation_capability_(NULL) , phone_capability_(NULL) , video_streaming_capability_(NULL) @@ -650,6 +651,10 @@ void HMICapabilitiesImpl::set_video_streaming_supported(const bool supported) { is_video_streaming_supported_ = supported; } +void HMICapabilitiesImpl::set_rc_supported(const bool supported) { + is_rc_supported_ = supported; +} + void HMICapabilitiesImpl::set_navigation_capability( const smart_objects::SmartObject& navigation_capability) { if (navigation_capability_) { @@ -803,6 +808,10 @@ bool HMICapabilitiesImpl::video_streaming_supported() const { return is_video_streaming_supported_; } +bool HMICapabilitiesImpl::rc_supported() const { + return is_rc_supported_; +} + const smart_objects::SmartObject* HMICapabilitiesImpl::navigation_capability() const { return navigation_capability_; @@ -1150,6 +1159,9 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() { Formatters::CFormatterJsonBase::jsonValueToObj(rc_capability, rc_capability_so); set_rc_capability(rc_capability_so); + if (!rc_capability_so.empty()) { + set_rc_supported(true); + } } } } // UI end diff --git a/src/components/application_manager/src/hmi_command_factory.cc b/src/components/application_manager/src/hmi_command_factory.cc index ffaa8d9b5f..a7f3ce7e6b 100644 --- a/src/components/application_manager/src/hmi_command_factory.cc +++ b/src/components/application_manager/src/hmi_command_factory.cc @@ -269,6 +269,7 @@ #include "application_manager/commands/hmi/on_system_error_notification.h" #include "application_manager/commands/hmi/basic_communication_system_request.h" #include "application_manager/commands/hmi/basic_communication_system_response.h" +#include "application_manager/commands/hmi/basic_communication_on_awake_sdl.h" #include "application_manager/commands/hmi/sdl_policy_update.h" #include "application_manager/commands/hmi/sdl_policy_update_response.h" #include "application_manager/commands/hmi/on_received_policy_update.h" @@ -781,6 +782,11 @@ CommandSharedPtr HMICommandFactory::CreateCommand( message, application_manager)); break; } + case hmi_apis::FunctionID::BasicCommunication_OnAwakeSDL: { + command.reset( + new commands::OnAwakeSDLNotification(message, application_manager)); + break; + } case hmi_apis::FunctionID::BasicCommunication_OnExitApplication: { command.reset(new commands::OnExitApplicationNotification( message, application_manager)); diff --git a/src/components/application_manager/src/message.cc b/src/components/application_manager/src/message.cc index b211b270b8..7bc686aef1 100644 --- a/src/components/application_manager/src/message.cc +++ b/src/components/application_manager/src/message.cc @@ -89,7 +89,7 @@ Message& Message::operator=(const Message& message) { set_data_size(message.data_size_); set_payload_size(message.payload_size_); if (message.binary_data_) { - set_binary_data(message.binary_data_); + set_binary_data(static_cast<const BinaryData*>(message.binary_data_)); } set_json_message(message.json_message_); set_protocol_version(message.protocol_version()); @@ -207,6 +207,19 @@ void Message::set_binary_data(BinaryData* data) { binary_data_ = new BinaryData(*data); } +void Message::set_binary_data(const BinaryData* data) { + if (NULL == data) { + NOTREACHED(); + return; + } + + if (binary_data_) { + delete binary_data_; + } + + binary_data_ = new BinaryData(*data); +} + void Message::set_json_message(const std::string& json_message) { json_message_ = json_message; } 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 65f4c79fa6..cf64152315 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -158,37 +158,60 @@ struct ExternalConsentStatusAppender } // namespace -std::pair<std::string, VehicleDataType> kVehicleDataInitializer[] = { - std::make_pair(strings::gps, GPS), - std::make_pair(strings::speed, SPEED), - std::make_pair(strings::rpm, RPM), - std::make_pair(strings::fuel_level, FUELLEVEL), - std::make_pair(strings::fuel_level_state, FUELLEVEL_STATE), - std::make_pair(strings::instant_fuel_consumption, FUELCONSUMPTION), - std::make_pair(strings::external_temp, EXTERNTEMP), - std::make_pair(strings::vin, VIN), - std::make_pair(strings::prndl, PRNDL), - std::make_pair(strings::tire_pressure, TIREPRESSURE), - std::make_pair(strings::odometer, ODOMETER), - std::make_pair(strings::belt_status, BELTSTATUS), - std::make_pair(strings::body_information, BODYINFO), - std::make_pair(strings::device_status, DEVICESTATUS), - std::make_pair(strings::driver_braking, BRAKING), - std::make_pair(strings::wiper_status, WIPERSTATUS), - std::make_pair(strings::head_lamp_status, HEADLAMPSTATUS), - std::make_pair(strings::e_call_info, ECALLINFO), - std::make_pair(strings::airbag_status, AIRBAGSTATUS), - std::make_pair(strings::emergency_event, EMERGENCYEVENT), - std::make_pair(strings::cluster_mode_status, CLUSTERMODESTATUS), - std::make_pair(strings::my_key, MYKEY), +std::pair<std::string, + mobile_apis::VehicleDataType::eType> kVehicleDataInitializer[] = { + std::make_pair(strings::gps, mobile_apis::VehicleDataType::VEHICLEDATA_GPS), + std::make_pair(strings::speed, + mobile_apis::VehicleDataType::VEHICLEDATA_SPEED), + std::make_pair(strings::rpm, mobile_apis::VehicleDataType::VEHICLEDATA_RPM), + std::make_pair(strings::fuel_level, + mobile_apis::VehicleDataType::VEHICLEDATA_FUELLEVEL), + std::make_pair(strings::fuel_level_state, + mobile_apis::VehicleDataType::VEHICLEDATA_FUELLEVEL_STATE), + std::make_pair(strings::instant_fuel_consumption, + mobile_apis::VehicleDataType::VEHICLEDATA_FUELCONSUMPTION), + std::make_pair(strings::external_temp, + mobile_apis::VehicleDataType::VEHICLEDATA_EXTERNTEMP), + std::make_pair(strings::vin, mobile_apis::VehicleDataType::VEHICLEDATA_VIN), + std::make_pair(strings::prndl, + mobile_apis::VehicleDataType::VEHICLEDATA_PRNDL), + std::make_pair(strings::tire_pressure, + mobile_apis::VehicleDataType::VEHICLEDATA_TIREPRESSURE), + std::make_pair(strings::odometer, + mobile_apis::VehicleDataType::VEHICLEDATA_ODOMETER), + std::make_pair(strings::belt_status, + mobile_apis::VehicleDataType::VEHICLEDATA_BELTSTATUS), + std::make_pair(strings::body_information, + mobile_apis::VehicleDataType::VEHICLEDATA_BODYINFO), + std::make_pair(strings::device_status, + mobile_apis::VehicleDataType::VEHICLEDATA_DEVICESTATUS), + std::make_pair(strings::driver_braking, + mobile_apis::VehicleDataType::VEHICLEDATA_BRAKING), + std::make_pair(strings::wiper_status, + mobile_apis::VehicleDataType::VEHICLEDATA_WIPERSTATUS), + std::make_pair(strings::head_lamp_status, + mobile_apis::VehicleDataType::VEHICLEDATA_HEADLAMPSTATUS), + std::make_pair(strings::e_call_info, + mobile_apis::VehicleDataType::VEHICLEDATA_ECALLINFO), + std::make_pair(strings::airbag_status, + mobile_apis::VehicleDataType::VEHICLEDATA_AIRBAGSTATUS), + std::make_pair(strings::emergency_event, + mobile_apis::VehicleDataType::VEHICLEDATA_EMERGENCYEVENT), + std::make_pair(strings::cluster_mode_status, + mobile_apis::VehicleDataType::VEHICLEDATA_CLUSTERMODESTATUS), + std::make_pair(strings::my_key, + mobile_apis::VehicleDataType::VEHICLEDATA_MYKEY), /* NOT DEFINED in mobile API std::make_pair(strings::gps, BATTVOLTAGE), */ - std::make_pair(strings::engine_torque, ENGINETORQUE), - std::make_pair(strings::acc_pedal_pos, ACCPEDAL), - std::make_pair(strings::steering_wheel_angle, STEERINGWHEEL), + std::make_pair(strings::engine_torque, + mobile_apis::VehicleDataType::VEHICLEDATA_ENGINETORQUE), + std::make_pair(strings::acc_pedal_pos, + mobile_apis::VehicleDataType::VEHICLEDATA_ACCPEDAL), + std::make_pair(strings::steering_wheel_angle, + mobile_apis::VehicleDataType::VEHICLEDATA_STEERINGWHEEL), }; const VehicleData MessageHelper::vehicle_data_( @@ -829,7 +852,7 @@ smart_objects::SmartObjectList MessageHelper::GetIVISubscriptionRequests( const VehicleInfoSubscriptions& subscriptions = vi_accessor.GetData(); for (; vehicle_data.end() != ivi_it; ++ivi_it) { - uint32_t type_id = static_cast<int>(ivi_it->second); + mobile_apis::VehicleDataType::eType type_id = ivi_it->second; if (subscriptions.end() != subscriptions.find(type_id)) { std::string key_name = ivi_it->first; msg_params[key_name] = true; diff --git a/src/components/application_manager/src/mobile_message_handler.cc b/src/components/application_manager/src/mobile_message_handler.cc index a3b5aa7dbd..2f06c5f3b5 100644 --- a/src/components/application_manager/src/mobile_message_handler.cc +++ b/src/components/application_manager/src/mobile_message_handler.cc @@ -196,7 +196,7 @@ MobileMessageHandler::HandleIncomingMessageProtocolV2( outgoing_message->set_payload_size(message->payload_size()); if (!payload.data.empty()) { - BinaryData binary_payload_data(payload.data); + const BinaryData binary_payload_data(payload.data); outgoing_message->set_binary_data(&binary_payload_data); } return outgoing_message.release(); diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index ad21f533a1..e6ebaf3b83 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -808,17 +808,17 @@ bool PolicyHandler::IsAppSuitableForPolicyUpdate( const Applications::value_type value) const { LOG4CXX_AUTO_TRACE(logger_); - const uint32_t app_id = value->app_id(); - if (!value->IsRegistered()) { LOG4CXX_DEBUG(logger_, - "Application " << app_id << " is not marked as registered."); + "Application " << value->app_id() + << " is not marked as registered."); return false; } LOG4CXX_DEBUG(logger_, - "Application " << app_id << " marked as registered." - "Checking its parameters."); + "Application " << value->app_id() + << " marked as registered." + "Checking its parameters."); DeviceParams device_params = GetDeviceParams( value->device(), 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 e7788bf9ff..435e621169 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc @@ -67,6 +67,7 @@ ResumeCtrlImpl::ResumeCtrlImpl(ApplicationManager& application_manager) this, &ResumeCtrlImpl::SaveDataOnTimer)) , is_resumption_active_(false) , is_data_saved_(false) + , is_suspended_(false) , launch_time_(time(NULL)) , application_manager_(application_manager) {} #ifdef BUILD_TESTS @@ -263,16 +264,25 @@ bool ResumeCtrlImpl::RemoveApplicationFromSaved( void ResumeCtrlImpl::OnSuspend() { LOG4CXX_AUTO_TRACE(logger_); - StopSavePersistentDataTimer(); - SaveAllApplications(); - resumption_storage_->OnSuspend(); - resumption_storage_->Persist(); + is_suspended_ = true; + FinalPersistData(); +} + +void ResumeCtrlImpl::OnIgnitionOff() { + LOG4CXX_AUTO_TRACE(logger_); + resumption_storage_->IncrementIgnOffCount(); + FinalPersistData(); } void ResumeCtrlImpl::OnAwake() { + LOG4CXX_AUTO_TRACE(logger_); + is_suspended_ = false; ResetLaunchTime(); StartSavePersistentDataTimer(); - return resumption_storage_->OnAwake(); +} + +bool ResumeCtrlImpl::is_suspended() const { + return is_suspended_; } void ResumeCtrlImpl::StartSavePersistentDataTimer() { @@ -433,6 +443,13 @@ void ResumeCtrlImpl::SaveDataOnTimer() { } } +void ResumeCtrlImpl::FinalPersistData() { + LOG4CXX_AUTO_TRACE(logger_); + StopSavePersistentDataTimer(); + SaveAllApplications(); + resumption_storage_->Persist(); +} + bool ResumeCtrlImpl::IsDeviceMacAddressEqual( ApplicationSharedPtr application, const std::string& saved_device_mac) { LOG4CXX_AUTO_TRACE(logger_); @@ -609,9 +626,10 @@ void ResumeCtrlImpl::AddSubscriptions( if (subscribtions.keyExists(strings::application_vehicle_info)) { const smart_objects::SmartObject& subscribtions_ivi = subscribtions[strings::application_vehicle_info]; - VehicleDataType ivi; + mobile_apis::VehicleDataType::eType ivi; for (size_t i = 0; i < subscribtions_ivi.length(); ++i) { - ivi = static_cast<VehicleDataType>((subscribtions_ivi[i]).asInt()); + ivi = static_cast<mobile_apis::VehicleDataType::eType>( + (subscribtions_ivi[i]).asInt()); application->SubscribeToIVI(ivi); } ProcessHMIRequests(MessageHelper::GetIVISubscriptionRequests( @@ -773,7 +791,7 @@ void ResumeCtrlImpl::LoadResumeData() { "Resumption data for application " << app_id << " and device id " << device_id << " will be dropped."); - resumption_storage_->DropAppDataResumption(device_id, app_id); + resumption_storage_->RemoveApplicationFromSaved(app_id, device_id); continue; } } diff --git a/src/components/application_manager/src/resumption/resumption_data.cc b/src/components/application_manager/src/resumption/resumption_data.cc index 273cd5413e..bd5bdbddab 100644 --- a/src/components/application_manager/src/resumption/resumption_data.cc +++ b/src/components/application_manager/src/resumption/resumption_data.cc @@ -33,7 +33,6 @@ #include "application_manager/resumption/resumption_data.h" #include "utils/logger.h" #include "application_manager/smart_object_keys.h" -#include "application_manager/vehicle_info_data.h" #include "application_manager/application_manager_settings.h" namespace resumption { diff --git a/src/components/application_manager/src/resumption/resumption_data_db.cc b/src/components/application_manager/src/resumption/resumption_data_db.cc index 08de6d8190..23fecb7624 100644 --- a/src/components/application_manager/src/resumption/resumption_data_db.cc +++ b/src/components/application_manager/src/resumption/resumption_data_db.cc @@ -212,7 +212,10 @@ uint32_t ResumptionDataDB::GetHMIApplicationID( return hmi_app_id; } -void ResumptionDataDB::OnSuspend() { +// DEPRECATED +void ResumptionDataDB::OnSuspend() {} + +void ResumptionDataDB::IncrementIgnOffCount() { LOG4CXX_AUTO_TRACE(logger_); utils::dbms::SQLQuery query_update_suspend_data(db()); @@ -291,7 +294,10 @@ bool ResumptionDataDB::GetHashId(const std::string& policy_app_id, return SelectHashId(policy_app_id, device_id, hash_id); } -void ResumptionDataDB::OnAwake() { +// DEPRECATED +void ResumptionDataDB::OnAwake() {} + +void ResumptionDataDB::DecrementIgnOffCount() { LOG4CXX_AUTO_TRACE(logger_); UpdateDataOnAwake(); diff --git a/src/components/application_manager/src/resumption/resumption_data_json.cc b/src/components/application_manager/src/resumption/resumption_data_json.cc index 7866fc4de1..203c4889c5 100644 --- a/src/components/application_manager/src/resumption/resumption_data_json.cc +++ b/src/components/application_manager/src/resumption/resumption_data_json.cc @@ -143,11 +143,14 @@ uint32_t ResumptionDataJson::GetHMIApplicationID( return hmi_app_id; } -void ResumptionDataJson::OnSuspend() { +// DEPRECATED +void ResumptionDataJson::OnSuspend() {} + +void ResumptionDataJson::IncrementIgnOffCount() { using namespace app_mngr; LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock autolock(resumption_lock_); - Json::Value to_save; + Json::Value to_save = Json::arrayValue; for (Json::Value::iterator it = GetSavedApplications().begin(); it != GetSavedApplications().end(); ++it) { @@ -167,7 +170,10 @@ void ResumptionDataJson::OnSuspend() { LOG4CXX_DEBUG(logger_, GetResumptionData().toStyledString()); } -void ResumptionDataJson::OnAwake() { +// DEPRECATED +void ResumptionDataJson::OnAwake() {} + +void ResumptionDataJson::DecrementIgnOffCount() { using namespace app_mngr; LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock autolock(resumption_lock_); diff --git a/src/components/application_manager/src/resumption/resumption_sql_queries.cc b/src/components/application_manager/src/resumption/resumption_sql_queries.cc index 5f318e6955..7a5008542c 100644 --- a/src/components/application_manager/src/resumption/resumption_sql_queries.cc +++ b/src/components/application_manager/src/resumption/resumption_sql_queries.cc @@ -212,7 +212,7 @@ const std::string kCreateSchema = "`vrHelpItemArray`(`idglobalProperties`); " "CREATE TABLE IF NOT EXISTS `application`( " " `idApplication` INTEGER PRIMARY KEY NOT NULL, " - " `appID` TEXT, " + " `appID` TEXT COLLATE NOCASE, " " `connection_key` INTEGER, " " `grammarID` INTEGER, " " `hashID` TEXT, " diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 45bab026b4..0bf3287e42 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -234,6 +234,7 @@ const char* hmi_capabilities = "hmiCapabilities"; const char* navigation = "navigation"; const char* phone_call = "phoneCall"; const char* video_streaming = "videoStreaming"; +const char* remote_control = "remoteControl"; const char* sdl_version = "sdlVersion"; const char* system_software_version = "systemSoftwareVersion"; const char* priority = "priority"; |