diff options
author | Shobhit Adlakha <ShobhitAd@users.noreply.github.com> | 2022-10-26 11:34:13 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-26 11:34:13 -0400 |
commit | 7343fc72c12edc8ac42a62556c9e4b29c9408bc3 (patch) | |
tree | 32e910f5440c10b384bb26b5555ac7adb77540ee /src/components/application_manager | |
parent | 65947fd1eb30a392948d67003df0fe803c070c6b (diff) | |
parent | fb05c085b449b2149f85338fd4d00951205ab969 (diff) | |
download | sdl_core-master.tar.gz |
Release 8.2.0
Diffstat (limited to 'src/components/application_manager')
53 files changed, 571 insertions, 312 deletions
diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index e018c28c54..d37a211044 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -1181,7 +1181,8 @@ class Application : public virtual InitialApplicationData, * @brief Get list of available application extensions * @return application extensions */ - virtual const std::list<AppExtensionPtr>& Extensions() const = 0; + virtual const DataAccessor<std::list<AppExtensionPtr> > Extensions() + const = 0; /** * @brief Get cloud app endpoint for websocket connection diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h index 49f44acacb..1746893be3 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -555,7 +555,7 @@ class ApplicationImpl : public virtual Application, */ bool RemoveExtension(AppExtensionUID uid) OVERRIDE; - const std::list<AppExtensionPtr>& Extensions() const OVERRIDE; + const DataAccessor<std::list<AppExtensionPtr> > Extensions() const OVERRIDE; std::string hash_val_; uint32_t grammar_id_; @@ -617,6 +617,7 @@ class ApplicationImpl : public virtual Application, Timer audio_stream_suspend_timer_; std::list<AppExtensionPtr> extensions_; + mutable std::shared_ptr<sync_primitives::RecursiveLock> extensions_lock_; // Cloud app properties std::string endpoint_; @@ -644,7 +645,6 @@ class ApplicationImpl : public virtual Application, CommandSoftButtonID cmd_softbuttonid_; // Lock for command soft button id sync_primitives::Lock cmd_softbuttonid_lock_; - mutable std::shared_ptr<sync_primitives::Lock> vi_lock_ptr_; mutable std::shared_ptr<sync_primitives::Lock> button_lock_ptr_; std::string folder_name_; ApplicationManager& application_manager_; diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index d72508bd63..0770cba4b1 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -1023,8 +1023,6 @@ class ApplicationManagerImpl rpc_service_ = std::move(rpc_service); } - bool is_stopping() const OVERRIDE; - bool is_audio_pass_thru_active() const OVERRIDE; /* * @brief Function Should be called when Low Voltage is occured diff --git a/src/components/application_manager/include/application_manager/commands/command.h b/src/components/application_manager/include/application_manager/commands/command.h index f8bc66df2a..1283db0edc 100644 --- a/src/components/application_manager/include/application_manager/commands/command.h +++ b/src/components/application_manager/include/application_manager/commands/command.h @@ -137,6 +137,8 @@ class Command { */ virtual void SetAllowedToTerminate(const bool allowed) = 0; + virtual const ApplicationManager& GetApplicationManager() const = 0; + enum CommandSource { SOURCE_SDL, SOURCE_MOBILE, diff --git a/src/components/application_manager/include/application_manager/commands/command_impl.h b/src/components/application_manager/include/application_manager/commands/command_impl.h index 534f07aa37..0438ffe682 100644 --- a/src/components/application_manager/include/application_manager/commands/command_impl.h +++ b/src/components/application_manager/include/application_manager/commands/command_impl.h @@ -182,6 +182,8 @@ class CommandImpl : public Command { */ void SetAllowedToTerminate(const bool allowed) OVERRIDE; + const ApplicationManager& GetApplicationManager() const OVERRIDE; + void OnUpdateTimeOut() OVERRIDE; /** diff --git a/src/components/application_manager/include/application_manager/help_prompt_manager.h b/src/components/application_manager/include/application_manager/help_prompt_manager.h index eb45705d9f..d5820169c0 100644 --- a/src/components/application_manager/include/application_manager/help_prompt_manager.h +++ b/src/components/application_manager/include/application_manager/help_prompt_manager.h @@ -80,6 +80,14 @@ class HelpPromptManager { const smart_objects::SmartObject& msg, const bool is_response) = 0; /** + * @brief Triggered when ResetGlobalProperties request is received from an + * application. Reset sending_type_ based on which global properties are reset + * @param msg containing GlobalProperties + */ + virtual void OnResetGlobalPropertiesReceived( + const smart_objects::SmartObject& msg) = 0; + + /** * @brief Requests sending type behavior */ enum class SendingType { kNoneSend, kSendHelpPrompt, kSendVRHelp, kSendBoth }; @@ -89,6 +97,16 @@ class HelpPromptManager { * @return current sending type */ virtual SendingType GetSendingType() const = 0; + + /** + * @brief Construct the helpPrompt parameter + */ + virtual void CreatePromptMsg(smart_objects::SmartObject& out_msg_params) = 0; + + /** + * @brief Construct the vrHelp parameter + */ + virtual void CreateVRMsg(smart_objects::SmartObject& out_msg_params) = 0; }; } // namespace application_manager diff --git a/src/components/application_manager/include/application_manager/help_prompt_manager_impl.h b/src/components/application_manager/include/application_manager/help_prompt_manager_impl.h index 3cd22a6afc..9094524c7d 100644 --- a/src/components/application_manager/include/application_manager/help_prompt_manager_impl.h +++ b/src/components/application_manager/include/application_manager/help_prompt_manager_impl.h @@ -104,11 +104,29 @@ class HelpPromptManagerImpl : public HelpPromptManager { const bool is_response) OVERRIDE; /** + * @brief Triggered when ResetGlobalProperties request is received from an + * application. Reset sending_type_ based on which global properties are reset + * @param msg containing GlobalProperties + */ + void OnResetGlobalPropertiesReceived( + const smart_objects::SmartObject& msg) OVERRIDE; + + /** * @brief Get current sending type * @return current sending type */ SendingType GetSendingType() const OVERRIDE; + /** + * @brief Construct the helpPrompt parameter + */ + void CreatePromptMsg(smart_objects::SmartObject& out_msg_params); + + /** + * @brief Construct the vrHelp parameter + */ + void CreateVRMsg(smart_objects::SmartObject& out_msg_params); + private: DISALLOW_COPY_AND_ASSIGN(HelpPromptManagerImpl); @@ -150,16 +168,6 @@ class HelpPromptManagerImpl : public HelpPromptManager { void SendRequests(); /** - * @brief Construct the helpPrompt parameter - */ - void CreatePromptMsg(smart_objects::SmartObject& out_msg_params); - - /** - * @brief Construct the vrHelp parameter - */ - void CreateVRMsg(smart_objects::SmartObject& out_msg_params); - - /** * @brief Setting request type to send HMI * @param msg containing request or response for the * SetGlobalPropertiesRequest diff --git a/src/components/application_manager/include/application_manager/hmi_state.h b/src/components/application_manager/include/application_manager/hmi_state.h index 8271edcbd8..745c135bde 100644 --- a/src/components/application_manager/include/application_manager/hmi_state.h +++ b/src/components/application_manager/include/application_manager/hmi_state.h @@ -37,6 +37,7 @@ #include <list> #include <memory> #include "interfaces/MOBILE_API.h" +#include "utils/atomic_object.h" #include "utils/macro.h" namespace application_manager { @@ -116,13 +117,13 @@ class HmiState { * @return return hmi level member */ virtual mobile_apis::HMILevel::eType hmi_level() const { - if (parent_) { + if (parent()) { if (mobile_apis::HMILevel::INVALID_ENUM == hmi_level_) { - return parent_->hmi_level(); + return parent()->hmi_level(); } // Higher values correlate to lower states // (FULL = 0, LIMITED = 1, etc.) - return std::max(parent_->max_hmi_level(), hmi_level_); + return std::max(parent()->max_hmi_level(), hmi_level_); } return hmi_level_; } @@ -132,8 +133,8 @@ class HmiState { * @return return maximum hmi level for app */ virtual mobile_apis::HMILevel::eType max_hmi_level() const { - if (parent_) { - return parent_->max_hmi_level(); + if (parent()) { + return parent()->max_hmi_level(); } return mobile_apis::HMILevel::HMI_FULL; } @@ -152,14 +153,14 @@ class HmiState { */ virtual mobile_apis::AudioStreamingState::eType audio_streaming_state() const { - if (parent_) { + if (parent()) { if (mobile_apis::AudioStreamingState::INVALID_ENUM == audio_streaming_state_) { - return parent_->audio_streaming_state(); + return parent()->audio_streaming_state(); } // Higher values correlate to lower states // (AUDIBLE = 0, ATTENUATED = 1, etc.) - return std::max(parent_->max_audio_streaming_state(), + return std::max(parent()->max_audio_streaming_state(), audio_streaming_state_); } return audio_streaming_state_; @@ -171,8 +172,8 @@ class HmiState { */ virtual mobile_apis::AudioStreamingState::eType max_audio_streaming_state() const { - if (parent_) { - return parent_->max_audio_streaming_state(); + if (parent()) { + return parent()->max_audio_streaming_state(); } return mobile_apis::AudioStreamingState::AUDIBLE; } @@ -183,14 +184,14 @@ class HmiState { */ virtual mobile_apis::VideoStreamingState::eType video_streaming_state() const { - if (parent_) { + if (parent()) { if (mobile_apis::VideoStreamingState::INVALID_ENUM == video_streaming_state_) { - return parent_->video_streaming_state(); + return parent()->video_streaming_state(); } // Higher values correlate to lower states // (STREAMABLE = 0, NOT_STREAMABLE = 1) - return std::max(parent_->max_video_streaming_state(), + return std::max(parent()->max_video_streaming_state(), video_streaming_state_); } return video_streaming_state_; @@ -202,8 +203,8 @@ class HmiState { */ virtual mobile_apis::VideoStreamingState::eType max_video_streaming_state() const { - if (parent_) { - return parent_->max_video_streaming_state(); + if (parent()) { + return parent()->max_video_streaming_state(); } return mobile_apis::VideoStreamingState::STREAMABLE; } @@ -232,9 +233,9 @@ class HmiState { */ virtual mobile_apis::SystemContext::eType system_context() const { // Parent's context should be used if not available for current state - if (parent_ && + if (parent() && system_context_ == mobile_apis::SystemContext::INVALID_ENUM) { - return parent_->system_context(); + return parent()->system_context(); } return system_context_; } @@ -280,7 +281,7 @@ class HmiState { uint32_t hmi_app_id_; StateID state_id_; const ApplicationManager& app_mngr_; - HmiStatePtr parent_; + sync_primitives::Atomic<HmiStatePtr> parent_; mobile_apis::WindowType::eType window_type_; mobile_apis::HMILevel::eType hmi_level_; mobile_apis::AudioStreamingState::eType audio_streaming_state_; diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index 9cfb504b00..dc7e0b6b1f 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -321,9 +321,6 @@ class MessageHelper { static smart_objects::SmartObjectList CreateGlobalPropertiesRequestsToHMI( ApplicationConstSharedPtr app, ApplicationManager& app_mngr); - static smart_objects::SmartObjectSPtr CreateAppVrHelp( - ApplicationConstSharedPtr app); - static smart_objects::SmartObjectList CreateShowRequestToHMI( ApplicationConstSharedPtr app, const uint32_t correlation_id); static void SendShowRequestToHMI(ApplicationConstSharedPtr app, diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data.h b/src/components/application_manager/include/application_manager/resumption/resumption_data.h index ee9972b98c..39b751bb4b 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_data.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_data.h @@ -157,7 +157,7 @@ class ResumptionData { * @brief Get the last ignition off time from LastState * @return the last ignition off time from LastState */ - virtual uint32_t GetIgnOffTime() const = 0; + virtual int64_t GetIgnOffTime() const = 0; /** * @brief Checks if saved data have application diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h b/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h index a4614d4f2c..768d34094b 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h @@ -167,7 +167,7 @@ class ResumptionDataDB : public ResumptionData { * @brief Get the last ignition off time from LastState * @return the last ignition off time from LastState */ - virtual uint32_t GetIgnOffTime() const; + virtual int64_t GetIgnOffTime() const; /** * @brief Checks if saved data have application @@ -289,7 +289,7 @@ class ResumptionDataDB : public ResumptionData { * @brief Select Ign off time * @return Ign off time from saved data */ - uint32_t SelectIgnOffTime() const; + int64_t SelectIgnOffTime() const; /** * @brief Checks existence application in DB diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h b/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h index f33ef83a9b..a4f83fff44 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h @@ -131,7 +131,7 @@ class ResumptionDataJson : public ResumptionData { * @brief Get the last ignition off time from LastState * @return the last ignition off time from LastState */ - virtual uint32_t GetIgnOffTime() const; + virtual int64_t GetIgnOffTime() const; void IncrementGlobalIgnOnCounter() OVERRIDE; diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data_processor_impl.h b/src/components/application_manager/include/application_manager/resumption/resumption_data_processor_impl.h index 312302d157..ffb9359f9c 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_data_processor_impl.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_data_processor_impl.h @@ -129,8 +129,9 @@ class ResumptionDataProcessorImpl * requests * @param app_id ID of application, related to event * @param found_request reference to found request + * @return true, if request is found and erased */ - void EraseProcessedRequest(const uint32_t app_id, + bool EraseProcessedRequest(const uint32_t app_id, const ResumptionRequest& found_request); /** diff --git a/src/components/application_manager/include/application_manager/state_controller_impl.h b/src/components/application_manager/include/application_manager/state_controller_impl.h index 6845851f97..e0200f55af 100644 --- a/src/components/application_manager/include/application_manager/state_controller_impl.h +++ b/src/components/application_manager/include/application_manager/state_controller_impl.h @@ -136,9 +136,10 @@ class StateControllerImpl : public event_engine::EventObserver, PostponedActivationController& GetPostponedActivationController() OVERRIDE; private: - int64_t RequestHMIStateChange(ApplicationConstSharedPtr app, - hmi_apis::Common_HMILevel::eType level, - bool send_policy_priority); + void RequestHMIStateChange(ApplicationConstSharedPtr app, + HmiStatePtr resolved_state, + hmi_apis::Common_HMILevel::eType level, + bool send_policy_priority); /** * @brief The HmiLevelConflictResolver struct diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_capabilities_manager_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_capabilities_manager_impl.cc index 75ccd46e4d..875455f545 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_capabilities_manager_impl.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_capabilities_manager_impl.cc @@ -371,23 +371,24 @@ bool RCCapabilitiesManagerImpl::CheckButtonName( SDL_LOG_AUTO_TRACE(); auto rc_capabilities = hmi_capabilities_.rc_capability(); if (!rc_capabilities) { - SDL_LOG_ERROR("No remote controll capabilities available"); + SDL_LOG_ERROR("No remote control capabilities available"); return false; } - if (enums_value::kRadio == module_type) { - if (!helpers::in_range(RCHelpers::buttons_radio(), button_name)) { - SDL_LOG_WARN("Trying to acceess climate button with module type radio"); - return false; - } - } + auto module_type_mismatch = [&button_name, &module_type]( + const std::string& type, + const std::vector<std::string>&& buttons) { + return (helpers::in_range(buttons, button_name) && type != module_type); + }; - if (enums_value::kClimate == module_type) { - if (!helpers::in_range(RCHelpers::buttons_climate(), button_name)) { - SDL_LOG_WARN("Trying to acceess radio button with module type climate"); - return false; - } + if (module_type_mismatch(enums_value::kRadio, RCHelpers::buttons_radio()) || + module_type_mismatch(enums_value::kClimate, + RCHelpers::buttons_climate())) { + SDL_LOG_WARN("Trying to access incompatible button: " + << button_name << " with module type: " << module_type); + return false; } + return true; } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h index 82967b717b..edbeaf1b9e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h @@ -97,8 +97,10 @@ class CreateInteractionChoiceSetRequest * @brief Calls after all responses from HMI were received. * Terminates request and sends successful response to mobile * if all responses were SUCCESS or calls DeleteChoices in other case. + * @param vr_result the result code from hmi. */ - void OnAllHMIResponsesReceived(); + void OnAllHMIResponsesReceived( + const hmi_apis::Common_Result::eType vr_result); /** * @brief The VRCommand struct @@ -201,8 +203,9 @@ class CreateInteractionChoiceSetRequest * @brief CountReceivedVRResponses counts received HMI responses. Updated * request timeout if not all responses received * Send response to mobile if all responses received. + * @param vr_result the result code from hmi. */ - void CountReceivedVRResponses(); + void CountReceivedVRResponses(const hmi_apis::Common_Result::eType vr_result); DISALLOW_COPY_AND_ASSIGN(CreateInteractionChoiceSetRequest); }; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc index ddd2c9db35..eaad84dafd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc @@ -444,12 +444,6 @@ void AddCommandRequest::on_event(const event_engine::Event& event) { result_code = ui_result_ == hmi_apis::Common_Result::REJECTED ? mobile_apis::Result::REJECTED : mobile_apis::Result::GENERIC_ERROR; - - msg_params[strings::grammar_id] = application->get_grammar_id(); - msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; - - SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params); - application->RemoveCommand(cmd_id); result = false; SDL_LOG_DEBUG("Result " << result); } @@ -461,10 +455,6 @@ void AddCommandRequest::on_event(const event_engine::Event& event) { result_code = vr_result_ == hmi_apis::Common_Result::REJECTED ? mobile_apis::Result::REJECTED : mobile_apis::Result::GENERIC_ERROR; - - SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params); - - application->RemoveCommand(cmd_id); result = false; SDL_LOG_DEBUG("Result " << result); } @@ -588,12 +578,28 @@ const std::string AddCommandRequest::GenerateMobileResponseInfo() { void AddCommandRequest::RemoveCommand() { SDL_LOG_AUTO_TRACE(); + using namespace helpers; + ApplicationSharedPtr app = application_manager_.application(connection_key()); if (app.use_count() == 0) { SDL_LOG_ERROR("No application associated with session key"); return; } + const bool is_ui_result_ok_or_missing = + Compare<hmi_apis::Common_Result::eType, EQ, ONE>( + ui_result_, + hmi_apis::Common_Result::INVALID_ENUM, + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::WARNINGS); + + const bool is_vr_result_ok_or_missing = + Compare<hmi_apis::Common_Result::eType, EQ, ONE>( + vr_result_, + hmi_apis::Common_Result::INVALID_ENUM, + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::WARNINGS); + const uint32_t cmd_id = (*message_)[strings::msg_params][strings::cmd_id].asUInt(); smart_objects::SmartObject msg_params(smart_objects::SmartType_Map); @@ -602,21 +608,15 @@ void AddCommandRequest::RemoveCommand() { app->RemoveCommand(cmd_id); - if (BothSend() && (IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_VR) && - IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_UI))) { - // in case we have send bth UI and VR and no one respond - // we have nothing to remove from HMI so no DeleteCommand expected - return; - } - - if (BothSend() && IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_VR)) { + if (ui_is_sent_ && is_ui_result_ok_or_missing) { SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params); } - if (BothSend() && IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_UI)) { - msg_params[strings::grammar_id] = app->get_grammar_id(); - msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; - SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params); + if (vr_is_sent_ && is_vr_result_ok_or_missing) { + smart_objects::SmartObject vr_msg_params = msg_params; + vr_msg_params[strings::grammar_id] = app->get_grammar_id(); + vr_msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; + SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &vr_msg_params); } } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc index 70f462c05d..f221742523 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc @@ -368,7 +368,8 @@ bool CreateInteractionChoiceSetRequest::ProcessSuccesfulHMIResponse( return true; } -void CreateInteractionChoiceSetRequest::CountReceivedVRResponses() { +void CreateInteractionChoiceSetRequest::CountReceivedVRResponses( + const hmi_apis::Common_Result::eType vr_result) { ++received_chs_count_; SDL_LOG_DEBUG("Got VR.AddCommand response, there are " << expected_chs_count_ - received_chs_count_ @@ -378,7 +379,7 @@ void CreateInteractionChoiceSetRequest::CountReceivedVRResponses() { connection_key(), correlation_id(), default_timeout()); SDL_LOG_DEBUG("Timeout for request was updated"); } else { - OnAllHMIResponsesReceived(); + OnAllHMIResponsesReceived(vr_result); } } @@ -392,7 +393,15 @@ void CreateInteractionChoiceSetRequest::on_event( const Common_Result::eType result = static_cast<Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); const bool is_no_error = Compare<Common_Result::eType, EQ, ONE>( - result, Common_Result::SUCCESS, Common_Result::WARNINGS); + result, + Common_Result::SUCCESS, + Common_Result::WARNINGS, + Common_Result::WRONG_LANGUAGE, + Common_Result::RETRY, + Common_Result::SAVED, + Common_Result::TRUNCATED_DATA, + Common_Result::UNSUPPORTED_RESOURCE); + uint32_t corr_id = static_cast<uint32_t>( message[strings::params][strings::correlation_id].asUInt()); if (event.id() == hmi_apis::FunctionID::VR_AddCommand) { @@ -407,7 +416,7 @@ void CreateInteractionChoiceSetRequest::on_event( ProcessHmiError(result); } } - CountReceivedVRResponses(); + CountReceivedVRResponses(result); } } @@ -464,7 +473,8 @@ void CreateInteractionChoiceSetRequest::DeleteChoices() { sent_commands_map_.clear(); } -void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() { +void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived( + const hmi_apis::Common_Result::eType vr_result) { SDL_LOG_AUTO_TRACE(); ApplicationSharedPtr application = @@ -478,7 +488,7 @@ void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() { if (!error_from_hmi_ && should_send_warnings_) { SendResponse(true, mobile_apis::Result::WARNINGS, kInvalidImageWarningInfo); } else if (!error_from_hmi_) { - SendResponse(true, mobile_apis::Result::SUCCESS); + SendResponse(true, MessageHelper::HMIToMobileResult(vr_result)); } else { DeleteChoices(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc index dccf2e9fdd..9caf7e4c7a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc @@ -89,7 +89,13 @@ void DeleteInteractionChoiceSetRequest::Run() { SendResponse(false, mobile_apis::Result::IN_USE); return; } - SendVrDeleteCommand(app); + if (choice_set.keyExists(strings::grammar_id) && + choice_set[strings::grammar_id].asInt() != -1) { + SendVrDeleteCommand(app); + } else { + response_result_codes_.push_back(hmi_apis::Common_Result::SUCCESS); + SendDeleteInteractionChoiceSetResponse(); + } } bool DeleteInteractionChoiceSetRequest::Init() { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc index af0a5a6539..0537043cd4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc @@ -225,8 +225,13 @@ size_t OnSystemRequestNotification::ParsePTString( size_t result_length = length; result.reserve(length * 2); for (size_t i = 0; i < length; ++i) { - if (pt_string[i] == '\"' || pt_string[i] == '\\') { + if (pt_string[i] == '\"') { result += '\\'; + } else if (pt_string[i] == '\\') { + result += '\\'; + --result_length; // contentLength is adjusted for the additional escape + // character added before special characters (like the + // newline string) } else if (pt_string[i] == '\n') { --result_length; // contentLength is adjusted when this character is // not copied to result. diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_request.cc index 92c5d19a05..a9abb5dc6d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_request.cc @@ -123,6 +123,9 @@ void ResetGlobalPropertiesRequest::Run() { SendHMIRequest( hmi_apis::FunctionID::RC_SetGlobalProperties, msg_params.get(), true); } + auto& help_prompt_manager = app->help_prompt_manager(); + help_prompt_manager.OnResetGlobalPropertiesReceived( + (*message_)[strings::msg_params]); } void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc index b4795dae21..d273ce8905 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc @@ -167,8 +167,7 @@ class AddCommandRequestTest } void CheckOnTimeOutCommandDeletion( - const hmi_apis::FunctionID::eType incoming_cmd, - const hmi_apis::FunctionID::eType cmd_to_delete) { + const hmi_apis::FunctionID::eType incoming_cmd) { CreateBasicParamsVRRequest(); CreateBasicParamsUIRequest(); SmartObject& msg_params = (*msg_)[strings::msg_params]; @@ -209,9 +208,15 @@ class AddCommandRequestTest EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)); EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(cmd_to_delete), _)) + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteCommand), _)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VR_DeleteCommand), _)) .WillOnce(Return(true)); + SmartObjectSPtr response = std::make_shared<SmartObject>(SmartType_Map); (*response)[strings::msg_params][strings::info] = "info"; EXPECT_CALL( @@ -598,13 +603,11 @@ TEST_F(AddCommandRequestTest, OnEvent_VR_SUCCESS) { } TEST_F(AddCommandRequestTest, OnTimeOut_EXPECT_VR_DeleteCommand) { - CheckOnTimeOutCommandDeletion(hmi_apis::FunctionID::VR_AddCommand, - hmi_apis::FunctionID::VR_DeleteCommand); + CheckOnTimeOutCommandDeletion(hmi_apis::FunctionID::VR_AddCommand); } TEST_F(AddCommandRequestTest, OnTimeOut_EXPECT_UI_DeleteCommand) { - CheckOnTimeOutCommandDeletion(hmi_apis::FunctionID::UI_AddCommand, - hmi_apis::FunctionID::UI_DeleteCommand); + CheckOnTimeOutCommandDeletion(hmi_apis::FunctionID::UI_AddCommand); } TEST_F(AddCommandRequestTest, OnEvent_BothSend_SUCCESS) { @@ -744,7 +747,7 @@ TEST_F(AddCommandRequestTest, TEST_F( AddCommandRequestTest, - OnEvent_UI_HmiResponseCodeIsGenericError_VR_HmiResponseCodeIsUnsupportedResourse_ExpectCommandRemoved) { + OnEvent_UI_HmiResponseCodeIsGenericError_VR_HmiResponseCodeIsUnsupportedResource_ExpectCommandRemoved) { CreateBasicParamsVRRequest(); CreateBasicParamsUIRequest(); SmartObject& params = (*msg_)[strings::params]; @@ -788,7 +791,7 @@ TEST_F( TEST_F( AddCommandRequestTest, - OnEvent_VR_HmiResponseCodeIsGenericError_UI_HmiResponseCodeIsUnsupportedResourse_ExpectCommandRemoved) { + OnEvent_VR_HmiResponseCodeIsGenericError_UI_HmiResponseCodeIsUnsupportedResource_ExpectCommandRemoved) { CreateBasicParamsVRRequest(); CreateBasicParamsUIRequest(); SmartObject& params = (*msg_)[strings::params]; @@ -833,7 +836,7 @@ TEST_F( TEST_F( AddCommandRequestTest, - OnEvent_UI_VR_HmiResponseCodeIsUnsupportedResourse_UI_NotAvailableInterfaceState_ExpectCommandRemoved) { + OnEvent_UI_VR_HmiResponseCodeIsUnsupportedResource_UI_NotAvailableInterfaceState_ExpectCommandRemoved) { CreateBasicParamsVRRequest(); CreateBasicParamsUIRequest(); SmartObject& params = (*msg_)[strings::params]; @@ -883,7 +886,7 @@ TEST_F( TEST_F( AddCommandRequestTest, - OnEvent_UI_VR_HmiResponseCodeIsUnsupportedResourse_VR_NotAvailableInterfaceState_ExpectCommandRemoved) { + OnEvent_UI_VR_HmiResponseCodeIsUnsupportedResource_VR_NotAvailableInterfaceState_ExpectCommandRemoved) { CreateBasicParamsVRRequest(); CreateBasicParamsUIRequest(); SmartObject& params = (*msg_)[strings::params]; @@ -1006,7 +1009,7 @@ TEST_F( } TEST_F(AddCommandRequestTest, - OnEvent_UI_EventWithNotSuccesResponseCode_ExpectVRCommandDelete) { + OnEvent_UI_EventWithNotSuccessResponseCode_ExpectVRCommandDelete) { CreateBasicParamsVRRequest(); CreateBasicParamsUIRequest(); SmartObject& params = (*msg_)[strings::params]; @@ -1048,7 +1051,7 @@ TEST_F(AddCommandRequestTest, ManageHMICommand( HMIResultCodeIs(hmi_apis::FunctionID::VR_DeleteCommand), _)) .WillOnce(Return(true)); - EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)).Times(2); + EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)); request_ptr->on_event(event_ui); request_ptr->on_event(event_vr); } @@ -1091,7 +1094,7 @@ TEST_F(AddCommandRequestTest, ManageHMICommand( HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteCommand), _)) .WillOnce(Return(true)); - EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)).Times(2); + EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)); Event event_vr(hmi_apis::FunctionID::VR_AddCommand); MessageSharedPtr msg_vr = CreateMessage(SmartType_Map); (*msg_vr)[strings::params][hmi_response::code] = @@ -1157,6 +1160,15 @@ TEST_F(AddCommandRequestTest, OnTimeOut_AppRemoveCommandCalled) { CreateCommand<AddCommandRequest>(msg_); request_ptr->Run(); EXPECT_CALL(*mock_app_, RemoveCommand(kCmdId)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteCommand), _)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VR_DeleteCommand), _)) + .WillOnce(Return(true)); + SmartObjectSPtr response = std::make_shared<SmartObject>(SmartType_Map); (*response)[strings::msg_params][strings::info] = "info"; EXPECT_CALL( @@ -1166,6 +1178,7 @@ TEST_F(AddCommandRequestTest, OnTimeOut_AppRemoveCommandCalled) { EXPECT_CALL(mock_rpc_service_, ManageMobileCommand( response, am::commands::Command::CommandSource::SOURCE_SDL)); + std::shared_ptr<RequestFromMobileImpl> base_class_request = static_cast<std::shared_ptr<RequestFromMobileImpl> >(request_ptr); base_class_request->OnTimeOut(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc index 951a206dff..8939ff9633 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc @@ -252,7 +252,7 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_VR_UNSUPPORTED_RESOURCE) { EXPECT_EQ( (*vr_command_result)[strings::msg_params][strings::success].asBool(), - false); + true); EXPECT_EQ( (*vr_command_result)[strings::msg_params][strings::result_code].asInt(), static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc index bd4c5c1ec6..aded581faf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc @@ -205,10 +205,6 @@ TEST_F(DeleteInteractionChoiceSetRequestTest, .WillOnce(Return(choice_set_id)); EXPECT_CALL(*app_, is_perform_interaction_active()).WillOnce(Return(false)); EXPECT_CALL(*app_, performinteraction_choice_set_map()).Times(0); - - EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId)) - .WillOnce(Return(invalid_choice_set_id)); - EXPECT_CALL(*app_, app_id()).Times(0); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc index f1bb7b64ca..7031363fe0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc @@ -81,7 +81,11 @@ class ResetGlobalPropertiesRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> { protected: ResetGlobalPropertiesRequestTest() - : msg_(CreateMessage()), mock_app_(CreateMockApp()) {} + : msg_(CreateMessage()), mock_app_(CreateMockApp()) { + mock_help_prompt_manager_ = + std::shared_ptr<application_manager_test::MockHelpPromptManager>( + new application_manager_test::MockHelpPromptManager()); + } void SetUp() OVERRIDE { (*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey; @@ -99,6 +103,8 @@ class ResetGlobalPropertiesRequestTest MessageSharedPtr msg_; MockAppPtr mock_app_; ResetGlobalPropertiesRequestPtr command_; + std::shared_ptr<application_manager_test::MockHelpPromptManager> + mock_help_prompt_manager_; }; class ResetGlobalPropertiesResponseTest @@ -142,6 +148,9 @@ TEST_F(ResetGlobalPropertiesRequestTest, Run_InvalidVrHelp_UNSUCCESS) { .WillByDefault(Return(std::make_shared<smart_objects::SmartObject>( smart_objects::SmartType_Map))); + EXPECT_CALL(*mock_app_, help_prompt_manager()) + .WillRepeatedly(ReturnRef(*mock_help_prompt_manager_.get())); + EXPECT_CALL(*mock_help_prompt_manager_, OnResetGlobalPropertiesReceived(_)); EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(1); command_->Run(); @@ -169,6 +178,9 @@ TEST_F(ResetGlobalPropertiesRequestTest, Run_SUCCESS) { .WillOnce(Return(msg_params)); EXPECT_CALL(mock_message_helper_, CreateUIResetGlobalPropertiesRequest(_, _)) .WillOnce(Return(msg_params)); + EXPECT_CALL(*mock_app_, help_prompt_manager()) + .WillRepeatedly(ReturnRef(*mock_help_prompt_manager_.get())); + EXPECT_CALL(*mock_help_prompt_manager_, OnResetGlobalPropertiesReceived(_)); EXPECT_CALL( mock_rpc_service_, @@ -208,6 +220,9 @@ TEST_F(ResetGlobalPropertiesRequestTest, EXPECT_CALL(mock_message_helper_, CreateUIResetGlobalPropertiesRequest(_, _)) .WillOnce(Return(msg_params)); + EXPECT_CALL(*mock_app_, help_prompt_manager()) + .WillRepeatedly(ReturnRef(*mock_help_prompt_manager_.get())); + EXPECT_CALL(*mock_help_prompt_manager_, OnResetGlobalPropertiesReceived(_)); EXPECT_CALL( mock_rpc_service_, @@ -253,6 +268,9 @@ TEST_F(ResetGlobalPropertiesRequestTest, .WillOnce(Return(msg_params)); EXPECT_CALL(mock_message_helper_, CreateUIResetGlobalPropertiesRequest(_, _)) .WillOnce(Return(msg_params)); + EXPECT_CALL(*mock_app_, help_prompt_manager()) + .WillRepeatedly(ReturnRef(*mock_help_prompt_manager_.get())); + EXPECT_CALL(*mock_help_prompt_manager_, OnResetGlobalPropertiesReceived(_)); MessageSharedPtr ui_msg = CreateMessage(); (*ui_msg)[am::strings::params][am::strings::correlation_id] = kCorrelationId; @@ -295,6 +313,9 @@ TEST_F(ResetGlobalPropertiesRequestTest, EXPECT_CALL(mock_message_helper_, CreateRCResetGlobalPropertiesRequest(_, _)) .WillOnce(Return(msg_params)); + EXPECT_CALL(*mock_app_, help_prompt_manager()) + .WillRepeatedly(ReturnRef(*mock_help_prompt_manager_.get())); + EXPECT_CALL(*mock_help_prompt_manager_, OnResetGlobalPropertiesReceived(_)); EXPECT_CALL( mock_rpc_service_, @@ -349,6 +370,9 @@ TEST_F(ResetGlobalPropertiesRequestTest, OnEvent_InvalidApp_NoHashUpdate) { .Times(0); EXPECT_CALL(mock_message_helper_, CreateUIResetGlobalPropertiesRequest(_, _)) .WillOnce(Return(msg_params)); + EXPECT_CALL(*mock_app_, help_prompt_manager()) + .WillRepeatedly(ReturnRef(*mock_help_prompt_manager_.get())); + EXPECT_CALL(*mock_help_prompt_manager_, OnResetGlobalPropertiesReceived(_)); EXPECT_CALL( mock_rpc_service_, @@ -400,6 +424,9 @@ TEST_F(ResetGlobalPropertiesRequestTest, .WillOnce(Return(msg_params)); EXPECT_CALL(mock_message_helper_, CreateUIResetGlobalPropertiesRequest(_, _)) .WillOnce(Return(msg_params)); + EXPECT_CALL(*mock_app_, help_prompt_manager()) + .WillRepeatedly(ReturnRef(*mock_help_prompt_manager_.get())); + EXPECT_CALL(*mock_help_prompt_manager_, OnResetGlobalPropertiesReceived(_)); EXPECT_CALL( mock_rpc_service_, @@ -467,6 +494,9 @@ TEST_F(ResetGlobalPropertiesRequestTest, .WillOnce(Return(msg_params)); EXPECT_CALL(mock_message_helper_, CreateUIResetGlobalPropertiesRequest(_, _)) .WillOnce(Return(msg_params)); + EXPECT_CALL(*mock_app_, help_prompt_manager()) + .WillRepeatedly(ReturnRef(*mock_help_prompt_manager_.get())); + EXPECT_CALL(*mock_help_prompt_manager_, OnResetGlobalPropertiesReceived(_)); EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); @@ -535,6 +565,9 @@ TEST_F(ResetGlobalPropertiesRequestTest, .WillOnce(Return(msg_params)); EXPECT_CALL(mock_message_helper_, CreateUIResetGlobalPropertiesRequest(_, _)) .WillOnce(Return(msg_params)); + EXPECT_CALL(*mock_app_, help_prompt_manager()) + .WillRepeatedly(ReturnRef(*mock_help_prompt_manager_.get())); + EXPECT_CALL(*mock_help_prompt_manager_, OnResetGlobalPropertiesReceived(_)); EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index e4a5304a1b..96a5128691 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -148,8 +148,8 @@ ApplicationImpl::ApplicationImpl( "AudioStreamSuspend", new ::timer::TimerTaskImpl<ApplicationImpl>( this, &ApplicationImpl::OnAudioStreamSuspend)) + , extensions_lock_(std::make_shared<sync_primitives::RecursiveLock>()) , hybrid_app_preference_(mobile_api::HybridAppPreference::INVALID_ENUM) - , vi_lock_ptr_(std::make_shared<sync_primitives::Lock>()) , button_lock_ptr_(std::make_shared<sync_primitives::Lock>()) , application_manager_(application_manager) { cmd_number_to_time_limits_[mobile_apis::FunctionID::ReadDIDID] = { @@ -178,12 +178,28 @@ ApplicationImpl::~ApplicationImpl() { active_message_ = NULL; } + button_lock_ptr_->Acquire(); subscribed_buttons_.clear(); + button_lock_ptr_->Release(); + { + sync_primitives::AutoLock lock(cmd_softbuttonid_lock_); + cmd_softbuttonid_.clear(); + } + cmd_number_to_time_limits_.clear(); + if (is_perform_interaction_active()) { set_perform_interaction_active(0); set_perform_interaction_mode(-1); } CleanupFiles(); + { + sync_primitives::AutoLock lock(mobile_message_lock_); + mobile_message_queue_.clear(); + } + { + sync_primitives::AutoLock lock(extensions_lock_); + extensions_.clear(); + } } void ApplicationImpl::CloseActiveMessage() { @@ -1301,6 +1317,7 @@ void ApplicationImpl::set_hmi_level( } AppExtensionPtr ApplicationImpl::QueryInterface(AppExtensionUID uid) { + sync_primitives::AutoLock auto_lock_list(extensions_lock_); std::list<AppExtensionPtr>::const_iterator it = extensions_.begin(); for (; it != extensions_.end(); ++it) { if ((*it)->uid() == uid) { @@ -1315,7 +1332,9 @@ bool ApplicationImpl::AddExtension(AppExtensionPtr extension) { if (!QueryInterface(extension->uid())) { SDL_LOG_TRACE("Add extenstion to add id" << app_id() << " with uid " << extension->uid()); + extensions_lock_->Acquire(); extensions_.push_back(extension); + extensions_lock_->Release(); return true; } return false; @@ -1323,6 +1342,7 @@ bool ApplicationImpl::AddExtension(AppExtensionPtr extension) { bool ApplicationImpl::RemoveExtension(AppExtensionUID uid) { SDL_LOG_AUTO_TRACE(); + sync_primitives::AutoLock auto_lock_list(extensions_lock_); auto it = std::find_if( extensions_.begin(), extensions_.end(), [uid](AppExtensionPtr extension) { return extension->uid() == uid; @@ -1336,8 +1356,11 @@ bool ApplicationImpl::RemoveExtension(AppExtensionUID uid) { return false; } -const std::list<AppExtensionPtr>& ApplicationImpl::Extensions() const { - return extensions_; +const DataAccessor<std::list<AppExtensionPtr> > ApplicationImpl::Extensions() + const { + DataAccessor<std::list<AppExtensionPtr> > accessor(extensions_, + extensions_lock_); + return accessor; } const std::string& ApplicationImpl::cloud_app_endpoint() const { diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index ec37e3b51f..6b14388b65 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -256,8 +256,35 @@ ApplicationManagerImpl::~ApplicationManagerImpl() { streaming_timer_pool_.clear(); } + { + sync_primitives::AutoLock lock(navi_service_status_lock_); + navi_service_status_.clear(); + } + + { + sync_primitives::AutoLock lock(tts_global_properties_app_list_lock_); + tts_global_properties_app_list_.clear(); + } + + { + sync_primitives::AutoLock lock(apps_to_register_list_lock_ptr_); + apps_to_register_.clear(); + } + + { + sync_primitives::AutoLock lock(reregister_wait_list_lock_ptr_); + reregister_wait_list_.clear(); + } + + { + sync_primitives::AutoLock lock(query_apps_devices_lock_); + query_apps_devices_.clear(); + } clear_pool_timer_.Stop(); secondary_transport_devices_cache_.clear(); + applications_list_lock_ptr_->Acquire(); + applications_.clear(); + applications_list_lock_ptr_->Release(); } DataAccessor<ApplicationSet> ApplicationManagerImpl::applications() const { @@ -984,7 +1011,7 @@ void ApplicationManagerImpl::RefreshCloudAppInformation() { return; #else SDL_LOG_AUTO_TRACE(); - if (is_stopping()) { + if (IsStopping()) { return; } std::vector<std::string> enabled_apps; @@ -2567,7 +2594,7 @@ void ApplicationManagerImpl::RemoveHMIFakeParameters( application_manager::commands::MessageSharedPtr& message, const hmi_apis::FunctionID::eType& function_id) { SDL_LOG_AUTO_TRACE(); - hmi_apis::HMI_API factory; + if (!(*message)[jhs::S_PARAMS].keyExists(jhs::S_FUNCTION_ID)) { SDL_LOG_ERROR("RemoveHMIFakeParameters message missing function id"); return; @@ -2576,7 +2603,7 @@ void ApplicationManagerImpl::RemoveHMIFakeParameters( static_cast<mobile_apis::FunctionID::eType>( (*message)[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt()); (*message)[jhs::S_PARAMS][jhs::S_FUNCTION_ID] = function_id; - factory.attachSchema(*message, true); + hmi_so_factory().attachSchema(*message, true); (*message)[jhs::S_PARAMS][jhs::S_FUNCTION_ID] = mobile_function_id; } @@ -3504,10 +3531,6 @@ mobile_apis::Result::eType ApplicationManagerImpl::CheckPolicyPermissions( return mobile_api::Result::SUCCESS; } -bool ApplicationManagerImpl::is_stopping() const { - return is_stopping_; -} - bool ApplicationManagerImpl::is_audio_pass_thru_active() const { return audio_pass_thru_active_; } @@ -3984,11 +4007,23 @@ bool ApplicationManagerImpl::ResetVrHelpTitleItems( const std::string& vr_help_title = get_settings().vr_help_title(); smart_objects::SmartObject so_vr_help_title(vr_help_title); - app->reset_vr_help_title(); - app->reset_vr_help(); app->set_vr_help_title(so_vr_help_title); + app->reset_vr_help(); + auto& help_prompt_manager = app->help_prompt_manager(); + + smart_objects::SmartObject so_vr_help(smart_objects::SmartType_Map); + help_prompt_manager.CreateVRMsg(so_vr_help); + + if (!so_vr_help.keyExists(strings::vr_help)) { + SDL_LOG_WARN("Failed to create vr_help items. Resetting to empty array"); + so_vr_help[strings::vr_help] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + } + + app->set_vr_help(so_vr_help[strings::vr_help]); + return true; } @@ -4542,11 +4577,10 @@ void ApplicationManagerImpl::OnUpdateHMIAppType( const mobile_apis::HMILevel::eType app_hmi_level = (*it)->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); - if (app_hmi_level == mobile_api::HMILevel::HMI_BACKGROUND) { - MessageHelper::SendUIChangeRegistrationRequestToHMI(*it, *this); - } else if ((app_hmi_level == mobile_api::HMILevel::HMI_FULL) || - (app_hmi_level == mobile_api::HMILevel::HMI_LIMITED)) { - MessageHelper::SendUIChangeRegistrationRequestToHMI(*it, *this); + + MessageHelper::SendUIChangeRegistrationRequestToHMI(*it, *this); + if ((app_hmi_level == mobile_api::HMILevel::HMI_FULL) || + (app_hmi_level == mobile_api::HMILevel::HMI_LIMITED)) { state_controller().SetRegularState( *it, mobile_apis::PredefinedWindows::DEFAULT_WINDOW, diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc index 34c2a6d6bc..7907cea2ab 100644 --- a/src/components/application_manager/src/commands/command_impl.cc +++ b/src/components/application_manager/src/commands/command_impl.cc @@ -174,6 +174,10 @@ void CommandImpl::SetAllowedToTerminate(const bool allowed) { allowed_to_terminate_ = allowed; } +const ApplicationManager& CommandImpl::GetApplicationManager() const { + return application_manager_; +} + bool CommandImpl::CheckAllowedParameters(const Command::CommandSource source) { SDL_LOG_AUTO_TRACE(); diff --git a/src/components/application_manager/src/commands/request_from_mobile_impl.cc b/src/components/application_manager/src/commands/request_from_mobile_impl.cc index 42df13f034..2e81ae5aea 100644 --- a/src/components/application_manager/src/commands/request_from_mobile_impl.cc +++ b/src/components/application_manager/src/commands/request_from_mobile_impl.cc @@ -660,9 +660,16 @@ bool RequestFromMobileImpl::PrepareResultForMobileResponse( ResponseInfo& out_second, ResponseInfo& out_third) const { SDL_LOG_AUTO_TRACE(); - bool result = (PrepareResultForMobileResponse(out_first, out_second) || - PrepareResultForMobileResponse(out_second, out_third)) && - PrepareResultForMobileResponse(out_first, out_third); + bool result_first_second = + PrepareResultForMobileResponse(out_first, out_second); + bool result_second_third = + PrepareResultForMobileResponse(out_second, out_third); + bool result_first_third = + PrepareResultForMobileResponse(out_first, out_third); + + bool result = (result_first_second && result_first_third) || + (result_second_third && result_first_second) || + (result_second_third && result_first_third); return result; } diff --git a/src/components/application_manager/src/help_prompt_manager_impl.cc b/src/components/application_manager/src/help_prompt_manager_impl.cc index 30a1139deb..99a919366e 100644 --- a/src/components/application_manager/src/help_prompt_manager_impl.cc +++ b/src/components/application_manager/src/help_prompt_manager_impl.cc @@ -183,6 +183,40 @@ void HelpPromptManagerImpl::OnSetGlobalPropertiesReceived( SetSendingType(msg); } +void HelpPromptManagerImpl::OnResetGlobalPropertiesReceived( + const smart_objects::SmartObject& msg) { + SDL_LOG_AUTO_TRACE(); + auto& global_properties_ids = msg[strings::properties]; + + for (size_t i = 0; i < global_properties_ids.length(); ++i) { + mobile_apis::GlobalProperty::eType global_property = + static_cast<mobile_apis::GlobalProperty::eType>( + global_properties_ids[i].asInt()); + switch (global_property) { + case mobile_apis::GlobalProperty::HELPPROMPT: { + sending_type_ = (SendingType::kNoneSend == sending_type_ || + SendingType::kSendHelpPrompt == sending_type_) + ? SendingType::kSendHelpPrompt + : SendingType::kSendBoth; + break; + } + case mobile_apis::GlobalProperty::VRHELPTITLE: + case mobile_apis::GlobalProperty::VRHELPITEMS: { + sending_type_ = (SendingType::kNoneSend == sending_type_ || + SendingType::kSendVRHelp == sending_type_) + ? SendingType::kSendVRHelp + : SendingType::kSendBoth; + break; + } + default: { + return; + } + } + } + + SDL_LOG_DEBUG("Sending type set to:" << static_cast<uint32_t>(sending_type_)); +} + HelpPromptManagerImpl::SendingType HelpPromptManagerImpl::GetSendingType() const { return sending_type_; @@ -330,12 +364,22 @@ void HelpPromptManagerImpl::CreateVRMsg( GenerateVrItems(out_msg_params, strings::vr_help); if (out_msg_params[strings::vr_help].empty()) { - out_msg_params.erase(strings::vr_help); - app_.reset_vr_help(); - } else { - app_.set_vr_help(out_msg_params[strings::vr_help]); + int32_t index = 0; + + smart_objects::SmartObject so_default_vr_help(smart_objects::SmartType_Map); + so_default_vr_help[strings::position] = index + 1; + so_default_vr_help[strings::text] = app_.name(); + out_msg_params[strings::vr_help][index++] = so_default_vr_help; + + if (app_.vr_synonyms()) { + smart_objects::SmartObject item(smart_objects::SmartType_Map); + item[strings::text] = (*(app_.vr_synonyms())).getElement(0); + item[strings::position] = index + 1; + out_msg_params[strings::vr_help][index++] = item; + } } -} + app_.set_vr_help(out_msg_params[strings::vr_help]); +} // namespace application_manager void HelpPromptManagerImpl::SetSendingType( const smart_objects::SmartObject& msg) { diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index 07200af6cd..6dc3264ac0 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -50,6 +50,7 @@ HmiState::HmiState(std::shared_ptr<Application> app, : hmi_app_id_(app->hmi_app_id()) , state_id_(state_id) , app_mngr_(app_mngr) + , parent_(HmiStatePtr()) , window_type_(mobile_apis::WindowType::INVALID_ENUM) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) @@ -63,6 +64,7 @@ HmiState::HmiState(std::shared_ptr<Application> app, : hmi_app_id_(app->hmi_app_id()) , state_id_(STATE_ID_REGULAR) , app_mngr_(app_mngr) + , parent_(HmiStatePtr()) , window_type_(mobile_apis::WindowType::INVALID_ENUM) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) 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 2e60bb2c66..d5d87a6a2f 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -383,13 +383,10 @@ MessageHelper::CreateUIResetGlobalPropertiesRequest( smart_objects::SmartType_Map); if (reset_result.vr_help_title_items) { - smart_objects::SmartObjectSPtr vr_help = CreateAppVrHelp(application); - if (!vr_help.get()) { - SDL_LOG_WARN("Failed to create vr_help"); - return smart_objects::SmartObjectSPtr(); - } else { - ui_reset_global_prop_request = vr_help; - } + (*ui_reset_global_prop_request)[strings::vr_help_title] = + *(application->vr_help_title()); + (*ui_reset_global_prop_request)[strings::vr_help] = + *(application->vr_help()); } if (reset_result.menu_name) { (*ui_reset_global_prop_request)[hmi_request::menu_title] = ""; @@ -740,11 +737,16 @@ void MessageHelper::SendDeleteChoiceSetRequest(smart_objects::SmartObject* cmd, DCHECK_OR_RETURN_VOID(cmd); using namespace smart_objects; - SmartObject msg_params = SmartObject(smart_objects::SmartType_Map); + if (!cmd->keyExists(strings::grammar_id) || + (*cmd)[strings::grammar_id].asInt() == -1) { + return; + } + SmartObject msg_params = SmartObject(smart_objects::SmartType_Map); msg_params[strings::app_id] = application->app_id(); msg_params[strings::type] = hmi_apis::Common_VRCommandType::Choice; msg_params[strings::grammar_id] = (*cmd)[strings::grammar_id]; + cmd = &((*cmd)[strings::choice_set]); for (uint32_t i = 0; i < (*cmd).length(); ++i) { msg_params[strings::cmd_id] = (*cmd)[i][strings::choice_id]; @@ -769,7 +771,10 @@ void MessageHelper::SendResetPropertiesRequest(ApplicationSharedPtr application, using namespace smart_objects; { - SmartObject msg_params = *MessageHelper::CreateAppVrHelp(application); + auto& help_prompt_manager = application->help_prompt_manager(); + smart_objects::SmartObject msg_params(smart_objects::SmartType_Map); + help_prompt_manager.CreateVRMsg(msg_params); + msg_params[hmi_request::menu_title] = ""; smart_objects::SmartObject keyboard_properties = @@ -1410,46 +1415,6 @@ void MessageHelper::SendTTSGlobalProperties(ApplicationSharedPtr app, } } -smart_objects::SmartObjectSPtr MessageHelper::CreateAppVrHelp( - ApplicationConstSharedPtr app) { - smart_objects::SmartObjectSPtr result = - std::make_shared<smart_objects::SmartObject>( - smart_objects::SmartType_Map); - - smart_objects::SmartObject& vr_help = *result; - const smart_objects::SmartObjectSPtr vr_help_title = app->vr_help_title(); - if (vr_help_title) { - vr_help[strings::vr_help_title] = vr_help_title->asString(); - } - - int32_t index = 0; - - smart_objects::SmartObject so_vr_help(smart_objects::SmartType_Map); - so_vr_help[strings::position] = index + 1; - so_vr_help[strings::text] = app->name(); - vr_help[strings::vr_help][index++] = so_vr_help; - - if (app->vr_synonyms()) { - smart_objects::SmartObject item(smart_objects::SmartType_Map); - item[strings::text] = (*(app->vr_synonyms())).getElement(0); - item[strings::position] = index + 1; - vr_help[strings::vr_help][index++] = item; - } - - // copy all app VR commands - const DataAccessor<CommandsMap> cmd_accessor = app->commands_map(); - const CommandsMap& commands = cmd_accessor.GetData(); - CommandsMap::const_iterator it = commands.begin(); - - for (; commands.end() != it; ++it) { - smart_objects::SmartObject item(smart_objects::SmartType_Map); - item[strings::text] = (*it->second)[strings::vr_commands][0].asString(); - item[strings::position] = index + 1; - vr_help[strings::vr_help][index++] = item; - } - return result; -} - smart_objects::SmartObjectList MessageHelper::CreateShowRequestToHMI( ApplicationConstSharedPtr app, const uint32_t correlation_id) { smart_objects::SmartObjectList requests; @@ -1567,6 +1532,7 @@ smart_objects::SmartObjectList MessageHelper::CreateAddCommandRequestToHMI( smart_objects::SmartObjectList MessageHelper::CreateAddVRCommandRequestFromChoiceToHMI( ApplicationConstSharedPtr app, ApplicationManager& app_mngr) { + SDL_LOG_AUTO_TRACE(); smart_objects::SmartObjectList requests; if (!app) { SDL_LOG_ERROR("Invalid application"); @@ -1581,6 +1547,11 @@ MessageHelper::CreateAddVRCommandRequestFromChoiceToHMI( (*(it->second))[strings::grammar_id].asUInt(); const size_t size = (*(it->second))[strings::choice_set].length(); for (size_t j = 0; j < size; ++j) { + if (!(*(it->second))[strings::choice_set][j].keyExists( + strings::vr_commands)) { + continue; + } + smart_objects::SmartObjectSPtr vr_command = CreateMessageForHMI( hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); if (!vr_command) { diff --git a/src/components/application_manager/src/request_controller_impl.cc b/src/components/application_manager/src/request_controller_impl.cc index 79458566dc..e331ea89e9 100644 --- a/src/components/application_manager/src/request_controller_impl.cc +++ b/src/components/application_manager/src/request_controller_impl.cc @@ -72,6 +72,24 @@ RequestControllerImpl::RequestControllerImpl( RequestControllerImpl::~RequestControllerImpl() { SDL_LOG_AUTO_TRACE(); Stop(); + + retained_mobile_requests_.clear(); + + { + sync_primitives::AutoLock auto_lock_list(notification_list_lock_); + notification_list_.clear(); + } + + { + sync_primitives::AutoLock auto_lock_list(duplicate_message_count_lock_); + duplicate_message_count_.clear(); + } + + { + sync_primitives::AutoLock auto_lock_list(mobile_request_list_lock_); + mobile_request_list_.clear(); + waiting_for_response_.RemoveMobileRequests(); + } } void RequestControllerImpl::Stop() { @@ -111,7 +129,6 @@ void RequestControllerImpl::InitializeThreadpool() { void RequestControllerImpl::DestroyThreadpool() { SDL_LOG_AUTO_TRACE(); { - AutoLock auto_lock(mobile_request_list_lock_); pool_state_ = TPoolState::STOPPED; SDL_LOG_DEBUG("Broadcasting STOP signal to all threads..."); cond_var_.Broadcast(); // notify all threads we are shutting down @@ -159,7 +176,9 @@ bool RequestControllerImpl::CheckPendingRequestsAmount( SDL_LOG_AUTO_TRACE(); if (pending_requests_amount > 0) { + mobile_request_list_lock_.Acquire(); const size_t pending_requests_size = mobile_request_list_.size(); + mobile_request_list_lock_.Release(); const bool available_to_add = pending_requests_amount > pending_requests_size; if (!available_to_add) { @@ -181,11 +200,12 @@ RequestController::TResult RequestControllerImpl::AddMobileRequest( cond_var_.NotifyOne(); return TResult::INVALID_DATA; } + SDL_LOG_DEBUG("correlation_id : " << request->correlation_id() << "connection_key : " << request->connection_key()); RequestController::TResult result = CheckPosibilitytoAdd(request, hmi_level); - if (TResult::SUCCESS == result) { + if (TResult::SUCCESS == result && TPoolState::STOPPED != pool_state_) { AutoLock auto_lock_list(mobile_request_list_lock_); mobile_request_list_.push_back(request); SDL_LOG_DEBUG("Waiting for execution: " << mobile_request_list_.size()); @@ -431,11 +451,13 @@ void RequestControllerImpl::TerminateWaitingForResponseAppRequests( void RequestControllerImpl::TerminateAppRequests(const uint32_t app_id) { SDL_LOG_AUTO_TRACE(); + mobile_request_list_lock_.Acquire(); SDL_LOG_DEBUG("app_id : " << app_id << "Requests waiting for execution count : " << mobile_request_list_.size() << "Requests waiting for response count : " << waiting_for_response_.Size()); + mobile_request_list_lock_.Release(); TerminateWaitingForExecutionAppRequests(app_id); TerminateWaitingForResponseAppRequests(app_id); @@ -452,8 +474,9 @@ void RequestControllerImpl::TerminateAllMobileRequests() { waiting_for_response_.RemoveMobileRequests(); SDL_LOG_DEBUG("Mobile Requests waiting for response cleared"); - AutoLock waiting_execution_auto_lock(mobile_request_list_lock_); + mobile_request_list_lock_.Acquire(); mobile_request_list_.clear(); + mobile_request_list_lock_.Release(); SDL_LOG_DEBUG("Mobile Requests waiting for execution cleared"); NotifyTimer(); } @@ -590,27 +613,32 @@ RequestControllerImpl::Worker::~Worker() {} void RequestControllerImpl::Worker::threadMain() { SDL_LOG_AUTO_TRACE(); - AutoLock auto_lock(thread_lock_); + AutoLock auto_thread_lock_(thread_lock_); while (!stop_flag_) { // Try to pick a request - AutoLock auto_lock(request_controller_->mobile_request_list_lock_); + request_controller_->mobile_request_list_lock_.Acquire(); while ((request_controller_->pool_state_ != TPoolState::STOPPED) && (request_controller_->mobile_request_list_.empty())) { // Wait until there is a task in the queue // Unlock mutex while wait, then lock it back when signaled SDL_LOG_INFO("Unlocking and waiting"); - request_controller_->cond_var_.Wait(auto_lock); + request_controller_->cond_var_.Wait( + request_controller_->mobile_request_list_lock_); SDL_LOG_INFO("Signaled and locking"); } // If the thread was shutdown, return from here if (request_controller_->pool_state_ == TPoolState::STOPPED) { + SDL_LOG_WARN("TPoolState::STOPPED"); + request_controller_->mobile_request_list_.clear(); + request_controller_->mobile_request_list_lock_.Release(); break; } if (request_controller_->mobile_request_list_.empty()) { SDL_LOG_WARN("Mobile request list is empty"); + request_controller_->mobile_request_list_lock_.Release(); break; } @@ -640,6 +668,7 @@ void RequestControllerImpl::Worker::threadMain() { cmd_request->SendResponse( false, mobile_apis::Result::INVALID_ID, "Duplicate correlation_id"); } + request_controller_->mobile_request_list_lock_.Release(); continue; } SDL_LOG_DEBUG("timeout_in_mseconds " << timeout_in_mseconds); @@ -653,7 +682,7 @@ void RequestControllerImpl::Worker::threadMain() { "of this request."); } - AutoUnlock unlock(auto_lock); + request_controller_->mobile_request_list_lock_.Release(); // execute if ((false == request_controller_->IsLowVoltage()) && @@ -663,6 +692,12 @@ void RequestControllerImpl::Worker::threadMain() { << " with timeout: " << timeout_in_mseconds); request_ptr->Run(); } + if (request_ptr->GetApplicationManager().IsStopping()) { + request_controller_->mobile_request_list_lock_.Acquire(); + request_controller_->mobile_request_list_.clear(); + request_controller_->waiting_for_response_.RemoveMobileRequests(); + request_controller_->mobile_request_list_lock_.Release(); + } } } 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 96870c12c1..c74ccaf4a1 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc @@ -734,7 +734,7 @@ bool ResumeCtrlImpl::CheckDelayBeforeIgnOff( return true; } - const uint32_t sec_spent_before_ign = labs(ign_off_time - time_stamp); + const uint64_t sec_spent_before_ign = labs(ign_off_time - time_stamp); SDL_LOG_DEBUG( "ign_off_time " << ign_off_time << "; app_disconnect_time " << time_stamp diff --git a/src/components/application_manager/src/resumption/resumption_data.cc b/src/components/application_manager/src/resumption/resumption_data.cc index 50b95dba42..0663237c43 100644 --- a/src/components/application_manager/src/resumption/resumption_data.cc +++ b/src/components/application_manager/src/resumption/resumption_data.cc @@ -163,7 +163,8 @@ smart_objects::SmartObject ResumptionData::GetApplicationSubscriptions( subscriptions); } - for (auto extension : application->Extensions()) { + auto extensions = application->Extensions(); + for (auto& extension : extensions.GetData()) { extension->SaveResumptionData(subscriptions); } 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 eedfc48b73..ce68609ee9 100644 --- a/src/components/application_manager/src/resumption/resumption_data_db.cc +++ b/src/components/application_manager/src/resumption/resumption_data_db.cc @@ -356,7 +356,7 @@ bool ResumptionDataDB::RemoveApplicationFromSaved( return result; } -uint32_t ResumptionDataDB::GetIgnOffTime() const { +int64_t ResumptionDataDB::GetIgnOffTime() const { SDL_LOG_AUTO_TRACE(); return SelectIgnOffTime(); } @@ -533,14 +533,14 @@ bool ResumptionDataDB::SelectHashId(const std::string& policy_app_id, return false; } -uint32_t ResumptionDataDB::SelectIgnOffTime() const { +int64_t ResumptionDataDB::SelectIgnOffTime() const { SDL_LOG_AUTO_TRACE(); - uint32_t ignOffTime = 0; + int64_t ignOffTime = 0; utils::dbms::SQLQuery query(db()); if (query.Prepare(kSelectIgnOffTime)) { if (query.Exec()) { - ignOffTime = query.GetUInteger(0); + ignOffTime = query.GetLongInt(0); SDL_LOG_INFO("Last ign off time = " << ignOffTime); return ignOffTime; } @@ -612,7 +612,7 @@ void ResumptionDataDB::SelectDataForLoadResumeData( SmartObject so_obj(SmartType_Map); so_obj[strings::hmi_level] = select_data.GetInteger(0); so_obj[strings::ign_off_count] = select_data.GetInteger(1); - so_obj[strings::time_stamp] = select_data.GetUInteger(2); + so_obj[strings::time_stamp] = select_data.GetLongInt(2); so_obj[strings::app_id] = select_data.GetString(3); so_obj[strings::device_id] = select_data.GetString(4); so_array_data[i++] = so_obj; @@ -1470,7 +1470,7 @@ bool ResumptionDataDB::SelectDataFromAppTable( saved_app[strings::hmi_app_id] = query.GetUInteger(4); saved_app[strings::hmi_level] = query.GetInteger(5); saved_app[strings::ign_off_count] = query.GetInteger(6); - saved_app[strings::time_stamp] = query.GetUInteger(7); + saved_app[strings::time_stamp] = query.GetLongInt(7); saved_app[strings::device_id] = query.GetString(8); saved_app[strings::is_media_application] = query.GetBoolean(9); saved_app[strings::subscribed_for_way_points] = query.GetBoolean(10); 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 5d6d008911..a2b99b4ac1 100644 --- a/src/components/application_manager/src/resumption/resumption_data_json.cc +++ b/src/components/application_manager/src/resumption/resumption_data_json.cc @@ -62,7 +62,7 @@ void ResumptionDataJson::SaveApplication( << " policy_app_id : " << policy_app_id); const std::string hash = application->curHash(); const uint32_t grammar_id = application->get_grammar_id(); - const uint32_t time_stamp = (uint32_t)time(NULL); + const int64_t time_stamp = (int64_t)time(NULL); const std::string device_mac = application->mac_address(); const mobile_apis::HMILevel::eType hmi_level = application->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); @@ -288,7 +288,7 @@ bool ResumptionDataJson::RemoveApplicationFromSaved( return result; } -uint32_t ResumptionDataJson::GetIgnOffTime() const { +int64_t ResumptionDataJson::GetIgnOffTime() const { using namespace app_mngr; SDL_LOG_AUTO_TRACE(); @@ -300,7 +300,7 @@ uint32_t ResumptionDataJson::GetIgnOffTime() const { accessor.GetMutableData().set_dictionary(dictionary); SDL_LOG_WARN("last_save_time section is missed"); } - return resumption[strings::last_ign_off_time].asUInt(); + return resumption[strings::last_ign_off_time].asInt64(); } uint32_t ResumptionDataJson::GetGlobalIgnOnCounter() const { @@ -399,7 +399,7 @@ void ResumptionDataJson::GetDataForLoadResumeData( smart_objects::SmartObject so(smart_objects::SmartType_Map); so[strings::hmi_level] = saved_app[strings::hmi_level].asInt(); so[strings::ign_off_count] = saved_app[strings::ign_off_count].asInt(); - so[strings::time_stamp] = saved_app[strings::time_stamp].asUInt(); + so[strings::time_stamp] = saved_app[strings::time_stamp].asInt64(); so[strings::app_id] = saved_app[strings::app_id].asString(); so[strings::device_id] = saved_app[strings::device_id].asString(); so_array_data[i++] = so; @@ -532,7 +532,7 @@ void ResumptionDataJson::SetLastIgnOffTime(time_t ign_off_time, SDL_LOG_WARN("ign_off_time = " << ign_off_time); Json::Value& resumption = GetResumptionData(dictionary); - resumption[strings::last_ign_off_time] = static_cast<uint32_t>(ign_off_time); + resumption[strings::last_ign_off_time] = static_cast<int64_t>(ign_off_time); } bool ResumptionDataJson::Init() { diff --git a/src/components/application_manager/src/resumption/resumption_data_processor_impl.cc b/src/components/application_manager/src/resumption/resumption_data_processor_impl.cc index b8462a533a..996b4f3026 100644 --- a/src/components/application_manager/src/resumption/resumption_data_processor_impl.cc +++ b/src/components/application_manager/src/resumption/resumption_data_processor_impl.cc @@ -178,7 +178,7 @@ void ResumptionDataProcessorImpl::ProcessResumptionStatus( } } -void ResumptionDataProcessorImpl::EraseProcessedRequest( +bool ResumptionDataProcessorImpl::EraseProcessedRequest( const uint32_t app_id, const ResumptionRequest& found_request) { SDL_LOG_AUTO_TRACE(); @@ -194,7 +194,11 @@ void ResumptionDataProcessorImpl::EraseProcessedRequest( request.request_id.function_id == found_request.request_id.function_id; }); - list_of_sent_requests.erase(request_iter); + if (request_iter != list_of_sent_requests.end()) { + list_of_sent_requests.erase(request_iter); + return true; + } + return false; } bool ResumptionDataProcessorImpl::IsResumptionFinished( @@ -285,6 +289,7 @@ void ResumptionDataProcessorImpl::ProcessResponseFromHMI( SDL_LOG_DEBUG("app_id is: " << app_id); auto found_request = GetRequest(app_id, function_id, corr_id); + if (!found_request) { SDL_LOG_ERROR("Request with function id " << function_id << " and corr id " << corr_id << " not found"); @@ -293,7 +298,11 @@ void ResumptionDataProcessorImpl::ProcessResponseFromHMI( auto request = *found_request; ProcessResumptionStatus(app_id, response, request); - EraseProcessedRequest(app_id, request); + + if (!EraseProcessedRequest(app_id, request)) { + SDL_LOG_DEBUG("Request has already been processed"); + return; + } if (!IsResumptionFinished(app_id)) { SDL_LOG_DEBUG("Resumption app " @@ -890,7 +899,8 @@ void ResumptionDataProcessorImpl::AddPluginsSubscriptions( const smart_objects::SmartObject& saved_app) { SDL_LOG_AUTO_TRACE(); - for (auto& extension : application->Extensions()) { + auto extensions = application->Extensions(); + for (auto& extension : extensions.GetData()) { extension->ProcessResumption(saved_app); } } @@ -995,7 +1005,7 @@ void ResumptionDataProcessorImpl::DeletePluginsSubscriptions( resumption_status_lock_.Release(); auto extensions = application->Extensions(); - for (auto& extension : extensions) { + for (auto& extension : extensions.GetData()) { extension->RevertResumption(resumption_data_to_revert); } } diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc index b6b9f2e16b..3e0a600d72 100644 --- a/src/components/application_manager/src/rpc_handler_impl.cc +++ b/src/components/application_manager/src/rpc_handler_impl.cc @@ -212,7 +212,7 @@ void RPCHandlerImpl::Handle(const impl::MessageFromMobile message) { SDL_LOG_ERROR("Null-pointer message received."); return; } - if (app_manager_.is_stopping()) { + if (app_manager_.IsStopping()) { SDL_LOG_INFO("Application manager is stopping"); return; } diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc index 28146a1adc..9880edb4a1 100644 --- a/src/components/application_manager/src/state_controller_impl.cc +++ b/src/components/application_manager/src/state_controller_impl.cc @@ -112,20 +112,7 @@ void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, resolved_state->hmi_level()); if (request_hmi_state_change) { - const int64_t result = RequestHMIStateChange(app, hmi_level, true); - if (-1 != result) { - const uint32_t corr_id = static_cast<uint32_t>(result); - - subscribe_on_event( - hmi_apis::FunctionID::BasicCommunication_CloseApplication, corr_id); - subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_ActivateApp, - corr_id); - - waiting_for_response_[app->app_id()] = resolved_state; - app_mngr_.set_application_id(corr_id, app->hmi_app_id()); - return; - } - SDL_LOG_ERROR("Unable to send BC.ActivateApp"); + RequestHMIStateChange(app, resolved_state, hmi_level, true); return; } ApplyRegularState(app, window_id, resolved_state); @@ -1104,8 +1091,9 @@ void StateControllerImpl::OnAppWindowAdded( OnStateChanged(app, window_id, initial_state, new_state); } -int64_t StateControllerImpl::RequestHMIStateChange( +void StateControllerImpl::RequestHMIStateChange( ApplicationConstSharedPtr app, + HmiStatePtr resolved_state, hmi_apis::Common_HMILevel::eType level, bool send_policy_priority) { SDL_LOG_AUTO_TRACE(); @@ -1122,15 +1110,21 @@ int64_t StateControllerImpl::RequestHMIStateChange( } if (!request) { SDL_LOG_ERROR("Unable to create request"); - return -1; + return; } + + const uint32_t corr_id = + (*request)[strings::params][strings::correlation_id].asUInt(); + subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_CloseApplication, + corr_id); + subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_ActivateApp, + corr_id); + waiting_for_response_[app->app_id()] = resolved_state; + app_mngr_.set_application_id(corr_id, app->hmi_app_id()); + if (!app_mngr_.GetRPCService().ManageHMICommand(request)) { SDL_LOG_ERROR("Unable to send request"); - return -1; } - const uint32_t corr_id = - (*request)[strings::params][strings::correlation_id].asUInt(); - return static_cast<int64_t>(corr_id); } void StateControllerImpl::ApplyPostponedStateForApp(ApplicationSharedPtr app) { diff --git a/src/components/application_manager/test/include/application_manager/mock_application.h b/src/components/application_manager/test/include/application_manager/mock_application.h index e94ffa5961..5568db4dd1 100644 --- a/src/components/application_manager/test/include/application_manager/mock_application.h +++ b/src/components/application_manager/test/include/application_manager/mock_application.h @@ -404,8 +404,9 @@ class MockApplication : public ::application_manager::Application { MOCK_METHOD1(AddExtension, bool(application_manager::AppExtensionPtr extention)); MOCK_METHOD1(RemoveExtension, bool(application_manager::AppExtensionUID uid)); - MOCK_CONST_METHOD0(Extensions, - const std::list<application_manager::AppExtensionPtr>&()); + MOCK_CONST_METHOD0( + Extensions, + const DataAccessor<std::list<application_manager::AppExtensionPtr> >()); MOCK_CONST_METHOD0(is_remote_control_supported, bool()); MOCK_METHOD1(set_remote_control_supported, void(const bool allow)); MOCK_CONST_METHOD0(cloud_app_endpoint, const std::string&()); diff --git a/src/components/application_manager/test/include/application_manager/mock_help_prompt_manager.h b/src/components/application_manager/test/include/application_manager/mock_help_prompt_manager.h index b44345deff..74f40c7613 100644 --- a/src/components/application_manager/test/include/application_manager/mock_help_prompt_manager.h +++ b/src/components/application_manager/test/include/application_manager/mock_help_prompt_manager.h @@ -51,7 +51,13 @@ class MockHelpPromptManager : public ::application_manager::HelpPromptManager { void(uint32_t cmd_id, const bool should_send_requests)); MOCK_METHOD2(OnSetGlobalPropertiesReceived, void(const smart_objects::SmartObject& msg, bool is_response)); + MOCK_METHOD1(OnResetGlobalPropertiesReceived, + void(const smart_objects::SmartObject& msg)); + MOCK_CONST_METHOD0(GetSendingType, SendingType()); + MOCK_METHOD1(CreatePromptMsg, + void(smart_objects::SmartObject& out_msg_params)); + MOCK_METHOD1(CreateVRMsg, void(smart_objects::SmartObject& out_msg_params)); }; } // namespace application_manager_test diff --git a/src/components/application_manager/test/include/application_manager/mock_message_helper.h b/src/components/application_manager/test/include/application_manager/mock_message_helper.h index 67d992d4af..0892a47f8c 100644 --- a/src/components/application_manager/test/include/application_manager/mock_message_helper.h +++ b/src/components/application_manager/test/include/application_manager/mock_message_helper.h @@ -312,8 +312,6 @@ class MockMessageHelper { MOCK_METHOD2(SendQueryApps, void(const uint32_t connection_key, ApplicationManager& app_man)); - MOCK_METHOD1(CreateAppVrHelp, - smart_objects::SmartObjectSPtr(ApplicationConstSharedPtr app)); MOCK_METHOD3(VerifyImageVrHelpItems, mobile_apis::Result::eType(smart_objects::SmartObject& message, ApplicationConstSharedPtr app, diff --git a/src/components/application_manager/test/include/application_manager/mock_request.h b/src/components/application_manager/test/include/application_manager/mock_request.h index 4348e39020..098002f15d 100644 --- a/src/components/application_manager/test/include/application_manager/mock_request.h +++ b/src/components/application_manager/test/include/application_manager/mock_request.h @@ -63,6 +63,8 @@ class MockRequest : public application_manager::commands::Command { MOCK_METHOD0(AllowedToTerminate, bool()); MOCK_METHOD1(SetAllowedToTerminate, void(bool is_allowed)); + MOCK_CONST_METHOD0(GetApplicationManager, + application_manager::ApplicationManager&()); MOCK_CONST_METHOD0(connection_key, uint32_t()); MOCK_CONST_METHOD0(correlation_id, uint32_t()); }; diff --git a/src/components/application_manager/test/include/application_manager/mock_resumption_data.h b/src/components/application_manager/test/include/application_manager/mock_resumption_data.h index 7cabc12086..b99ce11619 100644 --- a/src/components/application_manager/test/include/application_manager/mock_resumption_data.h +++ b/src/components/application_manager/test/include/application_manager/mock_resumption_data.h @@ -78,7 +78,7 @@ class MockResumptionData : public ::resumption::ResumptionData { MOCK_METHOD2(RemoveApplicationFromSaved, bool(const std::string& policy_app_id, const std::string& device_id)); - MOCK_CONST_METHOD0(GetIgnOffTime, uint32_t()); + MOCK_CONST_METHOD0(GetIgnOffTime, int64_t()); MOCK_CONST_METHOD2(IsApplicationSaved, ssize_t(const std::string& policy_app_id, const std::string& device_id)); diff --git a/src/components/application_manager/test/include/application_manager/resumption_data_test.h b/src/components/application_manager/test/include/application_manager/resumption_data_test.h index bea920e44e..93fa6bcae9 100644 --- a/src/components/application_manager/test/include/application_manager/resumption_data_test.h +++ b/src/components/application_manager/test/include/application_manager/resumption_data_test.h @@ -75,6 +75,7 @@ class ResumptionDataTest : public ::testing::Test { , setlock_ptr_(std::make_shared<sync_primitives::Lock>()) , btnlock_ptr_(std::make_shared<sync_primitives::Lock>()) , ivilock_ptr_(std::make_shared<sync_primitives::Lock>()) + , extensions_lock_(std::make_shared<sync_primitives::RecursiveLock>()) , window_params_map_lock_ptr_(std::make_shared<sync_primitives::Lock>()) { } virtual ~ResumptionDataTest(); @@ -162,6 +163,7 @@ class ResumptionDataTest : public ::testing::Test { std::shared_ptr<sync_primitives::Lock> setlock_ptr_; std::shared_ptr<sync_primitives::Lock> btnlock_ptr_; std::shared_ptr<sync_primitives::Lock> ivilock_ptr_; + std::shared_ptr<sync_primitives::RecursiveLock> extensions_lock_; std::shared_ptr<sync_primitives::Lock> window_params_map_lock_ptr_; application_manager_test::MockApplicationManagerSettings mock_application_manager_settings_; diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc index 9212b0feab..16e696a3bd 100644 --- a/src/components/application_manager/test/mock_message_helper.cc +++ b/src/components/application_manager/test/mock_message_helper.cc @@ -479,11 +479,6 @@ void MessageHelper::SendQueryApps(const uint32_t connection_key, app_man); } -smart_objects::SmartObjectSPtr MessageHelper::CreateAppVrHelp( - ApplicationConstSharedPtr app) { - return MockMessageHelper::message_helper_mock()->CreateAppVrHelp(app); -} - mobile_apis::Result::eType MessageHelper::VerifyImageVrHelpItems( smart_objects::SmartObject& message, ApplicationConstSharedPtr app, diff --git a/src/components/application_manager/test/request_controller/request_controller_test.cc b/src/components/application_manager/test/request_controller/request_controller_test.cc index 2de2a69cf7..796df0810f 100644 --- a/src/components/application_manager/test/request_controller/request_controller_test.cc +++ b/src/components/application_manager/test/request_controller/request_controller_test.cc @@ -45,7 +45,6 @@ #include "application_manager/event_engine/event_dispatcher.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_application_manager.h" #include "application_manager/mock_request_controller_settings.h" #include "application_manager/mock_request_timeout_handler.h" #include "application_manager/policies/policy_handler.h" @@ -62,10 +61,12 @@ namespace request_controller_test { using ::application_manager::request_controller::RequestController; using ::application_manager::request_controller::RequestControllerImpl; using ::application_manager::request_controller::RequestInfo; +using ::test::components::application_manager_test::MockApplicationManager; using test::components::application_manager_test::MockRequestTimeoutHandler; using ::test::components::event_engine_test::MockEventDispatcher; using ::testing::_; +using ::testing::DoAll; using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; @@ -168,6 +169,7 @@ class RequestControllerTestClass : public ::testing::Test { RequestControllerSPtr request_ctrl_; RequestPtr empty_mock_request_; const TestSettings default_settings_; + NiceMock<MockApplicationManager> app_mngr_; }; TEST_F(RequestControllerTestClass, @@ -179,13 +181,20 @@ TEST_F(RequestControllerTestClass, EXPECT_CALL(*request_valid, Run()) .Times(1) .WillRepeatedly(NotifyTestAsyncWaiter(waiter_valid)); + EXPECT_CALL(*request_valid, GetApplicationManager()) + .Times(1) + .WillRepeatedly(ReturnRef(app_mngr_)); + EXPECT_CALL(app_mngr_, IsStopping()) + .Times(1) + .WillRepeatedly( + DoAll(NotifyTestAsyncWaiter(waiter_valid), Return(false))); EXPECT_EQ(RequestController::TResult::SUCCESS, AddRequest(default_settings_, request_valid, RequestInfo::RequestType::MobileRequest, mobile_apis::HMILevel::HMI_NONE)); - EXPECT_TRUE(waiter_valid->WaitFor(1, 1000)); + EXPECT_TRUE(waiter_valid->WaitFor(2, 1000)); // The command should not be run if another command with the same // correlation_id is waiting for a response @@ -206,43 +215,25 @@ TEST_F(RequestControllerTestClass, TEST_F(RequestControllerTestClass, CheckPosibilitytoAdd_ZeroValueLimiters_SUCCESS) { + auto waiter_valid = TestAsyncWaiter::createInstance(); // Test case than pending_requests_amount, // app_time_scale_max_requests_ and // app_hmi_level_none_time_scale_max_requests_ equals 0 // (in the default settings they setted to 0) for (size_t i = 0; i < kMaxRequestAmount; ++i) { + RequestPtr request_valid = GetMockRequest(i); + EXPECT_CALL(*request_valid, GetApplicationManager()) + .WillRepeatedly(ReturnRef(app_mngr_)); + EXPECT_CALL(app_mngr_, IsStopping()) + .WillRepeatedly( + DoAll(NotifyTestAsyncWaiter(waiter_valid), Return(false))); EXPECT_EQ(RequestController::TResult::SUCCESS, AddRequest(default_settings_, - GetMockRequest(i), - RequestInfo::RequestType::MobileRequest, - mobile_apis::HMILevel::HMI_FULL)); - } -} - -TEST_F( - RequestControllerTestClass, - CheckPosibilitytoAdd_ExcessPendingRequestsAmount_TooManyPendingRequests) { - TestSettings settings; - settings.pending_requests_amount_ = kNumberOfRequests; - - request_ctrl_->DestroyThreadpool(); - - // Adding requests to fit in pending_requests_amount_ - for (size_t i = 0; i < kNumberOfRequests; ++i) { - EXPECT_EQ(RequestController::TResult::SUCCESS, - AddRequest(settings, - GetMockRequest(), + request_valid, RequestInfo::RequestType::MobileRequest, mobile_apis::HMILevel::HMI_FULL)); } - - // Trying to add one more extra request - // Expect overflow and TOO_MANY_PENDING_REQUESTS result - EXPECT_EQ(RequestController::TResult::TOO_MANY_PENDING_REQUESTS, - AddRequest(settings, - GetMockRequest(), - RequestInfo::RequestType::MobileRequest, - mobile_apis::HMILevel::HMI_FULL)); + EXPECT_TRUE(waiter_valid->WaitFor(kMaxRequestAmount, 1000)); } TEST_F(RequestControllerTestClass, IsLowVoltage_SetOnLowVoltage_TRUE) { @@ -258,11 +249,26 @@ TEST_F(RequestControllerTestClass, IsLowVoltage_SetOnWakeUp_FALSE) { } TEST_F(RequestControllerTestClass, AddMobileRequest_SetValidData_SUCCESS) { + RequestPtr request_valid = GetMockRequest(); + auto waiter_valid = TestAsyncWaiter::createInstance(); + ON_CALL(*request_valid, default_timeout()).WillByDefault(Return(0)); + EXPECT_CALL(*request_valid, Init()).WillOnce(Return(true)); + EXPECT_CALL(*request_valid, Run()) + .Times(1) + .WillRepeatedly(NotifyTestAsyncWaiter(waiter_valid)); + EXPECT_CALL(*request_valid, GetApplicationManager()) + .Times(1) + .WillRepeatedly(ReturnRef(app_mngr_)); + EXPECT_CALL(app_mngr_, IsStopping()) + .Times(1) + .WillRepeatedly( + DoAll(NotifyTestAsyncWaiter(waiter_valid), Return(false))); EXPECT_EQ(RequestController::TResult::SUCCESS, AddRequest(default_settings_, - GetMockRequest(), + request_valid, RequestInfo::RequestType::MobileRequest, mobile_apis::HMILevel::HMI_FULL)); + EXPECT_TRUE(waiter_valid->WaitFor(2, 1000)); } TEST_F(RequestControllerTestClass, @@ -292,18 +298,23 @@ TEST_F(RequestControllerTestClass, OnTimer_SUCCESS) { const uint32_t request_timeout = 1u; RequestPtr mock_request = GetMockRequest( kDefaultCorrelationID, kDefaultConnectionKey, request_timeout); - auto waiter = TestAsyncWaiter::createInstance(); + EXPECT_CALL(*mock_request, GetApplicationManager()) + .Times(1) + .WillRepeatedly(ReturnRef(app_mngr_)); + EXPECT_CALL(app_mngr_, IsStopping()) + .Times(1) + .WillRepeatedly(DoAll(NotifyTestAsyncWaiter(waiter), Return(false))); + EXPECT_CALL(*mock_request, HandleTimeOut()) + .WillOnce(NotifyTestAsyncWaiter(waiter)); + EXPECT_EQ(RequestController::TResult::SUCCESS, AddRequest(default_settings_, mock_request, RequestInfo::RequestType::MobileRequest)); - EXPECT_CALL(*mock_request, HandleTimeOut()) - .WillOnce(NotifyTestAsyncWaiter(waiter)); - // Waiting for call of `onTimeOut` for `kTimeScale` seconds - EXPECT_TRUE(waiter->WaitFor(1, kTimeScale)); + EXPECT_TRUE(waiter->WaitFor(2, kTimeScale)); } } // namespace request_controller_test diff --git a/src/components/application_manager/test/resumption/resume_ctrl_test.cc b/src/components/application_manager/test/resumption/resume_ctrl_test.cc index 1ff04c332c..058be224a7 100644 --- a/src/components/application_manager/test/resumption/resume_ctrl_test.cc +++ b/src/components/application_manager/test/resumption/resume_ctrl_test.cc @@ -98,7 +98,8 @@ class ResumeCtrlTest : public ::testing::Test { , kDefaultDeferredTestLevel_(eType::INVALID_ENUM) , kNaviLowbandwidthLevel_("LIMITED") , kProjectionLowbandwidthLevel_("NONE") - , kMediaLowbandwidthLevel_("NONE") { + , kMediaLowbandwidthLevel_("NONE") + , extensions_lock_(std::make_shared<sync_primitives::RecursiveLock>()) { profile::Profile profile_; profile_.set_config_file_name("smartDeviceLink.ini"); resumption_delay_before_ign_ = profile_.resumption_delay_before_ign(); @@ -245,6 +246,7 @@ class ResumeCtrlTest : public ::testing::Test { const std::string kMediaLowbandwidthLevel_; NiceMock<application_manager_test::MockRPCService> mock_rpc_service_; resumption::ResumeCtrl::ResumptionCallBack callback_; + std::shared_ptr<sync_primitives::RecursiveLock> extensions_lock_; }; /** @@ -327,7 +329,9 @@ TEST_F(ResumeCtrlTest, StartResumption_AppWithFiles) { .WillRepeatedly(Return(requests)); std::list<application_manager::AppExtensionPtr> extensions; extensions.insert(extensions.begin(), mock_app_extension_); - EXPECT_CALL(*mock_app_, Extensions()).WillOnce(ReturnRef(extensions)); + DataAccessor<std::list<application_manager::AppExtensionPtr> > accessor( + extensions, extensions_lock_); + EXPECT_CALL(*mock_app_, Extensions()).WillOnce(Return(accessor)); EXPECT_CALL(*mock_app_, set_grammar_id(kTestGrammarId_)); for (uint32_t i = 0; i < count_of_files; ++i) { EXPECT_CALL(*mock_app_, @@ -387,7 +391,9 @@ TEST_F(ResumeCtrlTest, StartResumption_AppWithSubmenues) { std::list<application_manager::AppExtensionPtr> extensions; extensions.insert(extensions.begin(), mock_app_extension_); - EXPECT_CALL(*mock_app_, Extensions()).WillOnce(ReturnRef(extensions)); + DataAccessor<std::list<application_manager::AppExtensionPtr> > accessor( + extensions, extensions_lock_); + EXPECT_CALL(*mock_app_, Extensions()).WillOnce(Return(accessor)); const bool res = res_ctrl_->StartResumption(mock_app_, kHash_, callback_); EXPECT_TRUE(res); @@ -461,7 +467,9 @@ TEST_F(ResumeCtrlTest, StartResumption_AppWithCommands) { .WillRepeatedly(Return(requests)); std::list<application_manager::AppExtensionPtr> extensions; extensions.insert(extensions.begin(), mock_app_extension_); - EXPECT_CALL(*mock_app_, Extensions()).WillOnce(ReturnRef(extensions)); + DataAccessor<std::list<application_manager::AppExtensionPtr> > accessor( + extensions, extensions_lock_); + EXPECT_CALL(*mock_app_, Extensions()).WillOnce(Return(accessor)); const bool res = res_ctrl_->StartResumption(mock_app_, kHash_, callback_); EXPECT_TRUE(res); @@ -521,7 +529,9 @@ TEST_F(ResumeCtrlTest, StartResumption_AppWithChoiceSet) { std::list<application_manager::AppExtensionPtr> extensions; extensions.insert(extensions.begin(), mock_app_extension_); - EXPECT_CALL(*mock_app_, Extensions()).WillOnce(ReturnRef(extensions)); + DataAccessor<std::list<application_manager::AppExtensionPtr> > accessor( + extensions, extensions_lock_); + EXPECT_CALL(*mock_app_, Extensions()).WillOnce(Return(accessor)); const bool res = res_ctrl_->StartResumption(mock_app_, kHash_, callback_); EXPECT_TRUE(res); @@ -560,9 +570,12 @@ TEST_F(ResumeCtrlTest, StartResumption_AppWithGlobalProperties) { EXPECT_CALL(*application_manager::MockMessageHelper::message_helper_mock(), CreateAddCommandRequestToHMI(_, _)) .WillRepeatedly(Return(requests)); + std::list<application_manager::AppExtensionPtr> extensions; extensions.insert(extensions.begin(), mock_app_extension_); - EXPECT_CALL(*mock_app_, Extensions()).WillOnce(ReturnRef(extensions)); + DataAccessor<std::list<application_manager::AppExtensionPtr> > accessor( + extensions, extensions_lock_); + EXPECT_CALL(*mock_app_, Extensions()).WillOnce(Return(accessor)); const bool res = res_ctrl_->StartResumption(mock_app_, kHash_, callback_); EXPECT_TRUE(res); } @@ -613,8 +626,9 @@ TEST_F(ResumeCtrlTest, StartResumption_AppWithSubscribeOnButtons) { std::list<application_manager::AppExtensionPtr> extensions; extensions.insert(extensions.begin(), mock_app_extension_); - - EXPECT_CALL(*mock_app_, Extensions()).WillOnce(ReturnRef(extensions)); + DataAccessor<std::list<application_manager::AppExtensionPtr> > accessor( + extensions, extensions_lock_); + EXPECT_CALL(*mock_app_, Extensions()).WillOnce(Return(accessor)); EXPECT_CALL(*mock_app_extension_, ProcessResumption(saved_app)); EXPECT_CALL(*application_manager::MockMessageHelper::message_helper_mock(), @@ -660,10 +674,11 @@ TEST_F(ResumeCtrlTest, StartResumption_AppWithSubscriptionToIVI) { smart_objects::SmartObjectList requests; std::list<application_manager::AppExtensionPtr> extensions; - extensions.insert(extensions.begin(), mock_app_extension_); - EXPECT_CALL(*mock_app_, Extensions()).WillOnce(ReturnRef(extensions)); + DataAccessor<std::list<application_manager::AppExtensionPtr> > accessor( + extensions, extensions_lock_); + EXPECT_CALL(*mock_app_, Extensions()).WillOnce(Return(accessor)); EXPECT_CALL(*mock_app_extension_, ProcessResumption(saved_app)); const bool res = res_ctrl_->StartResumption(mock_app_, kHash_, callback_); @@ -693,7 +708,6 @@ TEST_F(ResumeCtrlTest, std::list<application_manager::AppExtensionPtr> extensions; // It will work only for WayPointsAppExtension, need to rework this test extensions.insert(extensions.begin(), mock_app_extension_); - EXPECT_CALL(*mock_app_, Extensions()).WillOnce(ReturnRef(extensions)); EXPECT_CALL(mock_app_mngr_, SubscribeAppForWayPoints( @@ -752,8 +766,8 @@ TEST_F(ResumeCtrlTest, StartAppHmiStateResumption_AppInFull) { mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL; uint32_t ign_off_count = 0; smart_objects::SmartObject saved_app; - const uint32_t time_offset = 5; - const uint32_t time_stamp = + const int64_t time_offset = 5; + const int64_t time_stamp = time(nullptr) - resumption_delay_before_ign_ + time_offset; saved_app[application_manager::strings::ign_off_count] = ign_off_count; saved_app[application_manager::strings::hmi_level] = restored_test_type; @@ -808,8 +822,8 @@ TEST_F(ResumeCtrlTest, StartAppHmiStateResumption_AppHasDeferredResumption) { mobile_apis::HMILevel::eType deferred_level = eType::HMI_FULL; uint32_t ign_off_count = 0; smart_objects::SmartObject saved_app; - const uint32_t time_offset = 5; - const uint32_t time_stamp = + const int64_t time_offset = 5; + const int64_t time_stamp = time(nullptr) - resumption_delay_before_ign_ + time_offset; saved_app[application_manager::strings::ign_off_count] = ign_off_count; saved_app[application_manager::strings::hmi_level] = restored_test_type; @@ -848,8 +862,8 @@ TEST_F(ResumeCtrlTest, mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL; uint32_t ign_off_count = 0; smart_objects::SmartObject saved_app; - const uint32_t time_offset = 5; - const uint32_t time_stamp = + const int64_t time_offset = 5; + const int64_t time_stamp = time(nullptr) - resumption_delay_before_ign_ + time_offset; saved_app[application_manager::strings::ign_off_count] = ign_off_count; saved_app[application_manager::strings::hmi_level] = restored_test_type; @@ -894,8 +908,8 @@ TEST_F( mobile_apis::HMILevel::eType restored_test_type = eType::HMI_LIMITED; uint32_t ign_off_count = 0; smart_objects::SmartObject saved_app; - const uint32_t time_offset = 5; - const uint32_t time_stamp = + const int64_t time_offset = 5; + const int64_t time_stamp = time(nullptr) - resumption_delay_before_ign_ + time_offset; saved_app[application_manager::strings::ign_off_count] = ign_off_count; saved_app[application_manager::strings::hmi_level] = restored_test_type; @@ -1041,8 +1055,8 @@ TEST_F(ResumeCtrlTest, ApplicationResumptionTimer_AppInFull) { mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL; const uint32_t ign_off_count = 0u; smart_objects::SmartObject saved_app; - const uint32_t time_offset = 5; - const uint32_t time_stamp = + const int64_t time_offset = 5; + const int64_t time_stamp = time(nullptr) - resumption_delay_before_ign_ + time_offset; saved_app[application_manager::strings::ign_off_count] = ign_off_count; saved_app[application_manager::strings::hmi_level] = restored_test_type; @@ -1387,8 +1401,8 @@ TEST_F( ResumeCtrlTest, ResumptionLowVoltage_AppInFullUnregisteredWithinTimeFrame_HMILevelRestored) { const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL; - const uint32_t time_offset = 5; - const uint32_t time_stamp = + const int64_t time_offset = 5; + const int64_t time_stamp = time(nullptr) - resumption_delay_before_ign_ + time_offset; smart_objects::SmartObject saved_app; saved_app[application_manager::strings::hmi_level] = restored_test_type; @@ -1434,8 +1448,8 @@ TEST_F( ResumeCtrlTest, ResumptionLowVoltage_AppInFullUnregisteredBeyondTimeFrame_HMILevelNotRestored) { const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL; - const uint32_t time_offset = 5; - const uint32_t time_stamp = + const int64_t time_offset = 5; + const int64_t time_stamp = time(nullptr) - resumption_delay_before_ign_ - time_offset; smart_objects::SmartObject saved_app; saved_app[application_manager::strings::hmi_level] = restored_test_type; @@ -1473,8 +1487,8 @@ TEST_F( TEST_F(ResumeCtrlTest, ResumptionLowVoltage_AppInBackground_NotRestored) { const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_BACKGROUND; - const uint32_t time_offset = 5; - const uint32_t time_stamp = + const int64_t time_offset = 5; + const int64_t time_stamp = time(nullptr) - resumption_delay_before_ign_ - time_offset; smart_objects::SmartObject saved_app; saved_app[application_manager::strings::hmi_level] = restored_test_type; @@ -1501,8 +1515,8 @@ TEST_F( ResumeCtrlTest, ResumptionLowVoltage_AppInLimitedlUnregisteredWithinTimeFrame_HMILevelRestored) { const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_LIMITED; - const uint32_t time_offset = 5; - const uint32_t time_stamp = + const int64_t time_offset = 5; + const int64_t time_stamp = time(nullptr) - resumption_delay_before_ign_ + time_offset; smart_objects::SmartObject saved_app; saved_app[application_manager::strings::hmi_level] = restored_test_type; @@ -1548,8 +1562,8 @@ TEST_F( ResumeCtrlTest, ResumptionLowVoltage_AppInLimitedlUnregisteredBeyondTimeFrame_HMILevelNotRestored) { const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_LIMITED; - const uint32_t time_offset = 5; - const uint32_t time_stamp = + const int64_t time_offset = 5; + const int64_t time_stamp = time(nullptr) - resumption_delay_before_ign_ - time_offset; smart_objects::SmartObject saved_app; saved_app[application_manager::strings::hmi_level] = restored_test_type; diff --git a/src/components/application_manager/test/resumption/resumption_data_db_test.cc b/src/components/application_manager/test/resumption/resumption_data_db_test.cc index ec390e4be0..9f7058bec2 100644 --- a/src/components/application_manager/test/resumption/resumption_data_db_test.cc +++ b/src/components/application_manager/test/resumption/resumption_data_db_test.cc @@ -846,7 +846,7 @@ TEST_F(ResumptionDataDBTest, GetIgnOffTime_AfterSuspendAndAwake) { PrepareData(); EXPECT_TRUE(res_db()->Init()); SetZeroIgnOffTime(); - uint32_t last_ign_off_time; + int64_t last_ign_off_time; EXPECT_CALL(*mock_app_extension_, SaveResumptionData(_)); res_db()->SaveApplication(app_mock); @@ -856,11 +856,11 @@ TEST_F(ResumptionDataDBTest, GetIgnOffTime_AfterSuspendAndAwake) { res_db()->IncrementIgnOffCount(); - uint32_t after_suspend; + int64_t after_suspend; after_suspend = res_db()->GetIgnOffTime(); EXPECT_LE(last_ign_off_time, after_suspend); - uint32_t after_awake; + int64_t after_awake; res_db()->DecrementIgnOffCount(); after_awake = res_db()->GetIgnOffTime(); diff --git a/src/components/application_manager/test/resumption/resumption_data_json_test.cc b/src/components/application_manager/test/resumption/resumption_data_json_test.cc index 9d348ecbb7..24904dbce0 100644 --- a/src/components/application_manager/test/resumption/resumption_data_json_test.cc +++ b/src/components/application_manager/test/resumption/resumption_data_json_test.cc @@ -360,7 +360,7 @@ TEST_F(ResumptionDataJsonTest, GetHashId) { } TEST_F(ResumptionDataJsonTest, GetIgnOffTime_AfterSuspendAndAwake) { - uint32_t last_ign_off_time; + int64_t last_ign_off_time; PrepareData(); SetZeroIgnOff(); EXPECT_CALL(*mock_app_extension_, SaveResumptionData(_)); @@ -371,11 +371,11 @@ TEST_F(ResumptionDataJsonTest, GetIgnOffTime_AfterSuspendAndAwake) { res_json.IncrementIgnOffCount(); - uint32_t after_suspend; + int64_t after_suspend; after_suspend = res_json.GetIgnOffTime(); EXPECT_LE(last_ign_off_time, after_suspend); - uint32_t after_awake; + int64_t after_awake; res_json.DecrementIgnOffCount(); after_awake = res_json.GetIgnOffTime(); diff --git a/src/components/application_manager/test/resumption/resumption_data_test.cc b/src/components/application_manager/test/resumption/resumption_data_test.cc index cb5a4d9a56..603af4ca47 100644 --- a/src/components/application_manager/test/resumption/resumption_data_test.cc +++ b/src/components/application_manager/test/resumption/resumption_data_test.cc @@ -383,7 +383,9 @@ void ResumptionDataTest::PrepareData() { mock_app_extension_ = std::make_shared<NiceMock<application_manager_test::MockAppExtension> >(); extensions_.insert(extensions_.begin(), mock_app_extension_); - ON_CALL(*app_mock, Extensions()).WillByDefault(ReturnRef(extensions_)); + DataAccessor<std::list<application_manager::AppExtensionPtr> > accessor( + extensions_, extensions_lock_); + ON_CALL(*app_mock, Extensions()).WillByDefault(Return(accessor)); SetGlobalProporties(); SetCommands(); SetSubmenues(); diff --git a/src/components/application_manager/test/state_controller/state_controller_test.cc b/src/components/application_manager/test/state_controller/state_controller_test.cc index b6ec4fc8ef..f255223136 100644 --- a/src/components/application_manager/test/state_controller/state_controller_test.cc +++ b/src/components/application_manager/test/state_controller/state_controller_test.cc @@ -3654,7 +3654,11 @@ TEST_F(StateControllerImplTest, static_cast<hmi_apis::Common_HMILevel::eType>(new_state->hmi_level()), kCorrID); - smart_objects::SmartObjectSPtr bc_activate_app_request; + smart_objects::SmartObjectSPtr bc_activate_app_request = + std::make_shared<smart_objects::SmartObject>(); + (*bc_activate_app_request)[am::strings::params][am::strings::correlation_id] = + kCorrID; + EXPECT_CALL(message_helper_mock_, GetBCActivateAppRequestToHMI(_, _, _, _, _)) .WillOnce(Return(bc_activate_app_request)); EXPECT_CALL(*simple_app_ptr_, SetRegularState(_, _)).Times(0); |