From 884e897941a600c11b7fcfa3d8cf59ce15eb3571 Mon Sep 17 00:00:00 2001 From: Jacob Keeler Date: Thu, 4 May 2017 12:18:40 -0400 Subject: Invalid data responses now return useful error messages in `info` field --- .../src/application_manager_impl.cc | 15 +++++++++++---- .../src/commands/mobile/system_request.cc | 2 +- .../application_manager/src/hmi_capabilities_impl.cc | 19 +++++++++++-------- .../src/resumption/resumption_data_json.cc | 2 +- 4 files changed, 24 insertions(+), 14 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index f89b5e5caf..4c3aa08be6 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1807,9 +1807,12 @@ bool ApplicationManagerImpl::ConvertMessageToSO( message.function_id(), message.type(), message.correlation_id()); + + std::string errorMessage = ""; + if (!conversion_result || !mobile_so_factory().attachSchema(output, true) || - ((output.validate() != smart_objects::Errors::OK))) { + ((output.validate(errorMessage) != smart_objects::Errors::OK))) { LOG4CXX_WARN(logger_, "Failed to parse string to smart object :" << message.json_message()); @@ -1819,6 +1822,8 @@ bool ApplicationManagerImpl::ConvertMessageToSO( message.function_id(), message.correlation_id(), mobile_apis::Result::INVALID_DATA)); + + (*response)[strings::msg_params][strings::info] = errorMessage; ManageMobileCommand(response, commands::Command::ORIGIN_SDL); return false; } @@ -1866,7 +1871,10 @@ bool ApplicationManagerImpl::ConvertMessageToSO( LOG4CXX_WARN(logger_, "Failed to attach schema to object."); return false; } - if (output.validate() != smart_objects::Errors::OK) { + + std::string errorMessage = ""; + + if (output.validate(errorMessage) != smart_objects::Errors::OK) { LOG4CXX_ERROR(logger_, "Incorrect parameter from HMI"); if (application_manager::MessageType::kNotification == @@ -1884,8 +1892,7 @@ bool ApplicationManagerImpl::ConvertMessageToSO( output.erase(strings::msg_params); output[strings::params][hmi_response::code] = hmi_apis::Common_Result::INVALID_DATA; - output[strings::msg_params][strings::info] = - std::string("Received invalid data on HMI response"); + output[strings::msg_params][strings::info] = errorMessage; } break; } diff --git a/src/components/application_manager/src/commands/mobile/system_request.cc b/src/components/application_manager/src/commands/mobile/system_request.cc index 74d25508e0..0cec74f6a2 100644 --- a/src/components/application_manager/src/commands/mobile/system_request.cc +++ b/src/components/application_manager/src/commands/mobile/system_request.cc @@ -559,7 +559,7 @@ void SystemRequest::Run() { return; } - CFormatterJsonBase::jsonValueToObj(root, sm_object); + CFormatterJsonBase::jsonValueToObj(root, sm_object, ""); if (!ValidateQueryAppData(sm_object)) { SendResponse(false, mobile_apis::Result::GENERIC_ERROR); return; diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc index 9d52cc98db..8feb3a997d 100644 --- a/src/components/application_manager/src/hmi_capabilities_impl.cc +++ b/src/components/application_manager/src/hmi_capabilities_impl.cc @@ -760,7 +760,8 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() { smart_objects::SmartObject display_capabilities_so; Json::Value display_capabilities = ui.get("displayCapabilities", ""); Formatters::CFormatterJsonBase::jsonValueToObj(display_capabilities, - display_capabilities_so); + display_capabilities_so, + "displayCapabilities"); if (display_capabilities_so.keyExists(hmi_response::display_type)) { std::map Date: Fri, 29 Sep 2017 09:49:51 -0400 Subject: Fix build errors from merge and remove quotes from error messages --- .../application_manager/src/application_manager_impl.cc | 11 ++++++++--- .../application_manager/src/hmi_capabilities_impl.cc | 16 +++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 4d8b0706fc..616a538f5a 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -2317,8 +2317,10 @@ MessageValidationResult ApplicationManagerImpl::ValidateMessageBySchema( if (!mobile_so_factory().attachSchema(so, true)) { return INVALID_METADATA; } - - if (so.validate() != smart_objects::Errors::OK) { + std::string errorMessage(""); + if (so.validate(errorMessage) != smart_objects::Errors::OK) { + LOG4CXX_WARN(logger_, + "validate() failed for Mobile message - " << errorMessage); return SCHEMA_MISMATCH; } break; @@ -2337,7 +2339,10 @@ MessageValidationResult ApplicationManagerImpl::ValidateMessageBySchema( return INVALID_METADATA; } - if (so.validate() != smart_objects::Errors::OK) { + std::string errorMessage(""); + if (so.validate(errorMessage) != smart_objects::Errors::OK) { + LOG4CXX_WARN(logger_, + "validate() failed for HMI message - " << errorMessage); return SCHEMA_MISMATCH; } break; diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc index 4872361af7..17e9acc81a 100644 --- a/src/components/application_manager/src/hmi_capabilities_impl.cc +++ b/src/components/application_manager/src/hmi_capabilities_impl.cc @@ -1077,7 +1077,9 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() { system_capabilities.get("navigationCapability", ""); smart_objects::SmartObject navigation_capability_so; Formatters::CFormatterJsonBase::jsonValueToObj( - navigation_capability, navigation_capability_so); + navigation_capability, + navigation_capability_so, + "navigationCapability"); set_navigation_capability(navigation_capability_so); if (!navigation_capability_so.empty()) { set_navigation_supported(true); @@ -1088,8 +1090,8 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() { Json::Value phone_capability = system_capabilities.get("phoneCapability", ""); smart_objects::SmartObject phone_capability_so; - Formatters::CFormatterJsonBase::jsonValueToObj(phone_capability, - phone_capability_so); + Formatters::CFormatterJsonBase::jsonValueToObj( + phone_capability, phone_capability_so, "phoneCapability"); set_phone_capability(phone_capability_so); if (!phone_capability_so.empty()) { set_phone_call_supported(true); @@ -1100,8 +1102,8 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() { Json::Value vs_capability = system_capabilities.get("videoStreamingCapability", ""); smart_objects::SmartObject vs_capability_so; - Formatters::CFormatterJsonBase::jsonValueToObj(vs_capability, - vs_capability_so); + Formatters::CFormatterJsonBase::jsonValueToObj( + vs_capability, vs_capability_so, "videoStreamingCapability"); if (vs_capability_so.keyExists("supportedFormats")) { smart_objects::SmartObject& supported_format_array = @@ -1150,8 +1152,8 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() { Json::Value rc_capability = system_capabilities.get("remoteControlCapability", ""); smart_objects::SmartObject rc_capability_so; - Formatters::CFormatterJsonBase::jsonValueToObj(rc_capability, - rc_capability_so); + Formatters::CFormatterJsonBase::jsonValueToObj( + rc_capability, rc_capability_so, "remoteControlCapability"); set_rc_capability(rc_capability_so); } } -- cgit v1.2.1 From 273e26304efb215af3416f86ab86c1c7fd39f974 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 30 Nov 2017 15:19:11 -0500 Subject: Use ValidationReport objects for reporting rather than strings --- .../src/application_manager_impl.cc | 31 +++++++++++-------- .../src/commands/mobile/system_request.cc | 2 +- .../src/hmi_capabilities_impl.cc | 35 ++++++++++------------ .../src/resumption/resumption_data_json.cc | 2 +- 4 files changed, 35 insertions(+), 35 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 616a538f5a..5feb29e51d 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -2069,11 +2069,11 @@ bool ApplicationManagerImpl::ConvertMessageToSO( message.type(), message.correlation_id()); - std::string errorMessage = ""; + rpc::ValidationReport report("RPC"); if (!conversion_result || !mobile_so_factory().attachSchema(output, true) || - ((output.validate(errorMessage) != smart_objects::Errors::OK))) { + ((output.validate(&report) != smart_objects::Errors::OK))) { LOG4CXX_WARN(logger_, "Failed to parse string to smart object :" << message.json_message()); @@ -2084,7 +2084,8 @@ bool ApplicationManagerImpl::ConvertMessageToSO( message.correlation_id(), mobile_apis::Result::INVALID_DATA)); - (*response)[strings::msg_params][strings::info] = errorMessage; + (*response)[strings::msg_params][strings::info] = + rpc::PrettyFormat(report); ManageMobileCommand(response, commands::Command::ORIGIN_SDL); return false; } @@ -2133,15 +2134,17 @@ bool ApplicationManagerImpl::ConvertMessageToSO( return false; } - std::string errorMessage = ""; + rpc::ValidationReport report("RPC"); - if (output.validate(errorMessage) != smart_objects::Errors::OK) { - LOG4CXX_ERROR(logger_, "Incorrect parameter from HMI"); + if (output.validate(&report) != smart_objects::Errors::OK) { + LOG4CXX_ERROR(logger_, + "Incorrect parameter from HMI" + << rpc::PrettyFormat(report)); output.erase(strings::msg_params); output[strings::params][hmi_response::code] = hmi_apis::Common_Result::INVALID_DATA; - output[strings::msg_params][strings::info] = errorMessage; + output[strings::msg_params][strings::info] = rpc::PrettyFormat(report); return false; } break; @@ -2317,10 +2320,11 @@ MessageValidationResult ApplicationManagerImpl::ValidateMessageBySchema( if (!mobile_so_factory().attachSchema(so, true)) { return INVALID_METADATA; } - std::string errorMessage(""); - if (so.validate(errorMessage) != smart_objects::Errors::OK) { + rpc::ValidationReport report("RPC"); + if (so.validate(&report) != smart_objects::Errors::OK) { LOG4CXX_WARN(logger_, - "validate() failed for Mobile message - " << errorMessage); + "validate() failed for Mobile message - " + << rpc::PrettyFormat(report)); return SCHEMA_MISMATCH; } break; @@ -2339,10 +2343,11 @@ MessageValidationResult ApplicationManagerImpl::ValidateMessageBySchema( return INVALID_METADATA; } - std::string errorMessage(""); - if (so.validate(errorMessage) != smart_objects::Errors::OK) { + rpc::ValidationReport report("RPC"); + if (so.validate(&report) != smart_objects::Errors::OK) { LOG4CXX_WARN(logger_, - "validate() failed for HMI message - " << errorMessage); + "validate() failed for HMI message - " + << rpc::PrettyFormat(report)); return SCHEMA_MISMATCH; } break; diff --git a/src/components/application_manager/src/commands/mobile/system_request.cc b/src/components/application_manager/src/commands/mobile/system_request.cc index 46e6fbefa2..e4706441ef 100644 --- a/src/components/application_manager/src/commands/mobile/system_request.cc +++ b/src/components/application_manager/src/commands/mobile/system_request.cc @@ -574,7 +574,7 @@ void SystemRequest::Run() { return; } - CFormatterJsonBase::jsonValueToObj(root, sm_object, ""); + CFormatterJsonBase::jsonValueToObj(root, sm_object); if (!ValidateQueryAppData(sm_object)) { SendResponse(false, mobile_apis::Result::GENERIC_ERROR); return; diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc index 17e9acc81a..28049f8e35 100644 --- a/src/components/application_manager/src/hmi_capabilities_impl.cc +++ b/src/components/application_manager/src/hmi_capabilities_impl.cc @@ -866,8 +866,7 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() { smart_objects::SmartObject display_capabilities_so; Json::Value display_capabilities = ui.get("displayCapabilities", ""); Formatters::CFormatterJsonBase::jsonValueToObj(display_capabilities, - display_capabilities_so, - "displayCapabilities"); + display_capabilities_so); if (display_capabilities_so.keyExists(hmi_response::display_type)) { std::map Date: Mon, 4 Dec 2017 12:21:00 -0500 Subject: Add DEPRECATED macro, and fix resulting deprecated warnings --- .../application_manager/src/application_manager_impl.cc | 11 ++++++----- .../src/commands/mobile/perform_audio_pass_thru_request.cc | 3 +-- src/components/application_manager/src/message.cc | 5 ++--- .../application_manager/src/mobile_message_handler.cc | 3 +-- 4 files changed, 10 insertions(+), 12 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index a2cba5198e..896713f8bc 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1166,8 +1166,7 @@ void ApplicationManagerImpl::ReplaceHMIByMobileAppId( } } -// DEPRECATED -bool ApplicationManagerImpl::StartNaviService( +DEPRECATED bool ApplicationManagerImpl::StartNaviService( uint32_t app_id, protocol_handler::ServiceType service_type) { using namespace protocol_handler; LOG4CXX_AUTO_TRACE(logger_); @@ -1338,8 +1337,9 @@ void ApplicationManagerImpl::StopNaviService( app->StopStreaming(service_type); } -// DEPRECATED -bool ApplicationManagerImpl::OnServiceStartedCallback( +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +DEPRECATED bool ApplicationManagerImpl::OnServiceStartedCallback( const connection_handler::DeviceHandle& device_handle, const int32_t& session_key, const protocol_handler::ServiceType& type) { @@ -1374,6 +1374,7 @@ bool ApplicationManagerImpl::OnServiceStartedCallback( } return false; } +#pragma GCC diagnostic pop void ApplicationManagerImpl::OnServiceStartedCallback( const connection_handler::DeviceHandle& device_handle, @@ -2283,7 +2284,7 @@ bool ApplicationManagerImpl::ConvertSOtoMessage( } if (message.getElement(jhs::S_PARAMS).keyExists(strings::binary_data)) { - application_manager::BinaryData binaryData( + const application_manager::BinaryData binaryData( message.getElement(jhs::S_PARAMS) .getElement(strings::binary_data) .asBinary()); diff --git a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc index cff16e577c..9a802914c4 100644 --- a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc +++ b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc @@ -224,8 +224,7 @@ PerformAudioPassThruRequest::PrepareResponseParameters() { return response_params_; } -// DEPRECATED -bool PerformAudioPassThruRequest::PrepareResponseParameters( +DEPRECATED bool PerformAudioPassThruRequest::PrepareResponseParameters( mobile_apis::Result::eType& result_code, std::string& info) { LOG4CXX_AUTO_TRACE(logger_); NOTREACHED(); diff --git a/src/components/application_manager/src/message.cc b/src/components/application_manager/src/message.cc index d67a235a76..2a91289441 100644 --- a/src/components/application_manager/src/message.cc +++ b/src/components/application_manager/src/message.cc @@ -89,7 +89,7 @@ Message& Message::operator=(const Message& message) { set_data_size(message.data_size_); set_payload_size(message.payload_size_); if (message.binary_data_) { - set_binary_data(message.binary_data_); + set_binary_data((const BinaryData*)message.binary_data_); } set_json_message(message.json_message_); set_protocol_version(message.protocol_version()); @@ -194,8 +194,7 @@ void Message::set_message_type(MessageType type) { type_ = type; } -// DEPRECATED -void Message::set_binary_data(BinaryData* data) { +DEPRECATED void Message::set_binary_data(BinaryData* data) { if (NULL == data) { NOTREACHED(); return; diff --git a/src/components/application_manager/src/mobile_message_handler.cc b/src/components/application_manager/src/mobile_message_handler.cc index bc3aa32731..2f06c5f3b5 100644 --- a/src/components/application_manager/src/mobile_message_handler.cc +++ b/src/components/application_manager/src/mobile_message_handler.cc @@ -196,9 +196,8 @@ MobileMessageHandler::HandleIncomingMessageProtocolV2( outgoing_message->set_payload_size(message->payload_size()); if (!payload.data.empty()) { - BinaryData binary_payload_data(payload.data); + const BinaryData binary_payload_data(payload.data); outgoing_message->set_binary_data(&binary_payload_data); - outgoing_message->set_binary_data(&payload.data); } return outgoing_message.release(); } -- cgit v1.2.1 From 6153f79de2c362dd51c3e945294b74cd9f965ac5 Mon Sep 17 00:00:00 2001 From: AKalinich-Luxoft Date: Fri, 9 Jun 2017 09:33:10 +0300 Subject: Renamed OnSuspend->IncrementIgnOffCount and OnAwake->DecrementIgnOffCount This functions of ResumptionData class was renamed according to their exact logic. Also renamed in mock class and in unit tests. --- .../application_manager/src/resumption/resumption_data_db.cc | 4 ++-- .../application_manager/src/resumption/resumption_data_json.cc | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/resumption/resumption_data_db.cc b/src/components/application_manager/src/resumption/resumption_data_db.cc index 08de6d8190..59c8220a22 100644 --- a/src/components/application_manager/src/resumption/resumption_data_db.cc +++ b/src/components/application_manager/src/resumption/resumption_data_db.cc @@ -212,7 +212,7 @@ uint32_t ResumptionDataDB::GetHMIApplicationID( return hmi_app_id; } -void ResumptionDataDB::OnSuspend() { +void ResumptionDataDB::IncrementIgnOffCount() { LOG4CXX_AUTO_TRACE(logger_); utils::dbms::SQLQuery query_update_suspend_data(db()); @@ -291,7 +291,7 @@ bool ResumptionDataDB::GetHashId(const std::string& policy_app_id, return SelectHashId(policy_app_id, device_id, hash_id); } -void ResumptionDataDB::OnAwake() { +void ResumptionDataDB::DecrementIgnOffCount() { LOG4CXX_AUTO_TRACE(logger_); UpdateDataOnAwake(); diff --git a/src/components/application_manager/src/resumption/resumption_data_json.cc b/src/components/application_manager/src/resumption/resumption_data_json.cc index 7866fc4de1..013cd909fc 100644 --- a/src/components/application_manager/src/resumption/resumption_data_json.cc +++ b/src/components/application_manager/src/resumption/resumption_data_json.cc @@ -143,11 +143,11 @@ uint32_t ResumptionDataJson::GetHMIApplicationID( return hmi_app_id; } -void ResumptionDataJson::OnSuspend() { +void ResumptionDataJson::IncrementIgnOffCount() { using namespace app_mngr; LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock autolock(resumption_lock_); - Json::Value to_save; + Json::Value to_save = Json::arrayValue; for (Json::Value::iterator it = GetSavedApplications().begin(); it != GetSavedApplications().end(); ++it) { @@ -167,7 +167,7 @@ void ResumptionDataJson::OnSuspend() { LOG4CXX_DEBUG(logger_, GetResumptionData().toStyledString()); } -void ResumptionDataJson::OnAwake() { +void ResumptionDataJson::DecrementIgnOffCount() { using namespace app_mngr; LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock autolock(resumption_lock_); -- cgit v1.2.1 From 2f22052761aed0069b9a7fc99c0ffee1e60822c0 Mon Sep 17 00:00:00 2001 From: AKalinich-Luxoft Date: Fri, 9 Jun 2017 09:39:12 +0300 Subject: Added OnIgnitionOff() and new bool flag to ResumeCtrl class SDL should distinct ignition off and suspend notifications. SDL should not increment ignition off count in case of suspended notification, only in case of ignition off. This logic was separated by appending new function OnIgnitionOff() which will be called from application manager on ignition off instead of OnSuspend(). Also was added is_suspended flag and related getter/setter. This flag is used in: - ApplicationImpl to check should SDL send OnHashChange or not - In OnAwakeSDLNotification to check should SDL do OnAwake actions or not - OnExitAllApplicationsNotification and OnAwakeSDLNotification switches this flag Also was fixed some related UT expectations and mocks. --- .../src/application_manager_impl.cc | 2 +- .../hmi/on_exit_all_applications_notification.cc | 2 ++ .../src/resumption/resume_ctrl_impl.cc | 20 +++++++++++++++++--- 3 files changed, 20 insertions(+), 4 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index a2cba5198e..cacaadd996 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -2883,7 +2883,7 @@ void ApplicationManagerImpl::UnregisterAllApplications() { } } if (is_ignition_off) { - resume_controller().OnSuspend(); + resume_controller().OnIgnitionOff(); } request_ctrl_.terminateAllHMIRequests(); } diff --git a/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc b/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc index 07a95adcea..6d131683d3 100644 --- a/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc @@ -75,6 +75,8 @@ void OnExitAllApplicationsNotification::Run() { break; } case hmi_apis::Common_ApplicationsCloseReason::SUSPEND: { + application_manager_.resume_controller().set_is_suspended(true); + application_manager_.resume_controller().OnSuspend(); SendOnSDLPersistenceComplete(); return; } 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 c8740227df..bf7a365b9e 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc @@ -67,6 +67,7 @@ ResumeCtrlImpl::ResumeCtrlImpl(ApplicationManager& application_manager) this, &ResumeCtrlImpl::SaveDataOnTimer)) , is_resumption_active_(false) , is_data_saved_(false) + , is_suspended_(false) , launch_time_(time(NULL)) , application_manager_(application_manager) {} #ifdef BUILD_TESTS @@ -265,14 +266,27 @@ void ResumeCtrlImpl::OnSuspend() { LOG4CXX_AUTO_TRACE(logger_); StopSavePersistentDataTimer(); SaveAllApplications(); - resumption_storage_->OnSuspend(); resumption_storage_->Persist(); } +void ResumeCtrlImpl::OnIgnitionOff() { + LOG4CXX_AUTO_TRACE(logger_); + resumption_storage_->IncrementIgnOffCount(); + OnSuspend(); +} + void ResumeCtrlImpl::OnAwake() { + LOG4CXX_AUTO_TRACE(logger_); ResetLaunchTime(); StartSavePersistentDataTimer(); - return resumption_storage_->OnAwake(); +} + +bool ResumeCtrlImpl::is_suspended() const { + return is_suspended_; +} + +void ResumeCtrlImpl::set_is_suspended(const bool suspended_flag) { + is_suspended_ = suspended_flag; } void ResumeCtrlImpl::StartSavePersistentDataTimer() { @@ -774,7 +788,7 @@ void ResumeCtrlImpl::LoadResumeData() { "Resumption data for application " << app_id << " and device id " << device_id << " will be dropped."); - resumption_storage_->DropAppDataResumption(device_id, app_id); + resumption_storage_->RemoveApplicationFromSaved(app_id, device_id); continue; } } -- cgit v1.2.1 From e96f33b925b782cab8b515b7afd8d49965506010 Mon Sep 17 00:00:00 2001 From: AKalinich-Luxoft Date: Fri, 9 Jun 2017 09:22:30 +0300 Subject: Added new bool flag to ApplicationImpl class This flag is needed for checking, is SDL should send OnHashChange notification after OnAwake notification. During suspend state SDL must not send OnHashChange according to requirements. If some of RPC's triggers OnHashChange notification sending during suspend, this flag will be set to true and after OnAwake notification if this flag was set, SDL will send OnHashChange notification. --- .../application_manager/src/application_impl.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 569880bb56..f9cbc72d50 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -44,6 +44,7 @@ #include "utils/make_shared.h" #include "utils/timer_task_impl.h" #include "application_manager/policies/policy_handler_interface.h" +#include "application_manager/resumption/resume_ctrl.h" namespace { @@ -111,6 +112,7 @@ ApplicationImpl::ApplicationImpl( protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_3) , is_voice_communication_application_(false) , is_resuming_(false) + , flag_sending_hash_change_after_awake_(false) , video_stream_retry_number_(0) , audio_stream_retry_number_(0) , video_stream_suspend_timer_( @@ -872,7 +874,19 @@ void ApplicationImpl::UpdateHash() { utils::gen_hash(application_manager_.get_settings().hash_string_size()); set_is_application_data_changed(true); - MessageHelper::SendHashUpdateNotification(app_id(), application_manager_); + if (!application_manager_.resume_controller().is_suspended()) { + MessageHelper::SendHashUpdateNotification(app_id(), application_manager_); + } else { + flag_sending_hash_change_after_awake_ = true; + } +} + +bool ApplicationImpl::flag_sending_hash_change_after_awake() const { + return flag_sending_hash_change_after_awake_; +} + +void ApplicationImpl::set_flag_sending_hash_change_after_awake(bool flag) { + flag_sending_hash_change_after_awake_ = flag; } void ApplicationImpl::CleanupFiles() { -- cgit v1.2.1 From 13c5685d110e2a0c6623e0217a54b4466792657f Mon Sep 17 00:00:00 2001 From: AKalinich-Luxoft Date: Fri, 9 Jun 2017 09:12:46 +0300 Subject: Added missed implementation of OnAwakeSDLNotification This notification works in pair with OnExitAllApplications(SUSPEND) notification. However first one is present in code but second one was ommited. There was just empty file. File with implementation was added to CMakeLists. Message broker was subscribed to OnAwake notification from HMI. Added command creation in HMI Command Factory. --- .../hmi/basic_communication_on_awake_sdl.cc | 44 +++++++++++++++++++++- .../application_manager/src/hmi_command_factory.cc | 6 +++ 2 files changed, 49 insertions(+), 1 deletion(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc b/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc index 80b1edb5bb..3db61cf177 100644 --- a/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc +++ b/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Ford Motor Company + * Copyright (c) 2017, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,3 +29,45 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ + +#include "application_manager/commands/hmi/basic_communication_on_awake_sdl.h" +#include "application_manager/message_helper.h" +#include "application_manager/resumption/resume_ctrl.h" + +namespace application_manager { + +namespace commands { + +OnAwakeSDLNotification::OnAwakeSDLNotification( + const MessageSharedPtr& message, ApplicationManager& application_manager) + : NotificationFromHMI(message, application_manager) {} + +OnAwakeSDLNotification::~OnAwakeSDLNotification() {} + +void OnAwakeSDLNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + if (application_manager_.resume_controller().is_suspended()) { + { + application_manager_.resume_controller().set_is_suspended(false); + DataAccessor accessor = + application_manager_.applications(); + ApplicationSetIt it = accessor.GetData().begin(); + ApplicationSetIt itEnd = accessor.GetData().end(); + for (; it != itEnd; ++it) { + if ((*it).get()) { + if ((*it)->flag_sending_hash_change_after_awake()) { + MessageHelper::SendHashUpdateNotification((*it)->app_id(), + application_manager_); + (*it)->set_flag_sending_hash_change_after_awake(false); + } + } + } + } + application_manager_.resume_controller().OnAwake(); + } +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/hmi_command_factory.cc b/src/components/application_manager/src/hmi_command_factory.cc index ffaa8d9b5f..a7f3ce7e6b 100644 --- a/src/components/application_manager/src/hmi_command_factory.cc +++ b/src/components/application_manager/src/hmi_command_factory.cc @@ -269,6 +269,7 @@ #include "application_manager/commands/hmi/on_system_error_notification.h" #include "application_manager/commands/hmi/basic_communication_system_request.h" #include "application_manager/commands/hmi/basic_communication_system_response.h" +#include "application_manager/commands/hmi/basic_communication_on_awake_sdl.h" #include "application_manager/commands/hmi/sdl_policy_update.h" #include "application_manager/commands/hmi/sdl_policy_update_response.h" #include "application_manager/commands/hmi/on_received_policy_update.h" @@ -781,6 +782,11 @@ CommandSharedPtr HMICommandFactory::CreateCommand( message, application_manager)); break; } + case hmi_apis::FunctionID::BasicCommunication_OnAwakeSDL: { + command.reset( + new commands::OnAwakeSDLNotification(message, application_manager)); + break; + } case hmi_apis::FunctionID::BasicCommunication_OnExitApplication: { command.reset(new commands::OnExitApplicationNotification( message, application_manager)); -- cgit v1.2.1 From 7ab0ffe3fad16f019c644ee4caecc95e295b2ef2 Mon Sep 17 00:00:00 2001 From: AKalinich-Luxoft Date: Tue, 27 Jun 2017 12:02:09 +0300 Subject: Renamed methods, updated briefs, removed deep nesting --- .../application_manager/src/application_impl.cc | 12 ++++---- .../hmi/basic_communication_on_awake_sdl.cc | 32 +++++++++++----------- 2 files changed, 22 insertions(+), 22 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index f9cbc72d50..ed730a8c84 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -112,7 +112,7 @@ ApplicationImpl::ApplicationImpl( protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_3) , is_voice_communication_application_(false) , is_resuming_(false) - , flag_sending_hash_change_after_awake_(false) + , is_hash_changed_during_suspend_(false) , video_stream_retry_number_(0) , audio_stream_retry_number_(0) , video_stream_suspend_timer_( @@ -877,16 +877,16 @@ void ApplicationImpl::UpdateHash() { if (!application_manager_.resume_controller().is_suspended()) { MessageHelper::SendHashUpdateNotification(app_id(), application_manager_); } else { - flag_sending_hash_change_after_awake_ = true; + is_hash_changed_during_suspend_ = true; } } -bool ApplicationImpl::flag_sending_hash_change_after_awake() const { - return flag_sending_hash_change_after_awake_; +bool ApplicationImpl::IsHashChangedAfterAwake() const { + return is_hash_changed_during_suspend_; } -void ApplicationImpl::set_flag_sending_hash_change_after_awake(bool flag) { - flag_sending_hash_change_after_awake_ = flag; +void ApplicationImpl::SetHashChangedAfterAwake(const bool state) { + is_hash_changed_during_suspend_ = state; } void ApplicationImpl::CleanupFiles() { diff --git a/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc b/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc index 3db61cf177..7454451cbd 100644 --- a/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc +++ b/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc @@ -47,25 +47,25 @@ OnAwakeSDLNotification::~OnAwakeSDLNotification() {} void OnAwakeSDLNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); - if (application_manager_.resume_controller().is_suspended()) { - { - application_manager_.resume_controller().set_is_suspended(false); - DataAccessor accessor = - application_manager_.applications(); - ApplicationSetIt it = accessor.GetData().begin(); - ApplicationSetIt itEnd = accessor.GetData().end(); - for (; it != itEnd; ++it) { - if ((*it).get()) { - if ((*it)->flag_sending_hash_change_after_awake()) { - MessageHelper::SendHashUpdateNotification((*it)->app_id(), - application_manager_); - (*it)->set_flag_sending_hash_change_after_awake(false); - } - } + if (!application_manager_.resume_controller().is_suspended()) { + return; + } + + { + DataAccessor accessor = application_manager_.applications(); + ApplicationSetIt itBegin = accessor.GetData().begin(); + ApplicationSetIt itEnd = accessor.GetData().end(); + for (; itBegin != itEnd; ++itBegin) { + const ApplicationSharedPtr app = *itBegin; + if (app && app->IsHashChangedAfterAwake()) { + MessageHelper::SendHashUpdateNotification(app->app_id(), + application_manager_); + app->SetHashChangedAfterAwake(false); } } - application_manager_.resume_controller().OnAwake(); } + + application_manager_.resume_controller().OnAwake(); } } // namespace commands -- cgit v1.2.1 From 3baea565f75bfc8cebacccc0bc04045af076e7f8 Mon Sep 17 00:00:00 2001 From: AKalinich-Luxoft Date: Tue, 27 Jun 2017 12:05:14 +0300 Subject: Removed is_suspended setter. is_suspended flag was encapsulated inside resumption controller Updated mocks --- .../hmi/on_exit_all_applications_notification.cc | 1 - .../src/resumption/resume_ctrl_impl.cc | 19 +++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc b/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc index 6d131683d3..cb68b21263 100644 --- a/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc @@ -75,7 +75,6 @@ void OnExitAllApplicationsNotification::Run() { break; } case hmi_apis::Common_ApplicationsCloseReason::SUSPEND: { - application_manager_.resume_controller().set_is_suspended(true); application_manager_.resume_controller().OnSuspend(); SendOnSDLPersistenceComplete(); return; 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 bf7a365b9e..435e621169 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc @@ -264,19 +264,19 @@ bool ResumeCtrlImpl::RemoveApplicationFromSaved( void ResumeCtrlImpl::OnSuspend() { LOG4CXX_AUTO_TRACE(logger_); - StopSavePersistentDataTimer(); - SaveAllApplications(); - resumption_storage_->Persist(); + is_suspended_ = true; + FinalPersistData(); } void ResumeCtrlImpl::OnIgnitionOff() { LOG4CXX_AUTO_TRACE(logger_); resumption_storage_->IncrementIgnOffCount(); - OnSuspend(); + FinalPersistData(); } void ResumeCtrlImpl::OnAwake() { LOG4CXX_AUTO_TRACE(logger_); + is_suspended_ = false; ResetLaunchTime(); StartSavePersistentDataTimer(); } @@ -285,10 +285,6 @@ bool ResumeCtrlImpl::is_suspended() const { return is_suspended_; } -void ResumeCtrlImpl::set_is_suspended(const bool suspended_flag) { - is_suspended_ = suspended_flag; -} - void ResumeCtrlImpl::StartSavePersistentDataTimer() { LOG4CXX_AUTO_TRACE(logger_); if (!save_persistent_data_timer_.is_running()) { @@ -447,6 +443,13 @@ void ResumeCtrlImpl::SaveDataOnTimer() { } } +void ResumeCtrlImpl::FinalPersistData() { + LOG4CXX_AUTO_TRACE(logger_); + StopSavePersistentDataTimer(); + SaveAllApplications(); + resumption_storage_->Persist(); +} + bool ResumeCtrlImpl::IsDeviceMacAddressEqual( ApplicationSharedPtr application, const std::string& saved_device_mac) { LOG4CXX_AUTO_TRACE(logger_); -- cgit v1.2.1 From 8862a94c64534572c1e4e691af440598111cae7c Mon Sep 17 00:00:00 2001 From: AKalinich-Luxoft Date: Tue, 19 Dec 2017 19:34:04 +0200 Subject: Updated description, added deprecated methods --- src/components/application_manager/src/application_impl.cc | 4 ++-- .../src/commands/hmi/basic_communication_on_awake_sdl.cc | 4 ++-- .../application_manager/src/resumption/resumption_data_db.cc | 6 ++++++ .../application_manager/src/resumption/resumption_data_json.cc | 6 ++++++ 4 files changed, 16 insertions(+), 4 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index ed730a8c84..0ba98d67f5 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -881,11 +881,11 @@ void ApplicationImpl::UpdateHash() { } } -bool ApplicationImpl::IsHashChangedAfterAwake() const { +bool ApplicationImpl::IsHashChangedDuringSuspend() const { return is_hash_changed_during_suspend_; } -void ApplicationImpl::SetHashChangedAfterAwake(const bool state) { +void ApplicationImpl::SetHashChangedDuringSuspend(const bool state) { is_hash_changed_during_suspend_ = state; } diff --git a/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc b/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc index 7454451cbd..c6c550a474 100644 --- a/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc +++ b/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc @@ -57,10 +57,10 @@ void OnAwakeSDLNotification::Run() { ApplicationSetIt itEnd = accessor.GetData().end(); for (; itBegin != itEnd; ++itBegin) { const ApplicationSharedPtr app = *itBegin; - if (app && app->IsHashChangedAfterAwake()) { + if (app && app->IsHashChangedDuringSuspend()) { MessageHelper::SendHashUpdateNotification(app->app_id(), application_manager_); - app->SetHashChangedAfterAwake(false); + app->SetHashChangedDuringSuspend(false); } } } 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 59c8220a22..23fecb7624 100644 --- a/src/components/application_manager/src/resumption/resumption_data_db.cc +++ b/src/components/application_manager/src/resumption/resumption_data_db.cc @@ -212,6 +212,9 @@ uint32_t ResumptionDataDB::GetHMIApplicationID( return hmi_app_id; } +// DEPRECATED +void ResumptionDataDB::OnSuspend() {} + void ResumptionDataDB::IncrementIgnOffCount() { LOG4CXX_AUTO_TRACE(logger_); @@ -291,6 +294,9 @@ bool ResumptionDataDB::GetHashId(const std::string& policy_app_id, return SelectHashId(policy_app_id, device_id, hash_id); } +// DEPRECATED +void ResumptionDataDB::OnAwake() {} + void ResumptionDataDB::DecrementIgnOffCount() { LOG4CXX_AUTO_TRACE(logger_); 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 013cd909fc..203c4889c5 100644 --- a/src/components/application_manager/src/resumption/resumption_data_json.cc +++ b/src/components/application_manager/src/resumption/resumption_data_json.cc @@ -143,6 +143,9 @@ uint32_t ResumptionDataJson::GetHMIApplicationID( return hmi_app_id; } +// DEPRECATED +void ResumptionDataJson::OnSuspend() {} + void ResumptionDataJson::IncrementIgnOffCount() { using namespace app_mngr; LOG4CXX_AUTO_TRACE(logger_); @@ -167,6 +170,9 @@ void ResumptionDataJson::IncrementIgnOffCount() { LOG4CXX_DEBUG(logger_, GetResumptionData().toStyledString()); } +// DEPRECATED +void ResumptionDataJson::OnAwake() {} + void ResumptionDataJson::DecrementIgnOffCount() { using namespace app_mngr; LOG4CXX_AUTO_TRACE(logger_); -- cgit v1.2.1 From 2dab63338c700b9f92f50dfdd3b9490f04057503 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 17 Jan 2018 14:08:12 -0500 Subject: Address review comments Remove C style casts Add comments for pragma directives Remove redundant DEPRECATED macro usages --- src/components/application_manager/src/application_manager_impl.cc | 5 +++-- .../src/commands/mobile/perform_audio_pass_thru_request.cc | 2 +- src/components/application_manager/src/message.cc | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 896713f8bc..9da69b8279 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1166,7 +1166,7 @@ void ApplicationManagerImpl::ReplaceHMIByMobileAppId( } } -DEPRECATED bool ApplicationManagerImpl::StartNaviService( +bool ApplicationManagerImpl::StartNaviService( uint32_t app_id, protocol_handler::ServiceType service_type) { using namespace protocol_handler; LOG4CXX_AUTO_TRACE(logger_); @@ -1337,9 +1337,10 @@ void ApplicationManagerImpl::StopNaviService( app->StopStreaming(service_type); } +// Suppress warning for deprecated method used within another deprecated method #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" -DEPRECATED bool ApplicationManagerImpl::OnServiceStartedCallback( +bool ApplicationManagerImpl::OnServiceStartedCallback( const connection_handler::DeviceHandle& device_handle, const int32_t& session_key, const protocol_handler::ServiceType& type) { diff --git a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc index 9a802914c4..a05d41c098 100644 --- a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc +++ b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc @@ -224,7 +224,7 @@ PerformAudioPassThruRequest::PrepareResponseParameters() { return response_params_; } -DEPRECATED bool PerformAudioPassThruRequest::PrepareResponseParameters( +bool PerformAudioPassThruRequest::PrepareResponseParameters( mobile_apis::Result::eType& result_code, std::string& info) { LOG4CXX_AUTO_TRACE(logger_); NOTREACHED(); diff --git a/src/components/application_manager/src/message.cc b/src/components/application_manager/src/message.cc index 2a91289441..7bc686aef1 100644 --- a/src/components/application_manager/src/message.cc +++ b/src/components/application_manager/src/message.cc @@ -89,7 +89,7 @@ Message& Message::operator=(const Message& message) { set_data_size(message.data_size_); set_payload_size(message.payload_size_); if (message.binary_data_) { - set_binary_data((const BinaryData*)message.binary_data_); + set_binary_data(static_cast(message.binary_data_)); } set_json_message(message.json_message_); set_protocol_version(message.protocol_version()); @@ -194,7 +194,7 @@ void Message::set_message_type(MessageType type) { type_ = type; } -DEPRECATED void Message::set_binary_data(BinaryData* data) { +void Message::set_binary_data(BinaryData* data) { if (NULL == data) { NOTREACHED(); return; -- cgit v1.2.1 From 97a8191a57275c27a3bc58cd8e7b09b5ee4f92db Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 17 Jan 2018 17:13:41 -0500 Subject: Fix build errors with GCC6+ --- src/components/application_manager/src/commands/command_request_impl.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index 09aa4169e5..515d8a998c 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -31,6 +31,7 @@ */ #include +#include #include #include "utils/macro.h" #include "utils/make_shared.h" -- cgit v1.2.1 From a6791129fb1cfcd5dad96e4987b1c2664aafb61e Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Tue, 19 Sep 2017 16:51:35 +0300 Subject: Adds main logic and related bugfixes for transport switching --- .../application_manager/src/application_impl.cc | 29 +-- .../src/application_manager_impl.cc | 203 +++++++++++++++++---- .../src/commands/command_impl.cc | 36 ++-- .../src/commands/hmi/notification_to_hmi.cc | 7 +- .../hmi/on_app_unregistered_notification.cc | 6 + .../src/commands/hmi/request_to_hmi.cc | 7 +- .../src/commands/hmi/response_to_hmi.cc | 7 +- .../mobile/register_app_interface_request.cc | 57 +++++- .../application_manager/src/hmi_state.cc | 75 ++++---- .../src/policies/policy_handler.cc | 4 +- .../src/state_controller_impl.cc | 44 ++--- 11 files changed, 341 insertions(+), 134 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 0ba98d67f5..21847ffa1d 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -41,6 +41,7 @@ #include "utils/file_system.h" #include "utils/logger.h" #include "utils/gen_hash.h" +#include "utils/shared_ptr.h" #include "utils/make_shared.h" #include "utils/timer_task_impl.h" #include "application_manager/policies/policy_handler_interface.h" @@ -76,10 +77,21 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") namespace application_manager { +void SwitchApplicationParameters(ApplicationSharedPtr app, + const uint32_t app_id, + const uint32_t device_id) { + utils::SharedPtr application = + ApplicationSharedPtr::dynamic_pointer_cast(app); + DCHECK_OR_RETURN_VOID(application); + application->app_id_ = app_id; + application->device_id_ = device_id; +} + ApplicationImpl::ApplicationImpl( uint32_t application_id, const std::string& mobile_app_id, const std::string& mac_address, + const connection_handler::DeviceHandle device_id, const custom_str::CustomString& app_name, utils::SharedPtr statistics_manager, ApplicationManager& application_manager) @@ -107,6 +119,7 @@ ApplicationImpl::ApplicationImpl( , list_files_in_none_count_(0) , device_(0) , mac_address_(mac_address) + , device_id_(device_id) , usage_report_(mobile_app_id, statistics_manager) , protocol_version_( protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_3) @@ -137,12 +150,6 @@ ApplicationImpl::ApplicationImpl( SubscribeToButton(mobile_apis::ButtonName::CUSTOM_BUTTON); // load persistent files LoadPersistentFiles(); - HmiStatePtr initial_state = application_manager_.CreateRegularState( - app_id(), - mobile_apis::HMILevel::INVALID_ENUM, - mobile_apis::AudioStreamingState::INVALID_ENUM, - mobile_api::SystemContext::SYSCTXT_MAIN); - state_.InitState(initial_state); video_stream_suspend_timeout_ = application_manager_.get_settings().video_data_stopped_timeout(); @@ -347,7 +354,7 @@ const std::string& ApplicationImpl::bundle_id() const { } connection_handler::DeviceHandle ApplicationImpl::device() const { - return device_; + return device_id_; } const std::string& ApplicationImpl::mac_address() const { @@ -606,10 +613,6 @@ void ApplicationImpl::set_app_allowed(const bool allowed) { is_app_allowed_ = allowed; } -void ApplicationImpl::set_device(connection_handler::DeviceHandle device) { - device_ = device; -} - uint32_t ApplicationImpl::get_grammar_id() const { return grammar_id_; } @@ -863,6 +866,10 @@ bool ApplicationImpl::is_application_data_changed() const { return is_application_data_changed_; } +void ApplicationImpl::SetInitialState(HmiStatePtr state) { + state_.InitState(state); +} + void ApplicationImpl::set_is_application_data_changed( bool state_application_data) { is_application_data_changed_ = state_application_data; diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index b219635d46..65da6ed87e 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -93,9 +93,26 @@ DeviceTypes devicesType = { hmi_apis::Common_TransportType::USB_IOS), std::make_pair(std::string("BLUETOOTH"), hmi_apis::Common_TransportType::BLUETOOTH), + std::make_pair(std::string("IOS_BLUETOOTH"), + hmi_apis::Common_TransportType::BLUETOOTH), std::make_pair(std::string("WIFI"), hmi_apis::Common_TransportType::WIFI)}; } +bool device_id_comparator(const std::string& device_id, + ApplicationSharedPtr app) { + LOG4CXX_DEBUG(logger_, + "Data to compare: device_id : " << device_id << " app mac: " + << app->mac_address()); + + return device_id == app->mac_address(); +} + +bool policy_app_id_comparator(const std::string& policy_app_id, + ApplicationSharedPtr app) { + DCHECK_OR_RETURN(app, false); + return app->policy_app_id() == policy_app_id; +} + uint32_t ApplicationManagerImpl::corelation_id_ = 0; const uint32_t ApplicationManagerImpl::max_corelation_id_ = UINT_MAX; @@ -472,10 +489,10 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( // original app_id can be received via ApplicationImpl::mobile_app_id() uint32_t app_id = 0; std::list sessions_list; - uint32_t device_id = 0; + connection_handler::DeviceHandle device_id = 0; DCHECK_OR_RETURN(connection_handler_, ApplicationSharedPtr()); - if (connection_handler().GetDataOnSessionKey( + if (connection_handler().get_session_observer().GetDataOnSessionKey( connection_key, &app_id, &sessions_list, &device_id) == -1) { LOG4CXX_ERROR(logger_, "Failed to create application: no connection info."); utils::SharedPtr response( @@ -488,6 +505,20 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( return ApplicationSharedPtr(); } + smart_objects::SmartObject& params = message[strings::msg_params]; + const std::string& policy_app_id = params[strings::app_id].asString(); + const custom_str::CustomString& app_name = + message[strings::msg_params][strings::app_name].asCustomString(); + std::string device_mac; + std::string connection_type; + if (connection_handler().get_session_observer().GetDataOnDeviceID( + device_id, NULL, NULL, &device_mac, &connection_type) == -1) { + LOG4CXX_DEBUG(logger_, "Failed to extract device mac for id " << device_id); + } else { + LOG4CXX_DEBUG(logger_, + "Device mac for id" << device_id << " is " << device_mac); + } + LOG4CXX_DEBUG(logger_, "Restarting application list update timer"); GetPolicyHandler().OnAppsSearchStarted(); uint32_t timeout = get_settings().application_list_update_timeout(); @@ -506,22 +537,11 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( return ApplicationSharedPtr(); } - smart_objects::SmartObject& params = message[strings::msg_params]; - const std::string& policy_app_id = params[strings::app_id].asString(); - const custom_str::CustomString& app_name = - message[strings::msg_params][strings::app_name].asCustomString(); - std::string device_mac = ""; - if (connection_handler().get_session_observer().GetDataOnDeviceID( - device_id, NULL, NULL, &device_mac, NULL) == -1) { - LOG4CXX_ERROR(logger_, "Failed to extract device mac for id " << device_id); - } else { - LOG4CXX_DEBUG(logger_, - "Device mac for id" << device_id << " is " << device_mac); - } ApplicationSharedPtr application( new ApplicationImpl(app_id, policy_app_id, device_mac, + device_id, app_name, GetPolicyHandler().GetStatisticManager(), *this)); @@ -536,12 +556,19 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( return ApplicationSharedPtr(); } + HmiStatePtr initial_state = + CreateRegularState(utils::SharedPtr(application), + mobile_apis::HMILevel::INVALID_ENUM, + mobile_apis::AudioStreamingState::INVALID_ENUM, + mobile_api::SystemContext::SYSCTXT_MAIN); + + application->SetInitialState(initial_state); + application->set_folder_name(policy_app_id + "_" + application->mac_address()); // To load persistent files, app folder name must be known first, which is now // depends on device_id and mobile_app_id application->LoadPersistentFiles(); - application->set_device(device_id); application->set_grammar_id(GenerateGrammarID()); mobile_api::Language::eType launguage_desired = @@ -788,11 +815,11 @@ void ApplicationManagerImpl::SetAllAppsAllowed(const bool allowed) { } HmiStatePtr ApplicationManagerImpl::CreateRegularState( - uint32_t app_id, + utils::SharedPtr app, mobile_apis::HMILevel::eType hmi_level, mobile_apis::AudioStreamingState::eType audio_state, mobile_apis::SystemContext::eType system_context) const { - HmiStatePtr state(new HmiState(app_id, *this)); + HmiStatePtr state(new HmiState(app, *this)); state->set_hmi_level(hmi_level); state->set_audio_streaming_state(audio_state); state->set_system_context(system_context); @@ -1044,6 +1071,61 @@ void ApplicationManagerImpl::RemoveDevice( LOG4CXX_DEBUG(logger_, "device_handle " << device_handle); } +void ApplicationManagerImpl::OnDeviceSwitchingStart( + const std::string& device_uid) { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(reregister_wait_list_lock_); + auto apps_data_accessor = applications(); + + std::copy_if(apps_data_accessor.GetData().begin(), + apps_data_accessor.GetData().end(), + std::back_inserter(reregister_wait_list_), + std::bind1st(std::ptr_fun(&device_id_comparator), device_uid)); +} + +void ApplicationManagerImpl::OnDeviceSwitchFinish( + const std::string& device_uid) { + LOG4CXX_AUTO_TRACE(logger_); + UNUSED(device_uid); + sync_primitives::AutoLock lock(reregister_wait_list_lock_); + + const bool unexpected_disonnect = true; + const bool is_resuming = true; + for (auto app_it = reregister_wait_list_.begin(); + app_it != reregister_wait_list_.end(); + ++app_it) { + UnregisterApplication((*app_it)->app_id(), + mobile_apis::Result::INVALID_ENUM, + is_resuming, + unexpected_disonnect); + } + reregister_wait_list_.clear(); +} + +void ApplicationManagerImpl::SwitchApplication(ApplicationSharedPtr app, + const uint32_t connection_key, + const uint32_t device_id) { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(applications_list_lock_); + DCHECK_OR_RETURN_VOID(1 == applications_.erase(app)); + + LOG4CXX_DEBUG(logger_, + "Changing app id to " << connection_key + << ". Changing device id to " + << device_id); + + SwitchApplicationParameters(app, connection_key, device_id); + + // Normally this is done during registration, however since switched apps are + // not being registered again need to set protocol version on session. + connection_handler().BindProtocolVersionWithSession( + connection_key, static_cast(app->protocol_version())); + + // Application need to be re-inserted in order to keep sorting in applications + // container. Otherwise data loss on erasing is possible. + applications_.insert(app); +} + mobile_apis::HMILevel::eType ApplicationManagerImpl::GetDefaultHmiLevel( ApplicationConstSharedPtr application) const { using namespace mobile_apis; @@ -2589,10 +2671,10 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array, const std::string app_icon_dir(settings_.app_icons_folder()); const std::string full_icon_path(app_icon_dir + "/" + policy_app_id); - uint32_t device_id = 0; + connection_handler::DeviceHandle device_id = 0; if (-1 == - connection_handler().GetDataOnSessionKey( + connection_handler().get_session_observer().GetDataOnSessionKey( connection_key, NULL, NULL, &device_id)) { LOG4CXX_ERROR(logger_, "Failed to create application: no connection info."); @@ -2614,6 +2696,7 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array, new ApplicationImpl(0, policy_app_id, device_mac, + device_id, appName, GetPolicyHandler().GetStatisticManager(), *this)); @@ -2622,7 +2705,6 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array, app->SetPackageName(package_name); app->set_app_icon_path(full_icon_path); app->set_hmi_application_id(hmi_app_id); - app->set_device(device_id); app->set_vr_synonyms(vrSynonym); app->set_tts_name(ttsName); @@ -2977,13 +3059,14 @@ void ApplicationManagerImpl::UnregisterApplication( ApplicationSharedPtr app_to_remove; connection_handler::DeviceHandle handle = 0; { - DataAccessor accessor(applications()); - ApplicationSetConstIt it = accessor.GetData().begin(); - for (; it != accessor.GetData().end(); ++it) { - if ((*it)->app_id() == app_id) { - app_to_remove = *it; - handle = app_to_remove->device(); - break; + sync_primitives::AutoLock lock(applications_list_lock_); + auto it_app = applications_.begin(); + while (applications_.end() != it_app) { + if (app_id == (*it_app)->app_id()) { + app_to_remove = *it_app; + applications_.erase(it_app++); + } else { + ++it_app; } } if (!app_to_remove) { @@ -3001,11 +3084,10 @@ void ApplicationManagerImpl::UnregisterApplication( } else { resume_controller().RemoveApplicationFromSaved(app_to_remove); } - applications_.erase(app_to_remove); (hmi_capabilities_->get_hmi_language_handler()) .OnUnregisterApplication(app_id); AppV4DevicePredicate finder(handle); - ApplicationSharedPtr app = FindApp(accessor, finder); + ApplicationSharedPtr app = FindApp(applications(), finder); if (!app) { LOG4CXX_DEBUG( logger_, "There is no more SDL4 apps with device handle: " << handle); @@ -3236,8 +3318,9 @@ bool ApplicationManagerImpl::IsLowVoltage() { std::string ApplicationManagerImpl::GetHashedAppID( uint32_t connection_key, const std::string& mobile_app_id) const { - uint32_t device_id = 0; - connection_handler().GetDataOnSessionKey(connection_key, 0, NULL, &device_id); + connection_handler::DeviceHandle device_id = 0; + connection_handler().get_session_observer().GetDataOnSessionKey( + connection_key, 0, NULL, &device_id); std::string device_name; connection_handler().get_session_observer().GetDataOnDeviceID( device_id, &device_name, NULL, NULL, NULL); @@ -3598,6 +3681,18 @@ bool ApplicationManagerImpl::IsApplicationForbidden( return forbidden_applications.find(name) != forbidden_applications.end(); } +// TODO: check its usage +bool ApplicationManagerImpl::IsAppInReconnectMode( + const std::string& policy_app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(reregister_wait_list_lock_); + return reregister_wait_list_.end() != + std::find_if(reregister_wait_list_.begin(), + reregister_wait_list_.end(), + std::bind1st(std::ptr_fun(&policy_app_id_comparator), + policy_app_id)); +} + policy::DeviceConsent ApplicationManagerImpl::GetUserConsentForDevice( const std::string& device_id) const { return GetPolicyHandler().GetUserConsentForDevice(device_id); @@ -3881,6 +3976,52 @@ void ApplicationManagerImpl::OnUpdateHMIAppType( } } +void ApplicationManagerImpl::EraseAppFromReconnectionList( + const ApplicationSharedPtr& app) { + LOG4CXX_AUTO_TRACE(logger_); + if (!app) { + LOG4CXX_WARN(logger_, "Application is not valid."); + return; + } + + const auto policy_app_id = app->policy_app_id(); + sync_primitives::AutoLock lock(reregister_wait_list_lock_); + auto app_it = std::find_if( + reregister_wait_list_.begin(), + reregister_wait_list_.end(), + std::bind1st(std::ptr_fun(&policy_app_id_comparator), policy_app_id)); + if (reregister_wait_list_.end() != app_it) { + reregister_wait_list_.erase(app_it); + } +} + +void ApplicationManagerImpl::ProcessReconnection( + ApplicationSharedPtr application, const uint32_t connection_key) { + LOG4CXX_AUTO_TRACE(logger_); + DCHECK_OR_RETURN_VOID(application); + + connection_handler::DeviceHandle new_device_id = 0; + connection_handler().get_session_observer().GetDataOnSessionKey( + connection_key, NULL, NULL, &new_device_id); + DCHECK_OR_RETURN_VOID(new_device_id); + + std::string device_mac; + std::string connection_type; + connection_handler().get_session_observer().GetDataOnDeviceID( + new_device_id, NULL, NULL, &device_mac, &connection_type); + + DCHECK_OR_RETURN_VOID(application->mac_address() == device_mac); + + EraseAppFromReconnectionList(application); + + connection_handler().OnDeviceConnectionSwitched(device_mac); + + SwitchApplication(application, connection_key, new_device_id); + + // Update connection type for existed device. + GetPolicyHandler().AddDevice(device_mac, connection_type); +} + void ApplicationManagerImpl::OnPTUFinished(const bool ptu_result) { #ifdef SDL_REMOTE_CONTROL if (!ptu_result) { diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc index 0a3e65a790..d17f6cdc10 100644 --- a/src/components/application_manager/src/commands/command_impl.cc +++ b/src/components/application_manager/src/commands/command_impl.cc @@ -94,18 +94,20 @@ void CommandImpl::SetAllowedToTerminate(const bool allowed) { allowed_to_terminate_ = allowed; } -void CommandImpl::ReplaceMobileByHMIAppId( +bool CommandImpl::ReplaceMobileByHMIAppId( NsSmartDeviceLink::NsSmartObjects::SmartObject& message) { if (message.keyExists(strings::app_id)) { ApplicationSharedPtr application = application_manager_.application(message[strings::app_id].asUInt()); - if (application.valid()) { - LOG4CXX_DEBUG(logger_, - "ReplaceMobileByHMIAppId from " - << message[strings::app_id].asInt() << " to " - << application->hmi_app_id()); - message[strings::app_id] = application->hmi_app_id(); + if (!application) { + LOG4CXX_ERROR(logger_, "Substitution mobile --> HMI id is failed."); + return false; } + LOG4CXX_DEBUG(logger_, + "ReplaceMobileByHMIAppId from " + << message[strings::app_id].asInt() << " to " + << application->hmi_app_id()); + message[strings::app_id] = application->hmi_app_id(); } else { switch (message.getType()) { case smart_objects::SmartType::SmartType_Array: { @@ -128,22 +130,26 @@ void CommandImpl::ReplaceMobileByHMIAppId( default: { break; } } } + + return true; } -void CommandImpl::ReplaceHMIByMobileAppId( +bool CommandImpl::ReplaceHMIByMobileAppId( NsSmartDeviceLink::NsSmartObjects::SmartObject& message) { if (message.keyExists(strings::app_id)) { ApplicationSharedPtr application = application_manager_.application_by_hmi_app( message[strings::app_id].asUInt()); - if (application.valid()) { - LOG4CXX_DEBUG(logger_, - "ReplaceHMIByMobileAppId from " - << message[strings::app_id].asInt() << " to " - << application->app_id()); - message[strings::app_id] = application->app_id(); + if (!application) { + LOG4CXX_ERROR(logger_, "Substitution HMI --> mobile id is failed."); + return false; } + LOG4CXX_DEBUG(logger_, + "ReplaceHMIByMobileAppId from " + << message[strings::app_id].asInt() << " to " + << application->app_id()); + message[strings::app_id] = application->app_id(); } else { switch (message.getType()) { case smart_objects::SmartType::SmartType_Array: { @@ -165,6 +171,8 @@ void CommandImpl::ReplaceHMIByMobileAppId( default: { break; } } } + + return true; } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc b/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc index f1e933b7ef..7e24dce8d9 100644 --- a/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc @@ -39,15 +39,12 @@ namespace commands { NotificationToHMI::NotificationToHMI(const MessageSharedPtr& message, ApplicationManager& application_manager) - : CommandImpl(message, application_manager) { - // Replace Mobile connection id with HMI app id - ReplaceMobileByHMIAppId(*(message.get())); -} + : CommandImpl(message, application_manager) {} NotificationToHMI::~NotificationToHMI() {} bool NotificationToHMI::Init() { - return true; + return ReplaceMobileByHMIAppId(*message_); } bool NotificationToHMI::CleanUp() { diff --git a/src/components/application_manager/src/commands/hmi/on_app_unregistered_notification.cc b/src/components/application_manager/src/commands/hmi/on_app_unregistered_notification.cc index 10ea1ea303..f64e3e111b 100644 --- a/src/components/application_manager/src/commands/hmi/on_app_unregistered_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_app_unregistered_notification.cc @@ -44,6 +44,12 @@ OnAppUnregisteredNotification::OnAppUnregisteredNotification( OnAppUnregisteredNotification::~OnAppUnregisteredNotification() {} +bool OnAppUnregisteredNotification::Init() { + LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_DEBUG(logger_, "Replacement of hmi id is skipped."); + return true; +} + void OnAppUnregisteredNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/src/commands/hmi/request_to_hmi.cc b/src/components/application_manager/src/commands/hmi/request_to_hmi.cc index 39d549ac72..f26dc26ef6 100644 --- a/src/components/application_manager/src/commands/hmi/request_to_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/request_to_hmi.cc @@ -61,15 +61,12 @@ bool ChangeInterfaceState(ApplicationManager& application_manager, RequestToHMI::RequestToHMI(const MessageSharedPtr& message, ApplicationManager& application_manager) - : CommandImpl(message, application_manager) { - // Replace Mobile connection id with HMI app id - ReplaceMobileByHMIAppId(*(message.get())); -} + : CommandImpl(message, application_manager) {} RequestToHMI::~RequestToHMI() {} bool RequestToHMI::Init() { - return true; + return ReplaceMobileByHMIAppId(*message_); } bool RequestToHMI::CleanUp() { diff --git a/src/components/application_manager/src/commands/hmi/response_to_hmi.cc b/src/components/application_manager/src/commands/hmi/response_to_hmi.cc index e6f64047ba..77e523378a 100644 --- a/src/components/application_manager/src/commands/hmi/response_to_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/response_to_hmi.cc @@ -39,15 +39,12 @@ namespace commands { ResponseToHMI::ResponseToHMI(const MessageSharedPtr& message, ApplicationManager& application_manager) - : CommandImpl(message, application_manager) { - // Replace Mobile connection id with HMI app id - ReplaceMobileByHMIAppId(*(message.get())); -} + : CommandImpl(message, application_manager) {} ResponseToHMI::~ResponseToHMI() {} bool ResponseToHMI::Init() { - return true; + return ReplaceMobileByHMIAppId(*message_); } bool ResponseToHMI::CleanUp() { diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index 1a60537874..1939150541 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc @@ -217,6 +217,13 @@ void RegisterAppInterfaceRequest::Run() { return; } + if (IsApplicationSwitched()) { + return; + } + + const std::string mobile_app_id = + (*message_)[strings::msg_params][strings::app_id].asString(); + ApplicationSharedPtr application = application_manager_.application(connection_key()); @@ -362,7 +369,7 @@ void RegisterAppInterfaceRequest::Run() { GetPolicyHandler().SetDeviceInfo(device_mac, device_info); - SendRegisterAppInterfaceResponseToMobile(); + SendRegisterAppInterfaceResponseToMobile(AppicationType::kNewApplication); smart_objects::SmartObjectSPtr so = GetLockScreenIconUrlNotification(connection_key(), application); application_manager_.ManageMobileCommand(so, commands::Command::ORIGIN_SDL); @@ -501,7 +508,8 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params, hmi_capabilities.rc_supported(); } -void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() { +void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( + AppicationType app_type) { LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObject response_params(smart_objects::SmartType_Map); @@ -631,6 +639,14 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() { response_params[strings::system_software_version] = ccpu_version; } + if (AppicationType::kSwitchedApplication == app_type) { + LOG4CXX_DEBUG(logger_, + "Application has been switched from another transport."); + + SendResponse(true, result_code, NULL, &response_params); + return; + } + bool resumption = (*message_)[strings::msg_params].keyExists(strings::hash_id); @@ -1194,6 +1210,43 @@ void RegisterAppInterfaceRequest::SendSubscribeCustomButtonNotification() { CreateHMINotification(FunctionID::Buttons_OnButtonSubscription, msg_params); } +bool RegisterAppInterfaceRequest::IsApplicationSwitched() { + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + + const std::string& policy_app_id = msg_params[strings::app_id].asString(); + + LOG4CXX_DEBUG(logger_, "Looking for application id " << policy_app_id); + + auto app = application_manager_.application_by_policy_id(policy_app_id); + + if (!app) { + LOG4CXX_DEBUG(logger_, + "Application with policy id " << policy_app_id + << " is not found."); + return false; + } + + LOG4CXX_DEBUG(logger_, + "Application with policy id " << policy_app_id << " is found."); + if (!application_manager_.IsAppInReconnectMode(policy_app_id)) { + LOG4CXX_DEBUG(logger_, + "Policy id " << policy_app_id + << " is not found in reconnection list."); + SendResponse(false, mobile_apis::Result::APPLICATION_REGISTERED_ALREADY); + return false; + } + + LOG4CXX_DEBUG(logger_, "Application is found in reconnection list."); + application_manager_.ProcessReconnection(app, connection_key()); + SendRegisterAppInterfaceResponseToMobile( + AppicationType::kSwitchedApplication); + + application_manager_.SendHMIStatusNotification(app); + + return true; +} + policy::PolicyHandlerInterface& RegisterAppInterfaceRequest::GetPolicyHandler() { return application_manager_.GetPolicyHandler(); diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index 393a9d7784..d31ff364ea 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -37,18 +37,19 @@ namespace application_manager { -HmiState::HmiState(uint32_t app_id, +HmiState::HmiState(utils::SharedPtr app, const ApplicationManager& app_mngr, StateID state_id) - : app_id_(app_id) + : app_(app) , state_id_(state_id) , app_mngr_(app_mngr) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) , system_context_(mobile_apis::SystemContext::INVALID_ENUM) {} -HmiState::HmiState(uint32_t app_id, const ApplicationManager& app_mngr) - : app_id_(app_id) +HmiState::HmiState(utils::SharedPtr app, + const ApplicationManager& app_mngr) + : app_(app) , state_id_(STATE_ID_REGULAR) , app_mngr_(app_mngr) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) @@ -60,24 +61,20 @@ void HmiState::set_parent(HmiStatePtr parent) { parent_ = parent; } -bool HmiState::is_navi_app(const uint32_t app_id) const { - const ApplicationSharedPtr app = app_mngr_.application(app_id); - return app ? app->is_navi() : false; +bool HmiState::is_navi_app() const { + return app_->is_navi(); } -bool HmiState::is_media_app(const uint32_t app_id) const { - const ApplicationSharedPtr app = app_mngr_.application(app_id); - return app ? app->is_media_application() : false; +bool HmiState::is_media_app() const { + return app_->is_media_application(); } -bool HmiState::is_voice_communication_app(const uint32_t app_id) const { - const ApplicationSharedPtr app = app_mngr_.application(app_id); - return app ? app->is_voice_communication_supported() : false; +bool HmiState::is_voice_communication_app() const { + return app_->is_voice_communication_supported(); } -bool HmiState::is_mobile_projection_app(const uint32_t app_id) const { - const ApplicationSharedPtr app = app_mngr_.application(app_id); - return app ? app->mobile_projection_enabled() : false; +bool HmiState::is_mobile_projection_app() const { + return app_->mobile_projection_enabled(); } mobile_apis::AudioStreamingState::eType VRHmiState::audio_streaming_state() @@ -86,11 +83,13 @@ mobile_apis::AudioStreamingState::eType VRHmiState::audio_streaming_state() return AudioStreamingState::NOT_AUDIBLE; } -VRHmiState::VRHmiState(uint32_t app_id, const ApplicationManager& app_mngr) - : HmiState(app_id, app_mngr, STATE_ID_VR_SESSION) {} +VRHmiState::VRHmiState(utils::SharedPtr app, + const ApplicationManager& app_mngr) + : HmiState(app, app_mngr, STATE_ID_VR_SESSION) {} -TTSHmiState::TTSHmiState(uint32_t app_id, const ApplicationManager& app_mngr) - : HmiState(app_id, app_mngr, STATE_ID_TTS_SESSION) {} +TTSHmiState::TTSHmiState(utils::SharedPtr app, + const ApplicationManager& app_mngr) + : HmiState(app, app_mngr, STATE_ID_TTS_SESSION) {} mobile_apis::AudioStreamingState::eType TTSHmiState::audio_streaming_state() const { @@ -107,9 +106,9 @@ mobile_apis::AudioStreamingState::eType TTSHmiState::audio_streaming_state() return expected_state; } -NaviStreamingHmiState::NaviStreamingHmiState(uint32_t app_id, +NaviStreamingHmiState::NaviStreamingHmiState(utils::SharedPtr app, const ApplicationManager& app_mngr) - : HmiState(app_id, app_mngr, STATE_ID_NAVI_STREAMING) {} + : HmiState(app, app_mngr, STATE_ID_NAVI_STREAMING) {} mobile_apis::AudioStreamingState::eType NaviStreamingHmiState::audio_streaming_state() const { @@ -117,7 +116,7 @@ NaviStreamingHmiState::audio_streaming_state() const { using namespace mobile_apis; AudioStreamingState::eType expected_state = parent()->audio_streaming_state(); - if (!is_navi_app(app_id_) && AudioStreamingState::AUDIBLE == expected_state) { + if (!is_navi_app() && AudioStreamingState::AUDIBLE == expected_state) { if (app_mngr_.is_attenuated_supported()) { expected_state = AudioStreamingState::ATTENUATED; } else { @@ -127,9 +126,9 @@ NaviStreamingHmiState::audio_streaming_state() const { return expected_state; } -PhoneCallHmiState::PhoneCallHmiState(uint32_t app_id, +PhoneCallHmiState::PhoneCallHmiState(utils::SharedPtr app, const ApplicationManager& app_mngr) - : HmiState(app_id, app_mngr, STATE_ID_PHONE_CALL) {} + : HmiState(app, app_mngr, STATE_ID_PHONE_CALL) {} mobile_apis::HMILevel::eType PhoneCallHmiState::hmi_level() const { using namespace helpers; @@ -139,22 +138,22 @@ mobile_apis::HMILevel::eType PhoneCallHmiState::hmi_level() const { HMILevel::HMI_NONE)) { return parent()->hmi_level(); } - if (is_navi_app(app_id_) || is_mobile_projection_app(app_id_)) { + if (is_navi_app() || is_mobile_projection_app()) { return HMILevel::HMI_LIMITED; } - if (!is_media_app(app_id_)) { + if (!is_media_app()) { return parent()->hmi_level(); } return HMILevel::HMI_BACKGROUND; } -SafetyModeHmiState::SafetyModeHmiState(uint32_t app_id, +SafetyModeHmiState::SafetyModeHmiState(utils::SharedPtr app, const ApplicationManager& app_mngr) - : HmiState(app_id, app_mngr, STATE_ID_SAFETY_MODE) {} + : HmiState(app, app_mngr, STATE_ID_SAFETY_MODE) {} -DeactivateHMI::DeactivateHMI(uint32_t app_id, +DeactivateHMI::DeactivateHMI(utils::SharedPtr app, const ApplicationManager& app_mngr) - : HmiState(app_id, app_mngr, STATE_ID_DEACTIVATE_HMI) {} + : HmiState(app, app_mngr, STATE_ID_DEACTIVATE_HMI) {} mobile_apis::HMILevel::eType DeactivateHMI::hmi_level() const { using namespace helpers; @@ -167,8 +166,9 @@ mobile_apis::HMILevel::eType DeactivateHMI::hmi_level() const { return HMILevel::HMI_BACKGROUND; } -AudioSource::AudioSource(uint32_t app_id, const ApplicationManager& app_mngr) - : HmiState(app_id, app_mngr, STATE_ID_AUDIO_SOURCE) {} +AudioSource::AudioSource(utils::SharedPtr app, + const ApplicationManager& app_mngr) + : HmiState(app, app_mngr, STATE_ID_AUDIO_SOURCE) {} mobile_apis::HMILevel::eType AudioSource::hmi_level() const { using namespace mobile_apis; @@ -181,14 +181,15 @@ mobile_apis::HMILevel::eType AudioSource::hmi_level() const { HMILevel::HMI_NONE)) { return parent()->hmi_level(); } - if (is_navi_app(app_id_) || is_voice_communication_app(app_id_)) { + if (is_navi_app() || is_voice_communication_app()) { return HMILevel::HMI_LIMITED; } return HMILevel::HMI_BACKGROUND; } -EmbeddedNavi::EmbeddedNavi(uint32_t app_id, const ApplicationManager& app_mngr) - : HmiState(app_id, app_mngr, STATE_ID_EMBEDDED_NAVI) {} +EmbeddedNavi::EmbeddedNavi(utils::SharedPtr app, + const ApplicationManager& app_mngr) + : HmiState(app, app_mngr, STATE_ID_EMBEDDED_NAVI) {} mobile_apis::HMILevel::eType EmbeddedNavi::hmi_level() const { using namespace mobile_apis; @@ -198,7 +199,7 @@ mobile_apis::HMILevel::eType EmbeddedNavi::hmi_level() const { HMILevel::HMI_NONE)) { return parent()->hmi_level(); } - if (is_media_app(app_id_)) { + if (is_media_app()) { return HMILevel::HMI_LIMITED; } return HMILevel::HMI_BACKGROUND; diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index e6ebaf3b83..570aee180c 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1170,7 +1170,7 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification( continue; } policy_manager_->SetUserConsentForDevice(device_id, is_allowed); - uint32_t device_handle = 0; + connection_handler::DeviceHandle device_handle = 0; if (!connection_handler.GetDeviceID(device_id, &device_handle)) { LOG4CXX_WARN(logger_, "Device handle with mac " << device_id @@ -1204,7 +1204,7 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification( } // Case, when specific device was changed - uint32_t device_handle = 0u; + connection_handler::DeviceHandle device_handle = 0u; if (device_specific) { policy_manager_->SetUserConsentForDevice(device_mac, is_allowed); if (!connection_handler.GetDeviceID(device_mac, &device_handle)) { diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc index b456ff6abb..84081a3830 100644 --- a/src/components/application_manager/src/state_controller_impl.cc +++ b/src/components/application_manager/src/state_controller_impl.cc @@ -123,7 +123,7 @@ void StateControllerImpl::SetRegularState( HmiStatePtr prev_regular = app->RegularHmiState(); DCHECK_OR_RETURN_VOID(prev_regular); HmiStatePtr hmi_state = - CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR); + CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN_VOID(hmi_state); hmi_state->set_hmi_level(hmi_level); hmi_state->set_audio_streaming_state(audio_state); @@ -144,7 +144,7 @@ void StateControllerImpl::SetRegularState( return; } const HmiStatePtr hmi_state = - CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR); + CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN_VOID(hmi_state); hmi_state->set_hmi_level(hmi_level); @@ -166,7 +166,7 @@ void StateControllerImpl::SetRegularState( return; } HmiStatePtr hmi_state = - CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR); + CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN_VOID(hmi_state); hmi_state->set_hmi_level(hmi_level); hmi_state->set_audio_streaming_state(audio_state); @@ -184,7 +184,7 @@ void StateControllerImpl::SetRegularState( } HmiStatePtr prev_state = app->RegularHmiState(); HmiStatePtr hmi_state = - CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR); + CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN_VOID(hmi_state); hmi_state->set_hmi_level(hmi_level); hmi_state->set_audio_streaming_state(CalcAudioState(app, hmi_level)); @@ -206,7 +206,7 @@ void StateControllerImpl::SetRegularState( HmiStatePtr prev_regular = app->RegularHmiState(); DCHECK_OR_RETURN_VOID(prev_regular); HmiStatePtr hmi_state = - CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR); + CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN_VOID(hmi_state); hmi_state->set_hmi_level(prev_regular->hmi_level()); hmi_state->set_audio_streaming_state( @@ -227,7 +227,7 @@ void StateControllerImpl::SetRegularState( HmiStatePtr prev_state = app->RegularHmiState(); DCHECK_OR_RETURN_VOID(prev_state); HmiStatePtr hmi_state = - CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR); + CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN_VOID(hmi_state); hmi_state->set_hmi_level(prev_state->hmi_level()); hmi_state->set_audio_streaming_state(audio_state); @@ -325,7 +325,7 @@ HmiStatePtr StateControllerImpl::ResolveHmiState(ApplicationSharedPtr app, << state->system_context()); HmiStatePtr available_state = - CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR); + CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN(available_state, HmiStatePtr()); available_state->set_hmi_level(state->hmi_level()); available_state->set_audio_streaming_state(state->audio_streaming_state()); @@ -502,7 +502,7 @@ void StateControllerImpl::SetupRegularHmiState(ApplicationSharedPtr app, << ", system_context " << state->system_context()); HmiStatePtr curr_state = app->CurrentHmiState(); HmiStatePtr old_state = - CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR); + CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN_VOID(old_state); old_state->set_hmi_level(curr_state->hmi_level()); old_state->set_audio_streaming_state(curr_state->audio_streaming_state()); @@ -533,7 +533,7 @@ void StateControllerImpl::SetupRegularHmiState( HmiStatePtr prev_state = app->RegularHmiState(); DCHECK_OR_RETURN_VOID(prev_state); HmiStatePtr new_state = - CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR); + CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN_VOID(new_state); new_state->set_hmi_level(hmi_level); new_state->set_audio_streaming_state(audio_state); @@ -716,7 +716,7 @@ void StateControllerImpl::OnApplicationRegistered( active_states_lock_.Acquire(); StateIDList::iterator it = active_states_.begin(); for (; it != active_states_.end(); ++it) { - HmiStatePtr new_state = CreateHmiState(app->app_id(), *it); + HmiStatePtr new_state = CreateHmiState(app, *it); DCHECK_OR_RETURN_VOID(new_state); DCHECK_OR_RETURN_VOID(new_state->state_id() != HmiState::STATE_ID_REGULAR); HmiStatePtr old_hmi_state = app->CurrentHmiState(); @@ -726,7 +726,7 @@ void StateControllerImpl::OnApplicationRegistered( active_states_lock_.Release(); HmiStatePtr default_state = - CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR); + CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN_VOID(default_state); default_state->set_hmi_level(default_level); default_state->set_audio_streaming_state(CalcAudioState(app, default_level)); @@ -896,49 +896,49 @@ bool StateControllerImpl::IsStateActive(HmiState::StateID state_id) const { } HmiStatePtr StateControllerImpl::CreateHmiState( - uint32_t app_id, HmiState::StateID state_id) const { + utils::SharedPtr app, HmiState::StateID state_id) const { using namespace utils; LOG4CXX_AUTO_TRACE(logger_); HmiStatePtr new_state; switch (state_id) { case HmiState::STATE_ID_PHONE_CALL: { - new_state = MakeShared(app_id, app_mngr_); + new_state = MakeShared(app, app_mngr_); break; } case HmiState::STATE_ID_SAFETY_MODE: { - new_state = MakeShared(app_id, app_mngr_); + new_state = MakeShared(app, app_mngr_); break; } case HmiState::STATE_ID_VR_SESSION: { - new_state = MakeShared(app_id, app_mngr_); + new_state = MakeShared(app, app_mngr_); break; } case HmiState::STATE_ID_TTS_SESSION: { - new_state = MakeShared(app_id, app_mngr_); + new_state = MakeShared(app, app_mngr_); break; } case HmiState::STATE_ID_NAVI_STREAMING: { - new_state = MakeShared(app_id, app_mngr_); + new_state = MakeShared(app, app_mngr_); break; } case HmiState::STATE_ID_REGULAR: { - new_state = MakeShared(app_id, app_mngr_); + new_state = MakeShared(app, app_mngr_); break; } case HmiState::STATE_ID_POSTPONED: { - new_state = MakeShared(app_id, app_mngr_, state_id); + new_state = MakeShared(app, app_mngr_, state_id); break; } case HmiState::STATE_ID_DEACTIVATE_HMI: { - new_state = MakeShared(app_id, app_mngr_); + new_state = MakeShared(app, app_mngr_); break; } case HmiState::STATE_ID_AUDIO_SOURCE: { - new_state = MakeShared(app_id, app_mngr_); + new_state = MakeShared(app, app_mngr_); break; } case HmiState::STATE_ID_EMBEDDED_NAVI: { - new_state = MakeShared(app_id, app_mngr_); + new_state = MakeShared(app, app_mngr_); break; } default: -- cgit v1.2.1 From 8fa4f3b498916b89552394d25f9482ce4b06de5a Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Thu, 21 Sep 2017 17:40:49 +0300 Subject: Adds descriptions, removes unused code --- .../application_manager/src/application_impl.cc | 1 - .../src/application_manager_impl.cc | 27 +++++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 21847ffa1d..467d606f06 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -117,7 +117,6 @@ ApplicationImpl::ApplicationImpl( , put_file_in_none_count_(0) , delete_file_in_none_count_(0) , list_files_in_none_count_(0) - , device_(0) , mac_address_(mac_address) , device_id_(device_id) , usage_report_(mobile_app_id, statistics_manager) diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 65da6ed87e..20083702d4 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -98,6 +98,12 @@ DeviceTypes devicesType = { std::make_pair(std::string("WIFI"), hmi_apis::Common_TransportType::WIFI)}; } +/** + * @brief device_id_comparator is predicate to compare application device id + * @param device_id Device id to compare with + * @param app Application pointer + * @return True if device id of application matches to device id passed + */ bool device_id_comparator(const std::string& device_id, ApplicationSharedPtr app) { LOG4CXX_DEBUG(logger_, @@ -107,6 +113,13 @@ bool device_id_comparator(const std::string& device_id, return device_id == app->mac_address(); } +/** + * @brief policy_app_id_comparator is predicate to compare policy application + * ids + * @param policy_app_id Policy id of application + * @param app Application pointer + * @return True if policy id of application matches to policy id passed + */ bool policy_app_id_comparator(const std::string& policy_app_id, ApplicationSharedPtr app) { DCHECK_OR_RETURN(app, false); @@ -1516,6 +1529,17 @@ void ApplicationManagerImpl::OnServiceEndedCallback( << type << " with reason " << close_reason << " in session 0x" << std::hex << session_key); + auto app = application(static_cast(session_key)); + if (!app) { + return; + } + + if (IsAppInReconnectMode(app->policy_app_id())) { + LOG4CXX_DEBUG(logger_, + "Application is in reconnection list and won't be closed."); + return; + } + if (type == kRpc) { LOG4CXX_INFO(logger_, "Remove application."); /* In case it was unexpected disconnect or some special case @@ -3681,7 +3705,6 @@ bool ApplicationManagerImpl::IsApplicationForbidden( return forbidden_applications.find(name) != forbidden_applications.end(); } -// TODO: check its usage bool ApplicationManagerImpl::IsAppInReconnectMode( const std::string& policy_app_id) const { LOG4CXX_AUTO_TRACE(logger_); @@ -4014,8 +4037,6 @@ void ApplicationManagerImpl::ProcessReconnection( EraseAppFromReconnectionList(application); - connection_handler().OnDeviceConnectionSwitched(device_mac); - SwitchApplication(application, connection_key, new_device_id); // Update connection type for existed device. -- cgit v1.2.1 From 7d03482c7f9689a375cd87f3acabda1b9af7624f Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Thu, 21 Sep 2017 19:03:44 +0300 Subject: Reverts deprecated interfaces --- .../application_manager/src/application_impl.cc | 5 + .../src/application_manager_impl.cc | 12 ++ .../src/commands/command_impl.cc | 91 ++++++++- .../src/commands/hmi/notification_from_hmi.cc | 2 +- .../src/commands/hmi/notification_to_hmi.cc | 2 +- .../src/commands/hmi/request_from_hmi.cc | 2 +- .../src/commands/hmi/request_to_hmi.cc | 2 +- .../src/commands/hmi/response_from_hmi.cc | 2 +- .../src/commands/hmi/response_to_hmi.cc | 2 +- .../mobile/register_app_interface_request.cc | 213 +++++++++++++++++++++ .../application_manager/src/hmi_state.cc | 58 ++++++ .../src/message_helper/message_helper.cc | 2 +- 12 files changed, 378 insertions(+), 15 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 467d606f06..8af4c97543 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -612,6 +612,11 @@ void ApplicationImpl::set_app_allowed(const bool allowed) { is_app_allowed_ = allowed; } +// DEPRECATED +void ApplicationImpl::set_device(connection_handler::DeviceHandle device) { + device_id_ = device; +} + uint32_t ApplicationImpl::get_grammar_id() const { return grammar_id_; } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 20083702d4..fe9d2d8370 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -839,6 +839,18 @@ HmiStatePtr ApplicationManagerImpl::CreateRegularState( return state; } +HmiStatePtr ApplicationManagerImpl::CreateRegularState( + uint32_t app_id, + mobile_apis::HMILevel::eType hmi_level, + mobile_apis::AudioStreamingState::eType audio_state, + mobile_apis::SystemContext::eType system_context) const { + HmiStatePtr state(new HmiState(app_id, *this)); + state->set_hmi_level(hmi_level); + state->set_audio_streaming_state(audio_state); + state->set_system_context(system_context); + return state; +} + bool ApplicationManagerImpl::IsStateActive(HmiState::StateID state_id) const { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "Checking for active state id " << state_id); diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc index d17f6cdc10..f9cb09816e 100644 --- a/src/components/application_manager/src/commands/command_impl.cc +++ b/src/components/application_manager/src/commands/command_impl.cc @@ -94,7 +94,7 @@ void CommandImpl::SetAllowedToTerminate(const bool allowed) { allowed_to_terminate_ = allowed; } -bool CommandImpl::ReplaceMobileByHMIAppId( +bool CommandImpl::ReplaceMobileWithHMIAppId( NsSmartDeviceLink::NsSmartObjects::SmartObject& message) { if (message.keyExists(strings::app_id)) { ApplicationSharedPtr application = @@ -104,7 +104,7 @@ bool CommandImpl::ReplaceMobileByHMIAppId( return false; } LOG4CXX_DEBUG(logger_, - "ReplaceMobileByHMIAppId from " + "ReplaceMobileWithHMIAppId from " << message[strings::app_id].asInt() << " to " << application->hmi_app_id()); message[strings::app_id] = application->hmi_app_id(); @@ -114,7 +114,7 @@ bool CommandImpl::ReplaceMobileByHMIAppId( smart_objects::SmartArray* message_array = message.asArray(); smart_objects::SmartArray::iterator it = message_array->begin(); for (; it != message_array->end(); ++it) { - ReplaceMobileByHMIAppId(*it); + ReplaceMobileWithHMIAppId(*it); } break; } @@ -123,7 +123,7 @@ bool CommandImpl::ReplaceMobileByHMIAppId( std::set::const_iterator key = keys.begin(); for (; key != keys.end(); ++key) { std::string k = *key; - ReplaceMobileByHMIAppId(message[*key]); + ReplaceMobileWithHMIAppId(message[*key]); } break; } @@ -134,7 +134,44 @@ bool CommandImpl::ReplaceMobileByHMIAppId( return true; } -bool CommandImpl::ReplaceHMIByMobileAppId( +// DEPRECATED +void CommandImpl::ReplaceMobileByHMIAppId( + NsSmartDeviceLink::NsSmartObjects::SmartObject& message) { + if (message.keyExists(strings::app_id)) { + ApplicationSharedPtr application = + application_manager_.application(message[strings::app_id].asUInt()); + if (application.valid()) { + LOG4CXX_DEBUG(logger_, + "ReplaceMobileWithHMIAppId from " + << message[strings::app_id].asInt() << " to " + << application->hmi_app_id()); + message[strings::app_id] = application->hmi_app_id(); + } + } else { + switch (message.getType()) { + case smart_objects::SmartType::SmartType_Array: { + smart_objects::SmartArray* message_array = message.asArray(); + smart_objects::SmartArray::iterator it = message_array->begin(); + for (; it != message_array->end(); ++it) { + ReplaceMobileWithHMIAppId(*it); + } + break; + } + case smart_objects::SmartType::SmartType_Map: { + std::set keys = message.enumerate(); + std::set::const_iterator key = keys.begin(); + for (; key != keys.end(); ++key) { + std::string k = *key; + ReplaceMobileWithHMIAppId(message[*key]); + } + break; + } + default: { break; } + } + } +} + +bool CommandImpl::ReplaceHMIWithMobileAppId( NsSmartDeviceLink::NsSmartObjects::SmartObject& message) { if (message.keyExists(strings::app_id)) { ApplicationSharedPtr application = @@ -146,7 +183,7 @@ bool CommandImpl::ReplaceHMIByMobileAppId( return false; } LOG4CXX_DEBUG(logger_, - "ReplaceHMIByMobileAppId from " + "ReplaceHMIWithMobileAppId from " << message[strings::app_id].asInt() << " to " << application->app_id()); message[strings::app_id] = application->app_id(); @@ -156,7 +193,7 @@ bool CommandImpl::ReplaceHMIByMobileAppId( smart_objects::SmartArray* message_array = message.asArray(); smart_objects::SmartArray::iterator it = message_array->begin(); for (; it != message_array->end(); ++it) { - ReplaceHMIByMobileAppId(*it); + ReplaceHMIWithMobileAppId(*it); } break; } @@ -164,7 +201,7 @@ bool CommandImpl::ReplaceHMIByMobileAppId( std::set keys = message.enumerate(); std::set::const_iterator key = keys.begin(); for (; key != keys.end(); ++key) { - ReplaceHMIByMobileAppId(message[*key]); + ReplaceHMIWithMobileAppId(message[*key]); } break; } @@ -175,5 +212,43 @@ bool CommandImpl::ReplaceHMIByMobileAppId( return true; } +// DEPRECATED +void CommandImpl::ReplaceHMIByMobileAppId( + NsSmartDeviceLink::NsSmartObjects::SmartObject& message) { + if (message.keyExists(strings::app_id)) { + ApplicationSharedPtr application = + application_manager_.application_by_hmi_app( + message[strings::app_id].asUInt()); + + if (application.valid()) { + LOG4CXX_DEBUG(logger_, + "ReplaceHMIByMobileAppId from " + << message[strings::app_id].asInt() << " to " + << application->app_id()); + message[strings::app_id] = application->app_id(); + } + } else { + switch (message.getType()) { + case smart_objects::SmartType::SmartType_Array: { + smart_objects::SmartArray* message_array = message.asArray(); + smart_objects::SmartArray::iterator it = message_array->begin(); + for (; it != message_array->end(); ++it) { + ReplaceHMIByMobileAppId(*it); + } + break; + } + case smart_objects::SmartType::SmartType_Map: { + std::set keys = message.enumerate(); + std::set::const_iterator key = keys.begin(); + for (; key != keys.end(); ++key) { + ReplaceHMIByMobileAppId(message[*key]); + } + break; + } + default: { break; } + } + } +} + } // namespace commands } // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc b/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc index 64eb63fde8..3c2d73b10c 100644 --- a/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc @@ -42,7 +42,7 @@ NotificationFromHMI::NotificationFromHMI( const MessageSharedPtr& message, ApplicationManager& application_manager) : CommandImpl(message, application_manager) { // Replace HMI app id with Mobile connection id - ReplaceHMIByMobileAppId(*message); + ReplaceHMIWithMobileAppId(*message); } NotificationFromHMI::~NotificationFromHMI() {} diff --git a/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc b/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc index 7e24dce8d9..b6639c9aea 100644 --- a/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc @@ -44,7 +44,7 @@ NotificationToHMI::NotificationToHMI(const MessageSharedPtr& message, NotificationToHMI::~NotificationToHMI() {} bool NotificationToHMI::Init() { - return ReplaceMobileByHMIAppId(*message_); + return ReplaceMobileWithHMIAppId(*message_); } bool NotificationToHMI::CleanUp() { diff --git a/src/components/application_manager/src/commands/hmi/request_from_hmi.cc b/src/components/application_manager/src/commands/hmi/request_from_hmi.cc index 1119e7c4fd..c91423e369 100644 --- a/src/components/application_manager/src/commands/hmi/request_from_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/request_from_hmi.cc @@ -43,7 +43,7 @@ RequestFromHMI::RequestFromHMI(const MessageSharedPtr& message, : CommandImpl(message, application_manager) , EventObserver(application_manager.event_dispatcher()) { // Replace HMI app id with Mobile connection id - ReplaceHMIByMobileAppId(*(message.get())); + ReplaceHMIWithMobileAppId(*(message.get())); } RequestFromHMI::~RequestFromHMI() {} diff --git a/src/components/application_manager/src/commands/hmi/request_to_hmi.cc b/src/components/application_manager/src/commands/hmi/request_to_hmi.cc index f26dc26ef6..cba36cbb0c 100644 --- a/src/components/application_manager/src/commands/hmi/request_to_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/request_to_hmi.cc @@ -66,7 +66,7 @@ RequestToHMI::RequestToHMI(const MessageSharedPtr& message, RequestToHMI::~RequestToHMI() {} bool RequestToHMI::Init() { - return ReplaceMobileByHMIAppId(*message_); + return ReplaceMobileWithHMIAppId(*message_); } bool RequestToHMI::CleanUp() { diff --git a/src/components/application_manager/src/commands/hmi/response_from_hmi.cc b/src/components/application_manager/src/commands/hmi/response_from_hmi.cc index 23d8e6e229..c5a6dd9d3e 100644 --- a/src/components/application_manager/src/commands/hmi/response_from_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/response_from_hmi.cc @@ -48,7 +48,7 @@ ResponseFromHMI::ResponseFromHMI(const MessageSharedPtr& message, } // Replace HMI app id with Mobile connection id - ReplaceHMIByMobileAppId(*(message.get())); + ReplaceHMIWithMobileAppId(*(message.get())); } ResponseFromHMI::~ResponseFromHMI() {} diff --git a/src/components/application_manager/src/commands/hmi/response_to_hmi.cc b/src/components/application_manager/src/commands/hmi/response_to_hmi.cc index 77e523378a..94f6967e23 100644 --- a/src/components/application_manager/src/commands/hmi/response_to_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/response_to_hmi.cc @@ -44,7 +44,7 @@ ResponseToHMI::ResponseToHMI(const MessageSharedPtr& message, ResponseToHMI::~ResponseToHMI() {} bool ResponseToHMI::Init() { - return ReplaceMobileByHMIAppId(*message_); + return ReplaceMobileWithHMIAppId(*message_); } bool ResponseToHMI::CleanUp() { diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index 1939150541..775811fce0 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc @@ -729,6 +729,219 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( SendChangeRegistrationOnHMI(application); } +// DEPRECATED +void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() { + LOG4CXX_AUTO_TRACE(logger_); + smart_objects::SmartObject response_params(smart_objects::SmartType_Map); + + mobile_apis::Result::eType result_code = mobile_apis::Result::SUCCESS; + + const HMICapabilities& hmi_capabilities = + application_manager_.hmi_capabilities(); + + const uint32_t key = connection_key(); + ApplicationSharedPtr application = application_manager_.application(key); + + resumption::ResumeCtrl& resumer = application_manager_.resume_controller(); + + if (!application) { + LOG4CXX_ERROR(logger_, + "There is no application for such connection key" << key); + LOG4CXX_DEBUG(logger_, "Need to start resume data persistent timer"); + resumer.OnAppRegistrationEnd(); + return; + } + + response_params[strings::sync_msg_version][strings::major_version] = + major_version; // From generated file interfaces/generated_msg_version.h + response_params[strings::sync_msg_version][strings::minor_version] = + minor_version; // From generated file interfaces/generated_msg_version.h + response_params[strings::sync_msg_version][strings::patch_version] = + patch_version; // From generated file interfaces/generated_msg_version.h + + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + + if (msg_params[strings::language_desired].asInt() != + hmi_capabilities.active_vr_language() || + msg_params[strings::hmi_display_language_desired].asInt() != + hmi_capabilities.active_ui_language()) { + LOG4CXX_WARN(logger_, + "Wrong language on registering application " + << application->name().c_str()); + + LOG4CXX_ERROR( + logger_, + "VR language desired code is " + << msg_params[strings::language_desired].asInt() + << " , active VR language code is " + << hmi_capabilities.active_vr_language() << ", UI language code is " + << msg_params[strings::hmi_display_language_desired].asInt() + << " , active UI language code is " + << hmi_capabilities.active_ui_language()); + + result_code = mobile_apis::Result::WRONG_LANGUAGE; + } + + if (HmiInterfaces::STATE_NOT_AVAILABLE != + application_manager_.hmi_interfaces().GetInterfaceState( + HmiInterfaces::HMI_INTERFACE_TTS)) { + FillTTSRelatedFields(response_params, hmi_capabilities); + } + + if (HmiInterfaces::STATE_NOT_AVAILABLE != + application_manager_.hmi_interfaces().GetInterfaceState( + HmiInterfaces::HMI_INTERFACE_VR)) { + FillVRRelatedFields(response_params, hmi_capabilities); + } + + if (HmiInterfaces::STATE_NOT_AVAILABLE != + application_manager_.hmi_interfaces().GetInterfaceState( + HmiInterfaces::HMI_INTERFACE_UI)) { + FillUIRelatedFields(response_params, hmi_capabilities); + } + + if (hmi_capabilities.button_capabilities()) { + response_params[hmi_response::button_capabilities] = + *hmi_capabilities.button_capabilities(); + } + if (hmi_capabilities.soft_button_capabilities()) { + response_params[hmi_response::soft_button_capabilities] = + *hmi_capabilities.soft_button_capabilities(); + } + if (hmi_capabilities.preset_bank_capabilities()) { + response_params[hmi_response::preset_bank_capabilities] = + *hmi_capabilities.preset_bank_capabilities(); + } + if (hmi_capabilities.hmi_zone_capabilities()) { + if (smart_objects::SmartType_Array == + hmi_capabilities.hmi_zone_capabilities()->getType()) { + // hmi_capabilities json contains array and HMI response object + response_params[hmi_response::hmi_zone_capabilities] = + *hmi_capabilities.hmi_zone_capabilities(); + } else { + response_params[hmi_response::hmi_zone_capabilities][0] = + *hmi_capabilities.hmi_zone_capabilities(); + } + } + + if (HmiInterfaces::STATE_NOT_AVAILABLE != + application_manager_.hmi_interfaces().GetInterfaceState( + HmiInterfaces::HMI_INTERFACE_TTS)) { + FillTTSRelatedFields(response_params, hmi_capabilities); + } + + if (hmi_capabilities.pcm_stream_capabilities()) { + response_params[strings::pcm_stream_capabilities] = + *hmi_capabilities.pcm_stream_capabilities(); + } + + if (HmiInterfaces::STATE_NOT_AVAILABLE != + application_manager_.hmi_interfaces().GetInterfaceState( + HmiInterfaces::HMI_INTERFACE_VehicleInfo)) { + FillVIRelatedFields(response_params, hmi_capabilities); + } + + const std::vector& diag_modes = + application_manager_.get_settings().supported_diag_modes(); + if (!diag_modes.empty()) { + std::vector::const_iterator it = diag_modes.begin(); + uint32_t index = 0; + for (; it != diag_modes.end(); ++it) { + response_params[strings::supported_diag_modes][index] = *it; + ++index; + } + } + response_params[strings::sdl_version] = + application_manager_.get_settings().sdl_version(); + const std::string ccpu_version = + application_manager_.hmi_capabilities().ccpu_version(); + if (!ccpu_version.empty()) { + response_params[strings::system_software_version] = ccpu_version; + } + + bool resumption = + (*message_)[strings::msg_params].keyExists(strings::hash_id); + + bool need_restore_vr = resumption; + + std::string hash_id; + std::string add_info; + if (resumption) { + hash_id = (*message_)[strings::msg_params][strings::hash_id].asString(); + if (!resumer.CheckApplicationHash(application, hash_id)) { + LOG4CXX_WARN(logger_, + "Hash from RAI does not match to saved resume data."); + result_code = mobile_apis::Result::RESUME_FAILED; + add_info = "Hash from RAI does not match to saved resume data."; + need_restore_vr = false; + } else if (!resumer.CheckPersistenceFilesForResumption(application)) { + LOG4CXX_WARN(logger_, "Persistent data is missing."); + result_code = mobile_apis::Result::RESUME_FAILED; + add_info = "Persistent data is missing."; + need_restore_vr = false; + } else { + add_info = "Resume succeeded."; + } + } + if ((mobile_apis::Result::SUCCESS == result_code) && + (mobile_apis::Result::INVALID_ENUM != result_checking_app_hmi_type_)) { + add_info += response_info_; + result_code = result_checking_app_hmi_type_; + } + + // in case application exist in resumption we need to send resumeVrgrammars + if (false == resumption) { + resumption = resumer.IsApplicationSaved(application->policy_app_id(), + application->mac_address()); + } + + AppHmiTypes hmi_types; + if ((*message_)[strings::msg_params].keyExists(strings::app_hmi_type)) { + smart_objects::SmartArray* hmi_types_ptr = + (*message_)[strings::msg_params][strings::app_hmi_type].asArray(); + DCHECK_OR_RETURN_VOID(hmi_types_ptr); + SmartArrayValueExtractor extractor; + if (hmi_types_ptr && 0 < hmi_types_ptr->size()) { + std::transform(hmi_types_ptr->begin(), + hmi_types_ptr->end(), + std::back_inserter(hmi_types), + extractor); + } + } + policy::StatusNotifier notify_upd_manager = GetPolicyHandler().AddApplication( + application->policy_app_id(), hmi_types); + SendResponse(true, result_code, add_info.c_str(), &response_params); + SendOnAppRegisteredNotificationToHMI( + *(application.get()), resumption, need_restore_vr); +#ifdef SDL_REMOTE_CONTROL + if (msg_params.keyExists(strings::app_hmi_type)) { + GetPolicyHandler().SetDefaultHmiTypes(application->policy_app_id(), + &(msg_params[strings::app_hmi_type])); + } +#endif // SDL_REMOTE_CONTROL + + // Default HMI level should be set before any permissions validation, since it + // relies on HMI level. + application_manager_.OnApplicationRegistered(application); + (*notify_upd_manager)(); + + // Start PTU after successfull registration + // Sends OnPermissionChange notification to mobile right after RAI response + // and HMI level set-up + GetPolicyHandler().OnAppRegisteredOnMobile(application->policy_app_id()); + + if (result_code != mobile_apis::Result::RESUME_FAILED) { + resumer.StartResumption(application, hash_id); + } else { + resumer.StartResumptionOnlyHMILevel(application); + } + + // By default app subscribed to CUSTOM_BUTTON + SendSubscribeCustomButtonNotification(); + SendChangeRegistrationOnHMI(application); +} + void RegisterAppInterfaceRequest::SendChangeRegistration( const hmi_apis::FunctionID::eType function_id, const int32_t language, diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index d31ff364ea..f67de7a957 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -56,6 +56,28 @@ HmiState::HmiState(utils::SharedPtr app, , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) , system_context_(mobile_apis::SystemContext::INVALID_ENUM) {} +// DEPRECATED +HmiState::HmiState(uint32_t app_id, + const ApplicationManager& app_mngr, + StateID state_id) + : state_id_(state_id) + , app_mngr_(app_mngr) + , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) + , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) + , system_context_(mobile_apis::SystemContext::INVALID_ENUM) { + app_ = app_mngr_.application(app_id); +} + +// DEPRECATED +HmiState::HmiState(uint32_t app_id, const ApplicationManager& app_mngr) + : state_id_(STATE_ID_REGULAR) + , app_mngr_(app_mngr) + , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) + , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) + , system_context_(mobile_apis::SystemContext::INVALID_ENUM) { + app_ = app_mngr_.application(app_id); +} + void HmiState::set_parent(HmiStatePtr parent) { DCHECK_OR_RETURN_VOID(parent); parent_ = parent; @@ -87,10 +109,18 @@ VRHmiState::VRHmiState(utils::SharedPtr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_VR_SESSION) {} +// DEPRECATED +VRHmiState::VRHmiState(uint32_t app_id, const ApplicationManager& app_mngr) + : HmiState(app_id, app_mngr, STATE_ID_VR_SESSION) {} + TTSHmiState::TTSHmiState(utils::SharedPtr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_TTS_SESSION) {} +// DEPRECATED +TTSHmiState::TTSHmiState(uint32_t app_id, const ApplicationManager& app_mngr) + : HmiState(app_id, app_mngr, STATE_ID_TTS_SESSION) {} + mobile_apis::AudioStreamingState::eType TTSHmiState::audio_streaming_state() const { using namespace helpers; @@ -110,6 +140,11 @@ NaviStreamingHmiState::NaviStreamingHmiState(utils::SharedPtr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_NAVI_STREAMING) {} +// DEPRECATED +NaviStreamingHmiState::NaviStreamingHmiState(uint32_t app_id, + const ApplicationManager& app_mngr) + : HmiState(app_id, app_mngr, STATE_ID_NAVI_STREAMING) {} + mobile_apis::AudioStreamingState::eType NaviStreamingHmiState::audio_streaming_state() const { using namespace helpers; @@ -130,6 +165,11 @@ PhoneCallHmiState::PhoneCallHmiState(utils::SharedPtr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_PHONE_CALL) {} +// DEPRECATED +PhoneCallHmiState::PhoneCallHmiState(uint32_t app_id, + const ApplicationManager& app_mngr) + : HmiState(app_id, app_mngr, STATE_ID_PHONE_CALL) {} + mobile_apis::HMILevel::eType PhoneCallHmiState::hmi_level() const { using namespace helpers; using namespace mobile_apis; @@ -151,10 +191,20 @@ SafetyModeHmiState::SafetyModeHmiState(utils::SharedPtr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_SAFETY_MODE) {} +// DEPRECATED +SafetyModeHmiState::SafetyModeHmiState(uint32_t app_id, + const ApplicationManager& app_mngr) + : HmiState(app_id, app_mngr, STATE_ID_SAFETY_MODE) {} + DeactivateHMI::DeactivateHMI(utils::SharedPtr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_DEACTIVATE_HMI) {} +// DERECATED +DeactivateHMI::DeactivateHMI(uint32_t app_id, + const ApplicationManager& app_mngr) + : HmiState(app_id, app_mngr, STATE_ID_DEACTIVATE_HMI) {} + mobile_apis::HMILevel::eType DeactivateHMI::hmi_level() const { using namespace helpers; using namespace mobile_apis; @@ -170,6 +220,10 @@ AudioSource::AudioSource(utils::SharedPtr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_AUDIO_SOURCE) {} +// DEPRECATED +AudioSource::AudioSource(uint32_t app_id, const ApplicationManager& app_mngr) + : HmiState(app_id, app_mngr, STATE_ID_AUDIO_SOURCE) {} + mobile_apis::HMILevel::eType AudioSource::hmi_level() const { using namespace mobile_apis; using namespace helpers; @@ -191,6 +245,10 @@ EmbeddedNavi::EmbeddedNavi(utils::SharedPtr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_EMBEDDED_NAVI) {} +// DEPRECATED +EmbeddedNavi::EmbeddedNavi(uint32_t app_id, const ApplicationManager& app_mngr) + : HmiState(app_id, app_mngr, STATE_ID_EMBEDDED_NAVI) {} + mobile_apis::HMILevel::eType EmbeddedNavi::hmi_level() const { using namespace mobile_apis; using namespace helpers; 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 cf64152315..af9c221a4f 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -1531,7 +1531,7 @@ void MessageHelper::SendOnAppUnregNotificationToHMI( message[strings::params][strings::message_type] = MessageType::kNotification; // we put hmi_app_id because applicaton list does not contain application on // this momment - // and ReplaceHMIByMobileAppId function will be unable to replace app_id to + // and ReplaceHMIWithMobileAppId function will be unable to replace app_id to // hmi_app_id message[strings::msg_params][strings::app_id] = app->hmi_app_id(); message[strings::msg_params][strings::unexpected_disconnect] = -- cgit v1.2.1 From 53625d990e5ae307e84091140152c165ca7afc3b Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Fri, 29 Sep 2017 10:22:15 +0300 Subject: Initial implementation of resumption during switching --- .../src/application_manager_impl.cc | 122 ++++++++++ .../mobile/register_app_interface_request.cc | 22 +- .../src/message_helper/message_helper.cc | 266 +++++++++++++++++++++ 3 files changed, 402 insertions(+), 8 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index fe9d2d8370..e082b34005 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1106,6 +1106,11 @@ void ApplicationManagerImpl::OnDeviceSwitchingStart( apps_data_accessor.GetData().end(), std::back_inserter(reregister_wait_list_), std::bind1st(std::ptr_fun(&device_id_comparator), device_uid)); + + for (auto i = reregister_wait_list_.begin(); reregister_wait_list_.end() != i; + ++i) { + resume_ctrl_->SaveApplication(*i); + } } void ApplicationManagerImpl::OnDeviceSwitchFinish( @@ -2920,6 +2925,123 @@ void ApplicationManagerImpl::ClearAppsPersistentData() { } } +void ApplicationManagerImpl::RecallApplicationData(ApplicationSharedPtr app) { + LOG4CXX_AUTO_TRACE(logger_); + DCHECK_OR_RETURN_VOID(app); + + UnsubscribeAppFromWayPoints(app->app_id()); + if (!IsAnyAppSubscribedForWayPoints()) { + MessageHelper::SendUnsubscribedWayPoints(*this); + } + + // Removing commands + CommandsMap cmap = app->commands_map().GetData(); + + for (auto cmd : cmap) { + MessageHelper::SendDeleteCommandRequest(cmd.second, app, *this); + app->RemoveCommand(cmd.first); + } + // End removing commands + + // Removing submenues + SubMenuMap smap = app->sub_menu_map().GetData(); + + for (auto smenu : smap) { + MessageHelper::SendDeleteSubmenuRequest(smenu.second, app, *this); + app->RemoveSubMenu(smenu.first); + } + // End removing submenues + + // Removing choice sets + ChoiceSetMap csmap = app->choice_set_map().GetData(); + + for (auto choice : csmap) { + MessageHelper::SendDeleteChoiceSetRequest(choice.second, app, *this); + app->RemoveChoiceSet(choice.first); + } + // End removing choice sets + + // Reset global properties + // Help prompt reset + smart_objects::SmartObject empty_so = + smart_objects::SmartObject(smart_objects::SmartType_Array); + app->set_help_prompt(empty_so); + + // Timeout prompt reset + const std::vector& time_out_promt = + get_settings().time_out_promt(); + + smart_objects::SmartObject so_time_out_promt = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + for (uint32_t i = 0; i < time_out_promt.size(); ++i) { + smart_objects::SmartObject timeoutPrompt = + smart_objects::SmartObject(smart_objects::SmartType_Map); + timeoutPrompt[strings::text] = time_out_promt[i]; + timeoutPrompt[strings::type] = hmi_apis::Common_SpeechCapabilities::SC_TEXT; + so_time_out_promt[i] = timeoutPrompt; + } + + app->set_timeout_prompt(so_time_out_promt); + + // VR help title reset + app->reset_vr_help_title(); + + // VR help reset + app->reset_vr_help(); + + // Keyboard properties reset + app->set_keyboard_props(empty_so); + + // Menu icon reset + app->set_menu_icon(empty_so); + + // Menu title reset + app->set_menu_title(empty_so); + + MessageHelper::SendResetPropertiesRequest(app, *this); + // End reset global properties + + // Removing buttons subscriptions + ButtonSubscriptions buttons = app->SubscribedButtons().GetData(); + + for (auto button : buttons) { + if (mobile_apis::ButtonName::CUSTOM_BUTTON == button) { + continue; + } + MessageHelper::SendUnsubscribeButtonNotification(button, app, *this); + app->UnsubscribeFromButton(button); + } + // End removing buttons subscriptions + + // Removing IVI subscriptions + VehicleInfoSubscriptions ivi = app->SubscribedIVI().GetData(); + + for (auto i : ivi) { + app->UnsubscribeFromIVI(i); + SubscribedToIVIPredicate p(static_cast(i)); + auto app = FindApp(applications(), p); + if (!app) { + MessageHelper::SendUnsubscribeIVIRequest(i, app, *this); + } + } + // End removing IVI subscriptions + + // Removing files + // Except icons folder + auto files = app->getAppFiles(); + const auto icon_file = app->app_icon_path(); + for (auto file : files) { + auto file_name = file.first; + if (icon_file == file_name) { + continue; + } + app->DeleteFile(file_name); + file_system::DeleteFile(file_name); + } + // End removing files +} + void ApplicationManagerImpl::SendOnSDLClose() { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index 775811fce0..eebabb1ae7 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc @@ -639,14 +639,6 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( response_params[strings::system_software_version] = ccpu_version; } - if (AppicationType::kSwitchedApplication == app_type) { - LOG4CXX_DEBUG(logger_, - "Application has been switched from another transport."); - - SendResponse(true, result_code, NULL, &response_params); - return; - } - bool resumption = (*message_)[strings::msg_params].keyExists(strings::hash_id); @@ -677,6 +669,20 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( result_code = result_checking_app_hmi_type_; } + if (AppicationType::kSwitchedApplication == app_type) { + LOG4CXX_DEBUG(logger_, + "Application has been switched from another transport."); + + if (!resumption || mobile_apis::Result::RESUME_FAILED == result_code) { + application_manager_.RecallApplicationData(application); + resumer.RemoveApplicationFromSaved(application); + result_code = mobile_apis::Result::RESUME_FAILED; + } + + SendResponse(true, result_code, add_info.c_str(), &response_params); + return; + } + // in case application exist in resumption we need to send resumeVrgrammars if (false == resumption) { resumption = resumer.IsApplicationSaved(application->policy_app_id(), 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 af9c221a4f..cb9b111360 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -42,6 +42,7 @@ #include #include #include +#include #include "application_manager/application.h" #include "application_manager/application_manager.h" @@ -327,6 +328,23 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateRequestObject( return request; } +smart_objects::SmartObjectSPtr MessageHelper::CreateNotificationObject( + const uint32_t correlation_id) { + using namespace smart_objects; + + SmartObjectSPtr message = utils::MakeShared(SmartType_Map); + SmartObject& ref = *message; + + ref[strings::params][strings::message_type] = + static_cast(hmi_apis::messageType::notification); + ref[strings::params][strings::protocol_version] = + commands::CommandImpl::protocol_version_; + ref[strings::params][strings::protocol_type] = + commands::CommandImpl::hmi_protocol_type_; + ref[strings::params][strings::correlation_id] = correlation_id; + return message; +} + smart_objects::SmartObjectSPtr MessageHelper::CreateHashUpdateNotification( const uint32_t app_id) { LOG4CXX_AUTO_TRACE(logger_); @@ -400,6 +418,254 @@ MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( return notification; } +void MessageHelper::SendDeleteCommandRequest(smart_objects::SmartObject* cmd, + ApplicationSharedPtr application, + ApplicationManager& app_mngr) { + LOG4CXX_AUTO_TRACE(logger_); + DCHECK_OR_RETURN_VOID(cmd); + using namespace smart_objects; + SmartObject msg_params = SmartObject(smart_objects::SmartType_Map); + + msg_params[strings::cmd_id] = (*cmd)[strings::msg_params][strings::cmd_id]; + msg_params[strings::app_id] = application->app_id(); + + if ((*cmd).keyExists(strings::menu_params)) { + SmartObjectSPtr message = + CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + DCHECK(message); + + SmartObject& object = *message; + object[strings::params][strings::function_id] = + hmi_apis::FunctionID::UI_DeleteCommand; + + object[strings::msg_params] = msg_params; + + app_mngr.ManageHMICommand(message); + } + + if ((*cmd).keyExists(strings::vr_commands)) { + msg_params[strings::grammar_id] = application->get_grammar_id(); + msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; + + SmartObjectSPtr message = + CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + DCHECK(message); + + SmartObject& object = *message; + object[strings::params][strings::function_id] = + hmi_apis::FunctionID::VR_DeleteCommand; + + object[strings::msg_params] = msg_params; + + app_mngr.ManageHMICommand(message); + } +} + +void MessageHelper::SendDeleteSubmenuRequest(smart_objects::SmartObject* cmd, + ApplicationSharedPtr application, + ApplicationManager& app_mngr) { + LOG4CXX_AUTO_TRACE(logger_); + DCHECK_OR_RETURN_VOID(cmd); + using namespace smart_objects; + + SmartObject msg_params = SmartObject(smart_objects::SmartType_Map); + + msg_params[strings::menu_id] = (*cmd)[strings::msg_params][strings::menu_id]; + msg_params[strings::app_id] = application->app_id(); + + SmartObjectSPtr message = + CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + DCHECK(message); + + SmartObject& object = *message; + object[strings::params][strings::function_id] = + hmi_apis::FunctionID::UI_DeleteSubMenu; + + object[strings::msg_params] = msg_params; + + app_mngr.ManageHMICommand(message); + + // Same is deleted with SendDeleteCommandRequest? + const DataAccessor accessor = application->commands_map(); + const CommandsMap& commands = accessor.GetData(); + CommandsMap::const_iterator it = commands.begin(); + + for (; commands.end() != it; ++it) { + if (!(*it->second).keyExists(strings::vr_commands)) { + continue; + } + + if ((*cmd)[strings::msg_params][strings::menu_id].asInt() == + (*it->second)[strings::menu_params][hmi_request::parent_id].asInt()) { + SmartObject msg_params = SmartObject(smart_objects::SmartType_Map); + msg_params[strings::cmd_id] = (*it->second)[strings::cmd_id].asInt(); + msg_params[strings::app_id] = application->app_id(); + msg_params[strings::grammar_id] = application->get_grammar_id(); + msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; + + SmartObjectSPtr message = + CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + DCHECK(message); + + SmartObject& object = *message; + object[strings::params][strings::function_id] = + hmi_apis::FunctionID::VR_DeleteCommand; + + object[strings::msg_params] = msg_params; + + app_mngr.ManageHMICommand(message); + } + } +} + +void MessageHelper::SendDeleteChoiceSetRequest(smart_objects::SmartObject* cmd, + ApplicationSharedPtr application, + ApplicationManager& app_mngr) { + LOG4CXX_AUTO_TRACE(logger_); + DCHECK_OR_RETURN_VOID(cmd); + using namespace smart_objects; + + // Same is deleted with SendDeleteCommandRequest? + + 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]; + + SmartObjectSPtr message = + CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + DCHECK(message); + + SmartObject& object = *message; + object[strings::params][strings::function_id] = + hmi_apis::FunctionID::VR_DeleteCommand; + + object[strings::msg_params] = msg_params; + + app_mngr.ManageHMICommand(message); + } +} + +void MessageHelper::SendResetPropertiesRequest(ApplicationSharedPtr application, + ApplicationManager& app_mngr) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace smart_objects; + + { + SmartObject msg_params = SmartObject(smart_objects::SmartType_Map); + + msg_params = *MessageHelper::CreateAppVrHelp(application); + msg_params[hmi_request::menu_title] = ""; + + smart_objects::SmartObject key_board_properties = + smart_objects::SmartObject(smart_objects::SmartType_Map); + key_board_properties[strings::language] = + static_cast(hmi_apis::Common_Language::EN_US); + key_board_properties[hmi_request::keyboard_layout] = + static_cast(hmi_apis::Common_KeyboardLayout::QWERTY); + + key_board_properties[hmi_request::auto_complete_text] = ""; + msg_params[hmi_request::keyboard_properties] = key_board_properties; + + msg_params[strings::app_id] = application->app_id(); + + SmartObjectSPtr message = + CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + DCHECK(message); + + SmartObject& object = *message; + object[strings::params][strings::function_id] = + hmi_apis::FunctionID::UI_SetGlobalProperties; + + object[strings::msg_params] = msg_params; + + app_mngr.ManageHMICommand(message); + } + + { + SmartObject msg_params = SmartObject(smart_objects::SmartType_Map); + + msg_params[strings::help_prompt] = application->help_prompt(); + msg_params[strings::timeout_prompt] = application->timeout_prompt(); + msg_params[strings::app_id] = application->app_id(); + + SmartObjectSPtr message = + CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + DCHECK(message); + + SmartObject& object = *message; + object[strings::params][strings::function_id] = + hmi_apis::FunctionID::TTS_SetGlobalProperties; + + object[strings::msg_params] = msg_params; + + app_mngr.ManageHMICommand(message); + } +} + +void MessageHelper::SendUnsubscribeButtonNotification( + mobile_apis::ButtonName::eType button, + ApplicationSharedPtr application, + ApplicationManager& app_mngr) { + using namespace smart_objects; + using namespace hmi_apis; + + SmartObject msg_params = SmartObject(SmartType_Map); + msg_params[strings::app_id] = application->app_id(); + msg_params[strings::name] = button; + msg_params[strings::is_suscribed] = false; + + SmartObjectSPtr message = + CreateNotificationObject(app_mngr.GetNextHMICorrelationID()); + DCHECK(message); + + SmartObject& object = *message; + object[strings::params][strings::function_id] = + hmi_apis::FunctionID::Buttons_OnButtonSubscription; + + object[strings::msg_params] = msg_params; + + app_mngr.ManageHMICommand(message); +} + +void MessageHelper::SendUnsubscribeIVIRequest(uint32_t ivi_id, + ApplicationSharedPtr application, + ApplicationManager& app_mngr) { + using namespace smart_objects; + + std::string key_name; + for (auto item : vehicle_data_) { + if (ivi_id == item.second) { + key_name = item.first; + break; + } + } + + if (key_name.empty()) { + return; + } + + smart_objects::SmartObject msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[key_name] = true; + + SmartObjectSPtr message = + CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + DCHECK(message); + + SmartObject& object = *message; + object[strings::params][strings::function_id] = + hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData; + + object[strings::msg_params] = msg_params; + + app_mngr.ManageHMICommand(message); +} + const VehicleData& MessageHelper::vehicle_data() { return vehicle_data_; } -- cgit v1.2.1 From 41d6963df22188adba95856dfb0be9844a7de078 Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Fri, 29 Sep 2017 15:42:23 +0300 Subject: Moves app data recall logic out of ApplicationManager --- .../src/application_manager_impl.cc | 156 +-------------------- .../mobile/register_app_interface_request.cc | 4 +- .../src/helpers/application_helper.cc | 147 +++++++++++++++++++ 3 files changed, 152 insertions(+), 155 deletions(-) create mode 100644 src/components/application_manager/src/helpers/application_helper.cc (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index e082b34005..66c28a6888 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -50,6 +50,7 @@ #include "application_manager/app_launch/app_launch_ctrl_impl.h" #include "application_manager/app_launch/app_launch_data_db.h" #include "application_manager/app_launch/app_launch_data_json.h" +#include "application_manager/helpers/application_helper.h" #include "protocol_handler/protocol_handler.h" #include "hmi_message_handler/hmi_message_handler.h" #include "connection_handler/connection_handler_impl.h" @@ -223,33 +224,6 @@ ApplicationManagerImpl::~ApplicationManagerImpl() { navi_app_to_end_stream_.clear(); } -template -ApplicationSharedPtr FindApp(DataAccessor accessor, - UnaryPredicate finder) { - ApplicationSet::iterator it = std::find_if( - accessor.GetData().begin(), accessor.GetData().end(), finder); - if (accessor.GetData().end() == it) { - LOG4CXX_DEBUG(logger_, "Unable to find application"); - return ApplicationSharedPtr(); - } - ApplicationSharedPtr app = *it; - LOG4CXX_DEBUG(logger_, " Found Application app_id = " << app->app_id()); - return app; -} - -template -std::vector FindAllApps( - DataAccessor accessor, UnaryPredicate finder) { - std::vector result; - ApplicationSetConstIt it = std::find_if( - accessor.GetData().begin(), accessor.GetData().end(), finder); - while (it != accessor.GetData().end()) { - result.push_back(*it); - it = std::find_if(++it, accessor.GetData().end(), finder); - } - return result; -} - DataAccessor ApplicationManagerImpl::applications() const { DataAccessor accessor(applications_, applications_list_lock_); return accessor; @@ -360,15 +334,6 @@ ApplicationManagerImpl::applications_by_button(uint32_t button) { return FindAllApps(accessor, finder); } -struct SubscribedToIVIPredicate { - int32_t vehicle_info_; - SubscribedToIVIPredicate(int32_t vehicle_info) - : vehicle_info_(vehicle_info) {} - bool operator()(const ApplicationSharedPtr app) const { - return app ? app->IsSubscribedToIVI(vehicle_info_) : false; - } -}; - struct IsApplication { IsApplication(connection_handler::DeviceHandle device_handle, const std::string& policy_app_id) @@ -395,7 +360,7 @@ std::vector ApplicationManagerImpl::IviInfoUpdated( break; } - SubscribedToIVIPredicate finder(static_cast(vehicle_info)); + SubscribedToIVIPredicate finder(vehicle_info); DataAccessor accessor = applications(); return FindAllApps(accessor, finder); } @@ -2925,123 +2890,6 @@ void ApplicationManagerImpl::ClearAppsPersistentData() { } } -void ApplicationManagerImpl::RecallApplicationData(ApplicationSharedPtr app) { - LOG4CXX_AUTO_TRACE(logger_); - DCHECK_OR_RETURN_VOID(app); - - UnsubscribeAppFromWayPoints(app->app_id()); - if (!IsAnyAppSubscribedForWayPoints()) { - MessageHelper::SendUnsubscribedWayPoints(*this); - } - - // Removing commands - CommandsMap cmap = app->commands_map().GetData(); - - for (auto cmd : cmap) { - MessageHelper::SendDeleteCommandRequest(cmd.second, app, *this); - app->RemoveCommand(cmd.first); - } - // End removing commands - - // Removing submenues - SubMenuMap smap = app->sub_menu_map().GetData(); - - for (auto smenu : smap) { - MessageHelper::SendDeleteSubmenuRequest(smenu.second, app, *this); - app->RemoveSubMenu(smenu.first); - } - // End removing submenues - - // Removing choice sets - ChoiceSetMap csmap = app->choice_set_map().GetData(); - - for (auto choice : csmap) { - MessageHelper::SendDeleteChoiceSetRequest(choice.second, app, *this); - app->RemoveChoiceSet(choice.first); - } - // End removing choice sets - - // Reset global properties - // Help prompt reset - smart_objects::SmartObject empty_so = - smart_objects::SmartObject(smart_objects::SmartType_Array); - app->set_help_prompt(empty_so); - - // Timeout prompt reset - const std::vector& time_out_promt = - get_settings().time_out_promt(); - - smart_objects::SmartObject so_time_out_promt = - smart_objects::SmartObject(smart_objects::SmartType_Array); - - for (uint32_t i = 0; i < time_out_promt.size(); ++i) { - smart_objects::SmartObject timeoutPrompt = - smart_objects::SmartObject(smart_objects::SmartType_Map); - timeoutPrompt[strings::text] = time_out_promt[i]; - timeoutPrompt[strings::type] = hmi_apis::Common_SpeechCapabilities::SC_TEXT; - so_time_out_promt[i] = timeoutPrompt; - } - - app->set_timeout_prompt(so_time_out_promt); - - // VR help title reset - app->reset_vr_help_title(); - - // VR help reset - app->reset_vr_help(); - - // Keyboard properties reset - app->set_keyboard_props(empty_so); - - // Menu icon reset - app->set_menu_icon(empty_so); - - // Menu title reset - app->set_menu_title(empty_so); - - MessageHelper::SendResetPropertiesRequest(app, *this); - // End reset global properties - - // Removing buttons subscriptions - ButtonSubscriptions buttons = app->SubscribedButtons().GetData(); - - for (auto button : buttons) { - if (mobile_apis::ButtonName::CUSTOM_BUTTON == button) { - continue; - } - MessageHelper::SendUnsubscribeButtonNotification(button, app, *this); - app->UnsubscribeFromButton(button); - } - // End removing buttons subscriptions - - // Removing IVI subscriptions - VehicleInfoSubscriptions ivi = app->SubscribedIVI().GetData(); - - for (auto i : ivi) { - app->UnsubscribeFromIVI(i); - SubscribedToIVIPredicate p(static_cast(i)); - auto app = FindApp(applications(), p); - if (!app) { - MessageHelper::SendUnsubscribeIVIRequest(i, app, *this); - } - } - // End removing IVI subscriptions - - // Removing files - // Except icons folder - auto files = app->getAppFiles(); - const auto icon_file = app->app_icon_path(); - for (auto file : files) { - auto file_name = file.first; - if (icon_file == file_name) { - continue; - } - app->DeleteFile(file_name); - file_system::DeleteFile(file_name); - } - // End removing files -} - void ApplicationManagerImpl::SendOnSDLClose() { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index eebabb1ae7..f29d5e1379 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc @@ -46,6 +46,7 @@ #include "application_manager/message_helper.h" #include "application_manager/resumption/resume_ctrl.h" #include "application_manager/policies/policy_handler.h" +#include "application_manager/helpers/application_helper.h" #include "config_profile/profile.h" #include "interfaces/MOBILE_API.h" #include "interfaces/generated_msg_version.h" @@ -674,7 +675,8 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( "Application has been switched from another transport."); if (!resumption || mobile_apis::Result::RESUME_FAILED == result_code) { - application_manager_.RecallApplicationData(application); + application_manager::RecallApplicationData(application, + application_manager_); resumer.RemoveApplicationFromSaved(application); result_code = mobile_apis::Result::RESUME_FAILED; } diff --git a/src/components/application_manager/src/helpers/application_helper.cc b/src/components/application_manager/src/helpers/application_helper.cc new file mode 100644 index 0000000000..ffe97709a8 --- /dev/null +++ b/src/components/application_manager/src/helpers/application_helper.cc @@ -0,0 +1,147 @@ +#include +#include +#include "application_manager/helpers/application_helper.h" +#include "application_manager/message_helper.h" +#include "utils/logger.h" +#include "utils/file_system.h" + +namespace { +using namespace application_manager; +void RecallWayPoints(ApplicationSharedPtr app, + ApplicationManager& app_manager) { + app_manager.UnsubscribeAppFromWayPoints(app->app_id()); + if (!app_manager.IsAnyAppSubscribedForWayPoints()) { + MessageHelper::SendUnsubscribedWayPoints(app_manager); + } +} + +void RecallCommands(ApplicationSharedPtr app, ApplicationManager& app_manager) { + CommandsMap cmap = app->commands_map().GetData(); + + for (auto cmd : cmap) { + MessageHelper::SendDeleteCommandRequest(cmd.second, app, app_manager); + app->RemoveCommand(cmd.first); + } +} + +void RecallSubmenues(ApplicationSharedPtr app, + ApplicationManager& app_manager) { + SubMenuMap smap = app->sub_menu_map().GetData(); + + for (auto smenu : smap) { + MessageHelper::SendDeleteSubmenuRequest(smenu.second, app, app_manager); + app->RemoveSubMenu(smenu.first); + } +} + +void RecallChoiceSets(ApplicationSharedPtr app, + ApplicationManager& app_manager) { + ChoiceSetMap csmap = app->choice_set_map().GetData(); + + for (auto choice : csmap) { + MessageHelper::SendDeleteChoiceSetRequest(choice.second, app, app_manager); + app->RemoveChoiceSet(choice.first); + } +} + +void RecallGlobalProperties(ApplicationSharedPtr app, + ApplicationManager& app_manager) { + using namespace smart_objects; + + const std::vector& timeout_prompt = + app_manager.get_settings().time_out_promt(); + + SmartObject so_default_timeout_prompt = SmartObject(SmartType_Array); + + int32_t index = 0; + for (auto prompt : timeout_prompt) { + SmartObject timeoutPrompt = SmartObject(SmartType_Map); + timeoutPrompt[strings::text] = timeout_prompt[static_cast(index)]; + timeoutPrompt[strings::type] = hmi_apis::Common_SpeechCapabilities::SC_TEXT; + so_default_timeout_prompt[index] = timeoutPrompt; + ++index; + } + + app->set_timeout_prompt(so_default_timeout_prompt); + + SmartObject empty_so = SmartObject(SmartType_Array); + app->set_help_prompt(empty_so); + app->reset_vr_help_title(); + app->reset_vr_help(); + app->set_keyboard_props(empty_so); + app->set_menu_icon(empty_so); + app->set_menu_title(empty_so); + + MessageHelper::SendResetPropertiesRequest(app, app_manager); +} + +void RecallButtonSubscriptions(ApplicationSharedPtr app, + ApplicationManager& app_manager) { + ButtonSubscriptions buttons = app->SubscribedButtons().GetData(); + + for (auto button : buttons) { + if (mobile_apis::ButtonName::CUSTOM_BUTTON == button) { + continue; + } + MessageHelper::SendUnsubscribeButtonNotification(button, app, app_manager); + app->UnsubscribeFromButton(button); + } +} + +void RecallVISubscriptions(ApplicationSharedPtr app, + ApplicationManager& app_manager) { + VehicleInfoSubscriptions ivi = app->SubscribedIVI().GetData(); + + for (auto i : ivi) { + app->UnsubscribeFromIVI(i); + SubscribedToIVIPredicate p(i); + auto app = FindApp(app_manager.applications(), p); + if (!app) { + MessageHelper::SendUnsubscribeIVIRequest(i, app, app_manager); + } + } +} + +void CleanupAppFiles(ApplicationSharedPtr app) { + const auto icon_file = app->app_icon_path(); + + auto files = app->getAppFiles(); + for (auto file : files) { + auto file_name = file.first; + if (icon_file == file_name) { + continue; + } + app->DeleteFile(file_name); + file_system::DeleteFile(file_name); + } +} +} // namespace + +namespace application_manager { + +CREATE_LOGGERPTR_GLOBAL(logger, "ApplicationManager") + +SubscribedToIVIPredicate::SubscribedToIVIPredicate(uint32_t vehicle_info) + : vehicle_info_(vehicle_info) {} + +bool SubscribedToIVIPredicate::operator()( + const ApplicationSharedPtr app) const { + return app ? app->IsSubscribedToIVI(vehicle_info_) : false; +} + +void RecallApplicationData(ApplicationSharedPtr app, + ApplicationManager& app_manager) { + LOG4CXX_AUTO_TRACE(logger); + DCHECK_OR_RETURN_VOID(app); + + RecallWayPoints(app, app_manager); + RecallCommands(app, app_manager); + RecallSubmenues(app, app_manager); + RecallChoiceSets(app, app_manager); + RecallGlobalProperties(app, app_manager); + RecallButtonSubscriptions(app, app_manager); + RecallVISubscriptions(app, app_manager); + CleanupAppFiles(app); +} + +} // namespace application_manager -- cgit v1.2.1 From 35b49b9abf198963d165c618415c74bb0c59b31d Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Mon, 2 Oct 2017 10:12:01 +0300 Subject: Marks deprecated and unused interfaces in ApplicationManagerImpl --- src/components/application_manager/src/application_manager_impl.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 66c28a6888..2755f04b94 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -629,10 +629,12 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( return application; } +// DEPRECATED bool ApplicationManagerImpl::RemoveAppDataFromHMI(ApplicationSharedPtr app) { return true; } +// DEPRECATED bool ApplicationManagerImpl::LoadAppDataToHMI(ApplicationSharedPtr app) { return true; } @@ -784,6 +786,7 @@ void ApplicationManagerImpl::set_driver_distraction(const bool is_distracting) { is_distracting_driver_ = is_distracting; } +// DEPRECATED void ApplicationManagerImpl::set_vr_session_started(const bool state) { is_vr_session_strated_ = state; } -- cgit v1.2.1 From afbf4df6653fcb0d722b01da253acddaabba0d90 Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Mon, 2 Oct 2017 13:46:14 +0300 Subject: Initial implementation of holding commands for switching apps --- .../src/application_manager_impl.cc | 19 +++++- .../application_manager/src/command_holder_impl.cc | 75 ++++++++++++++++++++++ .../mobile/register_app_interface_request.cc | 2 + 3 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 src/components/application_manager/src/command_holder_impl.cc (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 2755f04b94..113b6e826a 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -195,6 +195,7 @@ ApplicationManagerImpl::ApplicationManagerImpl( const uint32_t timeout_ms = 10000u; clearing_timer->Start(timeout_ms, timer::kSingleShot); timer_pool_.push_back(clearing_timer); + commands_holder_.SetCommandsProcessor(this); } ApplicationManagerImpl::~ApplicationManagerImpl() { @@ -388,6 +389,10 @@ void ApplicationManagerImpl::OnApplicationRegistered(ApplicationSharedPtr app) { event.raise(event_dispatcher()); } +void ApplicationManagerImpl::OnApplicationSwitched(ApplicationSharedPtr app) { + commands_holder_.Release(app->policy_app_id()); +} + bool ApplicationManagerImpl::IsAppTypeExistsInFullOrLimited( ApplicationConstSharedPtr app) const { bool voice_state = app->is_voice_communication_supported(); @@ -1077,7 +1082,9 @@ void ApplicationManagerImpl::OnDeviceSwitchingStart( for (auto i = reregister_wait_list_.begin(); reregister_wait_list_.end() != i; ++i) { - resume_ctrl_->SaveApplication(*i); + auto app = *i; + request_ctrl_.terminateAppRequests(app->app_id()); + resume_ctrl_->SaveApplication(app); } } @@ -1092,7 +1099,9 @@ void ApplicationManagerImpl::OnDeviceSwitchFinish( for (auto app_it = reregister_wait_list_.begin(); app_it != reregister_wait_list_.end(); ++app_it) { - UnregisterApplication((*app_it)->app_id(), + auto app = *app_it; + commands_holder_.Drop(app->policy_app_id()); + UnregisterApplication(app->app_id(), mobile_apis::Result::INVALID_ENUM, is_resuming, unexpected_disonnect); @@ -2040,6 +2049,12 @@ bool ApplicationManagerImpl::ManageHMICommand( return false; } + auto app = application(command->connection_key()); + if (app && IsAppInReconnectMode(app->policy_app_id())) { + commands_holder_.Hold(app->policy_app_id(), message); + return true; + } + int32_t message_type = (*(message.get()))[strings::params][strings::message_type].asInt(); diff --git a/src/components/application_manager/src/command_holder_impl.cc b/src/components/application_manager/src/command_holder_impl.cc new file mode 100644 index 0000000000..3bb3e8c190 --- /dev/null +++ b/src/components/application_manager/src/command_holder_impl.cc @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2017, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "application_manager/command_holder_impl.h" +#include "application_manager/application_manager.h" + +namespace application_manager { +CommandHolderImpl::CommandHolderImpl() + : app_manager_(nullptr), commands_lock_() {} + +void CommandHolderImpl::SetCommandsProcessor(ApplicationManager* app_manager) { + DCHECK_OR_RETURN_VOID(app_manager); + app_manager_ = app_manager; +} + +void CommandHolderImpl::Hold( + const std::string& policy_app_id, + utils::SharedPtr command) { + sync_primitives::AutoLock lock(commands_lock_); + app_commands_[policy_app_id].push_back(command); +} + +void CommandHolderImpl::Release(const std::string& policy_app_id) { + sync_primitives::AutoLock lock(commands_lock_); + auto app_commands = app_commands_.find(policy_app_id); + if (app_commands_.end() == app_commands) { + return; + } + for (auto cmd : app_commands->second) { + DCHECK_OR_RETURN_VOID(app_manager_); + app_manager_->ManageHMICommand(cmd); + } + + app_commands_.erase(app_commands); +} + +void CommandHolderImpl::Drop(const std::string& policy_app_id) { + sync_primitives::AutoLock lock(commands_lock_); + auto app_commands = app_commands_.find(policy_app_id); + if (app_commands_.end() == app_commands) { + return; + } + + app_commands_.erase(app_commands); +} +} // application_manager diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index f29d5e1379..6088e46e06 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc @@ -1465,6 +1465,8 @@ bool RegisterAppInterfaceRequest::IsApplicationSwitched() { application_manager_.SendHMIStatusNotification(app); + application_manager_.OnApplicationSwitched(app); + return true; } -- cgit v1.2.1 From 764ff67916a0832a31b38a58f4877ecb48e1d301 Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Wed, 4 Oct 2017 13:20:23 +0300 Subject: Adds descriptions and removes obsolete implementations --- .../src/message_helper/message_helper.cc | 138 +++++++++------------ 1 file changed, 61 insertions(+), 77 deletions(-) (limited to 'src/components/application_manager/src') 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 cb9b111360..e02291224a 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -311,32 +311,14 @@ std::string MessageHelper::CommonLanguageToString( return std::string(); } -smart_objects::SmartObjectSPtr MessageHelper::CreateRequestObject( - const uint32_t correlation_id) { - using namespace smart_objects; - - SmartObjectSPtr request = utils::MakeShared(SmartType_Map); - SmartObject& ref = *request; - - ref[strings::params][strings::message_type] = - static_cast(hmi_apis::messageType::request); - ref[strings::params][strings::protocol_version] = - commands::CommandImpl::protocol_version_; - ref[strings::params][strings::protocol_type] = - commands::CommandImpl::hmi_protocol_type_; - ref[strings::params][strings::correlation_id] = correlation_id; - return request; -} - -smart_objects::SmartObjectSPtr MessageHelper::CreateNotificationObject( - const uint32_t correlation_id) { +smart_objects::SmartObjectSPtr MessageHelper::CreateMessageForHMI( + hmi_apis::messageType::eType message_type, const uint32_t correlation_id) { using namespace smart_objects; SmartObjectSPtr message = utils::MakeShared(SmartType_Map); SmartObject& ref = *message; - ref[strings::params][strings::message_type] = - static_cast(hmi_apis::messageType::notification); + ref[strings::params][strings::message_type] = static_cast(message_type); ref[strings::params][strings::protocol_version] = commands::CommandImpl::protocol_version_; ref[strings::params][strings::protocol_type] = @@ -362,8 +344,8 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateHashUpdateNotification( void MessageHelper::SendDecryptCertificateToHMI(const std::string& file_name, ApplicationManager& app_mngr) { using namespace smart_objects; - SmartObjectSPtr message = - CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + SmartObjectSPtr message = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); DCHECK(message); SmartObject& object = *message; @@ -430,8 +412,8 @@ void MessageHelper::SendDeleteCommandRequest(smart_objects::SmartObject* cmd, msg_params[strings::app_id] = application->app_id(); if ((*cmd).keyExists(strings::menu_params)) { - SmartObjectSPtr message = - CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + SmartObjectSPtr message = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); DCHECK(message); SmartObject& object = *message; @@ -447,8 +429,8 @@ void MessageHelper::SendDeleteCommandRequest(smart_objects::SmartObject* cmd, msg_params[strings::grammar_id] = application->get_grammar_id(); msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; - SmartObjectSPtr message = - CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + SmartObjectSPtr message = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); DCHECK(message); SmartObject& object = *message; @@ -473,8 +455,8 @@ void MessageHelper::SendDeleteSubmenuRequest(smart_objects::SmartObject* cmd, msg_params[strings::menu_id] = (*cmd)[strings::msg_params][strings::menu_id]; msg_params[strings::app_id] = application->app_id(); - SmartObjectSPtr message = - CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + SmartObjectSPtr message = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); DCHECK(message); SmartObject& object = *message; @@ -485,7 +467,6 @@ void MessageHelper::SendDeleteSubmenuRequest(smart_objects::SmartObject* cmd, app_mngr.ManageHMICommand(message); - // Same is deleted with SendDeleteCommandRequest? const DataAccessor accessor = application->commands_map(); const CommandsMap& commands = accessor.GetData(); CommandsMap::const_iterator it = commands.begin(); @@ -503,8 +484,8 @@ void MessageHelper::SendDeleteSubmenuRequest(smart_objects::SmartObject* cmd, msg_params[strings::grammar_id] = application->get_grammar_id(); msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; - SmartObjectSPtr message = - CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + SmartObjectSPtr message = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); DCHECK(message); SmartObject& object = *message; @@ -536,8 +517,8 @@ void MessageHelper::SendDeleteChoiceSetRequest(smart_objects::SmartObject* cmd, for (uint32_t i = 0; i < (*cmd).length(); ++i) { msg_params[strings::cmd_id] = (*cmd)[i][strings::choice_id]; - SmartObjectSPtr message = - CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + SmartObjectSPtr message = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); DCHECK(message); SmartObject& object = *message; @@ -573,8 +554,8 @@ void MessageHelper::SendResetPropertiesRequest(ApplicationSharedPtr application, msg_params[strings::app_id] = application->app_id(); - SmartObjectSPtr message = - CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + SmartObjectSPtr message = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); DCHECK(message); SmartObject& object = *message; @@ -593,8 +574,8 @@ void MessageHelper::SendResetPropertiesRequest(ApplicationSharedPtr application, msg_params[strings::timeout_prompt] = application->timeout_prompt(); msg_params[strings::app_id] = application->app_id(); - SmartObjectSPtr message = - CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + SmartObjectSPtr message = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); DCHECK(message); SmartObject& object = *message; @@ -619,8 +600,8 @@ void MessageHelper::SendUnsubscribeButtonNotification( msg_params[strings::name] = button; msg_params[strings::is_suscribed] = false; - SmartObjectSPtr message = - CreateNotificationObject(app_mngr.GetNextHMICorrelationID()); + SmartObjectSPtr message = CreateMessageForHMI( + hmi_apis::messageType::notification, app_mngr.GetNextHMICorrelationID()); DCHECK(message); SmartObject& object = *message; @@ -653,8 +634,8 @@ void MessageHelper::SendUnsubscribeIVIRequest(uint32_t ivi_id, smart_objects::SmartObject(smart_objects::SmartType_Map); msg_params[key_name] = true; - SmartObjectSPtr message = - CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + SmartObjectSPtr message = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); DCHECK(message); SmartObject& object = *message; @@ -1216,7 +1197,9 @@ void MessageHelper::SendSetAppIcon( using namespace smart_objects; SmartObjectSPtr set_app_icon = - CreateRequestObject(application_manager.GetNextHMICorrelationID()); + CreateMessageForHMI(hmi_apis::messageType::request, + application_manager.GetNextHMICorrelationID()); + if (set_app_icon) { SmartObject& so_to_send = *set_app_icon; so_to_send[strings::params][strings::function_id] = @@ -1275,7 +1258,7 @@ MessageHelper::CreateGlobalPropertiesRequestsToHMI( if (app->vr_help_title() || app->vr_help()) { smart_objects::SmartObjectSPtr ui_global_properties = - CreateRequestObject(correlation_id); + CreateMessageForHMI(hmi_apis::messageType::request, correlation_id); if (!ui_global_properties) { return requests; } @@ -1310,7 +1293,7 @@ MessageHelper::CreateGlobalPropertiesRequestsToHMI( // TTS global properties if (app->help_prompt() || app->timeout_prompt()) { smart_objects::SmartObjectSPtr tts_global_properties = - CreateRequestObject(correlation_id); + CreateMessageForHMI(hmi_apis::messageType::request, correlation_id); if (!tts_global_properties) { return requests; } @@ -1342,8 +1325,9 @@ void MessageHelper::SendTTSGlobalProperties(ApplicationSharedPtr app, if (!app) { return; } - smart_objects::SmartObjectSPtr tts_global_properties = - CreateRequestObject(app_man.GetNextHMICorrelationID()); + smart_objects::SmartObjectSPtr tts_global_properties = CreateMessageForHMI( + hmi_apis::messageType::request, app_man.GetNextHMICorrelationID()); + if (tts_global_properties) { smart_objects::SmartObject& so_to_send = *tts_global_properties; so_to_send[strings::params][strings::function_id] = @@ -1421,7 +1405,7 @@ smart_objects::SmartObjectList MessageHelper::CreateShowRequestToHMI( if (app->show_command()) { smart_objects::SmartObjectSPtr ui_show = - CreateRequestObject(correlation_id); + CreateMessageForHMI(hmi_apis::messageType::request, correlation_id); (*ui_show)[strings::params][strings::function_id] = static_cast(hmi_apis::FunctionID::UI_Show); @@ -1453,8 +1437,8 @@ void MessageHelper::SendShowConstantTBTRequestToHMI( } if (app->tbt_show_command()) { - smart_objects::SmartObjectSPtr navi_show_tbt = - CreateRequestObject(app_man.GetNextHMICorrelationID()); + smart_objects::SmartObjectSPtr navi_show_tbt = CreateMessageForHMI( + hmi_apis::messageType::request, app_man.GetNextHMICorrelationID()); if (!navi_show_tbt) { return; } @@ -1494,8 +1478,8 @@ smart_objects::SmartObjectList MessageHelper::CreateAddCommandRequestToHMI( for (; commands.end() != i; ++i) { // UI Interface if ((*i->second).keyExists(strings::menu_params)) { - smart_objects::SmartObjectSPtr ui_command = - CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + smart_objects::SmartObjectSPtr ui_command = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); if (!ui_command) { return requests; } @@ -1547,8 +1531,8 @@ 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) { - smart_objects::SmartObjectSPtr vr_command = - CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + smart_objects::SmartObjectSPtr vr_command = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); if (!vr_command) { return requests; } @@ -1581,8 +1565,8 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateChangeRegistration( const uint32_t app_id, const smart_objects::SmartObject* app_types, ApplicationManager& app_mngr) { - smart_objects::SmartObjectSPtr command = - CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + smart_objects::SmartObjectSPtr command = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); if (!command) { return NULL; } @@ -1638,8 +1622,8 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateAddVRCommandToHMI( const smart_objects::SmartObject& vr_commands, uint32_t app_id, ApplicationManager& app_mngr) { - smart_objects::SmartObjectSPtr vr_command = - CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + smart_objects::SmartObjectSPtr vr_command = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); if (!vr_command) { return NULL; } @@ -1758,7 +1742,7 @@ smart_objects::SmartObjectList MessageHelper::CreateAddSubMenuRequestToHMI( SubMenuMap::const_iterator i = sub_menu.begin(); for (; sub_menu.end() != i; ++i) { smart_objects::SmartObjectSPtr ui_sub_menu = - CreateRequestObject(correlation_id); + CreateMessageForHMI(hmi_apis::messageType::request, correlation_id); if (!ui_sub_menu) { return requsets; } @@ -1947,8 +1931,8 @@ void MessageHelper::SendPolicyUpdate(const std::string& file_path, const uint32_t timeout, const std::vector& retries, ApplicationManager& app_mngr) { - smart_objects::SmartObjectSPtr message = - CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + smart_objects::SmartObjectSPtr message = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); smart_objects::SmartObject& object = *message; object[strings::params][strings::function_id] = hmi_apis::FunctionID::BasicCommunication_PolicyUpdate; @@ -2129,8 +2113,8 @@ void MessageHelper::SendNaviSetVideoConfig( ApplicationManager& app_mngr, const smart_objects::SmartObject& video_params) { LOG4CXX_AUTO_TRACE(logger_); - smart_objects::SmartObjectSPtr request = - CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + smart_objects::SmartObjectSPtr request = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); if (!request) { return; } @@ -2147,8 +2131,8 @@ void MessageHelper::SendNaviSetVideoConfig( void MessageHelper::SendNaviStartStream(const int32_t app_id, ApplicationManager& app_mngr) { LOG4CXX_AUTO_TRACE(logger_); - smart_objects::SmartObjectSPtr start_stream = - CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + smart_objects::SmartObjectSPtr start_stream = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); if (!start_stream) { return; } @@ -2186,8 +2170,8 @@ void MessageHelper::SendNaviStartStream(const int32_t app_id, void MessageHelper::SendNaviStopStream(const int32_t app_id, ApplicationManager& app_mngr) { LOG4CXX_AUTO_TRACE(logger_); - smart_objects::SmartObjectSPtr stop_stream = - CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + smart_objects::SmartObjectSPtr stop_stream = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); if (!stop_stream) { return; } @@ -2203,8 +2187,8 @@ void MessageHelper::SendNaviStopStream(const int32_t app_id, void MessageHelper::SendAudioStartStream(const int32_t app_id, ApplicationManager& app_mngr) { LOG4CXX_AUTO_TRACE(logger_); - smart_objects::SmartObjectSPtr start_stream = - CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + smart_objects::SmartObjectSPtr start_stream = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); if (!start_stream) { return; @@ -2243,8 +2227,8 @@ void MessageHelper::SendAudioStartStream(const int32_t app_id, void MessageHelper::SendAudioStopStream(const int32_t app_id, ApplicationManager& app_mngr) { LOG4CXX_AUTO_TRACE(logger_); - smart_objects::SmartObjectSPtr stop_stream = - CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + smart_objects::SmartObjectSPtr stop_stream = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); if (!stop_stream) { return; @@ -2293,8 +2277,8 @@ void MessageHelper::SendOnDataStreaming( bool MessageHelper::SendStopAudioPathThru(ApplicationManager& app_mngr) { LOG4CXX_INFO(logger_, "MessageHelper::SendAudioStopAudioPathThru"); - smart_objects::SmartObjectSPtr result = - CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + smart_objects::SmartObjectSPtr result = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); (*result)[strings::params][strings::function_id] = hmi_apis::FunctionID::UI_EndAudioPassThru; @@ -2305,8 +2289,8 @@ bool MessageHelper::SendStopAudioPathThru(ApplicationManager& app_mngr) { bool MessageHelper::SendUnsubscribedWayPoints(ApplicationManager& app_mngr) { LOG4CXX_INFO(logger_, "MessageHelper::SendUnsubscribedWayPoints"); - smart_objects::SmartObjectSPtr result = - CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + smart_objects::SmartObjectSPtr result = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); (*result)[strings::params][strings::function_id] = hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints; @@ -2665,8 +2649,8 @@ void MessageHelper::SendOnStatusUpdate(const std::string& status, } void MessageHelper::SendGetSystemInfoRequest(ApplicationManager& app_mngr) { - smart_objects::SmartObjectSPtr message = - CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + smart_objects::SmartObjectSPtr message = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); if (!message) { return; } -- cgit v1.2.1 From 0127696c46a24ade4e76e32807175e0cfa5103a0 Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Fri, 27 Oct 2017 11:25:12 +0300 Subject: Changes CommandHolderImpl usage and removes odd interface Also typedefs used, typo in description fixed, minor code changes --- .../application_manager/src/application_manager_impl.cc | 9 +++++---- .../application_manager/src/command_holder_impl.cc | 12 +++--------- 2 files changed, 8 insertions(+), 13 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 113b6e826a..4f9cccb4d9 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -53,6 +53,7 @@ #include "application_manager/helpers/application_helper.h" #include "protocol_handler/protocol_handler.h" #include "hmi_message_handler/hmi_message_handler.h" +#include "application_manager/command_holder_impl.h" #include "connection_handler/connection_handler_impl.h" #include "formatters/formatter_json_rpc.h" #include "formatters/CFormatterJsonSDLRPCv2.h" @@ -195,7 +196,7 @@ ApplicationManagerImpl::ApplicationManagerImpl( const uint32_t timeout_ms = 10000u; clearing_timer->Start(timeout_ms, timer::kSingleShot); timer_pool_.push_back(clearing_timer); - commands_holder_.SetCommandsProcessor(this); + commands_holder_.reset(new CommandHolderImpl(*this)); } ApplicationManagerImpl::~ApplicationManagerImpl() { @@ -390,7 +391,7 @@ void ApplicationManagerImpl::OnApplicationRegistered(ApplicationSharedPtr app) { } void ApplicationManagerImpl::OnApplicationSwitched(ApplicationSharedPtr app) { - commands_holder_.Release(app->policy_app_id()); + commands_holder_->Release(app->policy_app_id()); } bool ApplicationManagerImpl::IsAppTypeExistsInFullOrLimited( @@ -1100,7 +1101,7 @@ void ApplicationManagerImpl::OnDeviceSwitchFinish( app_it != reregister_wait_list_.end(); ++app_it) { auto app = *app_it; - commands_holder_.Drop(app->policy_app_id()); + commands_holder_->Drop(app->policy_app_id()); UnregisterApplication(app->app_id(), mobile_apis::Result::INVALID_ENUM, is_resuming, @@ -2051,7 +2052,7 @@ bool ApplicationManagerImpl::ManageHMICommand( auto app = application(command->connection_key()); if (app && IsAppInReconnectMode(app->policy_app_id())) { - commands_holder_.Hold(app->policy_app_id(), message); + commands_holder_->Hold(app->policy_app_id(), message); return true; } diff --git a/src/components/application_manager/src/command_holder_impl.cc b/src/components/application_manager/src/command_holder_impl.cc index 3bb3e8c190..db3e1648ef 100644 --- a/src/components/application_manager/src/command_holder_impl.cc +++ b/src/components/application_manager/src/command_holder_impl.cc @@ -34,13 +34,8 @@ #include "application_manager/application_manager.h" namespace application_manager { -CommandHolderImpl::CommandHolderImpl() - : app_manager_(nullptr), commands_lock_() {} - -void CommandHolderImpl::SetCommandsProcessor(ApplicationManager* app_manager) { - DCHECK_OR_RETURN_VOID(app_manager); - app_manager_ = app_manager; -} +CommandHolderImpl::CommandHolderImpl(ApplicationManager& app_manager) + : app_manager_(app_manager) {} void CommandHolderImpl::Hold( const std::string& policy_app_id, @@ -56,8 +51,7 @@ void CommandHolderImpl::Release(const std::string& policy_app_id) { return; } for (auto cmd : app_commands->second) { - DCHECK_OR_RETURN_VOID(app_manager_); - app_manager_->ManageHMICommand(cmd); + app_manager_.ManageHMICommand(cmd); } app_commands_.erase(app_commands); -- cgit v1.2.1 From 02fd128d2790f68b1c8acb6e2115e6984ccc0c8b Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Fri, 27 Oct 2017 15:50:10 +0300 Subject: Fixes deadlock on resume data saving during transport switch Issue was happening due to - resume data restoring thread was acquiring app subscription lock and then application list lock - transport switching thread was acquiring application lock and was saving resume data and trying to get subscription lock Now after filtering switching application from application list its lock will be released --- .../application_manager/src/application_manager_impl.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 4f9cccb4d9..aea66aa27c 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1074,12 +1074,14 @@ void ApplicationManagerImpl::OnDeviceSwitchingStart( const std::string& device_uid) { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(reregister_wait_list_lock_); - auto apps_data_accessor = applications(); + { + auto apps_data_accessor = applications(); - std::copy_if(apps_data_accessor.GetData().begin(), - apps_data_accessor.GetData().end(), - std::back_inserter(reregister_wait_list_), - std::bind1st(std::ptr_fun(&device_id_comparator), device_uid)); + std::copy_if(apps_data_accessor.GetData().begin(), + apps_data_accessor.GetData().end(), + std::back_inserter(reregister_wait_list_), + std::bind1st(std::ptr_fun(&device_id_comparator), device_uid)); + } for (auto i = reregister_wait_list_.begin(); reregister_wait_list_.end() != i; ++i) { -- cgit v1.2.1 From f02cbd971c5a5f839aecf4ec894aeea61543e42b Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Fri, 27 Oct 2017 16:19:31 +0300 Subject: Renames interfaces for consistency --- src/components/application_manager/src/application_manager_impl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index aea66aa27c..4afaefb781 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1091,7 +1091,7 @@ void ApplicationManagerImpl::OnDeviceSwitchingStart( } } -void ApplicationManagerImpl::OnDeviceSwitchFinish( +void ApplicationManagerImpl::OnDeviceSwitchingFinish( const std::string& device_uid) { LOG4CXX_AUTO_TRACE(logger_); UNUSED(device_uid); -- cgit v1.2.1 From 610c86665a3f1b42fbce799a5296f32b0ca1782d Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Fri, 27 Oct 2017 16:37:36 +0300 Subject: Fixes typos, comments --- src/components/application_manager/src/helpers/application_helper.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/helpers/application_helper.cc b/src/components/application_manager/src/helpers/application_helper.cc index ffe97709a8..4b4816b273 100644 --- a/src/components/application_manager/src/helpers/application_helper.cc +++ b/src/components/application_manager/src/helpers/application_helper.cc @@ -24,8 +24,7 @@ void RecallCommands(ApplicationSharedPtr app, ApplicationManager& app_manager) { } } -void RecallSubmenues(ApplicationSharedPtr app, - ApplicationManager& app_manager) { +void RecallSubmenus(ApplicationSharedPtr app, ApplicationManager& app_manager) { SubMenuMap smap = app->sub_menu_map().GetData(); for (auto smenu : smap) { @@ -136,7 +135,7 @@ void RecallApplicationData(ApplicationSharedPtr app, RecallWayPoints(app, app_manager); RecallCommands(app, app_manager); - RecallSubmenues(app, app_manager); + RecallSubmenus(app, app_manager); RecallChoiceSets(app, app_manager); RecallGlobalProperties(app, app_manager); RecallButtonSubscriptions(app, app_manager); -- cgit v1.2.1 From d7c78d993921e95af420be5eeffa4199299d1441 Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Fri, 27 Oct 2017 17:02:01 +0300 Subject: Renames interfaces according to people desire --- src/components/application_manager/src/application_manager_impl.cc | 6 +++--- src/components/application_manager/src/command_holder_impl.cc | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 4afaefb781..abb2d9ea70 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -391,7 +391,7 @@ void ApplicationManagerImpl::OnApplicationRegistered(ApplicationSharedPtr app) { } void ApplicationManagerImpl::OnApplicationSwitched(ApplicationSharedPtr app) { - commands_holder_->Release(app->policy_app_id()); + commands_holder_->Resume(app->policy_app_id()); } bool ApplicationManagerImpl::IsAppTypeExistsInFullOrLimited( @@ -1103,7 +1103,7 @@ void ApplicationManagerImpl::OnDeviceSwitchingFinish( app_it != reregister_wait_list_.end(); ++app_it) { auto app = *app_it; - commands_holder_->Drop(app->policy_app_id()); + commands_holder_->Clear(app->policy_app_id()); UnregisterApplication(app->app_id(), mobile_apis::Result::INVALID_ENUM, is_resuming, @@ -2054,7 +2054,7 @@ bool ApplicationManagerImpl::ManageHMICommand( auto app = application(command->connection_key()); if (app && IsAppInReconnectMode(app->policy_app_id())) { - commands_holder_->Hold(app->policy_app_id(), message); + commands_holder_->Suspend(app->policy_app_id(), message); return true; } diff --git a/src/components/application_manager/src/command_holder_impl.cc b/src/components/application_manager/src/command_holder_impl.cc index db3e1648ef..dfb100c802 100644 --- a/src/components/application_manager/src/command_holder_impl.cc +++ b/src/components/application_manager/src/command_holder_impl.cc @@ -37,14 +37,14 @@ namespace application_manager { CommandHolderImpl::CommandHolderImpl(ApplicationManager& app_manager) : app_manager_(app_manager) {} -void CommandHolderImpl::Hold( +void CommandHolderImpl::Suspend( const std::string& policy_app_id, utils::SharedPtr command) { sync_primitives::AutoLock lock(commands_lock_); app_commands_[policy_app_id].push_back(command); } -void CommandHolderImpl::Release(const std::string& policy_app_id) { +void CommandHolderImpl::Resume(const std::string& policy_app_id) { sync_primitives::AutoLock lock(commands_lock_); auto app_commands = app_commands_.find(policy_app_id); if (app_commands_.end() == app_commands) { @@ -57,7 +57,7 @@ void CommandHolderImpl::Release(const std::string& policy_app_id) { app_commands_.erase(app_commands); } -void CommandHolderImpl::Drop(const std::string& policy_app_id) { +void CommandHolderImpl::Clear(const std::string& policy_app_id) { sync_primitives::AutoLock lock(commands_lock_); auto app_commands = app_commands_.find(policy_app_id); if (app_commands_.end() == app_commands) { -- cgit v1.2.1 From f748016ac120963bee90945b6bf256d2de02ece4 Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Mon, 13 Nov 2017 12:43:10 +0200 Subject: Fixes resume issue for application on switching transport In case app has been just registrered in previous session and didn't sent any data to resume later and then re-registers over new transport due to switch there is nothing to resume so RAI result should be SUCCESS --- .../src/commands/mobile/register_app_interface_request.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index 6088e46e06..4dd14e2075 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc @@ -674,7 +674,13 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( LOG4CXX_DEBUG(logger_, "Application has been switched from another transport."); - if (!resumption || mobile_apis::Result::RESUME_FAILED == result_code) { + if (hash_id.empty() && resumer.CheckApplicationHash(application, hash_id)) { + LOG4CXX_INFO(logger_, + "Application does not have hashID saved and neither " + "provided it with RAI. Nothing to resume."); + result_code = mobile_apis::Result::SUCCESS; + } else if (!resumption || + mobile_apis::Result::RESUME_FAILED == result_code) { application_manager::RecallApplicationData(application, application_manager_); resumer.RemoveApplicationFromSaved(application); -- cgit v1.2.1 From 0f7975968a2be51fa4da7be4cbb4da0ee1d637c7 Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Wed, 15 Nov 2017 15:53:19 +0200 Subject: Fixes handling of way points un/subscription for transport switch case In case app_id is used for way points subscription it being invalidated on transport switch and SDL can't unsubscribe same application after switch is done. --- .../src/application_manager_impl.cc | 37 ++++++++++++++++++++++ .../mobile/subscribe_way_points_request.cc | 6 ++-- .../mobile/unsubscribe_way_points_request.cc | 4 +-- .../src/helpers/application_helper.cc | 2 +- .../src/resumption/resume_ctrl_impl.cc | 2 +- .../src/resumption/resumption_data_db.cc | 3 +- .../src/resumption/resumption_data_json.cc | 2 +- 7 files changed, 47 insertions(+), 9 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index abb2d9ea70..03e9a7d95e 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -4146,9 +4146,46 @@ void ApplicationManagerImpl::UnsubscribeAppFromWayPoints( subscribed_way_points_apps_list_.erase(app_id); } +bool ApplicationManagerImpl::IsAppSubscribedForWayPoints( + ApplicationSharedPtr app) const { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_); + LOG4CXX_DEBUG(logger_, + "There are applications subscribed: " + << subscribed_way_points_apps_list_.size()); + if (subscribed_way_points_apps_list_.find(app) == + subscribed_way_points_apps_list_.end()) { + return false; + } + return true; +} + +void ApplicationManagerImpl::SubscribeAppForWayPoints( + ApplicationSharedPtr app) { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_); + subscribed_way_points_apps_list_.insert(app); + LOG4CXX_DEBUG(logger_, + "There are applications subscribed: " + << subscribed_way_points_apps_list_.size()); +} + +void ApplicationManagerImpl::UnsubscribeAppFromWayPoints( + ApplicationSharedPtr app) { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_); + subscribed_way_points_apps_list_.erase(app); + LOG4CXX_DEBUG(logger_, + "There are applications subscribed: " + << subscribed_way_points_apps_list_.size()); +} + bool ApplicationManagerImpl::IsAnyAppSubscribedForWayPoints() const { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_); + LOG4CXX_DEBUG(logger_, + "There are applications subscribed: " + << subscribed_way_points_apps_list_.size()); return !subscribed_way_points_apps_list_.empty(); } diff --git a/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc index 965741edf7..8195697dfc 100644 --- a/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc +++ b/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc @@ -25,13 +25,13 @@ void SubscribeWayPointsRequest::Run() { return; } - if (application_manager_.IsAppSubscribedForWayPoints(app->app_id())) { + if (application_manager_.IsAppSubscribedForWayPoints(app)) { SendResponse(false, mobile_apis::Result::IGNORED); return; } if (application_manager_.IsAnyAppSubscribedForWayPoints()) { - application_manager_.SubscribeAppForWayPoints(app->app_id()); + application_manager_.SubscribeAppForWayPoints(app); SendResponse(true, mobile_apis::Result::SUCCESS); return; } @@ -57,7 +57,7 @@ void SubscribeWayPointsRequest::on_event(const event_engine::Event& event) { const bool result = PrepareResultForMobileResponse( result_code, HmiInterfaces::HMI_INTERFACE_Navigation); if (result) { - application_manager_.SubscribeAppForWayPoints(app->app_id()); + application_manager_.SubscribeAppForWayPoints(app); } SendResponse(result, MessageHelper::HMIToMobileResult(result_code), diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc index 88ed396250..dc3404c022 100644 --- a/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc +++ b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc @@ -25,7 +25,7 @@ void UnSubscribeWayPointsRequest::Run() { return; } - if (!application_manager_.IsAppSubscribedForWayPoints(app->app_id())) { + if (!application_manager_.IsAppSubscribedForWayPoints(app)) { SendResponse(false, mobile_apis::Result::IGNORED); return; } @@ -51,7 +51,7 @@ void UnSubscribeWayPointsRequest::on_event(const event_engine::Event& event) { const bool result = PrepareResultForMobileResponse( result_code, HmiInterfaces::HMI_INTERFACE_Navigation); if (result) { - application_manager_.UnsubscribeAppFromWayPoints(app->app_id()); + application_manager_.UnsubscribeAppFromWayPoints(app); } SendResponse(result, MessageHelper::HMIToMobileResult(result_code), diff --git a/src/components/application_manager/src/helpers/application_helper.cc b/src/components/application_manager/src/helpers/application_helper.cc index 4b4816b273..2007b97434 100644 --- a/src/components/application_manager/src/helpers/application_helper.cc +++ b/src/components/application_manager/src/helpers/application_helper.cc @@ -9,7 +9,7 @@ namespace { using namespace application_manager; void RecallWayPoints(ApplicationSharedPtr app, ApplicationManager& app_manager) { - app_manager.UnsubscribeAppFromWayPoints(app->app_id()); + app_manager.UnsubscribeAppFromWayPoints(app); if (!app_manager.IsAnyAppSubscribedForWayPoints()) { MessageHelper::SendUnsubscribedWayPoints(app_manager); } 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 435e621169..72f2246e7c 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc @@ -597,7 +597,7 @@ void ResumeCtrlImpl::AddWayPointsSubscription( const smart_objects::SmartObject& subscribed_for_way_points_so = saved_app[strings::subscribed_for_way_points]; if (true == subscribed_for_way_points_so.asBool()) { - application_manager_.SubscribeAppForWayPoints(application->app_id()); + application_manager_.SubscribeAppForWayPoints(application); } } } 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 23fecb7624..bd439e05bc 100644 --- a/src/components/application_manager/src/resumption/resumption_data_db.cc +++ b/src/components/application_manager/src/resumption/resumption_data_db.cc @@ -2584,7 +2584,7 @@ bool ResumptionDataDB::InsertApplicationData( const mobile_apis::HMILevel::eType hmi_level = application.m_hmi_level; bool is_media_application = application.m_is_media_application; bool is_subscribed_for_way_points = - application_manager_.IsAppSubscribedForWayPoints(connection_key); + application_manager_.IsAppSubscribedForWayPoints(application.app_ptr); if (!query.Prepare(kInsertApplication)) { LOG4CXX_WARN(logger_, @@ -2810,6 +2810,7 @@ ApplicationParams::ApplicationParams(app_mngr::ApplicationSharedPtr application) m_hmi_app_id = application->hmi_app_id(); m_hmi_level = application->hmi_level(); m_is_media_application = application->IsAudioApplication(); + app_ptr = application; } } 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 203c4889c5..5bbf36dfdd 100644 --- a/src/components/application_manager/src/resumption/resumption_data_json.cc +++ b/src/components/application_manager/src/resumption/resumption_data_json.cc @@ -66,7 +66,7 @@ void ResumptionDataJson::SaveApplication( const std::string device_mac = application->mac_address(); const mobile_apis::HMILevel::eType hmi_level = application->hmi_level(); const bool is_subscribed_for_way_points = - application_manager_.IsAppSubscribedForWayPoints(application->app_id()); + application_manager_.IsAppSubscribedForWayPoints(application); sync_primitives::AutoLock autolock(resumption_lock_); Json::Value tmp; -- cgit v1.2.1 From 1d2fa24c81b8910ef533fbedf777f627e220e10e Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Wed, 15 Nov 2017 16:31:00 +0200 Subject: Fixes deletion of commands and submenus on failed resume While adding data from AddCommand/AddSubMenun msg_params are added itself so we have directly address internal fields w/o accessing 'msg_params' --- .../application_manager/src/message_helper/message_helper.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/components/application_manager/src') 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 e02291224a..34a35e5929 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -408,7 +408,7 @@ void MessageHelper::SendDeleteCommandRequest(smart_objects::SmartObject* cmd, using namespace smart_objects; SmartObject msg_params = SmartObject(smart_objects::SmartType_Map); - msg_params[strings::cmd_id] = (*cmd)[strings::msg_params][strings::cmd_id]; + msg_params[strings::cmd_id] = (*cmd)[strings::cmd_id]; msg_params[strings::app_id] = application->app_id(); if ((*cmd).keyExists(strings::menu_params)) { @@ -452,7 +452,7 @@ void MessageHelper::SendDeleteSubmenuRequest(smart_objects::SmartObject* cmd, SmartObject msg_params = SmartObject(smart_objects::SmartType_Map); - msg_params[strings::menu_id] = (*cmd)[strings::msg_params][strings::menu_id]; + msg_params[strings::menu_id] = (*cmd)[strings::menu_id]; msg_params[strings::app_id] = application->app_id(); SmartObjectSPtr message = CreateMessageForHMI( @@ -476,7 +476,7 @@ void MessageHelper::SendDeleteSubmenuRequest(smart_objects::SmartObject* cmd, continue; } - if ((*cmd)[strings::msg_params][strings::menu_id].asInt() == + if ((*cmd)[strings::menu_id].asInt() == (*it->second)[strings::menu_params][hmi_request::parent_id].asInt()) { SmartObject msg_params = SmartObject(smart_objects::SmartType_Map); msg_params[strings::cmd_id] = (*it->second)[strings::cmd_id].asInt(); -- cgit v1.2.1 From ec8b48590b89c2ba1dced1e33ad8565970829a5a Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Wed, 22 Nov 2017 15:49:42 +0200 Subject: Fixes RPCs holding for applications being switched --- .../src/application_manager_impl.cc | 40 ++++++++--- .../application_manager/src/command_holder_impl.cc | 84 +++++++++++++++++++--- 2 files changed, 104 insertions(+), 20 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 03e9a7d95e..f9fa396d80 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -391,7 +391,9 @@ void ApplicationManagerImpl::OnApplicationRegistered(ApplicationSharedPtr app) { } void ApplicationManagerImpl::OnApplicationSwitched(ApplicationSharedPtr app) { - commands_holder_->Resume(app->policy_app_id()); + LOG4CXX_AUTO_TRACE(logger_); + commands_holder_->Resume(app, CommandHolder::CommandType::kMobileCommand); + commands_holder_->Resume(app, CommandHolder::CommandType::kHmiCommand); } bool ApplicationManagerImpl::IsAppTypeExistsInFullOrLimited( @@ -1102,8 +1104,7 @@ void ApplicationManagerImpl::OnDeviceSwitchingFinish( for (auto app_it = reregister_wait_list_.begin(); app_it != reregister_wait_list_.end(); ++app_it) { - auto app = *app_it; - commands_holder_->Clear(app->policy_app_id()); + auto app = *app_it; UnregisterApplication(app->app_id(), mobile_apis::Result::INVALID_ENUM, is_resuming, @@ -1823,6 +1824,17 @@ bool ApplicationManagerImpl::ManageMobileCommand( return false; } + const uint32_t connection_key = static_cast( + (*message)[strings::params][strings::connection_key].asUInt()); + + auto app_ptr = application(connection_key); + if (app_ptr && IsAppInReconnectMode(app_ptr->policy_app_id())) { + commands_holder_->Suspend(app_ptr, + CommandHolder::CommandType::kMobileCommand, + message); + return true; + } + mobile_apis::FunctionID::eType function_id = static_cast( (*message)[strings::params][strings::function_id].asInt()); @@ -1833,9 +1845,6 @@ bool ApplicationManagerImpl::ManageMobileCommand( ? (*message)[strings::params][strings::correlation_id].asUInt() : 0; - uint32_t connection_key = - (*message)[strings::params][strings::connection_key].asUInt(); - int32_t protocol_type = (*message)[strings::params][strings::protocol_type].asUInt(); @@ -2052,10 +2061,18 @@ bool ApplicationManagerImpl::ManageHMICommand( return false; } - auto app = application(command->connection_key()); - if (app && IsAppInReconnectMode(app->policy_app_id())) { - commands_holder_->Suspend(app->policy_app_id(), message); - return true; + if ((*message).keyExists(strings::msg_params) && + (*message)[strings::msg_params].keyExists(strings::app_id)) { + const auto connection_key = + (*message)[strings::msg_params][strings::app_id].asUInt(); + + auto app = application(static_cast(connection_key)); + if (app && IsAppInReconnectMode(app->policy_app_id())) { + commands_holder_->Suspend(app, + CommandHolder::CommandType::kHmiCommand, + message); + return true; + } } int32_t message_type = @@ -3123,6 +3140,9 @@ void ApplicationManagerImpl::UnregisterApplication( SendUpdateAppList(); } } + + commands_holder_->Clear(app_to_remove); + if (audio_pass_thru_active_) { // May be better to put this code in MessageHelper? EndAudioPassThrough(); diff --git a/src/components/application_manager/src/command_holder_impl.cc b/src/components/application_manager/src/command_holder_impl.cc index dfb100c802..d5700f512e 100644 --- a/src/components/application_manager/src/command_holder_impl.cc +++ b/src/components/application_manager/src/command_holder_impl.cc @@ -32,38 +32,102 @@ #include "application_manager/command_holder_impl.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/command.h" namespace application_manager { +CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") + CommandHolderImpl::CommandHolderImpl(ApplicationManager& app_manager) : app_manager_(app_manager) {} void CommandHolderImpl::Suspend( - const std::string& policy_app_id, + ApplicationSharedPtr application, + CommandType type, utils::SharedPtr command) { + LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_DEBUG(logger_, "Suspending command(s) for application: " + << application->policy_app_id()); + sync_primitives::AutoLock lock(commands_lock_); + + if (CommandType::kHmiCommand == type) { + app_hmi_commands_[application].push_back(command); + LOG4CXX_DEBUG(logger_, "Suspended HMI command(s): " + << app_hmi_commands_.size()); + } else { + app_mobile_commands_[application].push_back(command); + LOG4CXX_DEBUG(logger_, "Suspended mobile command(s): " + << app_hmi_commands_.size()); + } +} + +void CommandHolderImpl::Resume(ApplicationSharedPtr application, + CommandType type) { + LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_DEBUG(logger_, "Resuming command(s) for application: " + << application->policy_app_id()); + if (CommandType::kHmiCommand == type) { + ResumeHmiCommand(application); + } else { + ResumeMobileCommand(application); + } +} + +void CommandHolderImpl::Clear(ApplicationSharedPtr application) { + LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_DEBUG(logger_, "Clearing command(s) for application: " + << application->policy_app_id()); sync_primitives::AutoLock lock(commands_lock_); - app_commands_[policy_app_id].push_back(command); + auto app_hmi_commands = app_hmi_commands_.find(application); + if (app_hmi_commands_.end() != app_hmi_commands) { + LOG4CXX_DEBUG(logger_, "Clearing HMI command(s): " + << app_hmi_commands->second.size()); + app_hmi_commands_.erase(app_hmi_commands); + } + + auto app_mobile_commands = app_mobile_commands_.find(application); + if (app_mobile_commands_.end() != app_mobile_commands) { + LOG4CXX_DEBUG(logger_, "Clearing mobile command(s): " + << app_mobile_commands->second.size()); + app_mobile_commands_.erase(app_mobile_commands); + } } -void CommandHolderImpl::Resume(const std::string& policy_app_id) { +void CommandHolderImpl::ResumeHmiCommand(ApplicationSharedPtr application) { sync_primitives::AutoLock lock(commands_lock_); - auto app_commands = app_commands_.find(policy_app_id); - if (app_commands_.end() == app_commands) { + auto app_commands = app_hmi_commands_.find(application); + if (app_hmi_commands_.end() == app_commands) { return; } + + LOG4CXX_DEBUG(logger_, "Resuming HMI command(s): " + << app_hmi_commands_.size()); + for (auto cmd : app_commands->second) { + (*cmd)[strings::msg_params][strings::app_id] = application->hmi_app_id(); app_manager_.ManageHMICommand(cmd); } - app_commands_.erase(app_commands); + app_hmi_commands_.erase(app_commands); } -void CommandHolderImpl::Clear(const std::string& policy_app_id) { +void CommandHolderImpl::ResumeMobileCommand(ApplicationSharedPtr application) { sync_primitives::AutoLock lock(commands_lock_); - auto app_commands = app_commands_.find(policy_app_id); - if (app_commands_.end() == app_commands) { + auto app_commands = app_mobile_commands_.find(application); + if (app_mobile_commands_.end() == app_commands) { return; } - app_commands_.erase(app_commands); + LOG4CXX_DEBUG(logger_, "Resuming mobile command(s): " + << app_mobile_commands_.size()); + + for (auto cmd : app_commands->second) { + (*cmd)[strings::params][strings::connection_key] = + application->app_id(); + app_manager_.ManageMobileCommand( + cmd, + commands::Command::CommandOrigin::ORIGIN_MOBILE); + } + + app_mobile_commands_.erase(app_commands); } } // application_manager -- cgit v1.2.1 From ee1d2d7677a7d94da43cc8b1e047bdd816e5fd83 Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Wed, 29 Nov 2017 18:33:59 +0200 Subject: Changes iAP2 Bluetooth to USB switching flow These changes update switching flow so now instead of automatic switching start in case of same UUID is detected SDL will wait for external signal from the system to start this flow. Also due to UUID is reliable only while device remains connected (at least on certain systems) SDL now uses Bluetooth MAC and USB serial to manage devices and UUID is used only for detection of devices able to switch their transports. Currently only iAP2 Bluetooth to USB support is implemented. --- .../application_manager/src/application_impl.cc | 4 +- .../src/application_manager_impl.cc | 46 ++++++++++++---- .../mobile/register_app_interface_request.cc | 62 +++++++++++++--------- .../src/policies/policy_handler.cc | 7 +++ 4 files changed, 84 insertions(+), 35 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 8af4c97543..fcdbc25a3e 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -79,12 +79,14 @@ namespace application_manager { void SwitchApplicationParameters(ApplicationSharedPtr app, const uint32_t app_id, - const uint32_t device_id) { + const size_t device_id, + const std::string& mac_address) { utils::SharedPtr application = ApplicationSharedPtr::dynamic_pointer_cast(app); DCHECK_OR_RETURN_VOID(application); application->app_id_ = app_id; application->device_id_ = device_id; + application->mac_address_ = mac_address; } ApplicationImpl::ApplicationImpl( diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index f9fa396d80..b4cb692740 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1073,18 +1073,25 @@ void ApplicationManagerImpl::RemoveDevice( } void ApplicationManagerImpl::OnDeviceSwitchingStart( - const std::string& device_uid) { + const connection_handler::Device& device_from, + const connection_handler::Device& device_to) { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(reregister_wait_list_lock_); { auto apps_data_accessor = applications(); - std::copy_if(apps_data_accessor.GetData().begin(), + std::copy_if( + apps_data_accessor.GetData().begin(), apps_data_accessor.GetData().end(), std::back_inserter(reregister_wait_list_), - std::bind1st(std::ptr_fun(&device_id_comparator), device_uid)); + std::bind1st(std::ptr_fun(&device_id_comparator), + device_from.mac_address())); } + { + // During sending of UpdateDeviceList this lock is acquired also so making + // it scoped + sync_primitives::AutoLock lock(reregister_wait_list_lock_); for (auto i = reregister_wait_list_.begin(); reregister_wait_list_.end() != i; ++i) { auto app = *i; @@ -1093,6 +1100,28 @@ void ApplicationManagerImpl::OnDeviceSwitchingStart( } } + policy_handler_->OnDeviceSwitching(device_from.mac_address(), + device_to.mac_address()); + + connection_handler::DeviceMap device_list; + device_list.insert(std::make_pair(device_to.device_handle(), device_to)); + + smart_objects::SmartObjectSPtr msg_params = + MessageHelper::CreateDeviceListSO(device_list, GetPolicyHandler(), *this); + + auto update_list = utils::MakeShared(); + smart_objects::SmartObject& so_to_send = *update_list; + so_to_send[jhs::S_PARAMS][jhs::S_FUNCTION_ID] = + hmi_apis::FunctionID::BasicCommunication_UpdateDeviceList; + so_to_send[jhs::S_PARAMS][jhs::S_MESSAGE_TYPE] = + hmi_apis::messageType::request; + so_to_send[jhs::S_PARAMS][jhs::S_PROTOCOL_VERSION] = 3; + so_to_send[jhs::S_PARAMS][jhs::S_PROTOCOL_TYPE] = 1; + so_to_send[jhs::S_PARAMS][jhs::S_CORRELATION_ID] = GetNextHMICorrelationID(); + so_to_send[jhs::S_MSG_PARAMS] = *msg_params; + ManageHMICommand(update_list); +} + void ApplicationManagerImpl::OnDeviceSwitchingFinish( const std::string& device_uid) { LOG4CXX_AUTO_TRACE(logger_); @@ -1115,8 +1144,9 @@ void ApplicationManagerImpl::OnDeviceSwitchingFinish( void ApplicationManagerImpl::SwitchApplication(ApplicationSharedPtr app, const uint32_t connection_key, - const uint32_t device_id) { - LOG4CXX_AUTO_TRACE(logger_); + const size_t device_id, + const std::string& mac_address) { + LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(applications_list_lock_); DCHECK_OR_RETURN_VOID(1 == applications_.erase(app)); @@ -1125,7 +1155,7 @@ void ApplicationManagerImpl::SwitchApplication(ApplicationSharedPtr app, << ". Changing device id to " << device_id); - SwitchApplicationParameters(app, connection_key, device_id); + SwitchApplicationParameters(app, connection_key, device_id, mac_address); // Normally this is done during registration, however since switched apps are // not being registered again need to set protocol version on session. @@ -4056,11 +4086,9 @@ void ApplicationManagerImpl::ProcessReconnection( connection_handler().get_session_observer().GetDataOnDeviceID( new_device_id, NULL, NULL, &device_mac, &connection_type); - DCHECK_OR_RETURN_VOID(application->mac_address() == device_mac); - EraseAppFromReconnectionList(application); - SwitchApplication(application, connection_key, new_device_id); + SwitchApplication(application, connection_key, new_device_id, device_mac); // Update connection type for existed device. GetPolicyHandler().AddDevice(device_mac, connection_type); diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index 4dd14e2075..fda4d09de2 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc @@ -370,7 +370,7 @@ void RegisterAppInterfaceRequest::Run() { GetPolicyHandler().SetDeviceInfo(device_mac, device_info); - SendRegisterAppInterfaceResponseToMobile(AppicationType::kNewApplication); + SendRegisterAppInterfaceResponseToMobile(ApplicationType::kNewApplication); smart_objects::SmartObjectSPtr so = GetLockScreenIconUrlNotification(connection_key(), application); application_manager_.ManageMobileCommand(so, commands::Command::ORIGIN_SDL); @@ -510,7 +510,7 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params, } void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( - AppicationType app_type) { + ApplicationType app_type) { LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObject response_params(smart_objects::SmartType_Map); @@ -640,6 +640,28 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( response_params[strings::system_software_version] = ccpu_version; } + if (ApplicationType::kSwitchedApplicationWrongHashId == app_type) { + LOG4CXX_DEBUG(logger_, + "Application has been switched from another transport, " + "but doesn't have correct hashID."); + + application_manager::RecallApplicationData(application, + application_manager_); + + SendResponse(true, mobile_apis::Result::RESUME_FAILED, NULL, + &response_params); + return; + } + + if (ApplicationType::kSwitchedApplicationHashOk == app_type) { + LOG4CXX_DEBUG(logger_, + "Application has been switched from another transport " + "and has correct hashID."); + SendResponse(true, mobile_apis::Result::SUCCESS, NULL, + &response_params); + return; + } + bool resumption = (*message_)[strings::msg_params].keyExists(strings::hash_id); @@ -670,27 +692,6 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( result_code = result_checking_app_hmi_type_; } - if (AppicationType::kSwitchedApplication == app_type) { - LOG4CXX_DEBUG(logger_, - "Application has been switched from another transport."); - - if (hash_id.empty() && resumer.CheckApplicationHash(application, hash_id)) { - LOG4CXX_INFO(logger_, - "Application does not have hashID saved and neither " - "provided it with RAI. Nothing to resume."); - result_code = mobile_apis::Result::SUCCESS; - } else if (!resumption || - mobile_apis::Result::RESUME_FAILED == result_code) { - application_manager::RecallApplicationData(application, - application_manager_); - resumer.RemoveApplicationFromSaved(application); - result_code = mobile_apis::Result::RESUME_FAILED; - } - - SendResponse(true, result_code, add_info.c_str(), &response_params); - return; - } - // in case application exist in resumption we need to send resumeVrgrammars if (false == resumption) { resumption = resumer.IsApplicationSaved(application->policy_app_id(), @@ -1465,9 +1466,20 @@ bool RegisterAppInterfaceRequest::IsApplicationSwitched() { } LOG4CXX_DEBUG(logger_, "Application is found in reconnection list."); + + auto app_type = ApplicationType::kSwitchedApplicationWrongHashId; + if ((*message_)[strings::msg_params].keyExists(strings::hash_id)) { + const auto hash_id = + (*message_)[strings::msg_params][strings::hash_id].asString(); + + auto& resume_ctrl = application_manager_.resume_controller(); + if (resume_ctrl.CheckApplicationHash(app, hash_id)) { + app_type = ApplicationType::kSwitchedApplicationHashOk; + } + } + application_manager_.ProcessReconnection(app, connection_key()); - SendRegisterAppInterfaceResponseToMobile( - AppicationType::kSwitchedApplication); + SendRegisterAppInterfaceResponseToMobile(app_type); application_manager_.SendHMIStatusNotification(app); diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 570aee180c..e5bf7a2a7c 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -852,6 +852,13 @@ uint32_t PolicyHandler::ChooseRandomAppForPolicyUpdate( return 0; } +void PolicyHandler::OnDeviceSwitching(const std::string& device_id_from, + const std::string& device_id_to) { + LOG4CXX_AUTO_TRACE(logger_); + POLICY_LIB_CHECK_VOID(); + policy_manager_->OnDeviceSwitching(device_id_from, device_id_to); +} + void PolicyHandler::OnGetStatusUpdate(const uint32_t correlation_id) { LOG4CXX_AUTO_TRACE(logger_); POLICY_LIB_CHECK_VOID(); -- cgit v1.2.1 From 2c207377259ad01c7f231533ba7189008d03a898 Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Thu, 30 Nov 2017 09:43:44 +0200 Subject: Updates mocks and unit tests after prior commit Fixes mock classes interfaces, unit tests and build after changes related to making iAP2 switching triggered externally and using of Bluetooth MAC/USB serial instead of UUID for internal device management. --- .../src/application_manager_impl.cc | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index b4cb692740..b6ffc80ed4 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1076,29 +1076,28 @@ void ApplicationManagerImpl::OnDeviceSwitchingStart( const connection_handler::Device& device_from, const connection_handler::Device& device_to) { LOG4CXX_AUTO_TRACE(logger_); - sync_primitives::AutoLock lock(reregister_wait_list_lock_); { auto apps_data_accessor = applications(); std::copy_if( - apps_data_accessor.GetData().begin(), - apps_data_accessor.GetData().end(), - std::back_inserter(reregister_wait_list_), - std::bind1st(std::ptr_fun(&device_id_comparator), - device_from.mac_address())); + apps_data_accessor.GetData().begin(), + apps_data_accessor.GetData().end(), + std::back_inserter(reregister_wait_list_), + std::bind1st(std::ptr_fun(&device_id_comparator), + device_from.mac_address())); } { // During sending of UpdateDeviceList this lock is acquired also so making // it scoped sync_primitives::AutoLock lock(reregister_wait_list_lock_); - for (auto i = reregister_wait_list_.begin(); reregister_wait_list_.end() != i; - ++i) { - auto app = *i; - request_ctrl_.terminateAppRequests(app->app_id()); - resume_ctrl_->SaveApplication(app); + for (auto i = reregister_wait_list_.begin(); reregister_wait_list_.end() != i; + ++i) { + auto app = *i; + request_ctrl_.terminateAppRequests(app->app_id()); + resume_ctrl_->SaveApplication(app); + } } -} policy_handler_->OnDeviceSwitching(device_from.mac_address(), device_to.mac_address()); @@ -1108,6 +1107,10 @@ void ApplicationManagerImpl::OnDeviceSwitchingStart( smart_objects::SmartObjectSPtr msg_params = MessageHelper::CreateDeviceListSO(device_list, GetPolicyHandler(), *this); + if (!msg_params) { + LOG4CXX_ERROR(logger_, "Can't create UpdateDeviceList notification"); + return; + } auto update_list = utils::MakeShared(); smart_objects::SmartObject& so_to_send = *update_list; -- cgit v1.2.1 From c4e771fb7d402157c5cbb5159c41e0a4553b8492 Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Wed, 6 Dec 2017 10:20:51 +0200 Subject: Fixes coding style --- .../application_manager/src/application_impl.cc | 2 +- .../src/application_manager_impl.cc | 34 ++++++++-------- .../application_manager/src/command_holder_impl.cc | 47 ++++++++++++---------- .../mobile/register_app_interface_request.cc | 45 ++++++++++----------- .../src/policies/policy_handler.cc | 2 +- 5 files changed, 65 insertions(+), 65 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index fcdbc25a3e..eaf097d43f 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -79,7 +79,7 @@ namespace application_manager { void SwitchApplicationParameters(ApplicationSharedPtr app, const uint32_t app_id, - const size_t device_id, + const size_t device_id, const std::string& mac_address) { utils::SharedPtr application = ApplicationSharedPtr::dynamic_pointer_cast(app); diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index b6ffc80ed4..d42d6d91b2 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1079,19 +1079,19 @@ void ApplicationManagerImpl::OnDeviceSwitchingStart( { auto apps_data_accessor = applications(); - std::copy_if( - apps_data_accessor.GetData().begin(), - apps_data_accessor.GetData().end(), - std::back_inserter(reregister_wait_list_), - std::bind1st(std::ptr_fun(&device_id_comparator), - device_from.mac_address())); + std::copy_if(apps_data_accessor.GetData().begin(), + apps_data_accessor.GetData().end(), + std::back_inserter(reregister_wait_list_), + std::bind1st(std::ptr_fun(&device_id_comparator), + device_from.mac_address())); } { // During sending of UpdateDeviceList this lock is acquired also so making // it scoped sync_primitives::AutoLock lock(reregister_wait_list_lock_); - for (auto i = reregister_wait_list_.begin(); reregister_wait_list_.end() != i; + for (auto i = reregister_wait_list_.begin(); + reregister_wait_list_.end() != i; ++i) { auto app = *i; request_ctrl_.terminateAppRequests(app->app_id()); @@ -1101,10 +1101,10 @@ void ApplicationManagerImpl::OnDeviceSwitchingStart( policy_handler_->OnDeviceSwitching(device_from.mac_address(), device_to.mac_address()); - + connection_handler::DeviceMap device_list; device_list.insert(std::make_pair(device_to.device_handle(), device_to)); - + smart_objects::SmartObjectSPtr msg_params = MessageHelper::CreateDeviceListSO(device_list, GetPolicyHandler(), *this); if (!msg_params) { @@ -1136,7 +1136,7 @@ void ApplicationManagerImpl::OnDeviceSwitchingFinish( for (auto app_it = reregister_wait_list_.begin(); app_it != reregister_wait_list_.end(); ++app_it) { - auto app = *app_it; + auto app = *app_it; UnregisterApplication(app->app_id(), mobile_apis::Result::INVALID_ENUM, is_resuming, @@ -1147,9 +1147,9 @@ void ApplicationManagerImpl::OnDeviceSwitchingFinish( void ApplicationManagerImpl::SwitchApplication(ApplicationSharedPtr app, const uint32_t connection_key, - const size_t device_id, + const size_t device_id, const std::string& mac_address) { - LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(applications_list_lock_); DCHECK_OR_RETURN_VOID(1 == applications_.erase(app)); @@ -1862,9 +1862,8 @@ bool ApplicationManagerImpl::ManageMobileCommand( auto app_ptr = application(connection_key); if (app_ptr && IsAppInReconnectMode(app_ptr->policy_app_id())) { - commands_holder_->Suspend(app_ptr, - CommandHolder::CommandType::kMobileCommand, - message); + commands_holder_->Suspend( + app_ptr, CommandHolder::CommandType::kMobileCommand, message); return true; } @@ -2101,9 +2100,8 @@ bool ApplicationManagerImpl::ManageHMICommand( auto app = application(static_cast(connection_key)); if (app && IsAppInReconnectMode(app->policy_app_id())) { - commands_holder_->Suspend(app, - CommandHolder::CommandType::kHmiCommand, - message); + commands_holder_->Suspend( + app, CommandHolder::CommandType::kHmiCommand, message); return true; } } diff --git a/src/components/application_manager/src/command_holder_impl.cc b/src/components/application_manager/src/command_holder_impl.cc index d5700f512e..82ba486913 100644 --- a/src/components/application_manager/src/command_holder_impl.cc +++ b/src/components/application_manager/src/command_holder_impl.cc @@ -45,26 +45,28 @@ void CommandHolderImpl::Suspend( CommandType type, utils::SharedPtr command) { LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, "Suspending command(s) for application: " - << application->policy_app_id()); + LOG4CXX_DEBUG(logger_, + "Suspending command(s) for application: " + << application->policy_app_id()); sync_primitives::AutoLock lock(commands_lock_); if (CommandType::kHmiCommand == type) { app_hmi_commands_[application].push_back(command); - LOG4CXX_DEBUG(logger_, "Suspended HMI command(s): " - << app_hmi_commands_.size()); + LOG4CXX_DEBUG(logger_, + "Suspended HMI command(s): " << app_hmi_commands_.size()); } else { app_mobile_commands_[application].push_back(command); - LOG4CXX_DEBUG(logger_, "Suspended mobile command(s): " - << app_hmi_commands_.size()); + LOG4CXX_DEBUG(logger_, + "Suspended mobile command(s): " << app_hmi_commands_.size()); } } void CommandHolderImpl::Resume(ApplicationSharedPtr application, CommandType type) { LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, "Resuming command(s) for application: " - << application->policy_app_id()); + LOG4CXX_DEBUG( + logger_, + "Resuming command(s) for application: " << application->policy_app_id()); if (CommandType::kHmiCommand == type) { ResumeHmiCommand(application); } else { @@ -74,20 +76,23 @@ void CommandHolderImpl::Resume(ApplicationSharedPtr application, void CommandHolderImpl::Clear(ApplicationSharedPtr application) { LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, "Clearing command(s) for application: " - << application->policy_app_id()); + LOG4CXX_DEBUG( + logger_, + "Clearing command(s) for application: " << application->policy_app_id()); sync_primitives::AutoLock lock(commands_lock_); auto app_hmi_commands = app_hmi_commands_.find(application); if (app_hmi_commands_.end() != app_hmi_commands) { - LOG4CXX_DEBUG(logger_, "Clearing HMI command(s): " - << app_hmi_commands->second.size()); + LOG4CXX_DEBUG( + logger_, + "Clearing HMI command(s): " << app_hmi_commands->second.size()); app_hmi_commands_.erase(app_hmi_commands); } auto app_mobile_commands = app_mobile_commands_.find(application); if (app_mobile_commands_.end() != app_mobile_commands) { - LOG4CXX_DEBUG(logger_, "Clearing mobile command(s): " - << app_mobile_commands->second.size()); + LOG4CXX_DEBUG( + logger_, + "Clearing mobile command(s): " << app_mobile_commands->second.size()); app_mobile_commands_.erase(app_mobile_commands); } } @@ -99,8 +104,8 @@ void CommandHolderImpl::ResumeHmiCommand(ApplicationSharedPtr application) { return; } - LOG4CXX_DEBUG(logger_, "Resuming HMI command(s): " - << app_hmi_commands_.size()); + LOG4CXX_DEBUG(logger_, + "Resuming HMI command(s): " << app_hmi_commands_.size()); for (auto cmd : app_commands->second) { (*cmd)[strings::msg_params][strings::app_id] = application->hmi_app_id(); @@ -117,15 +122,13 @@ void CommandHolderImpl::ResumeMobileCommand(ApplicationSharedPtr application) { return; } - LOG4CXX_DEBUG(logger_, "Resuming mobile command(s): " - << app_mobile_commands_.size()); + LOG4CXX_DEBUG(logger_, + "Resuming mobile command(s): " << app_mobile_commands_.size()); for (auto cmd : app_commands->second) { - (*cmd)[strings::params][strings::connection_key] = - application->app_id(); + (*cmd)[strings::params][strings::connection_key] = application->app_id(); app_manager_.ManageMobileCommand( - cmd, - commands::Command::CommandOrigin::ORIGIN_MOBILE); + cmd, commands::Command::CommandOrigin::ORIGIN_MOBILE); } app_mobile_commands_.erase(app_commands); diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index fda4d09de2..cb6534dd2d 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc @@ -641,26 +641,25 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( } if (ApplicationType::kSwitchedApplicationWrongHashId == app_type) { - LOG4CXX_DEBUG(logger_, - "Application has been switched from another transport, " - "but doesn't have correct hashID."); - - application_manager::RecallApplicationData(application, - application_manager_); - - SendResponse(true, mobile_apis::Result::RESUME_FAILED, NULL, - &response_params); - return; - } - - if (ApplicationType::kSwitchedApplicationHashOk == app_type) { - LOG4CXX_DEBUG(logger_, - "Application has been switched from another transport " - "and has correct hashID."); - SendResponse(true, mobile_apis::Result::SUCCESS, NULL, - &response_params); - return; - } + LOG4CXX_DEBUG(logger_, + "Application has been switched from another transport, " + "but doesn't have correct hashID."); + + application_manager::RecallApplicationData(application, + application_manager_); + + SendResponse( + true, mobile_apis::Result::RESUME_FAILED, NULL, &response_params); + return; + } + + if (ApplicationType::kSwitchedApplicationHashOk == app_type) { + LOG4CXX_DEBUG(logger_, + "Application has been switched from another transport " + "and has correct hashID."); + SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params); + return; + } bool resumption = (*message_)[strings::msg_params].keyExists(strings::hash_id); @@ -1469,10 +1468,10 @@ bool RegisterAppInterfaceRequest::IsApplicationSwitched() { auto app_type = ApplicationType::kSwitchedApplicationWrongHashId; if ((*message_)[strings::msg_params].keyExists(strings::hash_id)) { - const auto hash_id = + const auto hash_id = (*message_)[strings::msg_params][strings::hash_id].asString(); - - auto& resume_ctrl = application_manager_.resume_controller(); + + auto& resume_ctrl = application_manager_.resume_controller(); if (resume_ctrl.CheckApplicationHash(app, hash_id)) { app_type = ApplicationType::kSwitchedApplicationHashOk; } diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index e5bf7a2a7c..41e7990e43 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -852,7 +852,7 @@ uint32_t PolicyHandler::ChooseRandomAppForPolicyUpdate( return 0; } -void PolicyHandler::OnDeviceSwitching(const std::string& device_id_from, +void PolicyHandler::OnDeviceSwitching(const std::string& device_id_from, const std::string& device_id_to) { LOG4CXX_AUTO_TRACE(logger_); POLICY_LIB_CHECK_VOID(); -- cgit v1.2.1 From 8e628176a3cfe6d9bc47c80ba8c2a44cc0d961f0 Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Thu, 7 Dec 2017 16:51:55 +0200 Subject: Adds null pointer checks, fixes typos and other minor changes. --- .../src/application_manager_impl.cc | 4 ++- .../application_manager/src/command_holder_impl.cc | 5 ++++ .../src/commands/command_impl.cc | 16 +++++++++--- .../mobile/register_app_interface_request.cc | 2 +- .../src/helpers/application_helper.cc | 30 +++++++++++----------- 5 files changed, 36 insertions(+), 21 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index d42d6d91b2..da28cf9635 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -108,6 +108,7 @@ DeviceTypes devicesType = { */ bool device_id_comparator(const std::string& device_id, ApplicationSharedPtr app) { + DCHECK_OR_RETURN(app, false); LOG4CXX_DEBUG(logger_, "Data to compare: device_id : " << device_id << " app mac: " << app->mac_address()); @@ -1118,7 +1119,7 @@ void ApplicationManagerImpl::OnDeviceSwitchingStart( hmi_apis::FunctionID::BasicCommunication_UpdateDeviceList; so_to_send[jhs::S_PARAMS][jhs::S_MESSAGE_TYPE] = hmi_apis::messageType::request; - so_to_send[jhs::S_PARAMS][jhs::S_PROTOCOL_VERSION] = 3; + so_to_send[jhs::S_PARAMS][jhs::S_PROTOCOL_VERSION] = 2; so_to_send[jhs::S_PARAMS][jhs::S_PROTOCOL_TYPE] = 1; so_to_send[jhs::S_PARAMS][jhs::S_CORRELATION_ID] = GetNextHMICorrelationID(); so_to_send[jhs::S_MSG_PARAMS] = *msg_params; @@ -1150,6 +1151,7 @@ void ApplicationManagerImpl::SwitchApplication(ApplicationSharedPtr app, const size_t device_id, const std::string& mac_address) { LOG4CXX_AUTO_TRACE(logger_); + DCHECK_OR_RETURN_VOID(app); sync_primitives::AutoLock lock(applications_list_lock_); DCHECK_OR_RETURN_VOID(1 == applications_.erase(app)); diff --git a/src/components/application_manager/src/command_holder_impl.cc b/src/components/application_manager/src/command_holder_impl.cc index 82ba486913..4e2cf89f57 100644 --- a/src/components/application_manager/src/command_holder_impl.cc +++ b/src/components/application_manager/src/command_holder_impl.cc @@ -45,6 +45,7 @@ void CommandHolderImpl::Suspend( CommandType type, utils::SharedPtr command) { LOG4CXX_AUTO_TRACE(logger_); + DCHECK_OR_RETURN_VOID(application); LOG4CXX_DEBUG(logger_, "Suspending command(s) for application: " << application->policy_app_id()); @@ -64,6 +65,7 @@ void CommandHolderImpl::Suspend( void CommandHolderImpl::Resume(ApplicationSharedPtr application, CommandType type) { LOG4CXX_AUTO_TRACE(logger_); + DCHECK_OR_RETURN_VOID(application); LOG4CXX_DEBUG( logger_, "Resuming command(s) for application: " << application->policy_app_id()); @@ -76,6 +78,7 @@ void CommandHolderImpl::Resume(ApplicationSharedPtr application, void CommandHolderImpl::Clear(ApplicationSharedPtr application) { LOG4CXX_AUTO_TRACE(logger_); + DCHECK_OR_RETURN_VOID(application); LOG4CXX_DEBUG( logger_, "Clearing command(s) for application: " << application->policy_app_id()); @@ -98,6 +101,7 @@ void CommandHolderImpl::Clear(ApplicationSharedPtr application) { } void CommandHolderImpl::ResumeHmiCommand(ApplicationSharedPtr application) { + DCHECK_OR_RETURN_VOID(application); sync_primitives::AutoLock lock(commands_lock_); auto app_commands = app_hmi_commands_.find(application); if (app_hmi_commands_.end() == app_commands) { @@ -116,6 +120,7 @@ void CommandHolderImpl::ResumeHmiCommand(ApplicationSharedPtr application) { } void CommandHolderImpl::ResumeMobileCommand(ApplicationSharedPtr application) { + DCHECK_OR_RETURN_VOID(application); sync_primitives::AutoLock lock(commands_lock_); auto app_commands = app_mobile_commands_.find(application); if (app_mobile_commands_.end() == app_commands) { diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc index f9cb09816e..5251c9e122 100644 --- a/src/components/application_manager/src/commands/command_impl.cc +++ b/src/components/application_manager/src/commands/command_impl.cc @@ -114,7 +114,9 @@ bool CommandImpl::ReplaceMobileWithHMIAppId( smart_objects::SmartArray* message_array = message.asArray(); smart_objects::SmartArray::iterator it = message_array->begin(); for (; it != message_array->end(); ++it) { - ReplaceMobileWithHMIAppId(*it); + if (!ReplaceMobileWithHMIAppId(*it)) { + break; + } } break; } @@ -123,7 +125,9 @@ bool CommandImpl::ReplaceMobileWithHMIAppId( std::set::const_iterator key = keys.begin(); for (; key != keys.end(); ++key) { std::string k = *key; - ReplaceMobileWithHMIAppId(message[*key]); + if (!ReplaceMobileWithHMIAppId(message[*key])) { + break; + } } break; } @@ -193,7 +197,9 @@ bool CommandImpl::ReplaceHMIWithMobileAppId( smart_objects::SmartArray* message_array = message.asArray(); smart_objects::SmartArray::iterator it = message_array->begin(); for (; it != message_array->end(); ++it) { - ReplaceHMIWithMobileAppId(*it); + if (!ReplaceHMIWithMobileAppId(*it)) { + break; + } } break; } @@ -201,7 +207,9 @@ bool CommandImpl::ReplaceHMIWithMobileAppId( std::set keys = message.enumerate(); std::set::const_iterator key = keys.begin(); for (; key != keys.end(); ++key) { - ReplaceHMIWithMobileAppId(message[*key]); + if (!ReplaceHMIWithMobileAppId(message[*key])) { + break; + } } break; } diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index cb6534dd2d..26e50d39fe 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc @@ -645,7 +645,7 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( "Application has been switched from another transport, " "but doesn't have correct hashID."); - application_manager::RecallApplicationData(application, + application_manager::DeleteApplicationData(application, application_manager_); SendResponse( diff --git a/src/components/application_manager/src/helpers/application_helper.cc b/src/components/application_manager/src/helpers/application_helper.cc index 2007b97434..16b49faa2a 100644 --- a/src/components/application_manager/src/helpers/application_helper.cc +++ b/src/components/application_manager/src/helpers/application_helper.cc @@ -7,7 +7,7 @@ namespace { using namespace application_manager; -void RecallWayPoints(ApplicationSharedPtr app, +void DeleteWayPoints(ApplicationSharedPtr app, ApplicationManager& app_manager) { app_manager.UnsubscribeAppFromWayPoints(app); if (!app_manager.IsAnyAppSubscribedForWayPoints()) { @@ -15,7 +15,7 @@ void RecallWayPoints(ApplicationSharedPtr app, } } -void RecallCommands(ApplicationSharedPtr app, ApplicationManager& app_manager) { +void DeleteCommands(ApplicationSharedPtr app, ApplicationManager& app_manager) { CommandsMap cmap = app->commands_map().GetData(); for (auto cmd : cmap) { @@ -24,7 +24,7 @@ void RecallCommands(ApplicationSharedPtr app, ApplicationManager& app_manager) { } } -void RecallSubmenus(ApplicationSharedPtr app, ApplicationManager& app_manager) { +void DeleteSubmenus(ApplicationSharedPtr app, ApplicationManager& app_manager) { SubMenuMap smap = app->sub_menu_map().GetData(); for (auto smenu : smap) { @@ -33,7 +33,7 @@ void RecallSubmenus(ApplicationSharedPtr app, ApplicationManager& app_manager) { } } -void RecallChoiceSets(ApplicationSharedPtr app, +void DeleteChoiceSets(ApplicationSharedPtr app, ApplicationManager& app_manager) { ChoiceSetMap csmap = app->choice_set_map().GetData(); @@ -43,7 +43,7 @@ void RecallChoiceSets(ApplicationSharedPtr app, } } -void RecallGlobalProperties(ApplicationSharedPtr app, +void DeleteGlobalProperties(ApplicationSharedPtr app, ApplicationManager& app_manager) { using namespace smart_objects; @@ -74,7 +74,7 @@ void RecallGlobalProperties(ApplicationSharedPtr app, MessageHelper::SendResetPropertiesRequest(app, app_manager); } -void RecallButtonSubscriptions(ApplicationSharedPtr app, +void DeleteButtonSubscriptions(ApplicationSharedPtr app, ApplicationManager& app_manager) { ButtonSubscriptions buttons = app->SubscribedButtons().GetData(); @@ -87,7 +87,7 @@ void RecallButtonSubscriptions(ApplicationSharedPtr app, } } -void RecallVISubscriptions(ApplicationSharedPtr app, +void DeleteVISubscriptions(ApplicationSharedPtr app, ApplicationManager& app_manager) { VehicleInfoSubscriptions ivi = app->SubscribedIVI().GetData(); @@ -128,18 +128,18 @@ bool SubscribedToIVIPredicate::operator()( return app ? app->IsSubscribedToIVI(vehicle_info_) : false; } -void RecallApplicationData(ApplicationSharedPtr app, +void DeleteApplicationData(ApplicationSharedPtr app, ApplicationManager& app_manager) { LOG4CXX_AUTO_TRACE(logger); DCHECK_OR_RETURN_VOID(app); - RecallWayPoints(app, app_manager); - RecallCommands(app, app_manager); - RecallSubmenus(app, app_manager); - RecallChoiceSets(app, app_manager); - RecallGlobalProperties(app, app_manager); - RecallButtonSubscriptions(app, app_manager); - RecallVISubscriptions(app, app_manager); + DeleteWayPoints(app, app_manager); + DeleteCommands(app, app_manager); + DeleteSubmenus(app, app_manager); + DeleteChoiceSets(app, app_manager); + DeleteGlobalProperties(app, app_manager); + DeleteButtonSubscriptions(app, app_manager); + DeleteVISubscriptions(app, app_manager); CleanupAppFiles(app); } -- cgit v1.2.1 From 41c7c86289c1c36252ce217041e13214b080fe82 Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Thu, 7 Dec 2017 20:52:28 +0200 Subject: Changes return codes for application id replacement --- src/components/application_manager/src/commands/command_impl.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc index 5251c9e122..38fe980cce 100644 --- a/src/components/application_manager/src/commands/command_impl.cc +++ b/src/components/application_manager/src/commands/command_impl.cc @@ -115,7 +115,7 @@ bool CommandImpl::ReplaceMobileWithHMIAppId( smart_objects::SmartArray::iterator it = message_array->begin(); for (; it != message_array->end(); ++it) { if (!ReplaceMobileWithHMIAppId(*it)) { - break; + return false; } } break; @@ -126,7 +126,7 @@ bool CommandImpl::ReplaceMobileWithHMIAppId( for (; key != keys.end(); ++key) { std::string k = *key; if (!ReplaceMobileWithHMIAppId(message[*key])) { - break; + return false; } } break; @@ -198,7 +198,7 @@ bool CommandImpl::ReplaceHMIWithMobileAppId( smart_objects::SmartArray::iterator it = message_array->begin(); for (; it != message_array->end(); ++it) { if (!ReplaceHMIWithMobileAppId(*it)) { - break; + return false; } } break; @@ -208,7 +208,7 @@ bool CommandImpl::ReplaceHMIWithMobileAppId( std::set::const_iterator key = keys.begin(); for (; key != keys.end(); ++key) { if (!ReplaceHMIWithMobileAppId(message[*key])) { - break; + return false; } } break; -- cgit v1.2.1 From f5582e85acd8081a0d8a08d738e0dba39d9a4672 Mon Sep 17 00:00:00 2001 From: "Andrey Oleynik (GitHub)" Date: Fri, 8 Dec 2017 12:02:23 +0200 Subject: Revert "Changes return codes for application id replacement" This reverts commit 866dfe849471157d6d0b414cfb013198a879a51f. Returning false in case of inner app_id fields update failed causes many issues on exisiting logic and ATF scripts. --- src/components/application_manager/src/commands/command_impl.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc index 38fe980cce..5251c9e122 100644 --- a/src/components/application_manager/src/commands/command_impl.cc +++ b/src/components/application_manager/src/commands/command_impl.cc @@ -115,7 +115,7 @@ bool CommandImpl::ReplaceMobileWithHMIAppId( smart_objects::SmartArray::iterator it = message_array->begin(); for (; it != message_array->end(); ++it) { if (!ReplaceMobileWithHMIAppId(*it)) { - return false; + break; } } break; @@ -126,7 +126,7 @@ bool CommandImpl::ReplaceMobileWithHMIAppId( for (; key != keys.end(); ++key) { std::string k = *key; if (!ReplaceMobileWithHMIAppId(message[*key])) { - return false; + break; } } break; @@ -198,7 +198,7 @@ bool CommandImpl::ReplaceHMIWithMobileAppId( smart_objects::SmartArray::iterator it = message_array->begin(); for (; it != message_array->end(); ++it) { if (!ReplaceHMIWithMobileAppId(*it)) { - return false; + break; } } break; @@ -208,7 +208,7 @@ bool CommandImpl::ReplaceHMIWithMobileAppId( std::set::const_iterator key = keys.begin(); for (; key != keys.end(); ++key) { if (!ReplaceHMIWithMobileAppId(message[*key])) { - return false; + break; } } break; -- cgit v1.2.1 From a56108fabda2fed248778cdb9778c8cd3162b762 Mon Sep 17 00:00:00 2001 From: Andriy Byzhynar Date: Fri, 12 Jan 2018 15:14:55 +0200 Subject: Add wrappers for deprecated methods Added wrappers for some deprecated methods Grouped iface checks in SendRegisterAppInterfaceResponseToMobile Removed duplicated "if" statement Improved readability --- .../src/application_manager_impl.cc | 8 +-- .../src/commands/command_impl.cc | 68 ++-------------------- .../src/commands/hmi/notification_from_hmi.cc | 2 +- .../src/commands/hmi/notification_to_hmi.cc | 7 ++- .../src/commands/hmi/request_from_hmi.cc | 2 +- .../src/commands/hmi/request_to_hmi.cc | 7 ++- .../src/commands/hmi/response_from_hmi.cc | 2 +- .../src/commands/hmi/response_to_hmi.cc | 7 ++- .../mobile/register_app_interface_request.cc | 22 ++++--- 9 files changed, 37 insertions(+), 88 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index da28cf9635..cf8aae75f3 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -95,7 +95,7 @@ DeviceTypes devicesType = { hmi_apis::Common_TransportType::USB_IOS), std::make_pair(std::string("BLUETOOTH"), hmi_apis::Common_TransportType::BLUETOOTH), - std::make_pair(std::string("IOS_BLUETOOTH"), + std::make_pair(std::string("BLUETOOTH_IOS"), hmi_apis::Common_TransportType::BLUETOOTH), std::make_pair(std::string("WIFI"), hmi_apis::Common_TransportType::WIFI)}; } @@ -2109,7 +2109,7 @@ bool ApplicationManagerImpl::ManageHMICommand( } int32_t message_type = - (*(message.get()))[strings::params][strings::message_type].asInt(); + (*message)[strings::params][strings::message_type].asInt(); if (kRequest == message_type) { LOG4CXX_DEBUG(logger_, "ManageHMICommand"); @@ -2120,9 +2120,9 @@ bool ApplicationManagerImpl::ManageHMICommand( command->Run(); if (kResponse == message_type) { const uint32_t correlation_id = - (*(message.get()))[strings::params][strings::correlation_id].asUInt(); + (*message)[strings::params][strings::correlation_id].asUInt(); const int32_t function_id = - (*(message.get()))[strings::params][strings::function_id].asInt(); + (*message)[strings::params][strings::function_id].asInt(); request_ctrl_.OnHMIResponse(correlation_id, function_id); } return true; diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc index 5251c9e122..ea179a5bfc 100644 --- a/src/components/application_manager/src/commands/command_impl.cc +++ b/src/components/application_manager/src/commands/command_impl.cc @@ -96,6 +96,7 @@ void CommandImpl::SetAllowedToTerminate(const bool allowed) { bool CommandImpl::ReplaceMobileWithHMIAppId( NsSmartDeviceLink::NsSmartObjects::SmartObject& message) { + LOG4CXX_AUTO_TRACE(logger_); if (message.keyExists(strings::app_id)) { ApplicationSharedPtr application = application_manager_.application(message[strings::app_id].asUInt()); @@ -141,37 +142,8 @@ bool CommandImpl::ReplaceMobileWithHMIAppId( // DEPRECATED void CommandImpl::ReplaceMobileByHMIAppId( NsSmartDeviceLink::NsSmartObjects::SmartObject& message) { - if (message.keyExists(strings::app_id)) { - ApplicationSharedPtr application = - application_manager_.application(message[strings::app_id].asUInt()); - if (application.valid()) { - LOG4CXX_DEBUG(logger_, - "ReplaceMobileWithHMIAppId from " - << message[strings::app_id].asInt() << " to " - << application->hmi_app_id()); - message[strings::app_id] = application->hmi_app_id(); - } - } else { - switch (message.getType()) { - case smart_objects::SmartType::SmartType_Array: { - smart_objects::SmartArray* message_array = message.asArray(); - smart_objects::SmartArray::iterator it = message_array->begin(); - for (; it != message_array->end(); ++it) { - ReplaceMobileWithHMIAppId(*it); - } - break; - } - case smart_objects::SmartType::SmartType_Map: { - std::set keys = message.enumerate(); - std::set::const_iterator key = keys.begin(); - for (; key != keys.end(); ++key) { - std::string k = *key; - ReplaceMobileWithHMIAppId(message[*key]); - } - break; - } - default: { break; } - } + if (!ReplaceMobileWithHMIAppId(message)) { + LOG4CXX_ERROR(logger_, "Substitution mobile --> HMI id is failed."); } } @@ -223,38 +195,8 @@ bool CommandImpl::ReplaceHMIWithMobileAppId( // DEPRECATED void CommandImpl::ReplaceHMIByMobileAppId( NsSmartDeviceLink::NsSmartObjects::SmartObject& message) { - if (message.keyExists(strings::app_id)) { - ApplicationSharedPtr application = - application_manager_.application_by_hmi_app( - message[strings::app_id].asUInt()); - - if (application.valid()) { - LOG4CXX_DEBUG(logger_, - "ReplaceHMIByMobileAppId from " - << message[strings::app_id].asInt() << " to " - << application->app_id()); - message[strings::app_id] = application->app_id(); - } - } else { - switch (message.getType()) { - case smart_objects::SmartType::SmartType_Array: { - smart_objects::SmartArray* message_array = message.asArray(); - smart_objects::SmartArray::iterator it = message_array->begin(); - for (; it != message_array->end(); ++it) { - ReplaceHMIByMobileAppId(*it); - } - break; - } - case smart_objects::SmartType::SmartType_Map: { - std::set keys = message.enumerate(); - std::set::const_iterator key = keys.begin(); - for (; key != keys.end(); ++key) { - ReplaceHMIByMobileAppId(message[*key]); - } - break; - } - default: { break; } - } + if (!ReplaceHMIWithMobileAppId(message)) { + LOG4CXX_ERROR(logger_, "Substitution HMI --> mobile id is failed."); } } diff --git a/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc b/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc index 3c2d73b10c..64eb63fde8 100644 --- a/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc @@ -42,7 +42,7 @@ NotificationFromHMI::NotificationFromHMI( const MessageSharedPtr& message, ApplicationManager& application_manager) : CommandImpl(message, application_manager) { // Replace HMI app id with Mobile connection id - ReplaceHMIWithMobileAppId(*message); + ReplaceHMIByMobileAppId(*message); } NotificationFromHMI::~NotificationFromHMI() {} diff --git a/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc b/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc index b6639c9aea..c136f7b770 100644 --- a/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc @@ -39,12 +39,15 @@ namespace commands { NotificationToHMI::NotificationToHMI(const MessageSharedPtr& message, ApplicationManager& application_manager) - : CommandImpl(message, application_manager) {} + : CommandImpl(message, application_manager) { + // Replace Mobile connection id with HMI app id + ReplaceMobileByHMIAppId(*message_); +} NotificationToHMI::~NotificationToHMI() {} bool NotificationToHMI::Init() { - return ReplaceMobileWithHMIAppId(*message_); + return true; } bool NotificationToHMI::CleanUp() { diff --git a/src/components/application_manager/src/commands/hmi/request_from_hmi.cc b/src/components/application_manager/src/commands/hmi/request_from_hmi.cc index c91423e369..a203110ce4 100644 --- a/src/components/application_manager/src/commands/hmi/request_from_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/request_from_hmi.cc @@ -43,7 +43,7 @@ RequestFromHMI::RequestFromHMI(const MessageSharedPtr& message, : CommandImpl(message, application_manager) , EventObserver(application_manager.event_dispatcher()) { // Replace HMI app id with Mobile connection id - ReplaceHMIWithMobileAppId(*(message.get())); + ReplaceHMIByMobileAppId(*message); } RequestFromHMI::~RequestFromHMI() {} diff --git a/src/components/application_manager/src/commands/hmi/request_to_hmi.cc b/src/components/application_manager/src/commands/hmi/request_to_hmi.cc index cba36cbb0c..8079558545 100644 --- a/src/components/application_manager/src/commands/hmi/request_to_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/request_to_hmi.cc @@ -61,12 +61,15 @@ bool ChangeInterfaceState(ApplicationManager& application_manager, RequestToHMI::RequestToHMI(const MessageSharedPtr& message, ApplicationManager& application_manager) - : CommandImpl(message, application_manager) {} + : CommandImpl(message, application_manager) { + // Replace Mobile connection id with HMI app id + ReplaceMobileByHMIAppId(*message); +} RequestToHMI::~RequestToHMI() {} bool RequestToHMI::Init() { - return ReplaceMobileWithHMIAppId(*message_); + return true; } bool RequestToHMI::CleanUp() { diff --git a/src/components/application_manager/src/commands/hmi/response_from_hmi.cc b/src/components/application_manager/src/commands/hmi/response_from_hmi.cc index c5a6dd9d3e..5f5a9deca3 100644 --- a/src/components/application_manager/src/commands/hmi/response_from_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/response_from_hmi.cc @@ -48,7 +48,7 @@ ResponseFromHMI::ResponseFromHMI(const MessageSharedPtr& message, } // Replace HMI app id with Mobile connection id - ReplaceHMIWithMobileAppId(*(message.get())); + ReplaceHMIByMobileAppId(*message); } ResponseFromHMI::~ResponseFromHMI() {} diff --git a/src/components/application_manager/src/commands/hmi/response_to_hmi.cc b/src/components/application_manager/src/commands/hmi/response_to_hmi.cc index 94f6967e23..d70cc20e4c 100644 --- a/src/components/application_manager/src/commands/hmi/response_to_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/response_to_hmi.cc @@ -39,12 +39,15 @@ namespace commands { ResponseToHMI::ResponseToHMI(const MessageSharedPtr& message, ApplicationManager& application_manager) - : CommandImpl(message, application_manager) {} + : CommandImpl(message, application_manager) { + // Replace Mobile connection id with HMI app id + ReplaceMobileByHMIAppId(*message); +} ResponseToHMI::~ResponseToHMI() {} bool ResponseToHMI::Init() { - return ReplaceMobileWithHMIAppId(*message_); + return true; } bool ResponseToHMI::CleanUp() { diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index 26e50d39fe..2d787f3a1f 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc @@ -581,18 +581,27 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( FillUIRelatedFields(response_params, hmi_capabilities); } + if (HmiInterfaces::STATE_NOT_AVAILABLE != + application_manager_.hmi_interfaces().GetInterfaceState( + HmiInterfaces::HMI_INTERFACE_VehicleInfo)) { + FillVIRelatedFields(response_params, hmi_capabilities); + } + if (hmi_capabilities.button_capabilities()) { response_params[hmi_response::button_capabilities] = *hmi_capabilities.button_capabilities(); } + if (hmi_capabilities.soft_button_capabilities()) { response_params[hmi_response::soft_button_capabilities] = *hmi_capabilities.soft_button_capabilities(); } + if (hmi_capabilities.preset_bank_capabilities()) { response_params[hmi_response::preset_bank_capabilities] = *hmi_capabilities.preset_bank_capabilities(); } + if (hmi_capabilities.hmi_zone_capabilities()) { if (smart_objects::SmartType_Array == hmi_capabilities.hmi_zone_capabilities()->getType()) { @@ -605,23 +614,11 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( } } - if (HmiInterfaces::STATE_NOT_AVAILABLE != - application_manager_.hmi_interfaces().GetInterfaceState( - HmiInterfaces::HMI_INTERFACE_TTS)) { - FillTTSRelatedFields(response_params, hmi_capabilities); - } - if (hmi_capabilities.pcm_stream_capabilities()) { response_params[strings::pcm_stream_capabilities] = *hmi_capabilities.pcm_stream_capabilities(); } - if (HmiInterfaces::STATE_NOT_AVAILABLE != - application_manager_.hmi_interfaces().GetInterfaceState( - HmiInterfaces::HMI_INTERFACE_VehicleInfo)) { - FillVIRelatedFields(response_params, hmi_capabilities); - } - const std::vector& diag_modes = application_manager_.get_settings().supported_diag_modes(); if (!diag_modes.empty()) { @@ -632,6 +629,7 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( ++index; } } + response_params[strings::sdl_version] = application_manager_.get_settings().sdl_version(); const std::string ccpu_version = -- cgit v1.2.1 From 852ffc1975384a4abdba274104449cfe595965af Mon Sep 17 00:00:00 2001 From: Andriy Byzhynar Date: Fri, 12 Jan 2018 18:48:49 +0200 Subject: Fix issues after rebase --- src/components/application_manager/src/message_helper/message_helper.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/components/application_manager/src') 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 34a35e5929..4ae6ce4024 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -613,7 +613,7 @@ void MessageHelper::SendUnsubscribeButtonNotification( app_mngr.ManageHMICommand(message); } -void MessageHelper::SendUnsubscribeIVIRequest(uint32_t ivi_id, +void MessageHelper::SendUnsubscribeIVIRequest(int32_t ivi_id, ApplicationSharedPtr application, ApplicationManager& app_mngr) { using namespace smart_objects; -- cgit v1.2.1 From 60bc47f3a4089505fe377e9b154ad7ddc85d743e Mon Sep 17 00:00:00 2001 From: Andriy Byzhynar Date: Tue, 16 Jan 2018 14:17:36 +0200 Subject: Replace pragma with header guards Replaced #pragma once usage with header guards Added wrappers for deprecated functions Fixed related unit tests Fixed coding style in places related to code chages --- .../src/commands/hmi/notification_from_hmi.cc | 2 +- .../src/commands/hmi/notification_to_hmi.cc | 8 +- .../src/commands/hmi/request_from_hmi.cc | 2 +- .../src/commands/hmi/request_to_hmi.cc | 8 +- .../src/commands/hmi/response_from_hmi.cc | 2 +- .../src/commands/hmi/response_to_hmi.cc | 8 +- .../mobile/register_app_interface_request.cc | 210 +-------------------- 7 files changed, 13 insertions(+), 227 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc b/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc index 64eb63fde8..3c2d73b10c 100644 --- a/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc @@ -42,7 +42,7 @@ NotificationFromHMI::NotificationFromHMI( const MessageSharedPtr& message, ApplicationManager& application_manager) : CommandImpl(message, application_manager) { // Replace HMI app id with Mobile connection id - ReplaceHMIByMobileAppId(*message); + ReplaceHMIWithMobileAppId(*message); } NotificationFromHMI::~NotificationFromHMI() {} diff --git a/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc b/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc index c136f7b770..d52df950c3 100644 --- a/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc @@ -39,15 +39,13 @@ namespace commands { NotificationToHMI::NotificationToHMI(const MessageSharedPtr& message, ApplicationManager& application_manager) - : CommandImpl(message, application_manager) { - // Replace Mobile connection id with HMI app id - ReplaceMobileByHMIAppId(*message_); -} + : CommandImpl(message, application_manager) {} NotificationToHMI::~NotificationToHMI() {} bool NotificationToHMI::Init() { - return true; + // Replace Mobile connection id with HMI app id + return ReplaceMobileWithHMIAppId(*message_); } bool NotificationToHMI::CleanUp() { diff --git a/src/components/application_manager/src/commands/hmi/request_from_hmi.cc b/src/components/application_manager/src/commands/hmi/request_from_hmi.cc index a203110ce4..5a4e7b149e 100644 --- a/src/components/application_manager/src/commands/hmi/request_from_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/request_from_hmi.cc @@ -43,7 +43,7 @@ RequestFromHMI::RequestFromHMI(const MessageSharedPtr& message, : CommandImpl(message, application_manager) , EventObserver(application_manager.event_dispatcher()) { // Replace HMI app id with Mobile connection id - ReplaceHMIByMobileAppId(*message); + ReplaceHMIWithMobileAppId(*message); } RequestFromHMI::~RequestFromHMI() {} diff --git a/src/components/application_manager/src/commands/hmi/request_to_hmi.cc b/src/components/application_manager/src/commands/hmi/request_to_hmi.cc index 8079558545..6905e7cdef 100644 --- a/src/components/application_manager/src/commands/hmi/request_to_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/request_to_hmi.cc @@ -61,15 +61,13 @@ bool ChangeInterfaceState(ApplicationManager& application_manager, RequestToHMI::RequestToHMI(const MessageSharedPtr& message, ApplicationManager& application_manager) - : CommandImpl(message, application_manager) { - // Replace Mobile connection id with HMI app id - ReplaceMobileByHMIAppId(*message); -} + : CommandImpl(message, application_manager) {} RequestToHMI::~RequestToHMI() {} bool RequestToHMI::Init() { - return true; + // Replace Mobile connection id with HMI app id + return ReplaceMobileWithHMIAppId(*message_); } bool RequestToHMI::CleanUp() { diff --git a/src/components/application_manager/src/commands/hmi/response_from_hmi.cc b/src/components/application_manager/src/commands/hmi/response_from_hmi.cc index 5f5a9deca3..d6d5d95d07 100644 --- a/src/components/application_manager/src/commands/hmi/response_from_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/response_from_hmi.cc @@ -48,7 +48,7 @@ ResponseFromHMI::ResponseFromHMI(const MessageSharedPtr& message, } // Replace HMI app id with Mobile connection id - ReplaceHMIByMobileAppId(*message); + ReplaceHMIWithMobileAppId(*message); } ResponseFromHMI::~ResponseFromHMI() {} diff --git a/src/components/application_manager/src/commands/hmi/response_to_hmi.cc b/src/components/application_manager/src/commands/hmi/response_to_hmi.cc index d70cc20e4c..de1e1e0fde 100644 --- a/src/components/application_manager/src/commands/hmi/response_to_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/response_to_hmi.cc @@ -39,15 +39,13 @@ namespace commands { ResponseToHMI::ResponseToHMI(const MessageSharedPtr& message, ApplicationManager& application_manager) - : CommandImpl(message, application_manager) { - // Replace Mobile connection id with HMI app id - ReplaceMobileByHMIAppId(*message); -} + : CommandImpl(message, application_manager) {} ResponseToHMI::~ResponseToHMI() {} bool ResponseToHMI::Init() { - return true; + // Replace Mobile connection id with HMI app id + return ReplaceMobileWithHMIAppId(*message_); } bool ResponseToHMI::CleanUp() { diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index 2d787f3a1f..870ff532da 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc @@ -743,215 +743,7 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( // DEPRECATED void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() { - LOG4CXX_AUTO_TRACE(logger_); - smart_objects::SmartObject response_params(smart_objects::SmartType_Map); - - mobile_apis::Result::eType result_code = mobile_apis::Result::SUCCESS; - - const HMICapabilities& hmi_capabilities = - application_manager_.hmi_capabilities(); - - const uint32_t key = connection_key(); - ApplicationSharedPtr application = application_manager_.application(key); - - resumption::ResumeCtrl& resumer = application_manager_.resume_controller(); - - if (!application) { - LOG4CXX_ERROR(logger_, - "There is no application for such connection key" << key); - LOG4CXX_DEBUG(logger_, "Need to start resume data persistent timer"); - resumer.OnAppRegistrationEnd(); - return; - } - - response_params[strings::sync_msg_version][strings::major_version] = - major_version; // From generated file interfaces/generated_msg_version.h - response_params[strings::sync_msg_version][strings::minor_version] = - minor_version; // From generated file interfaces/generated_msg_version.h - response_params[strings::sync_msg_version][strings::patch_version] = - patch_version; // From generated file interfaces/generated_msg_version.h - - const smart_objects::SmartObject& msg_params = - (*message_)[strings::msg_params]; - - if (msg_params[strings::language_desired].asInt() != - hmi_capabilities.active_vr_language() || - msg_params[strings::hmi_display_language_desired].asInt() != - hmi_capabilities.active_ui_language()) { - LOG4CXX_WARN(logger_, - "Wrong language on registering application " - << application->name().c_str()); - - LOG4CXX_ERROR( - logger_, - "VR language desired code is " - << msg_params[strings::language_desired].asInt() - << " , active VR language code is " - << hmi_capabilities.active_vr_language() << ", UI language code is " - << msg_params[strings::hmi_display_language_desired].asInt() - << " , active UI language code is " - << hmi_capabilities.active_ui_language()); - - result_code = mobile_apis::Result::WRONG_LANGUAGE; - } - - if (HmiInterfaces::STATE_NOT_AVAILABLE != - application_manager_.hmi_interfaces().GetInterfaceState( - HmiInterfaces::HMI_INTERFACE_TTS)) { - FillTTSRelatedFields(response_params, hmi_capabilities); - } - - if (HmiInterfaces::STATE_NOT_AVAILABLE != - application_manager_.hmi_interfaces().GetInterfaceState( - HmiInterfaces::HMI_INTERFACE_VR)) { - FillVRRelatedFields(response_params, hmi_capabilities); - } - - if (HmiInterfaces::STATE_NOT_AVAILABLE != - application_manager_.hmi_interfaces().GetInterfaceState( - HmiInterfaces::HMI_INTERFACE_UI)) { - FillUIRelatedFields(response_params, hmi_capabilities); - } - - if (hmi_capabilities.button_capabilities()) { - response_params[hmi_response::button_capabilities] = - *hmi_capabilities.button_capabilities(); - } - if (hmi_capabilities.soft_button_capabilities()) { - response_params[hmi_response::soft_button_capabilities] = - *hmi_capabilities.soft_button_capabilities(); - } - if (hmi_capabilities.preset_bank_capabilities()) { - response_params[hmi_response::preset_bank_capabilities] = - *hmi_capabilities.preset_bank_capabilities(); - } - if (hmi_capabilities.hmi_zone_capabilities()) { - if (smart_objects::SmartType_Array == - hmi_capabilities.hmi_zone_capabilities()->getType()) { - // hmi_capabilities json contains array and HMI response object - response_params[hmi_response::hmi_zone_capabilities] = - *hmi_capabilities.hmi_zone_capabilities(); - } else { - response_params[hmi_response::hmi_zone_capabilities][0] = - *hmi_capabilities.hmi_zone_capabilities(); - } - } - - if (HmiInterfaces::STATE_NOT_AVAILABLE != - application_manager_.hmi_interfaces().GetInterfaceState( - HmiInterfaces::HMI_INTERFACE_TTS)) { - FillTTSRelatedFields(response_params, hmi_capabilities); - } - - if (hmi_capabilities.pcm_stream_capabilities()) { - response_params[strings::pcm_stream_capabilities] = - *hmi_capabilities.pcm_stream_capabilities(); - } - - if (HmiInterfaces::STATE_NOT_AVAILABLE != - application_manager_.hmi_interfaces().GetInterfaceState( - HmiInterfaces::HMI_INTERFACE_VehicleInfo)) { - FillVIRelatedFields(response_params, hmi_capabilities); - } - - const std::vector& diag_modes = - application_manager_.get_settings().supported_diag_modes(); - if (!diag_modes.empty()) { - std::vector::const_iterator it = diag_modes.begin(); - uint32_t index = 0; - for (; it != diag_modes.end(); ++it) { - response_params[strings::supported_diag_modes][index] = *it; - ++index; - } - } - response_params[strings::sdl_version] = - application_manager_.get_settings().sdl_version(); - const std::string ccpu_version = - application_manager_.hmi_capabilities().ccpu_version(); - if (!ccpu_version.empty()) { - response_params[strings::system_software_version] = ccpu_version; - } - - bool resumption = - (*message_)[strings::msg_params].keyExists(strings::hash_id); - - bool need_restore_vr = resumption; - - std::string hash_id; - std::string add_info; - if (resumption) { - hash_id = (*message_)[strings::msg_params][strings::hash_id].asString(); - if (!resumer.CheckApplicationHash(application, hash_id)) { - LOG4CXX_WARN(logger_, - "Hash from RAI does not match to saved resume data."); - result_code = mobile_apis::Result::RESUME_FAILED; - add_info = "Hash from RAI does not match to saved resume data."; - need_restore_vr = false; - } else if (!resumer.CheckPersistenceFilesForResumption(application)) { - LOG4CXX_WARN(logger_, "Persistent data is missing."); - result_code = mobile_apis::Result::RESUME_FAILED; - add_info = "Persistent data is missing."; - need_restore_vr = false; - } else { - add_info = "Resume succeeded."; - } - } - if ((mobile_apis::Result::SUCCESS == result_code) && - (mobile_apis::Result::INVALID_ENUM != result_checking_app_hmi_type_)) { - add_info += response_info_; - result_code = result_checking_app_hmi_type_; - } - - // in case application exist in resumption we need to send resumeVrgrammars - if (false == resumption) { - resumption = resumer.IsApplicationSaved(application->policy_app_id(), - application->mac_address()); - } - - AppHmiTypes hmi_types; - if ((*message_)[strings::msg_params].keyExists(strings::app_hmi_type)) { - smart_objects::SmartArray* hmi_types_ptr = - (*message_)[strings::msg_params][strings::app_hmi_type].asArray(); - DCHECK_OR_RETURN_VOID(hmi_types_ptr); - SmartArrayValueExtractor extractor; - if (hmi_types_ptr && 0 < hmi_types_ptr->size()) { - std::transform(hmi_types_ptr->begin(), - hmi_types_ptr->end(), - std::back_inserter(hmi_types), - extractor); - } - } - policy::StatusNotifier notify_upd_manager = GetPolicyHandler().AddApplication( - application->policy_app_id(), hmi_types); - SendResponse(true, result_code, add_info.c_str(), &response_params); - SendOnAppRegisteredNotificationToHMI( - *(application.get()), resumption, need_restore_vr); -#ifdef SDL_REMOTE_CONTROL - if (msg_params.keyExists(strings::app_hmi_type)) { - GetPolicyHandler().SetDefaultHmiTypes(application->policy_app_id(), - &(msg_params[strings::app_hmi_type])); - } -#endif // SDL_REMOTE_CONTROL - - // Default HMI level should be set before any permissions validation, since it - // relies on HMI level. - application_manager_.OnApplicationRegistered(application); - (*notify_upd_manager)(); - - // Start PTU after successfull registration - // Sends OnPermissionChange notification to mobile right after RAI response - // and HMI level set-up - GetPolicyHandler().OnAppRegisteredOnMobile(application->policy_app_id()); - - if (result_code != mobile_apis::Result::RESUME_FAILED) { - resumer.StartResumption(application, hash_id); - } else { - resumer.StartResumptionOnlyHMILevel(application); - } - - // By default app subscribed to CUSTOM_BUTTON - SendSubscribeCustomButtonNotification(); - SendChangeRegistrationOnHMI(application); + SendRegisterAppInterfaceResponseToMobile(ApplicationType::kNewApplication); } void RegisterAppInterfaceRequest::SendChangeRegistration( -- cgit v1.2.1 From 12431fd3437c94f1b96e2ceea432edd5184a4cb9 Mon Sep 17 00:00:00 2001 From: Andriy Byzhynar Date: Thu, 18 Jan 2018 15:18:36 +0200 Subject: Replace deprecation comments with DEPRECATED macro --- .../application_manager/src/application_impl.cc | 4 +- .../src/application_manager_impl.cc | 12 +++--- .../src/commands/command_impl.cc | 6 +-- .../mobile/register_app_interface_request.cc | 4 +- .../application_manager/src/hmi_state.cc | 47 ++++++++++------------ .../src/resumption/resumption_data_db.cc | 6 +-- .../src/resumption/resumption_data_json.cc | 6 +-- 7 files changed, 37 insertions(+), 48 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index eaf097d43f..735a9955a7 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -614,8 +614,8 @@ void ApplicationImpl::set_app_allowed(const bool allowed) { is_app_allowed_ = allowed; } -// DEPRECATED -void ApplicationImpl::set_device(connection_handler::DeviceHandle device) { +DEPRECATED void ApplicationImpl::set_device( + connection_handler::DeviceHandle device) { device_id_ = device; } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index cf8aae75f3..eb3313e492 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -638,13 +638,13 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( return application; } -// DEPRECATED -bool ApplicationManagerImpl::RemoveAppDataFromHMI(ApplicationSharedPtr app) { +DEPRECATED bool ApplicationManagerImpl::RemoveAppDataFromHMI( + ApplicationSharedPtr app) { return true; } -// DEPRECATED -bool ApplicationManagerImpl::LoadAppDataToHMI(ApplicationSharedPtr app) { +DEPRECATED bool ApplicationManagerImpl::LoadAppDataToHMI( + ApplicationSharedPtr app) { return true; } @@ -795,8 +795,8 @@ void ApplicationManagerImpl::set_driver_distraction(const bool is_distracting) { is_distracting_driver_ = is_distracting; } -// DEPRECATED -void ApplicationManagerImpl::set_vr_session_started(const bool state) { +DEPRECATED void ApplicationManagerImpl::set_vr_session_started( + const bool state) { is_vr_session_strated_ = state; } diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc index ea179a5bfc..b928184148 100644 --- a/src/components/application_manager/src/commands/command_impl.cc +++ b/src/components/application_manager/src/commands/command_impl.cc @@ -139,8 +139,7 @@ bool CommandImpl::ReplaceMobileWithHMIAppId( return true; } -// DEPRECATED -void CommandImpl::ReplaceMobileByHMIAppId( +DEPRECATED void CommandImpl::ReplaceMobileByHMIAppId( NsSmartDeviceLink::NsSmartObjects::SmartObject& message) { if (!ReplaceMobileWithHMIAppId(message)) { LOG4CXX_ERROR(logger_, "Substitution mobile --> HMI id is failed."); @@ -192,8 +191,7 @@ bool CommandImpl::ReplaceHMIWithMobileAppId( return true; } -// DEPRECATED -void CommandImpl::ReplaceHMIByMobileAppId( +DEPRECATED void CommandImpl::ReplaceHMIByMobileAppId( NsSmartDeviceLink::NsSmartObjects::SmartObject& message) { if (!ReplaceHMIWithMobileAppId(message)) { LOG4CXX_ERROR(logger_, "Substitution HMI --> mobile id is failed."); diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index 870ff532da..a3a30ddb20 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc @@ -741,8 +741,8 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( SendChangeRegistrationOnHMI(application); } -// DEPRECATED -void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() { +DEPRECATED void +RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() { SendRegisterAppInterfaceResponseToMobile(ApplicationType::kNewApplication); } diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index f67de7a957..bc1ccd8f42 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -56,10 +56,9 @@ HmiState::HmiState(utils::SharedPtr app, , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) , system_context_(mobile_apis::SystemContext::INVALID_ENUM) {} -// DEPRECATED -HmiState::HmiState(uint32_t app_id, - const ApplicationManager& app_mngr, - StateID state_id) +DEPRECATED HmiState::HmiState(uint32_t app_id, + const ApplicationManager& app_mngr, + StateID state_id) : state_id_(state_id) , app_mngr_(app_mngr) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) @@ -68,8 +67,8 @@ HmiState::HmiState(uint32_t app_id, app_ = app_mngr_.application(app_id); } -// DEPRECATED -HmiState::HmiState(uint32_t app_id, const ApplicationManager& app_mngr) +DEPRECATED HmiState::HmiState(uint32_t app_id, + const ApplicationManager& app_mngr) : state_id_(STATE_ID_REGULAR) , app_mngr_(app_mngr) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) @@ -109,16 +108,16 @@ VRHmiState::VRHmiState(utils::SharedPtr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_VR_SESSION) {} -// DEPRECATED -VRHmiState::VRHmiState(uint32_t app_id, const ApplicationManager& app_mngr) +DEPRECATED VRHmiState::VRHmiState(uint32_t app_id, + const ApplicationManager& app_mngr) : HmiState(app_id, app_mngr, STATE_ID_VR_SESSION) {} TTSHmiState::TTSHmiState(utils::SharedPtr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_TTS_SESSION) {} -// DEPRECATED -TTSHmiState::TTSHmiState(uint32_t app_id, const ApplicationManager& app_mngr) +DEPRECATED TTSHmiState::TTSHmiState(uint32_t app_id, + const ApplicationManager& app_mngr) : HmiState(app_id, app_mngr, STATE_ID_TTS_SESSION) {} mobile_apis::AudioStreamingState::eType TTSHmiState::audio_streaming_state() @@ -140,9 +139,8 @@ NaviStreamingHmiState::NaviStreamingHmiState(utils::SharedPtr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_NAVI_STREAMING) {} -// DEPRECATED -NaviStreamingHmiState::NaviStreamingHmiState(uint32_t app_id, - const ApplicationManager& app_mngr) +DEPRECATED NaviStreamingHmiState::NaviStreamingHmiState( + uint32_t app_id, const ApplicationManager& app_mngr) : HmiState(app_id, app_mngr, STATE_ID_NAVI_STREAMING) {} mobile_apis::AudioStreamingState::eType @@ -165,9 +163,8 @@ PhoneCallHmiState::PhoneCallHmiState(utils::SharedPtr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_PHONE_CALL) {} -// DEPRECATED -PhoneCallHmiState::PhoneCallHmiState(uint32_t app_id, - const ApplicationManager& app_mngr) +DEPRECATED PhoneCallHmiState::PhoneCallHmiState( + uint32_t app_id, const ApplicationManager& app_mngr) : HmiState(app_id, app_mngr, STATE_ID_PHONE_CALL) {} mobile_apis::HMILevel::eType PhoneCallHmiState::hmi_level() const { @@ -191,18 +188,16 @@ SafetyModeHmiState::SafetyModeHmiState(utils::SharedPtr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_SAFETY_MODE) {} -// DEPRECATED -SafetyModeHmiState::SafetyModeHmiState(uint32_t app_id, - const ApplicationManager& app_mngr) +DEPRECATED SafetyModeHmiState::SafetyModeHmiState( + uint32_t app_id, const ApplicationManager& app_mngr) : HmiState(app_id, app_mngr, STATE_ID_SAFETY_MODE) {} DeactivateHMI::DeactivateHMI(utils::SharedPtr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_DEACTIVATE_HMI) {} -// DERECATED -DeactivateHMI::DeactivateHMI(uint32_t app_id, - const ApplicationManager& app_mngr) +DEPRECATED DeactivateHMI::DeactivateHMI(uint32_t app_id, + const ApplicationManager& app_mngr) : HmiState(app_id, app_mngr, STATE_ID_DEACTIVATE_HMI) {} mobile_apis::HMILevel::eType DeactivateHMI::hmi_level() const { @@ -220,8 +215,8 @@ AudioSource::AudioSource(utils::SharedPtr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_AUDIO_SOURCE) {} -// DEPRECATED -AudioSource::AudioSource(uint32_t app_id, const ApplicationManager& app_mngr) +DEPRECATED AudioSource::AudioSource(uint32_t app_id, + const ApplicationManager& app_mngr) : HmiState(app_id, app_mngr, STATE_ID_AUDIO_SOURCE) {} mobile_apis::HMILevel::eType AudioSource::hmi_level() const { @@ -245,8 +240,8 @@ EmbeddedNavi::EmbeddedNavi(utils::SharedPtr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_EMBEDDED_NAVI) {} -// DEPRECATED -EmbeddedNavi::EmbeddedNavi(uint32_t app_id, const ApplicationManager& app_mngr) +DEPRECATED EmbeddedNavi::EmbeddedNavi(uint32_t app_id, + const ApplicationManager& app_mngr) : HmiState(app_id, app_mngr, STATE_ID_EMBEDDED_NAVI) {} mobile_apis::HMILevel::eType EmbeddedNavi::hmi_level() const { 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 bd439e05bc..b031fd0afd 100644 --- a/src/components/application_manager/src/resumption/resumption_data_db.cc +++ b/src/components/application_manager/src/resumption/resumption_data_db.cc @@ -212,8 +212,7 @@ uint32_t ResumptionDataDB::GetHMIApplicationID( return hmi_app_id; } -// DEPRECATED -void ResumptionDataDB::OnSuspend() {} +DEPRECATED void ResumptionDataDB::OnSuspend() {} void ResumptionDataDB::IncrementIgnOffCount() { LOG4CXX_AUTO_TRACE(logger_); @@ -294,8 +293,7 @@ bool ResumptionDataDB::GetHashId(const std::string& policy_app_id, return SelectHashId(policy_app_id, device_id, hash_id); } -// DEPRECATED -void ResumptionDataDB::OnAwake() {} +DEPRECATED void ResumptionDataDB::OnAwake() {} void ResumptionDataDB::DecrementIgnOffCount() { LOG4CXX_AUTO_TRACE(logger_); 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 5bbf36dfdd..e99d8bae26 100644 --- a/src/components/application_manager/src/resumption/resumption_data_json.cc +++ b/src/components/application_manager/src/resumption/resumption_data_json.cc @@ -143,8 +143,7 @@ uint32_t ResumptionDataJson::GetHMIApplicationID( return hmi_app_id; } -// DEPRECATED -void ResumptionDataJson::OnSuspend() {} +DEPRECATED void ResumptionDataJson::OnSuspend() {} void ResumptionDataJson::IncrementIgnOffCount() { using namespace app_mngr; @@ -170,8 +169,7 @@ void ResumptionDataJson::IncrementIgnOffCount() { LOG4CXX_DEBUG(logger_, GetResumptionData().toStyledString()); } -// DEPRECATED -void ResumptionDataJson::OnAwake() {} +DEPRECATED void ResumptionDataJson::OnAwake() {} void ResumptionDataJson::DecrementIgnOffCount() { using namespace app_mngr; -- cgit v1.2.1 From ad04121909b2de7d625acd8ec4aff390b39196aa Mon Sep 17 00:00:00 2001 From: JackLivio Date: Sat, 20 Jan 2018 16:22:50 -0500 Subject: Get dbus to compile --- .../src/commands/mobile/get_vehicle_data_request.cc | 2 +- .../src/commands/mobile/unsubscribe_vehicle_data_request.cc | 10 +++++++++- .../application_manager/src/message_helper/message_helper.cc | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc index 25e2da3eb6..46ef221d89 100644 --- a/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc +++ b/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc @@ -57,7 +57,7 @@ void GetVehicleDataRequest::Run() { int32_t app_id = (*message_)[strings::params][strings::connection_key].asUInt(); - ApplicationSharedPtr app = appplication_manager.application(app_id); + ApplicationSharedPtr app = application_manager_.application(app_id); if (!app) { LOG4CXX_ERROR(logger_, "NULL pointer"); diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc index fa3a9ad400..739135d19e 100644 --- a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc +++ b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc @@ -251,6 +251,14 @@ void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { return; } + ApplicationSharedPtr app = + application_manager_.application(CommandRequestImpl::connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer."); + return; + } + #ifdef HMI_DBUS_API for (HmiRequests::iterator it = hmi_requests_.begin(); it != hmi_requests_.end(); @@ -306,7 +314,7 @@ void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { } SendResponse(any_arg_success, status, NULL, &response_params); if (true == any_arg_success) { - UpdateHash(); + app->UpdateHash(); } } #else diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 65f4c79fa6..40afa5822c 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -850,7 +850,7 @@ smart_objects::SmartObjectList MessageHelper::GetIVISubscriptionRequests( if (true == msg_params.keyExists(sr.str) && true == msg_params[sr.str].asBool()) { smart_objects::SmartObjectSPtr request = - MessageHelper::CreateModuleInfoSO(sr.func_id); + MessageHelper::CreateModuleInfoSO(sr.func_id, app_mngr); (*request)[strings::msg_params] = msg_params; hmi_requests.push_back(request); } -- cgit v1.2.1 From dfabf1fa94c897e6ff853a6217f5b6484f6658fd Mon Sep 17 00:00:00 2001 From: AKalinich-Luxoft Date: Fri, 22 Dec 2017 15:30:03 +0200 Subject: Added overriden functions for SecurityManager listeners --- .../application_manager/src/application_manager_impl.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index eb3313e492..da11a4ac5b 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1655,6 +1655,12 @@ void ApplicationManagerImpl::OnCertificateUpdateRequired() { GetPolicyHandler().OnPTExchangeNeeded(); } +bool ApplicationManagerImpl::GetPolicyCertificateData(std::string& data) { + LOG4CXX_AUTO_TRACE(logger_); + data = GetPolicyHandler().RetrieveCertificate(); + return true; +} + security_manager::SSLContext::HandshakeContext ApplicationManagerImpl::GetHandshakeContext(uint32_t key) const { LOG4CXX_AUTO_TRACE(logger_); @@ -1666,6 +1672,15 @@ ApplicationManagerImpl::GetHandshakeContext(uint32_t key) const { } return SSLContext::HandshakeContext(); } + +bool ApplicationManagerImpl::CheckAppIsNavi(const uint32_t app_id) { + LOG4CXX_AUTO_TRACE(logger_); + ApplicationSharedPtr app = application(app_id); + if (app) { + return app->is_navi(); + } + return false; +} #endif // ENABLE_SECURITY void ApplicationManagerImpl::set_hmi_message_handler( -- cgit v1.2.1 From 4ce09f81793c0a2df3826e412831a1ddd0a5ce54 Mon Sep 17 00:00:00 2001 From: AKalinich-Luxoft Date: Tue, 26 Dec 2017 18:25:27 +0200 Subject: Minor refactoring in protocol and security manager Added consts for some methods. Fixed typos in description. Renamed some non informative variables names. --- src/components/application_manager/src/application_manager_impl.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index da11a4ac5b..96e8a1314b 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1655,7 +1655,7 @@ void ApplicationManagerImpl::OnCertificateUpdateRequired() { GetPolicyHandler().OnPTExchangeNeeded(); } -bool ApplicationManagerImpl::GetPolicyCertificateData(std::string& data) { +bool ApplicationManagerImpl::GetPolicyCertificateData(std::string& data) const { LOG4CXX_AUTO_TRACE(logger_); data = GetPolicyHandler().RetrieveCertificate(); return true; @@ -1673,7 +1673,7 @@ ApplicationManagerImpl::GetHandshakeContext(uint32_t key) const { return SSLContext::HandshakeContext(); } -bool ApplicationManagerImpl::CheckAppIsNavi(const uint32_t app_id) { +bool ApplicationManagerImpl::CheckAppIsNavi(const uint32_t app_id) const { LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = application(app_id); if (app) { -- cgit v1.2.1 From 29a39d9ea0dc3bdbca571c6c64fc0b2e16d45698 Mon Sep 17 00:00:00 2001 From: Jacob Keeler Date: Thu, 1 Feb 2018 11:03:54 -0500 Subject: Remove unused iterator --- src/components/application_manager/src/policies/policy_handler.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index e6ebaf3b83..d8c2d3cb5a 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1768,7 +1768,7 @@ void PolicyHandler::OnCertificateUpdated(const std::string& certificate_data) { void PolicyHandler::OnPTUFinished(const bool ptu_result) { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(listeners_lock_); - HandlersCollection::const_iterator it = listeners_.begin(); + std::for_each( listeners_.begin(), listeners_.end(), -- cgit v1.2.1 From 21754a3bde48b47f107830eba6f4e666b140e43a Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 1 Feb 2018 15:04:07 -0500 Subject: Fix deprecated warnings in application_impl and connection_handler_impl --- src/components/application_manager/src/application_impl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 735a9955a7..b58b1fa78d 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -614,7 +614,7 @@ void ApplicationImpl::set_app_allowed(const bool allowed) { is_app_allowed_ = allowed; } -DEPRECATED void ApplicationImpl::set_device( +void ApplicationImpl::set_device( connection_handler::DeviceHandle device) { device_id_ = device; } -- cgit v1.2.1 From 66af017aa02c6c3794bbd17da7b3c9b7bdc99eff Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 1 Feb 2018 16:00:32 -0500 Subject: Fix style issues in project --- src/components/application_manager/src/application_impl.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index b58b1fa78d..115a52eef3 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -614,8 +614,7 @@ void ApplicationImpl::set_app_allowed(const bool allowed) { is_app_allowed_ = allowed; } -void ApplicationImpl::set_device( - connection_handler::DeviceHandle device) { +void ApplicationImpl::set_device(connection_handler::DeviceHandle device) { device_id_ = device; } -- cgit v1.2.1