summaryrefslogtreecommitdiff
path: root/src/components/application_manager/src/commands
diff options
context:
space:
mode:
authorAndrii Kalinich (GitHub) <AKalinich@luxoft.com>2018-05-21 14:48:04 +0300
committerGitHub <noreply@github.com>2018-05-21 14:48:04 +0300
commit1f3a2e49b0b0a6254ca6e8b003784b43bd1488d0 (patch)
tree73c3a081a39495647695dee0c6e926a7b38cec17 /src/components/application_manager/src/commands
parent6212599da217e95899d63d4b33088082489841bd (diff)
parent44e583faf7cbd3f94fc644960bb71f1636aba4fa (diff)
downloadsdl_core-1f3a2e49b0b0a6254ca6e8b003784b43bd1488d0.tar.gz
Merge pull request #2198 from AKalinich-Luxoft/feature/help_promt_manager
Feature help promt manager
Diffstat (limited to 'src/components/application_manager/src/commands')
-rw-r--r--src/components/application_manager/src/commands/command_impl.cc67
-rw-r--r--src/components/application_manager/src/commands/command_request_impl.cc257
-rw-r--r--src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc44
-rw-r--r--src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc16
-rw-r--r--src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc16
-rw-r--r--src/components/application_manager/src/commands/hmi/notification_from_hmi.cc2
-rw-r--r--src/components/application_manager/src/commands/hmi/notification_to_hmi.cc8
-rw-r--r--src/components/application_manager/src/commands/hmi/on_app_unregistered_notification.cc6
-rw-r--r--src/components/application_manager/src/commands/hmi/on_driver_distraction_notification.cc70
-rw-r--r--src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc1
-rw-r--r--src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc5
-rw-r--r--src/components/application_manager/src/commands/hmi/request_from_hmi.cc2
-rw-r--r--src/components/application_manager/src/commands/hmi/request_to_hmi.cc8
-rw-r--r--src/components/application_manager/src/commands/hmi/response_from_hmi.cc2
-rw-r--r--src/components/application_manager/src/commands/hmi/response_to_hmi.cc8
-rw-r--r--src/components/application_manager/src/commands/mobile/add_command_request.cc4
-rw-r--r--src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc2
-rw-r--r--src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc44
-rw-r--r--src/components/application_manager/src/commands/mobile/alert_request.cc30
-rw-r--r--src/components/application_manager/src/commands/mobile/change_registration_request.cc152
-rw-r--r--src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc3
-rw-r--r--src/components/application_manager/src/commands/mobile/delete_command_request.cc10
-rw-r--r--src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc2
-rw-r--r--src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc2
-rw-r--r--src/components/application_manager/src/commands/mobile/dial_number_request.cc2
-rw-r--r--src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc7
-rw-r--r--src/components/application_manager/src/commands/mobile/get_dtcs_request.cc2
-rw-r--r--src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc4
-rw-r--r--src/components/application_manager/src/commands/mobile/get_way_points_request.cc2
-rw-r--r--src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc13
-rw-r--r--src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc123
-rw-r--r--src/components/application_manager/src/commands/mobile/perform_interaction_request.cc25
-rw-r--r--src/components/application_manager/src/commands/mobile/read_did_request.cc2
-rw-r--r--src/components/application_manager/src/commands/mobile/register_app_interface_request.cc116
-rw-r--r--src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc22
-rw-r--r--src/components/application_manager/src/commands/mobile/scrollable_message_request.cc3
-rw-r--r--src/components/application_manager/src/commands/mobile/send_location_request.cc2
-rw-r--r--src/components/application_manager/src/commands/mobile/set_app_icon_request.cc3
-rw-r--r--src/components/application_manager/src/commands/mobile/set_display_layout_request.cc2
-rw-r--r--src/components/application_manager/src/commands/mobile/set_global_properties_request.cc41
-rw-r--r--src/components/application_manager/src/commands/mobile/set_icon_request.cc3
-rw-r--r--src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc2
-rw-r--r--src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc2
-rw-r--r--src/components/application_manager/src/commands/mobile/show_request.cc2
-rw-r--r--src/components/application_manager/src/commands/mobile/slider_request.cc3
-rw-r--r--src/components/application_manager/src/commands/mobile/speak_request.cc3
-rw-r--r--src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc56
-rw-r--r--src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc8
-rw-r--r--src/components/application_manager/src/commands/mobile/system_request.cc17
-rw-r--r--src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc14
-rw-r--r--src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc6
-rw-r--r--src/components/application_manager/src/commands/mobile/update_turn_list_request.cc3
52 files changed, 908 insertions, 341 deletions
diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc
index 0a3e65a790..b928184148 100644
--- a/src/components/application_manager/src/commands/command_impl.cc
+++ b/src/components/application_manager/src/commands/command_impl.cc
@@ -94,25 +94,30 @@ void CommandImpl::SetAllowedToTerminate(const bool allowed) {
allowed_to_terminate_ = allowed;
}
-void CommandImpl::ReplaceMobileByHMIAppId(
+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());
- 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_,
+ "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) {
- ReplaceMobileByHMIAppId(*it);
+ if (!ReplaceMobileWithHMIAppId(*it)) {
+ break;
+ }
}
break;
}
@@ -121,36 +126,51 @@ void CommandImpl::ReplaceMobileByHMIAppId(
std::set<std::string>::const_iterator key = keys.begin();
for (; key != keys.end(); ++key) {
std::string k = *key;
- ReplaceMobileByHMIAppId(message[*key]);
+ if (!ReplaceMobileWithHMIAppId(message[*key])) {
+ break;
+ }
}
break;
}
default: { break; }
}
}
+
+ return true;
+}
+
+DEPRECATED void CommandImpl::ReplaceMobileByHMIAppId(
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& message) {
+ if (!ReplaceMobileWithHMIAppId(message)) {
+ LOG4CXX_ERROR(logger_, "Substitution mobile --> HMI id is failed.");
+ }
}
-void CommandImpl::ReplaceHMIByMobileAppId(
+bool CommandImpl::ReplaceHMIWithMobileAppId(
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_,
+ "ReplaceHMIWithMobileAppId 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);
+ if (!ReplaceHMIWithMobileAppId(*it)) {
+ break;
+ }
}
break;
}
@@ -158,13 +178,24 @@ void CommandImpl::ReplaceHMIByMobileAppId(
std::set<std::string> keys = message.enumerate();
std::set<std::string>::const_iterator key = keys.begin();
for (; key != keys.end(); ++key) {
- ReplaceHMIByMobileAppId(message[*key]);
+ if (!ReplaceHMIWithMobileAppId(message[*key])) {
+ break;
+ }
}
break;
}
default: { break; }
}
}
+
+ return true;
+}
+
+DEPRECATED void CommandImpl::ReplaceHMIByMobileAppId(
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& message) {
+ if (!ReplaceHMIWithMobileAppId(message)) {
+ LOG4CXX_ERROR(logger_, "Substitution HMI --> mobile id is failed.");
+ }
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc
index 3f9a1d13b3..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,8 +31,10 @@
*/
#include <algorithm>
+#include <numeric>
#include <string>
#include "utils/macro.h"
+#include "utils/make_shared.h"
#include "application_manager/commands/command_request_impl.h"
#include "application_manager/application_manager.h"
#include "application_manager/message_helper.h"
@@ -105,20 +107,29 @@ const std::string CreateInfoForUnsupportedResult(
}
bool CheckResultCode(const ResponseInfo& first, const ResponseInfo& second) {
- if (first.is_ok && second.is_unsupported_resource &&
- second.interface_state == HmiInterfaces::STATE_NOT_AVAILABLE) {
+ if (first.is_ok && second.is_unsupported_resource) {
+ return true;
+ }
+ if (first.is_ok && second.is_not_used) {
+ return true;
+ }
+ if (first.is_ok && second.is_ok) {
return true;
}
return false;
}
-bool IsResultCodeUnsupported(const ResponseInfo& first,
- const ResponseInfo& second) {
- return ((first.is_ok || first.is_invalid_enum) &&
- second.is_unsupported_resource) ||
- ((second.is_ok || second.is_invalid_enum) &&
- first.is_unsupported_resource) ||
- (first.is_unsupported_resource && second.is_unsupported_resource);
+bool IsResultCodeWarning(const ResponseInfo& first,
+ const ResponseInfo& second) {
+ const bool first_is_ok_second_is_warn =
+ (first.is_ok || first.is_not_used) &&
+ hmi_apis::Common_Result::WARNINGS == second.result_code;
+
+ const bool both_warnings =
+ hmi_apis::Common_Result::WARNINGS == first.result_code &&
+ hmi_apis::Common_Result::WARNINGS == second.result_code;
+
+ return first_is_ok_second_is_warn || both_warnings;
}
struct DisallowedParamsInserter {
@@ -146,6 +157,42 @@ struct DisallowedParamsInserter {
mobile_apis::VehicleDataResultCode::eType code_;
};
+ResponseInfo::ResponseInfo()
+ : result_code(hmi_apis::Common_Result::INVALID_ENUM)
+ , interface(HmiInterfaces::HMI_INTERFACE_INVALID_ENUM)
+ , interface_state(HmiInterfaces::STATE_NOT_RESPONSE)
+ , is_ok(false)
+ , is_unsupported_resource(false)
+ , is_not_used(false) {}
+
+ResponseInfo::ResponseInfo(const hmi_apis::Common_Result::eType result,
+ const HmiInterfaces::InterfaceID hmi_interface,
+ ApplicationManager& application_manager)
+ : result_code(result)
+ , interface(hmi_interface)
+ , interface_state(HmiInterfaces::STATE_NOT_RESPONSE)
+ , is_ok(false)
+ , is_unsupported_resource(false)
+ , is_not_used(false) {
+ using namespace helpers;
+
+ interface_state =
+ application_manager.hmi_interfaces().GetInterfaceState(hmi_interface);
+
+ is_ok = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ result_code,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::WARNINGS,
+ hmi_apis::Common_Result::WRONG_LANGUAGE,
+ hmi_apis::Common_Result::RETRY,
+ hmi_apis::Common_Result::SAVED);
+
+ is_not_used = hmi_apis::Common_Result::INVALID_ENUM == result_code;
+
+ is_unsupported_resource =
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == result_code;
+}
+
CommandRequestImpl::CommandRequestImpl(const MessageSharedPtr& message,
ApplicationManager& application_manager)
: CommandImpl(message, application_manager)
@@ -193,7 +240,7 @@ void CommandRequestImpl::onTimeOut() {
function_id(),
correlation_id(),
mobile_api::Result::GENERIC_ERROR);
-
+ AddTimeOutComponentInfoToMessage(*response);
application_manager_.ManageMobileCommand(response, ORIGIN_SDL);
}
@@ -204,6 +251,7 @@ void CommandRequestImpl::SendResponse(
const mobile_apis::Result::eType& result_code,
const char* info,
const smart_objects::SmartObject* response_params) {
+ LOG4CXX_AUTO_TRACE(logger_);
{
sync_primitives::AutoLock auto_lock(state_lock_);
if (kTimedOut == current_state_) {
@@ -214,11 +262,9 @@ void CommandRequestImpl::SendResponse(
current_state_ = kCompleted;
}
- smart_objects::SmartObjectSPtr result = new smart_objects::SmartObject;
- if (!result) {
- LOG4CXX_ERROR(logger_, "Memory allocation failed.");
- return;
- }
+ smart_objects::SmartObjectSPtr result =
+ utils::MakeShared<smart_objects::SmartObject>();
+
smart_objects::SmartObject& response = *result;
response[strings::params][strings::message_type] = MessageType::kResponse;
@@ -755,6 +801,7 @@ bool CommandRequestImpl::HasDisallowedParams() const {
bool CommandRequestImpl::PrepareResultForMobileResponse(
hmi_apis::Common_Result::eType result_code,
HmiInterfaces::InterfaceID interface) const {
+ LOG4CXX_AUTO_TRACE(logger_);
using namespace helpers;
if (Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
result_code,
@@ -777,48 +824,9 @@ bool CommandRequestImpl::PrepareResultForMobileResponse(
bool CommandRequestImpl::PrepareResultForMobileResponse(
ResponseInfo& out_first, ResponseInfo& out_second) const {
- using namespace helpers;
-
- out_first.is_ok = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- out_first.result_code,
- hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::WARNINGS,
- hmi_apis::Common_Result::WRONG_LANGUAGE,
- hmi_apis::Common_Result::RETRY,
- hmi_apis::Common_Result::SAVED);
-
- out_second.is_ok = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
- out_second.result_code,
- hmi_apis::Common_Result::SUCCESS,
- hmi_apis::Common_Result::WARNINGS,
- hmi_apis::Common_Result::WRONG_LANGUAGE,
- hmi_apis::Common_Result::RETRY,
- hmi_apis::Common_Result::SAVED);
-
- out_first.is_invalid_enum =
- hmi_apis::Common_Result::INVALID_ENUM == out_first.result_code;
-
- out_second.is_invalid_enum =
- hmi_apis::Common_Result::INVALID_ENUM == out_second.result_code;
-
- out_first.is_unsupported_resource =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == out_first.result_code;
-
- out_second.is_unsupported_resource =
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == out_second.result_code;
-
- out_first.interface_state =
- application_manager_.hmi_interfaces().GetInterfaceState(
- out_first.interface);
- out_second.interface_state =
- application_manager_.hmi_interfaces().GetInterfaceState(
- out_second.interface);
-
- bool result = (out_first.is_ok && out_second.is_ok) ||
- (out_second.is_invalid_enum && out_first.is_ok) ||
- (out_first.is_invalid_enum && out_second.is_ok);
- result = result || CheckResultCode(out_first, out_second);
- result = result || CheckResultCode(out_second, out_first);
+ LOG4CXX_AUTO_TRACE(logger_);
+ bool result = CheckResultCode(out_first, out_second) ||
+ CheckResultCode(out_second, out_first);
return result;
}
@@ -835,25 +843,30 @@ void CommandRequestImpl::GetInfo(
mobile_apis::Result::eType CommandRequestImpl::PrepareResultCodeForResponse(
const ResponseInfo& first, const ResponseInfo& second) {
+ LOG4CXX_AUTO_TRACE(logger_);
mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
- if (IsResultCodeUnsupported(first, second)) {
- result_code = mobile_apis::Result::UNSUPPORTED_RESOURCE;
- } else {
- // If response contains erroneous result code SDL need return erroneus
- // result code.
- hmi_apis::Common_Result::eType first_result =
- hmi_apis::Common_Result::INVALID_ENUM;
- hmi_apis::Common_Result::eType second_result =
- hmi_apis::Common_Result::INVALID_ENUM;
- if (!first.is_unsupported_resource) {
- first_result = first.result_code;
- }
- if (!second.is_unsupported_resource) {
- second_result = second.result_code;
- }
- result_code =
- MessageHelper::HMIToMobileResult(std::max(first_result, second_result));
- }
+ if (IsResultCodeUnsupported(first, second) ||
+ IsResultCodeUnsupported(second, first)) {
+ return mobile_apis::Result::UNSUPPORTED_RESOURCE;
+ }
+ if (IsResultCodeWarning(first, second) ||
+ IsResultCodeWarning(second, first)) {
+ return mobile_apis::Result::WARNINGS;
+ }
+ // If response contains erroneous result code SDL need return erroneus
+ // result code.
+ hmi_apis::Common_Result::eType first_result =
+ hmi_apis::Common_Result::INVALID_ENUM;
+ hmi_apis::Common_Result::eType second_result =
+ hmi_apis::Common_Result::INVALID_ENUM;
+ if (!first.is_unsupported_resource) {
+ first_result = first.result_code;
+ }
+ if (!second.is_unsupported_resource) {
+ second_result = second.result_code;
+ }
+ result_code =
+ MessageHelper::HMIToMobileResult(std::max(first_result, second_result));
return result_code;
}
@@ -862,6 +875,100 @@ const CommandParametersPermissions& CommandRequestImpl::parameters_permissions()
return parameters_permissions_;
}
+void CommandRequestImpl::StartAwaitForInterface(
+ const HmiInterfaces::InterfaceID interface_id) {
+ sync_primitives::AutoLock lock(awaiting_response_interfaces_lock_);
+ awaiting_response_interfaces_.insert(interface_id);
+}
+
+bool CommandRequestImpl::IsInterfaceAwaited(
+ const HmiInterfaces::InterfaceID& interface_id) const {
+ sync_primitives::AutoLock lock(awaiting_response_interfaces_lock_);
+ std::set<HmiInterfaces::InterfaceID>::const_iterator it =
+ awaiting_response_interfaces_.find(interface_id);
+ return (it != awaiting_response_interfaces_.end());
+}
+
+void CommandRequestImpl::EndAwaitForInterface(
+ const HmiInterfaces::InterfaceID& interface_id) {
+ sync_primitives::AutoLock lock(awaiting_response_interfaces_lock_);
+ std::set<HmiInterfaces::InterfaceID>::const_iterator it =
+ awaiting_response_interfaces_.find(interface_id);
+ if (it != awaiting_response_interfaces_.end()) {
+ awaiting_response_interfaces_.erase(it);
+ } else {
+ LOG4CXX_WARN(logger_,
+ "EndAwaitForInterface called on interface \
+ which was not put into await state: "
+ << interface_id);
+ }
+}
+
+bool CommandRequestImpl::IsResultCodeUnsupported(
+ const ResponseInfo& first, const ResponseInfo& second) const {
+ const bool first_ok_second_unsupported =
+ (first.is_ok || first.is_not_used) && second.is_unsupported_resource;
+ const bool both_unsupported =
+ first.is_unsupported_resource && second.is_unsupported_resource;
+ return first_ok_second_unsupported || both_unsupported;
+}
+
+std::string GetComponentNameFromInterface(
+ const HmiInterfaces::InterfaceID& interface) {
+ switch (interface) {
+ case HmiInterfaces::HMI_INTERFACE_Buttons:
+ return "Buttons";
+ case HmiInterfaces::HMI_INTERFACE_BasicCommunication:
+ return "BasicCommunication";
+ case HmiInterfaces::HMI_INTERFACE_VR:
+ return "VR";
+ case HmiInterfaces::HMI_INTERFACE_TTS:
+ return "TTS";
+ case HmiInterfaces::HMI_INTERFACE_UI:
+ return "UI";
+ case HmiInterfaces::HMI_INTERFACE_Navigation:
+ return "Navigation";
+ case HmiInterfaces::HMI_INTERFACE_VehicleInfo:
+ return "VehicleInfo";
+ case HmiInterfaces::HMI_INTERFACE_SDL:
+ return "SDL";
+ default:
+ return "Unknown type";
+ }
+}
+
+const std::string InfoInterfaceSeparator(
+ const std::string& sum, const HmiInterfaces::InterfaceID container_value) {
+ return sum.empty()
+ ? GetComponentNameFromInterface(container_value)
+ : sum + ", " + GetComponentNameFromInterface(container_value);
+}
+
+void CommandRequestImpl::AddTimeOutComponentInfoToMessage(
+ smart_objects::SmartObject& response) const {
+ using NsSmartDeviceLink::NsSmartObjects::SmartObject;
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock lock(awaiting_response_interfaces_lock_);
+ if (awaiting_response_interfaces_.empty()) {
+ LOG4CXX_ERROR(logger_, "No interfaces awaiting, info param is empty");
+ return;
+ }
+
+ const std::string not_responding_interfaces_string =
+ std::accumulate(awaiting_response_interfaces_.begin(),
+ awaiting_response_interfaces_.end(),
+ std::string(""),
+ InfoInterfaceSeparator);
+ LOG4CXX_DEBUG(
+ logger_,
+ "Not responding interfaces string: " << not_responding_interfaces_string);
+ if (!not_responding_interfaces_string.empty()) {
+ const std::string component_info =
+ not_responding_interfaces_string + " component does not respond";
+ response[strings::msg_params][strings::info] = component_info;
+ }
+}
+
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc b/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc
index 80b1edb5bb..c6c550a474 100644
--- a/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc
+++ b/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Ford Motor Company
+ * Copyright (c) 2017, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,3 +29,45 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
+
+#include "application_manager/commands/hmi/basic_communication_on_awake_sdl.h"
+#include "application_manager/message_helper.h"
+#include "application_manager/resumption/resume_ctrl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+OnAwakeSDLNotification::OnAwakeSDLNotification(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : NotificationFromHMI(message, application_manager) {}
+
+OnAwakeSDLNotification::~OnAwakeSDLNotification() {}
+
+void OnAwakeSDLNotification::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (!application_manager_.resume_controller().is_suspended()) {
+ return;
+ }
+
+ {
+ DataAccessor<ApplicationSet> accessor = application_manager_.applications();
+ ApplicationSetIt itBegin = accessor.GetData().begin();
+ ApplicationSetIt itEnd = accessor.GetData().end();
+ for (; itBegin != itEnd; ++itBegin) {
+ const ApplicationSharedPtr app = *itBegin;
+ if (app && app->IsHashChangedDuringSuspend()) {
+ MessageHelper::SendHashUpdateNotification(app->app_id(),
+ application_manager_);
+ app->SetHashChangedDuringSuspend(false);
+ }
+ }
+ }
+
+ application_manager_.resume_controller().OnAwake();
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc
index 0bcb26df8a..42b8c64fc0 100644
--- a/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc
+++ b/src/components/application_manager/src/commands/hmi/navi_audio_start_stream_request.cc
@@ -109,6 +109,8 @@ void AudioStartStreamRequest::on_event(const event_engine::Event& event) {
logger_,
"StartAudioStreamRequest aborted. Application can not stream");
}
+ application_manager_.TerminateRequest(
+ connection_key(), correlation_id(), function_id());
break;
}
if (hmi_apis::Common_Result::REJECTED == code) {
@@ -125,15 +127,16 @@ void AudioStartStreamRequest::on_event(const event_engine::Event& event) {
}
void AudioStartStreamRequest::onTimeOut() {
+ LOG4CXX_AUTO_TRACE(logger_);
RetryStartSession();
-
- application_manager_.TerminateRequest(
- connection_key(), correlation_id(), function_id());
}
void AudioStartStreamRequest::RetryStartSession() {
LOG4CXX_AUTO_TRACE(logger_);
+ application_manager_.TerminateRequest(
+ connection_key(), correlation_id(), function_id());
+
ApplicationSharedPtr app =
application_manager_.application_by_hmi_app(application_id());
if (!app) {
@@ -156,10 +159,11 @@ void AudioStartStreamRequest::RetryStartSession() {
}
uint32_t curr_retry_number = app->audio_stream_retry_number();
+ LOG4CXX_DEBUG(
+ logger_, "Retry number " << curr_retry_number << " of " << retry_number_);
+
if (curr_retry_number < retry_number_) {
- LOG4CXX_DEBUG(
- logger_,
- "Send AudioStartStream retry. retry_number = " << curr_retry_number);
+ LOG4CXX_DEBUG(logger_, "Send AudioStartStream retry");
MessageHelper::SendAudioStartStream(app->app_id(), application_manager_);
app->set_audio_stream_retry_number(++curr_retry_number);
} else {
diff --git a/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc b/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc
index b06c69e703..ffc325b5e4 100644
--- a/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc
+++ b/src/components/application_manager/src/commands/hmi/navi_start_stream_request.cc
@@ -109,6 +109,8 @@ void NaviStartStreamRequest::on_event(const event_engine::Event& event) {
logger_,
"NaviStartStreamRequest aborted. Application can not stream");
}
+ application_manager_.TerminateRequest(
+ connection_key(), correlation_id(), function_id());
break;
}
if (hmi_apis::Common_Result::REJECTED == code) {
@@ -125,15 +127,16 @@ void NaviStartStreamRequest::on_event(const event_engine::Event& event) {
}
void NaviStartStreamRequest::onTimeOut() {
+ LOG4CXX_AUTO_TRACE(logger_);
RetryStartSession();
-
- application_manager_.TerminateRequest(
- connection_key(), correlation_id(), function_id());
}
void NaviStartStreamRequest::RetryStartSession() {
LOG4CXX_AUTO_TRACE(logger_);
+ application_manager_.TerminateRequest(
+ connection_key(), correlation_id(), function_id());
+
ApplicationSharedPtr app =
application_manager_.application_by_hmi_app(application_id());
if (!app) {
@@ -156,10 +159,11 @@ void NaviStartStreamRequest::RetryStartSession() {
}
uint32_t curr_retry_number = app->video_stream_retry_number();
+ LOG4CXX_DEBUG(
+ logger_, "Retry number " << curr_retry_number << " of " << retry_number_);
+
if (curr_retry_number < retry_number_) {
- LOG4CXX_DEBUG(
- logger_,
- "Send NaviStartStream retry. retry_number = " << curr_retry_number);
+ LOG4CXX_DEBUG(logger_, "Send NaviStartStream retry");
MessageHelper::SendNaviStartStream(app->app_id(), application_manager_);
app->set_video_stream_retry_number(++curr_retry_number);
} else {
diff --git a/src/components/application_manager/src/commands/hmi/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 f1e933b7ef..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.get()));
-}
+ : 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/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/on_driver_distraction_notification.cc b/src/components/application_manager/src/commands/hmi/on_driver_distraction_notification.cc
index 4c322c456f..a895d353ce 100644
--- a/src/components/application_manager/src/commands/hmi/on_driver_distraction_notification.cc
+++ b/src/components/application_manager/src/commands/hmi/on_driver_distraction_notification.cc
@@ -34,8 +34,10 @@
#include "application_manager/commands/hmi/on_driver_distraction_notification.h"
#include "application_manager/application_impl.h"
+#include "application_manager/message_helper.h"
#include "interfaces/MOBILE_API.h"
#include "interfaces/HMI_API.h"
+#include "utils/make_shared.h"
namespace application_manager {
@@ -43,6 +45,53 @@ namespace commands {
namespace hmi {
+namespace {
+struct OnDriverDistractionProcessor {
+ OnDriverDistractionProcessor(
+ OnDriverDistractionNotification& command,
+ smart_objects::SmartObjectSPtr on_driver_distraction_so,
+ ApplicationManager& application_manager)
+ : command_(command)
+ , on_driver_distraction_so_(on_driver_distraction_so)
+ , application_manager_(application_manager)
+ , stringified_function_id_(MessageHelper::StringifiedFunctionID(
+ mobile_api::FunctionID::OnDriverDistractionID)) {}
+
+ void operator()(ApplicationSharedPtr application) {
+ if (application) {
+ (*on_driver_distraction_so_)[strings::params][strings::connection_key] =
+ application->app_id();
+ const RPCParams params;
+ policy::CheckPermissionResult result;
+ application_manager_.GetPolicyHandler().CheckPermissions(
+ application, stringified_function_id_, params, result);
+ if (result.hmi_level_permitted != policy::kRpcAllowed) {
+ MobileMessageQueue messages;
+ application->SwapMobileMessageQueue(messages);
+ messages.erase(
+ std::remove_if(
+ messages.begin(),
+ messages.end(),
+ [this](smart_objects::SmartObjectSPtr message) {
+ return (*message)[strings::params][strings::function_id]
+ .asString() == stringified_function_id_;
+ }),
+ messages.end());
+ application->PushMobileMessage(on_driver_distraction_so_);
+ return;
+ }
+ command_.SendNotificationToMobile(on_driver_distraction_so_);
+ }
+ }
+
+ private:
+ OnDriverDistractionNotification& command_;
+ smart_objects::SmartObjectSPtr on_driver_distraction_so_;
+ ApplicationManager& application_manager_;
+ std::string stringified_function_id_;
+};
+}
+
OnDriverDistractionNotification::OnDriverDistractionNotification(
const MessageSharedPtr& message, ApplicationManager& application_manager)
: NotificationFromHMI(message, application_manager) {}
@@ -51,38 +100,31 @@ OnDriverDistractionNotification::~OnDriverDistractionNotification() {}
void OnDriverDistractionNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-
const hmi_apis::Common_DriverDistractionState::eType state =
static_cast<hmi_apis::Common_DriverDistractionState::eType>(
(*message_)[strings::msg_params][hmi_notification::state].asInt());
- application_manager_.set_driver_distraction(state);
+ application_manager_.set_driver_distraction_state(state);
smart_objects::SmartObjectSPtr on_driver_distraction =
- new smart_objects::SmartObject();
+ utils::MakeShared<smart_objects::SmartObject>();
if (!on_driver_distraction) {
LOG4CXX_ERROR(logger_, "NULL pointer");
return;
}
-
(*on_driver_distraction)[strings::params][strings::function_id] =
mobile_api::FunctionID::OnDriverDistractionID;
-
+ (*on_driver_distraction)[strings::params][strings::message_type] =
+ static_cast<int32_t>(application_manager::MessageType::kNotification);
(*on_driver_distraction)[strings::msg_params][mobile_notification::state] =
state;
const ApplicationSet applications =
application_manager_.applications().GetData();
- ApplicationSetConstIt it = applications.begin();
- for (; applications.end() != it; ++it) {
- const ApplicationSharedPtr app = *it;
- if (app) {
- (*on_driver_distraction)[strings::params][strings::connection_key] =
- app->app_id();
- SendNotificationToMobile(on_driver_distraction);
- }
- }
+ OnDriverDistractionProcessor processor(
+ *this, on_driver_distraction, application_manager_);
+ std::for_each(applications.begin(), applications.end(), processor);
}
} // namespace hmi
diff --git a/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc b/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc
index 07a95adcea..cb68b21263 100644
--- a/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc
+++ b/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc
@@ -75,6 +75,7 @@ void OnExitAllApplicationsNotification::Run() {
break;
}
case hmi_apis::Common_ApplicationsCloseReason::SUSPEND: {
+ application_manager_.resume_controller().OnSuspend();
SendOnSDLPersistenceComplete();
return;
}
diff --git a/src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc
index 5383876714..bba7e2f3ff 100644
--- a/src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc
+++ b/src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc
@@ -53,8 +53,9 @@ void OnVIVehicleDataNotification::Run() {
const smart_objects::SmartObject& msg_params =
(*message_)[strings::msg_params];
if (msg_params.keyExists(strings::odometer)) {
- application_manager_.IviInfoUpdated(ODOMETER,
- msg_params[strings::odometer].asInt());
+ application_manager_.IviInfoUpdated(
+ mobile_apis::VehicleDataType::VEHICLEDATA_ODOMETER,
+ msg_params[strings::odometer].asInt());
}
SendNotificationToMobile(message_);
diff --git a/src/components/application_manager/src/commands/hmi/request_from_hmi.cc b/src/components/application_manager/src/commands/hmi/request_from_hmi.cc
index 1119e7c4fd..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.get()));
+ 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 39d549ac72..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.get()));
-}
+ : 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 23d8e6e229..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.get()));
+ 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 e6f64047ba..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.get()));
-}
+ : 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/add_command_request.cc b/src/components/application_manager/src/commands/mobile/add_command_request.cc
index c748ddcbb6..69948b8122 100644
--- a/src/components/application_manager/src/commands/mobile/add_command_request.cc
+++ b/src/components/application_manager/src/commands/mobile/add_command_request.cc
@@ -192,10 +192,12 @@ void AddCommandRequest::Run() {
}
if (send_ui_) {
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
SendHMIRequest(hmi_apis::FunctionID::UI_AddCommand, &ui_msg_params, true);
}
if (send_vr_) {
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR);
SendHMIRequest(hmi_apis::FunctionID::VR_AddCommand, &vr_msg_params, true);
}
}
@@ -317,6 +319,7 @@ void AddCommandRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::UI_AddCommand: {
LOG4CXX_INFO(logger_, "Received UI_AddCommand event");
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
is_ui_received_ = true;
ui_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
@@ -328,6 +331,7 @@ void AddCommandRequest::on_event(const event_engine::Event& event) {
}
case hmi_apis::FunctionID::VR_AddCommand: {
LOG4CXX_INFO(logger_, "Received VR_AddCommand event");
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR);
is_vr_received_ = true;
vr_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
diff --git a/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc b/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc
index a5491481dc..fe44e5a41f 100644
--- a/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc
+++ b/src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc
@@ -94,6 +94,7 @@ void AddSubMenuRequest::Run() {
(*message_)[strings::msg_params][strings::menu_name];
msg_params[strings::app_id] = app->app_id();
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
SendHMIRequest(hmi_apis::FunctionID::UI_AddSubMenu, &msg_params, true);
}
@@ -103,6 +104,7 @@ void AddSubMenuRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::UI_AddSubMenu: {
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
hmi_apis::Common_Result::eType result_code =
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
diff --git a/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc
index b151990289..d5767690d7 100644
--- a/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc
+++ b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc
@@ -111,6 +111,7 @@ void AlertManeuverRequest::Run() {
}
pending_requests_.Add(hmi_apis::FunctionID::Navigation_AlertManeuver);
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation);
SendHMIRequest(
hmi_apis::FunctionID::Navigation_AlertManeuver, &msg_params, true);
@@ -123,6 +124,7 @@ void AlertManeuverRequest::Run() {
msg_params[hmi_request::speak_type] =
hmi_apis::Common_MethodName::ALERT_MANEUVER;
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS);
SendHMIRequest(hmi_apis::FunctionID::TTS_Speak, &msg_params, true);
}
}
@@ -134,6 +136,7 @@ void AlertManeuverRequest::on_event(const event_engine::Event& event) {
switch (event_id) {
case hmi_apis::FunctionID::Navigation_AlertManeuver: {
LOG4CXX_INFO(logger_, "Received Navigation_AlertManeuver event");
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation);
pending_requests_.Remove(event_id);
navi_alert_maneuver_result_code_ =
static_cast<hmi_apis::Common_Result::eType>(
@@ -143,6 +146,7 @@ void AlertManeuverRequest::on_event(const event_engine::Event& event) {
}
case hmi_apis::FunctionID::TTS_Speak: {
LOG4CXX_INFO(logger_, "Received TTS_Speak event");
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS);
pending_requests_.Remove(event_id);
tts_speak_result_code_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
@@ -191,10 +195,13 @@ bool AlertManeuverRequest::PrepareResponseParameters(
application_manager::commands::ResponseInfo navigation_alert_info(
navi_alert_maneuver_result_code_,
- HmiInterfaces::HMI_INTERFACE_Navigation);
+ HmiInterfaces::HMI_INTERFACE_Navigation,
+ application_manager_);
application_manager::commands::ResponseInfo tts_alert_info(
- tts_speak_result_code_, HmiInterfaces::HMI_INTERFACE_TTS);
+ tts_speak_result_code_,
+ HmiInterfaces::HMI_INTERFACE_TTS,
+ application_manager_);
const bool result =
PrepareResultForMobileResponse(navigation_alert_info, tts_alert_info);
@@ -216,23 +223,42 @@ bool AlertManeuverRequest::PrepareResponseParameters(
bool AlertManeuverRequest::IsWhiteSpaceExist() {
LOG4CXX_AUTO_TRACE(logger_);
- const char* str = NULL;
+ using smart_objects::SmartArray;
if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) {
- const smart_objects::SmartArray* tc_array =
+ const SmartArray* tts_chunks_arr =
(*message_)[strings::msg_params][strings::tts_chunks].asArray();
- smart_objects::SmartArray::const_iterator it_tc = tc_array->begin();
- smart_objects::SmartArray::const_iterator it_tc_end = tc_array->end();
+ SmartArray::const_iterator it_tts_chunk = tts_chunks_arr->begin();
- for (; it_tc != it_tc_end; ++it_tc) {
- str = (*it_tc)[strings::text].asCharArray();
- if (strlen(str) && !CheckSyntax(str)) {
+ for (; it_tts_chunk != tts_chunks_arr->end(); ++it_tts_chunk) {
+ const char* tts_chunk_text = (*it_tts_chunk)[strings::text].asCharArray();
+ if (strlen(tts_chunk_text) && !CheckSyntax(tts_chunk_text)) {
LOG4CXX_ERROR(logger_, "Invalid tts_chunks syntax check failed");
return true;
}
}
}
+ if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) {
+ DCHECK_OR_RETURN(
+ (*message_)[strings::msg_params][strings::soft_buttons].getType() ==
+ smart_objects::SmartType_Array,
+ true);
+ const smart_objects::SmartArray* soft_button_array =
+ (*message_)[strings::msg_params][strings::soft_buttons].asArray();
+
+ SmartArray::const_iterator it_soft_button = soft_button_array->begin();
+
+ for (; it_soft_button != soft_button_array->end(); ++it_soft_button) {
+ const char* soft_button_text =
+ (*it_soft_button)[strings::text].asCharArray();
+ if (!CheckSyntax(soft_button_text)) {
+ LOG4CXX_ERROR(logger_, "Invalid soft_buttons syntax check failed");
+ return true;
+ }
+ }
+ }
+
return false;
}
diff --git a/src/components/application_manager/src/commands/mobile/alert_request.cc b/src/components/application_manager/src/commands/mobile/alert_request.cc
index 3288870b92..3c42e43767 100644
--- a/src/components/application_manager/src/commands/mobile/alert_request.cc
+++ b/src/components/application_manager/src/commands/mobile/alert_request.cc
@@ -116,18 +116,6 @@ void AlertRequest::Run() {
}
}
-void AlertRequest::onTimeOut() {
- LOG4CXX_AUTO_TRACE(logger_);
- if (false ==
- (*message_)[strings::msg_params].keyExists(strings::soft_buttons)) {
- CommandRequestImpl::onTimeOut();
- return;
- }
- LOG4CXX_INFO(logger_,
- "Default timeout ignored. "
- "AlertRequest with soft buttons wait timeout on HMI side");
-}
-
void AlertRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
const smart_objects::SmartObject& message = event.smart_object();
@@ -148,6 +136,7 @@ void AlertRequest::on_event(const event_engine::Event& event) {
case hmi_apis::FunctionID::UI_Alert: {
LOG4CXX_INFO(logger_, "Received UI_Alert event");
// Unsubscribe from event to avoid unwanted messages
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
unsubscribe_from_event(hmi_apis::FunctionID::UI_Alert);
awaiting_ui_alert_response_ = false;
HmiInterfaces::InterfaceState ui_interface_state =
@@ -157,6 +146,7 @@ void AlertRequest::on_event(const event_engine::Event& event) {
if (awaiting_tts_speak_response_ &&
HmiInterfaces::STATE_NOT_AVAILABLE != ui_interface_state) {
awaiting_tts_stop_speaking_response_ = true;
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS);
SendHMIRequest(hmi_apis::FunctionID::TTS_StopSpeaking, NULL, true);
}
alert_result_ = static_cast<hmi_apis::Common_Result::eType>(
@@ -170,6 +160,7 @@ void AlertRequest::on_event(const event_engine::Event& event) {
case hmi_apis::FunctionID::TTS_Speak: {
LOG4CXX_INFO(logger_, "Received TTS_Speak event");
// Unsubscribe from event to avoid unwanted messages
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS);
unsubscribe_from_event(hmi_apis::FunctionID::TTS_Speak);
awaiting_tts_speak_response_ = false;
tts_speak_result_ = static_cast<hmi_apis::Common_Result::eType>(
@@ -179,6 +170,7 @@ void AlertRequest::on_event(const event_engine::Event& event) {
}
case hmi_apis::FunctionID::TTS_StopSpeaking: {
LOG4CXX_INFO(logger_, "Received TTS_StopSpeaking event");
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS);
// Unsubscribe from event to avoid unwanted messages
unsubscribe_from_event(hmi_apis::FunctionID::TTS_StopSpeaking);
awaiting_tts_stop_speaking_response_ = false;
@@ -204,9 +196,11 @@ void AlertRequest::on_event(const event_engine::Event& event) {
bool AlertRequest::PrepareResponseParameters(
mobile_apis::Result::eType& result_code, std::string& info) {
- ResponseInfo ui_alert_info(alert_result_, HmiInterfaces::HMI_INTERFACE_UI);
+ ResponseInfo ui_alert_info(
+ alert_result_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_);
ResponseInfo tts_alert_info(tts_speak_result_,
- HmiInterfaces::HMI_INTERFACE_TTS);
+ HmiInterfaces::HMI_INTERFACE_TTS,
+ application_manager_);
bool result = PrepareResultForMobileResponse(ui_alert_info, tts_alert_info);
@@ -219,7 +213,7 @@ bool AlertRequest::PrepareResponseParameters(
result = false;
}
result_code = mobile_apis::Result::WARNINGS;
- if ((ui_alert_info.is_ok || ui_alert_info.is_invalid_enum) &&
+ if ((ui_alert_info.is_ok || ui_alert_info.is_not_used) &&
tts_alert_info.is_unsupported_resource &&
HmiInterfaces::STATE_AVAILABLE == tts_alert_info.interface_state) {
tts_response_info_ = "Unsupported phoneme type sent in a prompt";
@@ -230,6 +224,10 @@ bool AlertRequest::PrepareResponseParameters(
result_code = PrepareResultCodeForResponse(ui_alert_info, tts_alert_info);
info = MergeInfos(
ui_alert_info, ui_response_info_, tts_alert_info, tts_response_info_);
+ // Mobile Alert request is successful when UI_Alert is successful
+ if (is_ui_alert_sent_ && !ui_alert_info.is_ok) {
+ return false;
+ }
return result;
}
@@ -346,6 +344,7 @@ void AlertRequest::SendAlertRequest(int32_t app_id) {
msg_params.keyExists(hmi_request::soft_buttons)) {
awaiting_ui_alert_response_ = true;
is_ui_alert_sent_ = true;
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
SendHMIRequest(hmi_apis::FunctionID::UI_Alert, &msg_params, true);
}
}
@@ -370,6 +369,7 @@ void AlertRequest::SendSpeakRequest(int32_t app_id,
}
msg_params[strings::app_id] = app_id;
msg_params[hmi_request::speak_type] = Common_MethodName::ALERT;
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS);
SendHMIRequest(FunctionID::TTS_Speak, &msg_params, true);
}
diff --git a/src/components/application_manager/src/commands/mobile/change_registration_request.cc b/src/components/application_manager/src/commands/mobile/change_registration_request.cc
index f1f3b93e24..f55767c723 100644
--- a/src/components/application_manager/src/commands/mobile/change_registration_request.cc
+++ b/src/components/application_manager/src/commands/mobile/change_registration_request.cc
@@ -66,6 +66,73 @@ ChangeRegistrationRequest::ChangeRegistrationRequest(
ChangeRegistrationRequest::~ChangeRegistrationRequest() {}
+void ChangeRegistrationRequest::SendVRRequest(
+ ApplicationSharedPtr app, smart_objects::SmartObject& msg_params) {
+ const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces();
+ auto function = hmi_apis::FunctionID::VR_ChangeRegistration;
+ pending_requests_.Add(function);
+ smart_objects::SmartObject vr_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ vr_params[strings::language] = msg_params[strings::language];
+
+ vr_params[strings::app_id] = app->app_id();
+ if (msg_params.keyExists(strings::vr_synonyms)) {
+ vr_params[strings::vr_synonyms] = msg_params[strings::vr_synonyms];
+ app->set_vr_synonyms(msg_params[strings::vr_synonyms]);
+ }
+ StartAwaitForInterface(hmi_interfaces.GetInterfaceFromFunction(function));
+ SendHMIRequest(function, &vr_params, true);
+}
+
+void ChangeRegistrationRequest::SendTTSRequest(
+ ApplicationSharedPtr app, smart_objects::SmartObject& msg_params) {
+ const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces();
+ auto function = hmi_apis::FunctionID::TTS_ChangeRegistration;
+ pending_requests_.Add(function);
+
+ smart_objects::SmartObject tts_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ tts_params[strings::language] = msg_params[strings::language];
+
+ tts_params[strings::app_id] = app->app_id();
+ if (msg_params.keyExists(strings::tts_name)) {
+ tts_params[strings::tts_name] = msg_params[strings::tts_name];
+ app->set_tts_name(msg_params[strings::tts_name]);
+ }
+ StartAwaitForInterface(hmi_interfaces.GetInterfaceFromFunction(function));
+ SendHMIRequest(function, &tts_params, true);
+}
+
+void ChangeRegistrationRequest::SendUIRequest(
+ ApplicationSharedPtr app,
+ smart_objects::SmartObject& msg_params,
+ const int32_t hmi_language) {
+ const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces();
+ auto function = hmi_apis::FunctionID::UI_ChangeRegistration;
+ pending_requests_.Add(function);
+ // UI processing
+ smart_objects::SmartObject ui_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ ui_params[strings::language] = hmi_language;
+ ui_params[strings::app_id] = app->app_id();
+ if (msg_params.keyExists(strings::app_name)) {
+ ui_params[strings::app_name] = msg_params[strings::app_name];
+ app->set_name(msg_params[strings::app_name].asCustomString());
+ }
+ if (msg_params.keyExists(strings::ngn_media_screen_app_name)) {
+ ui_params[strings::ngn_media_screen_app_name] =
+ msg_params[strings::ngn_media_screen_app_name];
+ app->set_ngn_media_screen_name(
+ msg_params[strings::ngn_media_screen_app_name]);
+ }
+
+ StartAwaitForInterface(hmi_interfaces.GetInterfaceFromFunction(function));
+ SendHMIRequest(function, &ui_params, true);
+}
+
void ChangeRegistrationRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
using namespace smart_objects;
@@ -111,53 +178,42 @@ void ChangeRegistrationRequest::Run() {
return;
}
- pending_requests_.Add(hmi_apis::FunctionID::UI_ChangeRegistration);
- pending_requests_.Add(hmi_apis::FunctionID::VR_ChangeRegistration);
- pending_requests_.Add(hmi_apis::FunctionID::TTS_ChangeRegistration);
+ const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces();
- // UI processing
- SmartObject ui_params = SmartObject(SmartType_Map);
+ const HmiInterfaces::InterfaceState vr_state =
+ hmi_interfaces.GetInterfaceState(
+ HmiInterfaces::InterfaceID::HMI_INTERFACE_VR);
+ const HmiInterfaces::InterfaceState ui_state =
+ hmi_interfaces.GetInterfaceState(
+ HmiInterfaces::InterfaceID::HMI_INTERFACE_UI);
+ const HmiInterfaces::InterfaceState tts_state =
+ hmi_interfaces.GetInterfaceState(
+ HmiInterfaces::InterfaceID::HMI_INTERFACE_TTS);
- ui_params[strings::language] = hmi_language;
- ui_params[strings::app_id] = app->app_id();
- if (msg_params.keyExists(strings::app_name)) {
- ui_params[strings::app_name] = msg_params[strings::app_name];
- app->set_name(msg_params[strings::app_name].asCustomString());
+ using helpers::Compare;
+ using helpers::EQ;
+ using helpers::ALL;
+
+ if (Compare<HmiInterfaces::InterfaceState, EQ, ALL>(
+ HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE,
+ vr_state,
+ tts_state,
+ ui_state)) {
+ SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE);
+ return;
}
- if (msg_params.keyExists(strings::ngn_media_screen_app_name)) {
- ui_params[strings::ngn_media_screen_app_name] =
- msg_params[strings::ngn_media_screen_app_name];
- app->set_ngn_media_screen_name(
- msg_params[strings::ngn_media_screen_app_name]);
+ if (HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE != vr_state) {
+ // VR processing
+ SendVRRequest(app, msg_params);
}
-
- SendHMIRequest(hmi_apis::FunctionID::UI_ChangeRegistration, &ui_params, true);
-
- // VR processing
- SmartObject vr_params = SmartObject(SmartType_Map);
-
- vr_params[strings::language] = msg_params[strings::language];
-
- vr_params[strings::app_id] = app->app_id();
- if (msg_params.keyExists(strings::vr_synonyms)) {
- vr_params[strings::vr_synonyms] = msg_params[strings::vr_synonyms];
- app->set_vr_synonyms(msg_params[strings::vr_synonyms]);
+ if (HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE != tts_state) {
+ // TTS processing
+ SendTTSRequest(app, msg_params);
}
- SendHMIRequest(hmi_apis::FunctionID::VR_ChangeRegistration, &vr_params, true);
-
- // TTS processing
- SmartObject tts_params = SmartObject(SmartType_Map);
- tts_params[strings::language] = msg_params[strings::language];
-
- tts_params[strings::app_id] = app->app_id();
- if (msg_params.keyExists(strings::tts_name)) {
- tts_params[strings::tts_name] = msg_params[strings::tts_name];
- app->set_tts_name(msg_params[strings::tts_name]);
+ if (HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE != ui_state) {
+ SendUIRequest(app, msg_params, hmi_language);
}
-
- SendHMIRequest(
- hmi_apis::FunctionID::TTS_ChangeRegistration, &tts_params, true);
}
void ChangeRegistrationRequest::on_event(const event_engine::Event& event) {
@@ -169,6 +225,7 @@ void ChangeRegistrationRequest::on_event(const event_engine::Event& event) {
switch (event_id) {
case hmi_apis::FunctionID::UI_ChangeRegistration: {
LOG4CXX_INFO(logger_, "Received UI_ChangeRegistration event");
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
pending_requests_.Remove(event_id);
ui_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
@@ -177,6 +234,7 @@ void ChangeRegistrationRequest::on_event(const event_engine::Event& event) {
}
case hmi_apis::FunctionID::VR_ChangeRegistration: {
LOG4CXX_INFO(logger_, "Received VR_ChangeRegistration event");
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR);
pending_requests_.Remove(event_id);
vr_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
@@ -185,6 +243,7 @@ void ChangeRegistrationRequest::on_event(const event_engine::Event& event) {
}
case hmi_apis::FunctionID::TTS_ChangeRegistration: {
LOG4CXX_INFO(logger_, "Received TTS_ChangeRegistration event");
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS);
pending_requests_.Remove(event_id);
tts_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
@@ -295,12 +354,14 @@ bool ChangeRegistrationRequest::PrepareResponseParameters(
hmi_interfaces.GetInterfaceState(
HmiInterfaces::InterfaceID::HMI_INTERFACE_UI);
- ResponseInfo ui_properties_info(ui_result_, HmiInterfaces::HMI_INTERFACE_UI);
+ ResponseInfo ui_properties_info(
+ ui_result_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_);
- ResponseInfo tts_properties_info(tts_result_,
- HmiInterfaces::HMI_INTERFACE_TTS);
+ ResponseInfo tts_properties_info(
+ tts_result_, HmiInterfaces::HMI_INTERFACE_TTS, application_manager_);
- ResponseInfo vr_properties_info(ui_result_, HmiInterfaces::HMI_INTERFACE_VR);
+ ResponseInfo vr_properties_info(
+ ui_result_, HmiInterfaces::HMI_INTERFACE_VR, application_manager_);
bool result = ((!is_tts_ui_vr_unsupported) && is_tts_succeeded_unsupported &&
is_ui_succeeded_unsupported && is_vr_succeeded_unsupported);
@@ -338,6 +399,9 @@ bool ChangeRegistrationRequest::PrepareResponseParameters(
}
result_code = MessageHelper::HMIToMobileResult(
std::max(std::max(ui_result, vr_result), tts_result));
+ if (mobile_api::Result::INVALID_ENUM == result_code) {
+ result_code = mobile_api::Result::UNSUPPORTED_RESOURCE;
+ }
}
const bool is_tts_state_available =
diff --git a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc
index e1148bd126..20387ef230 100644
--- a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc
+++ b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc
@@ -287,6 +287,7 @@ void CreateInteractionChoiceSetRequest::SendVRAddCommandRequests(
sync_primitives::AutoLock commands_lock(vr_commands_lock_);
const uint32_t vr_cmd_id = msg_params[strings::cmd_id].asUInt();
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR);
const uint32_t vr_corr_id =
SendHMIRequest(hmi_apis::FunctionID::VR_AddCommand, &msg_params, true);
@@ -356,6 +357,7 @@ void CreateInteractionChoiceSetRequest::on_event(
uint32_t corr_id = static_cast<uint32_t>(
message[strings::params][strings::correlation_id].asUInt());
if (event.id() == hmi_apis::FunctionID::VR_AddCommand) {
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR);
{
sync_primitives::AutoLock commands_lock(vr_commands_lock_);
if (is_no_error) {
@@ -376,6 +378,7 @@ void CreateInteractionChoiceSetRequest::onTimeOut() {
if (!error_from_hmi_) {
SendResponse(false, mobile_apis::Result::GENERIC_ERROR);
}
+ CommandRequestImpl::onTimeOut();
DeleteChoices();
// We have to keep request alive until receive all responses from HMI
diff --git a/src/components/application_manager/src/commands/mobile/delete_command_request.cc b/src/components/application_manager/src/commands/mobile/delete_command_request.cc
index cfc8e12144..f894ed452c 100644
--- a/src/components/application_manager/src/commands/mobile/delete_command_request.cc
+++ b/src/components/application_manager/src/commands/mobile/delete_command_request.cc
@@ -104,12 +104,14 @@ void DeleteCommandRequest::Run() {
is_vr_send_ = true;
}
if (is_ui_send_) {
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params, true);
}
if (is_vr_send_) {
// VR params
msg_params[strings::grammar_id] = application->get_grammar_id();
msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command;
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR);
SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params, true);
}
}
@@ -117,8 +119,10 @@ void DeleteCommandRequest::Run() {
bool DeleteCommandRequest::PrepareResponseParameters(
mobile_apis::Result::eType& result_code, std::string& info) {
using namespace helpers;
- ResponseInfo ui_delete_info(ui_result_, HmiInterfaces::HMI_INTERFACE_UI);
- ResponseInfo vr_delete_info(vr_result_, HmiInterfaces::HMI_INTERFACE_VR);
+ ResponseInfo ui_delete_info(
+ ui_result_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_);
+ ResponseInfo vr_delete_info(
+ vr_result_, HmiInterfaces::HMI_INTERFACE_VR, application_manager_);
const bool result =
PrepareResultForMobileResponse(ui_delete_info, vr_delete_info);
@@ -143,6 +147,7 @@ void DeleteCommandRequest::on_event(const event_engine::Event& event) {
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
case hmi_apis::FunctionID::UI_DeleteCommand: {
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
is_ui_received_ = true;
ui_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
@@ -153,6 +158,7 @@ void DeleteCommandRequest::on_event(const event_engine::Event& event) {
break;
}
case hmi_apis::FunctionID::VR_DeleteCommand: {
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR);
is_vr_received_ = true;
vr_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
diff --git a/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc b/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc
index 21c7ecce90..09f3139245 100644
--- a/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc
+++ b/src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc
@@ -74,6 +74,7 @@ void DeleteSubMenuRequest::Run() {
msg_params[strings::menu_id] =
(*message_)[strings::msg_params][strings::menu_id];
msg_params[strings::app_id] = app->app_id();
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
SendHMIRequest(hmi_apis::FunctionID::UI_DeleteSubMenu, &msg_params, true);
}
@@ -143,6 +144,7 @@ void DeleteSubMenuRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::UI_DeleteSubMenu: {
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
hmi_apis::Common_Result::eType result_code =
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
diff --git a/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc b/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc
index 5c5d250026..7704d700f9 100644
--- a/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc
+++ b/src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc
@@ -83,6 +83,7 @@ void DiagnosticMessageRequest::Run() {
// Add app_id for HMI request
(*message_)[strings::msg_params][strings::app_id] = app->app_id();
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo);
SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage,
&(*message_)[strings::msg_params],
true);
@@ -94,6 +95,7 @@ void DiagnosticMessageRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage: {
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo);
hmi_apis::Common_Result::eType result_code =
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
diff --git a/src/components/application_manager/src/commands/mobile/dial_number_request.cc b/src/components/application_manager/src/commands/mobile/dial_number_request.cc
index 64685afe2e..d0ab42e266 100644
--- a/src/components/application_manager/src/commands/mobile/dial_number_request.cc
+++ b/src/components/application_manager/src/commands/mobile/dial_number_request.cc
@@ -87,6 +87,7 @@ void DialNumberRequest::Run() {
(*message_)[strings::msg_params][strings::number].asString();
msg_params[strings::app_id] = application->hmi_app_id();
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_BasicCommunication);
SendHMIRequest(
hmi_apis::FunctionID::BasicCommunication_DialNumber, &msg_params, true);
}
@@ -106,6 +107,7 @@ void DialNumberRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::BasicCommunication_DialNumber: {
LOG4CXX_INFO(logger_, "Received DialNumber event");
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_BasicCommunication);
result_code = CommandRequestImpl::GetMobileResultCode(
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt()));
diff --git a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc
index f67d1f2434..fb168e4256 100644
--- a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc
+++ b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc
@@ -47,6 +47,7 @@ EndAudioPassThruRequest::~EndAudioPassThruRequest() {}
void EndAudioPassThruRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
SendHMIRequest(hmi_apis::FunctionID::UI_EndAudioPassThru, NULL, true);
}
@@ -56,6 +57,7 @@ void EndAudioPassThruRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::UI_EndAudioPassThru: {
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
hmi_apis::Common_Result::eType result_code =
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asUInt());
@@ -64,9 +66,10 @@ void EndAudioPassThruRequest::on_event(const event_engine::Event& event) {
const bool result = PrepareResultForMobileResponse(
result_code, HmiInterfaces::HMI_INTERFACE_UI);
if (result) {
- bool ended_successfully = application_manager_.EndAudioPassThrough();
+ uint32_t app_id = connection_key();
+ bool ended_successfully = application_manager_.EndAudioPassThru(app_id);
if (ended_successfully) {
- application_manager_.StopAudioPassThru(connection_key());
+ application_manager_.StopAudioPassThru(app_id);
}
}
diff --git a/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc b/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc
index d98207c772..88fd07234a 100644
--- a/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc
+++ b/src/components/application_manager/src/commands/mobile/get_dtcs_request.cc
@@ -72,6 +72,7 @@ void GetDTCsRequest::Run() {
msg_params[strings::app_id] = app->app_id();
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo);
SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_GetDTCs, &msg_params, true);
}
@@ -81,6 +82,7 @@ void GetDTCsRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::VehicleInfo_GetDTCs: {
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo);
hmi_apis::Common_Result::eType result_code =
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
diff --git a/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc
index 25e2da3eb6..f81d0a8c2a 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");
@@ -250,6 +250,7 @@ void GetVehicleDataRequest::Run() {
}
}
if (msg_params.length() > min_length_msg_params) {
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo);
SendHMIRequest(
hmi_apis::FunctionID::VehicleInfo_GetVehicleData, &msg_params, true);
return;
@@ -266,6 +267,7 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::VehicleInfo_GetVehicleData: {
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo);
hmi_apis::Common_Result::eType result_code =
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
diff --git a/src/components/application_manager/src/commands/mobile/get_way_points_request.cc b/src/components/application_manager/src/commands/mobile/get_way_points_request.cc
index c313d74d4b..da4ce38646 100644
--- a/src/components/application_manager/src/commands/mobile/get_way_points_request.cc
+++ b/src/components/application_manager/src/commands/mobile/get_way_points_request.cc
@@ -31,6 +31,7 @@ void GetWayPointsRequest::Run() {
msg_params = (*message_)[strings::msg_params];
msg_params[strings::app_id] = app->app_id();
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation);
SendHMIRequest(hmi_apis::FunctionID::Navigation_GetWayPoints,
msg_params.empty() ? NULL : &msg_params,
true);
@@ -48,6 +49,7 @@ void GetWayPointsRequest::on_event(const event_engine::Event& event) {
}
case hmi_apis::FunctionID::Navigation_GetWayPoints: {
LOG4CXX_INFO(logger_, "Received Navigation_GetWayPoints event");
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation);
const hmi_apis::Common_Result::eType result_code =
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
diff --git a/src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc b/src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc
index 5225002652..f408d04955 100644
--- a/src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc
@@ -60,17 +60,8 @@ void OnHMIStatusNotification::Run() {
mobile_apis::HMILevel::eType hmi_level =
static_cast<mobile_apis::HMILevel::eType>(
(*message_)[strings::msg_params][strings::hmi_level].asInt());
- if ((mobile_apis::HMILevel::HMI_BACKGROUND == hmi_level) ||
- (mobile_apis::HMILevel::HMI_NONE == hmi_level)) {
- if (!(app->tts_properties_in_none())) {
- app->set_tts_properties_in_none(true);
- LOG4CXX_INFO(logger_,
- "OnHMIStatusNotification::Send TTS GlobalProperties"
- " with empty array to HMI");
- MessageHelper::SendTTSGlobalProperties(app, false, application_manager_);
- }
- } else if ((mobile_apis::HMILevel::HMI_FULL == hmi_level) ||
- (mobile_apis::HMILevel::HMI_LIMITED == hmi_level)) {
+ if ((mobile_apis::HMILevel::HMI_FULL == hmi_level) ||
+ (mobile_apis::HMILevel::HMI_LIMITED == hmi_level)) {
if (!(app->tts_properties_in_full())) {
app->set_tts_properties_in_full(true);
LOG4CXX_INFO(logger_,
diff --git a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc
index 9f5fd937f9..20076ac50c 100644
--- a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc
+++ b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc
@@ -47,8 +47,6 @@ namespace str = strings;
PerformAudioPassThruRequest::PerformAudioPassThruRequest(
const MessageSharedPtr& message, ApplicationManager& application_manager)
: CommandRequestImpl(message, application_manager)
- , awaiting_tts_speak_response_(false)
- , awaiting_ui_response_(false)
, result_tts_speak_(hmi_apis::Common_Result::INVALID_ENUM)
, result_ui_(hmi_apis::Common_Result::INVALID_ENUM) {
subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout);
@@ -97,7 +95,7 @@ void PerformAudioPassThruRequest::Run() {
// According with new implementation processing of UNSUPPORTE_RESOURCE
// need set flag before sending to hmi
- awaiting_ui_response_ = true;
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
if ((*message_)[str::msg_params].keyExists(str::initial_prompt) &&
(0 < (*message_)[str::msg_params][str::initial_prompt].length())) {
// In case TTS Speak, subscribe on notification
@@ -119,7 +117,7 @@ void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::UI_PerformAudioPassThru: {
LOG4CXX_TRACE(logger_, "Received UI_PerformAudioPassThru");
- awaiting_ui_response_ = false;
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
result_ui_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asUInt());
@@ -142,7 +140,7 @@ void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) {
result_tts_speak_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asUInt());
GetInfo(message, tts_info_);
- awaiting_tts_speak_response_ = false;
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS);
const bool is_tts_speak_success_unsuported =
Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
result_tts_speak_,
@@ -179,36 +177,58 @@ void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) {
return;
}
- std::string return_info;
- mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
- const bool result = PrepareResponseParameters(result_code, return_info);
+ const ResponseParams response_params = PrepareResponseParameters();
- SendResponse(result,
- result_code,
- return_info.empty() ? NULL : return_info.c_str(),
- &(message[strings::msg_params]));
+ SendResponse(
+ response_params.success,
+ response_params.result_code,
+ response_params.info.empty() ? NULL : response_params.info.c_str(),
+ &(message[strings::msg_params]));
}
-bool PerformAudioPassThruRequest::PrepareResponseParameters(
- mobile_apis::Result::eType& result_code, std::string& info) {
+const PerformAudioPassThruRequest::ResponseParams&
+PerformAudioPassThruRequest::PrepareResponseParameters() {
LOG4CXX_AUTO_TRACE(logger_);
- ResponseInfo ui_perform_info(result_ui_, HmiInterfaces::HMI_INTERFACE_UI);
+ ResponseInfo ui_perform_info(
+ result_ui_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_);
ResponseInfo tts_perform_info(result_tts_speak_,
- HmiInterfaces::HMI_INTERFACE_TTS);
- const bool result =
- PrepareResultForMobileResponse(ui_perform_info, tts_perform_info);
+ HmiInterfaces::HMI_INTERFACE_TTS,
+ application_manager_);
+ // Note(dtrunov): According to requirment "WARNINGS, success:true on getting
+ // UNSUPPORTED_RESOURCE for "ttsChunks"
if (ui_perform_info.is_ok && tts_perform_info.is_unsupported_resource &&
HmiInterfaces::STATE_AVAILABLE == tts_perform_info.interface_state) {
- result_code = mobile_apis::Result::WARNINGS;
+ response_params_.result_code = mobile_apis::Result::WARNINGS;
tts_info_ = "Unsupported phoneme type sent in a prompt";
- info = MergeInfos(ui_perform_info, ui_info_, tts_perform_info, tts_info_);
- return result;
+ response_params_.info =
+ MergeInfos(ui_perform_info, ui_info_, tts_perform_info, tts_info_);
+ response_params_.success = true;
+ return response_params_;
}
- result_code = PrepareResultCodeForResponse(ui_perform_info, tts_perform_info);
- info = MergeInfos(ui_perform_info, ui_info_, tts_perform_info, tts_info_);
- return result;
+
+ response_params_.success =
+ PrepareResultForMobileResponse(ui_perform_info, tts_perform_info);
+ if (IsResultCodeUnsupported(ui_perform_info, tts_perform_info)) {
+ response_params_.result_code = mobile_apis::Result::UNSUPPORTED_RESOURCE;
+ } else {
+ AudioPassThruResults results = PrepareAudioPassThruResultCodeForResponse(
+ ui_perform_info, tts_perform_info);
+ response_params_.success = results.second;
+ response_params_.result_code = results.first;
+ }
+ response_params_.info =
+ MergeInfos(ui_perform_info, ui_info_, tts_perform_info, tts_info_);
+
+ return response_params_;
+}
+
+bool PerformAudioPassThruRequest::PrepareResponseParameters(
+ mobile_apis::Result::eType& result_code, std::string& info) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ NOTREACHED();
+ return false;
}
void PerformAudioPassThruRequest::SendSpeakRequest() {
@@ -229,7 +249,7 @@ void PerformAudioPassThruRequest::SendSpeakRequest() {
// app_id
msg_params[strings::app_id] = connection_key();
msg_params[hmi_request::speak_type] = Common_MethodName::AUDIO_PASS_THRU;
- awaiting_tts_speak_response_ = true;
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS);
SendHMIRequest(FunctionID::TTS_Speak, &msg_params, true);
}
@@ -273,6 +293,7 @@ void PerformAudioPassThruRequest::SendPerformAudioPassThruRequest() {
msg_params[str::mute_audio] = true;
}
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
SendHMIRequest(
hmi_apis::FunctionID::UI_PerformAudioPassThru, &msg_params, true);
}
@@ -290,7 +311,8 @@ void PerformAudioPassThruRequest::SendRecordStartNotification() {
void PerformAudioPassThruRequest::StartMicrophoneRecording() {
LOG4CXX_AUTO_TRACE(logger_);
- application_manager_.BeginAudioPassThrough();
+ uint32_t app_id = connection_key();
+ application_manager_.BeginAudioPassThru(app_id);
application_manager_.StartAudioPassThruThread(
connection_key(),
@@ -349,20 +371,61 @@ bool PerformAudioPassThruRequest::IsWhiteSpaceExist() {
void PerformAudioPassThruRequest::FinishTTSSpeak() {
LOG4CXX_AUTO_TRACE(logger_);
- if (application_manager_.EndAudioPassThrough()) {
+ uint32_t app_id = connection_key();
+ if (application_manager_.EndAudioPassThru(app_id)) {
LOG4CXX_DEBUG(logger_, "Stop AudioPassThru.");
- application_manager_.StopAudioPassThru(connection_key());
+ application_manager_.StopAudioPassThru(app_id);
}
- if (!awaiting_tts_speak_response_) {
+ if (!IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_TTS)) {
LOG4CXX_WARN(logger_, "TTS Speak is inactive.");
return;
}
SendHMIRequest(hmi_apis::FunctionID::TTS_StopSpeaking, NULL);
}
+PerformAudioPassThruRequest::AudioPassThruResults
+PerformAudioPassThruRequest::PrepareAudioPassThruResultCodeForResponse(
+ const ResponseInfo& ui_response, const ResponseInfo& tts_response) {
+ mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
+
+ hmi_apis::Common_Result::eType common_result =
+ hmi_apis::Common_Result::INVALID_ENUM;
+ const hmi_apis::Common_Result::eType ui_result = ui_response.result_code;
+ const hmi_apis::Common_Result::eType tts_result = tts_response.result_code;
+ bool result = false;
+
+ if ((ui_result == hmi_apis::Common_Result::SUCCESS) &&
+ (tts_result == hmi_apis::Common_Result::SUCCESS)) {
+ result = true;
+ }
+
+ if ((ui_result == hmi_apis::Common_Result::SUCCESS) &&
+ (tts_result == hmi_apis::Common_Result::INVALID_ENUM)) {
+ result = true;
+ }
+
+ if ((ui_result == hmi_apis::Common_Result::SUCCESS) &&
+ (tts_result != hmi_apis::Common_Result::SUCCESS) &&
+ (tts_result != hmi_apis::Common_Result::INVALID_ENUM)) {
+ common_result = hmi_apis::Common_Result::WARNINGS;
+ result = true;
+ } else if (ui_response.is_ok &&
+ tts_result == hmi_apis::Common_Result::WARNINGS) {
+ common_result = hmi_apis::Common_Result::WARNINGS;
+ result = true;
+ } else if (ui_result == hmi_apis::Common_Result::INVALID_ENUM) {
+ common_result = tts_result;
+ } else {
+ common_result = ui_result;
+ }
+ result_code = MessageHelper::HMIToMobileResult(common_result);
+ return std::make_pair(result_code, result);
+}
+
bool PerformAudioPassThruRequest::IsWaitingHMIResponse() {
LOG4CXX_AUTO_TRACE(logger_);
- return awaiting_tts_speak_response_ || awaiting_ui_response_;
+ return IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_TTS) ||
+ IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_UI);
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc b/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc
index 007440e8e6..68940158b9 100644
--- a/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc
+++ b/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc
@@ -143,11 +143,10 @@ void PerformInteractionRequest::Run() {
}
}
- if (choice_set_id_list_length &&
- (!CheckChoiceIDFromRequest(
- app,
- choice_set_id_list_length,
- msg_params[strings::interaction_choice_set_id_list]))) {
+ if (!CheckChoiceIDFromRequest(
+ app,
+ choice_set_id_list_length,
+ msg_params[strings::interaction_choice_set_id_list])) {
LOG4CXX_ERROR(logger_,
"PerformInteraction has choice sets with "
"duplicated IDs or application does not have choice sets");
@@ -227,6 +226,7 @@ void PerformInteractionRequest::on_event(const event_engine::Event& event) {
}
case hmi_apis::FunctionID::UI_PerformInteraction: {
LOG4CXX_DEBUG(logger_, "Received UI_PerformInteraction event");
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
ui_response_received_ = true;
unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction);
ui_result_code_ = static_cast<hmi_apis::Common_Result::eType>(
@@ -237,6 +237,7 @@ void PerformInteractionRequest::on_event(const event_engine::Event& event) {
}
case hmi_apis::FunctionID::VR_PerformInteraction: {
LOG4CXX_DEBUG(logger_, "Received VR_PerformInteraction");
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR);
vr_response_received_ = true;
unsubscribe_from_event(hmi_apis::FunctionID::VR_PerformInteraction);
vr_result_code_ = static_cast<hmi_apis::Common_Result::eType>(
@@ -392,14 +393,14 @@ void PerformInteractionRequest::ProcessUIResponse(
if (result) {
if (is_pi_warning) {
ui_result_code_ = hmi_apis::Common_Result::WARNINGS;
- ui_info_ = "Unsupported phoneme type was sent in an item";
+ ui_info_ = message[strings::msg_params][strings::info].asString();
if (message.keyExists(strings::params) &&
message[strings::params].keyExists(strings::data)) {
msg_params = message[strings::params][strings::data];
}
} else if (is_pi_unsupported) {
ui_result_code_ = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
- ui_info_ = "Unsupported phoneme type was sent in an item";
+ ui_info_ = message[strings::msg_params][strings::info].asString();
} else if (message.keyExists(strings::msg_params)) {
msg_params = message[strings::msg_params];
}
@@ -503,6 +504,7 @@ void PerformInteractionRequest::SendUIPerformInteractionRequest(
(*message_)[strings::msg_params][hmi_request::interaction_layout]
.asInt();
}
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
SendHMIRequest(
hmi_apis::FunctionID::UI_PerformInteraction, &msg_params, true);
}
@@ -595,6 +597,7 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest(
msg_params[strings::timeout] = default_timeout_;
}
msg_params[strings::app_id] = app->app_id();
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR);
SendHMIRequest(
hmi_apis::FunctionID::VR_PerformInteraction, &msg_params, true);
}
@@ -926,10 +929,10 @@ void PerformInteractionRequest::SendBothModeResponse(
LOG4CXX_AUTO_TRACE(logger_);
mobile_apis::Result::eType perform_interaction_result_code =
mobile_apis::Result::INVALID_ENUM;
- ResponseInfo ui_perform_info(ui_result_code_,
- HmiInterfaces::HMI_INTERFACE_UI);
- ResponseInfo vr_perform_info(vr_result_code_,
- HmiInterfaces::HMI_INTERFACE_VR);
+ ResponseInfo ui_perform_info(
+ ui_result_code_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_);
+ ResponseInfo vr_perform_info(
+ vr_result_code_, HmiInterfaces::HMI_INTERFACE_VR, application_manager_);
const bool result =
PrepareResultForMobileResponse(ui_perform_info, vr_perform_info);
perform_interaction_result_code =
diff --git a/src/components/application_manager/src/commands/mobile/read_did_request.cc b/src/components/application_manager/src/commands/mobile/read_did_request.cc
index 0bf747bde3..c51f545e7e 100644
--- a/src/components/application_manager/src/commands/mobile/read_did_request.cc
+++ b/src/components/application_manager/src/commands/mobile/read_did_request.cc
@@ -87,6 +87,7 @@ void ReadDIDRequest::Run() {
(*message_)[strings::msg_params][strings::ecu_name];
msg_params[strings::did_location] =
(*message_)[strings::msg_params][strings::did_location];
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo);
SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_ReadDID, &msg_params, true);
}
@@ -97,6 +98,7 @@ void ReadDIDRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::VehicleInfo_ReadDID: {
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo);
hmi_apis::Common_Result::eType result_code =
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc
index 5185d9e5a6..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
@@ -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"
@@ -217,6 +218,10 @@ void RegisterAppInterfaceRequest::Run() {
return;
}
+ if (IsApplicationSwitched()) {
+ return;
+ }
+
const std::string mobile_app_id =
(*message_)[strings::msg_params][strings::app_id].asString();
@@ -231,7 +236,13 @@ void RegisterAppInterfaceRequest::Run() {
const smart_objects::SmartObject& msg_params =
(*message_)[strings::msg_params];
- const std::string& policy_app_id = msg_params[strings::app_id].asString();
+ const std::string policy_app_id = msg_params[strings::app_id].asString();
+ std::string new_policy_app_id = policy_app_id;
+ std::transform(policy_app_id.begin(),
+ policy_app_id.end(),
+ new_policy_app_id.begin(),
+ ::tolower);
+ (*message_)[strings::msg_params][strings::app_id] = new_policy_app_id;
if (application_manager_.IsApplicationForbidden(connection_key(),
policy_app_id)) {
@@ -359,7 +370,7 @@ void RegisterAppInterfaceRequest::Run() {
GetPolicyHandler().SetDeviceInfo(device_mac, device_info);
- SendRegisterAppInterfaceResponseToMobile();
+ SendRegisterAppInterfaceResponseToMobile(ApplicationType::kNewApplication);
smart_objects::SmartObjectSPtr so =
GetLockScreenIconUrlNotification(connection_key(), application);
application_manager_.ManageMobileCommand(so, commands::Command::ORIGIN_SDL);
@@ -498,7 +509,8 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params,
hmi_capabilities.rc_supported();
}
-void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
+void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
+ ApplicationType app_type) {
LOG4CXX_AUTO_TRACE(logger_);
smart_objects::SmartObject response_params(smart_objects::SmartType_Map);
@@ -569,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()) {
@@ -593,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<uint32_t>& diag_modes =
application_manager_.get_settings().supported_diag_modes();
if (!diag_modes.empty()) {
@@ -620,6 +629,7 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
++index;
}
}
+
response_params[strings::sdl_version] =
application_manager_.get_settings().sdl_version();
const std::string ccpu_version =
@@ -628,6 +638,27 @@ 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::DeleteApplicationData(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);
@@ -710,6 +741,11 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
SendChangeRegistrationOnHMI(application);
}
+DEPRECATED void
+RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
+ SendRegisterAppInterfaceResponseToMobile(ApplicationType::kNewApplication);
+}
+
void RegisterAppInterfaceRequest::SendChangeRegistration(
const hmi_apis::FunctionID::eType function_id,
const int32_t language,
@@ -1191,6 +1227,56 @@ 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.");
+
+ 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(app_type);
+
+ application_manager_.SendHMIStatusNotification(app);
+
+ application_manager_.OnApplicationSwitched(app);
+
+ return true;
+}
+
policy::PolicyHandlerInterface&
RegisterAppInterfaceRequest::GetPolicyHandler() {
return application_manager_.GetPolicyHandler();
diff --git a/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc b/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc
index 713d50e190..a7c2db0e65 100644
--- a/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc
+++ b/src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc
@@ -46,10 +46,6 @@ namespace commands {
ResetGlobalPropertiesRequest::ResetGlobalPropertiesRequest(
const MessageSharedPtr& message, ApplicationManager& application_manager)
: CommandRequestImpl(message, application_manager)
- , is_ui_send_(false)
- , is_tts_send_(false)
- , is_ui_received_(false)
- , is_tts_received_(false)
, ui_result_(hmi_apis::Common_Result::INVALID_ENUM)
, tts_result_(hmi_apis::Common_Result::INVALID_ENUM) {}
@@ -111,11 +107,11 @@ void ResetGlobalPropertiesRequest::Run() {
if (vr_help_title_items || menu_name || menu_icon ||
is_key_board_properties) {
- is_ui_send_ = true;
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
}
if (timeout_prompt || helpt_promt) {
- is_tts_send_ = true;
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS);
}
app->set_reset_global_properties_active(true);
@@ -245,7 +241,7 @@ void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::UI_SetGlobalProperties: {
LOG4CXX_INFO(logger_, "Received UI_SetGlobalProperties event");
- is_ui_received_ = true;
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
ui_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
GetInfo(message, ui_response_info_);
@@ -253,7 +249,7 @@ void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
}
case hmi_apis::FunctionID::TTS_SetGlobalProperties: {
LOG4CXX_INFO(logger_, "Received TTS_SetGlobalProperties event");
- is_tts_received_ = true;
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS);
tts_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
GetInfo(message, tts_response_info_);
@@ -292,9 +288,10 @@ bool ResetGlobalPropertiesRequest::PrepareResponseParameters(
using namespace helpers;
bool result = false;
- ResponseInfo ui_properties_info(ui_result_, HmiInterfaces::HMI_INTERFACE_UI);
- ResponseInfo tts_properties_info(tts_result_,
- HmiInterfaces::HMI_INTERFACE_TTS);
+ ResponseInfo ui_properties_info(
+ ui_result_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_);
+ ResponseInfo tts_properties_info(
+ tts_result_, HmiInterfaces::HMI_INTERFACE_TTS, application_manager_);
HmiInterfaces::InterfaceState tts_interface_state =
application_manager_.hmi_interfaces().GetInterfaceState(
@@ -321,7 +318,8 @@ bool ResetGlobalPropertiesRequest::PrepareResponseParameters(
}
bool ResetGlobalPropertiesRequest::IsPendingResponseExist() {
- return is_ui_send_ != is_ui_received_ || is_tts_send_ != is_tts_received_;
+ return IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_TTS) ||
+ IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_UI);
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc b/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc
index 0c770953fe..b0b2d5f464 100644
--- a/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc
+++ b/src/components/application_manager/src/commands/mobile/scrollable_message_request.cc
@@ -109,7 +109,7 @@ void ScrollableMessageRequest::Run() {
MessageHelper::SubscribeApplicationToSoftButton(
(*message_)[strings::msg_params], app, function_id());
}
-
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
SendHMIRequest(hmi_apis::FunctionID::UI_ScrollableMessage, &msg_params, true);
}
@@ -126,6 +126,7 @@ void ScrollableMessageRequest::on_event(const event_engine::Event& event) {
}
case hmi_apis::FunctionID::UI_ScrollableMessage: {
LOG4CXX_INFO(logger_, "Received UI_ScrollableMessage event");
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
hmi_apis::Common_Result::eType result_code =
static_cast<hmi_apis::Common_Result::eType>(
diff --git a/src/components/application_manager/src/commands/mobile/send_location_request.cc b/src/components/application_manager/src/commands/mobile/send_location_request.cc
index 9ec4ca3fcc..54664a8771 100644
--- a/src/components/application_manager/src/commands/mobile/send_location_request.cc
+++ b/src/components/application_manager/src/commands/mobile/send_location_request.cc
@@ -125,6 +125,7 @@ void SendLocationRequest::Run() {
SmartObject request_msg_params = SmartObject(smart_objects::SmartType_Map);
request_msg_params = msg_params;
request_msg_params[strings::app_id] = app->hmi_app_id();
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation);
SendHMIRequest(
hmi_apis::FunctionID::Navigation_SendLocation, &request_msg_params, true);
}
@@ -135,6 +136,7 @@ void SendLocationRequest::on_event(const event_engine::Event& event) {
const smart_objects::SmartObject& message = event.smart_object();
if (hmi_apis::FunctionID::Navigation_SendLocation == event.id()) {
LOG4CXX_INFO(logger_, "Received Navigation_SendLocation event");
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation);
const Common_Result::eType result_code = static_cast<Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
std::string response_info;
diff --git a/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc b/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc
index 5afddfb4d0..ee544e956a 100644
--- a/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc
+++ b/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc
@@ -114,7 +114,7 @@ void SetAppIconRequest::Run() {
// for further use in on_event function
(*message_)[strings::msg_params][strings::sync_file_name] =
msg_params[strings::sync_file_name];
-
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
SendHMIRequest(hmi_apis::FunctionID::UI_SetAppIcon, &msg_params, true);
}
@@ -242,6 +242,7 @@ void SetAppIconRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::UI_SetAppIcon: {
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
hmi_apis::Common_Result::eType result_code =
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
diff --git a/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc b/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc
index 984690384a..38b62ce731 100644
--- a/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc
+++ b/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc
@@ -58,6 +58,7 @@ void SetDisplayLayoutRequest::Run() {
}
(*message_)[strings::msg_params][strings::app_id] = app->app_id();
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
SendHMIRequest(hmi_apis::FunctionID::UI_SetDisplayLayout,
&((*message_)[strings::msg_params]),
true);
@@ -70,6 +71,7 @@ void SetDisplayLayoutRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::UI_SetDisplayLayout: {
LOG4CXX_INFO(logger_, "Received UI_SetDisplayLayout event");
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
hmi_apis::Common_Result::eType result_code =
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
diff --git a/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc
index 096c4ed783..75d08f9f26 100644
--- a/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc
+++ b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc
@@ -152,6 +152,9 @@ void SetGlobalPropertiesRequest::Run() {
params[strings::app_id] = app->app_id();
SendUIRequest(params, true);
+
+ auto& help_prompt_manager = app->help_prompt_manager();
+ help_prompt_manager.OnSetGlobalPropertiesReceived(params, false);
} else {
LOG4CXX_DEBUG(logger_, "VRHelp params does not present");
DCHECK_OR_RETURN_VOID(!is_vr_help_title_present && !is_vr_help_present);
@@ -159,15 +162,6 @@ void SetGlobalPropertiesRequest::Run() {
smart_objects::SmartObject params =
smart_objects::SmartObject(smart_objects::SmartType_Map);
- if (ValidateVRHelpTitle(app->vr_help_title())) {
- LOG4CXX_DEBUG(logger_, "App already contains VRHelp data");
- } else {
- if (!PrepareUIRequestDefaultVRHelpData(app, params)) {
- LOG4CXX_ERROR(logger_, "default VRHElp data could not be generated");
- SendResponse(false, mobile_apis::Result::INVALID_DATA);
- return;
- }
- }
PrepareUIRequestMenuAndKeyboardData(app, msg_params, params);
// Preparing data
@@ -197,6 +191,9 @@ void SetGlobalPropertiesRequest::Run() {
params[strings::app_id] = app->app_id();
SendTTSRequest(params, true);
+
+ auto& help_prompt_manager = app->help_prompt_manager();
+ help_prompt_manager.OnSetGlobalPropertiesReceived(params, false);
}
}
@@ -226,21 +223,34 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
using namespace helpers;
const smart_objects::SmartObject& message = event.smart_object();
+ ApplicationSharedPtr application =
+ application_manager_.application(connection_key());
+
switch (event.id()) {
case hmi_apis::FunctionID::UI_SetGlobalProperties: {
LOG4CXX_INFO(logger_, "Received UI_SetGlobalProperties event");
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
is_ui_received_ = true;
ui_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
GetInfo(message, ui_response_info_);
+ if (application.valid()) {
+ auto& help_prompt_manager = application->help_prompt_manager();
+ help_prompt_manager.OnSetGlobalPropertiesReceived(message, true);
+ }
break;
}
case hmi_apis::FunctionID::TTS_SetGlobalProperties: {
LOG4CXX_INFO(logger_, "Received TTS_SetGlobalProperties event");
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS);
is_tts_received_ = true;
tts_result_ = static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
GetInfo(message, tts_response_info_);
+ if (application.valid()) {
+ auto& help_prompt_manager = application->help_prompt_manager();
+ help_prompt_manager.OnSetGlobalPropertiesReceived(message, true);
+ }
break;
}
default: {
@@ -257,10 +267,6 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
std::string response_info;
const bool result = PrepareResponseParameters(result_code, response_info);
- // TODO{ALeshin} APPLINK-15858. connection_key removed during SendResponse
- ApplicationSharedPtr application =
- application_manager_.application(connection_key());
-
SendResponse(result,
result_code,
response_info.empty() ? NULL : response_info.c_str(),
@@ -277,10 +283,11 @@ bool SetGlobalPropertiesRequest::PrepareResponseParameters(
LOG4CXX_AUTO_TRACE(logger_);
using namespace helpers;
- ResponseInfo ui_properties_info(ui_result_, HmiInterfaces::HMI_INTERFACE_UI);
+ ResponseInfo ui_properties_info(
+ ui_result_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_);
- ResponseInfo tts_properties_info(tts_result_,
- HmiInterfaces::HMI_INTERFACE_TTS);
+ ResponseInfo tts_properties_info(
+ tts_result_, HmiInterfaces::HMI_INTERFACE_TTS, application_manager_);
const bool result =
PrepareResultForMobileResponse(ui_properties_info, tts_properties_info);
if (result &&
@@ -397,6 +404,7 @@ void SetGlobalPropertiesRequest::SendTTSRequest(
const smart_objects::SmartObject& params, bool use_events) {
LOG4CXX_AUTO_TRACE(logger_);
is_tts_send_ = true;
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS);
SendHMIRequest(
hmi_apis::FunctionID::TTS_SetGlobalProperties, &params, use_events);
}
@@ -405,6 +413,7 @@ void SetGlobalPropertiesRequest::SendUIRequest(
const smart_objects::SmartObject& params, bool use_events) {
LOG4CXX_AUTO_TRACE(logger_);
is_ui_send_ = true;
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
SendHMIRequest(
hmi_apis::FunctionID::UI_SetGlobalProperties, &params, use_events);
}
diff --git a/src/components/application_manager/src/commands/mobile/set_icon_request.cc b/src/components/application_manager/src/commands/mobile/set_icon_request.cc
index 85f34aead9..037de54456 100644
--- a/src/components/application_manager/src/commands/mobile/set_icon_request.cc
+++ b/src/components/application_manager/src/commands/mobile/set_icon_request.cc
@@ -95,7 +95,7 @@ void SetIconRequest::Run() {
// for further use in on_event function
(*message_)[strings::msg_params][strings::sync_file_name] =
msg_params[strings::sync_file_name];
-
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
SendHMIRequest(hmi_apis::FunctionID::UI_SetAppIcon, &msg_params, true);
}
@@ -105,6 +105,7 @@ void SetIconRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::UI_SetAppIcon: {
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
mobile_apis::Result::eType result_code =
static_cast<mobile_apis::Result::eType>(
message[strings::params][hmi_response::code].asInt());
diff --git a/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc b/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc
index 1e0a00318d..54727abe01 100644
--- a/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc
+++ b/src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc
@@ -71,6 +71,7 @@ void SetMediaClockRequest::Run() {
// copy entirely msg
msg_params = (*message_)[strings::msg_params];
msg_params[strings::app_id] = app->app_id();
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
SendHMIRequest(
hmi_apis::FunctionID::UI_SetMediaClockTimer, &msg_params, true);
@@ -85,6 +86,7 @@ void SetMediaClockRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::UI_SetMediaClockTimer: {
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
hmi_apis::Common_Result::eType result_code =
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
diff --git a/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc b/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc
index b1cc40009d..42bfea4864 100644
--- a/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc
+++ b/src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc
@@ -172,6 +172,7 @@ void ShowConstantTBTRequest::Run() {
}
app->set_tbt_show_command(msg_params);
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation);
SendHMIRequest(
hmi_apis::FunctionID::Navigation_ShowConstantTBT, &msg_params, true);
}
@@ -184,6 +185,7 @@ void ShowConstantTBTRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::Navigation_ShowConstantTBT: {
LOG4CXX_INFO(logger_, "Received Navigation_ShowConstantTBT event");
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation);
const Common_Result::eType result_code =
static_cast<Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
diff --git a/src/components/application_manager/src/commands/mobile/show_request.cc b/src/components/application_manager/src/commands/mobile/show_request.cc
index 5b8e98d7ea..ad598efc1d 100644
--- a/src/components/application_manager/src/commands/mobile/show_request.cc
+++ b/src/components/application_manager/src/commands/mobile/show_request.cc
@@ -263,6 +263,7 @@ void ShowRequest::Run() {
(*message_)[strings::msg_params][strings::custom_presets];
}
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
SendHMIRequest(hmi_apis::FunctionID::UI_Show, &msg_params, true);
MessageSharedPtr persistentData = new smart_objects::SmartObject(msg_params);
@@ -278,6 +279,7 @@ void ShowRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::UI_Show: {
LOG4CXX_DEBUG(logger_, "Received UI_Show event.");
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
std::string response_info;
hmi_apis::Common_Result::eType result_code =
static_cast<hmi_apis::Common_Result::eType>(
diff --git a/src/components/application_manager/src/commands/mobile/slider_request.cc b/src/components/application_manager/src/commands/mobile/slider_request.cc
index 054d0ec16d..f98869b08f 100644
--- a/src/components/application_manager/src/commands/mobile/slider_request.cc
+++ b/src/components/application_manager/src/commands/mobile/slider_request.cc
@@ -107,6 +107,7 @@ void SliderRequest::Run() {
msg_params[strings::timeout] = default_timeout_;
}
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
SendHMIRequest(hmi_apis::FunctionID::UI_Slider, &msg_params, true);
}
@@ -132,7 +133,7 @@ void SliderRequest::on_event(const event_engine::Event& event) {
}
LOG4CXX_DEBUG(logger_, "Received UI_Slider event");
-
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI);
const Common_Result::eType response_code = static_cast<Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
diff --git a/src/components/application_manager/src/commands/mobile/speak_request.cc b/src/components/application_manager/src/commands/mobile/speak_request.cc
index 6cbb762102..1954cde181 100644
--- a/src/components/application_manager/src/commands/mobile/speak_request.cc
+++ b/src/components/application_manager/src/commands/mobile/speak_request.cc
@@ -72,6 +72,7 @@ void SpeakRequest::Run() {
(*message_)[strings::msg_params][strings::app_id] = app->app_id();
(*message_)[strings::msg_params][hmi_request::speak_type] =
hmi_apis::Common_MethodName::SPEAK;
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS);
SendHMIRequest(hmi_apis::FunctionID::TTS_Speak,
&message_->getElement(strings::msg_params),
true);
@@ -82,7 +83,7 @@ void SpeakRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::TTS_Speak: {
LOG4CXX_INFO(logger_, "Received TTS_Speak event");
-
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS);
ProcessTTSSpeakResponse(event.smart_object());
break;
}
diff --git a/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc
index fc839a43f4..15ba7999bd 100644
--- a/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc
+++ b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc
@@ -3,6 +3,9 @@
Copyright (c) 2013, Ford Motor Company
All rights reserved.
+ Copyright (c) 2017, Livio, Inc.
+ All rights reserved.
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -116,7 +119,7 @@ void SubscribeVehicleDataRequest::Run() {
smart_objects::SmartObject response_params =
smart_objects::SmartObject(smart_objects::SmartType_Map);
bool result = false;
- CheckVISubscribtions(
+ CheckVISubscriptions(
app, info, result_code, response_params, msg_params, result);
if (mobile_apis::Result::INVALID_ENUM != result_code) {
@@ -149,6 +152,7 @@ void SubscribeVehicleDataRequest::Run() {
++it)
SendHMIRequest(it->func_id, &msg_params, true);
#else
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo);
SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData,
&msg_params,
true);
@@ -165,7 +169,7 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
LOG4CXX_ERROR(logger_, "Received unknown event.");
return;
}
-
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo);
ApplicationSharedPtr app =
application_manager_.application(CommandRequestImpl::connection_key());
@@ -250,6 +254,15 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
result_code = mobile_apis::Result::IGNORED;
response_info = "Already subscribed on some provided VehicleData.";
}
+
+ if (!vi_waiting_for_subscribe_.empty()) {
+ LOG4CXX_DEBUG(logger_, "Subscribing to all pending VehicleData");
+ VehicleInfoSubscriptions::const_iterator key =
+ vi_waiting_for_subscribe_.begin();
+ for (; key != vi_waiting_for_subscribe_.end(); ++key) {
+ app->SubscribeToIVI(*key);
+ }
+ }
}
UnsubscribeFailedSubscriptions(app, message[strings::msg_params]);
@@ -276,20 +289,33 @@ void SubscribeVehicleDataRequest::AddAlreadySubscribedVI(
smart_objects::SmartObject& msg_params) const {
LOG4CXX_AUTO_TRACE(logger_);
using namespace mobile_apis;
+ auto vi_to_string =
+ [](const mobile_apis::VehicleDataType::eType vehicle_data) {
+ for (auto& vi_str_to_int_pair : MessageHelper::vehicle_data()) {
+ if (vehicle_data == vi_str_to_int_pair.second) {
+ return vi_str_to_int_pair.first;
+ }
+ }
+ return std::string();
+ };
+
VehicleInfoSubscriptions::const_iterator it_same_app =
vi_already_subscribed_by_this_app_.begin();
for (; vi_already_subscribed_by_this_app_.end() != it_same_app;
++it_same_app) {
- msg_params[*it_same_app][strings::result_code] =
+ msg_params[vi_to_string(*it_same_app)][strings::result_code] =
VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED;
+ msg_params[vi_to_string(*it_same_app)][strings::data_type] = *it_same_app;
}
VehicleInfoSubscriptions::const_iterator it_another_app =
vi_already_subscribed_by_another_apps_.begin();
for (; vi_already_subscribed_by_another_apps_.end() != it_another_app;
++it_another_app) {
- msg_params[*it_another_app][strings::result_code] =
+ msg_params[vi_to_string(*it_another_app)][strings::result_code] =
VehicleDataResultCode::VDRC_SUCCESS;
+ msg_params[vi_to_string(*it_another_app)][strings::data_type] =
+ *it_another_app;
}
}
@@ -342,6 +368,21 @@ void SubscribeVehicleDataRequest::CheckVISubscribtions(
smart_objects::SmartObject& out_response_params,
smart_objects::SmartObject& out_request_params,
bool& out_result) {
+ CheckVISubscriptions(app,
+ out_info,
+ out_result_code,
+ out_response_params,
+ out_request_params,
+ out_result);
+}
+
+void SubscribeVehicleDataRequest::CheckVISubscriptions(
+ ApplicationSharedPtr app,
+ std::string& out_info,
+ mobile_apis::Result::eType& out_result_code,
+ smart_objects::SmartObject& out_response_params,
+ smart_objects::SmartObject& out_request_params,
+ bool& out_result) {
// counter for items to subscribe
VehicleInfoSubscriptions::size_type items_to_subscribe = 0;
// counter for subscribed items by application
@@ -366,7 +407,7 @@ void SubscribeVehicleDataRequest::CheckVISubscribtions(
++items_to_subscribe;
}
if (!is_interface_not_available && is_key_enabled) {
- VehicleDataType key_type = it->second;
+ mobile_apis::VehicleDataType::eType key_type = it->second;
if (app->IsSubscribedToIVI(key_type)) {
LOG4CXX_DEBUG(logger_,
"App with connection key "
@@ -407,12 +448,13 @@ void SubscribeVehicleDataRequest::CheckVISubscribtions(
out_request_params[key_name] = is_key_enabled;
- if (app->SubscribeToIVI(static_cast<uint32_t>(key_type))) {
+ if (is_key_enabled) {
+ vi_waiting_for_subscribe_.insert(key_type);
LOG4CXX_DEBUG(
logger_,
"App with connection key "
<< connection_key()
- << " have been subscribed for VehicleDataType: " << key_type);
+ << " will be subscribed for VehicleDataType: " << key_type);
++subscribed_items;
}
}
diff --git a/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc
index 0e0d760228..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,17 +25,18 @@ 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;
}
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation);
SendHMIRequest(
hmi_apis::FunctionID::Navigation_SubscribeWayPoints, NULL, true);
}
@@ -47,6 +48,7 @@ void SubscribeWayPointsRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::Navigation_SubscribeWayPoints: {
LOG4CXX_INFO(logger_, "Received Navigation_SubscribeWayPoints event");
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation);
const hmi_apis::Common_Result::eType result_code =
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
@@ -55,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/system_request.cc b/src/components/application_manager/src/commands/mobile/system_request.cc
index e4706441ef..fe38b93732 100644
--- a/src/components/application_manager/src/commands/mobile/system_request.cc
+++ b/src/components/application_manager/src/commands/mobile/system_request.cc
@@ -535,19 +535,8 @@ void SystemRequest::Run() {
if (!file || !file->is_download_complete ||
!file_system::MoveFile(app_full_file_path, file_dst_path)) {
LOG4CXX_DEBUG(logger_, "Binary data not found.");
-
- std::string origin_file_name;
- if ((*message_)[strings::msg_params].keyExists(strings::file_name)) {
- origin_file_name =
- (*message_)[strings::msg_params][strings::file_name].asString();
- }
- if (!(mobile_apis::RequestType::HTTP == request_type &&
- 0 == origin_file_name.compare(kIVSU))) {
- LOG4CXX_DEBUG(logger_, "Binary data required. Invalid data");
- SendResponse(false, mobile_apis::Result::INVALID_DATA);
- return;
- }
- LOG4CXX_DEBUG(logger_, "IVSU does not require binary data. Continue");
+ SendResponse(false, mobile_apis::Result::REJECTED);
+ return;
}
processing_file_ = file_dst_path;
}
@@ -598,6 +587,7 @@ void SystemRequest::Run() {
msg_params[strings::request_type] =
(*message_)[strings::msg_params][strings::request_type];
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_BasicCommunication);
SendHMIRequest(hmi_apis::FunctionID::BasicCommunication_SystemRequest,
&msg_params,
true);
@@ -611,6 +601,7 @@ void SystemRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::BasicCommunication_SystemRequest: {
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_BasicCommunication);
mobile_apis::Result::eType result_code =
GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asUInt()));
diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc
index fa3a9ad400..d6ad928bf7 100644
--- a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc
+++ b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc
@@ -134,7 +134,7 @@ void UnsubscribeVehicleDataRequest::Run() {
if (is_key_enabled) {
++items_to_unsubscribe;
- VehicleDataType key_type = it->second;
+ mobile_apis::VehicleDataType::eType key_type = it->second;
if (!app->IsSubscribedToIVI(key_type)) {
++unsubscribed_items;
vi_already_unsubscribed_by_this_app_.insert(key_type);
@@ -234,6 +234,7 @@ void UnsubscribeVehicleDataRequest::Run() {
++it)
SendHMIRequest(it->func_id, &msg_params, true);
#else
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo);
SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData,
&msg_params,
true);
@@ -250,6 +251,15 @@ void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
LOG4CXX_ERROR(logger_, "Received unknown event.");
return;
}
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo);
+
+ ApplicationSharedPtr app =
+ application_manager_.application(CommandRequestImpl::connection_key());
+
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "NULL pointer.");
+ return;
+ }
#ifdef HMI_DBUS_API
for (HmiRequests::iterator it = hmi_requests_.begin();
@@ -306,7 +316,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/commands/mobile/unsubscribe_way_points_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc
index 953bbc7a12..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,11 +25,12 @@ void UnSubscribeWayPointsRequest::Run() {
return;
}
- if (!application_manager_.IsAppSubscribedForWayPoints(app->app_id())) {
+ if (!application_manager_.IsAppSubscribedForWayPoints(app)) {
SendResponse(false, mobile_apis::Result::IGNORED);
return;
}
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation);
SendHMIRequest(
hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints, NULL, true);
}
@@ -41,6 +42,7 @@ void UnSubscribeWayPointsRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints: {
LOG4CXX_INFO(logger_, "Received Navigation_UnSubscribeWayPoints event");
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation);
const hmi_apis::Common_Result::eType result_code =
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
@@ -49,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/commands/mobile/update_turn_list_request.cc b/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc
index becab175e9..44fe9d0d07 100644
--- a/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc
+++ b/src/components/application_manager/src/commands/mobile/update_turn_list_request.cc
@@ -138,6 +138,7 @@ void UpdateTurnListRequest::Run() {
if ((*message_)[strings::msg_params].keyExists(strings::turn_list) ||
(*message_)[strings::msg_params].keyExists(strings::soft_buttons)) {
+ StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation);
SendHMIRequest(
hmi_apis::FunctionID::Navigation_UpdateTurnList, &msg_params, true);
} else {
@@ -154,7 +155,7 @@ void UpdateTurnListRequest::on_event(const event_engine::Event& event) {
switch (event.id()) {
case hmi_apis::FunctionID::Navigation_UpdateTurnList: {
LOG4CXX_INFO(logger_, "Received Navigation_UpdateTurnList event");
-
+ EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation);
const hmi_apis::Common_Result::eType result_code =
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());