summaryrefslogtreecommitdiff
path: root/src/components/application_manager/src/commands/mobile
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/src/commands/mobile')
-rw-r--r--src/components/application_manager/src/commands/mobile/add_command_request.cc310
-rw-r--r--src/components/application_manager/src/commands/mobile/add_command_response.cc12
-rw-r--r--src/components/application_manager/src/commands/mobile/add_sub_menu_request.cc57
-rw-r--r--src/components/application_manager/src/commands/mobile/add_sub_menu_response.cc13
-rw-r--r--src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc161
-rw-r--r--src/components/application_manager/src/commands/mobile/alert_maneuver_response.cc13
-rw-r--r--src/components/application_manager/src/commands/mobile/alert_request.cc285
-rw-r--r--src/components/application_manager/src/commands/mobile/alert_response.cc13
-rw-r--r--src/components/application_manager/src/commands/mobile/change_registration_request.cc226
-rw-r--r--src/components/application_manager/src/commands/mobile/change_registration_response.cc11
-rw-r--r--src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc312
-rw-r--r--src/components/application_manager/src/commands/mobile/create_interaction_choice_set_response.cc10
-rw-r--r--src/components/application_manager/src/commands/mobile/delete_command_request.cc173
-rw-r--r--src/components/application_manager/src/commands/mobile/delete_command_response.cc12
-rw-r--r--src/components/application_manager/src/commands/mobile/delete_file_request.cc47
-rw-r--r--src/components/application_manager/src/commands/mobile/delete_file_response.cc21
-rw-r--r--src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc114
-rw-r--r--src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_response.cc10
-rw-r--r--src/components/application_manager/src/commands/mobile/delete_sub_menu_request.cc66
-rw-r--r--src/components/application_manager/src/commands/mobile/delete_sub_menu_response.cc13
-rw-r--r--src/components/application_manager/src/commands/mobile/diagnostic_message_request.cc53
-rw-r--r--src/components/application_manager/src/commands/mobile/diagnostic_message_response.cc12
-rw-r--r--src/components/application_manager/src/commands/mobile/dial_number_request.cc20
-rw-r--r--src/components/application_manager/src/commands/mobile/dial_number_response.cc14
-rw-r--r--src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc15
-rw-r--r--src/components/application_manager/src/commands/mobile/end_audio_pass_thru_response.cc11
-rw-r--r--src/components/application_manager/src/commands/mobile/generic_response.cc4
-rw-r--r--src/components/application_manager/src/commands/mobile/get_dtcs_request.cc17
-rw-r--r--src/components/application_manager/src/commands/mobile/get_dtcs_response.cc12
-rw-r--r--src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc168
-rw-r--r--src/components/application_manager/src/commands/mobile/get_vehicle_data_response.cc13
-rw-r--r--src/components/application_manager/src/commands/mobile/get_way_points_request.cc59
-rw-r--r--src/components/application_manager/src/commands/mobile/get_way_points_response.cc22
-rw-r--r--src/components/application_manager/src/commands/mobile/list_files_request.cc58
-rw-r--r--src/components/application_manager/src/commands/mobile/list_files_response.cc13
-rw-r--r--src/components/application_manager/src/commands/mobile/on_app_interface_unregistered_notification.cc9
-rw-r--r--src/components/application_manager/src/commands/mobile/on_audio_pass_thru_notification.cc8
-rw-r--r--src/components/application_manager/src/commands/mobile/on_button_event_notification.cc84
-rw-r--r--src/components/application_manager/src/commands/mobile/on_button_press_notification.cc84
-rw-r--r--src/components/application_manager/src/commands/mobile/on_command_notification.cc22
-rw-r--r--src/components/application_manager/src/commands/mobile/on_driver_distraction_notification.cc10
-rw-r--r--src/components/application_manager/src/commands/mobile/on_hash_change_notification.cc18
-rw-r--r--src/components/application_manager/src/commands/mobile/on_hmi_status_notification.cc27
-rw-r--r--src/components/application_manager/src/commands/mobile/on_hmi_status_notification_from_mobile.cc54
-rw-r--r--src/components/application_manager/src/commands/mobile/on_keyboard_input_notification.cc31
-rw-r--r--src/components/application_manager/src/commands/mobile/on_language_change_notification.cc8
-rw-r--r--src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc8
-rw-r--r--src/components/application_manager/src/commands/mobile/on_system_request_notification.cc93
-rw-r--r--src/components/application_manager/src/commands/mobile/on_tbt_client_state_notification.cc12
-rw-r--r--src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc12
-rw-r--r--src/components/application_manager/src/commands/mobile/on_vehicle_data_notification.cc50
-rw-r--r--src/components/application_manager/src/commands/mobile/on_way_point_change_notification.cc61
-rw-r--r--src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc193
-rw-r--r--src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_response.cc12
-rw-r--r--src/components/application_manager/src/commands/mobile/perform_interaction_request.cc557
-rw-r--r--src/components/application_manager/src/commands/mobile/perform_interaction_response.cc11
-rw-r--r--src/components/application_manager/src/commands/mobile/put_file_request.cc142
-rw-r--r--src/components/application_manager/src/commands/mobile/put_file_response.cc17
-rw-r--r--src/components/application_manager/src/commands/mobile/read_did_request.cc47
-rw-r--r--src/components/application_manager/src/commands/mobile/read_did_response.cc12
-rw-r--r--src/components/application_manager/src/commands/mobile/register_app_interface_request.cc618
-rw-r--r--src/components/application_manager/src/commands/mobile/register_app_interface_response.cc47
-rw-r--r--src/components/application_manager/src/commands/mobile/reset_global_properties_request.cc183
-rw-r--r--src/components/application_manager/src/commands/mobile/reset_global_properties_response.cc11
-rw-r--r--src/components/application_manager/src/commands/mobile/scrollable_message_request.cc59
-rw-r--r--src/components/application_manager/src/commands/mobile/scrollable_message_response.cc19
-rw-r--r--src/components/application_manager/src/commands/mobile/send_location_request.cc214
-rw-r--r--src/components/application_manager/src/commands/mobile/send_location_response.cc13
-rw-r--r--src/components/application_manager/src/commands/mobile/set_app_icon_request.cc133
-rw-r--r--src/components/application_manager/src/commands/mobile/set_app_icon_response.cc12
-rw-r--r--src/components/application_manager/src/commands/mobile/set_display_layout_request.cc35
-rw-r--r--src/components/application_manager/src/commands/mobile/set_display_layout_response.cc12
-rw-r--r--src/components/application_manager/src/commands/mobile/set_global_properties_request.cc513
-rw-r--r--src/components/application_manager/src/commands/mobile/set_global_properties_response.cc12
-rw-r--r--src/components/application_manager/src/commands/mobile/set_icon_request.cc44
-rw-r--r--src/components/application_manager/src/commands/mobile/set_icon_response.cc15
-rw-r--r--src/components/application_manager/src/commands/mobile/set_media_clock_timer_request.cc27
-rw-r--r--src/components/application_manager/src/commands/mobile/set_media_clock_timer_response.cc11
-rw-r--r--src/components/application_manager/src/commands/mobile/show_constant_tbt_request.cc101
-rw-r--r--src/components/application_manager/src/commands/mobile/show_constant_tbt_response.cc13
-rw-r--r--src/components/application_manager/src/commands/mobile/show_request.cc136
-rw-r--r--src/components/application_manager/src/commands/mobile/show_response.cc13
-rw-r--r--src/components/application_manager/src/commands/mobile/slider_request.cc93
-rw-r--r--src/components/application_manager/src/commands/mobile/slider_response.cc12
-rw-r--r--src/components/application_manager/src/commands/mobile/speak_request.cc58
-rw-r--r--src/components/application_manager/src/commands/mobile/speak_response.cc13
-rw-r--r--src/components/application_manager/src/commands/mobile/subscribe_button_request.cc42
-rw-r--r--src/components/application_manager/src/commands/mobile/subscribe_button_response.cc8
-rw-r--r--src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_request.cc334
-rw-r--r--src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_response.cc12
-rw-r--r--src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc72
-rw-r--r--src/components/application_manager/src/commands/mobile/subscribe_way_points_response.cc22
-rw-r--r--src/components/application_manager/src/commands/mobile/system_request.cc231
-rw-r--r--src/components/application_manager/src/commands/mobile/system_response.cc12
-rw-r--r--src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc18
-rw-r--r--src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc23
-rw-r--r--src/components/application_manager/src/commands/mobile/unsubscribe_button_response.cc9
-rw-r--r--src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc332
-rw-r--r--src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_response.cc8
-rw-r--r--src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc65
-rw-r--r--src/components/application_manager/src/commands/mobile/unsubscribe_way_points_response.cc22
-rw-r--r--src/components/application_manager/src/commands/mobile/update_turn_list_request.cc93
-rw-r--r--src/components/application_manager/src/commands/mobile/update_turn_list_response.cc13
103 files changed, 4483 insertions, 3202 deletions
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 da44d0e7c4..03bdfadd66 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
@@ -33,27 +33,30 @@
#include <string>
#include "application_manager/commands/mobile/add_command_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application.h"
#include "application_manager/message_helper.h"
#include "utils/file_system.h"
+#include "utils/helpers.h"
+#include "utils/custom_string.h"
namespace application_manager {
namespace commands {
-AddCommandRequest::AddCommandRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message),
- send_ui_(false),
- send_vr_(false),
- is_ui_received_(false),
- is_vr_received_(false),
- ui_result_(hmi_apis::Common_Result::INVALID_ENUM),
- vr_result_(hmi_apis::Common_Result::INVALID_ENUM) {
-}
+namespace custom_str = utils::custom_string;
-AddCommandRequest::~AddCommandRequest() {
-}
+AddCommandRequest::AddCommandRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager)
+ , send_ui_(false)
+ , send_vr_(false)
+ , is_ui_received_(false)
+ , is_vr_received_(false)
+ , ui_result_(hmi_apis::Common_Result::INVALID_ENUM)
+ , vr_result_(hmi_apis::Common_Result::INVALID_ENUM) {}
+
+AddCommandRequest::~AddCommandRequest() {}
void AddCommandRequest::onTimeOut() {
LOG4CXX_AUTO_TRACE(logger_);
@@ -64,43 +67,43 @@ void AddCommandRequest::onTimeOut() {
void AddCommandRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ ApplicationSharedPtr app = application_manager_.application(
(*message_)[strings::params][strings::connection_key].asUInt());
if (!app) {
- LOG4CXX_ERROR_EXT(logger_, "No application associated with session key");
+ LOG4CXX_ERROR(logger_, "No application associated with session key");
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
return;
}
if ((*message_)[strings::msg_params].keyExists(strings::cmd_icon)) {
- mobile_apis::Result::eType verification_result =
- MessageHelper::VerifyImage((*message_)[strings::msg_params]
- [strings::cmd_icon], app);
+ mobile_apis::Result::eType verification_result = MessageHelper::VerifyImage(
+ (*message_)[strings::msg_params][strings::cmd_icon],
+ app,
+ application_manager_);
if (mobile_apis::Result::SUCCESS != verification_result) {
- LOG4CXX_ERROR_EXT(
- logger_,
- "MessageHelper::VerifyImage return " << verification_result);
+ LOG4CXX_ERROR(
+ logger_, "MessageHelper::VerifyImage return " << verification_result);
SendResponse(false, verification_result);
return;
}
}
if (!((*message_)[strings::msg_params].keyExists(strings::cmd_id))) {
- LOG4CXX_ERROR_EXT(logger_, "INVALID_DATA");
+ LOG4CXX_ERROR(logger_, "INVALID_DATA");
SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
}
if (app->FindCommand(
- (*message_)[strings::msg_params][strings::cmd_id].asUInt())) {
- LOG4CXX_ERROR_EXT(logger_, "INVALID_ID");
+ (*message_)[strings::msg_params][strings::cmd_id].asUInt())) {
+ LOG4CXX_ERROR(logger_, "INVALID_ID");
SendResponse(false, mobile_apis::Result::INVALID_ID);
return;
}
- bool data_exist = false;
+ bool data_exist = false;
if ((*message_)[strings::msg_params].keyExists(strings::menu_params)) {
if (!CheckCommandName(app)) {
@@ -108,21 +111,21 @@ void AddCommandRequest::Run() {
return;
}
if (((*message_)[strings::msg_params][strings::menu_params].keyExists(
- hmi_request::parent_id)) && (0 != (*message_)[strings::msg_params]
- [strings::menu_params][hmi_request::parent_id].asUInt())) {
+ hmi_request::parent_id)) &&
+ (0 !=
+ (*message_)[strings::msg_params][strings::menu_params]
+ [hmi_request::parent_id].asUInt())) {
if (!CheckCommandParentId(app)) {
- SendResponse(false, mobile_apis::Result::INVALID_ID,
- "Parent ID doesn't exist");
+ SendResponse(
+ false, mobile_apis::Result::INVALID_ID, "Parent ID doesn't exist");
return;
}
}
data_exist = true;
}
- if (((*message_)[strings::msg_params].keyExists(strings::vr_commands))
- && ((*message_)[strings::msg_params]
- [strings::vr_commands].length() > 0)) {
-
+ if (((*message_)[strings::msg_params].keyExists(strings::vr_commands)) &&
+ ((*message_)[strings::msg_params][strings::vr_commands].length() > 0)) {
if (!CheckCommandVRSynonym(app)) {
SendResponse(false, mobile_apis::Result::DUPLICATE_NAME);
return;
@@ -132,24 +135,22 @@ void AddCommandRequest::Run() {
}
if (!data_exist) {
- LOG4CXX_ERROR_EXT(logger_, "INVALID_DATA");
+ LOG4CXX_ERROR(logger_, "INVALID_DATA");
SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
}
if (IsWhiteSpaceExist()) {
- LOG4CXX_ERROR(logger_,
- "Incoming add command has contains \t\n \\t \\n");
+ LOG4CXX_ERROR(logger_, "Incoming add command has contains \t\n \\t \\n");
SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
}
- app->AddCommand((*message_)[strings::msg_params]
- [strings::cmd_id].asUInt(),
- (*message_)[strings::msg_params]);
+ app->AddCommand((*message_)[strings::msg_params][strings::cmd_id].asUInt(),
+ (*message_)[strings::msg_params]);
- smart_objects::SmartObject ui_msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject ui_msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
if ((*message_)[strings::msg_params].keyExists(strings::menu_params)) {
ui_msg_params[strings::cmd_id] =
(*message_)[strings::msg_params][strings::cmd_id];
@@ -158,10 +159,11 @@ void AddCommandRequest::Run() {
ui_msg_params[strings::app_id] = app->app_id();
- if ( ((*message_)[strings::msg_params].keyExists(strings::cmd_icon))
- && ((*message_)[strings::msg_params][strings::cmd_icon].keyExists(strings::value))
- && (0 < (*message_)[strings::msg_params][strings::cmd_icon]
- [strings::value].length())) {
+ if (((*message_)[strings::msg_params].keyExists(strings::cmd_icon)) &&
+ ((*message_)[strings::msg_params][strings::cmd_icon].keyExists(
+ strings::value)) &&
+ (0 < (*message_)[strings::msg_params][strings::cmd_icon][strings::value]
+ .length())) {
ui_msg_params[strings::cmd_icon] =
(*message_)[strings::msg_params][strings::cmd_icon];
}
@@ -169,8 +171,8 @@ void AddCommandRequest::Run() {
send_ui_ = true;
}
- smart_objects::SmartObject vr_msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject vr_msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
if ((*message_)[strings::msg_params].keyExists(strings::vr_commands)) {
vr_msg_params[strings::cmd_id] =
(*message_)[strings::msg_params][strings::cmd_id];
@@ -203,27 +205,28 @@ bool AddCommandRequest::CheckCommandName(ApplicationConstSharedPtr app) {
CommandsMap::const_iterator i = commands.begin();
uint32_t saved_parent_id = 0;
uint32_t parent_id = 0;
- if ((*message_)[strings::msg_params]
- [strings::menu_params].keyExists(hmi_request::parent_id)) {
- parent_id = (*message_)[strings::msg_params]
- [strings::menu_params][hmi_request::parent_id].asUInt();
+ if ((*message_)[strings::msg_params][strings::menu_params].keyExists(
+ hmi_request::parent_id)) {
+ parent_id = (*message_)[strings::msg_params][strings::menu_params]
+ [hmi_request::parent_id].asUInt();
}
for (; commands.end() != i; ++i) {
-
if (!(*i->second).keyExists(strings::menu_params)) {
continue;
}
saved_parent_id = 0;
if ((*i->second)[strings::menu_params].keyExists(hmi_request::parent_id)) {
- saved_parent_id = (*i->second)[strings::menu_params][hmi_request::parent_id].asUInt();
+ saved_parent_id =
+ (*i->second)[strings::menu_params][hmi_request::parent_id].asUInt();
}
- if (((*i->second)[strings::menu_params][strings::menu_name].asString()
- == (*message_)[strings::msg_params][strings::menu_params]
- [strings::menu_name].asString()) &&
+ if (((*i->second)[strings::menu_params][strings::menu_name].asString() ==
+ (*message_)[strings::msg_params][strings::menu_params]
+ [strings::menu_name].asString()) &&
(saved_parent_id == parent_id)) {
- LOG4CXX_INFO(logger_, "AddCommandRequest::CheckCommandName received"
+ LOG4CXX_INFO(logger_,
+ "AddCommandRequest::CheckCommandName received"
" command name already exist in same level menu");
return false;
}
@@ -241,23 +244,23 @@ bool AddCommandRequest::CheckCommandVRSynonym(ApplicationConstSharedPtr app) {
CommandsMap::const_iterator it = commands.begin();
for (; commands.end() != it; ++it) {
-
- if(!(*it->second).keyExists(strings::vr_commands)) {
+ if (!(*it->second).keyExists(strings::vr_commands)) {
continue;
}
for (size_t i = 0; i < (*it->second)[strings::vr_commands].length(); ++i) {
for (size_t j = 0;
- j < (*message_)[strings::msg_params][strings::vr_commands].length();
- ++j) {
- std::string vr_cmd_i =
- (*it->second)[strings::vr_commands][i].asString();
- std::string vr_cmd_j =
- (*message_)[strings::msg_params]
- [strings::vr_commands][j].asString();
-
- if (0 == strcasecmp(vr_cmd_i.c_str(), vr_cmd_j.c_str())) {
- LOG4CXX_INFO(logger_, "AddCommandRequest::CheckCommandVRSynonym"
+ j < (*message_)[strings::msg_params][strings::vr_commands].length();
+ ++j) {
+ const custom_str::CustomString& vr_cmd_i =
+ (*it->second)[strings::vr_commands][i].asCustomString();
+ const custom_str::CustomString& vr_cmd_j =
+ (*message_)[strings::msg_params][strings::vr_commands][j]
+ .asCustomString();
+
+ if (vr_cmd_i.CompareIgnoreCase(vr_cmd_j)) {
+ LOG4CXX_INFO(logger_,
+ "AddCommandRequest::CheckCommandVRSynonym"
" received command vr synonym already exist");
return false;
}
@@ -274,11 +277,12 @@ bool AddCommandRequest::CheckCommandParentId(ApplicationConstSharedPtr app) {
const int32_t parent_id =
(*message_)[strings::msg_params][strings::menu_params]
- [hmi_request::parent_id].asInt();
+ [hmi_request::parent_id].asInt();
smart_objects::SmartObject* parent = app->FindSubMenu(parent_id);
if (!parent) {
- LOG4CXX_INFO(logger_, "AddCommandRequest::CheckCommandParentId received"
+ LOG4CXX_INFO(logger_,
+ "AddCommandRequest::CheckCommandParentId received"
" submenu doesn't exist");
return false;
}
@@ -287,11 +291,12 @@ bool AddCommandRequest::CheckCommandParentId(ApplicationConstSharedPtr app) {
void AddCommandRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
+ using namespace helpers;
const smart_objects::SmartObject& message = event.smart_object();
ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(connection_key());
+ application_manager_.application(connection_key());
if (!application) {
LOG4CXX_ERROR(logger_, "NULL pointer");
@@ -299,7 +304,8 @@ void AddCommandRequest::on_event(const event_engine::Event& event) {
}
smart_objects::SmartObject msg_param(smart_objects::SmartType_Map);
- msg_param[strings::cmd_id] = (*message_)[strings::msg_params][strings::cmd_id];
+ msg_param[strings::cmd_id] =
+ (*message_)[strings::msg_params][strings::cmd_id];
msg_param[strings::app_id] = application->app_id();
switch (event.id()) {
@@ -326,79 +332,104 @@ void AddCommandRequest::on_event(const event_engine::Event& event) {
break;
}
default: {
- LOG4CXX_ERROR(logger_,"Received unknown event" << event.id());
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
return;
}
}
- if (!IsPendingResponseExist()) {
-
- ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(connection_key());
+ if (IsPendingResponseExist()) {
+ return;
+ }
- if (hmi_apis::Common_Result::REJECTED == ui_result_) {
- RemoveCommand();
- }
+ if (hmi_apis::Common_Result::REJECTED == ui_result_) {
+ RemoveCommand();
+ }
- smart_objects::SmartObject msg_params(smart_objects::SmartType_Map);
- msg_params[strings::cmd_id] = (*message_)[strings::msg_params][strings::cmd_id];
- msg_params[strings::app_id] = application->app_id();
-
- mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
-
- bool result = ((hmi_apis::Common_Result::SUCCESS == ui_result_) &&
- (hmi_apis::Common_Result::SUCCESS == vr_result_)) ||
- ((hmi_apis::Common_Result::SUCCESS == ui_result_) &&
- (hmi_apis::Common_Result::INVALID_ENUM == vr_result_ ||
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == vr_result_)) ||
- ((hmi_apis::Common_Result::INVALID_ENUM == ui_result_ ||
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == ui_result_ ) &&
- (hmi_apis::Common_Result::SUCCESS == vr_result_));
-
- if (!result && (hmi_apis::Common_Result::REJECTED == ui_result_)) {
- result_code = static_cast<mobile_apis::Result::eType>(ui_result_);
- } else {
- result_code = static_cast<mobile_apis::Result::eType>(
- std::max(ui_result_, vr_result_));
- }
+ smart_objects::SmartObject msg_params(smart_objects::SmartType_Map);
+ msg_params[strings::cmd_id] =
+ (*message_)[strings::msg_params][strings::cmd_id];
+ msg_params[strings::app_id] = application->app_id();
+
+ mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
+
+ const bool is_vr_invalid_unsupported =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ vr_result_,
+ hmi_apis::Common_Result::INVALID_ENUM,
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
+
+ const bool is_ui_ivalid_unsupported =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ ui_result_,
+ hmi_apis::Common_Result::INVALID_ENUM,
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
+
+ const bool is_no_ui_error = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ ui_result_,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::WARNINGS);
+
+ const bool is_no_vr_error = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ vr_result_,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::WARNINGS);
+
+ bool result = (is_no_ui_error && is_no_vr_error) ||
+ (is_no_ui_error && is_vr_invalid_unsupported) ||
+ (is_no_vr_error && is_ui_ivalid_unsupported);
+
+ const bool is_vr_or_ui_warning =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ hmi_apis::Common_Result::WARNINGS, ui_result_, vr_result_);
+
+ if (!result && hmi_apis::Common_Result::REJECTED == ui_result_) {
+ result_code = MessageHelper::HMIToMobileResult(ui_result_);
+ } else if (is_vr_or_ui_warning) {
+ result_code = mobile_apis::Result::WARNINGS;
+ } else {
+ result_code =
+ MessageHelper::HMIToMobileResult(std::max(ui_result_, vr_result_));
+ }
- if (BothSend() && hmi_apis::Common_Result::SUCCESS == vr_result_) {
- if (hmi_apis::Common_Result::SUCCESS != ui_result_ &&
- hmi_apis::Common_Result::WARNINGS != ui_result_ &&
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE != ui_result_) {
+ if (BothSend() && hmi_apis::Common_Result::SUCCESS == vr_result_) {
+ const bool is_ui_not_ok = Compare<hmi_apis::Common_Result::eType, NEQ, ALL>(
+ ui_result_,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::WARNINGS,
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
- result_code =
- (ui_result_ == hmi_apis::Common_Result::REJECTED) ?
- mobile_apis::Result::REJECTED : mobile_apis::Result::GENERIC_ERROR;
+ if (is_ui_not_ok) {
+ result_code = ui_result_ == hmi_apis::Common_Result::REJECTED
+ ? mobile_apis::Result::REJECTED
+ : mobile_apis::Result::GENERIC_ERROR;
- msg_params[strings::grammar_id] = application->get_grammar_id();
- msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command;
+ msg_params[strings::grammar_id] = application->get_grammar_id();
+ msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command;
- SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params);
- application->RemoveCommand((*message_)[strings::msg_params]
- [strings::cmd_id].asUInt());
- result = false;
- }
+ SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params);
+ application->RemoveCommand(
+ (*message_)[strings::msg_params][strings::cmd_id].asUInt());
+ result = false;
}
+ }
- if(BothSend() && hmi_apis::Common_Result::SUCCESS == ui_result_ &&
- hmi_apis::Common_Result::SUCCESS != vr_result_) {
+ if (BothSend() && hmi_apis::Common_Result::SUCCESS == ui_result_ &&
+ !is_no_vr_error) {
+ result_code = vr_result_ == hmi_apis::Common_Result::REJECTED
+ ? mobile_apis::Result::REJECTED
+ : mobile_apis::Result::GENERIC_ERROR;
- result_code =
- (vr_result_ == hmi_apis::Common_Result::REJECTED) ?
- mobile_apis::Result::REJECTED : mobile_apis::Result::GENERIC_ERROR;
+ SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params);
- SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params);
+ application->RemoveCommand(
+ (*message_)[strings::msg_params][strings::cmd_id].asUInt());
+ result = false;
+ }
- application->RemoveCommand((*message_)[strings::msg_params]
- [strings::cmd_id].asUInt());
- result = false;
- }
+ SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
- if (true == result) {
- application->UpdateHash();
- }
+ if (result) {
+ application->UpdateHash();
}
}
@@ -412,7 +443,7 @@ bool AddCommandRequest::IsWhiteSpaceExist() {
if ((*message_)[strings::msg_params].keyExists(strings::menu_params)) {
str = (*message_)[strings::msg_params][strings::menu_params]
- [strings::menu_name].asCharArray();
+ [strings::menu_name].asCharArray();
if (!CheckSyntax(str)) {
LOG4CXX_ERROR(logger_, "Invalid menu name syntax check failed.");
return true;
@@ -424,8 +455,8 @@ bool AddCommandRequest::IsWhiteSpaceExist() {
(*message_)[strings::msg_params][strings::vr_commands].length();
for (size_t i = 0; i < len; ++i) {
- str = (*message_)[strings::msg_params]
- [strings::vr_commands][i].asCharArray();
+ str = (*message_)[strings::msg_params][strings::vr_commands][i]
+ .asCharArray();
if (!CheckSyntax(str)) {
LOG4CXX_ERROR(logger_, "Invalid vr_commands syntax check failed");
return true;
@@ -434,8 +465,8 @@ bool AddCommandRequest::IsWhiteSpaceExist() {
}
if ((*message_)[strings::msg_params].keyExists(strings::cmd_icon)) {
- str = (*message_)[strings::msg_params]
- [strings::cmd_icon][strings::value].asCharArray();
+ str = (*message_)[strings::msg_params][strings::cmd_icon][strings::value]
+ .asCharArray();
if (!CheckSyntax(str)) {
LOG4CXX_ERROR(logger_, "Invalid cmd_icon value syntax check failed");
return true;
@@ -450,19 +481,19 @@ bool AddCommandRequest::BothSend() const {
void AddCommandRequest::RemoveCommand() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
- connection_key());
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app.valid()) {
LOG4CXX_ERROR(logger_, "No application associated with session key");
return;
}
smart_objects::SmartObject msg_params(smart_objects::SmartType_Map);
- msg_params[strings::cmd_id] = (*message_)[strings::msg_params][strings::cmd_id];
+ msg_params[strings::cmd_id] =
+ (*message_)[strings::msg_params][strings::cmd_id];
msg_params[strings::app_id] = app->app_id();
- app->RemoveCommand((*message_)[strings::msg_params]
- [strings::cmd_id].asUInt());
+ app->RemoveCommand(
+ (*message_)[strings::msg_params][strings::cmd_id].asUInt());
if (BothSend() && !(is_vr_received_ || is_ui_received_)) {
// in case we have send bth UI and VR and no one respond
@@ -479,7 +510,6 @@ void AddCommandRequest::RemoveCommand() {
msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command;
SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params);
}
-
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/add_command_response.cc b/src/components/application_manager/src/commands/mobile/add_command_response.cc
index 51684c065b..fc468f9c57 100644
--- a/src/components/application_manager/src/commands/mobile/add_command_response.cc
+++ b/src/components/application_manager/src/commands/mobile/add_command_response.cc
@@ -32,23 +32,21 @@
*/
#include "application_manager/commands/mobile/add_command_response.h"
-#include "application_manager/application_manager_impl.h"
namespace application_manager {
namespace commands {
-AddCommandResponse::AddCommandResponse(const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+AddCommandResponse::AddCommandResponse(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-AddCommandResponse::~AddCommandResponse() {
-}
+AddCommandResponse::~AddCommandResponse() {}
void AddCommandResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
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 f01645079c..83f137ac19 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
@@ -32,25 +32,24 @@
*/
#include "application_manager/commands/mobile/add_sub_menu_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application.h"
+#include "utils/helpers.h"
namespace application_manager {
namespace commands {
-AddSubMenuRequest::AddSubMenuRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+AddSubMenuRequest::AddSubMenuRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
-AddSubMenuRequest::~AddSubMenuRequest() {
-}
+AddSubMenuRequest::~AddSubMenuRequest() {}
void AddSubMenuRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
- (*message_)[strings::params][strings::connection_key].asUInt());
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
LOG4CXX_ERROR(logger_, "NULL pointer");
@@ -58,34 +57,37 @@ void AddSubMenuRequest::Run() {
return;
}
- if (app->FindSubMenu(
- (*message_)[strings::msg_params][strings::menu_id].asInt())) {
- LOG4CXX_ERROR(logger_, "INVALID_ID");
+ const int32_t menu_id =
+ (*message_)[strings::msg_params][strings::menu_id].asInt();
+ if (app->FindSubMenu(menu_id)) {
+ LOG4CXX_ERROR(logger_, "Menu with id " << menu_id << " is not found.");
SendResponse(false, mobile_apis::Result::INVALID_ID);
return;
}
- if (app->IsSubMenuNameAlreadyExist(
- (*message_)[strings::msg_params][strings::menu_name].asString())) {
- LOG4CXX_ERROR(logger_, "DUPLICATE_NAME");
+ const std::string& menu_name =
+ (*message_)[strings::msg_params][strings::menu_name].asString();
+
+ if (app->IsSubMenuNameAlreadyExist(menu_name)) {
+ LOG4CXX_ERROR(logger_, "Menu name " << menu_name << " is duplicated.");
SendResponse(false, mobile_apis::Result::DUPLICATE_NAME);
return;
}
if (!CheckSubMenuName()) {
- LOG4CXX_ERROR(logger_, "SubMenuName is not valid");
+ LOG4CXX_ERROR(logger_, "Sub-menu name is not valid.");
SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
}
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_params[strings::menu_id] =
(*message_)[strings::msg_params][strings::menu_id];
if ((*message_)[strings::msg_params].keyExists(strings::position)) {
- msg_params[strings::menu_params][strings::position] =
- (*message_)[strings::msg_params][strings::position];
+ msg_params[strings::menu_params][strings::position] =
+ (*message_)[strings::msg_params][strings::position];
}
msg_params[strings::menu_params][strings::menu_name] =
(*message_)[strings::msg_params][strings::menu_name];
@@ -96,6 +98,7 @@ void AddSubMenuRequest::Run() {
void AddSubMenuRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
+ using namespace helpers;
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
@@ -104,10 +107,13 @@ void AddSubMenuRequest::on_event(const event_engine::Event& event) {
static_cast<mobile_apis::Result::eType>(
message[strings::params][hmi_response::code].asInt());
- bool result = mobile_apis::Result::SUCCESS == result_code;
+ const bool result = Compare<mobile_api::Result::eType, EQ, ONE>(
+ result_code,
+ mobile_api::Result::SUCCESS,
+ mobile_api::Result::WARNINGS);
ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(connection_key());
+ application_manager_.application(connection_key());
if (!application) {
LOG4CXX_ERROR(logger_, "NULL pointer");
@@ -115,10 +121,10 @@ void AddSubMenuRequest::on_event(const event_engine::Event& event) {
}
if (result) {
- application->AddSubMenu((*message_)[strings::msg_params]
- [strings::menu_id].asInt(),
- (*message_)[strings::msg_params]);
- }
+ application->AddSubMenu(
+ (*message_)[strings::msg_params][strings::menu_id].asInt(),
+ (*message_)[strings::msg_params]);
+ }
SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
if (result) {
application->UpdateHash();
@@ -133,6 +139,7 @@ void AddSubMenuRequest::on_event(const event_engine::Event& event) {
}
bool AddSubMenuRequest::CheckSubMenuName() {
+ LOG4CXX_AUTO_TRACE(logger_);
const char* str = NULL;
str = (*message_)[strings::msg_params][strings::menu_name].asCharArray();
diff --git a/src/components/application_manager/src/commands/mobile/add_sub_menu_response.cc b/src/components/application_manager/src/commands/mobile/add_sub_menu_response.cc
index ff37a6a998..1fbdb4e66c 100644
--- a/src/components/application_manager/src/commands/mobile/add_sub_menu_response.cc
+++ b/src/components/application_manager/src/commands/mobile/add_sub_menu_response.cc
@@ -32,24 +32,23 @@
*/
#include "application_manager/commands/mobile/add_sub_menu_response.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
namespace application_manager {
namespace commands {
-AddSubMenuResponse::AddSubMenuResponse(const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+AddSubMenuResponse::AddSubMenuResponse(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-AddSubMenuResponse::~AddSubMenuResponse() {
-}
+AddSubMenuResponse::~AddSubMenuResponse() {}
void AddSubMenuResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
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 cdeccd86f4..ea00bc8d70 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
@@ -1,6 +1,5 @@
/*
-
- Copyright (c) 2013, Ford Motor Company
+ Copyright (c) 2016, Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -31,25 +30,28 @@
POSSIBILITY OF SUCH DAMAGE.
*/
-#include <string.h>
+#include <cstring>
+#include <string>
#include "application_manager/commands/mobile/alert_maneuver_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
+#include "application_manager/policies/policy_handler.h"
#include "application_manager/message_helper.h"
+#include "utils/helpers.h"
namespace application_manager {
namespace commands {
-AlertManeuverRequest::AlertManeuverRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message),
- tts_speak_result_code_(mobile_apis::Result::INVALID_ENUM),
- navi_alert_maneuver_result_code_(mobile_apis::Result::INVALID_ENUM) {
+AlertManeuverRequest::AlertManeuverRequest(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager)
+ , tts_speak_result_code_(mobile_apis::Result::INVALID_ENUM)
+ , navi_alert_maneuver_result_code_(mobile_apis::Result::INVALID_ENUM) {
subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout);
}
-AlertManeuverRequest::~AlertManeuverRequest() {
-}
+AlertManeuverRequest::~AlertManeuverRequest() {}
void AlertManeuverRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
@@ -61,7 +63,7 @@ void AlertManeuverRequest::Run() {
return;
}
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ ApplicationSharedPtr app = application_manager_.application(
(*message_)[strings::params][strings::connection_key].asUInt());
if (NULL == app.get()) {
@@ -78,10 +80,13 @@ void AlertManeuverRequest::Run() {
return;
}
- //ProcessSoftButtons checks strings on the contents incorrect character
+ // ProcessSoftButtons checks strings on the contents incorrect character
mobile_apis::Result::eType processing_result =
- MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], app);
+ MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params],
+ app,
+ application_manager_.GetPolicyHandler(),
+ application_manager_);
if (mobile_apis::Result::SUCCESS != processing_result) {
LOG4CXX_ERROR(logger_, "Wrong soft buttons parameters!");
@@ -100,25 +105,25 @@ void AlertManeuverRequest::Run() {
}
}
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_params[strings::app_id] = app->app_id();
if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) {
msg_params[hmi_request::soft_buttons] =
- (*message_)[strings::msg_params][strings::soft_buttons];
- MessageHelper::SubscribeApplicationToSoftButton((*message_)[strings::msg_params],
- app, function_id());
+ (*message_)[strings::msg_params][strings::soft_buttons];
+ MessageHelper::SubscribeApplicationToSoftButton(
+ (*message_)[strings::msg_params], app, function_id());
}
pending_requests_.Add(hmi_apis::FunctionID::Navigation_AlertManeuver);
- SendHMIRequest(hmi_apis::FunctionID::Navigation_AlertManeuver,
- &msg_params, true);
+ SendHMIRequest(
+ hmi_apis::FunctionID::Navigation_AlertManeuver, &msg_params, true);
if (tts_is_ok) {
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_params[hmi_request::tts_chunks] =
(*message_)[strings::msg_params][strings::tts_chunks];
@@ -131,9 +136,12 @@ void AlertManeuverRequest::Run() {
void AlertManeuverRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
+ using namespace helpers;
const smart_objects::SmartObject& message = event.smart_object();
-
- mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
+ bool is_tts_ok;
+ bool is_no_navi_error;
+ hmi_apis::Common_Result::eType tts_result;
+ hmi_apis::Common_Result::eType navi_result;
hmi_apis::FunctionID::eType event_id = event.id();
switch (event_id) {
case hmi_apis::FunctionID::Navigation_AlertManeuver: {
@@ -143,8 +151,23 @@ void AlertManeuverRequest::on_event(const event_engine::Event& event) {
navi_alert_maneuver_result_code_ =
static_cast<mobile_apis::Result::eType>(
- message[strings::params][hmi_response::code].asInt());
-
+ message[strings::params][hmi_response::code].asInt());
+ navi_result =
+ MessageHelper::MobileToHMIResult(navi_alert_maneuver_result_code_);
+ is_no_navi_error = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ navi_result,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::WARNINGS);
+
+ const bool is_navi_success =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ navi_result, hmi_apis::Common_Result::SUCCESS);
+ if (is_navi_success) {
+ info_navi_ =
+ message[strings::msg_params][hmi_response::message].asString();
+ } else {
+ info_navi_ = message[strings::msg_params][strings::info].asString();
+ }
break;
}
case hmi_apis::FunctionID::TTS_Speak: {
@@ -152,55 +175,85 @@ void AlertManeuverRequest::on_event(const event_engine::Event& event) {
pending_requests_.Remove(event_id);
- tts_speak_result_code_ =
- static_cast<mobile_apis::Result::eType>(
+ tts_speak_result_code_ = static_cast<mobile_apis::Result::eType>(
message[strings::params][hmi_response::code].asInt());
+ tts_result = MessageHelper::MobileToHMIResult(tts_speak_result_code_);
+
+ is_tts_ok = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ tts_result,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
+ hmi_apis::Common_Result::WARNINGS,
+ hmi_apis::Common_Result::INVALID_ENUM);
+
+ const bool is_tts_success =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ tts_result, hmi_apis::Common_Result::SUCCESS);
+ if (is_tts_success) {
+ info_tts_ =
+ message[strings::msg_params][hmi_response::message].asString();
+ } else {
+ info_tts_ = message[strings::msg_params][strings::info].asString();
+ }
break;
}
case hmi_apis::FunctionID::TTS_OnResetTimeout: {
LOG4CXX_INFO(logger_, "Received TTS_OnResetTimeout event");
- ApplicationManagerImpl::instance()->updateRequestTimeout(
+ application_manager_.updateRequestTimeout(
connection_key(), correlation_id(), default_timeout());
break;
}
default: {
- LOG4CXX_ERROR(logger_,"Received unknown event" << event.id());
- SendResponse(false, result_code, "Received unknown event");
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ SendResponse(
+ false, mobile_apis::Result::INVALID_ENUM, "Received unknown event");
return;
}
}
- if (pending_requests_.IsFinal(event_id)) {
+ if (!pending_requests_.IsFinal(event_id)) {
+ LOG4CXX_DEBUG(logger_,
+ "There are some pending responses from HMI."
+ "AlertManeuverRequest still waiting.");
+ return;
+ }
- bool result = ((mobile_apis::Result::SUCCESS == tts_speak_result_code_ ||
- mobile_apis::Result::UNSUPPORTED_RESOURCE == tts_speak_result_code_ ||
- mobile_apis::Result::INVALID_ENUM == tts_speak_result_code_) &&
- mobile_apis::Result::SUCCESS == navi_alert_maneuver_result_code_) ||
- (mobile_apis::Result::SUCCESS == tts_speak_result_code_ &&
- mobile_apis::Result::UNSUPPORTED_RESOURCE ==
- navi_alert_maneuver_result_code_);
+ const bool result =
+ (is_tts_ok && is_no_navi_error) ||
+ (hmi_apis::Common_Result::SUCCESS == tts_result &&
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == navi_result);
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(std::max(tts_speak_result_code_,
- navi_alert_maneuver_result_code_));
+ mobile_apis::Result::eType result_code =
+ static_cast<mobile_apis::Result::eType>(
+ std::max(tts_speak_result_code_, navi_alert_maneuver_result_code_));
- const char* return_info = NULL;
+ std::string return_info;
- if (result && mobile_apis::Result::UNSUPPORTED_RESOURCE ==
- tts_speak_result_code_) {
- result_code = mobile_apis::Result::WARNINGS;
- return_info = "Unsupported phoneme type sent in a prompt";
- }
+ const bool is_tts_or_navi_warning =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ hmi_apis::Common_Result::WARNINGS, tts_result, navi_result);
- SendResponse(result, result_code, return_info,
- &(message[strings::msg_params]));
- } else {
- LOG4CXX_INFO(logger_,
- "There are some pending responses from HMI."
- "AlertManeuverRequest still waiting.");
+ if (result && (is_tts_or_navi_warning ||
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result)) {
+ result_code = mobile_apis::Result::WARNINGS;
+ return_info = std::string("Unsupported phoneme type sent in a prompt");
+ }
+
+ if (!info_tts_.empty() && !info_navi_.empty()) {
+ info_tts_ += ". ";
+ }
+ return_info = info_tts_ + info_navi_;
+ bool must_be_empty_info = false;
+ if (return_info.find("\n") != std::string::npos ||
+ return_info.find("\t") != std::string::npos) {
+ must_be_empty_info = true;
}
+ SendResponse(result,
+ result_code,
+ (must_be_empty_info) ? NULL : return_info.c_str(),
+ &(message[strings::msg_params]));
}
bool AlertManeuverRequest::IsWhiteSpaceExist() {
diff --git a/src/components/application_manager/src/commands/mobile/alert_maneuver_response.cc b/src/components/application_manager/src/commands/mobile/alert_maneuver_response.cc
index 8f9c73267f..2f441594c2 100644
--- a/src/components/application_manager/src/commands/mobile/alert_maneuver_response.cc
+++ b/src/components/application_manager/src/commands/mobile/alert_maneuver_response.cc
@@ -32,24 +32,23 @@
*/
#include "application_manager/commands/mobile/alert_maneuver_response.h"
-#include "application_manager/application_manager_impl.h"
+
#include "interfaces/HMI_API.h"
namespace application_manager {
namespace commands {
-AlertManeuverResponse::AlertManeuverResponse(const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+AlertManeuverResponse::AlertManeuverResponse(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-AlertManeuverResponse::~AlertManeuverResponse() {
-}
+AlertManeuverResponse::~AlertManeuverResponse() {}
void AlertManeuverResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
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 ccabe4e177..53910a05b7 100644
--- a/src/components/application_manager/src/commands/mobile/alert_request.cc
+++ b/src/components/application_manager/src/commands/mobile/alert_request.cc
@@ -37,8 +37,9 @@
#include "application_manager/message_helper.h"
#include "application_manager/application_impl.h"
-#include "application_manager/application_manager_impl.h"
+#include "application_manager/policies/policy_handler.h"
+#include "utils/helpers.h"
namespace application_manager {
@@ -46,21 +47,21 @@ namespace commands {
namespace smart_objects = NsSmartDeviceLink::NsSmartObjects;
-AlertRequest::AlertRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message),
- awaiting_ui_alert_response_(false),
- awaiting_tts_speak_response_(false),
- awaiting_tts_stop_speaking_response_(false),
- response_success_(false),
- flag_other_component_sent_(false),
- response_result_(mobile_apis::Result::INVALID_ENUM),
- tts_speak_response_(mobile_apis::Result::INVALID_ENUM) {
+AlertRequest::AlertRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager)
+ , awaiting_ui_alert_response_(false)
+ , awaiting_tts_speak_response_(false)
+ , awaiting_tts_stop_speaking_response_(false)
+ , is_alert_succeeded_(false)
+ , is_ui_alert_sent_(false)
+ , alert_result_(mobile_apis::Result::INVALID_ENUM)
+ , tts_speak_result_(mobile_apis::Result::INVALID_ENUM) {
subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout);
subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout);
}
-AlertRequest::~AlertRequest() {
-}
+AlertRequest::~AlertRequest() {}
bool AlertRequest::Init() {
/* Timeout in milliseconds.
@@ -73,9 +74,11 @@ bool AlertRequest::Init() {
default_timeout_ = def_value;
}
- // If soft buttons are present, SDL will not use initiate timeout tracking for response.
+ // If soft buttons are present, SDL will not use initiate timeout tracking for
+ // response.
if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) {
- LOG4CXX_INFO(logger_, "Request contains soft buttons - request timeout "
+ LOG4CXX_INFO(logger_,
+ "Request contains soft buttons - request timeout "
"will be set to 0.");
default_timeout_ = 0;
}
@@ -86,48 +89,62 @@ bool AlertRequest::Init() {
void AlertRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- uint32_t app_id = (*message_)[strings::params][strings::connection_key]
- .asInt();
+ uint32_t app_id =
+ (*message_)[strings::params][strings::connection_key].asInt();
if (!Validate(app_id)) {
// Invalid command, abort execution
return;
}
+ bool tts_chunks_exists =
+ (*message_)[strings::msg_params].keyExists(strings::tts_chunks);
+ size_t length_tts_chunks = 0;
- if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) {
- if (0 < (*message_)[strings::msg_params][strings::tts_chunks].length()) {
- awaiting_tts_speak_response_ = true;
- }
+ if (tts_chunks_exists) {
+ length_tts_chunks =
+ (*message_)[strings::msg_params][strings::tts_chunks].length();
+ }
+
+ if ((tts_chunks_exists && length_tts_chunks) ||
+ ((*message_)[strings::msg_params].keyExists(strings::play_tone) &&
+ (*message_)[strings::msg_params][strings::play_tone].asBool())) {
+ awaiting_tts_speak_response_ = true;
}
+
SendAlertRequest(app_id);
- SendPlayToneNotification(app_id);
if (awaiting_tts_speak_response_) {
- SendSpeakRequest(app_id);
+ SendSpeakRequest(app_id, tts_chunks_exists, length_tts_chunks);
}
}
void AlertRequest::onTimeOut() {
- if (false == (*message_)[strings::msg_params].keyExists(strings::soft_buttons)) {
+ 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");
+ 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_);
+ using namespace helpers;
+
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
case hmi_apis::FunctionID::TTS_OnResetTimeout:
case hmi_apis::FunctionID::UI_OnResetTimeout: {
- LOG4CXX_INFO(logger_, "Received UI_OnResetTimeout event "
- " or TTS_OnResetTimeout event"
- << awaiting_tts_speak_response_ << " "
- << awaiting_tts_stop_speaking_response_ << " "
- << awaiting_ui_alert_response_);
- ApplicationManagerImpl::instance()->updateRequestTimeout(
+ LOG4CXX_INFO(logger_,
+ "Received UI_OnResetTimeout event "
+ " or TTS_OnResetTimeout event"
+ << awaiting_tts_speak_response_ << " "
+ << awaiting_tts_stop_speaking_response_ << " "
+ << awaiting_ui_alert_response_);
+ application_manager_.updateRequestTimeout(
connection_key(), correlation_id(), default_timeout());
break;
}
@@ -146,10 +163,16 @@ void AlertRequest::on_event(const event_engine::Event& event) {
static_cast<mobile_apis::Result::eType>(
message[strings::params][hmi_response::code].asInt());
// Mobile Alert request is successful when UI_Alert is successful
- response_success_ = (mobile_apis::Result::SUCCESS == result_code ||
- mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code);
- response_result_ = result_code;
- response_params_ = message[strings::msg_params];
+
+ const bool is_alert_ok = Compare<mobile_api::Result::eType, EQ, ONE>(
+ result_code,
+ mobile_apis::Result::SUCCESS,
+ mobile_apis::Result::UNSUPPORTED_RESOURCE,
+ mobile_apis::Result::WARNINGS);
+
+ is_alert_succeeded_ = is_alert_ok;
+ alert_result_ = result_code;
+ alert_response_params_ = message[strings::msg_params];
break;
}
case hmi_apis::FunctionID::TTS_Speak: {
@@ -157,7 +180,7 @@ void AlertRequest::on_event(const event_engine::Event& event) {
// Unsubscribe from event to avoid unwanted messages
unsubscribe_from_event(hmi_apis::FunctionID::TTS_Speak);
awaiting_tts_speak_response_ = false;
- tts_speak_response_ = static_cast<mobile_apis::Result::eType>(
+ tts_speak_result_ = static_cast<mobile_apis::Result::eType>(
message[strings::params][hmi_response::code].asInt());
break;
}
@@ -169,62 +192,82 @@ void AlertRequest::on_event(const event_engine::Event& event) {
break;
}
default: {
- LOG4CXX_ERROR(logger_,"Received unknown event" << event.id());
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
return;
}
}
- if (!HasHmiResponsesToWait()) {
- std::string response_info("");
- if ((mobile_apis::Result::UNSUPPORTED_RESOURCE == tts_speak_response_) &&
- (!flag_other_component_sent_)) {
- response_success_ = false;
- response_result_ = mobile_apis::Result::WARNINGS;
- response_info = "Unsupported phoneme type sent in a prompt";
- } else if ((mobile_apis::Result::UNSUPPORTED_RESOURCE ==
- tts_speak_response_) && (mobile_apis::Result::UNSUPPORTED_RESOURCE ==
- response_result_)) {
- response_result_ = mobile_apis::Result::WARNINGS;
- response_info = "Unsupported phoneme type sent in a prompt and "
- "unsupported image sent in soft buttons";
- } else if ((mobile_apis::Result::UNSUPPORTED_RESOURCE ==
- tts_speak_response_) && (mobile_apis::Result::SUCCESS ==
- response_result_)) {
- response_result_ = mobile_apis::Result::WARNINGS;
- response_info = "Unsupported phoneme type sent in a prompt";
- } else if ((mobile_apis::Result::SUCCESS == tts_speak_response_) &&
- ((mobile_apis::Result::INVALID_ENUM == response_result_) &&
- (!flag_other_component_sent_))) {
- response_result_ = mobile_apis::Result::SUCCESS;
- response_success_ = true;
- }
- if (((mobile_apis::Result::ABORTED == tts_speak_response_ )||
- (mobile_apis::Result::REJECTED == tts_speak_response_)) &&
- (!flag_other_component_sent_)) {
- response_success_ = false;
- response_result_ = tts_speak_response_;
- }
- SendResponse(response_success_, response_result_,
- response_info.empty() ? NULL : response_info.c_str(),
- &response_params_);
+ if (HasHmiResponsesToWait()) {
+ return;
+ }
+
+ const bool is_tts_alert_unsupported =
+ Compare<mobile_api::Result::eType, EQ, ALL>(
+ mobile_api::Result::UNSUPPORTED_RESOURCE,
+ tts_speak_result_,
+ alert_result_);
+
+ const bool is_alert_ok = Compare<mobile_api::Result::eType, EQ, ONE>(
+ alert_result_, mobile_api::Result::SUCCESS, mobile_api::Result::WARNINGS);
+
+ std::string response_info;
+ if (mobile_apis::Result::UNSUPPORTED_RESOURCE == tts_speak_result_ &&
+ !is_ui_alert_sent_) {
+ is_alert_succeeded_ = false;
+ alert_result_ = mobile_apis::Result::WARNINGS;
+ response_info = "Unsupported phoneme type sent in a prompt";
+ } else if (is_tts_alert_unsupported) {
+ alert_result_ = mobile_apis::Result::WARNINGS;
+ response_info =
+ "Unsupported phoneme type sent in a prompt and "
+ "unsupported image sent in soft buttons";
+ } else if (mobile_apis::Result::UNSUPPORTED_RESOURCE == tts_speak_result_ &&
+ is_alert_ok) {
+ alert_result_ = mobile_apis::Result::WARNINGS;
+ response_info = "Unsupported phoneme type sent in a prompt";
+ } else if (mobile_apis::Result::SUCCESS == tts_speak_result_ &&
+ (mobile_apis::Result::INVALID_ENUM == alert_result_ &&
+ !is_ui_alert_sent_)) {
+ alert_result_ = mobile_apis::Result::SUCCESS;
+ is_alert_succeeded_ = true;
+ }
+
+ const bool is_tts_not_ok =
+ Compare<mobile_api::Result::eType, EQ, ONE>(tts_speak_result_,
+ mobile_api::Result::ABORTED,
+ mobile_api::Result::REJECTED);
+
+ if (is_tts_not_ok && !is_ui_alert_sent_) {
+ is_alert_succeeded_ = false;
+ alert_result_ = tts_speak_result_;
+ }
+
+ if (mobile_apis::Result::WARNINGS == tts_speak_result_) {
+ alert_result_ = mobile_apis::Result::WARNINGS;
}
+
+ SendResponse(is_alert_succeeded_,
+ alert_result_,
+ response_info.empty() ? NULL : response_info.c_str(),
+ &alert_response_params_);
}
bool AlertRequest::Validate(uint32_t app_id) {
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
+ LOG4CXX_AUTO_TRACE(logger_);
+ ApplicationSharedPtr app = application_manager_.application(app_id);
if (!app) {
- LOG4CXX_ERROR_EXT(logger_, "No application associated with session key");
+ LOG4CXX_ERROR(logger_, "No application associated with session key");
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
return false;
}
if (mobile_apis::HMILevel::HMI_BACKGROUND == app->hmi_level() &&
app->IsCommandLimitsExceeded(
- static_cast<mobile_apis::FunctionID::eType>(function_id()),
- application_manager::TLimitSource::POLICY_TABLE)) {
+ static_cast<mobile_apis::FunctionID::eType>(function_id()),
+ application_manager::TLimitSource::POLICY_TABLE)) {
LOG4CXX_ERROR(logger_, "Alert frequency is too high.");
- SendResponse(false, mobile_apis::Result::REJECTED);
+ SendResponse(false, mobile_apis::Result::REJECTED);
return false;
}
@@ -233,10 +276,13 @@ bool AlertRequest::Validate(uint32_t app_id) {
return false;
}
- //ProcessSoftButtons checks strings on the contents incorrect character
+ // ProcessSoftButtons checks strings on the contents incorrect character
mobile_apis::Result::eType processing_result =
- MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], app);
+ MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params],
+ app,
+ application_manager_.GetPolicyHandler(),
+ application_manager_);
if (mobile_apis::Result::SUCCESS != processing_result) {
LOG4CXX_ERROR(logger_, "INVALID_DATA!");
@@ -245,13 +291,13 @@ bool AlertRequest::Validate(uint32_t app_id) {
}
// check if mandatory params(alertText1 and TTSChunk) specified
- if ((!(*message_)[strings::msg_params].keyExists(strings::alert_text1))
- && (!(*message_)[strings::msg_params].keyExists(strings::alert_text2))
- && (!(*message_)[strings::msg_params].keyExists(strings::tts_chunks)
- && (1 > (*message_)[strings::msg_params]
- [strings::tts_chunks].length()))) {
- LOG4CXX_ERROR_EXT(logger_, "Mandatory parameters are missing");
- SendResponse(false, mobile_apis::Result::INVALID_DATA,
+ if ((!(*message_)[strings::msg_params].keyExists(strings::alert_text1)) &&
+ (!(*message_)[strings::msg_params].keyExists(strings::alert_text2)) &&
+ (!(*message_)[strings::msg_params].keyExists(strings::tts_chunks) &&
+ (1 > (*message_)[strings::msg_params][strings::tts_chunks].length()))) {
+ LOG4CXX_ERROR(logger_, "Mandatory parameters are missing");
+ SendResponse(false,
+ mobile_apis::Result::INVALID_DATA,
"Mandatory parameters are missing");
return false;
}
@@ -260,21 +306,22 @@ bool AlertRequest::Validate(uint32_t app_id) {
}
void AlertRequest::SendAlertRequest(int32_t app_id) {
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
+ LOG4CXX_AUTO_TRACE(logger_);
+ ApplicationSharedPtr app = application_manager_.application(app_id);
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
- msg_params[hmi_request::alert_strings] = smart_objects::SmartObject(
- smart_objects::SmartType_Array);
+ msg_params[hmi_request::alert_strings] =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
int32_t index = 0;
if ((*message_)[strings::msg_params].keyExists(strings::alert_text1)) {
msg_params[hmi_request::alert_strings][index][hmi_request::field_name] =
hmi_apis::Common_TextFieldName::alertText1;
- msg_params[hmi_request::alert_strings][index][hmi_request::field_text] =
- (*message_)[strings::msg_params][strings::alert_text1];
- index++;
+ msg_params[hmi_request::alert_strings][index][hmi_request::field_text] =
+ (*message_)[strings::msg_params][strings::alert_text1];
+ index++;
}
if ((*message_)[strings::msg_params].keyExists(strings::alert_text2)) {
msg_params[hmi_request::alert_strings][index][hmi_request::field_name] =
@@ -287,7 +334,7 @@ void AlertRequest::SendAlertRequest(int32_t app_id) {
msg_params[hmi_request::alert_strings][index][hmi_request::field_name] =
hmi_apis::Common_TextFieldName::alertText3;
msg_params[hmi_request::alert_strings][index][hmi_request::field_text] =
- (*message_)[strings::msg_params][strings::alert_text3];
+ (*message_)[strings::msg_params][strings::alert_text3];
}
// softButtons
@@ -304,7 +351,7 @@ void AlertRequest::SendAlertRequest(int32_t app_id) {
// NAVI platform progressIndicator
if ((*message_)[strings::msg_params].keyExists(strings::progress_indicator)) {
msg_params[strings::progress_indicator] =
- (*message_)[strings::msg_params][strings::progress_indicator];
+ (*message_)[strings::msg_params][strings::progress_indicator];
}
// PASA Alert type
@@ -316,44 +363,35 @@ void AlertRequest::SendAlertRequest(int32_t app_id) {
// check out if there are alert strings or soft buttons
if (msg_params[hmi_request::alert_strings].length() > 0 ||
msg_params.keyExists(hmi_request::soft_buttons)) {
-
awaiting_ui_alert_response_ = true;
- flag_other_component_sent_ = true;
+ is_ui_alert_sent_ = true;
SendHMIRequest(hmi_apis::FunctionID::UI_Alert, &msg_params, true);
}
}
-void AlertRequest::SendSpeakRequest(int32_t app_id) {
+void AlertRequest::SendSpeakRequest(int32_t app_id,
+ bool tts_chunks_exists,
+ size_t length_tts_chunks) {
+ LOG4CXX_AUTO_TRACE(logger_);
using namespace hmi_apis;
using namespace smart_objects;
// crate HMI speak request
SmartObject msg_params = smart_objects::SmartObject(SmartType_Map);
-
- msg_params[hmi_request::tts_chunks] = smart_objects::SmartObject(SmartType_Array);
- msg_params[hmi_request::tts_chunks] =
- (*message_)[strings::msg_params][strings::tts_chunks];
+ if (tts_chunks_exists && length_tts_chunks) {
+ msg_params[hmi_request::tts_chunks] =
+ smart_objects::SmartObject(SmartType_Array);
+ msg_params[hmi_request::tts_chunks] =
+ (*message_)[strings::msg_params][strings::tts_chunks];
+ }
+ if ((*message_)[strings::msg_params].keyExists(strings::play_tone) &&
+ (*message_)[strings::msg_params][strings::play_tone].asBool()) {
+ msg_params[strings::play_tone] = true;
+ }
msg_params[strings::app_id] = app_id;
msg_params[hmi_request::speak_type] = Common_MethodName::ALERT;
SendHMIRequest(FunctionID::TTS_Speak, &msg_params, true);
}
-void AlertRequest::SendPlayToneNotification(int32_t app_id) {
- LOG4CXX_AUTO_TRACE(logger_);
- using namespace hmi_apis;
- using namespace smart_objects;
-
- // check playtone parameter
- if ((*message_)[strings::msg_params].keyExists(strings::play_tone)) {
- if ((*message_)[strings::msg_params][strings::play_tone].asBool()) {
- // crate HMI basic communication playtone request
- SmartObject msg_params = smart_objects::SmartObject(SmartType_Map);
- msg_params[strings::app_id] = app_id;
- msg_params[strings::method_name] = Common_MethodName::ALERT;
- CreateHMINotification(FunctionID::BasicCommunication_PlayTone, msg_params);
- }
- }
-}
-
bool AlertRequest::CheckStringsOfAlertRequest() {
LOG4CXX_AUTO_TRACE(logger_);
const char* str = NULL;
@@ -362,7 +400,7 @@ bool AlertRequest::CheckStringsOfAlertRequest() {
str = (*message_)[strings::msg_params][strings::alert_text1].asCharArray();
if (!CheckSyntax(str)) {
LOG4CXX_ERROR(logger_, "Invalid alert_text_1 syntax check failed");
- return false;
+ return false;
}
}
@@ -370,7 +408,7 @@ bool AlertRequest::CheckStringsOfAlertRequest() {
str = (*message_)[strings::msg_params][strings::alert_text2].asCharArray();
if (!CheckSyntax(str)) {
LOG4CXX_ERROR(logger_, "Invalid alert_text_2 syntax check failed");
- return false;
+ return false;
}
}
@@ -378,7 +416,7 @@ bool AlertRequest::CheckStringsOfAlertRequest() {
str = (*message_)[strings::msg_params][strings::alert_text3].asCharArray();
if (!CheckSyntax(str)) {
LOG4CXX_ERROR(logger_, "Invalid alert_text_3 syntax check failed");
- return false;
+ return false;
}
}
@@ -397,8 +435,9 @@ bool AlertRequest::CheckStringsOfAlertRequest() {
}
bool AlertRequest::HasHmiResponsesToWait() {
- return awaiting_ui_alert_response_ || awaiting_tts_speak_response_
- || awaiting_tts_stop_speaking_response_;
+ LOG4CXX_AUTO_TRACE(logger_);
+ return awaiting_ui_alert_response_ || awaiting_tts_speak_response_ ||
+ awaiting_tts_stop_speaking_response_;
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/alert_response.cc b/src/components/application_manager/src/commands/mobile/alert_response.cc
index dac086a8b1..f8ca487eae 100644
--- a/src/components/application_manager/src/commands/mobile/alert_response.cc
+++ b/src/components/application_manager/src/commands/mobile/alert_response.cc
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/alert_response.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "interfaces/MOBILE_API.h"
#include "interfaces/HMI_API.h"
@@ -41,17 +41,16 @@ namespace application_manager {
namespace commands {
-AlertResponse::AlertResponse(const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+AlertResponse::AlertResponse(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-AlertResponse::~AlertResponse() {
-}
+AlertResponse::~AlertResponse() {}
void AlertResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
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 89b2dbaf00..63339fdc33 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
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2013, Ford Motor Company
+ Copyright (c) 2016, Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -34,33 +34,45 @@
#include <string.h>
#include <algorithm>
#include "application_manager/commands/mobile/change_registration_request.h"
-#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_manager.h"
#include "application_manager/application_impl.h"
#include "interfaces/MOBILE_API.h"
#include "interfaces/HMI_API.h"
+namespace {
+namespace custom_str = utils::custom_string;
+struct IsSameNickname {
+ IsSameNickname(const custom_str::CustomString& app_id) : app_id_(app_id) {}
+ bool operator()(const policy::StringArray::value_type& nickname) const {
+ return app_id_.CompareIgnoreCase(nickname.c_str());
+ }
+
+ private:
+ const custom_str::CustomString& app_id_;
+};
+}
+
namespace application_manager {
namespace commands {
ChangeRegistrationRequest::ChangeRegistrationRequest(
- const MessageSharedPtr& message)
- : CommandRequestImpl(message),
- ui_result_(hmi_apis::Common_Result::INVALID_ENUM),
- vr_result_(hmi_apis::Common_Result::INVALID_ENUM),
- tts_result_(hmi_apis::Common_Result::INVALID_ENUM) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager)
+ , ui_result_(hmi_apis::Common_Result::INVALID_ENUM)
+ , vr_result_(hmi_apis::Common_Result::INVALID_ENUM)
+ , tts_result_(hmi_apis::Common_Result::INVALID_ENUM) {}
-ChangeRegistrationRequest::~ChangeRegistrationRequest() {
-}
+ChangeRegistrationRequest::~ChangeRegistrationRequest() {}
void ChangeRegistrationRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
+ using namespace smart_objects;
- ApplicationManagerImpl* instance = ApplicationManagerImpl::instance();
- const HMICapabilities& hmi_capabilities = instance->hmi_capabilities();
+ const HMICapabilities& hmi_capabilities =
+ application_manager_.hmi_capabilities();
- ApplicationSharedPtr app = instance->application(connection_key());
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
LOG4CXX_ERROR(logger_, "NULL pointer");
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
@@ -91,90 +103,84 @@ void ChangeRegistrationRequest::Run() {
tts_result_ = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE;
}
+ SmartObject& msg_params = (*message_)[strings::msg_params];
+
const int32_t hmi_language =
- (*message_)[strings::msg_params][strings::hmi_display_language].asInt();
+ msg_params[strings::hmi_display_language].asInt();
- const int32_t language =
- (*message_)[strings::msg_params][strings::language].asInt();
+ const int32_t language = msg_params[strings::language].asInt();
- if (false ==
- (IsLanguageSupportedByUI(hmi_language) &&
- IsLanguageSupportedByVR(language) &&
- IsLanguageSupportedByTTS(language))) {
+ if (false == (IsLanguageSupportedByUI(hmi_language) &&
+ IsLanguageSupportedByVR(language) &&
+ IsLanguageSupportedByTTS(language))) {
LOG4CXX_ERROR(logger_, "Language is not supported");
SendResponse(false, mobile_apis::Result::REJECTED);
return;
}
+ if (msg_params.keyExists(strings::app_name) &&
+ !IsNicknameAllowed(msg_params[strings::app_name].asCustomString())) {
+ LOG4CXX_ERROR(logger_, "Nickname is not allowed.");
+ SendResponse(false, mobile_apis::Result::DISALLOWED);
+ 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);
// UI processing
- smart_objects::SmartObject ui_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ SmartObject ui_params = SmartObject(SmartType_Map);
ui_params[strings::language] = hmi_language;
ui_params[strings::app_id] = app->app_id();
- if ((*message_)[strings::msg_params].keyExists(strings::app_name)) {
- ui_params[strings::app_name] =
- (*message_)[strings::msg_params][strings::app_name];
- app->set_name((*message_)[strings::msg_params][strings::app_name].asString());
+ 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 ((*message_)[strings::msg_params].keyExists(
- strings::ngn_media_screen_app_name)) {
+ if (msg_params.keyExists(strings::ngn_media_screen_app_name)) {
ui_params[strings::ngn_media_screen_app_name] =
- (*message_)[strings::msg_params][strings::ngn_media_screen_app_name];
- app->set_ngn_media_screen_name((*message_)[strings::msg_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]);
}
- SendHMIRequest(hmi_apis::FunctionID::UI_ChangeRegistration,
- &ui_params, true);
+ SendHMIRequest(hmi_apis::FunctionID::UI_ChangeRegistration, &ui_params, true);
// VR processing
- smart_objects::SmartObject vr_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
+ SmartObject vr_params = SmartObject(SmartType_Map);
- vr_params[strings::language] =
- (*message_)[strings::msg_params][strings::language];
+ vr_params[strings::language] = msg_params[strings::language];
vr_params[strings::app_id] = app->app_id();
- if ((*message_)[strings::msg_params].keyExists(strings::vr_synonyms)) {
- vr_params[strings::vr_synonyms] = (*message_)[strings::msg_params]
- [strings::vr_synonyms];
- app -> set_vr_synonyms((*message_)[strings::msg_params][strings::vr_synonyms]);
+ 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]);
}
- SendHMIRequest(hmi_apis::FunctionID::VR_ChangeRegistration,
- &vr_params, true);
+ SendHMIRequest(hmi_apis::FunctionID::VR_ChangeRegistration, &vr_params, true);
// TTS processing
- smart_objects::SmartObject tts_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
+ SmartObject tts_params = SmartObject(SmartType_Map);
- tts_params[strings::language] =
- (*message_)[strings::msg_params][strings::language];
+ tts_params[strings::language] = msg_params[strings::language];
tts_params[strings::app_id] = app->app_id();
- if ((*message_)[strings::msg_params].keyExists(strings::tts_name)) {
- tts_params[strings::tts_name] = (*message_)[strings::msg_params]
- [strings::tts_name];
- app->set_tts_name((*message_)[strings::msg_params][strings::tts_name]);
+ 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]);
}
- SendHMIRequest(hmi_apis::FunctionID::TTS_ChangeRegistration,
- &tts_params, true);
+ SendHMIRequest(
+ hmi_apis::FunctionID::TTS_ChangeRegistration, &tts_params, true);
}
bool ChangeRegistrationRequest::AllHmiResponsesSuccess(
- const hmi_apis::Common_Result::eType ui,
- const hmi_apis::Common_Result::eType vr,
- const hmi_apis::Common_Result::eType tts) {
-
- return
- hmi_apis::Common_Result::SUCCESS == ui &&
- hmi_apis::Common_Result::SUCCESS == vr &&
- hmi_apis::Common_Result::SUCCESS == tts;
+ const hmi_apis::Common_Result::eType ui,
+ const hmi_apis::Common_Result::eType vr,
+ const hmi_apis::Common_Result::eType tts) {
+ return hmi_apis::Common_Result::SUCCESS == ui &&
+ hmi_apis::Common_Result::SUCCESS == vr &&
+ hmi_apis::Common_Result::SUCCESS == tts;
}
void ChangeRegistrationRequest::on_event(const event_engine::Event& event) {
@@ -213,7 +219,7 @@ void ChangeRegistrationRequest::on_event(const event_engine::Event& event) {
if (pending_requests_.IsFinal(event_id)) {
ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(connection_key());
+ application_manager_.application(connection_key());
if (!application) {
LOG4CXX_ERROR(logger_, "NULL pointer");
@@ -222,36 +228,37 @@ void ChangeRegistrationRequest::on_event(const event_engine::Event& event) {
if (hmi_apis::Common_Result::SUCCESS == ui_result_) {
application->set_ui_language(static_cast<mobile_api::Language::eType>(
- (*message_)[strings::msg_params][strings::hmi_display_language].asInt()));
+ (*message_)[strings::msg_params][strings::hmi_display_language]
+ .asInt()));
}
- if (hmi_apis::Common_Result::SUCCESS == vr_result_
- || hmi_apis::Common_Result::SUCCESS == tts_result_) {
+ if (hmi_apis::Common_Result::SUCCESS == vr_result_ ||
+ hmi_apis::Common_Result::SUCCESS == tts_result_) {
application->set_language(static_cast<mobile_api::Language::eType>(
(*message_)[strings::msg_params][strings::language].asInt()));
}
- int32_t greates_result_code = std::max(std::max(ui_result_, vr_result_),
- tts_result_);
+ int32_t greates_result_code =
+ std::max(std::max(ui_result_, vr_result_), tts_result_);
(*message_)[strings::params][strings::function_id] =
- mobile_apis::FunctionID::eType::ChangeRegistrationID;
+ mobile_apis::FunctionID::eType::ChangeRegistrationID;
SendResponse(AllHmiResponsesSuccess(ui_result_, vr_result_, tts_result_),
static_cast<mobile_apis::Result::eType>(greates_result_code),
- NULL, &(message[strings::msg_params]));
+ NULL,
+ &(message[strings::msg_params]));
} else {
LOG4CXX_INFO(logger_,
- "There are some pending responses from HMI."
- "ChangeRegistrationRequest still waiting.");
+ "There are some pending responses from HMI."
+ "ChangeRegistrationRequest still waiting.");
}
}
bool ChangeRegistrationRequest::IsLanguageSupportedByUI(
const int32_t& hmi_display_lang) {
-
const HMICapabilities& hmi_capabilities =
- ApplicationManagerImpl::instance()->hmi_capabilities();
+ application_manager_.hmi_capabilities();
const smart_objects::SmartObject* ui_languages =
hmi_capabilities.ui_supported_languages();
@@ -274,7 +281,7 @@ bool ChangeRegistrationRequest::IsLanguageSupportedByUI(
bool ChangeRegistrationRequest::IsLanguageSupportedByVR(
const int32_t& hmi_display_lang) {
const HMICapabilities& hmi_capabilities =
- ApplicationManagerImpl::instance()->hmi_capabilities();
+ application_manager_.hmi_capabilities();
const smart_objects::SmartObject* vr_languages =
hmi_capabilities.vr_supported_languages();
@@ -297,7 +304,7 @@ bool ChangeRegistrationRequest::IsLanguageSupportedByVR(
bool ChangeRegistrationRequest::IsLanguageSupportedByTTS(
const int32_t& hmi_display_lang) {
const HMICapabilities& hmi_capabilities =
- ApplicationManagerImpl::instance()->hmi_capabilities();
+ application_manager_.hmi_capabilities();
const smart_objects::SmartObject* tts_languages =
hmi_capabilities.tts_supported_languages();
@@ -344,10 +351,10 @@ bool ChangeRegistrationRequest::IsWhiteSpaceExist() {
}
}
- if ((*message_)[strings::msg_params].
- keyExists(strings::ngn_media_screen_app_name)) {
- str = (*message_)[strings::msg_params]
- [strings::ngn_media_screen_app_name].asCharArray();
+ if ((*message_)[strings::msg_params].keyExists(
+ strings::ngn_media_screen_app_name)) {
+ str = (*message_)[strings::msg_params][strings::ngn_media_screen_app_name]
+ .asCharArray();
if (!CheckSyntax(str)) {
LOG4CXX_ERROR(logger_,
"Invalid ngn_media_screen_app_name syntax check failed");
@@ -379,22 +386,22 @@ mobile_apis::Result::eType ChangeRegistrationRequest::CheckCoincidence() {
const smart_objects::SmartObject& msg_params =
(*message_)[strings::msg_params];
- ApplicationManagerImpl::ApplicationListAccessor accessor;
- std::string app_name;
+ ApplicationSet accessor = application_manager_.applications().GetData();
+ custom_str::CustomString app_name;
uint32_t app_id = connection_key();
if (msg_params.keyExists(strings::app_name)) {
- app_name = msg_params[strings::app_name].asString();
+ app_name = msg_params[strings::app_name].asCustomString();
}
- ApplicationManagerImpl::ApplictionSetConstIt it = accessor.begin();
+ ApplicationSetConstIt it = accessor.begin();
for (; accessor.end() != it; ++it) {
if (app_id == (*it)->app_id()) {
continue;
}
- const std::string& cur_name = (*it)->name();
+ const custom_str::CustomString& cur_name = (*it)->name();
if (msg_params.keyExists(strings::app_name)) {
- if (!strcasecmp(app_name.c_str(), cur_name.c_str())) {
+ if (app_name.CompareIgnoreCase(cur_name)) {
LOG4CXX_ERROR(logger_, "Application name is known already.");
return mobile_apis::Result::DUPLICATE_NAME;
}
@@ -423,10 +430,57 @@ mobile_apis::Result::eType ChangeRegistrationRequest::CheckCoincidence() {
return mobile_apis::Result::DUPLICATE_NAME;
}
} // end vr check
- } // application for end
+ } // application for end
return mobile_apis::Result::SUCCESS;
}
+bool ChangeRegistrationRequest::IsNicknameAllowed(
+ const custom_str::CustomString& app_name) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
+
+ if (!app) {
+ LOG4CXX_ERROR(logger_,
+ "Can't find appication with connection key "
+ << connection_key());
+ return false;
+ }
+
+ const std::string policy_app_id = app->policy_app_id();
+
+ policy::StringArray app_nicknames;
+ policy::StringArray app_hmi_types;
+
+ bool init_result = application_manager_.GetPolicyHandler().GetInitialAppData(
+ policy_app_id, &app_nicknames, &app_hmi_types);
+
+ if (!init_result) {
+ LOG4CXX_ERROR(logger_,
+ "Error during getting of nickname list for application "
+ << policy_app_id);
+ return false;
+ }
+
+ if (!app_nicknames.empty()) {
+ IsSameNickname compare(app_name);
+ policy::StringArray::const_iterator it =
+ std::find_if(app_nicknames.begin(), app_nicknames.end(), compare);
+ if (app_nicknames.end() == it) {
+ LOG4CXX_WARN(logger_,
+ "Application name was not found in nicknames list.");
+
+ usage_statistics::AppCounter count_of_rejections_nickname_mismatch(
+ application_manager_.GetPolicyHandler().GetStatisticManager(),
+ policy_app_id,
+ usage_statistics::REJECTIONS_NICKNAME_MISMATCH);
+ ++count_of_rejections_nickname_mismatch;
+
+ return false;
+ }
+ }
+ return true;
+}
+
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/change_registration_response.cc b/src/components/application_manager/src/commands/mobile/change_registration_response.cc
index 557614f173..210cae64c5 100644
--- a/src/components/application_manager/src/commands/mobile/change_registration_response.cc
+++ b/src/components/application_manager/src/commands/mobile/change_registration_response.cc
@@ -32,24 +32,21 @@
*/
#include "application_manager/commands/mobile/change_registration_response.h"
-#include "application_manager/application_manager_impl.h"
namespace application_manager {
namespace commands {
ChangeRegistrationResponse::ChangeRegistrationResponse(
- const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-ChangeRegistrationResponse::~ChangeRegistrationResponse() {
-}
+ChangeRegistrationResponse::~ChangeRegistrationResponse() {}
void ChangeRegistrationResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
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 0dceaf0fa1..a7bb5ebc0b 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
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2013, Ford Motor Company
+ Copyright (c) 2016, Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -31,28 +31,28 @@
POSSIBILITY OF SUCH DAMAGE.
*/
-#include <string.h>
#include <string>
#include <algorithm>
#include <vector>
#include "application_manager/commands/mobile/create_interaction_choice_set_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
+#include "utils/gen_hash.h"
+#include "utils/helpers.h"
namespace application_manager {
namespace commands {
CreateInteractionChoiceSetRequest::CreateInteractionChoiceSetRequest(
- const MessageSharedPtr& message)
- : CommandRequestImpl(message),
- choice_set_id_(0),
- expected_chs_count_(0),
- received_chs_count_(0),
- error_from_hmi_(false),
- is_timed_out_(false) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager)
+ , choice_set_id_(0)
+ , expected_chs_count_(0)
+ , received_chs_count_(0)
+ , error_from_hmi_(false)
+ , is_timed_out_(false) {}
CreateInteractionChoiceSetRequest::~CreateInteractionChoiceSetRequest() {
LOG4CXX_AUTO_TRACE(logger_);
@@ -61,8 +61,7 @@ CreateInteractionChoiceSetRequest::~CreateInteractionChoiceSetRequest() {
void CreateInteractionChoiceSetRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
using namespace mobile_apis;
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
- (*message_)[strings::params][strings::connection_key].asUInt());
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
LOG4CXX_ERROR(logger_, "NULL pointer");
@@ -74,31 +73,37 @@ void CreateInteractionChoiceSetRequest::Run() {
++i) {
Result::eType verification_result_image = Result::SUCCESS;
Result::eType verification_result_secondary_image = Result::SUCCESS;
- if ((*message_)[strings::msg_params]
- [strings::choice_set][i].keyExists(strings::image)) {
+ if ((*message_)[strings::msg_params][strings::choice_set][i].keyExists(
+ strings::image)) {
verification_result_image = MessageHelper::VerifyImage(
- (*message_)[strings::msg_params][strings::choice_set]
- [i][strings::image], app);
+ (*message_)[strings::msg_params][strings::choice_set][i]
+ [strings::image],
+ app,
+ application_manager_);
}
- if ((*message_)[strings::msg_params]
- [strings::choice_set][i].keyExists(strings::secondary_image)) {
+ if ((*message_)[strings::msg_params][strings::choice_set][i].keyExists(
+ strings::secondary_image)) {
verification_result_secondary_image = MessageHelper::VerifyImage(
- (*message_)[strings::msg_params][strings::choice_set]
- [i][strings::secondary_image], app);
+ (*message_)[strings::msg_params][strings::choice_set][i]
+ [strings::secondary_image],
+ app,
+ application_manager_);
}
if (verification_result_image == Result::INVALID_DATA ||
verification_result_secondary_image == Result::INVALID_DATA) {
- LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!");
- SendResponse(false, Result::INVALID_DATA);
+ LOG4CXX_ERROR(logger_, "Image verification failed.");
+ SendResponse(false, Result::INVALID_DATA);
return;
}
}
- choice_set_id_ = (*message_)[strings::msg_params]
- [strings::interaction_choice_set_id].asInt();
+ choice_set_id_ =
+ (*message_)[strings::msg_params][strings::interaction_choice_set_id]
+ .asInt();
if (app->FindChoiceSet(choice_set_id_)) {
- LOG4CXX_ERROR(logger_, "Invalid ID");
+ LOG4CXX_ERROR(logger_,
+ "Choice set with id " << choice_set_id_ << " is not found.");
SendResponse(false, Result::INVALID_ID);
return;
}
@@ -108,134 +113,64 @@ void CreateInteractionChoiceSetRequest::Run() {
SendResponse(false, result);
return;
}
- uint32_t grammar_id = ApplicationManagerImpl::instance()->GenerateGrammarID();
+ uint32_t grammar_id = application_manager_.GenerateGrammarID();
(*message_)[strings::msg_params][strings::grammar_id] = grammar_id;
app->AddChoiceSet(choice_set_id_, (*message_)[strings::msg_params]);
SendVRAddCommandRequests(app);
}
mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet(
- ApplicationConstSharedPtr app) {
+ ApplicationConstSharedPtr app) {
+ using namespace smart_objects;
LOG4CXX_AUTO_TRACE(logger_);
- const smart_objects::SmartArray* new_choice_set_array =
- (*message_)[strings::msg_params][strings::choice_set].asArray();
-
- smart_objects::SmartArray::const_iterator it_array =
- new_choice_set_array->begin();
+ std::set<uint32_t> choice_id_set;
- smart_objects::SmartArray::const_iterator it_array_end =
- new_choice_set_array->end();
+ const SmartArray* choice_set =
+ (*message_)[strings::msg_params][strings::choice_set].asArray();
- // Self check of new choice set for params coincidence
- for (; it_array != it_array_end; ++it_array) {
- const smart_objects::SmartArray* vr_array =
- (*it_array)[strings::vr_commands].asArray();
+ SmartArray::const_iterator choice_set_it = choice_set->begin();
- CoincidencePredicateChoiceID c((*it_array)[strings::choice_id].asInt());
- if (1 != std::count_if(
- new_choice_set_array->begin(),
- new_choice_set_array->end(), c)) {
- LOG4CXX_ERROR(logger_, "Incoming choice set has duplicate IDs.");
+ for (; choice_set->end() != choice_set_it; ++choice_set_it) {
+ std::pair<std::set<uint32_t>::iterator, bool> ins_res =
+ choice_id_set.insert((*choice_set_it)[strings::choice_id].asInt());
+ if (!ins_res.second) {
+ LOG4CXX_ERROR(logger_,
+ "Choise with ID "
+ << (*choice_set_it)[strings::choice_id].asInt()
+ << " already exists");
return mobile_apis::Result::INVALID_ID;
}
- // Check new choice set params along with already registered choice sets
- const DataAccessor<ChoiceSetMap> accessor = app->choice_set_map();
- const ChoiceSetMap& app_choice_set_map = accessor.GetData();
- ChoiceSetMap::const_iterator it = app_choice_set_map.begin();
- ChoiceSetMap::const_iterator itEnd = app_choice_set_map.end();
- for (; it != itEnd; ++it) {
- const smart_objects::SmartObject* app_choice_set = it->second;
- if (NULL != app_choice_set) {
- const smart_objects::SmartArray* curr_choice_set =
- (*app_choice_set)[strings::choice_set].asArray();
-
- if (0 != std::count_if(
- curr_choice_set->begin(),
- curr_choice_set->end(),
- c)) {
- LOG4CXX_ERROR(logger_, "Incoming choice ID already exists.");
- return mobile_apis::Result::INVALID_ID;
- }
- }
- }
-
- CoincidencePredicateMenuName m((*it_array)[strings::menu_name].asString());
- if (1 != std::count_if(
- new_choice_set_array->begin(),
- new_choice_set_array->end(),
- m)) {
- LOG4CXX_ERROR(logger_, "Incoming choice set has duplicate menu names.");
- return mobile_apis::Result::DUPLICATE_NAME;
- }
-
- // Check coincidence inside the current choice
-
- smart_objects::SmartArray::const_iterator it_vr = vr_array->begin();
- smart_objects::SmartArray::const_iterator it_vr_end = vr_array->end();
-
- for (; it_vr != it_vr_end; ++it_vr) {
- CoincidencePredicateVRCommands v((*it_vr));
- if (1 != std::count_if(vr_array->begin(), vr_array->end(), v)) {
- LOG4CXX_ERROR(logger_,
- "Incoming choice set has duplicate VR command(s)");
-
- return mobile_apis::Result::DUPLICATE_NAME;
- }
- }
-
- // Check along with VR commands in other choices in the new set
- smart_objects::SmartArray::const_iterator it_same_array =
- new_choice_set_array->begin();
-
- smart_objects::SmartArray::const_iterator it_same_array_end =
- new_choice_set_array->end();
-
- for (; it_same_array != it_same_array_end; ++it_same_array) {
- // Skip check for itself
- if ((*it_array)[strings::choice_id] ==
- (*it_same_array)[strings::choice_id]) {
- continue;
- }
-
- if (compareSynonyms((*it_array), (*it_same_array))) {
- LOG4CXX_ERROR(logger_,
- "Incoming choice set has duplicate VR command(s).");
-
- return mobile_apis::Result::DUPLICATE_NAME;
- }
- }
-
- if (IsWhiteSpaceExist((*it_array))) {
- LOG4CXX_ERROR(logger_,
- "Incoming choice set has contains \t\n \\t \\n");
+ if (IsWhiteSpaceExist(*choice_set_it)) {
+ LOG4CXX_ERROR(logger_, "Incoming choice set has contains \t\n \\t \\n");
return mobile_apis::Result::INVALID_DATA;
}
}
-
return mobile_apis::Result::SUCCESS;
}
bool CreateInteractionChoiceSetRequest::compareSynonyms(
- const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice1,
- const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice2) {
+ const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice1,
+ const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice2) {
smart_objects::SmartArray* vr_cmds_1 =
- choice1[strings::vr_commands].asArray();
+ choice1[strings::vr_commands].asArray();
DCHECK(vr_cmds_1 != NULL);
smart_objects::SmartArray* vr_cmds_2 =
- choice2[strings::vr_commands].asArray();
+ choice2[strings::vr_commands].asArray();
DCHECK(vr_cmds_2 != NULL);
smart_objects::SmartArray::iterator it;
- it = std::find_first_of(vr_cmds_1->begin(), vr_cmds_1->end(),
- vr_cmds_2->begin(), vr_cmds_2->end(),
+ it = std::find_first_of(vr_cmds_1->begin(),
+ vr_cmds_1->end(),
+ vr_cmds_2->begin(),
+ vr_cmds_2->end(),
CreateInteractionChoiceSetRequest::compareStr);
-
if (it != vr_cmds_1->end()) {
- LOG4CXX_INFO(logger_, "Incoming choice set has duplicated VR synonyms "
- << it->asString());
+ LOG4CXX_INFO(logger_,
+ "Incoming choice set has duplicated VR synonyms "
+ << it->asString());
return true;
}
@@ -243,13 +178,13 @@ bool CreateInteractionChoiceSetRequest::compareSynonyms(
}
bool CreateInteractionChoiceSetRequest::compareStr(
- const NsSmartDeviceLink::NsSmartObjects::SmartObject& str1,
- const NsSmartDeviceLink::NsSmartObjects::SmartObject& str2) {
+ const NsSmartDeviceLink::NsSmartObjects::SmartObject& str1,
+ const NsSmartDeviceLink::NsSmartObjects::SmartObject& str2) {
return 0 == strcasecmp(str1.asCharArray(), str2.asCharArray());
}
bool CreateInteractionChoiceSetRequest::IsWhiteSpaceExist(
- const smart_objects::SmartObject& choice_set) {
+ const smart_objects::SmartObject& choice_set) {
LOG4CXX_AUTO_TRACE(logger_);
const char* str = NULL;
@@ -276,8 +211,7 @@ bool CreateInteractionChoiceSetRequest::IsWhiteSpaceExist(
}
if (choice_set.keyExists(strings::vr_commands)) {
- const size_t len =
- choice_set[strings::vr_commands].length();
+ const size_t len = choice_set[strings::vr_commands].length();
for (size_t i = 0; i < len; ++i) {
str = choice_set[strings::vr_commands][i].asCharArray();
@@ -299,8 +233,9 @@ bool CreateInteractionChoiceSetRequest::IsWhiteSpaceExist(
if (choice_set.keyExists(strings::secondary_image)) {
str = choice_set[strings::secondary_image][strings::value].asCharArray();
if (!CheckSyntax(str)) {
- LOG4CXX_ERROR(logger_, "Invalid secondary_image value. "
- "Syntax check failed");
+ LOG4CXX_ERROR(logger_,
+ "Invalid secondary_image value. "
+ "Syntax check failed");
return true;
}
}
@@ -308,15 +243,15 @@ bool CreateInteractionChoiceSetRequest::IsWhiteSpaceExist(
}
void CreateInteractionChoiceSetRequest::SendVRAddCommandRequests(
- application_manager::ApplicationSharedPtr const app) {
+ application_manager::ApplicationSharedPtr const app) {
LOG4CXX_AUTO_TRACE(logger_);
smart_objects::SmartObject& choice_set = (*message_)[strings::msg_params];
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_params[strings::type] = hmi_apis::Common_VRCommandType::Choice;
msg_params[strings::app_id] = app->app_id();
- msg_params[strings::grammar_id] = choice_set[strings::grammar_id];
+ msg_params[strings::grammar_id] = choice_set[strings::grammar_id];
const uint32_t choice_count = choice_set[strings::choice_set].length();
SetAllowedToTerminate(false);
@@ -326,17 +261,18 @@ void CreateInteractionChoiceSetRequest::SendVRAddCommandRequests(
{
sync_primitives::AutoLock error_lock(error_from_hmi_lock_);
if (error_from_hmi_) {
- LOG4CXX_WARN(logger_, "Error from HMI received. Stop sending VRCommands");
+ LOG4CXX_WARN(logger_,
+ "Error from HMI received. Stop sending VRCommands");
break;
}
}
msg_params[strings::cmd_id] =
- choice_set[strings::choice_set][chs_num][strings::choice_id];
- msg_params[strings::vr_commands] = smart_objects::SmartObject(
- smart_objects::SmartType_Array);
+ choice_set[strings::choice_set][chs_num][strings::choice_id];
+ msg_params[strings::vr_commands] =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
msg_params[strings::vr_commands] =
- choice_set[strings::choice_set][chs_num][strings::vr_commands];
+ choice_set[strings::choice_set][chs_num][strings::vr_commands];
sync_primitives::AutoLock commands_lock(vr_commands_lock_);
const uint32_t vr_cmd_id = msg_params[strings::cmd_id].asUInt();
@@ -345,8 +281,9 @@ void CreateInteractionChoiceSetRequest::SendVRAddCommandRequests(
VRCommandInfo vr_command(vr_cmd_id);
sent_commands_map_[vr_corr_id] = vr_command;
- LOG4CXX_DEBUG(logger_, "VR_command sent corr_id "
- << vr_corr_id << " cmd_id " << vr_corr_id);
+ LOG4CXX_DEBUG(logger_,
+ "VR_command sent corr_id " << vr_corr_id << " cmd_id "
+ << vr_corr_id);
}
expected_chs_count_ = chs_num;
LOG4CXX_DEBUG(logger_, "expected_chs_count_ = " << expected_chs_count_);
@@ -355,58 +292,60 @@ void CreateInteractionChoiceSetRequest::SendVRAddCommandRequests(
void CreateInteractionChoiceSetRequest::on_event(
const event_engine::Event& event) {
using namespace hmi_apis;
+ using namespace helpers;
LOG4CXX_AUTO_TRACE(logger_);
const smart_objects::SmartObject& message = event.smart_object();
if (event.id() == hmi_apis::FunctionID::VR_AddCommand) {
received_chs_count_++;
- LOG4CXX_DEBUG(logger_, "Got VR.AddCommand response, there are "
- << expected_chs_count_ - received_chs_count_
- << " more to wait.");
-
- uint32_t corr_id = static_cast<uint32_t>(message[strings::params]
- [strings::correlation_id].asUInt());
- SentCommandsMap::iterator it = sent_commands_map_.find(corr_id);
- if (sent_commands_map_.end() == it) {
- LOG4CXX_WARN(logger_, "HMI response for unknown VR command received");
- return;
- }
+ LOG4CXX_DEBUG(logger_,
+ "Got VR.AddCommand response, there are "
+ << expected_chs_count_ - received_chs_count_
+ << " more to wait.");
- Common_Result::eType vr_result_ = static_cast<Common_Result::eType>(
- message[strings::params][hmi_response::code].asInt());
- if (Common_Result::SUCCESS == vr_result_) {
- VRCommandInfo& vr_command = it->second;
- vr_command.succesful_response_received_ = true;
- } else {
- LOG4CXX_DEBUG(logger_, "Hmi response is not Success: " << vr_result_
- << ". Stop sending VRAddCommand requests");
- sync_primitives::AutoLock error_lock(error_from_hmi_lock_);
- if (!error_from_hmi_) {
- error_from_hmi_ = true;
- SendResponse(false, GetMobileResultCode(vr_result_));
+ uint32_t corr_id = static_cast<uint32_t>(
+ message[strings::params][strings::correlation_id].asUInt());
+ {
+ sync_primitives::AutoLock commands_lock(vr_commands_lock_);
+ SentCommandsMap::iterator it = sent_commands_map_.find(corr_id);
+ if (sent_commands_map_.end() == it) {
+ LOG4CXX_WARN(logger_, "HMI response for unknown VR command received");
+ return;
}
- }
- // update request timeout for case we send many VR add command requests
- // and HMI has no time to send responses for all of them
- LOG4CXX_DEBUG(logger_, "expected_chs_count_ = " << expected_chs_count_
- << "received_chs_count_ = " << received_chs_count_);
- if (received_chs_count_ < expected_chs_count_) {
- sync_primitives::AutoLock timeout_lock_(is_timed_out_lock_);
- if (!is_timed_out_) {
- ApplicationManagerImpl::instance()->updateRequestTimeout(
- connection_key(), correlation_id(), default_timeout());
+ Common_Result::eType vr_result = static_cast<Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+
+ const bool is_vr_no_error = Compare<Common_Result::eType, EQ, ONE>(
+ vr_result, Common_Result::SUCCESS, Common_Result::WARNINGS);
+
+ if (is_vr_no_error) {
+ VRCommandInfo& vr_command = it->second;
+ vr_command.succesful_response_received_ = true;
+ } else {
+ LOG4CXX_DEBUG(logger_,
+ "Hmi response is not Success: "
+ << vr_result
+ << ". Stop sending VRAddCommand requests");
+ if (!error_from_hmi_) {
+ error_from_hmi_ = true;
+ SendResponse(false, GetMobileResultCode(vr_result));
+ }
}
- } else {
- OnAllHMIResponsesReceived();
}
+ if (received_chs_count_ < expected_chs_count_) {
+ application_manager_.updateRequestTimeout(
+ connection_key(), correlation_id(), default_timeout());
+ LOG4CXX_DEBUG(logger_, "Timeout for request was updated");
+ return;
+ }
+ OnAllHMIResponsesReceived();
}
}
void CreateInteractionChoiceSetRequest::onTimeOut() {
LOG4CXX_AUTO_TRACE(logger_);
- sync_primitives::AutoLock error_lock(error_from_hmi_lock_);
if (!error_from_hmi_) {
SendResponse(false, mobile_apis::Result::GENERIC_ERROR);
}
@@ -416,15 +355,14 @@ void CreateInteractionChoiceSetRequest::onTimeOut() {
// according to SDLAQ-CRS-2976
sync_primitives::AutoLock timeout_lock_(is_timed_out_lock_);
is_timed_out_ = true;
- ApplicationManagerImpl::instance()->TerminateRequest(
- connection_key(), correlation_id());
+ application_manager_.TerminateRequest(connection_key(), correlation_id());
}
void CreateInteractionChoiceSetRequest::DeleteChoices() {
LOG4CXX_AUTO_TRACE(logger_);
ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(connection_key());
+ application_manager_.application(connection_key());
if (!application) {
LOG4CXX_ERROR(logger_, "NULL pointer");
return;
@@ -442,9 +380,9 @@ void CreateInteractionChoiceSetRequest::DeleteChoices() {
msg_param[strings::cmd_id] = vr_command_info.cmd_id_;
SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_param);
} else {
- LOG4CXX_WARN(
- logger_, "Succesfull response has not been received for cmd_id = "
- << vr_command_info.cmd_id_);
+ LOG4CXX_WARN(logger_,
+ "Succesfull response has not been received for cmd_id = "
+ << vr_command_info.cmd_id_);
}
}
sent_commands_map_.clear();
@@ -457,7 +395,7 @@ void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() {
SendResponse(true, mobile_apis::Result::SUCCESS);
ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(connection_key());
+ application_manager_.application(connection_key());
if (!application) {
LOG4CXX_ERROR(logger_, "NULL pointer");
return;
@@ -466,8 +404,8 @@ void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() {
} else {
DeleteChoices();
}
- ApplicationManagerImpl::instance()->TerminateRequest(connection_key(),
- correlation_id());
+
+ application_manager_.TerminateRequest(connection_key(), correlation_id());
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_response.cc b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_response.cc
index bc81206088..0cc137d6a0 100644
--- a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_response.cc
+++ b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_response.cc
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/create_interaction_choice_set_response.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "interfaces/MOBILE_API.h"
@@ -41,12 +41,10 @@ namespace application_manager {
namespace commands {
CreateInteractionChoiceSetResponse::CreateInteractionChoiceSetResponse(
- const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-CreateInteractionChoiceSetResponse::~CreateInteractionChoiceSetResponse() {
-}
+CreateInteractionChoiceSetResponse::~CreateInteractionChoiceSetResponse() {}
void CreateInteractionChoiceSetResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
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 99dd53d177..9a7b92f7b8 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
@@ -32,51 +32,54 @@
*/
#include "application_manager/commands/mobile/delete_command_request.h"
-#include "application_manager/application_manager_impl.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/helpers.h"
namespace application_manager {
namespace commands {
-DeleteCommandRequest::DeleteCommandRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message),
- is_ui_send_(false),
- is_vr_send_(false),
- is_ui_received_(false),
- is_vr_received_(false),
- ui_result_(hmi_apis::Common_Result::INVALID_ENUM),
- vr_result_(hmi_apis::Common_Result::INVALID_ENUM) {
-}
+DeleteCommandRequest::DeleteCommandRequest(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager)
+ , is_ui_send_(false)
+ , is_vr_send_(false)
+ , is_ui_received_(false)
+ , is_vr_received_(false)
+ , ui_result_(hmi_apis::Common_Result::INVALID_ENUM)
+ , vr_result_(hmi_apis::Common_Result::INVALID_ENUM) {}
-DeleteCommandRequest::~DeleteCommandRequest() {
-}
+DeleteCommandRequest::~DeleteCommandRequest() {}
void DeleteCommandRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(
- (*message_)[strings::params][strings::connection_key].asUInt());
+ ApplicationSharedPtr application =
+ application_manager_.application(connection_key());
if (!application) {
- SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
LOG4CXX_ERROR(logger_, "Application is not registered");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
return;
}
- smart_objects::SmartObject* command = application->FindCommand(
- (*message_)[strings::msg_params][strings::cmd_id].asInt());
+ const int32_t cmd_id =
+ (*message_)[strings::msg_params][strings::cmd_id].asInt();
+
+ smart_objects::SmartObject* command = application->FindCommand(cmd_id);
if (!command) {
+ LOG4CXX_ERROR(logger_, "Command with id " << cmd_id << " is not found.");
SendResponse(false, mobile_apis::Result::INVALID_ID);
- LOG4CXX_ERROR(logger_, "Invalid ID");
return;
}
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_params[strings::cmd_id] =
(*message_)[strings::msg_params][strings::cmd_id];
@@ -110,74 +113,112 @@ void DeleteCommandRequest::Run() {
void DeleteCommandRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
+ using namespace helpers;
+
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
case hmi_apis::FunctionID::UI_DeleteCommand: {
- LOG4CXX_INFO(logger_, "Received UI_DeleteCommand event");
is_ui_received_ = true;
- ui_result_ = static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asInt());
-
+ const int result = message[strings::params][hmi_response::code].asInt();
+ ui_result_ = static_cast<hmi_apis::Common_Result::eType>(result);
+ LOG4CXX_DEBUG(logger_,
+ "Received UI_DeleteCommand event with result "
+ << MessageHelper::HMIResultToString(ui_result_));
break;
}
case hmi_apis::FunctionID::VR_DeleteCommand: {
- LOG4CXX_INFO(logger_, "Received VR_DeleteCommand event");
is_vr_received_ = true;
- vr_result_ = static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asInt());
-
+ const int result = message[strings::params][hmi_response::code].asInt();
+ vr_result_ = static_cast<hmi_apis::Common_Result::eType>(result);
+ LOG4CXX_DEBUG(logger_,
+ "Received VR_DeleteCommand event with result "
+ << MessageHelper::HMIResultToString(vr_result_));
break;
}
default: {
- LOG4CXX_ERROR(logger_,"Received unknown event" << event.id());
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
return;
}
}
- if (!IsPendingResponseExist()) {
- ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(connection_key());
+ if (IsPendingResponseExist()) {
+ LOG4CXX_DEBUG(logger_, "Still awaiting for other responses.");
+ return;
+ }
- if (!application) {
- LOG4CXX_ERROR(logger_, "NULL pointer");
- return;
- }
+ ApplicationSharedPtr application =
+ application_manager_.application(connection_key());
- smart_objects::SmartObject* command = application->FindCommand(
- (*message_)[strings::msg_params][strings::cmd_id].asInt());
-
- if (command) {
- mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
-
- bool result = ((hmi_apis::Common_Result::SUCCESS == ui_result_) &&
- (hmi_apis::Common_Result::SUCCESS == vr_result_)) ||
- ((hmi_apis::Common_Result::SUCCESS == ui_result_) &&
- (hmi_apis::Common_Result::INVALID_ENUM == vr_result_)) ||
- ((hmi_apis::Common_Result::INVALID_ENUM == ui_result_) &&
- (hmi_apis::Common_Result::SUCCESS == vr_result_));
-
- if (result) {
- application->RemoveCommand(
- (*message_)[strings::msg_params][strings::cmd_id].asInt());
- }
-
- if (!result && (hmi_apis::Common_Result::REJECTED == ui_result_)) {
- result_code = static_cast<mobile_apis::Result::eType>(vr_result_);
- } else {
- result_code = static_cast<mobile_apis::Result::eType>(
- std::max(ui_result_, vr_result_));
- }
-
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
- if (result) {
- application->UpdateHash();
- }
- }
+ if (!application) {
+ LOG4CXX_ERROR(logger_, "Application is not registered");
+ return;
+ }
+ smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params];
+
+ const int32_t cmd_id = msg_params[strings::cmd_id].asInt();
+
+ smart_objects::SmartObject* command = application->FindCommand(cmd_id);
+
+ if (!command) {
+ LOG4CXX_ERROR(logger_,
+ "Command id " << cmd_id << " not found for "
+ "application with connection key "
+ << connection_key());
+ return;
+ }
+
+ const bool is_vr_success_invalid =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ vr_result_,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::INVALID_ENUM);
+
+ const bool is_ui_success_invalid =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ ui_result_,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::INVALID_ENUM);
+
+ const bool is_vr_ui_invalid =
+ Compare<hmi_apis::Common_Result::eType, EQ, ALL>(
+ hmi_apis::Common_Result::INVALID_ENUM, vr_result_, ui_result_);
+
+ const bool is_vr_or_ui_warning =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ hmi_apis::Common_Result::WARNINGS, ui_result_, vr_result_);
+
+ const bool result =
+ // In case of UI/VR is SUCCESS and other is SUCCESS/INVALID_ENUM
+ (is_vr_success_invalid && is_ui_success_invalid && !is_vr_ui_invalid) ||
+ // or one of them is WARNINGS
+ is_vr_or_ui_warning;
+
+ LOG4CXX_DEBUG(logger_, "Result code is " << (result ? "true" : "false"));
+
+ if (result) {
+ application->RemoveCommand(msg_params[strings::cmd_id].asInt());
+ }
+
+ mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
+ if (!result && hmi_apis::Common_Result::REJECTED == ui_result_) {
+ result_code = MessageHelper::HMIToMobileResult(vr_result_);
+ } else if (is_vr_or_ui_warning) {
+ LOG4CXX_DEBUG(logger_, "VR or UI result is warning");
+ result_code = mobile_apis::Result::WARNINGS;
+ } else {
+ result_code =
+ MessageHelper::HMIToMobileResult(std::max(ui_result_, vr_result_));
+ }
+
+ SendResponse(result, result_code, NULL, &msg_params);
+ if (result) {
+ application->UpdateHash();
}
}
bool DeleteCommandRequest::IsPendingResponseExist() {
+ LOG4CXX_AUTO_TRACE(logger_);
return is_ui_send_ != is_ui_received_ || is_vr_send_ != is_vr_received_;
}
diff --git a/src/components/application_manager/src/commands/mobile/delete_command_response.cc b/src/components/application_manager/src/commands/mobile/delete_command_response.cc
index 75178bcb4d..7abc1c11d4 100644
--- a/src/components/application_manager/src/commands/mobile/delete_command_response.cc
+++ b/src/components/application_manager/src/commands/mobile/delete_command_response.cc
@@ -32,23 +32,21 @@
*/
#include "application_manager/commands/mobile/delete_command_response.h"
-#include "application_manager/application_manager_impl.h"
namespace application_manager {
namespace commands {
-DeleteCommandResponse::DeleteCommandResponse(const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+DeleteCommandResponse::DeleteCommandResponse(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-DeleteCommandResponse::~DeleteCommandResponse() {
-}
+DeleteCommandResponse::~DeleteCommandResponse() {}
void DeleteCommandResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/delete_file_request.cc b/src/components/application_manager/src/commands/mobile/delete_file_request.cc
index 4c753871ce..00d23bb094 100644
--- a/src/components/application_manager/src/commands/mobile/delete_file_request.cc
+++ b/src/components/application_manager/src/commands/mobile/delete_file_request.cc
@@ -32,27 +32,26 @@
*/
#include "application_manager/commands/mobile/delete_file_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
-#include "config_profile/profile.h"
+
#include "utils/file_system.h"
namespace application_manager {
namespace commands {
-DeleteFileRequest::DeleteFileRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+DeleteFileRequest::DeleteFileRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
-DeleteFileRequest::~DeleteFileRequest() {
-}
+DeleteFileRequest::~DeleteFileRequest() {}
void DeleteFileRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(connection_key());
+ application_manager_.application(connection_key());
if (!application) {
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
@@ -61,20 +60,21 @@ void DeleteFileRequest::Run() {
}
if ((mobile_api::HMILevel::HMI_NONE == application->hmi_level()) &&
- (profile::Profile::instance()->delete_file_in_none() <=
+ (application_manager_.get_settings().delete_file_in_none() <=
application->delete_file_in_none_count())) {
- // If application is in the HMI_NONE level the quantity of allowed
- // DeleteFile request is limited by the configuration profile
- LOG4CXX_ERROR(logger_, "Too many requests from the app with HMILevel HMI_NONE ");
- SendResponse(false, mobile_apis::Result::REJECTED);
- return;
+ // If application is in the HMI_NONE level the quantity of allowed
+ // DeleteFile request is limited by the configuration profile
+ LOG4CXX_ERROR(logger_,
+ "Too many requests from the app with HMILevel HMI_NONE ");
+ SendResponse(false, mobile_apis::Result::REJECTED);
+ return;
}
const std::string& sync_file_name =
(*message_)[strings::msg_params][strings::sync_file_name].asString();
std::string full_file_path =
- profile::Profile::instance()->app_storage_folder() + "/";
+ application_manager_.get_settings().app_storage_folder() + "/";
full_file_path += application->folder_name();
full_file_path += "/";
full_file_path += sync_file_name;
@@ -97,17 +97,16 @@ void DeleteFileRequest::Run() {
}
}
-void DeleteFileRequest::SendFileRemovedNotification(
- const AppFile* file) const {
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+void DeleteFileRequest::SendFileRemovedNotification(const AppFile* file) const {
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
- msg_params[strings::app_id] = connection_key();
- msg_params[strings::file_name] = file->file_name;
- msg_params[strings::file_type] = file->file_type;
+ msg_params[strings::app_id] = connection_key();
+ msg_params[strings::file_name] = file->file_name;
+ msg_params[strings::file_type] = file->file_type;
- CreateHMINotification(
- hmi_apis::FunctionID::BasicCommunication_OnFileRemoved, msg_params);
+ CreateHMINotification(hmi_apis::FunctionID::BasicCommunication_OnFileRemoved,
+ msg_params);
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/delete_file_response.cc b/src/components/application_manager/src/commands/mobile/delete_file_response.cc
index 1bbb18313f..8ed6f7ba2e 100644
--- a/src/components/application_manager/src/commands/mobile/delete_file_response.cc
+++ b/src/components/application_manager/src/commands/mobile/delete_file_response.cc
@@ -32,26 +32,24 @@
*/
#include "application_manager/commands/mobile/delete_file_response.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
namespace application_manager {
namespace commands {
-DeleteFileResponse::DeleteFileResponse(const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+DeleteFileResponse::DeleteFileResponse(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-DeleteFileResponse::~DeleteFileResponse() {
-}
+DeleteFileResponse::~DeleteFileResponse() {}
void DeleteFileResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- uint32_t app_id = (*message_)[strings::params][strings::connection_key]
- .asUInt();
- ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()->application(app_id);
+ uint32_t app_id =
+ (*message_)[strings::params][strings::connection_key].asUInt();
+ ApplicationSharedPtr app = application_manager_.application(app_id);
if (!app) {
LOG4CXX_ERROR(logger_, "Application not registered");
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
@@ -59,8 +57,7 @@ void DeleteFileResponse::Run() {
}
(*message_)[strings::msg_params][strings::space_available] =
- static_cast<int32_t>(
- ApplicationManagerImpl::instance()->GetAvailableSpaceForApp(app->name()));
+ static_cast<uint32_t>(app->GetAvailableDiskSpace());
SendResponse((*message_)[strings::msg_params][strings::success].asBool());
}
diff --git a/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc b/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc
index 18c6b3b084..6ef8e5d9da 100644
--- a/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc
+++ b/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_request.cc
@@ -32,59 +32,60 @@
*/
#include "application_manager/commands/mobile/delete_interaction_choice_set_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "interfaces/MOBILE_API.h"
#include "interfaces/HMI_API.h"
#include "application_manager/message_helper.h"
+
namespace application_manager {
namespace commands {
DeleteInteractionChoiceSetRequest::DeleteInteractionChoiceSetRequest(
- const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
-DeleteInteractionChoiceSetRequest::~DeleteInteractionChoiceSetRequest() {
-}
+DeleteInteractionChoiceSetRequest::~DeleteInteractionChoiceSetRequest() {}
void DeleteInteractionChoiceSetRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
- (*message_)[strings::params][strings::connection_key].asUInt());
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
- LOG4CXX_ERROR_EXT(logger_, "No application associated with session key");
+ LOG4CXX_ERROR(logger_,
+ "No application associated with connection key "
+ << connection_key());
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
return;
}
- const int32_t choise_set_id =
- (*message_)[strings::msg_params]
- [strings::interaction_choice_set_id].asInt();
+ const int32_t choice_set_id =
+ (*message_)[strings::msg_params][strings::interaction_choice_set_id]
+ .asInt();
- if (!app->FindChoiceSet(choise_set_id)) {
- LOG4CXX_ERROR_EXT(logger_, "INVALID_ID");
+ if (!app->FindChoiceSet(choice_set_id)) {
+ LOG4CXX_ERROR(logger_,
+ "Choice set with id " << choice_set_id << " is not found.");
SendResponse(false, mobile_apis::Result::INVALID_ID);
return;
}
if (ChoiceSetInUse(app)) {
- LOG4CXX_ERROR_EXT(logger_, "Choice set currently in use");
+ LOG4CXX_ERROR(logger_, "Choice set currently in use.");
SendResponse(false, mobile_apis::Result::IN_USE);
return;
}
SendVrDeleteCommand(app);
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
- msg_params[strings::interaction_choice_set_id] = choise_set_id;
+ msg_params[strings::interaction_choice_set_id] = choice_set_id;
msg_params[strings::app_id] = app->app_id();
- app->RemoveChoiceSet(choise_set_id);
+ app->RemoveChoiceSet(choice_set_id);
// Checking of HMI responses will be implemented with APPLINK-14600
const bool result = true;
@@ -94,49 +95,60 @@ void DeleteInteractionChoiceSetRequest::Run() {
}
}
-bool DeleteInteractionChoiceSetRequest::ChoiceSetInUse(ApplicationConstSharedPtr app) {
- if (app->is_perform_interaction_active()) {
- // retrieve stored choice sets for perform interaction
+bool DeleteInteractionChoiceSetRequest::ChoiceSetInUse(
+ ApplicationConstSharedPtr app) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (!app->is_perform_interaction_active()) {
+ return false;
+ }
const DataAccessor<PerformChoiceSetMap> accessor =
app->performinteraction_choice_set_map();
const PerformChoiceSetMap& choice_set_map = accessor.GetData();
- PerformChoiceSetMap::const_iterator it = choice_set_map.begin();
- for (; choice_set_map.end() != it; ++it) {
- const PerformChoice& choice = it->second;
- PerformChoice::const_iterator choice_it = choice.begin();
- for (; choice.end() != choice_it; ++choice_it) {
- if (choice_it->first == (*message_)[strings::msg_params]
- [strings::interaction_choice_set_id].asUInt()) {
- LOG4CXX_ERROR_EXT(logger_,
- "DeleteInteractionChoiceSetRequest::ChoiceSetInUse");
- return true;
- }
+ const uint32_t choice_set_id =
+ (*message_)[strings::msg_params][strings::interaction_choice_set_id]
+ .asUInt();
+
+ PerformChoiceSetMap::const_iterator it = choice_set_map.begin();
+ for (; choice_set_map.end() != it; ++it) {
+ const PerformChoice& choice = it->second;
+ PerformChoice::const_iterator choice_it = choice.begin();
+ for (; choice.end() != choice_it; ++choice_it) {
+ if (choice_it->first == choice_set_id) {
+ LOG4CXX_ERROR(logger_,
+ "Choice set with id " << choice_set_id << " is in use.");
+ return true;
}
}
}
- return false;
+ return true;
}
void DeleteInteractionChoiceSetRequest::SendVrDeleteCommand(
application_manager::ApplicationSharedPtr app) {
- LOG4CXX_INFO(logger_, "PerformInteractionRequest::SendVrDeleteCommand");
-
- smart_objects::SmartObject* choice_set =
- app->FindChoiceSet((*message_)[strings::msg_params]
- [strings::interaction_choice_set_id].asInt());
-
- if (choice_set) {
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
- msg_params[strings::app_id] = app->app_id();
- msg_params[strings::type] = hmi_apis::Common_VRCommandType::Choice;
- msg_params[strings::grammar_id] = (*choice_set)[strings::grammar_id];
- choice_set = &((*choice_set)[strings::choice_set]);
- for (uint32_t i = 0; i < (*choice_set).length() ; ++i) {
- msg_params[strings::cmd_id] = (*choice_set)[i][strings::choice_id];
- SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params);
- }
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ const uint32_t choice_set_id =
+ (*message_)[strings::msg_params][strings::interaction_choice_set_id]
+ .asUInt();
+
+ smart_objects::SmartObject* choice_set = app->FindChoiceSet(choice_set_id);
+
+ if (!choice_set) {
+ LOG4CXX_ERROR(logger_,
+ "Choice set with id " << choice_set_id << " is not found.");
+ return;
+ }
+
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ msg_params[strings::app_id] = app->app_id();
+ msg_params[strings::type] = hmi_apis::Common_VRCommandType::Choice;
+ msg_params[strings::grammar_id] = (*choice_set)[strings::grammar_id];
+ choice_set = &((*choice_set)[strings::choice_set]);
+ for (uint32_t i = 0; i < (*choice_set).length(); ++i) {
+ msg_params[strings::cmd_id] = (*choice_set)[i][strings::choice_id];
+ SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params);
}
}
diff --git a/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_response.cc b/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_response.cc
index f9ee513b94..97e07529af 100644
--- a/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_response.cc
+++ b/src/components/application_manager/src/commands/mobile/delete_interaction_choice_set_response.cc
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/delete_interaction_choice_set_response.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "interfaces/MOBILE_API.h"
#include "interfaces/HMI_API.h"
@@ -42,12 +42,10 @@ namespace application_manager {
namespace commands {
DeleteInteractionChoiceSetResponse::DeleteInteractionChoiceSetResponse(
- const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-DeleteInteractionChoiceSetResponse::~DeleteInteractionChoiceSetResponse() {
-}
+DeleteInteractionChoiceSetResponse::~DeleteInteractionChoiceSetResponse() {}
void DeleteInteractionChoiceSetResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
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 6b6bd3fbda..bdb5521921 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
@@ -32,26 +32,25 @@
*/
#include "application_manager/commands/mobile/delete_sub_menu_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "interfaces/HMI_API.h"
+#include "utils/helpers.h"
namespace application_manager {
namespace commands {
-DeleteSubMenuRequest::DeleteSubMenuRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+DeleteSubMenuRequest::DeleteSubMenuRequest(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
-DeleteSubMenuRequest::~DeleteSubMenuRequest() {
-}
+DeleteSubMenuRequest::~DeleteSubMenuRequest() {}
void DeleteSubMenuRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
- (*message_)[strings::params][strings::connection_key].asUInt());
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
@@ -59,15 +58,17 @@ void DeleteSubMenuRequest::Run() {
return;
}
- if (!app->FindSubMenu(
- (*message_)[strings::msg_params][strings::menu_id].asInt())) {
+ const int32_t menu_id =
+ (*message_)[strings::msg_params][strings::menu_id].asInt();
+
+ if (!app->FindSubMenu(menu_id)) {
+ LOG4CXX_ERROR(logger_, "Menu with id " << menu_id << " is not found.");
SendResponse(false, mobile_apis::Result::INVALID_ID);
- LOG4CXX_ERROR(logger_, "Invalid ID");
return;
}
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_params[strings::menu_id] =
(*message_)[strings::msg_params][strings::menu_id];
@@ -76,7 +77,8 @@ void DeleteSubMenuRequest::Run() {
SendHMIRequest(hmi_apis::FunctionID::UI_DeleteSubMenu, &msg_params, true);
}
-void DeleteSubMenuRequest::DeleteSubMenuVRCommands(ApplicationConstSharedPtr app) {
+void DeleteSubMenuRequest::DeleteSubMenuVRCommands(
+ ApplicationConstSharedPtr app) {
LOG4CXX_AUTO_TRACE(logger_);
const DataAccessor<CommandsMap> accessor = app->commands_map();
@@ -84,16 +86,14 @@ void DeleteSubMenuRequest::DeleteSubMenuVRCommands(ApplicationConstSharedPtr app
CommandsMap::const_iterator it = commands.begin();
for (; commands.end() != it; ++it) {
-
if (!(*it->second).keyExists(strings::vr_commands)) {
continue;
}
- if ((*message_)[strings::msg_params][strings::menu_id].asInt()
- == (*it->second)[strings::menu_params]
- [hmi_request::parent_id].asInt()) {
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ if ((*message_)[strings::msg_params][strings::menu_id].asInt() ==
+ (*it->second)[strings::menu_params][hmi_request::parent_id].asInt()) {
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_params[strings::cmd_id] = (*it->second)[strings::cmd_id].asInt();
msg_params[strings::app_id] = app->app_id();
msg_params[strings::grammar_id] = app->get_grammar_id();
@@ -104,7 +104,8 @@ void DeleteSubMenuRequest::DeleteSubMenuVRCommands(ApplicationConstSharedPtr app
}
}
-void DeleteSubMenuRequest::DeleteSubMenuUICommands(ApplicationSharedPtr const app) {
+void DeleteSubMenuRequest::DeleteSubMenuUICommands(
+ ApplicationSharedPtr const app) {
LOG4CXX_AUTO_TRACE(logger_);
const DataAccessor<CommandsMap> accessor(app->commands_map());
@@ -118,11 +119,10 @@ void DeleteSubMenuRequest::DeleteSubMenuUICommands(ApplicationSharedPtr const ap
continue;
}
- if ((*message_)[strings::msg_params][strings::menu_id].asInt()
- == (*it->second)[strings::menu_params]
- [hmi_request::parent_id].asInt()) {
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ if ((*message_)[strings::msg_params][strings::menu_id].asInt() ==
+ (*it->second)[strings::menu_params][hmi_request::parent_id].asInt()) {
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_params[strings::app_id] = app->app_id();
msg_params[strings::cmd_id] = (*it->second)[strings::cmd_id].asInt();
app->RemoveCommand((*it->second)[strings::cmd_id].asInt());
@@ -138,6 +138,7 @@ void DeleteSubMenuRequest::DeleteSubMenuUICommands(ApplicationSharedPtr const ap
void DeleteSubMenuRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
+ using namespace helpers;
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
@@ -146,10 +147,13 @@ void DeleteSubMenuRequest::on_event(const event_engine::Event& event) {
static_cast<mobile_apis::Result::eType>(
message[strings::params][hmi_response::code].asInt());
- bool result = mobile_apis::Result::SUCCESS == result_code;
+ const bool result = Compare<mobile_api::Result::eType, EQ, ONE>(
+ result_code,
+ mobile_api::Result::SUCCESS,
+ mobile_api::Result::WARNINGS);
ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(connection_key());
+ application_manager_.application(connection_key());
if (!application) {
LOG4CXX_ERROR(logger_, "NULL pointer");
@@ -162,9 +166,12 @@ void DeleteSubMenuRequest::on_event(const event_engine::Event& event) {
DeleteSubMenuUICommands(application);
application->RemoveSubMenu(
(*message_)[strings::msg_params][strings::menu_id].asInt());
- }
+ }
SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ if (result) {
+ application->UpdateHash();
+ }
break;
}
default: {
@@ -174,7 +181,6 @@ void DeleteSubMenuRequest::on_event(const event_engine::Event& event) {
}
}
-
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/delete_sub_menu_response.cc b/src/components/application_manager/src/commands/mobile/delete_sub_menu_response.cc
index 05795e5908..ad9d2ad858 100644
--- a/src/components/application_manager/src/commands/mobile/delete_sub_menu_response.cc
+++ b/src/components/application_manager/src/commands/mobile/delete_sub_menu_response.cc
@@ -32,24 +32,21 @@
*/
#include "application_manager/commands/mobile/delete_sub_menu_response.h"
-#include "application_manager/application_manager_impl.h"
namespace application_manager {
namespace commands {
-DeleteSubMenuResponse::DeleteSubMenuResponse(const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+DeleteSubMenuResponse::DeleteSubMenuResponse(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-DeleteSubMenuResponse::~DeleteSubMenuResponse() {
-}
+DeleteSubMenuResponse::~DeleteSubMenuResponse() {}
void DeleteSubMenuResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
-
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
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 f5e8808d38..5252ea0e33 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
@@ -33,27 +33,25 @@
#include <algorithm>
#include "application_manager/commands/mobile/diagnostic_message_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
-#include "config_profile/profile.h"
+
#include "interfaces/HMI_API.h"
namespace application_manager {
namespace commands {
-DiagnosticMessageRequest::DiagnosticMessageRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+DiagnosticMessageRequest::DiagnosticMessageRequest(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
-DiagnosticMessageRequest::~DiagnosticMessageRequest() {
-}
+DiagnosticMessageRequest::~DiagnosticMessageRequest() {}
void DiagnosticMessageRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()->application(connection_key());
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
LOG4CXX_ERROR(logger_, "Application is not registered.");
@@ -62,30 +60,31 @@ void DiagnosticMessageRequest::Run() {
}
const std::vector<uint32_t>& supported_diag_modes =
- profile::Profile::instance()->supported_diag_modes();
-
- uint32_t message_data_length =
- (*message_)[strings::msg_params][strings::message_data].length();
- for (uint32_t i = 0; i < message_data_length; ++i) {
- uint32_t message_data =
- (*message_)[strings::msg_params][strings::message_data][i].asUInt();
- if (supported_diag_modes.end() == std::find(supported_diag_modes.begin(),
- supported_diag_modes.end(),
- message_data)) {
- LOG4CXX_ERROR(logger_, "Received message data " << message_data <<
- " not supported");
- SendResponse(false, mobile_apis::Result::REJECTED,
- "Received message data not supported");
- return;
- }
+ application_manager_.get_settings().supported_diag_modes();
+
+ smart_objects::SmartObject& msg_data =
+ (*message_)[strings::msg_params][strings::message_data];
+
+ const uint8_t mode_position = 0;
+ const uint32_t msg_diagnostic_mode = msg_data[mode_position].asUInt();
+ if (supported_diag_modes.end() == std::find(supported_diag_modes.begin(),
+ supported_diag_modes.end(),
+ msg_diagnostic_mode)) {
+ LOG4CXX_ERROR(logger_,
+ "Received diagnostic mode " << msg_diagnostic_mode
+ << " is not supported.");
+ SendResponse(false,
+ mobile_apis::Result::REJECTED,
+ "Received diagnostic mode is not supported.");
+ return;
}
// Add app_id for HMI request
(*message_)[strings::msg_params][strings::app_id] = app->app_id();
SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage,
- &(*message_)[strings::msg_params], true);
-
+ &(*message_)[strings::msg_params],
+ true);
}
void DiagnosticMessageRequest::on_event(const event_engine::Event& event) {
diff --git a/src/components/application_manager/src/commands/mobile/diagnostic_message_response.cc b/src/components/application_manager/src/commands/mobile/diagnostic_message_response.cc
index 9c399a00c8..8c59a97a8b 100644
--- a/src/components/application_manager/src/commands/mobile/diagnostic_message_response.cc
+++ b/src/components/application_manager/src/commands/mobile/diagnostic_message_response.cc
@@ -32,23 +32,21 @@
*/
#include "application_manager/commands/mobile/diagnostic_message_response.h"
-#include "application_manager/application_manager_impl.h"
namespace application_manager {
namespace commands {
-DiagnosticMessageResponse::DiagnosticMessageResponse(const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+DiagnosticMessageResponse::DiagnosticMessageResponse(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-DiagnosticMessageResponse::~DiagnosticMessageResponse() {
-}
+DiagnosticMessageResponse::~DiagnosticMessageResponse() {}
void DiagnosticMessageResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
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 6e8f5e15ad..64685afe2e 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
@@ -33,15 +33,16 @@
#include <algorithm>
#include <string>
#include "application_manager/commands/mobile/dial_number_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
namespace application_manager {
namespace commands {
-DialNumberRequest::DialNumberRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message) {}
+DialNumberRequest::DialNumberRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
DialNumberRequest::~DialNumberRequest() {}
@@ -57,13 +58,14 @@ void DialNumberRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(connection_key());
+ application_manager_.application(connection_key());
if (!application) {
LOG4CXX_ERROR(logger_, "NULL pointer");
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
return;
}
+
std::string number =
(*message_)[strings::msg_params][strings::number].asString();
if (!CheckSyntax(number)) {
@@ -71,10 +73,11 @@ void DialNumberRequest::Run() {
SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
}
+
StripNumberParam(number);
if (number.empty()) {
- LOG4CXX_WARN(logger_,
- "After strip number param is empty. Invalid incoming data");
+ LOG4CXX_ERROR(logger_,
+ "After strip number param is empty. Invalid incoming data");
SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
}
@@ -89,8 +92,9 @@ void DialNumberRequest::Run() {
}
void DialNumberRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_AUTO_TRACE(logger_);
ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(connection_key());
+ application_manager_.application(connection_key());
if (!application) {
LOG4CXX_ERROR(logger_, "NULL pointer");
@@ -130,7 +134,7 @@ void DialNumberRequest::on_event(const event_engine::Event& event) {
void DialNumberRequest::StripNumberParam(std::string& number) {
std::size_t found = 0;
while (std::string::npos !=
- (found = number.find_first_not_of("+*#,;0123456789"))) {
+ (found = number.find_first_not_of("0123456789*#,;+"))) {
number.erase(number.begin() + found);
}
(*message_)[strings::msg_params][strings::number] = number;
diff --git a/src/components/application_manager/src/commands/mobile/dial_number_response.cc b/src/components/application_manager/src/commands/mobile/dial_number_response.cc
index 1daab5a4e1..750dcf25c4 100644
--- a/src/components/application_manager/src/commands/mobile/dial_number_response.cc
+++ b/src/components/application_manager/src/commands/mobile/dial_number_response.cc
@@ -31,21 +31,21 @@
*/
#include "application_manager/commands/mobile/dial_number_response.h"
-#include "application_manager/application_manager_impl.h"
namespace application_manager {
namespace commands {
-DialNumberResponse::DialNumberResponse(const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+DialNumberResponse::DialNumberResponse(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-DialNumberResponse::~DialNumberResponse() {
-}
+DialNumberResponse::~DialNumberResponse() {}
void DialNumberResponse::Run() {
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
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 78a867a6d8..5a922f595f 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
@@ -32,19 +32,16 @@
*/
#include "application_manager/commands/mobile/end_audio_pass_thru_request.h"
-#include "application_manager/application_manager_impl.h"
namespace application_manager {
namespace commands {
EndAudioPassThruRequest::EndAudioPassThruRequest(
- const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
-EndAudioPassThruRequest::~EndAudioPassThruRequest() {
-}
+EndAudioPassThruRequest::~EndAudioPassThruRequest() {}
void EndAudioPassThruRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
@@ -65,11 +62,9 @@ void EndAudioPassThruRequest::on_event(const event_engine::Event& event) {
bool result = mobile_apis::Result::SUCCESS == mobile_code;
if (result) {
- bool ended_successfully =
- ApplicationManagerImpl::instance()->end_audio_pass_thru();
+ bool ended_successfully = application_manager_.EndAudioPassThrough();
if (ended_successfully) {
- ApplicationManagerImpl::instance()->StopAudioPassThru(
- connection_key());
+ application_manager_.StopAudioPassThru(connection_key());
}
}
diff --git a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_response.cc b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_response.cc
index 0ac1a00bd4..bb477f5083 100644
--- a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_response.cc
+++ b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_response.cc
@@ -32,24 +32,21 @@
*/
#include "application_manager/commands/mobile/end_audio_pass_thru_response.h"
-#include "application_manager/application_manager_impl.h"
namespace application_manager {
namespace commands {
EndAudioPassThruResponse::EndAudioPassThruResponse(
- const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-EndAudioPassThruResponse::~EndAudioPassThruResponse() {
-}
+EndAudioPassThruResponse::~EndAudioPassThruResponse() {}
void EndAudioPassThruResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/generic_response.cc b/src/components/application_manager/src/commands/mobile/generic_response.cc
index 69c841b2f1..20f6931bb9 100644
--- a/src/components/application_manager/src/commands/mobile/generic_response.cc
+++ b/src/components/application_manager/src/commands/mobile/generic_response.cc
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/generic_response.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
namespace application_manager {
@@ -55,7 +55,7 @@ void GenericResponse::Run() {
(*message_)[strings::params][strings::message_type] = MessageType::kResponse;
(*message_)[strings::msg_params][strings::success] = false;
(*message_)[strings::msg_params][strings::result_code] =
- mobile_apis::Result::INVALID_DATA;
+ mobile_apis::Result::INVALID_DATA;
SendResponse(false);
}
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 f6791759a4..80bc89f853 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
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/get_dtcs_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "interfaces/HMI_API.h"
@@ -40,17 +40,16 @@ namespace application_manager {
namespace commands {
-GetDTCsRequest::GetDTCsRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+GetDTCsRequest::GetDTCsRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
-GetDTCsRequest::~GetDTCsRequest() {
-}
+GetDTCsRequest::~GetDTCsRequest() {}
void GetDTCsRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ ApplicationSharedPtr app = application_manager_.application(
(*message_)[strings::params][strings::connection_key].asUInt());
if (!app) {
@@ -59,8 +58,8 @@ void GetDTCsRequest::Run() {
return;
}
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_params[strings::ecu_name] =
(*message_)[strings::msg_params][strings::ecu_name];
diff --git a/src/components/application_manager/src/commands/mobile/get_dtcs_response.cc b/src/components/application_manager/src/commands/mobile/get_dtcs_response.cc
index 523711c975..ecaf5c3d8f 100644
--- a/src/components/application_manager/src/commands/mobile/get_dtcs_response.cc
+++ b/src/components/application_manager/src/commands/mobile/get_dtcs_response.cc
@@ -32,23 +32,21 @@
*/
#include "application_manager/commands/mobile/get_dtcs_response.h"
-#include "application_manager/application_manager_impl.h"
namespace application_manager {
namespace commands {
-GetDTCsResponse::GetDTCsResponse(const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+GetDTCsResponse::GetDTCsResponse(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-GetDTCsResponse::~GetDTCsResponse() {
-}
+GetDTCsResponse::~GetDTCsResponse() {}
void GetDTCsResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
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 719cae11b7..b4c6db9b91 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
@@ -33,7 +33,7 @@
#include <string>
#include "application_manager/commands/mobile/get_vehicle_data_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
#include "interfaces/MOBILE_API.h"
@@ -46,18 +46,18 @@ namespace commands {
namespace str = strings;
#ifdef HMI_DBUS_API
-GetVehicleDataRequest::GetVehicleDataRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+GetVehicleDataRequest::GetVehicleDataRequest(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
-GetVehicleDataRequest::~GetVehicleDataRequest() {
-}
+GetVehicleDataRequest::~GetVehicleDataRequest() {}
void GetVehicleDataRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- int32_t app_id = (*message_)[strings::params][strings::connection_key].asUInt();
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
+ int32_t app_id =
+ (*message_)[strings::params][strings::connection_key].asUInt();
+ ApplicationSharedPtr app = appplication_manager.application(app_id);
if (!app) {
LOG4CXX_ERROR(logger_, "NULL pointer");
@@ -69,8 +69,8 @@ void GetVehicleDataRequest::Run() {
VehicleData::const_iterator it = vehicle_data.begin();
for (; vehicle_data.end() != it; ++it) {
- if (true == (*message_)[str::msg_params].keyExists(it->first)
- && true == (*message_)[str::msg_params][it->first].asBool()) {
+ if (true == (*message_)[str::msg_params].keyExists(it->first) &&
+ true == (*message_)[str::msg_params][it->first].asBool()) {
SendRequestsToHmi(app->app_id());
return;
}
@@ -80,37 +80,44 @@ void GetVehicleDataRequest::Run() {
}
namespace {
- struct Subrequest {
- hmi_apis::FunctionID::eType func_id;
- const char* str;
- };
- Subrequest subrequests[] = {
- { hmi_apis::FunctionID::VehicleInfo_GetGpsData, str::gps},
- { hmi_apis::FunctionID::VehicleInfo_GetSpeed, str::speed},
- { hmi_apis::FunctionID::VehicleInfo_GetRpm, str::rpm},
- { hmi_apis::FunctionID::VehicleInfo_GetFuelLevel, str::fuel_level},
- { hmi_apis::FunctionID::VehicleInfo_GetFuelLevelState, str::fuel_level_state},
- { hmi_apis::FunctionID::VehicleInfo_GetInstantFuelConsumption, str::instant_fuel_consumption},
- { hmi_apis::FunctionID::VehicleInfo_GetExternalTemperature, str::external_temp},
- { hmi_apis::FunctionID::VehicleInfo_GetVin, str::vin},
- { hmi_apis::FunctionID::VehicleInfo_GetPrndl, str::prndl},
- { hmi_apis::FunctionID::VehicleInfo_GetTirePressure, str::tire_pressure},
- { hmi_apis::FunctionID::VehicleInfo_GetOdometer, str::odometer},
- { hmi_apis::FunctionID::VehicleInfo_GetBeltStatus, str::belt_status},
- { hmi_apis::FunctionID::VehicleInfo_GetBodyInformation, str::body_information},
- { hmi_apis::FunctionID::VehicleInfo_GetDeviceStatus, str::device_status},
- { hmi_apis::FunctionID::VehicleInfo_GetDriverBraking, str::driver_braking},
- { hmi_apis::FunctionID::VehicleInfo_GetWiperStatus, str::wiper_status},
- { hmi_apis::FunctionID::VehicleInfo_GetHeadLampStatus, str::head_lamp_status},
- { hmi_apis::FunctionID::VehicleInfo_GetEngineTorque, str::engine_torque},
- { hmi_apis::FunctionID::VehicleInfo_GetAccPedalPosition, str::acc_pedal_pos},
- { hmi_apis::FunctionID::VehicleInfo_GetSteeringWheelAngle, str::steering_wheel_angle},
- { hmi_apis::FunctionID::VehicleInfo_GetECallInfo, str::e_call_info},
- { hmi_apis::FunctionID::VehicleInfo_GetAirbagStatus, str::airbag_status},
- { hmi_apis::FunctionID::VehicleInfo_GetEmergencyEvent, str::emergency_event},
- { hmi_apis::FunctionID::VehicleInfo_GetClusterModeStatus, str::cluster_mode_status},
- { hmi_apis::FunctionID::VehicleInfo_GetMyKey, str::my_key},
- };
+struct Subrequest {
+ hmi_apis::FunctionID::eType func_id;
+ const char* str;
+};
+Subrequest subrequests[] = {
+ {hmi_apis::FunctionID::VehicleInfo_GetGpsData, str::gps},
+ {hmi_apis::FunctionID::VehicleInfo_GetSpeed, str::speed},
+ {hmi_apis::FunctionID::VehicleInfo_GetRpm, str::rpm},
+ {hmi_apis::FunctionID::VehicleInfo_GetFuelLevel, str::fuel_level},
+ {hmi_apis::FunctionID::VehicleInfo_GetFuelLevelState,
+ str::fuel_level_state},
+ {hmi_apis::FunctionID::VehicleInfo_GetInstantFuelConsumption,
+ str::instant_fuel_consumption},
+ {hmi_apis::FunctionID::VehicleInfo_GetExternalTemperature,
+ str::external_temp},
+ {hmi_apis::FunctionID::VehicleInfo_GetVin, str::vin},
+ {hmi_apis::FunctionID::VehicleInfo_GetPrndl, str::prndl},
+ {hmi_apis::FunctionID::VehicleInfo_GetTirePressure, str::tire_pressure},
+ {hmi_apis::FunctionID::VehicleInfo_GetOdometer, str::odometer},
+ {hmi_apis::FunctionID::VehicleInfo_GetBeltStatus, str::belt_status},
+ {hmi_apis::FunctionID::VehicleInfo_GetBodyInformation,
+ str::body_information},
+ {hmi_apis::FunctionID::VehicleInfo_GetDeviceStatus, str::device_status},
+ {hmi_apis::FunctionID::VehicleInfo_GetDriverBraking, str::driver_braking},
+ {hmi_apis::FunctionID::VehicleInfo_GetWiperStatus, str::wiper_status},
+ {hmi_apis::FunctionID::VehicleInfo_GetHeadLampStatus,
+ str::head_lamp_status},
+ {hmi_apis::FunctionID::VehicleInfo_GetEngineTorque, str::engine_torque},
+ {hmi_apis::FunctionID::VehicleInfo_GetAccPedalPosition, str::acc_pedal_pos},
+ {hmi_apis::FunctionID::VehicleInfo_GetSteeringWheelAngle,
+ str::steering_wheel_angle},
+ {hmi_apis::FunctionID::VehicleInfo_GetECallInfo, str::e_call_info},
+ {hmi_apis::FunctionID::VehicleInfo_GetAirbagStatus, str::airbag_status},
+ {hmi_apis::FunctionID::VehicleInfo_GetEmergencyEvent, str::emergency_event},
+ {hmi_apis::FunctionID::VehicleInfo_GetClusterModeStatus,
+ str::cluster_mode_status},
+ {hmi_apis::FunctionID::VehicleInfo_GetMyKey, str::my_key},
+};
}
void GetVehicleDataRequest::SendRequestsToHmi(const int32_t app_id) {
@@ -119,8 +126,8 @@ void GetVehicleDataRequest::SendRequestsToHmi(const int32_t app_id) {
for (size_t i = 0; i < sizeof(subrequests) / sizeof(subrequests[0]); ++i) {
const Subrequest& sr = subrequests[i];
- if (true == (*message_)[str::msg_params].keyExists(sr.str)
- && true == (*message_)[str::msg_params][sr.str].asBool()) {
+ if (true == (*message_)[str::msg_params].keyExists(sr.str) &&
+ true == (*message_)[str::msg_params][sr.str].asBool()) {
HmiRequest hmi_request;
hmi_request.str = sr.str;
hmi_request.func_id = sr.func_id;
@@ -133,7 +140,8 @@ void GetVehicleDataRequest::SendRequestsToHmi(const int32_t app_id) {
hmi_requests_.size() << " requests are going to be sent to HMI");
for (HmiRequests::const_iterator it = hmi_requests_.begin();
- it != hmi_requests_.end(); ++it) {
+ it != hmi_requests_.end();
+ ++it) {
SendHMIRequest(it->func_id, &msg_params, true);
}
}
@@ -144,12 +152,12 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) {
const smart_objects::SmartObject& message = event.smart_object();
for (HmiRequests::iterator it = hmi_requests_.begin();
- it != hmi_requests_.end(); ++it) {
- HmiRequest & hmi_request = *it;
+ it != hmi_requests_.end();
+ ++it) {
+ HmiRequest& hmi_request = *it;
if (hmi_request.func_id == event.id()) {
- hmi_request.status =
- static_cast<hmi_apis::Common_Result::eType>(message[strings::params][hmi_response::code]
- .asInt());
+ hmi_request.status = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
if (hmi_apis::Common_Result::SUCCESS == hmi_request.status)
hmi_request.value = message[str::msg_params][hmi_request.str];
hmi_request.complete = true;
@@ -161,7 +169,8 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) {
bool any_arg_success = false;
mobile_api::Result::eType status = mobile_api::Result::eType::SUCCESS;
for (HmiRequests::const_iterator it = hmi_requests_.begin();
- it != hmi_requests_.end(); ++it) {
+ it != hmi_requests_.end();
+ ++it) {
if (!it->complete) {
all_complete = false;
break;
@@ -169,13 +178,16 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) {
if (hmi_apis::Common_Result::SUCCESS != it->status) {
if (mobile_api::Result::SUCCESS == status) {
status = static_cast<mobile_apis::Result::eType>(it->status);
- } else if (status
- != static_cast<mobile_apis::Result::eType>(it->status)) {
+ } else if (status !=
+ static_cast<mobile_apis::Result::eType>(it->status)) {
status = mobile_api::Result::eType::GENERIC_ERROR;
}
- LOG4CXX_TRACE(logger_, "Status from HMI: " << it->status << ", so response status become " << status);
+ LOG4CXX_TRACE(logger_,
+ "Status from HMI: " << it->status
+ << ", so response status become "
+ << status);
} else {
- any_arg_success = true;
+ any_arg_success = true;
}
}
@@ -183,34 +195,34 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) {
smart_objects::SmartObject response_params(smart_objects::SmartType_Map);
if (any_arg_success) {
for (HmiRequests::const_iterator it = hmi_requests_.begin();
- it != hmi_requests_.end(); ++it) {
+ it != hmi_requests_.end();
+ ++it) {
response_params[it->str] = it->value;
}
}
- LOG4CXX_INFO(
- logger_, "All HMI requests are complete");
- const char *info = NULL;
+ LOG4CXX_INFO(logger_, "All HMI requests are complete");
+ const char* info = NULL;
std::string error_message;
if (true == message[strings::params].keyExists(strings::error_msg)) {
error_message = message[strings::params][strings::error_msg].asString();
info = error_message.c_str();
}
- SendResponse( any_arg_success, status, info, &response_params);
+ SendResponse(any_arg_success, status, info, &response_params);
}
}
#else
-GetVehicleDataRequest::GetVehicleDataRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+GetVehicleDataRequest::GetVehicleDataRequest(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
-GetVehicleDataRequest::~GetVehicleDataRequest() {
-}
+GetVehicleDataRequest::~GetVehicleDataRequest() {}
void GetVehicleDataRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- int32_t app_id = (*message_)[strings::params][strings::connection_key].asUInt();
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
+ int32_t app_id =
+ (*message_)[strings::params][strings::connection_key].asUInt();
+ ApplicationSharedPtr app = application_manager_.application(app_id);
if (!app) {
LOG4CXX_ERROR(logger_, "NULL pointer");
@@ -219,27 +231,27 @@ void GetVehicleDataRequest::Run() {
}
if (app->IsCommandLimitsExceeded(
- static_cast<mobile_apis::FunctionID::eType>(function_id()),
- application_manager::TLimitSource::CONFIG_FILE)) {
+ static_cast<mobile_apis::FunctionID::eType>(function_id()),
+ application_manager::TLimitSource::CONFIG_FILE)) {
LOG4CXX_ERROR(logger_, "GetVehicleData frequency is too high.");
SendResponse(false, mobile_apis::Result::REJECTED);
return;
}
const VehicleData& vehicle_data = MessageHelper::vehicle_data();
VehicleData::const_iterator it = vehicle_data.begin();
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_params[strings::app_id] = app->app_id();
const uint32_t min_length_msg_params = 1;
for (; vehicle_data.end() != it; ++it) {
- if (true == (*message_)[str::msg_params].keyExists(it->first)
- && true == (*message_)[str::msg_params][it->first].asBool()) {
+ if (true == (*message_)[str::msg_params].keyExists(it->first) &&
+ true == (*message_)[str::msg_params][it->first].asBool()) {
msg_params[it->first] = (*message_)[strings::msg_params][it->first];
}
}
if (msg_params.length() > min_length_msg_params) {
- SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_GetVehicleData,
- &msg_params, true);
+ SendHMIRequest(
+ hmi_apis::FunctionID::VehicleInfo_GetVehicleData, &msg_params, true);
return;
} else if (HasDisallowedParams()) {
SendResponse(false, mobile_apis::Result::DISALLOWED);
@@ -263,7 +275,7 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) {
&& message[strings::msg_params].length() > 1)) {
result = true;
}
- const char *info = NULL;
+ const char* info = NULL;
std::string error_message;
if (true ==
message[strings::msg_params].keyExists(hmi_response::method)) {
@@ -283,8 +295,8 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) {
}
}
-#endif // #ifdef HMI_DBUS_API
+#endif // #ifdef HMI_DBUS_API
-} // namespace commands
+} // namespace commands
-} // namespace application_manager
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/get_vehicle_data_response.cc b/src/components/application_manager/src/commands/mobile/get_vehicle_data_response.cc
index 5491e9b1aa..1e64746262 100644
--- a/src/components/application_manager/src/commands/mobile/get_vehicle_data_response.cc
+++ b/src/components/application_manager/src/commands/mobile/get_vehicle_data_response.cc
@@ -32,24 +32,23 @@
*/
#include "application_manager/commands/mobile/get_vehicle_data_response.h"
-#include "application_manager/application_manager_impl.h"
+
#include "interfaces/HMI_API.h"
namespace application_manager {
namespace commands {
-GetVehicleDataResponse::GetVehicleDataResponse(const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+GetVehicleDataResponse::GetVehicleDataResponse(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-GetVehicleDataResponse::~GetVehicleDataResponse() {
-}
+GetVehicleDataResponse::~GetVehicleDataResponse() {}
void GetVehicleDataResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
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
new file mode 100644
index 0000000000..9baf747ee4
--- /dev/null
+++ b/src/components/application_manager/src/commands/mobile/get_way_points_request.cc
@@ -0,0 +1,59 @@
+#include "application_manager/application_manager.h"
+#include "application_manager/commands/mobile/get_way_points_request.h"
+
+namespace application_manager {
+
+namespace commands {
+
+GetWayPointsRequest::GetWayPointsRequest(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
+
+GetWayPointsRequest::~GetWayPointsRequest() {}
+
+void GetWayPointsRequest::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
+
+ if (!app) {
+ LOG4CXX_ERROR(logger_,
+ "An application with connection key "
+ << connection_key() << " is not registered.");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ msg_params = (*message_)[strings::msg_params];
+ msg_params[strings::app_id] = app->app_id();
+ SendHMIRequest(hmi_apis::FunctionID::Navigation_GetWayPoints,
+ msg_params.empty() ? NULL : &msg_params,
+ true);
+}
+
+void GetWayPointsRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
+ const smart_objects::SmartObject& message = event.smart_object();
+ switch (event.id()) {
+ case hmi_apis::FunctionID::Navigation_GetWayPoints: {
+ LOG4CXX_INFO(logger_, "Received Navigation_GetWayPoints event");
+ mobile_apis::Result::eType result_code =
+ GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asUInt()));
+ bool result = mobile_apis::Result::SUCCESS == result_code;
+ SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ break;
+ }
+ }
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/get_way_points_response.cc b/src/components/application_manager/src/commands/mobile/get_way_points_response.cc
new file mode 100644
index 0000000000..7956b34cae
--- /dev/null
+++ b/src/components/application_manager/src/commands/mobile/get_way_points_response.cc
@@ -0,0 +1,22 @@
+#include "application_manager/application_manager.h"
+#include "application_manager/commands/mobile/get_way_points_response.h"
+
+namespace application_manager {
+
+namespace commands {
+
+GetWayPointsResponse::GetWayPointsResponse(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
+
+GetWayPointsResponse::~GetWayPointsResponse() {}
+
+void GetWayPointsResponse::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ application_manager_.SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/list_files_request.cc b/src/components/application_manager/src/commands/mobile/list_files_request.cc
index 427443e3e9..425f1ddb46 100644
--- a/src/components/application_manager/src/commands/mobile/list_files_request.cc
+++ b/src/components/application_manager/src/commands/mobile/list_files_request.cc
@@ -31,10 +31,11 @@
POSSIBILITY OF SUCH DAMAGE.
*/
+#include <string>
#include "application_manager/commands/mobile/list_files_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
-#include "config_profile/profile.h"
+
#include "application_manager/mobile_command_factory.h"
#include "utils/file_system.h"
@@ -42,18 +43,17 @@ namespace application_manager {
namespace commands {
-ListFilesRequest::ListFilesRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+ListFilesRequest::ListFilesRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
-ListFilesRequest::~ListFilesRequest() {
-}
+ListFilesRequest::~ListFilesRequest() {}
void ListFilesRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(connection_key());
+ application_manager_.application(connection_key());
if (!application) {
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
@@ -62,33 +62,43 @@ void ListFilesRequest::Run() {
}
if ((mobile_api::HMILevel::HMI_NONE == application->hmi_level()) &&
- (profile::Profile::instance()->list_files_in_none() <=
+ (application_manager_.get_settings().list_files_in_none() <=
application->list_files_in_none_count())) {
- // If application is in the HMI_NONE level the quantity of allowed
- // DeleteFile request is limited by the configuration profile
- LOG4CXX_ERROR(logger_, "Too many requests from the app with HMILevel HMI_NONE ");
- SendResponse(false, mobile_apis::Result::REJECTED);
- return;
+ // If application is in the HMI_NONE level the quantity of allowed
+ // DeleteFile request is limited by the configuration profile
+ LOG4CXX_ERROR(logger_,
+ "Too many requests from the app with HMILevel HMI_NONE ");
+ SendResponse(false, mobile_apis::Result::REJECTED);
+ return;
}
application->increment_list_files_in_none_count();
(*message_)[strings::msg_params][strings::space_available] =
- static_cast<int32_t>(ApplicationManagerImpl::instance()->
- GetAvailableSpaceForApp(application->folder_name()));
- int32_t i = 0;
+ static_cast<int32_t>(application->GetAvailableDiskSpace());
+ uint32_t i = 0;
const AppFilesMap& app_files = application->getAppFiles();
for (AppFilesMap::const_iterator it = app_files.begin();
- it != app_files.end(); ++it) {
- //In AppFile to application stored full path to file. In message required
- //to write only name file.
- //Plus one required for move to next letter after '/'.
- (*message_)[strings::msg_params][strings::filenames][i++] =
- it->first.substr(it->first.find_last_of('/') + 1);
+ it != app_files.end();
+ ++it) {
+ std::string filename = it->first.substr(it->first.find_last_of('/') + 1);
+ // In AppFile to application stored full path to file. In message required
+ // to write only name file.
+ // Plus one required for move to next letter after '/'.
+ if (i < application_manager_.get_settings().list_files_response_size()) {
+ LOG4CXX_DEBUG(logger_,
+ "File " + filename + " added to ListFiles response");
+ (*message_)[strings::msg_params][strings::filenames][i++] = filename;
+ } else {
+ LOG4CXX_DEBUG(logger_,
+ "File " + filename + " not added to ListFiles response");
+ }
}
(*message_)[strings::params][strings::message_type] =
application_manager::MessageType::kResponse;
- SendResponse(true, mobile_apis::Result::SUCCESS, NULL,
+ SendResponse(true,
+ mobile_apis::Result::SUCCESS,
+ NULL,
&(*message_)[strings::msg_params]);
}
diff --git a/src/components/application_manager/src/commands/mobile/list_files_response.cc b/src/components/application_manager/src/commands/mobile/list_files_response.cc
index 42bd1e6f07..fde15a94ef 100644
--- a/src/components/application_manager/src/commands/mobile/list_files_response.cc
+++ b/src/components/application_manager/src/commands/mobile/list_files_response.cc
@@ -32,24 +32,23 @@
*/
#include "application_manager/commands/mobile/list_files_response.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
namespace application_manager {
namespace commands {
-ListFilesResponse::ListFilesResponse(const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+ListFilesResponse::ListFilesResponse(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-ListFilesResponse::~ListFilesResponse() {
-}
+ListFilesResponse::~ListFilesResponse() {}
void ListFilesResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/on_app_interface_unregistered_notification.cc b/src/components/application_manager/src/commands/mobile/on_app_interface_unregistered_notification.cc
index e3e51faa6e..6064374dab 100644
--- a/src/components/application_manager/src/commands/mobile/on_app_interface_unregistered_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_app_interface_unregistered_notification.cc
@@ -39,12 +39,11 @@ namespace application_manager {
namespace commands {
OnAppInterfaceUnregisteredNotification::OnAppInterfaceUnregisteredNotification(
- const MessageSharedPtr& message)
- : CommandNotificationImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandNotificationImpl(message, application_manager) {}
-OnAppInterfaceUnregisteredNotification::~OnAppInterfaceUnregisteredNotification() {
-}
+OnAppInterfaceUnregisteredNotification::
+ ~OnAppInterfaceUnregisteredNotification() {}
void OnAppInterfaceUnregisteredNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
diff --git a/src/components/application_manager/src/commands/mobile/on_audio_pass_thru_notification.cc b/src/components/application_manager/src/commands/mobile/on_audio_pass_thru_notification.cc
index d1329bf8ea..d0fa3597bc 100644
--- a/src/components/application_manager/src/commands/mobile/on_audio_pass_thru_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_audio_pass_thru_notification.cc
@@ -37,12 +37,10 @@ namespace application_manager {
namespace commands {
OnAudioPassThruNotification::OnAudioPassThruNotification(
- const MessageSharedPtr& message)
- : CommandNotificationImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandNotificationImpl(message, application_manager) {}
-OnAudioPassThruNotification::~OnAudioPassThruNotification() {
-}
+OnAudioPassThruNotification::~OnAudioPassThruNotification() {}
void OnAudioPassThruNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
diff --git a/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc b/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc
index 5f14ad953f..64043d2a88 100644
--- a/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/on_button_event_notification.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "interfaces/MOBILE_API.h"
@@ -43,50 +43,51 @@ namespace commands {
namespace mobile {
OnButtonEventNotification::OnButtonEventNotification(
- const MessageSharedPtr& message)
- : CommandNotificationImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandNotificationImpl(message, application_manager) {}
-OnButtonEventNotification::~OnButtonEventNotification() {
-}
+OnButtonEventNotification::~OnButtonEventNotification() {}
void OnButtonEventNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- const uint32_t btn_id =
- static_cast<uint32_t>(
- (*message_)[strings::msg_params][hmi_response::button_name].asInt());
+ const uint32_t btn_id = static_cast<uint32_t>(
+ (*message_)[strings::msg_params][hmi_response::button_name].asInt());
+
+ const bool is_app_id_exists =
+ (*message_)[strings::msg_params].keyExists(strings::app_id);
+ const ApplicationSharedPtr app = application_manager_.application(
+ (*message_)[strings::msg_params][strings::app_id].asUInt());
// CUSTOM_BUTTON notification
if (static_cast<uint32_t>(mobile_apis::ButtonName::CUSTOM_BUTTON) == btn_id) {
// app_id is mandatory for CUSTOM_BUTTON notification
- if (false == (*message_)[strings::msg_params].keyExists(strings::app_id)) {
- LOG4CXX_ERROR_EXT(logger_, "CUSTOM_BUTTON OnButtonEvent without app_id.");
+ if (!is_app_id_exists) {
+ LOG4CXX_ERROR(logger_, "CUSTOM_BUTTON OnButtonEvent without app_id.");
return;
}
// custom_button_id is mandatory for CUSTOM_BUTTON notification
- if (false == (*message_)[strings::msg_params].keyExists(
- hmi_response::custom_button_id)) {
- LOG4CXX_ERROR_EXT(logger_,
- "CUSTOM_BUTTON OnButtonEvent without custom_button_id.");
+ if (false ==
+ (*message_)[strings::msg_params].keyExists(
+ hmi_response::custom_button_id)) {
+ LOG4CXX_ERROR(logger_,
+ "CUSTOM_BUTTON OnButtonEvent without custom_button_id.");
return;
}
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
- (*message_)[strings::msg_params][strings::app_id].asUInt());
-
- if (false == app.valid()) {
- LOG4CXX_ERROR_EXT(logger_, "Application doesn't exist.");
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "Application doesn't exist.");
return;
}
uint32_t custom_btn_id = 0;
- custom_btn_id = (*message_)[strings::msg_params]
- [hmi_response::custom_button_id].asUInt();
+ custom_btn_id =
+ (*message_)[strings::msg_params][hmi_response::custom_button_id]
+ .asUInt();
if (false == app->IsSubscribedToSoftButton(custom_btn_id)) {
- LOG4CXX_ERROR_EXT(logger_,
+ LOG4CXX_ERROR(logger_,
"Application doesn't subscribed to this custom_button_id.");
return;
}
@@ -95,48 +96,47 @@ void OnButtonEventNotification::Run() {
return;
}
- const std::vector<ApplicationSharedPtr>& subscribedApps =
- ApplicationManagerImpl::instance()->applications_by_button(btn_id);
+ const std::vector<ApplicationSharedPtr>& subscribed_apps =
+ application_manager_.applications_by_button(btn_id);
- std::vector<ApplicationSharedPtr>::const_iterator it = subscribedApps.begin();
- for (; subscribedApps.end() != it; ++it) {
+ std::vector<ApplicationSharedPtr>::const_iterator it =
+ subscribed_apps.begin();
+ for (; subscribed_apps.end() != it; ++it) {
ApplicationSharedPtr subscribed_app = *it;
if (!subscribed_app) {
- LOG4CXX_WARN_EXT(logger_, "Null pointer to subscribed app.");
+ LOG4CXX_WARN(logger_, "Null pointer to subscribed app.");
continue;
}
- //Send ButtonEvent notification only in HMI_FULL or HMI_LIMITED mode
+ // Send ButtonEvent notification only in HMI_FULL or HMI_LIMITED mode
if ((mobile_api::HMILevel::HMI_FULL != subscribed_app->hmi_level()) &&
(mobile_api::HMILevel::HMI_LIMITED != subscribed_app->hmi_level())) {
- LOG4CXX_WARN_EXT(logger_, "OnButtonEvent in HMI_BACKGROUND or NONE");
+ LOG4CXX_WARN(logger_,
+ "OnButtonEvent notification is allowed only"
+ << "in FULL or LIMITED hmi level");
continue;
}
-
- //Send ButtonEvent notification for OK button only in HMI_FULL mode
- if ((static_cast<uint32_t>(mobile_apis::ButtonName::OK) == btn_id) &&
- (!subscribed_app->IsFullscreen())) {
- continue;
+ // if "app_id" absent send notification only in HMI_FULL mode
+ if (is_app_id_exists || subscribed_app->IsFullscreen()) {
+ SendButtonEvent(subscribed_app);
}
-
- SendButtonEvent(subscribed_app);
}
}
void OnButtonEventNotification::SendButtonEvent(ApplicationConstSharedPtr app) {
if (!app) {
- LOG4CXX_ERROR_EXT(logger_, "OnButtonEvent NULL pointer");
+ LOG4CXX_ERROR(logger_, "OnButtonEvent NULL pointer");
return;
}
- smart_objects::SmartObjectSPtr on_btn_event = new smart_objects::SmartObject();
+ smart_objects::SmartObjectSPtr on_btn_event =
+ new smart_objects::SmartObject();
if (!on_btn_event) {
- LOG4CXX_ERROR_EXT(logger_, "OnButtonEvent NULL pointer");
+ LOG4CXX_ERROR(logger_, "OnButtonEvent NULL pointer");
return;
}
-
(*on_btn_event)[strings::params][strings::connection_key] = app->app_id();
(*on_btn_event)[strings::params][strings::function_id] =
@@ -148,7 +148,7 @@ void OnButtonEventNotification::SendButtonEvent(ApplicationConstSharedPtr app) {
(*message_)[strings::msg_params][hmi_response::button_mode];
if ((*message_)[strings::msg_params].keyExists(
- hmi_response::custom_button_id)) {
+ hmi_response::custom_button_id)) {
(*on_btn_event)[strings::msg_params][strings::custom_button_id] =
(*message_)[strings::msg_params][strings::custom_button_id];
}
diff --git a/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc b/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc
index 86fe664f86..fdf8b559bc 100644
--- a/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/on_button_press_notification.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "interfaces/MOBILE_API.h"
@@ -43,50 +43,51 @@ namespace commands {
namespace mobile {
OnButtonPressNotification::OnButtonPressNotification(
- const MessageSharedPtr& message)
- : CommandNotificationImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandNotificationImpl(message, application_manager) {}
-OnButtonPressNotification::~OnButtonPressNotification() {
-}
+OnButtonPressNotification::~OnButtonPressNotification() {}
void OnButtonPressNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- const uint32_t btn_id =
- static_cast<uint32_t>(
- (*message_)[strings::msg_params][hmi_response::button_name].asInt());
+ const uint32_t btn_id = static_cast<uint32_t>(
+ (*message_)[strings::msg_params][hmi_response::button_name].asInt());
+
+ const bool is_app_id_exists =
+ (*message_)[strings::msg_params].keyExists(strings::app_id);
+ const ApplicationSharedPtr app = application_manager_.application(
+ (*message_)[strings::msg_params][strings::app_id].asUInt());
// CUSTOM_BUTTON notification
if (static_cast<uint32_t>(mobile_apis::ButtonName::CUSTOM_BUTTON) == btn_id) {
// app_id is mandatory for CUSTOM_BUTTON notification
- if (false == (*message_)[strings::msg_params].keyExists(strings::app_id)) {
- LOG4CXX_ERROR_EXT(logger_, "CUSTOM_BUTTON OnButtonPress without app_id.");
+ if (!is_app_id_exists) {
+ LOG4CXX_ERROR(logger_, "CUSTOM_BUTTON OnButtonPress without app_id.");
return;
}
// custom_button_id is mandatory for CUSTOM_BUTTON notification
- if (false == (*message_)[strings::msg_params].keyExists(
- hmi_response::custom_button_id)) {
- LOG4CXX_ERROR_EXT(logger_,
- "CUSTOM_BUTTON OnButtonPress without custom_button_id.");
+ if (false ==
+ (*message_)[strings::msg_params].keyExists(
+ hmi_response::custom_button_id)) {
+ LOG4CXX_ERROR(logger_,
+ "CUSTOM_BUTTON OnButtonPress without custom_button_id.");
return;
}
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
- (*message_)[strings::msg_params][strings::app_id].asUInt());
-
- if (false == app.valid()) {
- LOG4CXX_ERROR_EXT(logger_, "Application doesn't exist.");
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "Application doesn't exist.");
return;
}
uint32_t custom_btn_id = 0;
- custom_btn_id = (*message_)[strings::msg_params]
- [hmi_response::custom_button_id].asUInt();
+ custom_btn_id =
+ (*message_)[strings::msg_params][hmi_response::custom_button_id]
+ .asUInt();
if (false == app->IsSubscribedToSoftButton(custom_btn_id)) {
- LOG4CXX_ERROR_EXT(logger_,
+ LOG4CXX_ERROR(logger_,
"Application doesn't subscribed to this custom_button_id.");
return;
}
@@ -95,48 +96,47 @@ void OnButtonPressNotification::Run() {
return;
}
- const std::vector<ApplicationSharedPtr>& subscribedApps =
- ApplicationManagerImpl::instance()->applications_by_button(btn_id);
+ const std::vector<ApplicationSharedPtr>& subscribed_apps =
+ application_manager_.applications_by_button(btn_id);
- std::vector<ApplicationSharedPtr>::const_iterator it = subscribedApps.begin();
- for (; subscribedApps.end() != it; ++it) {
+ std::vector<ApplicationSharedPtr>::const_iterator it =
+ subscribed_apps.begin();
+ for (; subscribed_apps.end() != it; ++it) {
ApplicationSharedPtr subscribed_app = *it;
if (!subscribed_app) {
- LOG4CXX_WARN_EXT(logger_, "Null pointer to subscribed app.");
+ LOG4CXX_WARN(logger_, "Null pointer to subscribed app.");
continue;
}
- //Send ButtonPress notification only in HMI_FULL or HMI_LIMITED mode
+ // Send ButtonPress notification only in HMI_FULL or HMI_LIMITED mode
if ((mobile_api::HMILevel::HMI_FULL != subscribed_app->hmi_level()) &&
(mobile_api::HMILevel::HMI_LIMITED != subscribed_app->hmi_level())) {
- LOG4CXX_WARN_EXT(logger_, "OnButtonPress in HMI_BACKGROUND or NONE");
+ LOG4CXX_WARN(logger_,
+ "OnButtonPress notification is allowed only"
+ << "in FULL or LIMITED hmi level");
continue;
}
-
- //Send ButtonPress notification for OK button only in HMI_FULL mode
- if ((static_cast<uint32_t>(mobile_apis::ButtonName::OK) == btn_id) &&
- (mobile_api::HMILevel::HMI_FULL != subscribed_app->hmi_level())) {
- continue;
+ // if "app_id" absent send notification only in HMI_FULL mode
+ if (is_app_id_exists || subscribed_app->IsFullscreen()) {
+ SendButtonPress(subscribed_app);
}
-
- SendButtonPress(subscribed_app);
}
}
void OnButtonPressNotification::SendButtonPress(ApplicationConstSharedPtr app) {
if (!app) {
- LOG4CXX_ERROR_EXT(logger_, "OnButtonPress NULL pointer");
+ LOG4CXX_ERROR(logger_, "OnButtonPress NULL pointer");
return;
}
- smart_objects::SmartObjectSPtr on_btn_press = new smart_objects::SmartObject();
+ smart_objects::SmartObjectSPtr on_btn_press =
+ new smart_objects::SmartObject();
if (!on_btn_press) {
- LOG4CXX_ERROR_EXT(logger_, "OnButtonPress NULL pointer");
+ LOG4CXX_ERROR(logger_, "OnButtonPress NULL pointer");
return;
}
-
(*on_btn_press)[strings::params][strings::connection_key] = app->app_id();
(*on_btn_press)[strings::params][strings::function_id] =
@@ -148,7 +148,7 @@ void OnButtonPressNotification::SendButtonPress(ApplicationConstSharedPtr app) {
(*message_)[strings::msg_params][hmi_response::button_mode];
if ((*message_)[strings::msg_params].keyExists(
- hmi_response::custom_button_id)) {
+ hmi_response::custom_button_id)) {
(*on_btn_press)[strings::msg_params][strings::custom_button_id] =
(*message_)[strings::msg_params][strings::custom_button_id];
}
diff --git a/src/components/application_manager/src/commands/mobile/on_command_notification.cc b/src/components/application_manager/src/commands/mobile/on_command_notification.cc
index 9bba1851f6..ae8aeff771 100644
--- a/src/components/application_manager/src/commands/mobile/on_command_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_command_notification.cc
@@ -32,37 +32,35 @@
*/
#include "application_manager/commands/mobile/on_command_notification.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
namespace application_manager {
namespace commands {
-OnCommandNotification::OnCommandNotification(const MessageSharedPtr& message)
- : CommandNotificationImpl(message) {
-}
+OnCommandNotification::OnCommandNotification(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandNotificationImpl(message, application_manager) {}
-OnCommandNotification::~OnCommandNotification() {
-}
+OnCommandNotification::~OnCommandNotification() {}
void OnCommandNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ ApplicationSharedPtr app = application_manager_.application(
(*message_)[strings::msg_params][strings::app_id].asInt());
if (!app) {
- LOG4CXX_ERROR_EXT(logger_, "No application associated with session key");
+ LOG4CXX_ERROR(logger_, "No application associated with session key");
return;
}
- const uint32_t cmd_id = (*message_)[strings::msg_params][strings::cmd_id]
- .asUInt();
+ const uint32_t cmd_id =
+ (*message_)[strings::msg_params][strings::cmd_id].asUInt();
if (!app->FindCommand(cmd_id)) {
- LOG4CXX_ERROR_EXT(logger_,
- " No applications found for the command " << cmd_id);
+ LOG4CXX_ERROR(logger_, " No applications found for the command " << cmd_id);
return;
}
diff --git a/src/components/application_manager/src/commands/mobile/on_driver_distraction_notification.cc b/src/components/application_manager/src/commands/mobile/on_driver_distraction_notification.cc
index e9145520f4..44ed2cf3b7 100644
--- a/src/components/application_manager/src/commands/mobile/on_driver_distraction_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_driver_distraction_notification.cc
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/on_driver_distraction_notification.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "interfaces/MOBILE_API.h"
@@ -43,12 +43,10 @@ namespace commands {
namespace mobile {
OnDriverDistractionNotification::OnDriverDistractionNotification(
- const MessageSharedPtr& message)
- : CommandNotificationImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandNotificationImpl(message, application_manager) {}
-OnDriverDistractionNotification::~OnDriverDistractionNotification() {
-}
+OnDriverDistractionNotification::~OnDriverDistractionNotification() {}
void OnDriverDistractionNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
diff --git a/src/components/application_manager/src/commands/mobile/on_hash_change_notification.cc b/src/components/application_manager/src/commands/mobile/on_hash_change_notification.cc
index 10f3eb1ab6..19b93f2cbf 100644
--- a/src/components/application_manager/src/commands/mobile/on_hash_change_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_hash_change_notification.cc
@@ -33,7 +33,7 @@
*/
#include "application_manager/commands/mobile/on_hash_change_notification.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "interfaces/MOBILE_API.h"
#include <string>
@@ -45,12 +45,10 @@ namespace commands {
namespace mobile {
OnHashChangeNotification::OnHashChangeNotification(
- const MessageSharedPtr& message)
- : CommandNotificationImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandNotificationImpl(message, application_manager) {}
-OnHashChangeNotification::~OnHashChangeNotification() {
-}
+OnHashChangeNotification::~OnHashChangeNotification() {}
void OnHashChangeNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
@@ -60,17 +58,17 @@ void OnHashChangeNotification::Run() {
int32_t app_id;
app_id = (*message_)[strings::params][strings::connection_key].asInt();
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
+ ApplicationSharedPtr app = application_manager_.application(app_id);
if (app) {
(*message_)[strings::msg_params][strings::hash_id] = app->curHash();
SendNotification();
} else {
- LOG4CXX_WARN(logger_, "Application with app_id " << app_id << " does not exist");
+ LOG4CXX_WARN(logger_,
+ "Application with app_id " << app_id << " does not exist");
}
-
}
-} //namespace mobile
+} // namespace mobile
} // namespace commands
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 e4a2d7c340..5225002652 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
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/on_hmi_status_notification.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/message_helper.h"
#include "application_manager/message.h"
#include "interfaces/MOBILE_API.h"
@@ -41,20 +41,17 @@ namespace application_manager {
namespace commands {
OnHMIStatusNotification::OnHMIStatusNotification(
- const MessageSharedPtr& message)
- : CommandNotificationImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandNotificationImpl(message, application_manager) {}
-OnHMIStatusNotification::~OnHMIStatusNotification() {
-}
+OnHMIStatusNotification::~OnHMIStatusNotification() {}
void OnHMIStatusNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- (*message_)[strings::params][strings::message_type] = static_cast<int32_t> (
- application_manager::MessageType::kNotification);
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
- connection_key());
+ (*message_)[strings::params][strings::message_type] =
+ static_cast<int32_t>(application_manager::MessageType::kNotification);
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app.valid()) {
LOG4CXX_ERROR(logger_, "OnHMIStatusNotification application doesn't exist");
return;
@@ -67,18 +64,18 @@ void OnHMIStatusNotification::Run() {
(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"
+ LOG4CXX_INFO(logger_,
+ "OnHMIStatusNotification::Send TTS GlobalProperties"
" with empty array to HMI");
- MessageHelper::SendTTSGlobalProperties(app, false);
+ MessageHelper::SendTTSGlobalProperties(app, false, application_manager_);
}
} else if ((mobile_apis::HMILevel::HMI_FULL == hmi_level) ||
- (mobile_apis::HMILevel::HMI_LIMITED == 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_,
"OnHMIStatusNotification AddAppToTTSGlobalPropertiesList");
- ApplicationManagerImpl::instance()->AddAppToTTSGlobalPropertiesList(
- app->app_id());
+ application_manager_.AddAppToTTSGlobalPropertiesList(app->app_id());
}
}
SendNotification();
diff --git a/src/components/application_manager/src/commands/mobile/on_hmi_status_notification_from_mobile.cc b/src/components/application_manager/src/commands/mobile/on_hmi_status_notification_from_mobile.cc
index 02b4b64aa0..9b16bd3572 100644
--- a/src/components/application_manager/src/commands/mobile/on_hmi_status_notification_from_mobile.cc
+++ b/src/components/application_manager/src/commands/mobile/on_hmi_status_notification_from_mobile.cc
@@ -32,7 +32,6 @@
*/
#include "application_manager/commands/mobile/on_hmi_status_notification_from_mobile.h"
-#include "application_manager/application_manager_impl.h"
#include "application_manager/message_helper.h"
#include "application_manager/message.h"
@@ -40,30 +39,27 @@ namespace application_manager {
namespace commands {
OnHMIStatusNotificationFromMobile::OnHMIStatusNotificationFromMobile(
- const MessageSharedPtr& message)
- : CommandNotificationFromMobileImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandNotificationFromMobileImpl(message, application_manager) {}
-OnHMIStatusNotificationFromMobile::~OnHMIStatusNotificationFromMobile() {
-}
+OnHMIStatusNotificationFromMobile::~OnHMIStatusNotificationFromMobile() {}
void OnHMIStatusNotificationFromMobile::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- (*message_)[strings::params][strings::message_type] = static_cast<int32_t> (
- application_manager::MessageType::kNotification);
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
- connection_key());
+ (*message_)[strings::params][strings::message_type] =
+ static_cast<int32_t>(application_manager::MessageType::kNotification);
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app.valid()) {
- LOG4CXX_ERROR(logger_,
- "OnHMIStatusNotificationFromMobile application doesn't exist");
+ LOG4CXX_ERROR(
+ logger_, "OnHMIStatusNotificationFromMobile application doesn't exist");
return;
}
mobile_apis::HMILevel::eType current_hmi_state =
static_cast<mobile_apis::HMILevel::eType>(
- (*message_)[strings::msg_params][strings::hmi_level].asUInt());
+ (*message_)[strings::msg_params][strings::hmi_level].asUInt());
bool is_current_state_foreground =
mobile_apis::HMILevel::HMI_FULL == current_hmi_state;
@@ -72,44 +68,46 @@ void OnHMIStatusNotificationFromMobile::Run() {
connection_handler::DeviceHandle handle = app->device();
bool is_apps_requested_before =
- application_manager::ApplicationManagerImpl::instance()->
- IsAppsQueriedFrom(handle);
+ application_manager_.IsAppsQueriedFrom(handle);
- LOG4CXX_DEBUG(logger_, "Mobile HMI state notication came for connection key:"
- << connection_key() << " and handle: " << handle);
+ LOG4CXX_DEBUG(logger_,
+ "Mobile HMI state notication came for connection key:"
+ << connection_key() << " and handle: " << handle);
if (!is_apps_requested_before &&
ProtocolVersion::kV4 == app->protocol_version() && app->is_foreground()) {
// In case this notification will be received from mobile side with
// foreground level for app on mobile, this should trigger remote
// apps list query for SDL 4.0 app
- MessageHelper::SendQueryApps(connection_key());
+ MessageHelper::SendQueryApps(connection_key(), application_manager_);
return;
}
if (is_apps_requested_before) {
- LOG4CXX_DEBUG(logger_, "Remote apps list had been requested already "
- " for handle: " << handle);
+ LOG4CXX_DEBUG(logger_,
+ "Remote apps list had been requested already "
+ " for handle: "
+ << handle);
if (ProtocolVersion::kV4 == app->protocol_version()) {
- ApplicationManagerImpl::ApplicationListAccessor accessor;
+ const ApplicationSet& accessor =
+ application_manager_.applications().GetData();
bool is_another_foreground_sdl4_app = false;
- ApplicationManagerImpl::ApplictionSetIt it = accessor.begin();
- for (;accessor.end() != it; ++it) {
+ ApplicationSetConstIt it = accessor.begin();
+ for (; accessor.end() != it; ++it) {
if (connection_key() != (*it)->app_id() &&
ProtocolVersion::kV4 == (*it)->protocol_version() &&
- (*it)->is_foreground()) {
+ (*it)->is_foreground()) {
is_another_foreground_sdl4_app = true;
break;
}
}
if (!is_another_foreground_sdl4_app) {
- application_manager::ApplicationManagerImpl::instance()->
- MarkAppsGreyOut(handle, !is_current_state_foreground);
- application_manager::ApplicationManagerImpl::instance()->
- SendUpdateAppList();
+ application_manager_.MarkAppsGreyOut(handle,
+ !is_current_state_foreground);
+ application_manager_.SendUpdateAppList();
}
}
return;
diff --git a/src/components/application_manager/src/commands/mobile/on_keyboard_input_notification.cc b/src/components/application_manager/src/commands/mobile/on_keyboard_input_notification.cc
index 6285d684ea..851e9f3059 100644
--- a/src/components/application_manager/src/commands/mobile/on_keyboard_input_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_keyboard_input_notification.cc
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/on_keyboard_input_notification.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "interfaces/MOBILE_API.h"
@@ -43,36 +43,37 @@ namespace commands {
namespace mobile {
OnKeyBoardInputNotification::OnKeyBoardInputNotification(
- const MessageSharedPtr& message)
- : CommandNotificationImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandNotificationImpl(message, application_manager) {}
-OnKeyBoardInputNotification::~OnKeyBoardInputNotification() {
-}
+OnKeyBoardInputNotification::~OnKeyBoardInputNotification() {}
void OnKeyBoardInputNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
ApplicationSharedPtr app_to_notify;
- ApplicationManagerImpl::ApplicationListAccessor accessor;
- ApplicationManagerImpl::ApplictionSetIt it = accessor.begin();
- for (; accessor.end() != it; ++it) {
+ DataAccessor<ApplicationSet> accessor = application_manager_.applications();
+ ApplicationSetIt it = accessor.GetData().begin();
+ for (; accessor.GetData().end() != it; ++it) {
// if there is app with active perform interaction use it for notification
- if ((*it)->is_perform_interaction_active()) {
- LOG4CXX_INFO(logger_, "There is application with active PerformInteraction");
- app_to_notify = *it;
+ ApplicationSharedPtr app = *it;
+ if (app->is_perform_interaction_active()) {
+ LOG4CXX_INFO(logger_,
+ "There is application with active PerformInteraction");
+ app_to_notify = app;
break;
}
- if (mobile_apis::HMILevel::eType::HMI_FULL == (*it)->hmi_level()) {
+ if (mobile_apis::HMILevel::eType::HMI_FULL == app->hmi_level()) {
LOG4CXX_INFO(logger_, "There is application in HMI_FULL level");
- app_to_notify = *it;
+ app_to_notify = app;
}
}
if (app_to_notify.valid()) {
- (*message_)[strings::params][strings::connection_key] = app_to_notify->app_id();
+ (*message_)[strings::params][strings::connection_key] =
+ app_to_notify->app_id();
SendNotification();
}
}
diff --git a/src/components/application_manager/src/commands/mobile/on_language_change_notification.cc b/src/components/application_manager/src/commands/mobile/on_language_change_notification.cc
index 43b1b5b921..76420b85b6 100644
--- a/src/components/application_manager/src/commands/mobile/on_language_change_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_language_change_notification.cc
@@ -38,12 +38,10 @@ namespace application_manager {
namespace commands {
OnLanguageChangeNotification::OnLanguageChangeNotification(
- const MessageSharedPtr& message)
- : CommandNotificationImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandNotificationImpl(message, application_manager) {}
-OnLanguageChangeNotification::~OnLanguageChangeNotification() {
-}
+OnLanguageChangeNotification::~OnLanguageChangeNotification() {}
void OnLanguageChangeNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
diff --git a/src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc b/src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc
index 62ea1af1fc..a4167a802e 100644
--- a/src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_permissions_change_notification.cc
@@ -40,12 +40,10 @@ namespace application_manager {
namespace commands {
OnPermissionsChangeNotification::OnPermissionsChangeNotification(
- const MessageSharedPtr& message)
- : CommandNotificationImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandNotificationImpl(message, application_manager) {}
-OnPermissionsChangeNotification::~OnPermissionsChangeNotification() {
-}
+OnPermissionsChangeNotification::~OnPermissionsChangeNotification() {}
void OnPermissionsChangeNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
diff --git a/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc b/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc
index fbcbaede81..b57490806c 100644
--- a/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc
@@ -36,8 +36,8 @@
#include "application_manager/commands/mobile/on_system_request_notification.h"
#include "interfaces/MOBILE_API.h"
#include "utils/file_system.h"
-#include "application_manager/application_manager_impl.h"
-#include "application_manager/policies/policy_handler.h"
+#include "application_manager/application_manager.h"
+#include "application_manager/policies/policy_handler_interface.h"
namespace application_manager {
@@ -46,8 +46,8 @@ namespace commands {
namespace mobile {
OnSystemRequestNotification::OnSystemRequestNotification(
- const MessageSharedPtr& message)
- : CommandNotificationImpl(message) {}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandNotificationImpl(message, application_manager) {}
OnSystemRequestNotification::~OnSystemRequestNotification() {}
@@ -56,8 +56,7 @@ void OnSystemRequestNotification::Run() {
using namespace application_manager;
using namespace mobile_apis;
- ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()->application(connection_key());
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app.valid()) {
LOG4CXX_ERROR(logger_,
@@ -68,9 +67,10 @@ void OnSystemRequestNotification::Run() {
RequestType::eType request_type = static_cast<RequestType::eType>(
(*message_)[strings::msg_params][strings::request_type].asInt());
-
- if (!policy::PolicyHandler::instance()->IsRequestTypeAllowed(
- app->mobile_app_id(), request_type)) {
+ const policy::PolicyHandlerInterface& policy_handler =
+ application_manager_.GetPolicyHandler();
+ if (!policy_handler.IsRequestTypeAllowed(app->policy_app_id(),
+ request_type)) {
LOG4CXX_WARN(logger_,
"Request type " << request_type
<< " is not allowed by policies");
@@ -104,8 +104,9 @@ void OnSystemRequestNotification::Run() {
#ifdef EXTENDED_POLICY
void OnSystemRequestNotification::AddHeader(BinaryMessage& message) const {
LOG4CXX_AUTO_TRACE(logger_);
- const int timeout = policy::PolicyHandler::instance()->TimeoutExchange();
+ const int timeout = application_manager_.GetPolicyHandler().TimeoutExchange();
+ size_t content_length;
char size_str[24];
if (0 > sprintf(size_str, "%zu", static_cast<size_t>(message.size()))) {
@@ -116,27 +117,46 @@ void OnSystemRequestNotification::AddHeader(BinaryMessage& message) const {
if (0 > sprintf(timeout_str, "%d", timeout)) {
memset(timeout_str, 0, sizeof(timeout_str));
}
+
std::string policy_table_string = std::string(message.begin(), message.end());
- ParsePTString(policy_table_string);
+
+ /* The Content-Length to be sent in the HTTP Request header should be
+ calculated before additional escape characters are added to the
+ policy table string. The mobile proxy will remove the escape
+ characters after receiving this request. */
+
+ content_length = ParsePTString(policy_table_string);
+
+ if (0 > sprintf(size_str, "%zu", content_length)) {
+ memset(size_str, 0, sizeof(size_str));
+ }
+
const std::string header =
- "{"
- " \"HTTPRequest\": {"
- "\"headers\": {"
- "\"ContentType\": \"application/json\","
- "\"ConnectTimeout\": " + std::string(timeout_str) + ","
- "\"DoOutput\": true,"
- "\"DoInput\": true,"
- "\"UseCaches\": false,"
- "\"RequestMethod\": \"POST\","
- "\"ReadTimeout\":" + std::string(timeout_str) + ","
- "\"InstanceFollowRedirects\": false,"
- "\"charset\": \"utf-8\","
- "\"Content_Length\": " + std::string(size_str) +
- "},"
- "\"body\": \"" + policy_table_string + "\""
+ "{"
+ " \"HTTPRequest\": {"
+ "\"headers\": {"
+ "\"ContentType\": \"application/json\","
+ "\"ConnectTimeout\": " +
+ std::string(timeout_str) +
+ ","
+ "\"DoOutput\": true,"
+ "\"DoInput\": true,"
+ "\"UseCaches\": false,"
+ "\"RequestMethod\": \"POST\","
+ "\"ReadTimeout\":" +
+ std::string(timeout_str) +
+ ","
+ "\"InstanceFollowRedirects\": false,"
+ "\"charset\": \"utf-8\","
+ "\"Content_-Length\": " +
+ std::string(size_str) +
+ "},"
+ "\"body\": \"" +
+ policy_table_string +
+ "\""
"}"
- "}";
+ "}";
message.clear();
message.assign(header.begin(), header.end());
@@ -145,23 +165,28 @@ void OnSystemRequestNotification::AddHeader(BinaryMessage& message) const {
logger_, "Header added: " << std::string(message.begin(), message.end()));
}
-void OnSystemRequestNotification::ParsePTString(std::string& pt_string) const{
+size_t OnSystemRequestNotification::ParsePTString(
+ std::string& pt_string) const {
std::string result;
- size_t length = pt_string.length();
- result.reserve(length*2);
- for(size_t i=0;i<length;++i){
- if(pt_string[i]=='\"' || pt_string[i]=='\\'){
+ size_t length = pt_string.length();
+ size_t result_length = length;
+ result.reserve(length * 2);
+ for (size_t i = 0; i < length; ++i) {
+ if (pt_string[i] == '\"' || pt_string[i] == '\\') {
result += '\\';
- } else if(pt_string[i] == '\n') {
+ } else if (pt_string[i] == '\n') {
+ result_length--; // contentLength is adjusted when this character is not
+ // copied to result.
continue;
}
result += pt_string[i];
}
pt_string = result;
+ return result_length;
}
#endif
-} //namespace mobile
+} // namespace mobile
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/on_tbt_client_state_notification.cc b/src/components/application_manager/src/commands/mobile/on_tbt_client_state_notification.cc
index 99a5d665db..894469ac34 100644
--- a/src/components/application_manager/src/commands/mobile/on_tbt_client_state_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_tbt_client_state_notification.cc
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/on_tbt_client_state_notification.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "interfaces/MOBILE_API.h"
@@ -41,12 +41,10 @@ namespace application_manager {
namespace commands {
OnTBTClientStateNotification::OnTBTClientStateNotification(
- const MessageSharedPtr& message)
- : CommandNotificationImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandNotificationImpl(message, application_manager) {}
-OnTBTClientStateNotification::~OnTBTClientStateNotification() {
-}
+OnTBTClientStateNotification::~OnTBTClientStateNotification() {}
void OnTBTClientStateNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
@@ -55,7 +53,7 @@ void OnTBTClientStateNotification::Run() {
static_cast<int32_t>(application_manager::MessageType::kNotification);
const std::vector<ApplicationSharedPtr>& applications =
- ApplicationManagerImpl::instance()->applications_with_navi();
+ application_manager_.applications_with_navi();
std::vector<ApplicationSharedPtr>::const_iterator it = applications.begin();
for (; applications.end() != it; ++it) {
diff --git a/src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc b/src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc
index 8780ab1b6a..c769194c95 100644
--- a/src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/on_touch_event_notification.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
namespace application_manager {
@@ -42,18 +42,16 @@ namespace commands {
namespace mobile {
OnTouchEventNotification::OnTouchEventNotification(
- const MessageSharedPtr& message)
- : CommandNotificationImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandNotificationImpl(message, application_manager) {}
-OnTouchEventNotification::~OnTouchEventNotification() {
-}
+OnTouchEventNotification::~OnTouchEventNotification() {}
void OnTouchEventNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
const std::vector<ApplicationSharedPtr>& applications =
- ApplicationManagerImpl::instance()->applications_with_navi();
+ application_manager_.applications_with_navi();
std::vector<ApplicationSharedPtr>::const_iterator it = applications.begin();
for (; applications.end() != it; ++it) {
diff --git a/src/components/application_manager/src/commands/mobile/on_vehicle_data_notification.cc b/src/components/application_manager/src/commands/mobile/on_vehicle_data_notification.cc
index 68755bef54..37abbab351 100644
--- a/src/components/application_manager/src/commands/mobile/on_vehicle_data_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_vehicle_data_notification.cc
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/on_vehicle_data_notification.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
#include "interfaces/MOBILE_API.h"
@@ -42,19 +42,17 @@ namespace application_manager {
namespace commands {
OnVehicleDataNotification::OnVehicleDataNotification(
- const MessageSharedPtr& message)
- : CommandNotificationImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandNotificationImpl(message, application_manager) {}
-OnVehicleDataNotification::~OnVehicleDataNotification() {
-}
+OnVehicleDataNotification::~OnVehicleDataNotification() {}
void OnVehicleDataNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
std::vector<ApplicationSharedPtr> appNotification;
std::vector<ApplicationSharedPtr>::iterator appNotification_it =
- appNotification.begin();
+ appNotification.begin();
std::vector<smart_objects::SmartObject> appSO;
const VehicleData& vehicle_data = MessageHelper::vehicle_data();
@@ -63,39 +61,47 @@ void OnVehicleDataNotification::Run() {
for (; vehicle_data.end() != it; ++it) {
if (true == (*message_)[strings::msg_params].keyExists(it->first)) {
const std::vector<ApplicationSharedPtr>& applications =
- ApplicationManagerImpl::instance()->IviInfoUpdated(it->second,
- (*message_)[strings::msg_params][it->first].asInt());
+ application_manager_.IviInfoUpdated(
+ it->second, (*message_)[strings::msg_params][it->first].asInt());
+
+ std::vector<ApplicationSharedPtr>::const_iterator app_it =
+ applications.begin();
- std::vector<ApplicationSharedPtr>::const_iterator app_it = applications.begin();
for (; applications.end() != app_it; ++app_it) {
const ApplicationSharedPtr app = *app_it;
- DCHECK(app);
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ continue;
+ }
- appNotification_it = find(appNotification.begin(), appNotification.end(), app);
+ appNotification_it =
+ find(appNotification.begin(), appNotification.end(), app);
if (appNotification_it == appNotification.end()) {
appNotification.push_back(app);
- smart_objects::SmartObject msg_param = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_param =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_param[it->first] = (*message_)[strings::msg_params][it->first];
appSO.push_back(msg_param);
} else {
- size_t idx = std::distance(appNotification.begin(), appNotification_it);
+ size_t idx =
+ std::distance(appNotification.begin(), appNotification_it);
appSO[idx][it->first] = (*message_)[strings::msg_params][it->first];
}
}
}
}
- LOG4CXX_DEBUG(logger_, "Number of Notifications to be send: " <<
- appNotification.size());
+ LOG4CXX_DEBUG(
+ logger_,
+ "Number of Notifications to be send: " << appNotification.size());
for (size_t idx = 0; idx < appNotification.size(); idx++) {
- LOG4CXX_INFO(
- logger_,
- "Send OnVehicleData PRNDL notification to " << appNotification[idx]->name()
- << " application id " << appNotification[idx]->app_id());
+ LOG4CXX_INFO(logger_,
+ "Send OnVehicleData PRNDL notification to "
+ << appNotification[idx]->name().c_str()
+ << " application id " << appNotification[idx]->app_id());
(*message_)[strings::params][strings::connection_key] =
- appNotification[idx]->app_id();
+ appNotification[idx]->app_id();
(*message_)[strings::msg_params] = appSO[idx];
SendNotification();
}
diff --git a/src/components/application_manager/src/commands/mobile/on_way_point_change_notification.cc b/src/components/application_manager/src/commands/mobile/on_way_point_change_notification.cc
new file mode 100644
index 0000000000..0b24228810
--- /dev/null
+++ b/src/components/application_manager/src/commands/mobile/on_way_point_change_notification.cc
@@ -0,0 +1,61 @@
+/*
+
+ Copyright (c) 2013, Ford Motor Company
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the Ford Motor Company nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "application_manager/commands/mobile/on_way_point_change_notification.h"
+#include "application_manager/application_manager.h"
+
+namespace application_manager {
+namespace commands {
+
+OnWayPointChangeNotification::OnWayPointChangeNotification(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandNotificationImpl(message, application_manager) {}
+
+OnWayPointChangeNotification::~OnWayPointChangeNotification() {}
+
+void OnWayPointChangeNotification::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ std::set<int32_t> subscribed_for_way_points =
+ application_manager_.GetAppsSubscribedForWayPoints();
+
+ for (std::set<int32_t>::const_iterator app_id =
+ subscribed_for_way_points.begin();
+ app_id != subscribed_for_way_points.end();
+ ++app_id) {
+ (*message_)[strings::params][strings::connection_key] = *app_id;
+ SendNotification();
+ }
+}
+} // namespace commands
+} // namespace application_manager
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 b1ac31b9d8..d595119d45 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
@@ -33,9 +33,10 @@
#include <cstring>
#include "application_manager/commands/mobile/perform_audio_pass_thru_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
+#include "utils/helpers.h"
namespace application_manager {
@@ -44,25 +45,19 @@ namespace commands {
namespace str = strings;
PerformAudioPassThruRequest::PerformAudioPassThruRequest(
- const MessageSharedPtr& message)
- : CommandRequestImpl(message),
- is_active_tts_speak_(false),
- result_tts_speak_(mobile_apis::Result::SUCCESS) {
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager)
+ , is_active_tts_speak_(false)
+ , result_tts_speak_(mobile_apis::Result::SUCCESS) {
subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout);
}
-PerformAudioPassThruRequest::~PerformAudioPassThruRequest() {
-}
+PerformAudioPassThruRequest::~PerformAudioPassThruRequest() {}
void PerformAudioPassThruRequest::onTimeOut() {
LOG4CXX_AUTO_TRACE(logger_);
- if (ApplicationManagerImpl::instance()->end_audio_pass_thru()) {
- ApplicationManagerImpl::instance()->StopAudioPassThru(connection_key());
- }
-
FinishTTSSpeak();
-
CommandRequestImpl::onTimeOut();
}
@@ -75,8 +70,7 @@ bool PerformAudioPassThruRequest::Init() {
void PerformAudioPassThruRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()->application(connection_key());
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
LOG4CXX_ERROR(logger_, "APPLICATION_NOT_REGISTERED");
@@ -92,7 +86,8 @@ void PerformAudioPassThruRequest::Run() {
if (IsWhiteSpaceExist()) {
LOG4CXX_ERROR(logger_,
- "Incoming perform audio pass thru has contains \\t\\n \\\\t \\\\n"
+ "Incoming perform audio pass thru has contains "
+ "\\t\\n \\\\t \\\\n"
" text contains only whitespace in initialPrompt");
SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
@@ -112,10 +107,18 @@ void PerformAudioPassThruRequest::Run() {
void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
+ using namespace helpers;
+
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
case hmi_apis::FunctionID::UI_PerformAudioPassThru: {
+ LOG4CXX_TRACE(logger_, "Received UI_PerformAudioPassThru");
+
+ if (!WaitTTSSpeak()) {
+ LOG4CXX_DEBUG(logger_, "TTS.Speak is absent");
+ return;
+ }
mobile_apis::Result::eType mobile_code =
GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
@@ -128,47 +131,52 @@ void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) {
return;
}
- if (ApplicationManagerImpl::instance()->end_audio_pass_thru()) {
- ApplicationManagerImpl::instance()->StopAudioPassThru(connection_key());
- }
-
FinishTTSSpeak();
std::string return_info;
- bool result = mobile_apis::Result::SUCCESS == mobile_code ||
- mobile_apis::Result::RETRY == mobile_code;
-
- if ((mobile_apis::Result::SUCCESS == mobile_code) &&
- (mobile_apis::Result::UNSUPPORTED_RESOURCE == result_tts_speak_)) {
+ const bool result = Compare<mobile_api::Result::eType, EQ, ONE>(
+ mobile_code,
+ mobile_apis::Result::SUCCESS,
+ mobile_apis::Result::RETRY,
+ mobile_apis::Result::WARNINGS);
+
+ const bool is_result_ok = Compare<mobile_api::Result::eType, EQ, ONE>(
+ mobile_code,
+ mobile_apis::Result::SUCCESS,
+ mobile_apis::Result::WARNINGS);
+
+ if (is_result_ok &&
+ mobile_apis::Result::UNSUPPORTED_RESOURCE == result_tts_speak_) {
mobile_code = mobile_apis::Result::WARNINGS;
return_info = "Unsupported phoneme type sent in a prompt";
}
- SendResponse(result, mobile_code, return_info.c_str(),
+ SendResponse(result,
+ mobile_code,
+ return_info.empty() ? NULL : return_info.c_str(),
&(message[strings::msg_params]));
break;
}
case hmi_apis::FunctionID::TTS_Speak: {
LOG4CXX_INFO(logger_, "Received TTS_Speak event");
- result_tts_speak_ = GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asUInt()));
+ result_tts_speak_ =
+ GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asUInt()));
is_active_tts_speak_ = false;
if (mobile_apis::Result::SUCCESS == result_tts_speak_) {
SendRecordStartNotification();
StartMicrophoneRecording();
// update request timeout to get time for perform audio recording
- ApplicationManagerImpl::instance()->
- updateRequestTimeout(connection_key(),
- correlation_id(),
- default_timeout());
+ application_manager_.updateRequestTimeout(
+ connection_key(), correlation_id(), default_timeout());
}
break;
}
case hmi_apis::FunctionID::TTS_OnResetTimeout: {
LOG4CXX_INFO(logger_, "Received TTS_OnResetTimeout event");
- ApplicationManagerImpl::instance()->updateRequestTimeout(
+ application_manager_.updateRequestTimeout(
connection_key(), correlation_id(), default_timeout());
break;
}
@@ -180,7 +188,8 @@ void PerformAudioPassThruRequest::on_event(const event_engine::Event& event) {
}
void PerformAudioPassThruRequest::SendSpeakRequest() {
- // crate HMI TTS speak request
+ LOG4CXX_AUTO_TRACE(logger_);
+
using namespace hmi_apis;
using namespace smart_objects;
@@ -189,8 +198,8 @@ void PerformAudioPassThruRequest::SendSpeakRequest() {
if ((*message_)[str::msg_params].keyExists(str::initial_prompt) &&
(0 < (*message_)[str::msg_params][str::initial_prompt].length())) {
for (uint32_t i = 0;
- i < (*message_)[str::msg_params][str::initial_prompt].length();
- ++i) {
+ i < (*message_)[str::msg_params][str::initial_prompt].length();
+ ++i) {
msg_params[hmi_request::tts_chunks][i][str::text] =
(*message_)[str::msg_params][str::initial_prompt][i][str::text];
msg_params[hmi_request::tts_chunks][i][str::type] =
@@ -205,12 +214,13 @@ void PerformAudioPassThruRequest::SendSpeakRequest() {
}
void PerformAudioPassThruRequest::SendPerformAudioPassThruRequest() {
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_params[str::app_id] = connection_key();
- // duration
msg_params[hmi_request::max_duration] =
(*message_)[str::msg_params][str::max_duration];
@@ -218,21 +228,21 @@ void PerformAudioPassThruRequest::SendPerformAudioPassThruRequest() {
smart_objects::SmartObject(smart_objects::SmartType_Array);
if ((*message_)[str::msg_params].keyExists(str::audio_pass_display_text1)) {
- msg_params[hmi_request::audio_pass_display_texts]
- [0][hmi_request::field_name] = static_cast<int32_t>
- (hmi_apis::Common_TextFieldName::audioPassThruDisplayText1);
- msg_params[hmi_request::audio_pass_display_texts]
- [0][hmi_request::field_text] =
- (*message_)[str::msg_params][str::audio_pass_display_text1];
+ msg_params[hmi_request::audio_pass_display_texts][0]
+ [hmi_request::field_name] = static_cast<int32_t>(
+ hmi_apis::Common_TextFieldName::audioPassThruDisplayText1);
+ msg_params[hmi_request::audio_pass_display_texts][0]
+ [hmi_request::field_text] =
+ (*message_)[str::msg_params][str::audio_pass_display_text1];
}
if ((*message_)[str::msg_params].keyExists(str::audio_pass_display_text2)) {
- msg_params[hmi_request::audio_pass_display_texts]
- [1][hmi_request::field_name] = static_cast<int32_t>
- (hmi_apis::Common_TextFieldName::audioPassThruDisplayText2);
- msg_params[hmi_request::audio_pass_display_texts]
- [1][hmi_request::field_text] =
- (*message_)[str::msg_params][str::audio_pass_display_text2];
+ msg_params[hmi_request::audio_pass_display_texts][1]
+ [hmi_request::field_name] = static_cast<int32_t>(
+ hmi_apis::Common_TextFieldName::audioPassThruDisplayText2);
+ msg_params[hmi_request::audio_pass_display_texts][1]
+ [hmi_request::field_text] =
+ (*message_)[str::msg_params][str::audio_pass_display_text2];
}
if ((*message_)[str::msg_params].keyExists(str::mute_audio)) {
@@ -243,23 +253,28 @@ void PerformAudioPassThruRequest::SendPerformAudioPassThruRequest() {
msg_params[str::mute_audio] = true;
}
- SendHMIRequest(hmi_apis::FunctionID::UI_PerformAudioPassThru,
- &msg_params, true);
+ SendHMIRequest(
+ hmi_apis::FunctionID::UI_PerformAudioPassThru, &msg_params, true);
}
void PerformAudioPassThruRequest::SendRecordStartNotification() {
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_params[strings::app_id] = connection_key();
CreateHMINotification(hmi_apis::FunctionID::UI_OnRecordStart, msg_params);
}
void PerformAudioPassThruRequest::StartMicrophoneRecording() {
- ApplicationManagerImpl::instance()->begin_audio_pass_thru();
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ application_manager_.BeginAudioPassThrough();
- ApplicationManagerImpl::instance()->StartAudioPassThruThread(
- connection_key(), correlation_id(),
+ application_manager_.StartAudioPassThruThread(
+ connection_key(),
+ correlation_id(),
(*message_)[str::msg_params][str::max_duration].asInt(),
(*message_)[str::msg_params][str::sampling_rate].asInt(),
(*message_)[str::msg_params][str::bits_per_sample].asInt(),
@@ -286,25 +301,25 @@ bool PerformAudioPassThruRequest::IsWhiteSpaceExist() {
}
}
- if ((*message_)[strings::msg_params].
- keyExists(strings::audio_pass_display_text1)) {
-
- str = (*message_)[strings::msg_params]
- [strings::audio_pass_display_text1].asCharArray();
+ if ((*message_)[strings::msg_params].keyExists(
+ strings::audio_pass_display_text1)) {
+ str = (*message_)[strings::msg_params][strings::audio_pass_display_text1]
+ .asCharArray();
if (!CheckSyntax(str)) {
- LOG4CXX_ERROR(logger_,
+ LOG4CXX_ERROR(
+ logger_,
"Invalid audio_pass_display_text1 value syntax check failed");
return true;
}
}
- if ((*message_)[strings::msg_params].
- keyExists(strings::audio_pass_display_text2)) {
-
- str = (*message_)[strings::msg_params]
- [strings::audio_pass_display_text2].asCharArray();
+ if ((*message_)[strings::msg_params].keyExists(
+ strings::audio_pass_display_text2)) {
+ str = (*message_)[strings::msg_params][strings::audio_pass_display_text2]
+ .asCharArray();
if (!CheckSyntax(str)) {
- LOG4CXX_ERROR(logger_,
+ LOG4CXX_ERROR(
+ logger_,
"Invalid audio_pass_display_text2 value syntax check failed");
return true;
}
@@ -312,11 +327,43 @@ bool PerformAudioPassThruRequest::IsWhiteSpaceExist() {
return false;
}
-void PerformAudioPassThruRequest::FinishTTSSpeak(){
- if (is_active_tts_speak_) {
- is_active_tts_speak_ = false;
- SendHMIRequest(hmi_apis::FunctionID::TTS_StopSpeaking, NULL);
+void PerformAudioPassThruRequest::FinishTTSSpeak() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (application_manager_.EndAudioPassThrough()) {
+ LOG4CXX_DEBUG(logger_, "Stop AudioPassThru.");
+ application_manager_.StopAudioPassThru(connection_key());
}
+ if (!is_active_tts_speak_) {
+ LOG4CXX_WARN(logger_, "TTS Speak is inactive.");
+ return;
+ }
+ is_active_tts_speak_ = false;
+ SendHMIRequest(hmi_apis::FunctionID::TTS_StopSpeaking, NULL);
+}
+
+bool PerformAudioPassThruRequest::WaitTTSSpeak() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ uint64_t default_timeout_msec =
+ application_manager_.get_settings().default_timeout();
+ const TimevalStruct start_time = date_time::DateTime::getCurrentTime();
+
+ // Waiting for TTS_Speak
+ while (is_active_tts_speak_) {
+ uint64_t difference_between_start_current_time =
+ date_time::DateTime::calculateTimeSpan(start_time);
+ // Send GENERIC_ERROR after default timeout
+ if (difference_between_start_current_time > default_timeout_msec) {
+ LOG4CXX_WARN(logger_, "Expired timeout for TTS.Speak response");
+ // Don't use onTimeOut(), because default_timeout_ is bigger than
+ // Default time in *.ini file
+ FinishTTSSpeak();
+ SendResponse(false,
+ mobile_apis::Result::eType::GENERIC_ERROR,
+ "Expired timeout for TTS.Speak response");
+ return false;
+ }
+ }
+ return true;
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_response.cc b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_response.cc
index 585383889d..e8a638c076 100644
--- a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_response.cc
+++ b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_response.cc
@@ -32,25 +32,21 @@
*/
#include "application_manager/commands/mobile/perform_audio_pass_thru_response.h"
-#include "application_manager/application_manager_impl.h"
-
namespace application_manager {
namespace commands {
PerformAudioPassThruResponse::PerformAudioPassThruResponse(
- const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-PerformAudioPassThruResponse::~PerformAudioPassThruResponse() {
-}
+PerformAudioPassThruResponse::~PerformAudioPassThruResponse() {}
void PerformAudioPassThruResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // 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 54edc8e516..39ad51e822 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
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2013, Ford Motor Company
+ Copyright (c) 2016, Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -34,39 +34,44 @@
#include <string.h>
#include <string>
#include "application_manager/commands/mobile/perform_interaction_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
-#include "config_profile/profile.h"
+
#include "interfaces/MOBILE_API.h"
#include "interfaces/HMI_API.h"
#include "utils/file_system.h"
+#include "utils/helpers.h"
+#include "utils/custom_string.h"
+#include "utils/gen_hash.h"
namespace application_manager {
namespace commands {
+namespace custom_str = utils::custom_string;
+
uint32_t PerformInteractionRequest::pi_requests_count_ = 0;
PerformInteractionRequest::PerformInteractionRequest(
- const MessageSharedPtr& message)
-: CommandRequestImpl(message),
- vr_perform_interaction_code_(mobile_apis::Result::INVALID_ENUM),
- interaction_mode_(mobile_apis::InteractionMode::INVALID_ENUM),
- ui_response_recived_(false),
- vr_response_recived_(false),
- app_pi_was_active_before_(false) {
-
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager)
+ , interaction_mode_(mobile_apis::InteractionMode::INVALID_ENUM)
+ , ui_response_recived_(false)
+ , vr_response_recived_(false)
+ , ui_result_(false)
+ , vr_result_(false)
+ , app_pi_was_active_before_(false)
+ , vr_resultCode_(mobile_apis::Result::INVALID_ENUM)
+ , ui_resultCode_(mobile_apis::Result::INVALID_ENUM) {
subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout);
subscribe_on_event(hmi_apis::FunctionID::VR_OnCommand);
subscribe_on_event(hmi_apis::FunctionID::Buttons_OnButtonPress);
}
-PerformInteractionRequest::~PerformInteractionRequest() {
-}
+PerformInteractionRequest::~PerformInteractionRequest() {}
bool PerformInteractionRequest::Init() {
-
/* Timeout in milliseconds.
If omitted a standard value of 10000 milliseconds is used.*/
if ((*message_)[strings::msg_params].keyExists(strings::timeout)) {
@@ -87,8 +92,7 @@ bool PerformInteractionRequest::Init() {
void PerformInteractionRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()->application(connection_key());
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
LOG4CXX_ERROR(logger_, "Application is not registered");
@@ -97,7 +101,7 @@ void PerformInteractionRequest::Run() {
}
if (app->is_perform_interaction_active()) {
- LOG4CXX_INFO(logger_, "Application has active PerformInteraction");
+ LOG4CXX_DEBUG(logger_, "Application has active PerformInteraction");
app_pi_was_active_before_ = true;
}
@@ -112,8 +116,9 @@ void PerformInteractionRequest::Run() {
if ((mobile_apis::InteractionMode::VR_ONLY == interaction_mode_) &&
(mobile_apis::LayoutMode::KEYBOARD == interaction_layout)) {
- LOG4CXX_ERROR_EXT(logger_, "PerformInteraction contains InteractionMode"
- "=VR_ONLY and interactionLayout=KEYBOARD");
+ LOG4CXX_ERROR(logger_,
+ "PerformInteraction contains InteractionMode"
+ "=VR_ONLY and interactionLayout=KEYBOARD");
SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
}
@@ -124,38 +129,41 @@ void PerformInteractionRequest::Run() {
if (0 == choice_set_id_list_length) {
if (mobile_apis::LayoutMode::KEYBOARD == interaction_layout) {
if (mobile_apis::InteractionMode::BOTH == interaction_mode_) {
- LOG4CXX_ERROR_EXT(logger_,"interactionChoiceSetIDList is empty,"
- " InteractionMode=BOTH and"
- " interactionLayout=KEYBOARD");
+ LOG4CXX_ERROR(logger_,
+ "interactionChoiceSetIDList is empty,"
+ " InteractionMode=BOTH and"
+ " interactionLayout=KEYBOARD");
SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
}
} else {
- LOG4CXX_ERROR_EXT(logger_,"interactionChoiceSetIDList is empty"
- " and interactionLayout!=KEYBOARD");
+ LOG4CXX_ERROR(logger_,
+ "interactionChoiceSetIDList is empty"
+ " and interactionLayout!=KEYBOARD");
SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
}
}
- if (msg_params.keyExists(strings::vr_help)) {
- if (mobile_apis::Result::SUCCESS != MessageHelper::VerifyImageVrHelpItems(
- msg_params[strings::vr_help], app)) {
- LOG4CXX_ERROR_EXT(
- logger_,
- "MessageHelper::VerifyImageVrHelpItems return INVALID_DATA!");
- SendResponse(false, mobile_apis::Result::INVALID_DATA);
- return;
- }
+ if (choice_set_id_list_length &&
+ (!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");
+ SendResponse(false, mobile_apis::Result::INVALID_ID);
+ return;
}
- smart_objects::SmartObject& choice_list =
- msg_params[strings::interaction_choice_set_id_list];
-
- for (size_t i = 0; i < choice_list.length(); ++i) {
- if (!app->FindChoiceSet(choice_list[i].asInt())) {
- LOG4CXX_ERROR(logger_, "Invalid ID");
- SendResponse(false, mobile_apis::Result::INVALID_ID);
+ if (msg_params.keyExists(strings::vr_help)) {
+ if (mobile_apis::Result::SUCCESS !=
+ MessageHelper::VerifyImageVrHelpItems(
+ msg_params[strings::vr_help], app, application_manager_)) {
+ LOG4CXX_ERROR(logger_,
+ "Verification of " << strings::vr_help << " failed.");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
}
}
@@ -169,27 +177,24 @@ void PerformInteractionRequest::Run() {
switch (interaction_mode_) {
case mobile_apis::InteractionMode::BOTH: {
- LOG4CXX_INFO(logger_, "Interaction Mode: BOTH");
- if (!CheckChoiceSetVRSynonyms(app) ||
- !CheckChoiceSetMenuNames(app) ||
+ LOG4CXX_DEBUG(logger_, "Interaction Mode: BOTH");
+ if (!CheckChoiceSetVRSynonyms(app) || !CheckChoiceSetMenuNames(app) ||
!CheckVrHelpItemPositions(app)) {
return;
}
break;
}
case mobile_apis::InteractionMode::MANUAL_ONLY: {
- LOG4CXX_INFO(logger_, "Interaction Mode: MANUAL_ONLY");
- if (!CheckChoiceSetVRSynonyms(app) ||
- !CheckChoiceSetMenuNames(app) ||
+ LOG4CXX_DEBUG(logger_, "Interaction Mode: MANUAL_ONLY");
+ if (!CheckChoiceSetVRSynonyms(app) || !CheckChoiceSetMenuNames(app) ||
!CheckVrHelpItemPositions(app)) {
return;
}
break;
}
case mobile_apis::InteractionMode::VR_ONLY: {
- LOG4CXX_INFO(logger_, "Interaction Mode: VR_ONLY");
- if (!CheckChoiceSetVRSynonyms(app) ||
- !CheckVrHelpItemPositions(app)) {
+ LOG4CXX_DEBUG(logger_, "Interaction Mode: VR_ONLY");
+ if (!CheckChoiceSetVRSynonyms(app) || !CheckVrHelpItemPositions(app)) {
return;
}
break;
@@ -210,25 +215,35 @@ void PerformInteractionRequest::Run() {
void PerformInteractionRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
+ const smart_objects::SmartObject& message = event.smart_object();
+ smart_objects::SmartObject msg_param =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
switch (event.id()) {
case hmi_apis::FunctionID::UI_OnResetTimeout: {
- LOG4CXX_INFO(logger_, "Received UI_OnResetTimeout event");
- ApplicationManagerImpl::instance()->updateRequestTimeout(connection_key(),
- correlation_id(),
- default_timeout());
+ LOG4CXX_DEBUG(logger_, "Received UI_OnResetTimeout event");
+ application_manager_.updateRequestTimeout(
+ connection_key(), correlation_id(), default_timeout());
break;
}
case hmi_apis::FunctionID::UI_PerformInteraction: {
- LOG4CXX_INFO(logger_, "Received UI_PerformInteraction event");
+ LOG4CXX_DEBUG(logger_, "Received UI_PerformInteraction event");
ui_response_recived_ = true;
- ProcessPerformInteractionResponse(event.smart_object());
+ unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction);
+ ui_resultCode_ =
+ GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asUInt()));
+ ProcessPerformInteractionResponse(event.smart_object(), msg_param);
break;
}
case hmi_apis::FunctionID::VR_PerformInteraction: {
- LOG4CXX_INFO(logger_, "Received VR_PerformInteraction");
+ LOG4CXX_DEBUG(logger_, "Received VR_PerformInteraction");
vr_response_recived_ = true;
- ProcessVRResponse(event.smart_object());
+ unsubscribe_from_event(hmi_apis::FunctionID::VR_PerformInteraction);
+ vr_resultCode_ =
+ GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asUInt()));
+ ProcessVRResponse(event.smart_object(), msg_param);
break;
}
default: {
@@ -236,6 +251,12 @@ void PerformInteractionRequest::on_event(const event_engine::Event& event) {
break;
}
}
+
+ if (mobile_apis::InteractionMode::BOTH == interaction_mode_ &&
+ !HasHMIResponsesToWait()) {
+ LOG4CXX_DEBUG(logger_, "Send response in BOTH iteraction mode");
+ SendBothModeResponse(msg_param);
+ }
}
void PerformInteractionRequest::onTimeOut() {
@@ -248,16 +269,14 @@ void PerformInteractionRequest::onTimeOut() {
DisablePerformInteraction();
CommandRequestImpl::onTimeOut();
} else {
- ApplicationManagerImpl::instance()->updateRequestTimeout(connection_key(),
- correlation_id(),
- default_timeout());
+ application_manager_.updateRequestTimeout(
+ connection_key(), correlation_id(), default_timeout());
}
break;
}
case mobile_apis::InteractionMode::VR_ONLY: {
- ApplicationManagerImpl::instance()->updateRequestTimeout(connection_key(),
- correlation_id(),
- default_timeout());
+ application_manager_.updateRequestTimeout(
+ connection_key(), correlation_id(), default_timeout());
break;
}
case mobile_apis::InteractionMode::MANUAL_ONLY: {
@@ -273,155 +292,160 @@ void PerformInteractionRequest::onTimeOut() {
};
}
-
void PerformInteractionRequest::ProcessVRResponse(
- const smart_objects::SmartObject& message) {
+ const smart_objects::SmartObject& message,
+ smart_objects::SmartObject& msg_params) {
LOG4CXX_AUTO_TRACE(logger_);
using namespace mobile_apis;
using namespace mobile_apis::Result;
using namespace smart_objects;
+ using namespace helpers;
- ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()->application(connection_key());
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
- if (!app.get()) {
+ if (!app) {
LOG4CXX_ERROR(logger_, "NULL pointer");
return;
}
- vr_perform_interaction_code_ = static_cast<eType>(
- message[strings::params][hmi_response::code].asInt());
- if (ABORTED == vr_perform_interaction_code_ ||
- TIMED_OUT == vr_perform_interaction_code_) {
- LOG4CXX_INFO(logger_, "VR response aborted");
+ CheckResponseResultCode();
+ msg_params[strings::trigger_source] =
+ static_cast<int32_t>(TriggerSource::TS_VR);
+
+ const bool is_vr_aborted_timeout =
+ Compare<Result::eType, EQ, ONE>(vr_resultCode_, ABORTED, TIMED_OUT);
+
+ if (is_vr_aborted_timeout) {
+ LOG4CXX_DEBUG(logger_, "VR response aborted");
if (InteractionMode::VR_ONLY == interaction_mode_) {
- LOG4CXX_INFO(logger_, "Aborted or Timeout Send Close Popup");
+ LOG4CXX_DEBUG(logger_, "Aborted or Timeout Send Close Popup");
TerminatePerformInteraction();
- SendResponse(false, vr_perform_interaction_code_);
- return;
- } else {
- LOG4CXX_INFO(logger_, "Update timeout for UI");
- ApplicationManagerImpl::instance()->
- updateRequestTimeout(connection_key(),
- correlation_id(),
- default_timeout());
+ SendResponse(false, vr_resultCode_);
return;
}
- }
-
- if (REJECTED == vr_perform_interaction_code_) {
- LOG4CXX_INFO(logger_, "VR had been rejected.");
- TerminatePerformInteraction();
- SendResponse(false, vr_perform_interaction_code_);
+ LOG4CXX_DEBUG(logger_, "Update timeout for UI");
+ application_manager_.updateRequestTimeout(
+ connection_key(), correlation_id(), default_timeout());
return;
}
- if (SUCCESS == vr_perform_interaction_code_ &&
+ if (SUCCESS == vr_resultCode_ &&
InteractionMode::MANUAL_ONLY == interaction_mode_) {
- LOG4CXX_INFO(logger_, "VR response SUCCESS in MANUAL_ONLY mode " <<
- "Wait for UI response");
+ LOG4CXX_DEBUG(logger_,
+ "VR response SUCCESS in MANUAL_ONLY mode "
+ << "Wait for UI response");
// in case MANUAL_ONLY mode VR.PI SUCCESS just return
return;
}
- SmartObject msg_params = SmartObject(SmartType_Map);
- SmartObject* ptr_msg_params = NULL;
- if (message[strings::msg_params].keyExists(strings::choice_id)) {
- if (CheckChoiceIDFromResponse(
- app, message[strings::msg_params][strings::choice_id].asInt())) {
- msg_params[strings::choice_id] =
- message[strings::msg_params][strings::choice_id].asInt();
- ptr_msg_params = &msg_params;
- } else {
+ const SmartObject& hmi_msg_params = message[strings::msg_params];
+ if (hmi_msg_params.keyExists(strings::choice_id)) {
+ const int choise_id = hmi_msg_params[strings::choice_id].asInt();
+ if (!CheckChoiceIDFromResponse(app, choise_id)) {
LOG4CXX_ERROR(logger_, "Wrong choiceID was received from HMI");
TerminatePerformInteraction();
- SendResponse(false, GENERIC_ERROR,"Wrong choiceID was received from HMI");
+ SendResponse(
+ false, GENERIC_ERROR, "Wrong choiceID was received from HMI");
return;
}
+ msg_params[strings::choice_id] = choise_id;
}
- eType result_code = INVALID_ENUM;
+ vr_result_ = true;
- if (UNSUPPORTED_RESOURCE == vr_perform_interaction_code_) {
- LOG4CXX_INFO(logger_, "VR response WARNINGS");
- result_code = WARNINGS;
- } else {
- LOG4CXX_INFO(logger_, "VR response SUCCESS");
- result_code = SUCCESS;
- msg_params[strings::trigger_source] =
- static_cast<int32_t>(TriggerSource::TS_VR);
- ptr_msg_params = &msg_params;
+ if (mobile_apis::InteractionMode::BOTH == interaction_mode_ &&
+ mobile_apis::Result::SUCCESS != vr_resultCode_) {
+ LOG4CXX_DEBUG(logger_, "VR response isn't SUCCESS in BOTH mode");
+ return;
}
+
+ LOG4CXX_DEBUG(logger_, "VR response consider to be SUCCESS");
TerminatePerformInteraction();
- SendResponse(true, result_code, NULL, ptr_msg_params);
+ SendResponse(vr_result_, SUCCESS, NULL, &msg_params);
}
void PerformInteractionRequest::ProcessPerformInteractionResponse(
- const smart_objects::SmartObject& message) {
+ const smart_objects::SmartObject& message,
+ smart_objects::SmartObject& msg_params) {
LOG4CXX_AUTO_TRACE(logger_);
+ using namespace helpers;
+ using namespace smart_objects;
- ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()->application(connection_key());
- if (!app.get()) {
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
+ if (!app) {
LOG4CXX_ERROR(logger_, "NULL pointer");
return;
}
- bool result = false;
- std::string info;
-
- smart_objects::SmartObject msg_params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
+ ui_result_ = Compare<mobile_api::Result::eType, EQ, ONE>(
+ ui_resultCode_,
+ mobile_apis::Result::SUCCESS,
+ mobile_apis::Result::WARNINGS,
+ mobile_apis::Result::UNSUPPORTED_RESOURCE);
- mobile_apis::Result::eType result_code =
- GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asUInt()));
+ const bool is_pi_warning = Compare<mobile_api::Result::eType, EQ, ONE>(
+ ui_resultCode_, mobile_apis::Result::WARNINGS);
- if (mobile_apis::Result::SUCCESS == result_code) {
- result = true;
- }
+ const bool is_pi_unsupported = Compare<mobile_api::Result::eType, EQ, ONE>(
+ ui_resultCode_, mobile_apis::Result::UNSUPPORTED_RESOURCE);
- if (mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code) {
- result = true;
- result_code = mobile_apis::Result::WARNINGS;
- info = "Unsupported phoneme type was sent in an item";
- }
+ std::string info;
- if (result) {
+ if (ui_result_) {
+ if (is_pi_warning) {
+ ui_resultCode_ = mobile_apis::Result::WARNINGS;
+ info = "Unsupported phoneme type was sent in an item";
+ if (message.keyExists(strings::params) &&
+ message[strings::params].keyExists(strings::data)) {
+ msg_params = message[strings::params][strings::data];
+ }
+ } else if (is_pi_unsupported) {
+ ui_resultCode_ = mobile_apis::Result::UNSUPPORTED_RESOURCE;
+ info = "Unsupported phoneme type was sent in an item";
+ } else if (message.keyExists(strings::msg_params)) {
+ msg_params = message[strings::msg_params];
+ }
// result code must be GENERIC_ERROR in case wrong choice_id
- if (message[strings::msg_params].keyExists(strings::choice_id)) {
- if (!CheckChoiceIDFromResponse(app, message[strings::msg_params]
- [strings::choice_id].asInt())) {
- result_code = mobile_apis::Result::GENERIC_ERROR;
+ if (msg_params.keyExists(strings::choice_id)) {
+ if (!CheckChoiceIDFromResponse(app,
+ msg_params[strings::choice_id].asInt())) {
+ ui_resultCode_ = mobile_apis::Result::GENERIC_ERROR;
info = "Wrong choiceID was received from HMI";
} else {
- msg_params = message[strings::msg_params];
- msg_params[strings::trigger_source] = mobile_apis::TriggerSource::TS_MENU;
+ msg_params[strings::trigger_source] =
+ mobile_apis::TriggerSource::TS_MENU;
+ }
+ } else if (msg_params.keyExists(strings::manual_text_entry)) {
+ msg_params[strings::trigger_source] =
+ mobile_apis::TriggerSource::TS_KEYBOARD;
+ if (msg_params[strings::manual_text_entry].empty()) {
+ msg_params.erase(strings::manual_text_entry);
}
- } else if (message[strings::msg_params].keyExists(strings::manual_text_entry)) {
- msg_params = message[strings::msg_params];
- msg_params[strings::trigger_source] = mobile_apis::TriggerSource::TS_KEYBOARD;
}
}
DisablePerformInteraction();
- const char* return_info = (info.empty()) ? NULL : info.c_str();
- const smart_objects::SmartObject* response_params = (msg_params.empty()) ? NULL : &msg_params;
- SendResponse(result, result_code, return_info, response_params);
+ const SmartObject* response_params = msg_params.empty() ? NULL : &msg_params;
+
+ if (mobile_apis::InteractionMode::BOTH != interaction_mode_) {
+ DisablePerformInteraction();
+ SendResponse(ui_result_, ui_resultCode_, info.c_str(), response_params);
+ }
}
void PerformInteractionRequest::SendUIPerformInteractionRequest(
application_manager::ApplicationSharedPtr const app) {
+ LOG4CXX_AUTO_TRACE(logger_);
smart_objects::SmartObject& choice_set_id_list =
(*message_)[strings::msg_params][strings::interaction_choice_set_id_list];
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
- mobile_apis::InteractionMode::eType mode =
+ mobile_apis::InteractionMode::eType mode =
static_cast<mobile_apis::InteractionMode::eType>(
- (*message_)[strings::msg_params][strings::interaction_mode].asInt());
+ (*message_)[strings::msg_params][strings::interaction_mode].asInt());
if (mobile_apis::InteractionMode::VR_ONLY != mode) {
msg_params[hmi_request::initial_text][hmi_request::field_name] =
@@ -443,24 +467,23 @@ void PerformInteractionRequest::SendUIPerformInteractionRequest(
if (mobile_apis::InteractionMode::BOTH == mode ||
mobile_apis::InteractionMode::MANUAL_ONLY == mode) {
- msg_params[strings::timeout] = default_timeout_/2;
+ msg_params[strings::timeout] = default_timeout_ / 2;
} else {
msg_params[strings::timeout] = default_timeout_;
}
msg_params[strings::app_id] = app->app_id();
if (mobile_apis::InteractionMode::VR_ONLY != mode) {
- msg_params[strings::choice_set] = smart_objects::SmartObject(
- smart_objects::SmartType_Array);
+ msg_params[strings::choice_set] =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
}
int32_t index_array_of_vr_help = 0;
for (size_t i = 0; i < choice_set_id_list.length(); ++i) {
- smart_objects::SmartObject* choice_set = app->FindChoiceSet(
- choice_set_id_list[i].asInt());
+ smart_objects::SmartObject* choice_set =
+ app->FindChoiceSet(choice_set_id_list[i].asInt());
if (choice_set) {
// save perform interaction choice set
- app->AddPerformInteractionChoiceSet(correlation_id(),
- choice_set_id_list[i].asInt(),
- *choice_set);
+ app->AddPerformInteractionChoiceSet(
+ correlation_id(), choice_set_id_list[i].asInt(), *choice_set);
for (size_t j = 0; j < (*choice_set)[strings::choice_set].length(); ++j) {
if (mobile_apis::InteractionMode::VR_ONLY != mode) {
size_t index = msg_params[strings::choice_set].length();
@@ -469,8 +492,8 @@ void PerformInteractionRequest::SendUIPerformInteractionRequest(
// vrCommands should be added via VR.AddCommand only
msg_params[strings::choice_set][index].erase(strings::vr_commands);
}
- if (mobile_apis::InteractionMode::MANUAL_ONLY !=
- mode && !is_vr_help_item) {
+ if (mobile_apis::InteractionMode::MANUAL_ONLY != mode &&
+ !is_vr_help_item) {
smart_objects::SmartObject& vr_commands =
(*choice_set)[strings::choice_set][j][strings::vr_commands];
if (0 < vr_commands.length()) {
@@ -484,32 +507,31 @@ void PerformInteractionRequest::SendUIPerformInteractionRequest(
}
}
}
- if ((*message_)[strings::msg_params]
- .keyExists(hmi_request::interaction_layout)
- && mobile_apis::InteractionMode::VR_ONLY != mode) {
+ if ((*message_)[strings::msg_params].keyExists(
+ hmi_request::interaction_layout) &&
+ mobile_apis::InteractionMode::VR_ONLY != mode) {
msg_params[hmi_request::interaction_layout] =
- (*message_)[strings::msg_params][hmi_request::interaction_layout].
- asInt();
+ (*message_)[strings::msg_params][hmi_request::interaction_layout]
+ .asInt();
}
- CreateUIPerformInteraction(msg_params, app);
-}
-
-void PerformInteractionRequest::CreateUIPerformInteraction(
- const smart_objects::SmartObject& msg_params,
- application_manager::ApplicationSharedPtr const app) {
- SendHMIRequest(hmi_apis::FunctionID::UI_PerformInteraction,
- &msg_params, true);
+ SendHMIRequest(
+ hmi_apis::FunctionID::UI_PerformInteraction, &msg_params, true);
}
void PerformInteractionRequest::SendVRPerformInteractionRequest(
application_manager::ApplicationSharedPtr const app) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
smart_objects::SmartObject msg_params =
smart_objects::SmartObject(smart_objects::SmartType_Map);
+
smart_objects::SmartObject& choice_list =
- (*message_)[strings::msg_params][strings::interaction_choice_set_id_list];
+ (*message_)[strings::msg_params][strings::interaction_choice_set_id_list];
if (mobile_apis::InteractionMode::MANUAL_ONLY != interaction_mode_) {
- msg_params[strings::grammar_id] = smart_objects::SmartObject(smart_objects::SmartType_Array);
+ msg_params[strings::grammar_id] =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
+
int32_t grammar_id_index = 0;
for (uint32_t i = 0; i < choice_list.length(); ++i) {
smart_objects::SmartObject* choice_set =
@@ -518,16 +540,14 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest(
LOG4CXX_WARN(logger_, "Couldn't found choiset");
continue;
}
- msg_params[strings::grammar_id][grammar_id_index++]=
+ msg_params[strings::grammar_id][grammar_id_index++] =
(*choice_set)[strings::grammar_id].asUInt();
}
}
if ((*message_)[strings::msg_params].keyExists(strings::help_prompt)) {
-
msg_params[strings::help_prompt] =
(*message_)[strings::msg_params][strings::help_prompt];
-
} else {
if (choice_list.length() != 0) {
msg_params[strings::help_prompt] =
@@ -539,9 +559,8 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest(
app->FindChoiceSet(choice_list[i].asInt());
if (choice_set) {
- for (uint32_t j = 0;
- j < (*choice_set)[strings::choice_set].length();
- ++j) {
+ for (uint32_t j = 0; j < (*choice_set)[strings::choice_set].length();
+ ++j) {
smart_objects::SmartObject& vr_commands =
(*choice_set)[strings::choice_set][j][strings::vr_commands];
if (0 < vr_commands.length()) {
@@ -550,8 +569,9 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest(
// Since there is no custom data from application side, SDL should
// construct prompt and append delimiter to each item
item[strings::type] = hmi_apis::Common_SpeechCapabilities::SC_TEXT;
- item[strings::text] = vr_commands[0].asString() +
- profile::Profile::instance()->tts_delimiter();
+ item[strings::text] =
+ vr_commands[0].asString() +
+ application_manager_.get_settings().tts_delimiter();
msg_params[strings::help_prompt][index++] = item;
}
}
@@ -563,7 +583,7 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest(
if ((*message_)[strings::msg_params].keyExists(strings::timeout_prompt)) {
msg_params[strings::timeout_prompt] =
- (*message_)[strings::msg_params][strings::timeout_prompt];
+ (*message_)[strings::msg_params][strings::timeout_prompt];
} else {
if (msg_params.keyExists(strings::help_prompt)) {
msg_params[strings::timeout_prompt] = msg_params[strings::help_prompt];
@@ -571,38 +591,40 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest(
}
if ((*message_)[strings::msg_params].keyExists(strings::initial_prompt)) {
- msg_params[strings::initial_prompt] =
- (*message_)[strings::msg_params][strings::initial_prompt];
+ msg_params[strings::initial_prompt] =
+ (*message_)[strings::msg_params][strings::initial_prompt];
}
mobile_apis::InteractionMode::eType mode =
static_cast<mobile_apis::InteractionMode::eType>(
- (*message_)[strings::msg_params][strings::interaction_mode].asInt());
+ (*message_)[strings::msg_params][strings::interaction_mode].asInt());
if (mobile_apis::InteractionMode::BOTH == mode ||
mobile_apis::InteractionMode::MANUAL_ONLY == mode) {
- msg_params[strings::timeout] = default_timeout_/2;
+ msg_params[strings::timeout] = default_timeout_ / 2;
} else {
msg_params[strings::timeout] = default_timeout_;
}
-
- SendHMIRequest(hmi_apis::FunctionID::VR_PerformInteraction, &msg_params,
- true);
+ msg_params[strings::app_id] = app->app_id();
+ SendHMIRequest(
+ hmi_apis::FunctionID::VR_PerformInteraction, &msg_params, true);
}
bool PerformInteractionRequest::CheckChoiceSetMenuNames(
application_manager::ApplicationSharedPtr const app) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
smart_objects::SmartObject& choice_list =
(*message_)[strings::msg_params][strings::interaction_choice_set_id_list];
for (size_t i = 0; i < choice_list.length(); ++i) {
// choice_set contains SmartObject msg_params
- smart_objects::SmartObject* i_choice_set = app->FindChoiceSet(
- choice_list[i].asInt());
+ smart_objects::SmartObject* i_choice_set =
+ app->FindChoiceSet(choice_list[i].asInt());
for (size_t j = 0; j < choice_list.length(); ++j) {
- smart_objects::SmartObject* j_choice_set = app->FindChoiceSet(
- choice_list[j].asInt());
+ smart_objects::SmartObject* j_choice_set =
+ app->FindChoiceSet(choice_list[j].asInt());
if (i == j) {
// skip check the same element
@@ -619,16 +641,17 @@ bool PerformInteractionRequest::CheckChoiceSetMenuNames(
size_t jj = 0;
for (; ii < (*i_choice_set)[strings::choice_set].length(); ++ii) {
for (; jj < (*j_choice_set)[strings::choice_set].length(); ++jj) {
- std::string ii_menu_name =
+ const std::string& ii_menu_name =
(*i_choice_set)[strings::choice_set][ii][strings::menu_name]
.asString();
- std::string jj_menu_name =
+ const std::string& jj_menu_name =
(*j_choice_set)[strings::choice_set][jj][strings::menu_name]
.asString();
if (ii_menu_name == jj_menu_name) {
LOG4CXX_ERROR(logger_, "Choice set has duplicated menu name");
- SendResponse(false, mobile_apis::Result::DUPLICATE_NAME,
+ SendResponse(false,
+ mobile_apis::Result::DUPLICATE_NAME,
"Choice set has duplicated menu name");
return false;
}
@@ -642,17 +665,19 @@ bool PerformInteractionRequest::CheckChoiceSetMenuNames(
bool PerformInteractionRequest::CheckChoiceSetVRSynonyms(
application_manager::ApplicationSharedPtr const app) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
smart_objects::SmartObject& choice_list =
(*message_)[strings::msg_params][strings::interaction_choice_set_id_list];
for (size_t i = 0; i < choice_list.length(); ++i) {
// choice_set contains SmartObject msg_params
- smart_objects::SmartObject* i_choice_set = app->FindChoiceSet(
- choice_list[i].asInt());
+ smart_objects::SmartObject* i_choice_set =
+ app->FindChoiceSet(choice_list[i].asInt());
for (size_t j = 0; j < choice_list.length(); ++j) {
- smart_objects::SmartObject* j_choice_set = app->FindChoiceSet(
- choice_list[j].asInt());
+ smart_objects::SmartObject* j_choice_set =
+ app->FindChoiceSet(choice_list[j].asInt());
if (i == j) {
// skip check the same element
@@ -678,11 +703,14 @@ bool PerformInteractionRequest::CheckChoiceSetVRSynonyms(
for (size_t iii = 0; iii < ii_vr_commands.length(); ++iii) {
for (size_t jjj = 0; jjj < jj_vr_commands.length(); ++jjj) {
- std::string vr_cmd_i = ii_vr_commands[iii].asString();
- std::string vr_cmd_j = jj_vr_commands[jjj].asString();
- if (0 == strcasecmp(vr_cmd_i.c_str(), vr_cmd_j.c_str())) {
+ const custom_str::CustomString& vr_cmd_i =
+ ii_vr_commands[iii].asCustomString();
+ const custom_str::CustomString& vr_cmd_j =
+ jj_vr_commands[jjj].asCustomString();
+ if (vr_cmd_i.CompareIgnoreCase(vr_cmd_j)) {
LOG4CXX_ERROR(logger_, "Choice set has duplicated VR synonym");
- SendResponse(false, mobile_apis::Result::DUPLICATE_NAME,
+ SendResponse(false,
+ mobile_apis::Result::DUPLICATE_NAME,
"Choice set has duplicated VR synonym");
return false;
}
@@ -692,16 +720,15 @@ bool PerformInteractionRequest::CheckChoiceSetVRSynonyms(
}
}
}
-
return true;
}
bool PerformInteractionRequest::CheckVrHelpItemPositions(
application_manager::ApplicationSharedPtr const app) {
+ LOG4CXX_AUTO_TRACE(logger_);
if (!(*message_)[strings::msg_params].keyExists(strings::vr_help)) {
- LOG4CXX_INFO(logger_, ""
- "PerformInteractionRequest::CheckVrHelpItemPositions vr_help omitted");
+ LOG4CXX_DEBUG(logger_, strings::vr_help << " is omitted.");
return true;
}
@@ -712,7 +739,8 @@ bool PerformInteractionRequest::CheckVrHelpItemPositions(
for (size_t i = 0; i < vr_help.length(); ++i) {
if (position != vr_help[i][strings::position].asInt()) {
LOG4CXX_ERROR(logger_, "Non-sequential vrHelp item position");
- SendResponse(false, mobile_apis::Result::REJECTED,
+ SendResponse(false,
+ mobile_apis::Result::REJECTED,
"Non-sequential vrHelp item position");
return false;
}
@@ -722,8 +750,9 @@ bool PerformInteractionRequest::CheckVrHelpItemPositions(
}
void PerformInteractionRequest::DisablePerformInteraction() {
- ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()->application(connection_key());
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
LOG4CXX_ERROR(logger_, "NULL pointer");
return;
@@ -750,7 +779,6 @@ bool PerformInteractionRequest::IsWhiteSpaceExist() {
return true;
}
-
if ((*message_)[strings::msg_params].keyExists(strings::initial_prompt)) {
const smart_objects::SmartArray* ip_array =
(*message_)[strings::msg_params][strings::initial_prompt].asArray();
@@ -827,8 +855,10 @@ bool PerformInteractionRequest::IsWhiteSpaceExist() {
}
void PerformInteractionRequest::TerminatePerformInteraction() {
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_params[hmi_request::method_name] = "UI.PerformInteraction";
SendHMIRequest(hmi_apis::FunctionID::UI_ClosePopUp, &msg_params);
DisablePerformInteraction();
@@ -847,8 +877,8 @@ bool PerformInteractionRequest::CheckChoiceIDFromResponse(
const PerformChoice& choice = choice_set_map_it->second;
PerformChoice::const_iterator it = choice.begin();
for (; choice.end() != it; ++it) {
- const smart_objects::SmartObject& choice_set = (*it->second).getElement(
- strings::choice_set);
+ const smart_objects::SmartObject& choice_set =
+ (*it->second).getElement(strings::choice_set);
for (size_t j = 0; j < choice_set.length(); ++j) {
if (choice_id ==
choice_set.getElement(j).getElement(strings::choice_id).asInt()) {
@@ -860,6 +890,101 @@ bool PerformInteractionRequest::CheckChoiceIDFromResponse(
return false;
}
+bool PerformInteractionRequest::CheckChoiceIDFromRequest(
+ ApplicationSharedPtr app,
+ const size_t choice_set_id_list_length,
+ const smart_objects::SmartObject& choice_set_id_list) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ size_t choice_list_length = 0;
+ std::set<uint32_t> choice_id_set;
+ smart_objects::SmartObject* choice_set = 0;
+ std::pair<std::set<uint32_t>::iterator, bool> ins_res;
+
+ for (size_t i = 0; i < choice_set_id_list_length; ++i) {
+ choice_set = app->FindChoiceSet(choice_set_id_list[i].asInt());
+ if (!choice_set) {
+ LOG4CXX_ERROR(
+ logger_,
+ "Couldn't find choiset_id = " << choice_set_id_list[i].asInt());
+ return false;
+ }
+ choice_list_length = (*choice_set)[strings::choice_set].length();
+ const smart_objects::SmartObject& choices_list =
+ (*choice_set)[strings::choice_set];
+ for (size_t k = 0; k < choice_list_length; ++k) {
+ ins_res =
+ choice_id_set.insert(choices_list[k][strings::choice_id].asInt());
+ if (!ins_res.second) {
+ LOG4CXX_ERROR(logger_,
+ "Choise with ID "
+ << choices_list[k][strings::choice_id].asInt()
+ << " already exists");
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+const bool PerformInteractionRequest::HasHMIResponsesToWait() const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ return !ui_response_recived_ || !vr_response_recived_;
+}
+
+void PerformInteractionRequest::CheckResponseResultCode() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ mobile_apis::Result::eType resultCode = mobile_apis::Result::INVALID_ENUM;
+ bool result = false;
+ if (mobile_apis::Result::GENERIC_ERROR == vr_resultCode_) {
+ LOG4CXX_DEBUG(logger_, "VR response GENERIC_ERROR");
+ resultCode = mobile_apis::Result::GENERIC_ERROR;
+ } else if (mobile_apis::Result::REJECTED == vr_resultCode_) {
+ LOG4CXX_DEBUG(logger_, "VR had been rejected.");
+ resultCode = mobile_apis::Result::REJECTED;
+ } else if (mobile_apis::Result::WARNINGS == vr_resultCode_ ||
+ mobile_apis::Result::UNSUPPORTED_REQUEST == vr_resultCode_) {
+ LOG4CXX_DEBUG(logger_, "VR response WARNINGS");
+ resultCode = mobile_api::Result::WARNINGS;
+ result = true;
+ }
+
+ if (mobile_apis::Result::INVALID_ENUM != resultCode) {
+ TerminatePerformInteraction();
+ SendResponse(result, resultCode);
+ }
+}
+
+void PerformInteractionRequest::SendBothModeResponse(
+ const smart_objects::SmartObject& msg_param) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ using namespace mobile_apis::Result;
+
+ bool result = ui_result_ || vr_result_;
+ mobile_apis::Result::eType perform_interaction_result_code = ui_resultCode_;
+
+ if (UNSUPPORTED_RESOURCE == vr_resultCode_ &&
+ UNSUPPORTED_RESOURCE != ui_resultCode_) {
+ perform_interaction_result_code = vr_resultCode_;
+ } else if (UNSUPPORTED_RESOURCE == vr_resultCode_ &&
+ UNSUPPORTED_RESOURCE == ui_resultCode_) {
+ result = false;
+ }
+
+ const bool is_error_code = (SUCCESS != perform_interaction_result_code ||
+ WARNINGS != perform_interaction_result_code);
+
+ if (vr_resultCode_ == ui_resultCode_ && is_error_code) {
+ result = false;
+ }
+
+ const smart_objects::SmartObject* response_params =
+ msg_param.empty() ? NULL : &msg_param;
+
+ TerminatePerformInteraction();
+ SendResponse(result, perform_interaction_result_code, NULL, response_params);
+}
+
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/perform_interaction_response.cc b/src/components/application_manager/src/commands/mobile/perform_interaction_response.cc
index 59d706926d..6003751669 100644
--- a/src/components/application_manager/src/commands/mobile/perform_interaction_response.cc
+++ b/src/components/application_manager/src/commands/mobile/perform_interaction_response.cc
@@ -32,24 +32,21 @@
*/
#include "application_manager/commands/mobile/perform_interaction_response.h"
-#include "application_manager/application_manager_impl.h"
namespace application_manager {
namespace commands {
PerformInteractionResponse::PerformInteractionResponse(
- const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-PerformInteractionResponse::~PerformInteractionResponse() {
-}
+PerformInteractionResponse::~PerformInteractionResponse() {}
void PerformInteractionResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/put_file_request.cc b/src/components/application_manager/src/commands/mobile/put_file_request.cc
index 88743e3668..68e7ad60d1 100644
--- a/src/components/application_manager/src/commands/mobile/put_file_request.cc
+++ b/src/components/application_manager/src/commands/mobile/put_file_request.cc
@@ -31,36 +31,36 @@
POSSIBILITY OF SUCH DAMAGE.
*/
+#include <algorithm>
#include "application_manager/commands/mobile/put_file_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/policies/policy_handler.h"
#include "application_manager/application_impl.h"
-#include "config_profile/profile.h"
+
#include "utils/file_system.h"
namespace application_manager {
namespace commands {
-PutFileRequest::PutFileRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message)
- , offset_(0)
- , sync_file_name_()
- , length_(0)
- , file_type_(mobile_apis::FileType::INVALID_ENUM)
- , is_persistent_file_(false) {
-}
+PutFileRequest::PutFileRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager)
+ , offset_(0)
+ , sync_file_name_()
+ , length_(0)
+ , file_type_(mobile_apis::FileType::INVALID_ENUM)
+ , is_persistent_file_(false) {}
-PutFileRequest::~PutFileRequest() {
-}
+PutFileRequest::~PutFileRequest() {}
void PutFileRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(connection_key());
- smart_objects::SmartObject response_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ application_manager_.application(connection_key());
+ smart_objects::SmartObject response_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
if (!application) {
LOG4CXX_ERROR(logger_, "Application is not registered");
@@ -69,13 +69,14 @@ void PutFileRequest::Run() {
}
if (mobile_api::HMILevel::HMI_NONE == application->hmi_level() &&
- profile::Profile::instance()->put_file_in_none() <=
- application->put_file_in_none_count()) {
+ application_manager_.get_settings().put_file_in_none() <=
+ application->put_file_in_none_count()) {
// If application is in the HMI_NONE level the quantity of allowed
// PutFile request is limited by the configuration profile
LOG4CXX_ERROR(logger_,
"Too many requests from the app with HMILevel HMI_NONE ");
- SendResponse(false, mobile_apis::Result::REJECTED,
+ SendResponse(false,
+ mobile_apis::Result::REJECTED,
"Too many requests from the app with HMILevel HMI_NONE",
&response_params);
return;
@@ -83,7 +84,8 @@ void PutFileRequest::Run() {
if (!(*message_)[strings::params].keyExists(strings::binary_data)) {
LOG4CXX_ERROR(logger_, "Binary data empty");
- SendResponse(false, mobile_apis::Result::INVALID_DATA,
+ SendResponse(false,
+ mobile_apis::Result::INVALID_DATA,
"Binary data empty",
&response_params);
return;
@@ -91,7 +93,8 @@ void PutFileRequest::Run() {
if (!(*message_)[strings::msg_params].keyExists(strings::sync_file_name)) {
LOG4CXX_ERROR(logger_, "No file name");
- SendResponse(false, mobile_apis::Result::INVALID_DATA,
+ SendResponse(false,
+ mobile_apis::Result::INVALID_DATA,
"No file name",
&response_params);
return;
@@ -99,23 +102,24 @@ void PutFileRequest::Run() {
if (!(*message_)[strings::msg_params].keyExists(strings::file_type)) {
LOG4CXX_ERROR(logger_, "No file type");
- SendResponse(false, mobile_apis::Result::INVALID_DATA,
+ SendResponse(false,
+ mobile_apis::Result::INVALID_DATA,
"No file type",
&response_params);
return;
}
sync_file_name_ =
- (*message_)[strings::msg_params][strings::sync_file_name].asString();
- file_type_ =
- static_cast<mobile_apis::FileType::eType>(
+ (*message_)[strings::msg_params][strings::sync_file_name].asString();
+ file_type_ = static_cast<mobile_apis::FileType::eType>(
(*message_)[strings::msg_params][strings::file_type].asInt());
const std::vector<uint8_t> binary_data =
- (*message_)[strings::params][strings::binary_data].asBinary();
+ (*message_)[strings::params][strings::binary_data].asBinary();
// Policy table update in json format is currently to be received via PutFile
// TODO(PV): after latest discussion has to be changed
if (mobile_apis::FileType::JSON == file_type_) {
- policy::PolicyHandler::instance()->ReceiveMessageFromSDK(sync_file_name_, binary_data);
+ application_manager_.GetPolicyHandler().ReceiveMessageFromSDK(
+ sync_file_name_, binary_data);
}
offset_ = 0;
@@ -127,83 +131,92 @@ void PutFileRequest::Run() {
(*message_)[strings::msg_params].keyExists(strings::offset);
if (offset_exist) {
- offset_ = (*message_)[strings::msg_params][strings::offset].asInt64();
+ offset_ = (*message_)[strings::msg_params][strings::offset].asInt();
}
- if ((*message_)[strings::msg_params].
- keyExists(strings::persistent_file)) {
+ if ((*message_)[strings::msg_params].keyExists(strings::persistent_file)) {
is_persistent_file_ =
- (*message_)[strings::msg_params][strings::persistent_file].asBool();
+ (*message_)[strings::msg_params][strings::persistent_file].asBool();
}
- if ((*message_)[strings::msg_params].
- keyExists(strings::system_file)) {
+ if ((*message_)[strings::msg_params].keyExists(strings::system_file)) {
is_system_file =
- (*message_)[strings::msg_params][strings::system_file].asBool();
+ (*message_)[strings::msg_params][strings::system_file].asBool();
}
std::string file_path;
if (is_system_file) {
response_params[strings::space_available] = 0;
- file_path = profile::Profile::instance()->system_files_path();
+ file_path = application_manager_.get_settings().system_files_path();
} else {
- file_path = profile::Profile::instance()->app_storage_folder();
+ file_path = application_manager_.get_settings().app_storage_folder();
file_path += "/" + application->folder_name();
- uint32_t space_available = ApplicationManagerImpl::instance()->
- GetAvailableSpaceForApp(application->folder_name());
+ uint32_t space_available = application->GetAvailableDiskSpace();
if (binary_data.size() > space_available) {
-
response_params[strings::space_available] =
static_cast<uint32_t>(space_available);
LOG4CXX_ERROR(logger_, "Out of memory");
- SendResponse(false, mobile_apis::Result::OUT_OF_MEMORY,
- "Out of memory", &response_params);
+ SendResponse(false,
+ mobile_apis::Result::OUT_OF_MEMORY,
+ "Out of memory",
+ &response_params);
return;
}
}
if (!file_system::CreateDirectoryRecursively(file_path)) {
- LOG4CXX_ERROR(logger_, "Cann't create folder");
- SendResponse(false, mobile_apis::Result::GENERIC_ERROR,
- "Cann't create folder.", &response_params);
+ LOG4CXX_ERROR(logger_, "Can't create folder");
+ SendResponse(false,
+ mobile_apis::Result::GENERIC_ERROR,
+ "Can't create folder.",
+ &response_params);
return;
}
-
- mobile_apis::Result::eType save_result =
- ApplicationManagerImpl::instance()->SaveBinary(binary_data, file_path,
- sync_file_name_, offset_);
-
+ const std::string full_path = file_path + "/" + sync_file_name_;
+ UNUSED(full_path);
+ LOG4CXX_DEBUG(logger_,
+ "Wrtiting " << binary_data.size() << "bytes to " << full_path
+ << " (current size is"
+ << file_system::FileSize(full_path) << ")");
+
+ mobile_apis::Result::eType save_result = application_manager_.SaveBinary(
+ binary_data, file_path, sync_file_name_, offset_);
+
+ LOG4CXX_DEBUG(logger_,
+ "New size of " << full_path << " is "
+ << file_system::FileSize(full_path) << " bytes");
if (!is_system_file) {
- response_params[strings::space_available] = static_cast<uint32_t>(
- ApplicationManagerImpl::instance()->GetAvailableSpaceForApp(
- application->folder_name()));
+ response_params[strings::space_available] =
+ static_cast<uint32_t>(application->GetAvailableDiskSpace());
}
sync_file_name_ = file_path + "/" + sync_file_name_;
switch (save_result) {
case mobile_apis::Result::SUCCESS: {
-
+ LOG4CXX_INFO(logger_, "PutFile is successful");
if (!is_system_file) {
- AppFile file(sync_file_name_, is_persistent_file_,
- is_download_compleate, file_type_);
+ AppFile file(sync_file_name_,
+ is_persistent_file_,
+ is_download_compleate,
+ file_type_);
if (0 == offset_) {
LOG4CXX_INFO(logger_, "New file downloading");
if (!application->AddFile(file)) {
-
LOG4CXX_INFO(logger_,
"Couldn't add file to application (File already Exist"
- << " in application and was rewritten on FS)");
+ << " in application and was rewritten on FS)");
/* It can be first part of new big file, so we need to update
information about it's downloading status and persistence */
if (!application->UpdateFile(file)) {
- LOG4CXX_INFO(logger_, "Couldn't update file");
+ LOG4CXX_ERROR(logger_, "Couldn't update file");
/* If it is impossible to update file, application doesn't
know about existing this file */
- SendResponse(false, mobile_apis::Result::INVALID_DATA,
+ SendResponse(false,
+ mobile_apis::Result::INVALID_DATA,
"Couldn't update file",
&response_params);
return;
@@ -224,20 +237,21 @@ void PutFileRequest::Run() {
break;
}
default:
- LOG4CXX_WARN(logger_, "Save in unsuccessful. Result = " << save_result);
+ LOG4CXX_WARN(logger_,
+ "PutFile is unsuccessful. Result = " << save_result);
SendResponse(false, save_result, "Can't save file", &response_params);
break;
}
}
void PutFileRequest::SendOnPutFileNotification() {
- LOG4CXX_INFO(logger_, "SendOnPutFileNotification" );
- smart_objects::SmartObjectSPtr notification = new smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ LOG4CXX_INFO(logger_, "SendOnPutFileNotification");
+ smart_objects::SmartObjectSPtr notification =
+ new smart_objects::SmartObject(smart_objects::SmartType_Map);
smart_objects::SmartObject& message = *notification;
message[strings::params][strings::function_id] =
- hmi_apis::FunctionID::BasicCommunication_OnPutFile;
+ hmi_apis::FunctionID::BasicCommunication_OnPutFile;
message[strings::params][strings::message_type] = MessageType::kNotification;
message[strings::msg_params][strings::app_id] = connection_key();
@@ -250,7 +264,7 @@ void PutFileRequest::SendOnPutFileNotification() {
message[strings::msg_params][strings::length] = length_;
message[strings::msg_params][strings::persistent_file] = is_persistent_file_;
message[strings::msg_params][strings::file_type] = file_type_;
- ApplicationManagerImpl::instance()->ManageHMICommand(notification);
+ application_manager_.ManageHMICommand(notification);
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/put_file_response.cc b/src/components/application_manager/src/commands/mobile/put_file_response.cc
index 52598fda16..50c62aef7f 100644
--- a/src/components/application_manager/src/commands/mobile/put_file_response.cc
+++ b/src/components/application_manager/src/commands/mobile/put_file_response.cc
@@ -34,31 +34,28 @@
#include "application_manager/commands/mobile/put_file_response.h"
#include "utils/file_system.h"
#include "application_manager/application_impl.h"
-#include "application_manager/application_manager_impl.h"
namespace application_manager {
namespace commands {
-PutFileResponse::PutFileResponse(const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+PutFileResponse::PutFileResponse(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-PutFileResponse::~PutFileResponse() {
-}
+PutFileResponse::~PutFileResponse() {}
void PutFileResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- uint32_t app_id = (*message_)[strings::params][strings::connection_key]
- .asUInt();
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
+ uint32_t app_id =
+ (*message_)[strings::params][strings::connection_key].asUInt();
+ ApplicationSharedPtr app = application_manager_.application(app_id);
if (!app) {
LOG4CXX_ERROR(logger_, "Application not registered");
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
return;
}
-
SendResponse((*message_)[strings::msg_params][strings::success].asBool());
}
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 18f43f12ca..69885f9d40 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
@@ -1,6 +1,5 @@
/*
-
- Copyright (c) 2013, Ford Motor Company
+ Copyright (c) 2016, Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -31,8 +30,9 @@
POSSIBILITY OF SUCH DAMAGE.
*/
+#include <string>
#include "application_manager/commands/mobile/read_did_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "interfaces/MOBILE_API.h"
#include "interfaces/HMI_API.h"
@@ -41,45 +41,46 @@ namespace application_manager {
namespace commands {
-ReadDIDRequest::ReadDIDRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+ReadDIDRequest::ReadDIDRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
-ReadDIDRequest::~ReadDIDRequest() {
-}
+ReadDIDRequest::~ReadDIDRequest() {}
void ReadDIDRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- uint32_t app_id = (*message_)[strings::params][strings::connection_key]
- .asUInt();
+ uint32_t app_id =
+ (*message_)[strings::params][strings::connection_key].asUInt();
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
- LOG4CXX_INFO(logger_, "Correlation_id :" << (*message_)[strings::params][strings::correlation_id]
- .asUInt());
+ ApplicationSharedPtr app = application_manager_.application(app_id);
+ LOG4CXX_INFO(
+ logger_,
+ "Correlation_id :"
+ << (*message_)[strings::params][strings::correlation_id].asUInt());
if (!app) {
- LOG4CXX_ERROR_EXT(logger_, "An application is not registered.");
+ LOG4CXX_ERROR(logger_, "An application is not registered.");
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
return;
}
if (app->IsCommandLimitsExceeded(
- static_cast<mobile_apis::FunctionID::eType>(function_id()),
- application_manager::TLimitSource::CONFIG_FILE)) {
+ static_cast<mobile_apis::FunctionID::eType>(function_id()),
+ application_manager::TLimitSource::CONFIG_FILE)) {
LOG4CXX_ERROR(logger_, "ReadDID frequency is too high.");
SendResponse(false, mobile_apis::Result::REJECTED);
return;
}
if ((*message_)[strings::msg_params][strings::did_location].empty()) {
- LOG4CXX_ERROR_EXT(logger_, "INVALID_DATA");
+ LOG4CXX_ERROR(logger_, "INVALID_DATA");
SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
}
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_params[strings::app_id] = app->app_id();
msg_params[strings::ecu_name] =
(*message_)[strings::msg_params][strings::ecu_name];
@@ -101,7 +102,13 @@ void ReadDIDRequest::on_event(const event_engine::Event& event) {
bool result = mobile_apis::Result::SUCCESS == result_code;
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ const std::string return_info =
+ message[strings::msg_params][hmi_response::message].asString();
+
+ SendResponse(result,
+ result_code,
+ return_info.c_str(),
+ &(message[strings::msg_params]));
break;
}
default: {
diff --git a/src/components/application_manager/src/commands/mobile/read_did_response.cc b/src/components/application_manager/src/commands/mobile/read_did_response.cc
index 1133fe89ed..e54c4ba005 100644
--- a/src/components/application_manager/src/commands/mobile/read_did_response.cc
+++ b/src/components/application_manager/src/commands/mobile/read_did_response.cc
@@ -32,23 +32,21 @@
*/
#include "application_manager/commands/mobile/read_did_response.h"
-#include "application_manager/application_manager_impl.h"
namespace application_manager {
namespace commands {
-ReadDIDResponse::ReadDIDResponse(const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+ReadDIDResponse::ReadDIDResponse(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-ReadDIDResponse::~ReadDIDResponse() {
-}
+ReadDIDResponse::~ReadDIDResponse() {}
void ReadDIDResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc
index 6a724bfacf..e9f6db05b2 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
@@ -35,18 +35,22 @@
#include <unistd.h>
#include <algorithm>
+#include <map>
#include <string.h>
-#include "application_manager/application_manager_impl.h"
+#include <utils/make_shared.h>
+#include "application_manager/application_manager.h"
+#include "application_manager/policies/policy_handler_interface.h"
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
-#include "application_manager/policies/policy_handler.h"
-#include "config_profile/profile.h"
+#include "application_manager/resumption/resume_ctrl.h"
#include "interfaces/MOBILE_API.h"
+#include "interfaces/generated_msg_version.h"
namespace {
+namespace custom_str = utils::custom_string;
-mobile_apis::AppHMIType::eType StringToAppHMIType(const std::string &str) {
+mobile_apis::AppHMIType::eType StringToAppHMIType(const std::string& str) {
if ("DEFAULT" == str) {
return mobile_apis::AppHMIType::DEFAULT;
} else if ("COMMUNICATION" == str) {
@@ -72,33 +76,55 @@ mobile_apis::AppHMIType::eType StringToAppHMIType(const std::string &str) {
}
}
+std::string AppHMITypeToString(mobile_apis::AppHMIType::eType type) {
+ const std::map<mobile_apis::AppHMIType::eType, std::string> app_hmi_type_map =
+ {{mobile_apis::AppHMIType::DEFAULT, "DEFAULT"},
+ {mobile_apis::AppHMIType::COMMUNICATION, "COMMUNICATION"},
+ {mobile_apis::AppHMIType::MEDIA, "MEDIA"},
+ {mobile_apis::AppHMIType::MESSAGING, "MESSAGING"},
+ {mobile_apis::AppHMIType::NAVIGATION, "NAVIGATION"},
+ {mobile_apis::AppHMIType::INFORMATION, "INFORMATION"},
+ {mobile_apis::AppHMIType::SOCIAL, "SOCIAL"},
+ {mobile_apis::AppHMIType::BACKGROUND_PROCESS, "BACKGROUND_PROCESS"},
+ {mobile_apis::AppHMIType::TESTING, "TESTING"},
+ {mobile_apis::AppHMIType::SYSTEM, "SYSTEM"}};
+
+ std::map<mobile_apis::AppHMIType::eType, std::string>::const_iterator iter =
+ app_hmi_type_map.find(type);
+
+ return app_hmi_type_map.end() != iter ? iter->second : std::string("");
+}
+
struct AppHMITypeInserter {
- AppHMITypeInserter(smart_objects::SmartObject &so_array)
+ AppHMITypeInserter(smart_objects::SmartObject& so_array)
: index_(0), so_array_(so_array) {}
- bool operator()(const std::string &app_hmi_type) {
+ bool operator()(const std::string& app_hmi_type) {
so_array_[index_] = StringToAppHMIType(app_hmi_type);
++index_;
return true;
}
-private:
+ private:
uint32_t index_;
- smart_objects::SmartObject &so_array_;
+ smart_objects::SmartObject& so_array_;
};
struct CheckMissedTypes {
- CheckMissedTypes(const policy::StringArray &policy_app_types,
- std::string &log)
+ CheckMissedTypes(const policy::StringArray& policy_app_types,
+ std::string& log)
: policy_app_types_(policy_app_types), log_(log) {}
- bool operator()(const smart_objects::SmartArray::value_type &value) {
- std::string app_type_str = value.asString();
- policy::StringArray::const_iterator it = policy_app_types_.begin();
- policy::StringArray::const_iterator it_end = policy_app_types_.end();
- for (; it != it_end; ++it) {
- if (app_type_str == *it) {
- return true;
+ bool operator()(const smart_objects::SmartArray::value_type& value) {
+ std::string app_type_str = AppHMITypeToString(
+ static_cast<mobile_apis::AppHMIType::eType>(value.asInt()));
+ if (!app_type_str.empty()) {
+ policy::StringArray::const_iterator it = policy_app_types_.begin();
+ policy::StringArray::const_iterator it_end = policy_app_types_.end();
+ for (; it != it_end; ++it) {
+ if (app_type_str == *it) {
+ return true;
+ }
}
}
@@ -108,19 +134,19 @@ struct CheckMissedTypes {
return true;
}
-private:
- const policy::StringArray &policy_app_types_;
- std::string &log_;
+ private:
+ const policy::StringArray& policy_app_types_;
+ std::string& log_;
};
struct IsSameNickname {
- IsSameNickname(const std::string &app_id) : app_id_(app_id) {}
- bool operator()(const policy::StringArray::value_type nickname) const {
- return !strcasecmp(app_id_.c_str(), nickname.c_str());
+ IsSameNickname(const custom_str::CustomString& app_id) : app_id_(app_id) {}
+ bool operator()(const policy::StringArray::value_type& nickname) const {
+ return app_id_.CompareIgnoreCase(nickname.c_str());
}
-private:
- const std::string &app_id_;
+ private:
+ const custom_str::CustomString& app_id_;
};
}
@@ -129,9 +155,9 @@ namespace application_manager {
namespace commands {
RegisterAppInterfaceRequest::RegisterAppInterfaceRequest(
- const MessageSharedPtr &message)
- : CommandRequestImpl(message),
- result_checking_app_hmi_type_(mobile_apis::Result::INVALID_ENUM) {}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager)
+ , result_checking_app_hmi_type_(mobile_apis::Result::INVALID_ENUM) {}
RegisterAppInterfaceRequest::~RegisterAppInterfaceRequest() {}
@@ -141,8 +167,9 @@ bool RegisterAppInterfaceRequest::Init() {
}
void RegisterAppInterfaceRequest::Run() {
- LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::Run "
- << connection_key());
+ using namespace helpers;
+ LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_DEBUG(logger_, "Connection key is " << connection_key());
// Fix problem with SDL and HMI HTML. This problem is not actual for HMI PASA.
// Flag conditional compilation specific to customer is used in order to
@@ -151,24 +178,21 @@ void RegisterAppInterfaceRequest::Run() {
// FIXME(EZamakhov): on shutdown - get freez
// wait till HMI started
- while (ApplicationManagerImpl::exists() &&
- !ApplicationManagerImpl::instance()->IsStopping() &&
- !ApplicationManagerImpl::instance()->IsHMICooperating()) {
- LOG4CXX_DEBUG(logger_, "Waiting for the HMI... conn_key="
- << connection_key()
- << ", correlation_id=" << correlation_id()
- << ", default_timeout=" << default_timeout()
- << ", thread=" << pthread_self());
- ApplicationManagerImpl::instance()->updateRequestTimeout(
+ while (!application_manager_.IsStopping() &&
+ !application_manager_.IsHMICooperating()) {
+ LOG4CXX_DEBUG(logger_,
+ "Waiting for the HMI... conn_key="
+ << connection_key()
+ << ", correlation_id=" << correlation_id()
+ << ", default_timeout=" << default_timeout()
+ << ", thread=" << pthread_self());
+ application_manager_.updateRequestTimeout(
connection_key(), correlation_id(), default_timeout());
sleep(1);
// TODO(DK): timer_->StartWait(1);
}
- if (!ApplicationManagerImpl::exists()) {
- LOG4CXX_WARN(logger_, "The ApplicationManager doesn't exist!");
- return;
- } else if (ApplicationManagerImpl::instance()->IsStopping()) {
+ if (application_manager_.IsStopping()) {
LOG4CXX_WARN(logger_, "The ApplicationManager is stopping!");
return;
}
@@ -177,21 +201,35 @@ void RegisterAppInterfaceRequest::Run() {
(*message_)[strings::msg_params][strings::app_id].asString();
ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(connection_key());
+ application_manager_.application(connection_key());
if (application) {
SendResponse(false, mobile_apis::Result::APPLICATION_REGISTERED_ALREADY);
return;
}
+ const smart_objects::SmartObject& msg_params =
+ (*message_)[strings::msg_params];
+
+ const std::string& policy_app_id = msg_params[strings::app_id].asString();
+
+ if (application_manager_.IsApplicationForbidden(connection_key(),
+ policy_app_id)) {
+ SendResponse(false, mobile_apis::Result::TOO_MANY_PENDING_REQUESTS);
+ return;
+ }
+
if (IsApplicationWithSameAppIdRegistered()) {
SendResponse(false, mobile_apis::Result::DISALLOWED);
return;
}
mobile_apis::Result::eType policy_result = CheckWithPolicyData();
- if (mobile_apis::Result::SUCCESS != policy_result &&
- mobile_apis::Result::WARNINGS != policy_result) {
+
+ if (Compare<mobile_apis::Result::eType, NEQ, ALL>(
+ policy_result,
+ mobile_apis::Result::SUCCESS,
+ mobile_apis::Result::WARNINGS)) {
SendResponse(false, policy_result);
return;
}
@@ -199,11 +237,12 @@ void RegisterAppInterfaceRequest::Run() {
mobile_apis::Result::eType coincidence_result = CheckCoincidence();
if (mobile_apis::Result::SUCCESS != coincidence_result) {
- LOG4CXX_ERROR_EXT(logger_, "Coincidence check failed.");
+ LOG4CXX_ERROR(logger_, "Coincidence check failed.");
if (mobile_apis::Result::DUPLICATE_NAME == coincidence_result) {
usage_statistics::AppCounter count_of_rejections_duplicate_name(
- policy::PolicyHandler::instance()->GetStatisticManager(),
- mobile_app_id, usage_statistics::REJECTIONS_DUPLICATE_NAME);
+ GetPolicyHandler().GetStatisticManager(),
+ policy_app_id,
+ usage_statistics::REJECTIONS_DUPLICATE_NAME);
++count_of_rejections_duplicate_name;
}
SendResponse(false, coincidence_result);
@@ -217,129 +256,173 @@ void RegisterAppInterfaceRequest::Run() {
return;
}
- const smart_objects::SmartObject &msg_params =
- (*message_)[strings::msg_params];
-
- ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()->RegisterApplication(message_);
+ application = application_manager_.RegisterApplication(message_);
- if (!app) {
- LOG4CXX_ERROR_EXT(logger_, "Application "
- << msg_params[strings::app_name].asString()
- << " hasn't been registered!");
+ if (!application) {
+ LOG4CXX_ERROR(logger_, "Application hasn't been registered!");
+ return;
+ }
+ // For resuming application need to restore hmi_app_id from resumeCtrl
+ resumption::ResumeCtrl& resumer = application_manager_.resume_controller();
+ const std::string& device_mac = application->mac_address();
+
+ // there is side affect with 2 mobile app with the same mobile app_id
+ if (resumer.IsApplicationSaved(policy_app_id, device_mac)) {
+ application->set_hmi_application_id(
+ resumer.GetHMIApplicationID(policy_app_id, device_mac));
} else {
- app->set_is_media_application(
- msg_params[strings::is_media_application].asBool());
+ application->set_hmi_application_id(
+ application_manager_.GenerateNewHMIAppID());
+ }
- if (msg_params.keyExists(strings::vr_synonyms)) {
- app->set_vr_synonyms(msg_params[strings::vr_synonyms]);
- }
+ application->set_is_media_application(
+ msg_params[strings::is_media_application].asBool());
- if (msg_params.keyExists(strings::ngn_media_screen_app_name)) {
- app->set_ngn_media_screen_name(
- msg_params[strings::ngn_media_screen_app_name]);
- }
+ if (msg_params.keyExists(strings::vr_synonyms)) {
+ application->set_vr_synonyms(msg_params[strings::vr_synonyms]);
+ }
- if (msg_params.keyExists(strings::tts_name)) {
- app->set_tts_name(msg_params[strings::tts_name]);
- }
+ if (msg_params.keyExists(strings::ngn_media_screen_app_name)) {
+ application->set_ngn_media_screen_name(
+ msg_params[strings::ngn_media_screen_app_name]);
+ }
- if (msg_params.keyExists(strings::app_hmi_type)) {
- app->set_app_types(msg_params[strings::app_hmi_type]);
+ if (msg_params.keyExists(strings::tts_name)) {
+ application->set_tts_name(msg_params[strings::tts_name]);
+ }
- // check app type
- const smart_objects::SmartObject &app_type =
- msg_params.getElement(strings::app_hmi_type);
+ if (msg_params.keyExists(strings::app_hmi_type)) {
+ application->set_app_types(msg_params[strings::app_hmi_type]);
- for (size_t i = 0; i < app_type.length(); ++i) {
- if (mobile_apis::AppHMIType::NAVIGATION ==
- static_cast<mobile_apis::AppHMIType::eType>(
- app_type.getElement(i).asUInt())) {
- app->set_is_navi(true);
- }
- if (mobile_apis::AppHMIType::COMMUNICATION ==
- static_cast<mobile_apis::AppHMIType::eType>(
- app_type.getElement(i).asUInt())) {
- app->set_voice_communication_supported(true);
- }
+ // check app type
+ const smart_objects::SmartObject& app_type =
+ msg_params.getElement(strings::app_hmi_type);
+
+ for (size_t i = 0; i < app_type.length(); ++i) {
+ if (mobile_apis::AppHMIType::NAVIGATION ==
+ static_cast<mobile_apis::AppHMIType::eType>(
+ app_type.getElement(i).asUInt())) {
+ application->set_is_navi(true);
+ }
+ if (mobile_apis::AppHMIType::COMMUNICATION ==
+ static_cast<mobile_apis::AppHMIType::eType>(
+ app_type.getElement(i).asUInt())) {
+ application->set_voice_communication_supported(true);
}
}
+ }
- const connection_handler::DeviceHandle handle = app->device();
- // Add device to policy table and set device info, if any
- std::string device_mac_address =
- application_manager::MessageHelper::GetDeviceMacAddressForHandle(
- handle);
- policy::DeviceParams dev_params;
- application_manager::MessageHelper::GetDeviceInfoForHandle(handle,
- &dev_params);
- policy::DeviceInfo device_info;
- device_info.AdoptDeviceType(dev_params.device_connection_type);
- if (msg_params.keyExists(strings::device_info)) {
- FillDeviceInfo(&device_info);
- }
+ // Add device to policy table and set device info, if any
+ policy::DeviceParams dev_params;
+ if (-1 ==
+ application_manager_.connection_handler()
+ .get_session_observer()
+ .GetDataOnDeviceID(application->device(),
+ &dev_params.device_name,
+ NULL,
+ &dev_params.device_mac_address,
+ &dev_params.device_connection_type)) {
+ LOG4CXX_ERROR(logger_,
+ "Failed to extract information for device "
+ << application->device());
+ }
+ policy::DeviceInfo device_info;
+ device_info.AdoptDeviceType(dev_params.device_connection_type);
+ if (msg_params.keyExists(strings::device_info)) {
+ FillDeviceInfo(&device_info);
+ }
- policy::PolicyHandler::instance()->SetDeviceInfo(device_mac_address,
- device_info);
+ GetPolicyHandler().SetDeviceInfo(device_mac, device_info);
- SendRegisterAppInterfaceResponseToMobile();
+ SendRegisterAppInterfaceResponseToMobile();
+ smart_objects::SmartObjectSPtr so =
+ GetLockScreenIconUrlNotification(connection_key(), application);
+ application_manager_.ManageMobileCommand(so, commands::Command::ORIGIN_SDL);
+}
- MessageHelper::SendLockScreenIconUrlNotification(
- (*message_)[strings::params][strings::connection_key].asInt());
- }
+smart_objects::SmartObjectSPtr
+RegisterAppInterfaceRequest::GetLockScreenIconUrlNotification(
+ const uint32_t connection_key, ApplicationSharedPtr app) {
+ DCHECK_OR_RETURN(app.get(), smart_objects::SmartObjectSPtr());
+ smart_objects::SmartObjectSPtr message =
+ utils::MakeShared<smart_objects::SmartObject>(
+ smart_objects::SmartType_Map);
+ (*message)[strings::params][strings::function_id] =
+ mobile_apis::FunctionID::OnSystemRequestID;
+ (*message)[strings::params][strings::connection_key] = connection_key;
+ (*message)[strings::params][strings::message_type] =
+ mobile_apis::messageType::notification;
+ (*message)[strings::params][strings::protocol_type] =
+ commands::CommandImpl::mobile_protocol_type_;
+ (*message)[strings::params][strings::protocol_version] =
+ commands::CommandImpl::protocol_version_;
+ (*message)[strings::msg_params][strings::request_type] =
+ mobile_apis::RequestType::LOCK_SCREEN_ICON_URL;
+ (*message)[strings::msg_params][strings::url] =
+ GetPolicyHandler().GetLockScreenIconUrl();
+ return message;
}
-void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
- mobile_apis::Result::eType result) {
+void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
+ LOG4CXX_AUTO_TRACE(logger_);
smart_objects::SmartObject response_params(smart_objects::SmartType_Map);
- ApplicationManagerImpl *app_manager = ApplicationManagerImpl::instance();
- const HMICapabilities &hmi_capabilities = app_manager->hmi_capabilities();
+ mobile_apis::Result::eType result_code = mobile_apis::Result::SUCCESS;
+
+ const HMICapabilities& hmi_capabilities =
+ application_manager_.hmi_capabilities();
+
const uint32_t key = connection_key();
- ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(key);
+ ApplicationSharedPtr application = application_manager_.application(key);
+
+ resumption::ResumeCtrl& resumer = application_manager_.resume_controller();
if (!application) {
- LOG4CXX_ERROR(logger_, "There is no application for such connection key"
- << key);
+ LOG4CXX_ERROR(logger_,
+ "There is no application for such connection key" << key);
+ LOG4CXX_DEBUG(logger_, "Need to start resume data persistent timer");
+ resumer.OnAppRegistrationEnd();
return;
}
response_params[strings::sync_msg_version][strings::major_version] =
- APIVersion::kAPIV3;
+ major_version; // From generated file interfaces/generated_msg_version.h
response_params[strings::sync_msg_version][strings::minor_version] =
- APIVersion::kAPIV0;
+ minor_version; // From generated file interfaces/generated_msg_version.h
response_params[strings::language] = hmi_capabilities.active_vr_language();
response_params[strings::hmi_display_language] =
hmi_capabilities.active_ui_language();
- const smart_objects::SmartObject &msg_params =
+ const smart_objects::SmartObject& msg_params =
(*message_)[strings::msg_params];
if (msg_params[strings::language_desired].asInt() !=
hmi_capabilities.active_vr_language() ||
msg_params[strings::hmi_display_language_desired].asInt() !=
hmi_capabilities.active_ui_language()) {
+ LOG4CXX_WARN(logger_,
+ "Wrong language on registering application "
+ << application->name().c_str());
- LOG4CXX_WARN_EXT(logger_, "Wrong language on registering application "
- << application->name());
-
- LOG4CXX_ERROR_EXT(
+ LOG4CXX_ERROR(
logger_,
- "vr " << msg_params[strings::language_desired].asInt() << " - "
- << hmi_capabilities.active_vr_language() << "ui "
- << msg_params[strings::hmi_display_language_desired].asInt()
- << " - " << hmi_capabilities.active_ui_language());
-
- result = mobile_apis::Result::WRONG_LANGUAGE;
+ "VR language desired code is "
+ << msg_params[strings::language_desired].asInt()
+ << " , active VR language code is "
+ << hmi_capabilities.active_vr_language() << ", UI language code is "
+ << msg_params[strings::hmi_display_language_desired].asInt()
+ << " , active UI language code is "
+ << hmi_capabilities.active_ui_language());
+
+ result_code = mobile_apis::Result::WRONG_LANGUAGE;
}
if (hmi_capabilities.display_capabilities()) {
response_params[hmi_response::display_capabilities] =
smart_objects::SmartObject(smart_objects::SmartType_Map);
- smart_objects::SmartObject &display_caps =
+ smart_objects::SmartObject& display_caps =
response_params[hmi_response::display_capabilities];
display_caps[hmi_response::display_type] =
@@ -433,6 +516,10 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
*hmi_capabilities.audio_pass_thru_capabilities();
}
}
+ if (hmi_capabilities.pcm_stream_capabilities()) {
+ response_params[strings::pcm_stream_capabilities] =
+ *hmi_capabilities.pcm_stream_capabilities();
+ }
if (hmi_capabilities.vehicle_type()) {
response_params[hmi_response::vehicle_type] =
*hmi_capabilities.vehicle_type();
@@ -442,8 +529,8 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
*(hmi_capabilities.prerecorded_speech());
}
- const std::vector<uint32_t> &diag_modes =
- profile::Profile::instance()->supported_diag_modes();
+ const std::vector<uint32_t>& diag_modes =
+ application_manager_.get_settings().supported_diag_modes();
if (!diag_modes.empty()) {
std::vector<uint32_t>::const_iterator it = diag_modes.begin();
uint32_t index = 0;
@@ -460,82 +547,204 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
response_params[strings::hmi_capabilities][strings::phone_call] =
hmi_capabilities.phone_call_supported();
response_params[strings::sdl_version] =
- profile::Profile::instance()->sdl_version();
- response_params[strings::system_software_version] =
- hmi_capabilities.ccpu_version();
-
- ResumeCtrl &resumer = ApplicationManagerImpl::instance()->resume_controller();
- std::string hash_id = "";
+ application_manager_.get_settings().sdl_version();
+ const std::string ccpu_version =
+ application_manager_.hmi_capabilities().ccpu_version();
+ if (!ccpu_version.empty()) {
+ response_params[strings::system_software_version] = ccpu_version;
+ }
- std::string add_info("");
bool resumption =
(*message_)[strings::msg_params].keyExists(strings::hash_id);
+
bool need_restore_vr = resumption;
+
+ std::string hash_id;
+ std::string add_info;
if (resumption) {
hash_id = (*message_)[strings::msg_params][strings::hash_id].asString();
if (!resumer.CheckApplicationHash(application, hash_id)) {
- LOG4CXX_WARN(logger_, "Hash does not match");
- result = mobile_apis::Result::RESUME_FAILED;
- add_info = "Hash does not match";
+ LOG4CXX_WARN(logger_,
+ "Hash from RAI does not match to saved resume data.");
+ result_code = mobile_apis::Result::RESUME_FAILED;
+ add_info = "Hash from RAI does not match to saved resume data.";
need_restore_vr = false;
} else if (!resumer.CheckPersistenceFilesForResumption(application)) {
- LOG4CXX_WARN(logger_, "Persistent data is missed");
- result = mobile_apis::Result::RESUME_FAILED;
- add_info = "Persistent data is missed";
+ LOG4CXX_WARN(logger_, "Persistent data is missing.");
+ result_code = mobile_apis::Result::RESUME_FAILED;
+ add_info = "Persistent data is missing.";
need_restore_vr = false;
} else {
- add_info = " Resume Succeed";
+ add_info = "Resume succeeded.";
}
}
- if ((mobile_apis::Result::SUCCESS == result) &&
+ if ((mobile_apis::Result::SUCCESS == result_code) &&
(mobile_apis::Result::INVALID_ENUM != result_checking_app_hmi_type_)) {
add_info += response_info_;
- result = result_checking_app_hmi_type_;
+ result_code = result_checking_app_hmi_type_;
}
// in case application exist in resumption we need to send resumeVrgrammars
if (false == resumption) {
- resumption = resumer.IsApplicationSaved(application->mobile_app_id());
+ resumption = resumer.IsApplicationSaved(application->policy_app_id(),
+ application->mac_address());
}
- MessageHelper::SendOnAppRegisteredNotificationToHMI(
+ SendOnAppRegisteredNotificationToHMI(
*(application.get()), resumption, need_restore_vr);
+ SendResponse(true, result_code, add_info.c_str(), &response_params);
- SendResponse(true, result, add_info.c_str(), &response_params);
+ // Check if application exists, because application might be unregestered
+ // during sending reponse to mobile.
+ application = application_manager_.application(key);
+ if (application) {
+ LOG4CXX_DEBUG(logger_, "Application with app_id = " << key << " exists.");
+ if (result_code != mobile_apis::Result::RESUME_FAILED) {
+ resumer.StartResumption(application, hash_id);
+ } else {
+ resumer.StartResumptionOnlyHMILevel(application);
+ }
- if (result != mobile_apis::Result::RESUME_FAILED) {
- resumer.StartResumption(application, hash_id);
+ // By default app subscribed to CUSTOM_BUTTON
+ SendSubscribeCustomButtonNotification();
+ MessageHelper::SendChangeRegistrationRequestToHMI(application,
+ application_manager_);
} else {
- resumer.StartResumptionOnlyHMILevel(application);
+ LOG4CXX_DEBUG(logger_,
+ "Application with app_id = " << key << " doesn't exist.");
+ }
+}
+
+void RegisterAppInterfaceRequest::SendOnAppRegisteredNotificationToHMI(
+ const Application& application_impl,
+ bool resumption,
+ bool need_restore_vr) {
+ using namespace smart_objects;
+ SmartObjectSPtr notification = utils::MakeShared<SmartObject>(SmartType_Map);
+ if (!notification) {
+ LOG4CXX_ERROR(logger_, "Failed to create smart object");
+ return;
+ }
+
+ (*notification)[strings::params] = SmartObject(SmartType_Map);
+ smart_objects::SmartObject& params = (*notification)[strings::params];
+ params[strings::function_id] = static_cast<int32_t>(
+ hmi_apis::FunctionID::BasicCommunication_OnAppRegistered);
+ params[strings::message_type] = static_cast<int32_t>(kNotification);
+ params[strings::protocol_version] = commands::CommandImpl::protocol_version_;
+ params[strings::protocol_type] = commands::CommandImpl::hmi_protocol_type_;
+
+ (*notification)[strings::msg_params] = SmartObject(SmartType_Map);
+ smart_objects::SmartObject& msg_params = (*notification)[strings::msg_params];
+ // Due to current requirements in case when we're in resumption mode
+ // we have to always send resumeVRGrammar field.
+ if (resumption) {
+ msg_params[strings::resume_vr_grammars] = need_restore_vr;
+ }
+
+ if (application_impl.vr_synonyms()) {
+ msg_params[strings::vr_synonyms] = *(application_impl.vr_synonyms());
+ }
+
+ if (application_impl.tts_name()) {
+ msg_params[strings::tts_name] = *(application_impl.tts_name());
+ }
+
+ std::string priority;
+ GetPolicyHandler().GetPriority(application_impl.policy_app_id(), &priority);
+
+ if (!priority.empty()) {
+ msg_params[strings::priority] = MessageHelper::GetPriorityCode(priority);
+ }
+
+ msg_params[strings::msg_params] = SmartObject(SmartType_Map);
+ smart_objects::SmartObject& application = msg_params[strings::application];
+ application[strings::app_name] = application_impl.name();
+ application[strings::app_id] = application_impl.app_id();
+ application[hmi_response::policy_app_id] = application_impl.policy_app_id();
+ application[strings::icon] = application_impl.app_icon_path();
+
+ const smart_objects::SmartObject* ngn_media_screen_name =
+ application_impl.ngn_media_screen_name();
+ if (ngn_media_screen_name) {
+ application[strings::ngn_media_screen_app_name] = *ngn_media_screen_name;
+ }
+
+ application[strings::hmi_display_language_desired] =
+ static_cast<int32_t>(application_impl.ui_language());
+
+ application[strings::is_media_application] =
+ application_impl.is_media_application();
+
+ const smart_objects::SmartObject* app_type = application_impl.app_types();
+ if (app_type) {
+ application[strings::app_type] = *app_type;
+ }
+
+ std::vector<std::string> request_types =
+ GetPolicyHandler().GetAppRequestTypes(application_impl.policy_app_id());
+
+ application[strings::request_type] = SmartObject(SmartType_Array);
+ smart_objects::SmartObject& request_array =
+ application[strings::request_type];
+
+ uint32_t index = 0;
+ std::vector<std::string>::const_iterator it = request_types.begin();
+ for (; request_types.end() != it; ++it) {
+ request_array[index] = *it;
+ ++index;
+ }
+
+ application[strings::device_info] = SmartObject(SmartType_Map);
+ smart_objects::SmartObject& device_info = application[strings::device_info];
+ const protocol_handler::SessionObserver& session_observer =
+ application_manager_.connection_handler().get_session_observer();
+ std::string device_name;
+ std::string mac_address;
+ std::string transport_type;
+ const connection_handler::DeviceHandle handle = application_impl.device();
+ if (-1 ==
+ session_observer.GetDataOnDeviceID(
+ handle, &device_name, NULL, &mac_address, &transport_type)) {
+ LOG4CXX_ERROR(logger_,
+ "Failed to extract information for device " << handle);
}
- // By default app subscribed to CUSTOM_BUTTON
- // Need to send notification to HMI
- SendSubscribeCustomButtonNotification();
- MessageHelper::SendChangeRegistrationRequestToHMI(application);
+ device_info[strings::name] = device_name;
+ device_info[strings::id] = mac_address;
+
+ const policy::DeviceConsent device_consent =
+ GetPolicyHandler().GetUserConsentForDevice(mac_address);
+ device_info[strings::isSDLAllowed] =
+ policy::DeviceConsent::kDeviceAllowed == device_consent;
+
+ device_info[strings::transport_type] =
+ application_manager_.GetDeviceTransportType(transport_type);
+
+ DCHECK(application_manager_.ManageHMICommand(notification));
}
mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence() {
LOG4CXX_AUTO_TRACE(logger_);
- const smart_objects::SmartObject &msg_params =
+ const smart_objects::SmartObject& msg_params =
(*message_)[strings::msg_params];
- ApplicationManagerImpl::ApplicationListAccessor accessor;
+ ApplicationSet accessor = application_manager_.applications().GetData();
- ApplicationManagerImpl::ApplictionSetConstIt it = accessor.begin();
- const std::string app_name = msg_params[strings::app_name].asString();
+ ApplicationSetConstIt it = accessor.begin();
+ const custom_str::CustomString& app_name =
+ msg_params[strings::app_name].asCustomString();
for (; accessor.end() != it; ++it) {
-
// name check
- const std::string &cur_name = (*it)->name();
- if (!strcasecmp(app_name.c_str(), cur_name.c_str())) {
+ const custom_str::CustomString& cur_name = (*it)->name();
+ if (app_name.CompareIgnoreCase(cur_name)) {
LOG4CXX_ERROR(logger_, "Application name is known already.");
return mobile_apis::Result::DUPLICATE_NAME;
}
- const smart_objects::SmartObject *vr = (*it)->vr_synonyms();
- const std::vector<smart_objects::SmartObject> *curr_vr = NULL;
+ const smart_objects::SmartObject* vr = (*it)->vr_synonyms();
+ const std::vector<smart_objects::SmartObject>* curr_vr = NULL;
if (NULL != vr) {
curr_vr = vr->asArray();
CoincidencePredicateVR v(app_name);
@@ -548,7 +757,7 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence() {
// vr check
if (msg_params.keyExists(strings::vr_synonyms)) {
- const std::vector<smart_objects::SmartObject> *new_vr =
+ const std::vector<smart_objects::SmartObject>* new_vr =
msg_params[strings::vr_synonyms].asArray();
CoincidencePredicateVR v(cur_name);
@@ -556,29 +765,29 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence() {
LOG4CXX_ERROR(logger_, "vr_synonyms duplicated with app_name .");
return mobile_apis::Result::DUPLICATE_NAME;
}
- } // end vr check
+ } // end vr check
- } // application for end
+ } // application for end
return mobile_apis::Result::SUCCESS;
-} // method end
+} // method end
mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() {
- LOG4CXX_INFO(logger_, "CheckWithPolicyData");
+ LOG4CXX_AUTO_TRACE(logger_);
// TODO(AOleynik): Check is necessary to allow register application in case
// of disabled policy
// Remove this check, when HMI will support policy
- if (!policy::PolicyHandler::instance()->PolicyEnabled()) {
+ if (!GetPolicyHandler().PolicyEnabled()) {
return mobile_apis::Result::WARNINGS;
}
- smart_objects::SmartObject &message = *message_;
+ smart_objects::SmartObject& message = *message_;
policy::StringArray app_nicknames;
policy::StringArray app_hmi_types;
- std::string mobile_app_id =
+ const std::string mobile_app_id =
message[strings::msg_params][strings::app_id].asString();
- const bool init_result = policy::PolicyHandler::instance()->GetInitialAppData(
+ const bool init_result = GetPolicyHandler().GetInitialAppData(
mobile_app_id, &app_nicknames, &app_hmi_types);
if (!init_result) {
@@ -588,7 +797,7 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() {
if (!app_nicknames.empty()) {
IsSameNickname compare(
- message[strings::msg_params][strings::app_name].asString());
+ message[strings::msg_params][strings::app_name].asCustomString());
policy::StringArray::const_iterator it =
std::find_if(app_nicknames.begin(), app_nicknames.end(), compare);
if (app_nicknames.end() == it) {
@@ -597,8 +806,9 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() {
// App should be unregistered, if its name is not present in nicknames
// list
usage_statistics::AppCounter count_of_rejections_nickname_mismatch(
- policy::PolicyHandler::instance()->GetStatisticManager(),
- mobile_app_id, usage_statistics::REJECTIONS_NICKNAME_MISMATCH);
+ GetPolicyHandler().GetStatisticManager(),
+ mobile_app_id,
+ usage_statistics::REJECTIONS_NICKNAME_MISMATCH);
++count_of_rejections_nickname_mismatch;
return mobile_apis::Result::DISALLOWED;
}
@@ -618,9 +828,10 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() {
CheckMissedTypes checker(app_hmi_types, log);
std::for_each(app_types.begin(), app_types.end(), checker);
if (!log.empty()) {
- response_info_ = "Following AppHMITypes are not present in policy "
- "table:" +
- log;
+ response_info_ =
+ "Following AppHMITypes are not present in policy "
+ "table:" +
+ log;
result_checking_app_hmi_type_ = mobile_apis::Result::WARNINGS;
}
}
@@ -628,7 +839,7 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() {
message[strings::msg_params][strings::app_hmi_type] =
smart_objects::SmartObject(smart_objects::SmartType_Array);
- smart_objects::SmartObject &app_hmi_type =
+ smart_objects::SmartObject& app_hmi_type =
message[strings::msg_params][strings::app_hmi_type];
AppHMITypeInserter inserter(app_hmi_type);
@@ -639,7 +850,7 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() {
}
void RegisterAppInterfaceRequest::FillDeviceInfo(
- policy::DeviceInfo *device_info) {
+ policy::DeviceInfo* device_info) {
const std::string hardware = "hardware";
const std::string firmware_rev = "firmwareRev";
const std::string os = "os";
@@ -647,10 +858,10 @@ void RegisterAppInterfaceRequest::FillDeviceInfo(
const std::string carrier = "carrier";
const std::string max_number_rfcom_ports = "maxNumberRFCOMMPorts";
- const smart_objects::SmartObject &msg_params =
+ const smart_objects::SmartObject& msg_params =
(*message_)[strings::msg_params];
- const smart_objects::SmartObject &device_info_so =
+ const smart_objects::SmartObject& device_info_so =
msg_params[strings::device_info];
if (device_info_so.keyExists(hardware)) {
@@ -677,22 +888,19 @@ void RegisterAppInterfaceRequest::FillDeviceInfo(
}
bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() {
+ LOG4CXX_AUTO_TRACE(logger_);
- LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::"
- "IsApplicationWithSameAppIdRegistered");
+ const custom_string::CustomString mobile_app_id =
+ (*message_)[strings::msg_params][strings::app_id].asCustomString();
- const std::string mobile_app_id =
- (*message_)[strings::msg_params][strings::app_id].asString();
+ const ApplicationSet& applications =
+ application_manager_.applications().GetData();
- ApplicationManagerImpl::ApplicationListAccessor accessor;
- const ApplicationManagerImpl::ApplictionSet applications =
- accessor.applications();
-
- ApplicationManagerImpl::ApplictionSetConstIt it = applications.begin();
- ApplicationManagerImpl::ApplictionSetConstIt it_end = applications.end();
+ ApplicationSetConstIt it = applications.begin();
+ ApplicationSetConstIt it_end = applications.end();
for (; it != it_end; ++it) {
- if (!strcasecmp(mobile_app_id.c_str(), (*it)->mobile_app_id().c_str())) {
+ if (mobile_app_id.CompareIgnoreCase((*it)->policy_app_id().c_str())) {
return true;
}
}
@@ -702,7 +910,7 @@ bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() {
bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() {
LOG4CXX_AUTO_TRACE(logger_);
- const char *str = NULL;
+ const char* str = NULL;
str = (*message_)[strings::msg_params][strings::app_name].asCharArray();
if (!CheckSyntax(str)) {
@@ -711,7 +919,7 @@ bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() {
}
if ((*message_)[strings::msg_params].keyExists(strings::tts_name)) {
- const smart_objects::SmartArray *tn_array =
+ const smart_objects::SmartArray* tn_array =
(*message_)[strings::msg_params][strings::tts_name].asArray();
smart_objects::SmartArray::const_iterator it_tn = tn_array->begin();
@@ -738,7 +946,7 @@ bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() {
}
if ((*message_)[strings::msg_params].keyExists(strings::vr_synonyms)) {
- const smart_objects::SmartArray *vs_array =
+ const smart_objects::SmartArray* vs_array =
(*message_)[strings::msg_params][strings::vr_synonyms].asArray();
smart_objects::SmartArray::const_iterator it_vs = vs_array->begin();
@@ -762,7 +970,6 @@ bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() {
}
if ((*message_)[strings::msg_params].keyExists(strings::device_info)) {
-
if ((*message_)[strings::msg_params][strings::device_info].keyExists(
strings::hardware)) {
str = (*message_)[strings::msg_params][strings::device_info]
@@ -825,12 +1032,14 @@ bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() {
return true;
}
}
+
return false;
}
void RegisterAppInterfaceRequest::CheckResponseVehicleTypeParam(
- smart_objects::SmartObject &vehicle_type, const std::string &param,
- const std::string &backup_value) {
+ smart_objects::SmartObject& vehicle_type,
+ const std::string& param,
+ const std::string& backup_value) {
using namespace hmi_response;
if (!vehicle_type.keyExists(param) || vehicle_type[param].empty()) {
if (!backup_value.empty()) {
@@ -855,6 +1064,11 @@ void RegisterAppInterfaceRequest::SendSubscribeCustomButtonNotification() {
CreateHMINotification(FunctionID::Buttons_OnButtonSubscription, msg_params);
}
-} // namespace commands
+policy::PolicyHandlerInterface&
+RegisterAppInterfaceRequest::GetPolicyHandler() {
+ return application_manager_.GetPolicyHandler();
+}
+
+} // namespace commands
-} // namespace application_manager
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc
index b910881273..1d7f829a68 100644
--- a/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc
+++ b/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc
@@ -33,9 +33,10 @@
#include "application_manager/commands/mobile/register_app_interface_response.h"
#include "interfaces/MOBILE_API.h"
-#include "application_manager/policies/policy_handler.h"
-#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_manager.h"
+#include "application_manager/policies/policy_handler_interface.h"
#include "connection_handler/connection_handler.h"
+#include "application_manager/policies/policy_handler_interface.h"
namespace application_manager {
@@ -44,7 +45,7 @@ namespace commands {
void RegisterAppInterfaceResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
+ mobile_apis::Result::eType result_code = mobile_apis::Result::SUCCESS;
bool success = (*message_)[strings::msg_params][strings::success].asBool();
bool last_message = !success;
// Do not close connection in case of APPLICATION_NOT_REGISTERED despite it is
@@ -60,46 +61,48 @@ void RegisterAppInterfaceResponse::Run() {
SendResponse(success, result_code, last_message);
+ if (mobile_apis::Result::SUCCESS != result_code) {
+ return;
+ }
+
// Add registered application to the policy db right after response sent to
// mobile to be able to check all other API according to app permissions
application_manager::ApplicationSharedPtr application =
- application_manager::ApplicationManagerImpl::instance()->application(
- connection_key());
-
+ application_manager_.application(connection_key());
if (!application) {
- LOG4CXX_ERROR(logger_, "Application with connection key "
- << connection_key() << " is not registered.");
+ LOG4CXX_ERROR(logger_,
+ "Application with connection key " << connection_key()
+ << " is not registered.");
return;
}
- SetHeartBeatTimeout(connection_key(), application->mobile_app_id());
+ SetHeartBeatTimeout(connection_key(), application->policy_app_id());
// Default HMI level should be set before any permissions validation, since it
// relies on HMI level.
- ApplicationManagerImpl::instance()->OnApplicationRegistered(application);
+ application_manager_.OnApplicationRegistered(application);
// Sends OnPermissionChange notification to mobile right after RAI response
// and HMI level set-up
- policy::PolicyHandler::instance()->OnAppRegisteredOnMobile(
- application->mobile_app_id());
+ application_manager_.GetPolicyHandler().OnAppRegisteredOnMobile(
+ application->policy_app_id());
}
void RegisterAppInterfaceResponse::SetHeartBeatTimeout(
- uint32_t connection_key, const std::string &mobile_app_id) {
+ uint32_t connection_key, const std::string& mobile_app_id) {
LOG4CXX_AUTO_TRACE(logger_);
- policy::PolicyHandler *policy_handler = policy::PolicyHandler::instance();
- if (policy_handler->PolicyEnabled()) {
- const int32_t timeout = policy_handler->HeartBeatTimeout(mobile_app_id) /
- date_time::DateTime::MILLISECONDS_IN_SECOND;
+ policy::PolicyHandlerInterface& policy_handler =
+ application_manager_.GetPolicyHandler();
+ if (policy_handler.PolicyEnabled()) {
+ const uint32_t timeout = policy_handler.HeartBeatTimeout(mobile_app_id);
if (timeout > 0) {
- application_manager::ApplicationManagerImpl::instance()
- ->connection_handler()
- ->SetHeartBeatTimeout(connection_key, timeout);
+ application_manager_.connection_handler().SetHeartBeatTimeout(
+ connection_key, timeout);
}
} else {
LOG4CXX_INFO(logger_, "Policy is turn off");
}
}
-} // namespace commands
-} // namespace application_manager
+} // namespace commands
+} // namespace application_manager
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 2089d429ac..0260fef676 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
@@ -32,10 +32,10 @@
*/
#include "application_manager/commands/mobile/reset_global_properties_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
-#include "config_profile/profile.h"
+
#include "interfaces/MOBILE_API.h"
#include "interfaces/HMI_API.h"
@@ -44,38 +44,36 @@ namespace application_manager {
namespace commands {
ResetGlobalPropertiesRequest::ResetGlobalPropertiesRequest(
- const MessageSharedPtr& message)
- : CommandRequestImpl(message),
- 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) {
-}
+ 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) {}
-ResetGlobalPropertiesRequest::~ResetGlobalPropertiesRequest() {
-}
+ResetGlobalPropertiesRequest::~ResetGlobalPropertiesRequest() {}
void ResetGlobalPropertiesRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- uint32_t app_id = (*message_)[strings::params][strings::connection_key].asUInt();
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
+ uint32_t app_id =
+ (*message_)[strings::params][strings::connection_key].asUInt();
+ ApplicationSharedPtr app = application_manager_.application(app_id);
if (!app) {
- LOG4CXX_ERROR_EXT(logger_, "No application associated with session key");
+ LOG4CXX_ERROR(logger_, "No application associated with session key");
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
return;
}
- size_t obj_length = (*message_)[strings::msg_params][strings::properties]
- .length();
- //if application waits for sending ttsGlobalProperties need to remove this
- //application from tts_global_properties_app_list_
+ size_t obj_length =
+ (*message_)[strings::msg_params][strings::properties].length();
+ // if application waits for sending ttsGlobalProperties need to remove this
+ // application from tts_global_properties_app_list_
LOG4CXX_INFO(logger_, "RemoveAppFromTTSGlobalPropertiesList");
- ApplicationManagerImpl::instance()->RemoveAppFromTTSGlobalPropertiesList(
- app_id);
+ application_manager_.RemoveAppFromTTSGlobalPropertiesList(app_id);
bool helpt_promt = false;
bool timeout_prompt = false;
@@ -96,20 +94,23 @@ void ResetGlobalPropertiesRequest::Run() {
} else if (mobile_apis::GlobalProperty::TIMEOUTPROMPT == global_property) {
timeout_prompt = ResetTimeoutPromt(app);
} else if (((mobile_apis::GlobalProperty::VRHELPTITLE == global_property) ||
- (mobile_apis::GlobalProperty::VRHELPITEMS == global_property)) &&
- (0 == number_of_reset_vr)) {
+ (mobile_apis::GlobalProperty::VRHELPITEMS ==
+ global_property)) &&
+ (0 == number_of_reset_vr)) {
++number_of_reset_vr;
vr_help_title_items = ResetVrHelpTitleItems(app);
} else if (mobile_apis::GlobalProperty::MENUNAME == global_property) {
menu_name = true;
} else if (mobile_apis::GlobalProperty::MENUICON == global_property) {
menu_icon = true;
- } else if (mobile_apis::GlobalProperty::KEYBOARDPROPERTIES == global_property) {
+ } else if (mobile_apis::GlobalProperty::KEYBOARDPROPERTIES ==
+ global_property) {
is_key_board_properties = true;
}
}
- if (vr_help_title_items || menu_name || menu_icon || is_key_board_properties) {
+ if (vr_help_title_items || menu_name || menu_icon ||
+ is_key_board_properties) {
is_ui_send_ = true;
}
@@ -119,13 +120,14 @@ void ResetGlobalPropertiesRequest::Run() {
app->set_reset_global_properties_active(true);
- if (vr_help_title_items || menu_name || menu_icon || is_key_board_properties) {
-
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ if (vr_help_title_items || menu_name || menu_icon ||
+ is_key_board_properties) {
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
if (vr_help_title_items) {
- smart_objects::SmartObjectSPtr vr_help = MessageHelper::CreateAppVrHelp(app);
+ smart_objects::SmartObjectSPtr vr_help =
+ MessageHelper::CreateAppVrHelp(app);
if (!vr_help) {
return;
}
@@ -135,19 +137,20 @@ void ResetGlobalPropertiesRequest::Run() {
msg_params[hmi_request::menu_title] = "";
app->set_menu_title(msg_params[hmi_request::menu_title]);
}
- //TODO(DT): clarify the sending parameter menuIcon
- //if (menu_icon) {
+ // TODO(DT): clarify the sending parameter menuIcon
+ // if (menu_icon) {
//}
if (is_key_board_properties) {
- smart_objects::SmartObject key_board_properties = smart_objects::
- SmartObject(smart_objects::SmartType_Map);
- key_board_properties[strings::language] = static_cast<int32_t>
- (hmi_apis::Common_Language::EN_US);
- key_board_properties[hmi_request::keyboard_layout] = static_cast<int32_t>
- (hmi_apis::Common_KeyboardLayout::QWERTY);
+ smart_objects::SmartObject key_board_properties =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ key_board_properties[strings::language] =
+ static_cast<int32_t>(hmi_apis::Common_Language::EN_US);
+ key_board_properties[hmi_request::keyboard_layout] =
+ static_cast<int32_t>(hmi_apis::Common_KeyboardLayout::QWERTY);
// Look for APPLINK-4432 for details.
- /*smart_objects::SmartObject limited_character_list = smart_objects::SmartObject(
+ /*smart_objects::SmartObject limited_character_list =
+ smart_objects::SmartObject(
smart_objects::SmartType_Array);
limited_character_list[0] = "";
key_board_properties[hmi_request::limited_character_list] =
@@ -158,14 +161,14 @@ void ResetGlobalPropertiesRequest::Run() {
}
msg_params[strings::app_id] = app->app_id();
- SendHMIRequest(hmi_apis::FunctionID::UI_SetGlobalProperties,
- &msg_params, true);
+ SendHMIRequest(
+ hmi_apis::FunctionID::UI_SetGlobalProperties, &msg_params, true);
}
if (timeout_prompt || helpt_promt) {
// create ui request
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
if (helpt_promt) {
msg_params[strings::help_prompt] = (*app->help_prompt());
@@ -177,20 +180,20 @@ void ResetGlobalPropertiesRequest::Run() {
msg_params[strings::app_id] = app->app_id();
- SendHMIRequest(hmi_apis::FunctionID::TTS_SetGlobalProperties,
- &msg_params, true);
+ SendHMIRequest(
+ hmi_apis::FunctionID::TTS_SetGlobalProperties, &msg_params, true);
}
}
bool ResetGlobalPropertiesRequest::ResetHelpPromt(
application_manager::ApplicationSharedPtr app) {
if (!app) {
- LOG4CXX_ERROR_EXT(logger_, "Null pointer");
+ LOG4CXX_ERROR(logger_, "Null pointer");
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
return false;
}
- smart_objects::SmartObject so_help_prompt = smart_objects::SmartObject(
- smart_objects::SmartType_Array);
+ smart_objects::SmartObject so_help_prompt =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
app->set_help_prompt(so_help_prompt);
return true;
}
@@ -198,20 +201,20 @@ bool ResetGlobalPropertiesRequest::ResetHelpPromt(
bool ResetGlobalPropertiesRequest::ResetTimeoutPromt(
application_manager::ApplicationSharedPtr const app) {
if (!app) {
- LOG4CXX_ERROR_EXT(logger_, "Null pointer");
+ LOG4CXX_ERROR(logger_, "Null pointer");
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
return false;
}
- const std::vector<std::string>& time_out_promt = profile::Profile::instance()
- ->time_out_promt();
+ const std::vector<std::string>& time_out_promt =
+ application_manager_.get_settings().time_out_promt();
- smart_objects::SmartObject so_time_out_promt = smart_objects::SmartObject(
- smart_objects::SmartType_Array);
+ smart_objects::SmartObject so_time_out_promt =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
for (uint32_t i = 0; i < time_out_promt.size(); ++i) {
- smart_objects::SmartObject timeoutPrompt = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject timeoutPrompt =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
timeoutPrompt[strings::text] = time_out_promt[i];
timeoutPrompt[strings::type] = hmi_apis::Common_SpeechCapabilities::SC_TEXT;
so_time_out_promt[i] = timeoutPrompt;
@@ -225,7 +228,7 @@ bool ResetGlobalPropertiesRequest::ResetTimeoutPromt(
bool ResetGlobalPropertiesRequest::ResetVrHelpTitleItems(
application_manager::ApplicationSharedPtr const app) {
if (!app) {
- LOG4CXX_ERROR_EXT(logger_, "Null pointer");
+ LOG4CXX_ERROR(logger_, "Null pointer");
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
return false;
}
@@ -240,37 +243,38 @@ void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
const smart_objects::SmartObject& message = event.smart_object();
ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(connection_key());
+ application_manager_.application(connection_key());
switch (event.id()) {
- case hmi_apis::FunctionID::UI_SetGlobalProperties: {
- LOG4CXX_INFO(logger_, "Received UI_SetGlobalProperties event");
- is_ui_received_ = true;
- ui_result_ = static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asInt());
- break;
- }
- case hmi_apis::FunctionID::TTS_SetGlobalProperties: {
- LOG4CXX_INFO(logger_, "Received TTS_SetGlobalProperties event");
- is_tts_received_ = true;
- tts_result_ = static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asInt());
- break;
- }
- default: {
- LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
- return;
- }
+ case hmi_apis::FunctionID::UI_SetGlobalProperties: {
+ LOG4CXX_INFO(logger_, "Received UI_SetGlobalProperties event");
+ is_ui_received_ = true;
+ ui_result_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ break;
+ }
+ case hmi_apis::FunctionID::TTS_SetGlobalProperties: {
+ LOG4CXX_INFO(logger_, "Received TTS_SetGlobalProperties event");
+ is_tts_received_ = true;
+ tts_result_ = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ return;
+ }
}
if (!IsPendingResponseExist()) {
- bool result = ((hmi_apis::Common_Result::SUCCESS == ui_result_)
- && (hmi_apis::Common_Result::SUCCESS == tts_result_ ||
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_))
- || ((hmi_apis::Common_Result::SUCCESS == ui_result_)
- && (hmi_apis::Common_Result::INVALID_ENUM == tts_result_))
- || ((hmi_apis::Common_Result::INVALID_ENUM == ui_result_)
- && (hmi_apis::Common_Result::SUCCESS == tts_result_));
+ bool result =
+ ((hmi_apis::Common_Result::SUCCESS == ui_result_) &&
+ (hmi_apis::Common_Result::SUCCESS == tts_result_ ||
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_)) ||
+ ((hmi_apis::Common_Result::SUCCESS == ui_result_) &&
+ (hmi_apis::Common_Result::INVALID_ENUM == tts_result_)) ||
+ ((hmi_apis::Common_Result::INVALID_ENUM == ui_result_) &&
+ (hmi_apis::Common_Result::SUCCESS == tts_result_));
mobile_apis::Result::eType result_code;
const char* return_info = NULL;
@@ -281,18 +285,20 @@ void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
return_info = "Unsupported phoneme type sent in a prompt";
} else {
result_code = static_cast<mobile_apis::Result::eType>(
- std::max(ui_result_, tts_result_));
+ std::max(ui_result_, tts_result_));
}
} else {
result_code = static_cast<mobile_apis::Result::eType>(
- std::max(ui_result_, tts_result_));
+ std::max(ui_result_, tts_result_));
}
- SendResponse(result, static_cast<mobile_apis::Result::eType>(result_code),
- return_info, &(message[strings::msg_params]));
+ SendResponse(result,
+ static_cast<mobile_apis::Result::eType>(result_code),
+ return_info,
+ &(message[strings::msg_params]));
if (!application) {
- LOG4CXX_DEBUG(logger_, "NULL pointer");
+ LOG4CXX_ERROR(logger_, "NULL pointer");
return;
}
@@ -304,7 +310,6 @@ void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
}
}
-
bool ResetGlobalPropertiesRequest::IsPendingResponseExist() {
return is_ui_send_ != is_ui_received_ || is_tts_send_ != is_tts_received_;
}
diff --git a/src/components/application_manager/src/commands/mobile/reset_global_properties_response.cc b/src/components/application_manager/src/commands/mobile/reset_global_properties_response.cc
index 8e562956ae..c621977868 100644
--- a/src/components/application_manager/src/commands/mobile/reset_global_properties_response.cc
+++ b/src/components/application_manager/src/commands/mobile/reset_global_properties_response.cc
@@ -32,24 +32,21 @@
*/
#include "application_manager/commands/mobile/reset_global_properties_response.h"
-#include "application_manager/application_manager_impl.h"
namespace application_manager {
namespace commands {
ResetGlobalPropertiesResponse::ResetGlobalPropertiesResponse(
- const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-ResetGlobalPropertiesResponse::~ResetGlobalPropertiesResponse() {
-}
+ResetGlobalPropertiesResponse::~ResetGlobalPropertiesResponse() {}
void ResetGlobalPropertiesResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // 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 10f080e0e7..89bd43fcd6 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
@@ -33,27 +33,27 @@
#include <string.h>
#include "application_manager/commands/mobile/scrollable_message_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
+#include "application_manager/policies/policy_handler.h"
#include "application_manager/message_helper.h"
#include "interfaces/MOBILE_API.h"
#include "interfaces/HMI_API.h"
+#include "utils/helpers.h"
namespace application_manager {
namespace commands {
ScrollableMessageRequest::ScrollableMessageRequest(
- const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {
subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout);
}
-ScrollableMessageRequest::~ScrollableMessageRequest() {
-}
+ScrollableMessageRequest::~ScrollableMessageRequest() {}
bool ScrollableMessageRequest::Init() {
-
/* Timeout in milliseconds.
If omitted a standard value of 10000 milliseconds is used.*/
if ((*message_)[strings::msg_params].keyExists(strings::timeout)) {
@@ -70,8 +70,7 @@ bool ScrollableMessageRequest::Init() {
void ScrollableMessageRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app = application_manager::ApplicationManagerImpl::instance()
- ->application((*message_)[strings::params][strings::connection_key].asUInt());
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
LOG4CXX_ERROR(logger_, "Application is not registered");
@@ -79,10 +78,13 @@ void ScrollableMessageRequest::Run() {
return;
}
- //ProcessSoftButtons checks strings on the contents incorrect character
+ // ProcessSoftButtons checks strings on the contents incorrect character
mobile_apis::Result::eType processing_result =
- MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], app);
+ MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params],
+ app,
+ application_manager_.GetPolicyHandler(),
+ application_manager_);
if (mobile_apis::Result::SUCCESS != processing_result) {
LOG4CXX_ERROR(logger_, "Wrong soft buttons parameters!");
@@ -90,13 +92,12 @@ void ScrollableMessageRequest::Run() {
return;
}
-
-
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_params[hmi_request::message_text][hmi_request::field_name] =
- static_cast<int32_t>(hmi_apis::Common_TextFieldName::scrollableMessageBody);
+ static_cast<int32_t>(
+ hmi_apis::Common_TextFieldName::scrollableMessageBody);
msg_params[hmi_request::message_text][hmi_request::field_text] =
(*message_)[strings::msg_params][strings::scroll_message_body];
msg_params[strings::app_id] = app->app_id();
@@ -114,36 +115,41 @@ void ScrollableMessageRequest::Run() {
void ScrollableMessageRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
+ using namespace helpers;
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
case hmi_apis::FunctionID::UI_OnResetTimeout: {
LOG4CXX_INFO(logger_, "Received UI_OnResetTimeout event");
- ApplicationManagerImpl::instance()->updateRequestTimeout(connection_key(),
- correlation_id(),
- default_timeout());
+ application_manager_.updateRequestTimeout(
+ connection_key(), correlation_id(), default_timeout());
break;
}
case hmi_apis::FunctionID::UI_ScrollableMessage: {
LOG4CXX_INFO(logger_, "Received UI_ScrollableMessage event");
mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>
- (message[strings::params][hmi_response::code].asInt());
+ static_cast<mobile_apis::Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+
HMICapabilities& hmi_capabilities =
- ApplicationManagerImpl::instance()->hmi_capabilities();
- bool result = false;
- if (mobile_apis::Result::SUCCESS == result_code) {
- result = true;
- } else if ((mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code) &&
+ application_manager_.hmi_capabilities();
+
+ bool result = Compare<mobile_api::Result::eType, EQ, ONE>(
+ result_code,
+ mobile_api::Result::SUCCESS,
+ mobile_api::Result::WARNINGS);
+
+ if (mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code &&
hmi_capabilities.is_ui_cooperating()) {
result = true;
}
+
SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
break;
}
default: {
- LOG4CXX_ERROR(logger_,"Received unknown event" << event.id());
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
break;
}
}
@@ -151,4 +157,3 @@ void ScrollableMessageRequest::on_event(const event_engine::Event& event) {
} // namespace commands
} // namespace application_manager
-
diff --git a/src/components/application_manager/src/commands/mobile/scrollable_message_response.cc b/src/components/application_manager/src/commands/mobile/scrollable_message_response.cc
index 212a3ba912..a5b16bdb70 100644
--- a/src/components/application_manager/src/commands/mobile/scrollable_message_response.cc
+++ b/src/components/application_manager/src/commands/mobile/scrollable_message_response.cc
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/scrollable_message_response.h"
-#include "application_manager/application_manager_impl.h"
+
#include "interfaces/HMI_API.h"
#include "interfaces/MOBILE_API.h"
@@ -41,22 +41,21 @@ namespace application_manager {
namespace commands {
ScrollableMessageResponse::ScrollableMessageResponse(
- const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
void ScrollableMessageResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- mobile_apis::Result::eType result_code = static_cast<mobile_apis::Result::eType>(
- (*message_)[strings::msg_params][strings::result_code].asInt());
- ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(
- (*message_)[strings::params][strings::connection_key].asInt());
+ mobile_apis::Result::eType result_code =
+ static_cast<mobile_apis::Result::eType>(
+ (*message_)[strings::msg_params][strings::result_code].asInt());
+ ApplicationSharedPtr application = application_manager_.application(
+ (*message_)[strings::params][strings::connection_key].asInt());
if ((mobile_apis::Result::REJECTED != result_code) && application) {
application->UnsubscribeFromSoftButtons(
(*message_)[strings::params][strings::function_id].asInt());
}
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
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 b1c96ebb98..975f7e43c3 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
@@ -30,39 +30,51 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
+#include <algorithm>
+
#include "application_manager/commands/mobile/send_location_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/message_helper.h"
+#include "utils/helpers.h"
+#include "utils/custom_string.h"
namespace application_manager {
namespace commands {
-SendLocationRequest::SendLocationRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+SendLocationRequest::SendLocationRequest(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
-SendLocationRequest::~SendLocationRequest() {
-}
+SendLocationRequest::~SendLocationRequest() {}
void SendLocationRequest::Run() {
using namespace hmi_apis;
+ using smart_objects::SmartObject;
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app = application_manager::ApplicationManagerImpl::instance()
- ->application(connection_key());
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
- LOG4CXX_ERROR_EXT(logger_,
- "An application with connection key " << connection_key()
- << " is not registered.");
+ LOG4CXX_ERROR(logger_,
+ "An application with connection key "
+ << connection_key() << " is not registered.");
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
return;
}
- const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params];
- std::list<Common_TextFieldName::eType> fields_to_check;
+ smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params];
+ if (msg_params.keyExists(strings::delivery_mode)) {
+ const std::vector<std::string>& allowed_params =
+ parameters_permissions().allowed_params;
+ if (allowed_params.end() == std::find(allowed_params.begin(),
+ allowed_params.end(),
+ strings::delivery_mode)) {
+ msg_params.erase(strings::delivery_mode);
+ }
+ }
+ std::vector<Common_TextFieldName::eType> fields_to_check;
if (msg_params.keyExists(strings::location_name)) {
fields_to_check.push_back(Common_TextFieldName::locationName);
}
@@ -87,11 +99,27 @@ void SendLocationRequest::Run() {
return;
}
- if ((*message_)[strings::msg_params].keyExists(strings::location_image)) {
+ if (msg_params.keyExists(strings::address)) {
+ const utils::custom_string::CustomString& address =
+ msg_params[strings::address].asCustomString();
+ if (address.empty()) {
+ msg_params.erase(strings::address);
+ }
+ }
+
+ if (!CheckFieldsCompatibility()) {
+ LOG4CXX_ERROR(logger_, "CheckFieldsCompatibility failed");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ return;
+ }
+
+ if (msg_params.keyExists(strings::location_image)) {
mobile_apis::Result::eType verification_result =
mobile_apis::Result::SUCCESS;
verification_result = MessageHelper::VerifyImage(
- (*message_)[strings::msg_params][strings::location_image], app);
+ (*message_)[strings::msg_params][strings::location_image],
+ app,
+ application_manager_);
if (mobile_apis::Result::SUCCESS != verification_result) {
LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!");
SendResponse(false, verification_result);
@@ -99,61 +127,76 @@ void SendLocationRequest::Run() {
}
}
- smart_objects::SmartObject request_msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
- request_msg_params = (*message_)[strings::msg_params];
+ SmartObject request_msg_params = SmartObject(smart_objects::SmartType_Map);
+ request_msg_params = msg_params;
request_msg_params[strings::app_id] = app->hmi_app_id();
-
- SendHMIRequest(hmi_apis::FunctionID::Navigation_SendLocation,
- &request_msg_params, true);
+ SendHMIRequest(
+ hmi_apis::FunctionID::Navigation_SendLocation, &request_msg_params, true);
}
void SendLocationRequest::on_event(const event_engine::Event& event) {
- LOG4CXX_INFO(logger_, "SendLocationRquest::on_event");
+ LOG4CXX_AUTO_TRACE(logger_);
+ namespace Result = mobile_apis::Result;
+ using namespace helpers;
const smart_objects::SmartObject& message = event.smart_object();
- switch (event.id()) {
- case hmi_apis::FunctionID::Navigation_SendLocation: {
- LOG4CXX_INFO(logger_, "Received Navigation_SendLocation event");
- mobile_apis::Result::eType result_code = GetMobileResultCode(
- static_cast<hmi_apis::Common_Result::eType>(
- message[strings::params][hmi_response::code].asUInt()));
- bool result =
- mobile_apis::Result::SUCCESS == result_code ||
- mobile_apis::Result::WARNINGS == result_code ||
- mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code ;
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
- break;
- }
- default: {
- LOG4CXX_ERROR(logger_,"Received unknown event" << event.id());
- break;
- }
+ if (hmi_apis::FunctionID::Navigation_SendLocation == event.id()) {
+ LOG4CXX_INFO(logger_, "Received Navigation_SendLocation event");
+ mobile_apis::Result::eType result_code =
+ GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asUInt()));
+ const bool result =
+ Compare<Result::eType, EQ, ONE>(result_code,
+ Result::SAVED,
+ Result::SUCCESS,
+ Result::WARNINGS,
+ Result::UNSUPPORTED_RESOURCE);
+ SendResponse(result, result_code, NULL, &(message[strings::params]));
+ return;
}
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
}
-bool SendLocationRequest::IsWhiteSpaceExist() {
- LOG4CXX_INFO(logger_, "SendLocationRquest::IsWhiteSpaceExist");
- const char* str;
+bool SendLocationRequest::CheckFieldsCompatibility() {
const smart_objects::SmartObject& msg_params =
(*message_)[strings::msg_params];
-
- if (msg_params.keyExists(strings::location_name)) {
- str = msg_params[strings::location_name].asCharArray();
- if (!CheckSyntax(str)) {
- LOG4CXX_ERROR(logger_,
- "parameter locationName contains invalid character");
- return true;
- }
+ MessageHelper::PrintSmartObject(msg_params);
+ const bool longitude_degrees_exist =
+ msg_params.keyExists(strings::longitude_degrees);
+ const bool latitude_degrees_exist =
+ msg_params.keyExists(strings::latitude_degrees);
+ const bool address_exist = msg_params.keyExists(strings::address);
+
+ if (latitude_degrees_exist ^ longitude_degrees_exist) {
+ LOG4CXX_DEBUG(logger_,
+ "latitude and longitude should be provided only in pair");
+ return false;
}
- if (msg_params.keyExists(strings::location_description)) {
- str = msg_params[strings::location_description].asCharArray();
- if (!CheckSyntax(str)) {
- LOG4CXX_ERROR(logger_,
- "parameter locationDescription contains invalid character");
- return true;
- }
+ if (!address_exist && !longitude_degrees_exist && !latitude_degrees_exist) {
+ LOG4CXX_DEBUG(logger_,
+ "address or latitude/longtitude should should be provided");
+ return false;
+ }
+ return true;
+}
+void insert_if_contains(
+ const smart_objects::SmartObject& msg_params,
+ const std::string& param_key,
+ std::vector<utils::custom_string::CustomString>& output_vector) {
+ if (msg_params.keyExists(param_key)) {
+ output_vector.push_back(msg_params[param_key].asCustomString());
}
+}
+
+bool SendLocationRequest::IsWhiteSpaceExist() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ std::vector<utils::custom_string::CustomString> fields_to_check;
+ const smart_objects::SmartObject& msg_params =
+ (*message_)[strings::msg_params];
+ insert_if_contains(msg_params, strings::location_name, fields_to_check);
+ insert_if_contains(
+ msg_params, strings::location_description, fields_to_check);
+ insert_if_contains(msg_params, strings::phone_number, fields_to_check);
if (msg_params.keyExists(strings::address_lines)) {
const smart_objects::SmartArray* al_array =
@@ -161,60 +204,63 @@ bool SendLocationRequest::IsWhiteSpaceExist() {
smart_objects::SmartArray::const_iterator it_al = al_array->begin();
smart_objects::SmartArray::const_iterator it_al_end = al_array->end();
for (; it_al != it_al_end; ++it_al) {
- str = (*it_al).asCharArray();
- if(!CheckSyntax(str)) {
- LOG4CXX_ERROR(logger_,
- "parameter address_lines contains invalid character");
- return true;
- }
+ const utils::custom_string::CustomString& val = (*it_al).asCustomString();
+ fields_to_check.push_back(val);
}
}
- if (msg_params.keyExists(strings::phone_number)) {
- str = msg_params[strings::phone_number].asCharArray();
- if (!CheckSyntax(str)) {
- LOG4CXX_ERROR(logger_,
- "parameter phoneNumber contains invalid character");
- return true;
- }
+ if (msg_params.keyExists(strings::address)) {
+ const smart_objects::SmartObject& address_so = msg_params[strings::address];
+ insert_if_contains(address_so, strings::country_name, fields_to_check);
+ insert_if_contains(address_so, strings::country_code, fields_to_check);
+ insert_if_contains(address_so, strings::postal_code, fields_to_check);
+ insert_if_contains(
+ address_so, strings::administrative_area, fields_to_check);
+ insert_if_contains(address_so, strings::locality, fields_to_check);
+ insert_if_contains(address_so, strings::sub_locality, fields_to_check);
+ insert_if_contains(address_so, strings::thoroughfare, fields_to_check);
+ insert_if_contains(address_so, strings::sub_thoroughfare, fields_to_check);
}
- if (msg_params.keyExists(strings::location_image)) {
- str = msg_params[strings::location_image][strings::value].asCharArray();
- if (!CheckSyntax(str)) {
+ std::vector<utils::custom_string::CustomString>::iterator it =
+ fields_to_check.begin();
+ for (; it != fields_to_check.end(); ++it) {
+ const std::string& str = it->AsMBString();
+ if (!CheckSyntax(str, false)) {
LOG4CXX_ERROR(logger_,
- "parameter value in locationImage contains invalid character");
+ "string '" << str << "'' contains invalid characters");
return true;
}
}
-
return false;
}
-bool SendLocationRequest::CheckHMICapabilities(std::list<hmi_apis::Common_TextFieldName::eType>& fields_names) {
+bool SendLocationRequest::CheckHMICapabilities(
+ std::vector<hmi_apis::Common_TextFieldName::eType>& fields_names) {
using namespace smart_objects;
using namespace hmi_apis;
-
if (fields_names.empty()) {
return true;
}
- ApplicationManagerImpl* instance = ApplicationManagerImpl::instance();
- const HMICapabilities& hmi_capabilities = instance->hmi_capabilities();
+ const HMICapabilities& hmi_capabilities =
+ application_manager_.hmi_capabilities();
if (!hmi_capabilities.is_ui_cooperating()) {
- LOG4CXX_ERROR_EXT(logger_, "UI is not supported.");
+ LOG4CXX_ERROR(logger_, "UI is not supported.");
return false;
}
if (hmi_capabilities.display_capabilities()) {
const SmartObject disp_cap = (*hmi_capabilities.display_capabilities());
- const SmartObject& text_fields = disp_cap.getElement(hmi_response::text_fields);
+ const SmartObject& text_fields =
+ disp_cap.getElement(hmi_response::text_fields);
const size_t len = text_fields.length();
for (size_t i = 0; i < len; ++i) {
const SmartObject& text_field = text_fields[i];
const Common_TextFieldName::eType filed_name =
- static_cast<Common_TextFieldName::eType>(text_field.getElement(strings::name).asInt());
- const std::list<Common_TextFieldName::eType>::iterator it =
+ static_cast<Common_TextFieldName::eType>(
+ text_field.getElement(strings::name).asInt());
+ const std::vector<Common_TextFieldName::eType>::iterator it =
std::find(fields_names.begin(), fields_names.end(), filed_name);
if (it != fields_names.end()) {
fields_names.erase(it);
@@ -223,7 +269,7 @@ bool SendLocationRequest::CheckHMICapabilities(std::list<hmi_apis::Common_TextFi
}
if (!fields_names.empty()) {
- LOG4CXX_ERROR_EXT(logger_, "Some fields are not supported by capabilities");
+ LOG4CXX_ERROR(logger_, "Some fields are not supported by capabilities");
return false;
}
return true;
diff --git a/src/components/application_manager/src/commands/mobile/send_location_response.cc b/src/components/application_manager/src/commands/mobile/send_location_response.cc
index 32756c999d..167642e390 100644
--- a/src/components/application_manager/src/commands/mobile/send_location_response.cc
+++ b/src/components/application_manager/src/commands/mobile/send_location_response.cc
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/send_location_response.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "interfaces/HMI_API.h"
@@ -40,17 +40,16 @@ namespace application_manager {
namespace commands {
-SendLocationResponse::SendLocationResponse(const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+SendLocationResponse::SendLocationResponse(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-SendLocationResponse::~SendLocationResponse() {
-}
+SendLocationResponse::~SendLocationResponse() {}
void SendLocationResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
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 bd9c9fa0cb..40b708e30d 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
@@ -31,38 +31,35 @@
POSSIBILITY OF SUCH DAMAGE.
*/
+#include <algorithm>
#include "application_manager/commands/mobile/set_app_icon_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
-#include "config_profile/profile.h"
#include "interfaces/MOBILE_API.h"
#include "interfaces/HMI_API.h"
#include "utils/file_system.h"
+#include "utils/helpers.h"
namespace application_manager {
namespace commands {
-int8_t SetAppIconRequest::is_icons_saving_enabled_ = -1;
-
-SetAppIconRequest::SetAppIconRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
- if (-1 == is_icons_saving_enabled_) {
- const std::string path = profile::Profile::instance()->app_icons_folder();
- is_icons_saving_enabled_ =
- file_system::IsWritingAllowed(path) &&
- file_system::IsReadingAllowed(path);
- }
+SetAppIconRequest::SetAppIconRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager)
+ , is_icons_saving_enabled_(false) {
+ const std::string path =
+ application_manager_.get_settings().app_icons_folder();
+ is_icons_saving_enabled_ = file_system::IsWritingAllowed(path) &&
+ file_system::IsReadingAllowed(path);
}
-SetAppIconRequest::~SetAppIconRequest() {
-}
+SetAppIconRequest::~SetAppIconRequest() {}
void SetAppIconRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()->application(connection_key());
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
LOG4CXX_ERROR(logger_, "Application is not registered");
@@ -74,7 +71,7 @@ void SetAppIconRequest::Run() {
(*message_)[strings::msg_params][strings::sync_file_name].asString();
std::string full_file_path =
- profile::Profile::instance()->app_storage_folder() + "/";
+ application_manager_.get_settings().app_storage_folder() + "/";
full_file_path += app->folder_name();
full_file_path += "/";
full_file_path += sync_file_name;
@@ -89,22 +86,22 @@ void SetAppIconRequest::Run() {
CopyToIconStorage(full_file_path);
}
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_params[strings::app_id] = app->app_id();
- msg_params[strings::sync_file_name] = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ msg_params[strings::sync_file_name] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
-// Panasonic requres unchanged path value without encoded special characters
- const std::string full_file_path_for_hmi = file_system::ConvertPathForURL(
- full_file_path);
+ // Panasonic requres unchanged path value without encoded special characters
+ const std::string full_file_path_for_hmi =
+ file_system::ConvertPathForURL(full_file_path);
msg_params[strings::sync_file_name][strings::value] = full_file_path_for_hmi;
// TODO(VS): research why is image_type hardcoded
msg_params[strings::sync_file_name][strings::image_type] =
- static_cast<int32_t> (SetAppIconRequest::ImageType::DYNAMIC);
+ static_cast<int32_t>(SetAppIconRequest::ImageType::DYNAMIC);
// for further use in on_event function
(*message_)[strings::msg_params][strings::sync_file_name] =
@@ -114,38 +111,41 @@ void SetAppIconRequest::Run() {
}
void SetAppIconRequest::CopyToIconStorage(
- const std::string& path_to_file) const {
- if (!profile::Profile::instance()->enable_protocol_4()) {
+ const std::string& path_to_file) const {
+ if (!application_manager_.protocol_handler()
+ .get_settings()
+ .enable_protocol_4()) {
LOG4CXX_WARN(logger_,
"Icon copying skipped, since protocol ver. 4 is not enabled.");
return;
}
std::vector<uint8_t> file_content;
- if(!file_system::ReadBinaryFile(path_to_file, file_content)) {
+ if (!file_system::ReadBinaryFile(path_to_file, file_content)) {
LOG4CXX_ERROR(logger_, "Can't read icon file: " << path_to_file);
return;
}
const std::string icon_storage =
- profile::Profile::instance()->app_icons_folder();
- const uint64_t storage_max_size =
- static_cast<uint64_t>(
- profile::Profile::instance()->app_icons_folder_max_size());
+ application_manager_.get_settings().app_icons_folder();
+ const uint64_t storage_max_size = static_cast<uint64_t>(
+ application_manager_.get_settings().app_icons_folder_max_size());
const uint64_t file_size = file_system::FileSize(path_to_file);
if (storage_max_size < file_size) {
- LOG4CXX_ERROR(logger_, "Icon size (" << file_size << ") is bigger, than "
- " icons storage maximum size (" << storage_max_size << ")."
- "Copying skipped.");
+ LOG4CXX_ERROR(logger_,
+ "Icon size (" << file_size << ") is bigger, than "
+ " icons storage maximum size ("
+ << storage_max_size << ")."
+ "Copying skipped.");
return;
}
- const uint64_t storage_size = static_cast<uint64_t>(
- file_system::DirectorySize(icon_storage));
+ const uint64_t storage_size =
+ static_cast<uint64_t>(file_system::DirectorySize(icon_storage));
if (storage_max_size < (file_size + storage_size)) {
const uint32_t icons_amount =
- profile::Profile::instance()->app_icons_amount_to_remove();
+ application_manager_.get_settings().app_icons_amount_to_remove();
if (!icons_amount) {
LOG4CXX_DEBUG(logger_,
@@ -159,17 +159,16 @@ void SetAppIconRequest::CopyToIconStorage(
}
}
ApplicationConstSharedPtr app =
- application_manager::ApplicationManagerImpl::instance()->
- application(connection_key());
+ application_manager_.application(connection_key());
if (!app) {
- LOG4CXX_ERROR(logger_, "Can't get application for connection key: "
- << connection_key());
+ LOG4CXX_ERROR(
+ logger_,
+ "Can't get application for connection key: " << connection_key());
return;
}
- const std::string icon_path =
- icon_storage + "/" + app->mobile_app_id();
+ const std::string icon_path = icon_storage + "/" + app->policy_app_id();
if (!file_system::CreateFile(icon_path)) {
LOG4CXX_ERROR(logger_, "Can't create icon: " << icon_path);
return;
@@ -180,8 +179,9 @@ void SetAppIconRequest::CopyToIconStorage(
return;
}
- LOG4CXX_DEBUG(logger_, "Icon was successfully copied from :" << path_to_file
- << " to " << icon_path);
+ LOG4CXX_DEBUG(logger_,
+ "Icon was successfully copied from :" << path_to_file << " to "
+ << icon_path);
return;
}
@@ -191,7 +191,7 @@ void SetAppIconRequest::RemoveOldestIcons(const std::string& storage,
const std::vector<std::string> icons_list = file_system::ListFiles(storage);
std::map<uint64_t, std::string> icon_modification_time;
std::vector<std::string>::const_iterator it = icons_list.begin();
- for (;it != icons_list.end(); ++it) {
+ for (; it != icons_list.end(); ++it) {
const std::string file_name = *it;
const std::string file_path = storage + "/" + file_name;
if (!file_system::FileExists(file_path)) {
@@ -212,53 +212,56 @@ void SetAppIconRequest::RemoveOldestIcons(const std::string& storage,
LOG4CXX_DEBUG(logger_, "Error while deleting icon " << file_path);
}
icon_modification_time.erase(icon_modification_time.begin());
- LOG4CXX_DEBUG(logger_, "Old icon " << file_path
- << " was deleted successfully.");
+ LOG4CXX_DEBUG(logger_,
+ "Old icon " << file_path << " was deleted successfully.");
}
}
bool SetAppIconRequest::IsEnoughSpaceForIcon(const uint64_t icon_size) const {
const std::string icon_storage =
- profile::Profile::instance()->app_icons_folder();
- const uint64_t storage_max_size =
- static_cast<uint64_t>(
- profile::Profile::instance()->app_icons_folder_max_size());
- const uint64_t storage_size = static_cast<uint64_t>(
- file_system::DirectorySize(icon_storage));
+ application_manager_.get_settings().app_icons_folder();
+ const uint64_t storage_max_size = static_cast<uint64_t>(
+ application_manager_.get_settings().app_icons_folder_max_size());
+ const uint64_t storage_size =
+ static_cast<uint64_t>(file_system::DirectorySize(icon_storage));
return storage_max_size >= (icon_size + storage_size);
}
void SetAppIconRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
- const smart_objects::SmartObject& event_message = event.smart_object();
+ using namespace helpers;
+ const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
case hmi_apis::FunctionID::UI_SetAppIcon: {
mobile_apis::Result::eType result_code =
static_cast<mobile_apis::Result::eType>(
- event_message[strings::params][hmi_response::code].asInt());
+ message[strings::params][hmi_response::code].asInt());
- bool result = mobile_apis::Result::SUCCESS == result_code;
+ const bool result = Compare<mobile_api::Result::eType, EQ, ONE>(
+ result_code,
+ mobile_api::Result::SUCCESS,
+ mobile_api::Result::WARNINGS);
if (result) {
ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()->application(connection_key());
+ application_manager_.application(connection_key());
if (!message_.valid() || !app.valid()) {
- LOG4CXX_ERROR(logger_, "NULL pointer.");
- return;
+ LOG4CXX_ERROR(logger_, "NULL pointer.");
+ return;
}
- const std::string path = (*message_)[strings::msg_params]
- [strings::sync_file_name]
- [strings::value].asString();
+ const std::string& path =
+ (*message_)[strings::msg_params][strings::sync_file_name]
+ [strings::value].asString();
app->set_app_icon_path(path);
LOG4CXX_INFO(logger_,
"Icon path was set to '" << app->app_icon_path() << "'");
}
- SendResponse(result, result_code, NULL, &(event_message[strings::msg_params]));
+ SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
break;
}
default: {
diff --git a/src/components/application_manager/src/commands/mobile/set_app_icon_response.cc b/src/components/application_manager/src/commands/mobile/set_app_icon_response.cc
index 563490bd46..29f3950ffc 100644
--- a/src/components/application_manager/src/commands/mobile/set_app_icon_response.cc
+++ b/src/components/application_manager/src/commands/mobile/set_app_icon_response.cc
@@ -32,23 +32,21 @@
*/
#include "application_manager/commands/mobile/set_app_icon_response.h"
-#include "application_manager/application_manager_impl.h"
namespace application_manager {
namespace commands {
-SetAppIconResponse::SetAppIconResponse(const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+SetAppIconResponse::SetAppIconResponse(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-SetAppIconResponse::~SetAppIconResponse() {
-}
+SetAppIconResponse::~SetAppIconResponse() {}
void SetAppIconResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
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 f3d9e28c04..6cb6318791 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
@@ -32,26 +32,23 @@
*/
#include "application_manager/commands/mobile/set_display_layout_request.h"
-#include "application_manager/application_manager_impl.h"
-#include "application_manager/application_impl.h"
+#include "application_manager/application_impl.h"
namespace application_manager {
namespace commands {
SetDisplayLayoutRequest::SetDisplayLayoutRequest(
- const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
-SetDisplayLayoutRequest::~SetDisplayLayoutRequest() {
-}
+SetDisplayLayoutRequest::~SetDisplayLayoutRequest() {}
void SetDisplayLayoutRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
ApplicationConstSharedPtr app =
- ApplicationManagerImpl::instance()->application(connection_key());
+ application_manager_.application(connection_key());
if (!app) {
LOG4CXX_ERROR(logger_, "Application is not registered");
@@ -61,8 +58,8 @@ void SetDisplayLayoutRequest::Run() {
(*message_)[strings::msg_params][strings::app_id] = app->app_id();
SendHMIRequest(hmi_apis::FunctionID::UI_SetDisplayLayout,
- &((*message_)[strings::msg_params]), true);
-
+ &((*message_)[strings::msg_params]),
+ true);
}
void SetDisplayLayoutRequest::on_event(const event_engine::Event& event) {
@@ -74,21 +71,25 @@ void SetDisplayLayoutRequest::on_event(const event_engine::Event& event) {
LOG4CXX_INFO(logger_, "Received UI_SetDisplayLayout event");
mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
- message[strings::params][hmi_response::code].asInt());
+ static_cast<mobile_apis::Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
bool response_success = mobile_apis::Result::SUCCESS == result_code;
smart_objects::SmartObject msg_params = message[strings::msg_params];
if (response_success) {
HMICapabilities& hmi_capabilities =
- ApplicationManagerImpl::instance()->hmi_capabilities();
+ application_manager_.hmi_capabilities();
// in case templates_available is empty copy from hmi capabilities
if (msg_params.keyExists(hmi_response::display_capabilities)) {
- if (0 == msg_params[hmi_response::display_capabilities][hmi_response::templates_available].length()) {
- msg_params[hmi_response::display_capabilities][hmi_response::templates_available] =
- hmi_capabilities.display_capabilities()->getElement(hmi_response::templates_available);
+ if (0 ==
+ msg_params[hmi_response::display_capabilities]
+ [hmi_response::templates_available].length()) {
+ msg_params[hmi_response::display_capabilities]
+ [hmi_response::templates_available] =
+ hmi_capabilities.display_capabilities()->getElement(
+ hmi_response::templates_available);
}
}
}
@@ -96,7 +97,7 @@ void SetDisplayLayoutRequest::on_event(const event_engine::Event& event) {
break;
}
default: {
- LOG4CXX_ERROR(logger_,"Received unknown event" << event.id());
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
return;
}
}
diff --git a/src/components/application_manager/src/commands/mobile/set_display_layout_response.cc b/src/components/application_manager/src/commands/mobile/set_display_layout_response.cc
index 3844b3bf05..b5e53803c8 100644
--- a/src/components/application_manager/src/commands/mobile/set_display_layout_response.cc
+++ b/src/components/application_manager/src/commands/mobile/set_display_layout_response.cc
@@ -33,25 +33,21 @@
#include "application_manager/commands/mobile/set_display_layout_response.h"
#include "application_manager/application_impl.h"
-#include "application_manager/application_manager_impl.h"
namespace application_manager {
namespace commands {
SetDisplayLayoutResponse::SetDisplayLayoutResponse(
- const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-SetDisplayLayoutResponse::~SetDisplayLayoutResponse() {
-}
+SetDisplayLayoutResponse::~SetDisplayLayoutResponse() {}
void SetDisplayLayoutResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
-
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
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 aef167cb54..171b902df1 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
@@ -1,6 +1,5 @@
/*
-
- Copyright (c) 2013, Ford Motor Company
+ Copyright (c) 2015, Ford Motor Company
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -34,29 +33,27 @@
#include <string.h>
#include <algorithm>
#include "application_manager/commands/mobile/set_global_properties_request.h"
-#include "application_manager/application_manager_impl.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/helpers.h"
namespace application_manager {
namespace commands {
SetGlobalPropertiesRequest::SetGlobalPropertiesRequest(
- const MessageSharedPtr& message)
- : CommandRequestImpl(message),
- 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) {
-}
+ 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) {}
-SetGlobalPropertiesRequest::~SetGlobalPropertiesRequest() {
-}
+SetGlobalPropertiesRequest::~SetGlobalPropertiesRequest() {}
void SetGlobalPropertiesRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
@@ -64,13 +61,12 @@ void SetGlobalPropertiesRequest::Run() {
const smart_objects::SmartObject& msg_params =
(*message_)[strings::msg_params];
- uint32_t app_id =
- (*message_)[strings::params][strings::connection_key].asUInt();
-
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
- LOG4CXX_ERROR_EXT(logger_, "No application associated with session key");
+ LOG4CXX_ERROR(logger_,
+ "No application associated with connection key "
+ << connection_key());
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
return;
}
@@ -86,230 +82,144 @@ void SetGlobalPropertiesRequest::Run() {
if ((*message_)[strings::msg_params].keyExists(strings::menu_icon)) {
verification_result = MessageHelper::VerifyImage(
- (*message_)[strings::msg_params][strings::menu_icon], app);
+ (*message_)[strings::msg_params][strings::menu_icon],
+ app,
+ application_manager_);
if (mobile_apis::Result::SUCCESS != verification_result) {
- LOG4CXX_ERROR_EXT(
- logger_,
- "MessageHelper::VerifyImage return " << verification_result);
+ LOG4CXX_ERROR(
+ logger_, "MessageHelper::VerifyImage return " << verification_result);
SendResponse(false, verification_result);
return;
}
}
// Check for image file(s) in vrHelpItem
if ((*message_)[strings::msg_params].keyExists(strings::vr_help)) {
- if (mobile_apis::Result::SUCCESS != MessageHelper::VerifyImageVrHelpItems(
- (*message_)[strings::msg_params][strings::vr_help], app)) {
- LOG4CXX_ERROR_EXT(
- logger_,
- "MessageHelper::VerifyImage return INVALID_DATA!" );
+ if (mobile_apis::Result::SUCCESS !=
+ MessageHelper::VerifyImageVrHelpItems(
+ (*message_)[strings::msg_params][strings::vr_help],
+ app,
+ application_manager_)) {
+ LOG4CXX_ERROR(logger_, "MessageHelper::VerifyImage return INVALID_DATA!");
SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
}
}
if (IsWhiteSpaceExist()) {
+ LOG4CXX_ERROR(logger_, "White spaces found");
SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
}
- //if application waits for sending ttsGlobalProperties need to remove this
- //application from tts_global_properties_app_list_
- LOG4CXX_INFO(logger_, "RemoveAppFromTTSGlobalPropertiesList");
- ApplicationManagerImpl::instance()->RemoveAppFromTTSGlobalPropertiesList(
- app_id);
+ // if application waits for sending ttsGlobalProperties need to remove this
+ // application from tts_global_properties_app_list_
+ application_manager_.RemoveAppFromTTSGlobalPropertiesList(connection_key());
bool is_help_prompt_present = msg_params.keyExists(strings::help_prompt);
- bool is_timeout_prompt_present = msg_params.keyExists(
- strings::timeout_prompt);
+ bool is_timeout_prompt_present =
+ msg_params.keyExists(strings::timeout_prompt);
bool is_vr_help_title_present = msg_params.keyExists(strings::vr_help_title);
bool is_vr_help_present = msg_params.keyExists(strings::vr_help);
- bool is_menu_title_present = msg_params.keyExists(hmi_request::menu_title);
- bool is_menu_icon_present = msg_params.keyExists(hmi_request::menu_icon);
- bool is_keyboard_props_present =
- msg_params.keyExists(hmi_request::keyboard_properties);
-
- // Media-only applications support API v2.1 with less parameters
- // Code deleted according to APPLINK-6119 APPLINK-6133
- // Not sure that it is right
-
-// if (!app->allowed_support_navigation() &&
-// (is_keyboard_props_present ||
-// is_menu_icon_present ||
-// is_menu_title_present)
-// ) {
-// const std::string app_type =
-// app->is_media_application() ? "media" : "non-media";
-
-// const std::string message =
-// "There are too many parameters for "+app_type+" application.";
-// SendResponse(false,
-// mobile_apis::Result::INVALID_DATA,
-// message.c_str());
-// return;
-// }
-
- if ((is_vr_help_title_present && is_vr_help_present) ||
- (!is_vr_help_title_present && !is_vr_help_present)) {
- is_ui_send_ = true;
- }
- if (is_help_prompt_present || is_timeout_prompt_present) {
- is_tts_send_ = true;
+ // check VR params
+ if (is_vr_help_title_present ^ is_vr_help_present) {
+ LOG4CXX_ERROR(logger_,
+ "Reject because of vr_help or vr_help_title only provided");
+ SendResponse(false, mobile_apis::Result::REJECTED);
+ return;
}
-
if (is_vr_help_title_present && is_vr_help_present) {
- // check vrhelpitem position index
- if (!CheckVrHelpItemsOrder()) {
- LOG4CXX_ERROR(logger_, "Request rejected");
+ LOG4CXX_DEBUG(logger_, "VRHelp params presents");
+
+ if (!CheckVrHelpItemsOrder(msg_params[strings::vr_help])) {
+ LOG4CXX_ERROR(logger_,
+ "VR Help Items contains nonsequential positions"
+ << " (e.g. [1,2,4]) or not started from 1");
SendResponse(false, mobile_apis::Result::REJECTED);
return;
}
- app->set_vr_help_title(
- msg_params.getElement(strings::vr_help_title));
- app->set_vr_help(
- msg_params.getElement(strings::vr_help));
-
smart_objects::SmartObject params =
smart_objects::SmartObject(smart_objects::SmartType_Map);
- params[strings::vr_help_title] = (*app->vr_help_title());
- params[strings::vr_help] = (*app->vr_help());
- params[strings::app_id] = app->app_id();
- if (is_menu_title_present) {
-
- params[hmi_request::menu_title] =
- msg_params[hmi_request::menu_title].asString();
- app->set_menu_title(msg_params[hmi_request::menu_title]);
- }
- if (is_menu_icon_present) {
+ PrepareUIRequestVRHelpData(app, msg_params, params);
+ PrepareUIRequestMenuAndKeyboardData(app, msg_params, params);
- params[hmi_request::menu_icon] =
- msg_params[hmi_request::menu_icon];
- app->set_menu_icon(msg_params[hmi_request::menu_icon]);
- }
- if (is_keyboard_props_present) {
+ params[strings::app_id] = app->app_id();
+ SendUIRequest(params, true);
+ } else {
+ LOG4CXX_DEBUG(logger_, "VRHelp params does not present");
+ DCHECK_OR_RETURN_VOID(!is_vr_help_title_present && !is_vr_help_present);
- params[hmi_request::keyboard_properties] =
- msg_params[hmi_request::keyboard_properties];
- app->set_keyboard_props(msg_params[hmi_request::keyboard_properties]);
- }
+ smart_objects::SmartObject params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
- SendHMIRequest(hmi_apis::FunctionID::UI_SetGlobalProperties,
- &params, true);
- } else if (!is_vr_help_title_present && !is_vr_help_present) {
- const DataAccessor<CommandsMap> accessor = app->commands_map();
- const CommandsMap& cmdMap = accessor.GetData();
- CommandsMap::const_iterator command_it = cmdMap.begin();
-
- int32_t index = 0;
- smart_objects::SmartObject vr_help_items;
- for (; cmdMap.end() != command_it; ++command_it) {
- if (false == (*command_it->second).keyExists(strings::vr_commands)) {
- LOG4CXX_ERROR(logger_, "VR synonyms are empty");
+ 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;
}
- // use only first
- vr_help_items[index][strings::position] = (index + 1);
- vr_help_items[index++][strings::text] =
- (*command_it->second)[strings::vr_commands][0];
}
+ PrepareUIRequestMenuAndKeyboardData(app, msg_params, params);
- app->set_vr_help_title(smart_objects::SmartObject(app->name()));
-
- smart_objects::SmartObject params =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
-
- params[strings::vr_help_title] = (*app->vr_help_title());
- if (vr_help_items.length() > 0) {
- app->set_vr_help(vr_help_items);
- params[strings::vr_help] = (*app->vr_help());
- }
- params[strings::app_id] = app->app_id();
- if (is_menu_title_present) {
-
- params[hmi_request::menu_title] =
- msg_params[hmi_request::menu_title].asString();
- app->set_menu_title(msg_params[hmi_request::menu_title]);
- }
- if (is_menu_icon_present) {
-
- params[hmi_request::menu_icon] =
- msg_params[hmi_request::menu_icon];
- app->set_menu_icon(msg_params[hmi_request::menu_icon]);
- }
- if (is_keyboard_props_present) {
-
- params[hmi_request::keyboard_properties] =
- msg_params[hmi_request::keyboard_properties];
- app->set_keyboard_props(msg_params[hmi_request::keyboard_properties]);
+ // Preparing data
+ if (params.empty()) {
+ LOG4CXX_DEBUG(logger_, "No UI info provided");
+ } else {
+ params[strings::app_id] = app->app_id();
+ SendUIRequest(params, true);
}
-
- SendHMIRequest(hmi_apis::FunctionID::UI_SetGlobalProperties,
- &params, true);
- } else {
- LOG4CXX_ERROR(logger_, "Request rejected");
- SendResponse(false, mobile_apis::Result::REJECTED);
- return;
}
-
// check TTS params
if (is_help_prompt_present || is_timeout_prompt_present) {
+ LOG4CXX_DEBUG(logger_, "TTS params presents");
smart_objects::SmartObject params =
smart_objects::SmartObject(smart_objects::SmartType_Map);
if (is_help_prompt_present) {
- app->set_help_prompt(
- msg_params.getElement(strings::help_prompt));
+ app->set_help_prompt(msg_params.getElement(strings::help_prompt));
params[strings::help_prompt] = (*app->help_prompt());
}
if (is_timeout_prompt_present) {
- app->set_timeout_prompt(
- msg_params.getElement(strings::timeout_prompt));
+ app->set_timeout_prompt(msg_params.getElement(strings::timeout_prompt));
params[strings::timeout_prompt] = (*app->timeout_prompt());
}
params[strings::app_id] = app->app_id();
-
- SendHMIRequest(hmi_apis::FunctionID::TTS_SetGlobalProperties,
- &params, true);
+ SendTTSRequest(params, true);
}
}
-bool SetGlobalPropertiesRequest::CheckVrHelpItemsOrder() {
- const smart_objects::SmartObject vr_help = (*message_)[strings::msg_params]
- .getElement(strings::vr_help);
-
- // vr help item start position must be 1
- const uint32_t vr_help_item_start_position = 1;
-
- if (vr_help_item_start_position !=
- vr_help.getElement(0).getElement(strings::position).asUInt()) {
- LOG4CXX_ERROR(logger_, "VR help items start position is wrong");
- return false;
- }
-
- // Check if VR Help Items contains sequential positionss
- size_t i = 0;
- for (size_t j = 1; j < vr_help.length(); ++i, ++j) {
- if ((vr_help.getElement(i).getElement(strings::position).asInt() + 1)
- != vr_help.getElement(j).getElement(strings::position).asInt()) {
- LOG4CXX_ERROR(logger_, "VR help items order is wrong");
+bool SetGlobalPropertiesRequest::CheckVrHelpItemsOrder(
+ const smart_objects::SmartObject& vr_help) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK_OR_RETURN(vr_help.getType() == smart_objects::SmartType_Array, false);
+ const size_t vr_help_length = vr_help.length();
+ DCHECK_OR_RETURN(vr_help_length > 0, false);
+
+ for (size_t j = 0; j < vr_help_length; ++j) {
+ const size_t position =
+ vr_help.getElement(j).getElement(strings::position).asUInt();
+ // Elements shall start from 1 and increment one by one
+ if (position != (j + 1)) {
+ LOG4CXX_ERROR(logger_,
+ "VR help items order is wrong"
+ << " at " << j << ", position value:" << position);
return false;
}
}
-
return true;
}
void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
+ using namespace helpers;
const smart_objects::SmartObject& message = event.smart_object();
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(CommandRequestImpl::connection_key());
-
switch (event.id()) {
case hmi_apis::FunctionID::UI_SetGlobalProperties: {
LOG4CXX_INFO(logger_, "Received UI_SetGlobalProperties event");
@@ -331,65 +241,189 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) {
}
}
- if (!IsPendingResponseExist()) {
- bool result = ((hmi_apis::Common_Result::SUCCESS == ui_result_)
- && (hmi_apis::Common_Result::SUCCESS == tts_result_ ||
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_))
- || ((hmi_apis::Common_Result::SUCCESS == ui_result_ ||
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == ui_result_)
- && (hmi_apis::Common_Result::INVALID_ENUM == tts_result_))
- || ((hmi_apis::Common_Result::INVALID_ENUM == ui_result_ ||
- hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == ui_result_)
- && (hmi_apis::Common_Result::SUCCESS == tts_result_));
-
- mobile_apis::Result::eType result_code;
- const char* return_info = NULL;
-
- if (result) {
- if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_) {
- result_code = mobile_apis::Result::WARNINGS;
- return_info = "Unsupported phoneme type sent in a prompt";
- } else {
- result_code = static_cast<mobile_apis::Result::eType>(
- std::max(ui_result_, tts_result_));
- }
- } else {
- result_code = static_cast<mobile_apis::Result::eType>(
- std::max(ui_result_, tts_result_));
- }
+ if (IsPendingResponseExist()) {
+ LOG4CXX_DEBUG(logger_, "Continue waiting for response");
+ return;
+ }
- // TODO(AOleynik): APPLINK-15858
- ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(connection_key());
+ const bool is_tts_succeeded =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ tts_result_,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
+ hmi_apis::Common_Result::WARNINGS);
+
+ const bool is_ui_succeeded = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ ui_result_,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE,
+ hmi_apis::Common_Result::WARNINGS);
+
+ const bool is_ui_invalid_unsupported =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ ui_result_,
+ hmi_apis::Common_Result::INVALID_ENUM,
+ hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
+
+ bool result = (is_tts_succeeded && is_ui_succeeded) ||
+ (is_ui_succeeded &&
+ hmi_apis::Common_Result::INVALID_ENUM == tts_result_) ||
+ (is_ui_invalid_unsupported && is_tts_succeeded);
+
+ mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
+ const char* return_info = NULL;
+
+ const bool is_ui_or_tts_warning =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ hmi_apis::Common_Result::WARNINGS, tts_result_, ui_result_);
+
+ if (result && (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_ ||
+ is_ui_or_tts_warning)) {
+ result_code = mobile_apis::Result::WARNINGS;
+ return_info =
+ std::string("Unsupported phoneme type sent in a prompt").c_str();
+ } else {
+ result_code =
+ MessageHelper::HMIToMobileResult(std::max(ui_result_, tts_result_));
+ }
- SendResponse(result, result_code, return_info,
- &(message[strings::msg_params]));
+ // TODO{ALeshin} APPLINK-15858. connection_key removed during SendResponse
+ ApplicationSharedPtr application =
+ application_manager_.application(connection_key());
- if (!application) {
- LOG4CXX_DEBUG(logger_, "NULL pointer.");
- return;
- }
+ SendResponse(
+ result, result_code, return_info, &(message[strings::msg_params]));
+
+ if (!application) {
+ LOG4CXX_DEBUG(logger_, "NULL pointer.");
+ return;
+ }
+
+ if (result) {
+ application->UpdateHash();
+ }
+}
- if (result) {
- application->UpdateHash();
+bool SetGlobalPropertiesRequest::ValidateVRHelpTitle(
+ const smart_objects::SmartObject* const vr_help_so_ptr) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (vr_help_so_ptr) {
+ const std::string& vr_help = vr_help_so_ptr->asString();
+ LOG4CXX_TRACE(logger_, "App contains vr_help_title: \"" << vr_help << '"');
+ return !vr_help.empty();
+ }
+ return false;
+}
+
+void SetGlobalPropertiesRequest::PrepareUIRequestVRHelpData(
+ const ApplicationSharedPtr app,
+ const smart_objects::SmartObject& msg_params,
+ smart_objects::SmartObject& out_params) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK_OR_RETURN_VOID(app);
+
+ app->set_vr_help_title(msg_params.getElement(strings::vr_help_title));
+ app->set_vr_help(msg_params.getElement(strings::vr_help));
+
+ out_params[strings::vr_help_title] = (*app->vr_help_title());
+ out_params[strings::vr_help] = (*app->vr_help());
+}
+
+bool SetGlobalPropertiesRequest::PrepareUIRequestDefaultVRHelpData(
+ const ApplicationSharedPtr app, smart_objects::SmartObject& out_params) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK_OR_RETURN(app, false);
+
+ LOG4CXX_DEBUG(logger_, "Generate default VRHelp data");
+ const DataAccessor<CommandsMap> accessor = app->commands_map();
+ const CommandsMap& cmdMap = accessor.GetData();
+
+ int32_t index = 0;
+ smart_objects::SmartObject vr_help_items;
+ for (CommandsMap::const_iterator command_it = cmdMap.begin();
+ cmdMap.end() != command_it;
+ ++command_it) {
+ const smart_objects::SmartObject& command = *command_it->second;
+ if (!command.keyExists(strings::vr_commands)) {
+ LOG4CXX_ERROR(logger_, "VR synonyms are empty");
+ return false;
}
+ // use only first
+ vr_help_items[index][strings::position] = (index + 1);
+ vr_help_items[index++][strings::text] =
+ (*command_it->second)[strings::vr_commands][0];
+ }
+
+ app->set_vr_help_title(smart_objects::SmartObject(app->name()));
+
+ out_params[strings::vr_help_title] = (*app->vr_help_title());
+ if (vr_help_items.length() > 0) {
+ app->set_vr_help(vr_help_items);
+ out_params[strings::vr_help] = (*app->vr_help());
}
+ return true;
}
-bool SetGlobalPropertiesRequest::IsPendingResponseExist() {
+void SetGlobalPropertiesRequest::PrepareUIRequestMenuAndKeyboardData(
+ const ApplicationSharedPtr app,
+ const smart_objects::SmartObject& msg_params,
+ smart_objects::SmartObject& out_params) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK_OR_RETURN_VOID(app);
+
+ const bool is_menu_title_present =
+ msg_params.keyExists(hmi_request::menu_title);
+ const bool is_menu_icon_present =
+ msg_params.keyExists(hmi_request::menu_icon);
+ const bool is_keyboard_props_present =
+ msg_params.keyExists(hmi_request::keyboard_properties);
+
+ if (is_menu_title_present) {
+ out_params[hmi_request::menu_title] =
+ msg_params[hmi_request::menu_title].asString();
+ app->set_menu_title(msg_params[hmi_request::menu_title]);
+ }
+ if (is_menu_icon_present) {
+ out_params[hmi_request::menu_icon] = msg_params[hmi_request::menu_icon];
+ app->set_menu_icon(msg_params[hmi_request::menu_icon]);
+ }
+ if (is_keyboard_props_present) {
+ out_params[hmi_request::keyboard_properties] =
+ msg_params[hmi_request::keyboard_properties];
+ app->set_keyboard_props(msg_params[hmi_request::keyboard_properties]);
+ }
+}
+
+void SetGlobalPropertiesRequest::SendTTSRequest(
+ const smart_objects::SmartObject& params, bool use_events) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ SendHMIRequest(
+ hmi_apis::FunctionID::TTS_SetGlobalProperties, &params, use_events);
+ is_tts_send_ = true;
+}
+
+void SetGlobalPropertiesRequest::SendUIRequest(
+ const smart_objects::SmartObject& params, bool use_events) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ SendHMIRequest(
+ hmi_apis::FunctionID::UI_SetGlobalProperties, &params, use_events);
+ is_ui_send_ = true;
+}
+bool SetGlobalPropertiesRequest::IsPendingResponseExist() {
return is_ui_send_ != is_ui_received_ || is_tts_send_ != is_tts_received_;
}
bool SetGlobalPropertiesRequest::ValidateConditionalMandatoryParameters(
const smart_objects::SmartObject& params) {
- return params.keyExists(strings::help_prompt)
- || params.keyExists(strings::timeout_prompt)
- || params.keyExists(strings::vr_help_title)
- || params.keyExists(strings::vr_help)
- || params.keyExists(strings::menu_title)
- || params.keyExists(strings::menu_icon)
- || params.keyExists(strings::keyboard_properties);
+ LOG4CXX_AUTO_TRACE(logger_);
+ return params.keyExists(strings::help_prompt) ||
+ params.keyExists(strings::timeout_prompt) ||
+ params.keyExists(strings::vr_help_title) ||
+ params.keyExists(strings::vr_help) ||
+ params.keyExists(strings::menu_title) ||
+ params.keyExists(strings::menu_icon) ||
+ params.keyExists(strings::keyboard_properties);
}
bool SetGlobalPropertiesRequest::IsWhiteSpaceExist() {
@@ -449,12 +483,11 @@ bool SetGlobalPropertiesRequest::IsWhiteSpaceExist() {
str = (*it_vh)[strings::image][strings::value].asCharArray();
if (!CheckSyntax(str)) {
LOG4CXX_ERROR(logger_,
- "Invalid vr_help image value syntax check failed");
+ "Invalid vr_help image value syntax check failed");
return true;
}
- }
-
- }
+ } // if image exists
+ } // for - vh_array iteration
}
if (msg_params.keyExists(strings::menu_icon)) {
@@ -481,14 +514,12 @@ bool SetGlobalPropertiesRequest::IsWhiteSpaceExist() {
}
}
-
if (msg_params.keyExists(strings::keyboard_properties)) {
- if (msg_params[strings::keyboard_properties].
- keyExists(strings::limited_character_list)) {
-
+ if (msg_params[strings::keyboard_properties].keyExists(
+ strings::limited_character_list)) {
const smart_objects::SmartArray* lcl_array =
msg_params[strings::keyboard_properties]
- [strings::limited_character_list].asArray();
+ [strings::limited_character_list].asArray();
smart_objects::SmartArray::const_iterator it_lcl = lcl_array->begin();
smart_objects::SmartArray::const_iterator it_lcl_end = lcl_array->end();
@@ -496,30 +527,30 @@ bool SetGlobalPropertiesRequest::IsWhiteSpaceExist() {
for (; it_lcl != it_lcl_end; ++it_lcl) {
str = (*it_lcl).asCharArray();
if (!CheckSyntax(str)) {
- LOG4CXX_ERROR(logger_, "Invalid keyboard_properties "
- "limited_character_list syntax check failed");
+ LOG4CXX_ERROR(logger_,
+ "Invalid keyboard_properties "
+ "limited_character_list syntax check failed");
return true;
}
}
}
- if (msg_params[strings::keyboard_properties].
- keyExists(strings::auto_complete_text)) {
-
- str = msg_params[strings::keyboard_properties]
- [strings::auto_complete_text].asCharArray();
+ if (msg_params[strings::keyboard_properties].keyExists(
+ strings::auto_complete_text)) {
+ str =
+ msg_params[strings::keyboard_properties][strings::auto_complete_text]
+ .asCharArray();
if (!CheckSyntax(str)) {
- LOG4CXX_ERROR(logger_, "Invalid keyboard_properties "
- "auto_complete_text syntax check failed");
+ LOG4CXX_ERROR(logger_,
+ "Invalid keyboard_properties "
+ "auto_complete_text syntax check failed");
return true;
}
}
-
}
return false;
}
} // namespace commands
-
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/set_global_properties_response.cc b/src/components/application_manager/src/commands/mobile/set_global_properties_response.cc
index 759333385d..5cfbcb2d58 100644
--- a/src/components/application_manager/src/commands/mobile/set_global_properties_response.cc
+++ b/src/components/application_manager/src/commands/mobile/set_global_properties_response.cc
@@ -32,25 +32,21 @@
*/
#include "application_manager/commands/mobile/set_global_properties_response.h"
-#include "application_manager/application_manager_impl.h"
-
namespace application_manager {
namespace commands {
SetGlobalPropertiesResponse::SetGlobalPropertiesResponse(
- const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-SetGlobalPropertiesResponse::~SetGlobalPropertiesResponse() {
-}
+SetGlobalPropertiesResponse::~SetGlobalPropertiesResponse() {}
void SetGlobalPropertiesResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
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 4b06730752..85f34aead9 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
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/set_icon_request.h"
-#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_manager.h"
#include "application_manager/application_impl.h"
#include "config_profile/profile.h"
#include "interfaces/MOBILE_API.h"
@@ -43,18 +43,16 @@ namespace application_manager {
namespace commands {
-SetIconRequest::SetIconRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+SetIconRequest::SetIconRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
-SetIconRequest::~SetIconRequest() {
-}
+SetIconRequest::~SetIconRequest() {}
void SetIconRequest::Run() {
- LOG4CXX_INFO(logger_, "SetIconRequest::Run");
+ LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()->application(connection_key());
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
LOG4CXX_ERROR(logger_, "Application is not registered");
@@ -66,7 +64,7 @@ void SetIconRequest::Run() {
(*message_)[strings::msg_params][strings::sync_file_name].asString();
std::string full_file_path =
- profile::Profile::instance()->app_storage_folder() + "/";
+ application_manager_.get_settings().app_storage_folder() + "/";
full_file_path += app->folder_name();
full_file_path += "/";
full_file_path += sync_file_name;
@@ -77,22 +75,22 @@ void SetIconRequest::Run() {
return;
}
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_params[strings::app_id] = app->app_id();
- msg_params[strings::sync_file_name] = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ msg_params[strings::sync_file_name] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
-// Panasonic requres unchanged path value without encoded special characters
- const std::string full_file_path_for_hmi = file_system::ConvertPathForURL(
- full_file_path);
+ // Panasonic requres unchanged path value without encoded special characters
+ const std::string full_file_path_for_hmi =
+ file_system::ConvertPathForURL(full_file_path);
msg_params[strings::sync_file_name][strings::value] = full_file_path_for_hmi;
// TODO(VS): research why is image_type hardcoded
msg_params[strings::sync_file_name][strings::image_type] =
- static_cast<int32_t> (SetIconRequest::ImageType::DYNAMIC);
+ static_cast<int32_t>(SetIconRequest::ImageType::DYNAMIC);
// for further use in on_event function
(*message_)[strings::msg_params][strings::sync_file_name] =
@@ -102,7 +100,7 @@ void SetIconRequest::Run() {
}
void SetIconRequest::on_event(const event_engine::Event& event) {
- LOG4CXX_INFO(logger_, "SetIconRequest::on_event");
+ LOG4CXX_AUTO_TRACE(logger_);
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
@@ -115,11 +113,11 @@ void SetIconRequest::on_event(const event_engine::Event& event) {
if (result) {
ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()->application(connection_key());
+ application_manager_.application(connection_key());
- const std::string path = (*message_)[strings::msg_params]
- [strings::sync_file_name]
- [strings::value].asString();
+ const std::string path =
+ (*message_)[strings::msg_params][strings::sync_file_name]
+ [strings::value].asString();
app->set_app_icon_path(path);
LOG4CXX_INFO(logger_,
diff --git a/src/components/application_manager/src/commands/mobile/set_icon_response.cc b/src/components/application_manager/src/commands/mobile/set_icon_response.cc
index f1580823d1..c140d04f51 100644
--- a/src/components/application_manager/src/commands/mobile/set_icon_response.cc
+++ b/src/components/application_manager/src/commands/mobile/set_icon_response.cc
@@ -32,23 +32,22 @@
*/
#include "application_manager/commands/mobile/set_icon_response.h"
-#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_manager.h"
namespace application_manager {
namespace commands {
-SetIconResponse::SetIconResponse(const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+SetIconResponse::SetIconResponse(const MessageSharedPtr& message,
+ ApplicationManager& app_man)
+ : CommandResponseImpl(message, app_man) {}
-SetIconResponse::~SetIconResponse() {
-}
+SetIconResponse::~SetIconResponse() {}
void SetIconResponse::Run() {
- LOG4CXX_INFO(logger_, "SetIconResponse::Run");
+ LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
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 536bb755ed..a198ce63c3 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
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/set_media_clock_timer_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "interfaces/MOBILE_API.h"
#include "interfaces/HMI_API.h"
@@ -41,18 +41,16 @@ namespace application_manager {
namespace commands {
-SetMediaClockRequest::SetMediaClockRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+SetMediaClockRequest::SetMediaClockRequest(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
-SetMediaClockRequest::~SetMediaClockRequest() {
-}
+SetMediaClockRequest::~SetMediaClockRequest() {}
void SetMediaClockRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()->application(connection_key());
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
@@ -67,14 +65,14 @@ void SetMediaClockRequest::Run() {
}
if (isDataValid()) {
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
// copy entirely msg
msg_params = (*message_)[strings::msg_params];
msg_params[strings::app_id] = app->app_id();
- SendHMIRequest(hmi_apis::FunctionID::UI_SetMediaClockTimer,
- &msg_params, true);
+ SendHMIRequest(
+ hmi_apis::FunctionID::UI_SetMediaClockTimer, &msg_params, true);
} else {
SendResponse(false, mobile_apis::Result::INVALID_DATA);
}
@@ -110,7 +108,6 @@ bool SetMediaClockRequest::isDataValid() {
if (update_mode == mobile_apis::UpdateMode::COUNTUP ||
update_mode == mobile_apis::UpdateMode::COUNTDOWN) {
-
if (!msg_params.keyExists(strings::start_time)) {
LOG4CXX_INFO(logger_, "Invalid data");
return false;
@@ -134,9 +131,9 @@ bool SetMediaClockRequest::isDataValid() {
(msg_params[strings::end_time][strings::seconds].asUInt());
if (((end_time_in_seconds > start_time_in_seconds) &&
- (update_mode == mobile_apis::UpdateMode::COUNTDOWN)) ||
+ (update_mode == mobile_apis::UpdateMode::COUNTDOWN)) ||
((end_time_in_seconds < start_time_in_seconds) &&
- (update_mode == mobile_apis::UpdateMode::COUNTUP))) {
+ (update_mode == mobile_apis::UpdateMode::COUNTUP))) {
LOG4CXX_INFO(logger_, "Invalid data");
return false;
}
diff --git a/src/components/application_manager/src/commands/mobile/set_media_clock_timer_response.cc b/src/components/application_manager/src/commands/mobile/set_media_clock_timer_response.cc
index da6f204da4..30e802a1db 100644
--- a/src/components/application_manager/src/commands/mobile/set_media_clock_timer_response.cc
+++ b/src/components/application_manager/src/commands/mobile/set_media_clock_timer_response.cc
@@ -32,24 +32,21 @@
*/
#include "application_manager/commands/mobile/set_media_clock_timer_response.h"
-#include "application_manager/application_manager_impl.h"
namespace application_manager {
namespace commands {
SetMediaClockTimerResponse::SetMediaClockTimerResponse(
- const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-SetMediaClockTimerResponse::~SetMediaClockTimerResponse() {
-}
+SetMediaClockTimerResponse::~SetMediaClockTimerResponse() {}
void SetMediaClockTimerResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
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 1e861d14ce..2d79e13582 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
@@ -31,11 +31,13 @@
POSSIBILITY OF SUCH DAMAGE.
*/
-#include <string.h>
+#include <cstring>
#include "application_manager/commands/mobile/show_constant_tbt_request.h"
-#include "application_manager/application_manager_impl.h"
+
+#include "application_manager/policies/policy_handler.h"
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
+#include "application_manager/policies/policy_handler_interface.h"
#include "interfaces/MOBILE_API.h"
#include "interfaces/HMI_API.h"
@@ -43,17 +45,16 @@ namespace application_manager {
namespace commands {
-ShowConstantTBTRequest::ShowConstantTBTRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+ShowConstantTBTRequest::ShowConstantTBTRequest(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
-ShowConstantTBTRequest::~ShowConstantTBTRequest() {
-}
+ShowConstantTBTRequest::~ShowConstantTBTRequest() {}
void ShowConstantTBTRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ ApplicationSharedPtr app = application_manager_.application(
(*message_)[strings::params][strings::connection_key].asUInt());
if (!app) {
@@ -68,8 +69,8 @@ void ShowConstantTBTRequest::Run() {
return;
}
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_params = (*message_)[strings::msg_params];
if (IsWhiteSpaceExist()) {
@@ -79,10 +80,13 @@ void ShowConstantTBTRequest::Run() {
return;
}
- //ProcessSoftButtons checks strings on the contents incorrect character
+ // ProcessSoftButtons checks strings on the contents incorrect character
mobile_apis::Result::eType processing_result =
- MessageHelper::ProcessSoftButtons(msg_params, app);
+ MessageHelper::ProcessSoftButtons(msg_params,
+ app,
+ application_manager_.GetPolicyHandler(),
+ application_manager_);
if (mobile_apis::Result::SUCCESS != processing_result) {
LOG4CXX_ERROR(logger_, "INVALID_DATA!");
@@ -90,12 +94,10 @@ void ShowConstantTBTRequest::Run() {
return;
}
-
- mobile_apis::Result::eType verification_result =
- mobile_apis::Result::SUCCESS;
+ mobile_apis::Result::eType verification_result = mobile_apis::Result::SUCCESS;
if (msg_params.keyExists(strings::turn_icon)) {
verification_result = MessageHelper::VerifyImage(
- msg_params[strings::turn_icon], app);
+ msg_params[strings::turn_icon], app, application_manager_);
if (mobile_apis::Result::SUCCESS != verification_result) {
LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!");
SendResponse(false, verification_result);
@@ -105,7 +107,7 @@ void ShowConstantTBTRequest::Run() {
if (msg_params.keyExists(strings::next_turn_icon)) {
verification_result = MessageHelper::VerifyImage(
- msg_params[strings::next_turn_icon], app);
+ msg_params[strings::next_turn_icon], app, application_manager_);
if (mobile_apis::Result::SUCCESS != verification_result) {
LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!");
SendResponse(false, verification_result);
@@ -115,8 +117,8 @@ void ShowConstantTBTRequest::Run() {
msg_params[strings::app_id] = app->app_id();
- msg_params[hmi_request::navi_texts] = smart_objects::SmartObject(
- smart_objects::SmartType_Array);
+ msg_params[hmi_request::navi_texts] =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
int32_t index = 0;
if (msg_params.keyExists(strings::navigation_text_1)) {
@@ -156,24 +158,24 @@ void ShowConstantTBTRequest::Run() {
}
if (msg_params.keyExists(strings::time_to_destination)) {
- // erase useless param
- msg_params.erase(strings::time_to_destination);
- msg_params[hmi_request::navi_texts][index][hmi_request::field_name] =
- static_cast<int32_t>(hmi_apis::Common_TextFieldName::timeToDestination);
- msg_params[hmi_request::navi_texts][index++][hmi_request::field_text] =
- (*message_)[strings::msg_params][strings::time_to_destination];
+ // erase useless param
+ msg_params.erase(strings::time_to_destination);
+ msg_params[hmi_request::navi_texts][index][hmi_request::field_name] =
+ static_cast<int32_t>(hmi_apis::Common_TextFieldName::timeToDestination);
+ msg_params[hmi_request::navi_texts][index++][hmi_request::field_text] =
+ (*message_)[strings::msg_params][strings::time_to_destination];
}
if (msg_params.keyExists(strings::soft_buttons)) {
- MessageHelper::SubscribeApplicationToSoftButton(msg_params, app, function_id());
+ MessageHelper::SubscribeApplicationToSoftButton(
+ msg_params, app, function_id());
}
app->set_tbt_show_command(msg_params);
- SendHMIRequest(hmi_apis::FunctionID::Navigation_ShowConstantTBT, &msg_params,
- true);
+ SendHMIRequest(
+ hmi_apis::FunctionID::Navigation_ShowConstantTBT, &msg_params, true);
}
-
void ShowConstantTBTRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
const smart_objects::SmartObject& message = event.smart_object();
@@ -181,25 +183,31 @@ 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");
+ std::string return_info;
mobile_apis::Result::eType result_code =
GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt()));
HMICapabilities& hmi_capabilities =
- ApplicationManagerImpl::instance()->hmi_capabilities();
+ application_manager_.hmi_capabilities();
bool result = false;
if (mobile_apis::Result::SUCCESS == result_code) {
result = true;
+ return_info =
+ message[strings::msg_params][hmi_response::message].asString();
} else if ((mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code) &&
- hmi_capabilities.is_ui_cooperating()) {
+ hmi_capabilities.is_ui_cooperating()) {
result = true;
}
- SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ SendResponse(result,
+ result_code,
+ return_info.empty() ? 0 : return_info.c_str(),
+ &(message[strings::msg_params]));
break;
}
default: {
- LOG4CXX_ERROR(logger_,"Received unknown event" << event.id());
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
break;
}
}
@@ -210,8 +218,8 @@ bool ShowConstantTBTRequest::IsWhiteSpaceExist() {
const char* str = NULL;
if ((*message_)[strings::msg_params].keyExists(strings::turn_icon)) {
- str = (*message_)[strings::msg_params]
- [strings::turn_icon][strings::value].asCharArray();
+ str = (*message_)[strings::msg_params][strings::turn_icon][strings::value]
+ .asCharArray();
if (!CheckSyntax(str)) {
LOG4CXX_ERROR(logger_, "Invalid turn_icon value syntax check failed");
return true;
@@ -219,8 +227,8 @@ bool ShowConstantTBTRequest::IsWhiteSpaceExist() {
}
if ((*message_)[strings::msg_params].keyExists(strings::next_turn_icon)) {
- str = (*message_)[strings::msg_params]
- [strings::next_turn_icon][strings::value].asCharArray();
+ str = (*message_)[strings::msg_params][strings::next_turn_icon]
+ [strings::value].asCharArray();
if (!CheckSyntax(str)) {
LOG4CXX_ERROR(logger_,
"Invalid next_turn_icon value syntax check failed");
@@ -229,8 +237,8 @@ bool ShowConstantTBTRequest::IsWhiteSpaceExist() {
}
if ((*message_)[strings::msg_params].keyExists(strings::navigation_text_1)) {
- str = (*message_)[strings::msg_params]
- [strings::navigation_text_1].asCharArray();
+ str = (*message_)[strings::msg_params][strings::navigation_text_1]
+ .asCharArray();
if (strlen(str) && !CheckSyntax(str)) {
LOG4CXX_ERROR(logger_,
"Invalid navigation_text_1 value syntax check failed");
@@ -239,8 +247,8 @@ bool ShowConstantTBTRequest::IsWhiteSpaceExist() {
}
if ((*message_)[strings::msg_params].keyExists(strings::navigation_text_2)) {
- str = (*message_)[strings::msg_params]
- [strings::navigation_text_2].asCharArray();
+ str = (*message_)[strings::msg_params][strings::navigation_text_2]
+ .asCharArray();
if (strlen(str) && !CheckSyntax(str)) {
LOG4CXX_ERROR(logger_,
"Invalid navigation_text_2 value syntax check failed");
@@ -257,8 +265,8 @@ bool ShowConstantTBTRequest::IsWhiteSpaceExist() {
}
if ((*message_)[strings::msg_params].keyExists(strings::total_distance)) {
- str = (*message_)[strings::msg_params]
- [strings::total_distance].asCharArray();
+ str =
+ (*message_)[strings::msg_params][strings::total_distance].asCharArray();
if (strlen(str) && !CheckSyntax(str)) {
LOG4CXX_ERROR(logger_,
"Invalid total_distance value syntax check failed");
@@ -266,9 +274,10 @@ bool ShowConstantTBTRequest::IsWhiteSpaceExist() {
}
}
- if ((*message_)[strings::msg_params].keyExists(strings::time_to_destination)) {
- str = (*message_)[strings::msg_params]
- [strings::time_to_destination].asCharArray();
+ if ((*message_)[strings::msg_params].keyExists(
+ strings::time_to_destination)) {
+ str = (*message_)[strings::msg_params][strings::time_to_destination]
+ .asCharArray();
if (strlen(str) && !CheckSyntax(str)) {
LOG4CXX_ERROR(logger_,
"Invalid time_to_destination value syntax check failed");
diff --git a/src/components/application_manager/src/commands/mobile/show_constant_tbt_response.cc b/src/components/application_manager/src/commands/mobile/show_constant_tbt_response.cc
index e45cd760df..80a36129cf 100644
--- a/src/components/application_manager/src/commands/mobile/show_constant_tbt_response.cc
+++ b/src/components/application_manager/src/commands/mobile/show_constant_tbt_response.cc
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/show_constant_tbt_response.h"
-#include "application_manager/application_manager_impl.h"
+
#include "interfaces/HMI_API.h"
namespace application_manager {
@@ -40,17 +40,16 @@ namespace application_manager {
namespace commands {
ShowConstantTBTResponse::ShowConstantTBTResponse(
- const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
-ShowConstantTBTResponse::~ShowConstantTBTResponse() {
-}
+ : CommandResponseImpl(message, application_manager) {}
+
+ShowConstantTBTResponse::~ShowConstantTBTResponse() {}
void ShowConstantTBTResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
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 0a136e0ac2..467d8d0236 100644
--- a/src/components/application_manager/src/commands/mobile/show_request.cc
+++ b/src/components/application_manager/src/commands/mobile/show_request.cc
@@ -30,75 +30,76 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
+#include <string.h>
#include "application_manager/commands/mobile/show_request.h"
-#include "application_manager/application_manager_impl.h"
+
+#include "application_manager/policies/policy_handler.h"
#include "application_manager/application.h"
#include "application_manager/message_helper.h"
#include "utils/file_system.h"
-
-#include <string.h>
+#include "utils/helpers.h"
namespace application_manager {
namespace commands {
-ShowRequest::ShowRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+ShowRequest::ShowRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
-ShowRequest::~ShowRequest() {
-}
+ShowRequest::~ShowRequest() {}
void ShowRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app = application_manager::ApplicationManagerImpl::instance()
- ->application(
- (*message_)[strings::params][strings::connection_key].asInt());
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
- LOG4CXX_ERROR_EXT(
- logger_, "Application is not registered");
+ LOG4CXX_ERROR(logger_, "Application is not registered");
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
return;
}
- //SDLAQ-CRS-494, VC3.1
+ // SDLAQ-CRS-494, VC3.1
if ((*message_)[strings::msg_params].empty()) {
- LOG4CXX_ERROR(logger_, "INVALID_DATA!");
+ LOG4CXX_ERROR(logger_, strings::msg_params << " is empty.");
SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
}
if (!CheckStringsOfShowRequest()) {
- LOG4CXX_ERROR(logger_, "Incorrect characters in string");
- SendResponse(false, mobile_apis::Result::INVALID_DATA);
- return;
- }
+ LOG4CXX_ERROR(logger_, "Incorrect characters in string");
+ SendResponse(false, mobile_apis::Result::INVALID_DATA);
+ return;
+ }
- //ProcessSoftButtons checks strings on the contents incorrect character
+ // ProcessSoftButtons checks strings on the contents incorrect character
mobile_apis::Result::eType processing_result = mobile_apis::Result::SUCCESS;
- if(((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) &&
+ if (((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) &&
((*message_)[strings::msg_params][strings::soft_buttons].length() > 0)) {
- processing_result =
- MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], app);
+ processing_result = MessageHelper::ProcessSoftButtons(
+ (*message_)[strings::msg_params],
+ app,
+ application_manager_.GetPolicyHandler(),
+ application_manager_);
}
if (mobile_apis::Result::SUCCESS != processing_result) {
- LOG4CXX_ERROR(logger_, "INVALID_DATA!");
+ LOG4CXX_ERROR(logger_, "Processing of soft buttons failed.");
SendResponse(false, processing_result);
return;
}
- mobile_apis::Result::eType verification_result =
- mobile_apis::Result::SUCCESS;
+ mobile_apis::Result::eType verification_result = mobile_apis::Result::SUCCESS;
if (((*message_)[strings::msg_params].keyExists(strings::graphic)) &&
- ((*message_)[strings::msg_params]
- [strings::graphic][strings::value].asString()).length()) {
+ ((*message_)[strings::msg_params][strings::graphic][strings::value]
+ .asString()).length()) {
verification_result = MessageHelper::VerifyImage(
- (*message_)[strings::msg_params][strings::graphic], app);
+ (*message_)[strings::msg_params][strings::graphic],
+ app,
+ application_manager_);
if (mobile_apis::Result::SUCCESS != verification_result) {
- LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!");
+ LOG4CXX_ERROR(logger_, "Image verification failed.");
SendResponse(false, verification_result);
return;
}
@@ -106,20 +107,22 @@ void ShowRequest::Run() {
if ((*message_)[strings::msg_params].keyExists(strings::secondary_graphic)) {
verification_result = MessageHelper::VerifyImage(
- (*message_)[strings::msg_params][strings::secondary_graphic], app);
+ (*message_)[strings::msg_params][strings::secondary_graphic],
+ app,
+ application_manager_);
if (mobile_apis::Result::SUCCESS != verification_result) {
- LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!");
+ LOG4CXX_ERROR(logger_, "Image verification failed.");
SendResponse(false, verification_result);
return;
}
}
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_params[strings::app_id] = app->app_id();
- msg_params[hmi_request::show_strings] = smart_objects::SmartObject(
- smart_objects::SmartType_Array);
+ msg_params[hmi_request::show_strings] =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
int32_t index = 0;
if ((*message_)[strings::msg_params].keyExists(strings::main_field_1)) {
@@ -190,7 +193,7 @@ void ShowRequest::Run() {
if ((*message_)[strings::msg_params].keyExists(strings::secondary_graphic)) {
msg_params[strings::secondary_graphic] =
- (*message_)[strings::msg_params][strings::secondary_graphic];
+ (*message_)[strings::msg_params][strings::secondary_graphic];
}
if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) {
@@ -217,34 +220,37 @@ void ShowRequest::Run() {
void ShowRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
+ using namespace helpers;
+
const smart_objects::SmartObject& message = event.smart_object();
switch (event.id()) {
case hmi_apis::FunctionID::UI_Show: {
- LOG4CXX_INFO(logger_, "Received UI_Show event");
- std::string response_info("");
+ LOG4CXX_DEBUG(logger_, "Received UI_Show event.");
+ std::string response_info;
mobile_apis::Result::eType result_code =
static_cast<mobile_apis::Result::eType>(
- message[strings::params][hmi_response::code].asInt());
+ message[strings::params][hmi_response::code].asInt());
- bool result = false;
+ const bool result = Compare<mobile_api::Result::eType, EQ, ONE>(
+ result_code,
+ mobile_api::Result::SUCCESS,
+ mobile_api::Result::WARNINGS);
- if (mobile_apis::Result::SUCCESS == result_code) {
- result = true;
- } else if (mobile_apis::Result::WARNINGS == result_code) {
- result = true;
- if (message[strings::params].keyExists(hmi_response::message)) {
- response_info = message[strings::params][hmi_response::message].asString();
- }
+ if (mobile_apis::Result::WARNINGS == result_code &&
+ message[strings::params].keyExists(hmi_response::message)) {
+ response_info =
+ message[strings::params][hmi_response::message].asString();
}
- SendResponse(result, result_code,
+ SendResponse(result,
+ result_code,
response_info.empty() ? NULL : response_info.c_str(),
- &(message[strings::msg_params]));
+ &(message[strings::msg_params]));
break;
}
default: {
- LOG4CXX_ERROR(logger_,"Received unknown event" << event.id());
+ LOG4CXX_ERROR(logger_, "Received unknown event " << event.id());
break;
}
}
@@ -258,7 +264,7 @@ bool ShowRequest::CheckStringsOfShowRequest() {
str = (*message_)[strings::msg_params][strings::main_field_4].asCharArray();
if (strlen(str) && !CheckSyntax(str)) {
LOG4CXX_ERROR(logger_, "Invalid main_field_4 syntax check failed");
- return false;
+ return false;
}
}
if ((*message_)[strings::msg_params].keyExists(strings::main_field_3)) {
@@ -304,20 +310,20 @@ bool ShowRequest::CheckStringsOfShowRequest() {
}
}
if ((*message_)[strings::msg_params].keyExists(strings::custom_presets)) {
- smart_objects::SmartObject& custom_presets_array =
- (*message_)[strings::msg_params][strings::custom_presets];
- for (size_t i = 0; i < custom_presets_array.length(); ++i) {
- str = custom_presets_array[i].asCharArray();
- if (!CheckSyntax(str)) {
- LOG4CXX_ERROR(logger_, "Invalid custom_presets syntax check failed");
- return false;
- }
+ smart_objects::SmartObject& custom_presets_array =
+ (*message_)[strings::msg_params][strings::custom_presets];
+ for (size_t i = 0; i < custom_presets_array.length(); ++i) {
+ str = custom_presets_array[i].asCharArray();
+ if (!CheckSyntax(str)) {
+ LOG4CXX_ERROR(logger_, "Invalid custom_presets syntax check failed");
+ return false;
}
+ }
}
if ((*message_)[strings::msg_params].keyExists(strings::graphic)) {
- str = (*message_)[strings::msg_params]
- [strings::graphic][strings::value].asCharArray();
+ str = (*message_)[strings::msg_params][strings::graphic][strings::value]
+ .asCharArray();
if (strlen(str) && !CheckSyntax(str)) {
LOG4CXX_ERROR(logger_, "Invalid graphic value syntax check failed");
return false;
@@ -325,11 +331,11 @@ bool ShowRequest::CheckStringsOfShowRequest() {
}
if ((*message_)[strings::msg_params].keyExists(strings::secondary_graphic)) {
- str = (*message_)[strings::msg_params]
- [strings::secondary_graphic][strings::value].asCharArray();
+ str = (*message_)[strings::msg_params][strings::secondary_graphic]
+ [strings::value].asCharArray();
if (!CheckSyntax(str)) {
LOG4CXX_ERROR(logger_,
- "Invalid secondary_graphic value syntax check failed");
+ "Invalid secondary_graphic value syntax check failed");
return false;
}
}
diff --git a/src/components/application_manager/src/commands/mobile/show_response.cc b/src/components/application_manager/src/commands/mobile/show_response.cc
index 0c46cdd83c..8027c908f1 100644
--- a/src/components/application_manager/src/commands/mobile/show_response.cc
+++ b/src/components/application_manager/src/commands/mobile/show_response.cc
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/show_response.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "interfaces/HMI_API.h"
@@ -40,17 +40,16 @@ namespace application_manager {
namespace commands {
-ShowResponse::ShowResponse(const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+ShowResponse::ShowResponse(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-ShowResponse::~ShowResponse() {
-}
+ShowResponse::~ShowResponse() {}
void ShowResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
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 c46311c667..3920b49db3 100644
--- a/src/components/application_manager/src/commands/mobile/slider_request.cc
+++ b/src/components/application_manager/src/commands/mobile/slider_request.cc
@@ -32,28 +32,30 @@
*/
#include "application_manager/commands/mobile/slider_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
+#include "application_manager/message_helper.h"
+#include "utils/helpers.h"
#include "config_profile/profile.h"
namespace application_manager {
namespace commands {
-SliderRequest::SliderRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
+SliderRequest::SliderRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {
subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout);
}
-SliderRequest::~SliderRequest() {
-}
+SliderRequest::~SliderRequest() {}
bool SliderRequest::Init() {
-
/* Timeout in milliseconds.
If omitted a standard value of 10000 milliseconds is used.*/
if ((*message_)[strings::msg_params].keyExists(strings::timeout)) {
- default_timeout_ = profile::Profile::instance()->default_timeout() +
+ default_timeout_ =
+ application_manager_.get_settings().default_timeout() +
(*message_)[strings::msg_params][strings::timeout].asUInt();
}
@@ -63,9 +65,8 @@ bool SliderRequest::Init() {
void SliderRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr application =
- application_manager::ApplicationManagerImpl::instance()->application(
- (*message_)[strings::params][strings::connection_key].asUInt());
+ ApplicationSharedPtr application = application_manager_.application(
+ (*message_)[strings::params][strings::connection_key].asUInt());
if (!application) {
LOG4CXX_ERROR(logger_, "Application is not registered");
@@ -73,8 +74,8 @@ void SliderRequest::Run() {
return;
}
- if ((*message_)[strings::msg_params][strings::num_ticks].asInt()
- < (*message_)[strings::msg_params][strings::position].asInt()) {
+ if ((*message_)[strings::msg_params][strings::num_ticks].asInt() <
+ (*message_)[strings::msg_params][strings::position].asInt()) {
LOG4CXX_ERROR(logger_, "INVALID_DATA");
SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
@@ -82,9 +83,8 @@ void SliderRequest::Run() {
if ((*message_)[strings::msg_params].keyExists(strings::slider_footer)) {
if (1 < (*message_)[strings::msg_params][strings::slider_footer].length()) {
- if ((*message_)[strings::msg_params][strings::num_ticks].asUInt()
- != (*message_)[strings::msg_params]
- [strings::slider_footer].length()) {
+ if ((*message_)[strings::msg_params][strings::num_ticks].asUInt() !=
+ (*message_)[strings::msg_params][strings::slider_footer].length()) {
LOG4CXX_ERROR(logger_, "INVALID_DATA");
SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
@@ -98,8 +98,8 @@ void SliderRequest::Run() {
return;
}
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_params = (*message_)[strings::msg_params];
msg_params[strings::app_id] = application->app_id();
@@ -112,46 +112,60 @@ void SliderRequest::Run() {
void SliderRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
- const smart_objects::SmartObject& message = event.smart_object();
+ using namespace helpers;
+ using namespace smart_objects;
+ using namespace hmi_apis;
+
+ const SmartObject& message = event.smart_object();
const event_engine::Event::EventID event_id = event.id();
- if (event_id == hmi_apis::FunctionID::UI_OnResetTimeout) {
+ if (event_id == FunctionID::UI_OnResetTimeout) {
LOG4CXX_INFO(logger_, "Received UI_OnResetTimeout event");
- ApplicationManagerImpl::instance()->updateRequestTimeout(connection_key(),
- correlation_id(),
- default_timeout());
+ application_manager_.updateRequestTimeout(
+ connection_key(), correlation_id(), default_timeout());
return;
}
- if (event_id != hmi_apis::FunctionID::UI_Slider) {
+
+ if (event_id != FunctionID::UI_Slider) {
LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
return;
}
- //event_id == hmi_apis::FunctionID::UI_Slider:
- LOG4CXX_INFO(logger_, "Received UI_Slider event");
-
- const mobile_apis::Result::eType response_code =
- static_cast<mobile_apis::Result::eType>(
- message[strings::params][hmi_response::code].asInt());
- smart_objects::SmartObject response_msg_params = message[strings::msg_params];
- if (response_code == mobile_apis::Result::ABORTED &&
- message[strings::params][strings::data].keyExists(strings::slider_position)) {
- //Copy slider_position info to msg_params section
- response_msg_params[strings::slider_position] =
- message[strings::params][strings::data][strings::slider_position];
+ LOG4CXX_DEBUG(logger_, "Received UI_Slider event");
+
+ const Common_Result::eType response_code = static_cast<Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+
+ SmartObject response_msg_params = message[strings::msg_params];
+
+ const bool is_timeout_aborted = Compare<Common_Result::eType, EQ, ONE>(
+ response_code, Common_Result::TIMED_OUT, Common_Result::ABORTED);
+
+ if (is_timeout_aborted) {
+ if (message[strings::params][strings::data].keyExists(
+ strings::slider_position)) {
+ // Copy slider_position info to msg_params section
+ response_msg_params[strings::slider_position] =
+ message[strings::params][strings::data][strings::slider_position];
+ } else {
+ LOG4CXX_ERROR(logger_,
+ strings::slider_position << " field is absent"
+ " in response.");
+ response_msg_params[strings::slider_position] = 0;
+ }
}
- const bool is_response_success =
- (mobile_apis::Result::SUCCESS == response_code);
+ const bool is_response_success = Compare<Common_Result::eType, EQ, ONE>(
+ response_code, Common_Result::SUCCESS, Common_Result::WARNINGS);
SendResponse(is_response_success,
- mobile_apis::Result::eType(response_code),
+ MessageHelper::HMIToMobileResult(response_code),
0,
&response_msg_params);
}
bool SliderRequest::IsWhiteSpaceExist() {
- LOG4CXX_INFO(logger_, "PerformAudioPassThruRequest::IsWhiteSpaceExist");
+ LOG4CXX_AUTO_TRACE(logger_);
const char* str = NULL;
str = (*message_)[strings::msg_params][strings::slider_header].asCharArray();
@@ -180,4 +194,3 @@ bool SliderRequest::IsWhiteSpaceExist() {
} // namespace commands
} // namespace application_manager
-
diff --git a/src/components/application_manager/src/commands/mobile/slider_response.cc b/src/components/application_manager/src/commands/mobile/slider_response.cc
index 7f0c10b068..2cfcaf48fd 100644
--- a/src/components/application_manager/src/commands/mobile/slider_response.cc
+++ b/src/components/application_manager/src/commands/mobile/slider_response.cc
@@ -32,23 +32,21 @@
*/
#include "application_manager/commands/mobile/slider_response.h"
-#include "application_manager/application_manager_impl.h"
namespace application_manager {
namespace commands {
-SliderResponse::SliderResponse(const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+SliderResponse::SliderResponse(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-SliderResponse::~SliderResponse() {
-}
+SliderResponse::~SliderResponse() {}
void SliderResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
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 894b97ea9b..01db47909b 100644
--- a/src/components/application_manager/src/commands/mobile/speak_request.cc
+++ b/src/components/application_manager/src/commands/mobile/speak_request.cc
@@ -33,29 +33,30 @@
#include <string.h>
#include "application_manager/commands/mobile/speak_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
+#include "application_manager/message_helper.h"
+#include "utils/helpers.h"
namespace application_manager {
namespace commands {
-SpeakRequest::SpeakRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
+SpeakRequest::SpeakRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {
subscribe_on_event(hmi_apis::FunctionID::TTS_OnResetTimeout);
}
-SpeakRequest::~SpeakRequest() {
-}
+SpeakRequest::~SpeakRequest() {}
void SpeakRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app = application_manager::ApplicationManagerImpl::instance()
- ->application(connection_key());
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
- LOG4CXX_ERROR_EXT(logger_, "NULL pointer");
+ LOG4CXX_ERROR(logger_, "NULL pointer");
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
return;
}
@@ -72,7 +73,8 @@ void SpeakRequest::Run() {
(*message_)[strings::msg_params][hmi_request::speak_type] =
hmi_apis::Common_MethodName::SPEAK;
SendHMIRequest(hmi_apis::FunctionID::TTS_Speak,
- &message_->getElement(strings::msg_params), true);
+ &message_->getElement(strings::msg_params),
+ true);
}
void SpeakRequest::on_event(const event_engine::Event& event) {
@@ -87,7 +89,7 @@ void SpeakRequest::on_event(const event_engine::Event& event) {
case hmi_apis::FunctionID::TTS_OnResetTimeout: {
LOG4CXX_INFO(logger_, "Received TTS_OnResetTimeout event");
- ApplicationManagerImpl::instance()->updateRequestTimeout(
+ application_manager_.updateRequestTimeout(
connection_key(), correlation_id(), default_timeout());
break;
}
@@ -99,35 +101,45 @@ void SpeakRequest::on_event(const event_engine::Event& event) {
}
void SpeakRequest::ProcessTTSSpeakResponse(
- const smart_objects::SmartObject& message) {
+ const smart_objects::SmartObject& message) {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(
- connection_key());
+ using namespace helpers;
+
+ ApplicationSharedPtr application =
+ application_manager_.application(connection_key());
if (!application) {
LOG4CXX_ERROR(logger_, "NULL pointer");
return;
}
- bool result = false;
+ hmi_apis::Common_Result::eType hmi_result_code =
+ static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+
mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(
- message[strings::params][hmi_response::code].asInt());
- if (mobile_apis::Result::SUCCESS == result_code) {
- result = true;
- }
+ MessageHelper::HMIToMobileResult(hmi_result_code);
+
+ const bool result = Compare<mobile_api::Result::eType, EQ, ONE>(
+ result_code, mobile_api::Result::SUCCESS, mobile_api::Result::WARNINGS);
+
(*message_)[strings::params][strings::function_id] =
- mobile_apis::FunctionID::SpeakID;
+ mobile_apis::FunctionID::SpeakID;
const char* return_info = NULL;
- if (mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code) {
+ const bool is_result_ok = Compare<mobile_api::Result::eType, EQ, ONE>(
+ result_code,
+ mobile_api::Result::UNSUPPORTED_RESOURCE,
+ mobile_api::Result::WARNINGS);
+
+ if (is_result_ok) {
result_code = mobile_apis::Result::WARNINGS;
return_info = "Unsupported phoneme type sent in a prompt";
}
- SendResponse(result, static_cast<mobile_apis::Result::eType>(result_code),
- return_info, &(message[strings::msg_params]));
+ SendResponse(
+ result, result_code, return_info, &(message[strings::msg_params]));
}
bool SpeakRequest::IsWhiteSpaceExist() {
diff --git a/src/components/application_manager/src/commands/mobile/speak_response.cc b/src/components/application_manager/src/commands/mobile/speak_response.cc
index d99b1d0952..612d32c913 100644
--- a/src/components/application_manager/src/commands/mobile/speak_response.cc
+++ b/src/components/application_manager/src/commands/mobile/speak_response.cc
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/speak_response.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "interfaces/HMI_API.h"
@@ -40,17 +40,16 @@ namespace application_manager {
namespace commands {
-SpeakResponse::SpeakResponse(const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+SpeakResponse::SpeakResponse(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-SpeakResponse::~SpeakResponse() {
-}
+SpeakResponse::~SpeakResponse() {}
void SpeakResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc
index 22bc57620a..7ec4e20fbd 100644
--- a/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc
+++ b/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc
@@ -32,7 +32,6 @@
*/
#include "application_manager/commands/mobile/subscribe_button_request.h"
-#include "application_manager/application_manager_impl.h"
namespace application_manager {
@@ -40,21 +39,19 @@ namespace commands {
namespace str = strings;
-SubscribeButtonRequest::SubscribeButtonRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+SubscribeButtonRequest::SubscribeButtonRequest(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
-SubscribeButtonRequest::~SubscribeButtonRequest() {
-}
+SubscribeButtonRequest::~SubscribeButtonRequest() {}
void SubscribeButtonRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()->application(connection_key());
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
- LOG4CXX_ERROR_EXT(logger_, "APPLICATION_NOT_REGISTERED");
+ LOG4CXX_ERROR(logger_, "APPLICATION_NOT_REGISTERED");
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
return;
}
@@ -64,21 +61,22 @@ void SubscribeButtonRequest::Run() {
(*message_)[str::msg_params][str::button_name].asUInt());
if (!IsSubscriptionAllowed(app, btn_id)) {
- LOG4CXX_ERROR_EXT(logger_, "Subscribe on button " << btn_id
- << " isn't allowed");
+ LOG4CXX_ERROR(logger_,
+ "Subscribe on button " << btn_id << " isn't allowed");
SendResponse(false, mobile_apis::Result::REJECTED);
return;
}
if (!CheckHMICapabilities(btn_id)) {
- LOG4CXX_ERROR_EXT(logger_, "Subscribe on button " << btn_id
- << " isn't allowed by HMI capabilities");
+ LOG4CXX_ERROR(logger_,
+ "Subscribe on button "
+ << btn_id << " isn't allowed by HMI capabilities");
SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE);
return;
}
if (app->IsSubscribedToButton(btn_id)) {
- LOG4CXX_ERROR_EXT(logger_, "Already subscribed to button " << btn_id);
+ LOG4CXX_ERROR(logger_, "Already subscribed to button " << btn_id);
SendResponse(false, mobile_apis::Result::IGNORED);
return;
}
@@ -96,11 +94,10 @@ void SubscribeButtonRequest::Run() {
bool SubscribeButtonRequest::IsSubscriptionAllowed(
ApplicationSharedPtr app, mobile_apis::ButtonName::eType btn_id) {
-
if (!app->is_media_application() &&
((mobile_apis::ButtonName::SEEKLEFT == btn_id) ||
- (mobile_apis::ButtonName::SEEKRIGHT == btn_id)||
- (mobile_apis::ButtonName::TUNEUP == btn_id) ||
+ (mobile_apis::ButtonName::SEEKRIGHT == btn_id) ||
+ (mobile_apis::ButtonName::TUNEUP == btn_id) ||
(mobile_apis::ButtonName::TUNEDOWN == btn_id))) {
return false;
}
@@ -114,12 +111,9 @@ bool SubscribeButtonRequest::CheckHMICapabilities(
using namespace mobile_apis;
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl* app_mgr = ApplicationManagerImpl::instance();
- DCHECK_OR_RETURN(app_mgr, false);
-
- const HMICapabilities& hmi_caps = app_mgr->hmi_capabilities();
+ const HMICapabilities& hmi_caps = application_manager_.hmi_capabilities();
if (!hmi_caps.is_ui_cooperating()) {
- LOG4CXX_ERROR_EXT(logger_, "UI is not supported by HMI.");
+ LOG4CXX_ERROR(logger_, "UI is not supported by HMI.");
return false;
}
@@ -129,8 +123,8 @@ bool SubscribeButtonRequest::CheckHMICapabilities(
const size_t length = button_caps.length();
for (size_t i = 0; i < length; ++i) {
const SmartObject& caps = button_caps[i];
- const ButtonName::eType name =
- static_cast<ButtonName::eType>(caps.getElement(hmi_response::button_name).asInt());
+ const ButtonName::eType name = static_cast<ButtonName::eType>(
+ caps.getElement(hmi_response::button_name).asInt());
if (name == button) {
return true;
}
diff --git a/src/components/application_manager/src/commands/mobile/subscribe_button_response.cc b/src/components/application_manager/src/commands/mobile/subscribe_button_response.cc
index a3452ef19f..a92e58b19a 100644
--- a/src/components/application_manager/src/commands/mobile/subscribe_button_response.cc
+++ b/src/components/application_manager/src/commands/mobile/subscribe_button_response.cc
@@ -38,12 +38,10 @@ namespace application_manager {
namespace commands {
SubscribeButtonResponse::SubscribeButtonResponse(
- const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-SubscribeButtonResponse::~SubscribeButtonResponse() {
-}
+SubscribeButtonResponse::~SubscribeButtonResponse() {}
void SubscribeButtonResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
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 a22f7c0dda..485c5d0009 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
@@ -32,62 +32,77 @@
*/
#include "application_manager/commands/mobile/subscribe_vehicle_data_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
+#include "utils/helpers.h"
namespace application_manager {
namespace commands {
SubscribeVehicleDataRequest::SubscribeVehicleDataRequest(
- const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
-SubscribeVehicleDataRequest::~SubscribeVehicleDataRequest() {
-}
+SubscribeVehicleDataRequest::~SubscribeVehicleDataRequest() {}
#ifdef HMI_DBUS_API
namespace {
- struct Subrequest {
- hmi_apis::FunctionID::eType func_id;
- const char* str;
- };
- Subrequest subrequests[] = {
- { hmi_apis::FunctionID::VehicleInfo_SubscribeGps, strings::gps},
- { hmi_apis::FunctionID::VehicleInfo_SubscribeSpeed, strings::speed},
- { hmi_apis::FunctionID::VehicleInfo_SubscribeRpm, strings::rpm},
- { hmi_apis::FunctionID::VehicleInfo_SubscribeFuelLevel, strings::fuel_level},
- { hmi_apis::FunctionID::VehicleInfo_SubscribeFuelLevel_State, strings::fuel_level_state},
- { hmi_apis::FunctionID::VehicleInfo_SubscribeInstantFuelConsumption, strings::instant_fuel_consumption},
- { hmi_apis::FunctionID::VehicleInfo_SubscribeExternalTemperature, strings::external_temp},
- { hmi_apis::FunctionID::VehicleInfo_SubscribeVin, strings::vin},
- { hmi_apis::FunctionID::VehicleInfo_SubscribePrndl, strings::prndl},
- { hmi_apis::FunctionID::VehicleInfo_SubscribeTirePressure, strings::tire_pressure},
- { hmi_apis::FunctionID::VehicleInfo_SubscribeOdometer, strings::odometer},
- { hmi_apis::FunctionID::VehicleInfo_SubscribeBeltStatus, strings::belt_status},
- { hmi_apis::FunctionID::VehicleInfo_SubscribeBodyInformation, strings::body_information},
- { hmi_apis::FunctionID::VehicleInfo_SubscribeDeviceStatus, strings::device_status},
- { hmi_apis::FunctionID::VehicleInfo_SubscribeDriverBraking, strings::driver_braking},
- { hmi_apis::FunctionID::VehicleInfo_SubscribeWiperStatus, strings::wiper_status},
- { hmi_apis::FunctionID::VehicleInfo_SubscribeHeadLampStatus, strings::head_lamp_status},
- { hmi_apis::FunctionID::VehicleInfo_SubscribeEngineTorque, strings::engine_torque},
- { hmi_apis::FunctionID::VehicleInfo_SubscribeAccPedalPosition, strings::acc_pedal_pos},
- { hmi_apis::FunctionID::VehicleInfo_SubscribeSteeringWheelAngle, strings::steering_wheel_angle},
- { hmi_apis::FunctionID::VehicleInfo_SubscribeECallInfo, strings::e_call_info},
- { hmi_apis::FunctionID::VehicleInfo_SubscribeAirbagStatus, strings::airbag_status},
- { hmi_apis::FunctionID::VehicleInfo_SubscribeEmergencyEvent, strings::emergency_event},
- { hmi_apis::FunctionID::VehicleInfo_SubscribeClusterModeStatus, strings::cluster_mode_status},
- { hmi_apis::FunctionID::VehicleInfo_SubscribeMyKey, strings::my_key},
- };
+struct Subrequest {
+ hmi_apis::FunctionID::eType func_id;
+ const char* str;
+};
+Subrequest subrequests[] = {
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeGps, strings::gps},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeSpeed, strings::speed},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeRpm, strings::rpm},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeFuelLevel, strings::fuel_level},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeFuelLevel_State,
+ strings::fuel_level_state},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeInstantFuelConsumption,
+ strings::instant_fuel_consumption},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeExternalTemperature,
+ strings::external_temp},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeVin, strings::vin},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribePrndl, strings::prndl},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeTirePressure,
+ strings::tire_pressure},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeOdometer, strings::odometer},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeBeltStatus,
+ strings::belt_status},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeBodyInformation,
+ strings::body_information},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeDeviceStatus,
+ strings::device_status},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeDriverBraking,
+ strings::driver_braking},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeWiperStatus,
+ strings::wiper_status},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeHeadLampStatus,
+ strings::head_lamp_status},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeEngineTorque,
+ strings::engine_torque},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeAccPedalPosition,
+ strings::acc_pedal_pos},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeSteeringWheelAngle,
+ strings::steering_wheel_angle},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeECallInfo,
+ strings::e_call_info},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeAirbagStatus,
+ strings::airbag_status},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeEmergencyEvent,
+ strings::emergency_event},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeClusterModeStatus,
+ strings::cluster_mode_status},
+ {hmi_apis::FunctionID::VehicleInfo_SubscribeMyKey, strings::my_key},
+};
}
-#endif // #ifdef HMI_DBUS_API
+#endif // #ifdef HMI_DBUS_API
void SubscribeVehicleDataRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
- CommandRequestImpl::connection_key());
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
LOG4CXX_ERROR(logger_, "NULL pointer");
@@ -103,43 +118,88 @@ void SubscribeVehicleDataRequest::Run() {
const VehicleData& vehicle_data = MessageHelper::vehicle_data();
VehicleData::const_iterator it = vehicle_data.begin();
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
- smart_objects::SmartObject response_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
-
- msg_params[strings::app_id] = app->app_id();
+ smart_objects::SmartObject response_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
for (; vehicle_data.end() != it; ++it) {
- std::string key_name = it->first;
+ const std::string& key_name = it->first;
if ((*message_)[strings::msg_params].keyExists(key_name)) {
bool is_key_enabled = (*message_)[strings::msg_params][key_name].asBool();
if (is_key_enabled) {
++items_to_subscribe;
- msg_params[key_name] = is_key_enabled;
VehicleDataType key_type = it->second;
- if (app->SubscribeToIVI(static_cast<uint32_t>(key_type))) {
+ if (app->IsSubscribedToIVI(key_type)) {
+ LOG4CXX_DEBUG(logger_,
+ "App with connection key "
+ << connection_key()
+ << " is subscribed already for VehicleDataType: "
+ << key_type);
++subscribed_items;
- } else {
+ vi_already_subscribed_by_this_app_.insert(key_type);
response_params[key_name][strings::data_type] = key_type;
response_params[key_name][strings::result_code] =
mobile_apis::VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED;
+ continue;
+ }
+
+ if (IsSomeoneSubscribedFor(key_type)) {
+ LOG4CXX_DEBUG(logger_,
+ "There are apps subscribed already for "
+ "VehicleDataType: "
+ << key_type);
+ if (!app->SubscribeToIVI(static_cast<uint32_t>(key_type))) {
+ LOG4CXX_ERROR(
+ logger_,
+ "Unable to subscribe for VehicleDataType: " << key_type);
+ continue;
+ }
+ LOG4CXX_DEBUG(
+ logger_,
+ "App with connection key "
+ << connection_key()
+ << " have been subscribed for VehicleDataType: " << key_type);
+ ++subscribed_items;
+ vi_already_subscribed_by_another_apps_.insert(key_type);
+ response_params[key_name][strings::data_type] = key_type;
+ response_params[key_name][strings::result_code] =
+ mobile_apis::VehicleDataResultCode::VDRC_SUCCESS;
+ continue;
+ }
+
+ msg_params[key_name] = is_key_enabled;
+
+ if (app->SubscribeToIVI(static_cast<uint32_t>(key_type))) {
+ LOG4CXX_DEBUG(
+ logger_,
+ "App with connection key "
+ << connection_key()
+ << " have been subscribed for VehicleDataType: " << key_type);
+ ++subscribed_items;
}
}
}
}
+ bool is_everything_already_subscribed =
+ static_cast<uint32_t>(items_to_subscribe) ==
+ vi_already_subscribed_by_another_apps_.size() +
+ vi_already_subscribed_by_this_app_.size();
+
if (0 == items_to_subscribe) {
if (HasDisallowedParams()) {
SendResponse(false, mobile_apis::Result::DISALLOWED);
} else {
- SendResponse(false, mobile_apis::Result::INVALID_DATA,
- "No data in the request");
+ SendResponse(
+ false, mobile_apis::Result::INVALID_DATA, "No data in the request");
}
return;
- } else if (0 == subscribed_items) {
+ }
+
+ if (0 == subscribed_items) {
SendResponse(false,
mobile_apis::Result::IGNORED,
"Already subscribed on provided VehicleData.",
@@ -147,12 +207,26 @@ void SubscribeVehicleDataRequest::Run() {
return;
}
+ if (is_everything_already_subscribed) {
+ mobile_apis::Result::eType result_code =
+ vi_already_subscribed_by_this_app_.size()
+ ? mobile_apis::Result::IGNORED
+ : mobile_apis::Result::SUCCESS;
+
+ const char* info = vi_already_subscribed_by_this_app_.size()
+ ? "Already subscribed on some provided VehicleData."
+ : NULL;
+
+ SendResponse(true, result_code, info, &response_params);
+ return;
+ }
+
#ifdef HMI_DBUS_API
- //Generate list of subrequests
+ // Generate list of subrequests
for (size_t i = 0; i < sizeof(subrequests) / sizeof(subrequests[0]); ++i) {
const Subrequest& sr = subrequests[i];
- if (true == (*message_)[strings::msg_params].keyExists(sr.str)
- && true == (*message_)[strings::msg_params][sr.str].asBool()) {
+ if (true == (*message_)[strings::msg_params].keyExists(sr.str) &&
+ true == (*message_)[strings::msg_params][sr.str].asBool()) {
HmiRequest hmi_request;
hmi_request.str = sr.str;
hmi_request.func_id = sr.func_id;
@@ -160,24 +234,34 @@ void SubscribeVehicleDataRequest::Run() {
hmi_requests_.push_back(hmi_request);
}
}
- LOG4CXX_INFO(logger_, hmi_requests_.size() << " requests are going to be sent to HMI");
+ LOG4CXX_DEBUG(
+ logger_, hmi_requests_.size() << " requests are going to be sent to HMI");
- //Send subrequests
- for (HmiRequests::const_iterator it = hmi_requests_.begin(); it != hmi_requests_.end(); ++it)
+ // Send subrequests
+ for (HmiRequests::const_iterator it = hmi_requests_.begin();
+ it != hmi_requests_.end();
+ ++it)
SendHMIRequest(it->func_id, &msg_params, true);
#else
SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData,
- &msg_params, true);
-#endif // #ifdef HMI_DBUS_API
+ &msg_params,
+ true);
+#endif // #ifdef HMI_DBUS_API
}
void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
+ using namespace helpers;
const smart_objects::SmartObject& message = event.smart_object();
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
- CommandRequestImpl::connection_key());
+ if (hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData != event.id()) {
+ LOG4CXX_ERROR(logger_, "Received unknown event.");
+ return;
+ }
+
+ ApplicationSharedPtr app =
+ application_manager_.application(CommandRequestImpl::connection_key());
if (!app) {
LOG4CXX_ERROR(logger_, "NULL pointer.");
@@ -186,23 +270,24 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
#ifdef HMI_DBUS_API
for (HmiRequests::iterator it = hmi_requests_.begin();
- it != hmi_requests_.end(); ++it) {
- HmiRequest & hmi_request = *it;
+ it != hmi_requests_.end();
+ ++it) {
+ HmiRequest& hmi_request = *it;
if (hmi_request.func_id == event.id()) {
- hmi_request.status =
- static_cast<hmi_apis::Common_Result::eType>(message[strings::params][hmi_response::code]
- .asInt());
+ hmi_request.status = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
if (hmi_apis::Common_Result::SUCCESS == hmi_request.status)
hmi_request.value = message[strings::msg_params][hmi_request.str];
hmi_request.complete = true;
break;
}
}
- bool all_complete = true;
+ bool all_complete = true;
bool any_arg_success = false;
mobile_api::Result::eType status = mobile_api::Result::eType::SUCCESS;
for (HmiRequests::const_iterator it = hmi_requests_.begin();
- it != hmi_requests_.end(); ++it) {
+ it != hmi_requests_.end();
+ ++it) {
if (!it->complete) {
all_complete = false;
break;
@@ -210,12 +295,14 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
if (hmi_apis::Common_Result::SUCCESS != it->status) {
if (mobile_api::Result::SUCCESS == status) {
status = static_cast<mobile_apis::Result::eType>(it->status);
- } else if (status
- != static_cast<mobile_apis::Result::eType>(it->status)) {
+ } else if (status !=
+ static_cast<mobile_apis::Result::eType>(it->status)) {
status = mobile_api::Result::eType::GENERIC_ERROR;
}
- LOG4CXX_TRACE(logger_, "Status from HMI: " << it->status <<
- ", so response status become " << status);
+ LOG4CXX_TRACE(logger_,
+ "Status from HMI: " << it->status
+ << ", so response status become "
+ << status);
} else {
any_arg_success = true;
}
@@ -225,7 +312,8 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
smart_objects::SmartObject response_params(smart_objects::SmartType_Map);
if (any_arg_success) {
for (HmiRequests::const_iterator it = hmi_requests_.begin();
- it != hmi_requests_.end(); ++it) {
+ it != hmi_requests_.end();
+ ++it) {
response_params[it->str] = it->value;
}
}
@@ -241,53 +329,105 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
- bool result =
- hmi_result == hmi_apis::Common_Result::SUCCESS;
+ const bool is_result_no_error =
+ Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ hmi_result,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::WARNINGS);
+
+ bool is_succeeded =
+ is_result_no_error || !vi_already_subscribed_by_another_apps_.empty();
mobile_apis::Result::eType result_code =
- hmi_result == hmi_apis::Common_Result::SUCCESS
- ? mobile_apis::Result::SUCCESS
- : static_cast<mobile_apis::Result::eType>(
- message[strings::params][hmi_response::code].asInt());
+ MessageHelper::HMIToMobileResult(hmi_result);
const char* return_info = NULL;
- if (result) {
- if (IsAnythingAlreadySubscribed(message[strings::msg_params])) {
+ if (is_succeeded) {
+ if (!vi_already_subscribed_by_this_app_.empty()) {
result_code = mobile_apis::Result::IGNORED;
return_info = "Already subscribed on some provided VehicleData.";
}
}
- SendResponse(result,
- result_code,
- return_info,
- &(message[strings::msg_params]));
+ UnsubscribeFailedSubscriptions(app, message[strings::msg_params]);
+
+ if (!vi_already_subscribed_by_another_apps_.empty() ||
+ !vi_already_subscribed_by_this_app_.empty()) {
+ AddAlreadySubscribedVI(
+ const_cast<smart_objects::SmartObject&>(message[strings::msg_params]));
+ }
+
+ SendResponse(
+ is_succeeded, result_code, return_info, &(message[strings::msg_params]));
- if (result) {
+ if (is_succeeded) {
app->UpdateHash();
}
-#endif // #ifdef HMI_DBUS_API
+#endif // #ifdef HMI_DBUS_API
}
-bool SubscribeVehicleDataRequest::IsAnythingAlreadySubscribed(
- const smart_objects::SmartObject& msg_params) const {
- LOG4CXX_INFO(logger_, "IsAnythingAlreadySubscribed");
+void SubscribeVehicleDataRequest::AddAlreadySubscribedVI(
+ smart_objects::SmartObject& msg_params) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ using namespace mobile_apis;
+ 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] =
+ VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED;
+ }
+
+ 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] =
+ VehicleDataResultCode::VDRC_SUCCESS;
+ }
+}
+void SubscribeVehicleDataRequest::UnsubscribeFailedSubscriptions(
+ ApplicationSharedPtr app,
+ const smart_objects::SmartObject& msg_params) const {
+ LOG4CXX_AUTO_TRACE(logger_);
const VehicleData& vehicle_data = MessageHelper::vehicle_data();
VehicleData::const_iterator it = vehicle_data.begin();
for (; vehicle_data.end() != it; ++it) {
if (msg_params.keyExists(it->first)) {
- if (msg_params[it->first][strings::result_code].asInt() ==
- hmi_apis::Common_VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED) {
- return true;
+ if (msg_params[it->first][strings::result_code].asInt() !=
+ hmi_apis::Common_VehicleDataResultCode::VDRC_SUCCESS) {
+ LOG4CXX_DEBUG(logger_,
+ "Subscription for VehicleDataType "
+ << it->first
+ << " is unsuccessfull. "
+ "Unsubscribing app with connection key "
+ << connection_key() << " from it.");
+ app->UnsubscribeFromIVI(it->second);
}
}
}
-
- return false;
}
+struct SubscribedToIVIPredicate {
+ int32_t vehicle_info_;
+ SubscribedToIVIPredicate(int32_t vehicle_info)
+ : vehicle_info_(vehicle_info) {}
+ bool operator()(const ApplicationSharedPtr app) const {
+ return app ? app->IsSubscribedToIVI(vehicle_info_) : false;
+ }
+};
+
+bool SubscribeVehicleDataRequest::IsSomeoneSubscribedFor(
+ const uint32_t param_id) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ SubscribedToIVIPredicate finder(param_id);
+ DataAccessor<ApplicationSet> accessor = application_manager_.applications();
+ ApplicationSetConstIt it = std::find_if(
+ accessor.GetData().begin(), accessor.GetData().end(), finder);
+ return it != accessor.GetData().end();
+}
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_response.cc b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_response.cc
index c0554c62eb..7ed16407a5 100644
--- a/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_response.cc
+++ b/src/components/application_manager/src/commands/mobile/subscribe_vehicle_data_response.cc
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/subscribe_vehicle_data_response.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "interfaces/MOBILE_API.h"
@@ -40,16 +40,14 @@ namespace application_manager {
namespace commands {
SubscribeVehicleDataResponse::SubscribeVehicleDataResponse(
- const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-SubscribeVehicleDataResponse::~SubscribeVehicleDataResponse() {
-}
+SubscribeVehicleDataResponse::~SubscribeVehicleDataResponse() {}
void SubscribeVehicleDataResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
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
new file mode 100644
index 0000000000..8134730eee
--- /dev/null
+++ b/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc
@@ -0,0 +1,72 @@
+#include "application_manager/application_manager.h"
+#include "application_manager/commands/mobile/subscribe_way_points_request.h"
+
+namespace application_manager {
+
+namespace commands {
+
+SubscribeWayPointsRequest::SubscribeWayPointsRequest(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
+
+SubscribeWayPointsRequest::~SubscribeWayPointsRequest() {}
+
+void SubscribeWayPointsRequest::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
+
+ if (!app) {
+ LOG4CXX_ERROR(logger_,
+ "An application with connection key "
+ << connection_key() << " is not registered.");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ if (application_manager_.IsAppSubscribedForWayPoints(app->app_id())) {
+ SendResponse(false, mobile_apis::Result::IGNORED);
+ return;
+ }
+
+ if (application_manager_.IsAnyAppSubscribedForWayPoints()) {
+ application_manager_.SubscribeAppForWayPoints(app->app_id());
+ SendResponse(true, mobile_apis::Result::SUCCESS);
+ app->UpdateHash();
+ return;
+ }
+
+ SendHMIRequest(
+ hmi_apis::FunctionID::Navigation_SubscribeWayPoints, NULL, true);
+}
+
+void SubscribeWayPointsRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
+ const smart_objects::SmartObject& message = event.smart_object();
+ switch (event.id()) {
+ case hmi_apis::FunctionID::Navigation_SubscribeWayPoints: {
+ LOG4CXX_INFO(logger_, "Received Navigation_SubscribeWayPoints event");
+ mobile_apis::Result::eType result_code =
+ GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asUInt()));
+ bool result = mobile_apis::Result::SUCCESS == result_code;
+ if (result) {
+ application_manager_.SubscribeAppForWayPoints(app->app_id());
+ }
+ SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ if (result) {
+ app->UpdateHash();
+ }
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ break;
+ }
+ }
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/subscribe_way_points_response.cc b/src/components/application_manager/src/commands/mobile/subscribe_way_points_response.cc
new file mode 100644
index 0000000000..c2e642619a
--- /dev/null
+++ b/src/components/application_manager/src/commands/mobile/subscribe_way_points_response.cc
@@ -0,0 +1,22 @@
+#include "application_manager/application_manager.h"
+#include "application_manager/commands/mobile/subscribe_way_points_response.h"
+
+namespace application_manager {
+
+namespace commands {
+
+SubscribeWayPointsResponse::SubscribeWayPointsResponse(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
+
+SubscribeWayPointsResponse::~SubscribeWayPointsResponse() {}
+
+void SubscribeWayPointsResponse::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ application_manager_.SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
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 c0b8b0ebf7..b9acf5e930 100644
--- a/src/components/application_manager/src/commands/mobile/system_request.cc
+++ b/src/components/application_manager/src/commands/mobile/system_request.cc
@@ -31,26 +31,26 @@ Copyright (c) 2013, Ford Motor Company
POSSIBILITY OF SUCH DAMAGE.
*/
+#include "application_manager/commands/mobile/system_request.h"
+
#include <vector>
#include <string>
-#include <map>
-#include <set>
-#include "application_manager/commands/mobile/system_request.h"
-#include "application_manager/application_manager_impl.h"
-#include "application_manager/application_impl.h"
-#include "application_manager/policies/policy_handler.h"
+#include <stdio.h>
+#include <algorithm>
+#include <sstream>
+#include "application_manager/policies/policy_handler_interface.h"
#include "interfaces/MOBILE_API.h"
-#include "config_profile/profile.h"
#include "utils/file_system.h"
-#include "formatters/CFormatterJsonBase.hpp"
+#include "formatters/CFormatterJsonBase.h"
#include "json/json.h"
#include "utils/helpers.h"
+#include "utils/custom_string.h"
namespace application_manager {
+CREATE_LOGGERPTR_LOCAL(logger_, "ApplicationManager")
namespace {
-CREATE_LOGGERPTR_LOCAL(logger_, "ApplicationManager")
#ifdef ENABLE_LOG
const char* kQueryAppsValidationFailedPrefix =
":QUERY_APPS_VALIDATION_FAILED: ";
@@ -72,11 +72,11 @@ class QueryAppsDataValidator {
typedef std::set<std::string> SynonymsSet;
typedef std::map<std::string, SynonymsSet> SynonymsMap;
- QueryAppsDataValidator(const smart_objects::SmartObject& object,
- const ApplicationManagerImpl& manager)
+ QueryAppsDataValidator(smart_objects::SmartObject& object,
+ const ApplicationManager& manager)
: data_(object), manager_(manager) {}
- bool Validate() const {
+ bool Validate() {
LOG4CXX_AUTO_TRACE(logger_);
if (!data_.isValid()) {
LOG4CXX_ERROR(logger_,
@@ -102,19 +102,25 @@ class QueryAppsDataValidator {
return true;
}
- bool ValidateAppDataAndOsAndLanguagesData() const {
- const smart_objects::SmartArray* objects_array =
- data_[json::response].asArray();
+ bool ValidateAppDataAndOsAndLanguagesData() {
+ smart_objects::SmartArray* objects_array = data_[json::response].asArray();
+
if (!objects_array) {
LOG4CXX_WARN(logger_,
kQueryAppsValidationFailedPrefix
<< "QueryApps response is not array.");
return false;
}
- const std::size_t arr_size(objects_array->size());
+
SynonymsMap synonyms_map;
- for (std::size_t idx = 0; idx < arr_size; ++idx) {
- const smart_objects::SmartObject& app_data = (*objects_array)[idx];
+ bool has_response_valid_application = false;
+
+ smart_objects::SmartArray::iterator applications_iterator =
+ objects_array->begin();
+
+ for (; applications_iterator != objects_array->end();
+ ++applications_iterator) {
+ const smart_objects::SmartObject& app_data = *applications_iterator;
if (!app_data.isValid()) {
LOG4CXX_WARN(logger_,
@@ -122,59 +128,50 @@ class QueryAppsDataValidator {
<< "Wrong application data in json file.");
return false;
}
- std::set<std::string> app_ids_set;
- if (!ValidateAppIdAndAppName(app_data, app_ids_set)) {
+
+ if (!CheckMandatoryParametersPresent(app_data)) {
+ LOG4CXX_WARN(logger_,
+ "Application hasn`t some of mandatory parameters. "
+ "Application will be skipped.");
+ objects_array->erase(applications_iterator);
+ continue;
+ }
+
+ if (!ValidateAppIdAndAppName(app_data)) {
return false;
}
+
+ // If we dont have any of android/ios field
+ // we skip this json in CheckMandatoryParametersPresent
+ const std::string os_type =
+ (app_data.keyExists(json::android)) ? json::android : json::ios;
+
// Verify os and dependent languages data
- std::string os_type;
- if (app_data.keyExists(json::ios)) {
- os_type = json::ios;
- if (!app_data[os_type].keyExists(json::urlScheme)) {
- LOG4CXX_WARN(logger_,
- kQueryAppsValidationFailedPrefix
- << "Can't find URL scheme in json file.");
- return false;
- }
- if (app_data[os_type][json::urlScheme].asString().length() >
+ if (json::ios == os_type) {
+ if (app_data[json::ios][json::urlScheme].asString().length() >
kUrlSchemaLengthMax) {
LOG4CXX_WARN(
logger_,
kQueryAppsValidationFailedPrefix
<< "An urlscheme length exceeds maximum allowed ["
- << app_data[os_type][json::urlScheme].asString().length()
+ << app_data[json::ios][json::urlScheme].asString().length()
<< "]>[" << kUrlSchemaLengthMax << "]");
return false;
}
}
- if (os_type.empty()) {
- if (app_data.keyExists(json::android)) {
- os_type = json::android;
- if (!app_data[os_type].keyExists(json::packageName)) {
- LOG4CXX_WARN(logger_,
- kQueryAppsValidationFailedPrefix
- << "Can't find package name in json file.");
- return false;
- }
- if (app_data[json::android][json::packageName].asString().length() >
- kPackageNameLengthMax) {
- LOG4CXX_WARN(logger_,
- kQueryAppsValidationFailedPrefix
- << "Package name length ["
- << app_data[json::android][json::packageName]
- .asString()
- .length() << "] exceeds max length ["
- << kPackageNameLengthMax << "]in json file.");
- return false;
- }
- }
- }
- if (os_type.empty()) {
- LOG4CXX_WARN(logger_,
- kQueryAppsValidationFailedPrefix
- << "Can't find mobile OS type in json file.");
- return false;
+ if (json::android == os_type) {
+ if (app_data[json::android][json::packageName].asString().length() >
+ kPackageNameLengthMax) {
+ LOG4CXX_WARN(logger_,
+ kQueryAppsValidationFailedPrefix
+ << "Package name length ["
+ << app_data[json::android][json::packageName]
+ .asString()
+ .length() << "] exceeds max length ["
+ << kPackageNameLengthMax << "]in json file.");
+ return false;
+ }
}
// Languages verification
@@ -188,19 +185,12 @@ class QueryAppsDataValidator {
synonyms_map)) {
return false;
}
+ has_response_valid_application = true;
}
- return true;
+ return has_response_valid_application;
}
- bool ValidateAppIdAndAppName(const smart_objects::SmartObject& app_data,
- std::set<std::string>& app_ids_set) const {
- // Verify appid
- if (!app_data.keyExists(json::appId)) {
- LOG4CXX_WARN(logger_,
- kQueryAppsValidationFailedPrefix
- << "Can't find app ID in json file.");
- return false;
- }
+ bool ValidateAppIdAndAppName(const smart_objects::SmartObject& app_data) {
// Verify appid length
const std::string app_id(app_data[json::appId].asString());
if (app_id.length() > kAppIdLengthMax) {
@@ -212,30 +202,21 @@ class QueryAppsDataValidator {
}
// Verify that appid is unique
- if (app_ids_set.find(app_id) != app_ids_set.end()) {
+ if (applications_id_set_.find(app_id) != applications_id_set_.end()) {
LOG4CXX_WARN(logger_,
kQueryAppsValidationFailedPrefix
<< "An Object ID is not unigue [" << app_id << "]");
return false;
}
- app_ids_set.insert(app_id);
+ applications_id_set_.insert(app_id);
// Verify that app is not registered yet
ApplicationSharedPtr registered_app =
manager_.application_by_policy_id(app_id);
if (registered_app) {
- LOG4CXX_WARN(logger_,
- kQueryAppsValidationFailedPrefix
- << "Application with the same id: " << app_id
- << " is registered already.");
- return false;
- }
- // Verify app name exist
- if (!app_data.keyExists(json::name)) {
- LOG4CXX_WARN(logger_,
- kQueryAppsValidationFailedPrefix
- << "Can't find app name in json file.");
- return false;
+ LOG4CXX_INFO(logger_,
+ "Application with the id: " << app_id
+ << " is already registered.");
}
// And app name length
const std::string appName(app_data[json::name].asString());
@@ -404,8 +385,36 @@ class QueryAppsDataValidator {
return true;
}
- const smart_objects::SmartObject& data_;
- const ApplicationManagerImpl& manager_;
+ bool CheckMandatoryParametersPresent(
+ const smart_objects::SmartObject& app_data) const {
+ if (!app_data.keyExists(json::android) && !app_data.keyExists(json::ios)) {
+ return false;
+ }
+
+ if (app_data.keyExists(json::android) &&
+ !app_data[json::android].keyExists(json::packageName)) {
+ return false;
+ }
+
+ if (app_data.keyExists(json::ios) &&
+ !app_data[json::ios].keyExists(json::urlScheme)) {
+ return false;
+ }
+
+ if (!app_data.keyExists(json::appId)) {
+ return false;
+ }
+
+ if (!app_data.keyExists(json::name)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ smart_objects::SmartObject& data_;
+ std::set<std::string> applications_id_set_;
+ const ApplicationManager& manager_;
DISALLOW_COPY_AND_ASSIGN(QueryAppsDataValidator);
};
@@ -413,23 +422,24 @@ class QueryAppsDataValidator {
namespace commands {
+namespace custom_str = utils::custom_string;
+
uint32_t SystemRequest::index = 0;
const std::string kSYNC = "SYNC";
const std::string kIVSU = "IVSU";
-SystemRequest::SystemRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+SystemRequest::SystemRequest(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
-SystemRequest::~SystemRequest() {
-}
+SystemRequest::~SystemRequest() {}
void SystemRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(connection_key());
+ application_manager_.application(connection_key());
if (!(application.valid())) {
LOG4CXX_ERROR(logger_, "NULL pointer");
@@ -441,8 +451,10 @@ void SystemRequest::Run() {
static_cast<mobile_apis::RequestType::eType>(
(*message_)[strings::msg_params][strings::request_type].asInt());
- if (!policy::PolicyHandler::instance()->IsRequestTypeAllowed(
- application->mobile_app_id(), request_type)) {
+ const policy::PolicyHandlerInterface& policy_handler =
+ application_manager_.GetPolicyHandler();
+ if (!policy_handler.IsRequestTypeAllowed(application->policy_app_id(),
+ request_type)) {
SendResponse(false, mobile_apis::Result::DISALLOWED);
return;
}
@@ -469,15 +481,18 @@ void SystemRequest::Run() {
std::string binary_data_folder;
if ((*message_)[strings::params].keyExists(strings::binary_data)) {
binary_data = (*message_)[strings::params][strings::binary_data].asBinary();
- binary_data_folder = profile::Profile::instance()->system_files_path();
+ binary_data_folder =
+ application_manager_.get_settings().system_files_path();
} else {
- binary_data_folder = profile::Profile::instance()->app_storage_folder();
+ binary_data_folder =
+ application_manager_.get_settings().app_storage_folder();
binary_data_folder += "/";
binary_data_folder += application->folder_name();
binary_data_folder += "/";
}
- std::string file_dst_path = profile::Profile::instance()->system_files_path();
+ std::string file_dst_path =
+ application_manager_.get_settings().system_files_path();
file_dst_path += "/";
file_dst_path += file_name;
@@ -486,7 +501,7 @@ void SystemRequest::Run() {
logger_,
"Binary data is present. Trying to save it to: " << binary_data_folder);
if (mobile_apis::Result::SUCCESS !=
- (ApplicationManagerImpl::instance()->SaveBinary(
+ (application_manager_.SaveBinary(
binary_data, binary_data_folder, file_name, 0))) {
LOG4CXX_DEBUG(logger_, "Binary data can't be saved.");
SendResponse(false, mobile_apis::Result::GENERIC_ERROR);
@@ -524,7 +539,15 @@ void SystemRequest::Run() {
LOG4CXX_DEBUG(logger_, "Binary data ok.");
- if (mobile_apis::RequestType::QUERY_APPS == request_type) {
+ if (mobile_apis::RequestType::HTTP == request_type &&
+ (*message_)[strings::msg_params].keyExists(strings::file_name)) {
+ const std::string& file =
+ (*message_)[strings::msg_params][strings::file_name].asString();
+ application_manager_.GetPolicyHandler().ReceiveMessageFromSDK(file,
+ binary_data);
+ SendResponse(true, mobile_apis::Result::SUCCESS);
+ return;
+ } else if (mobile_apis::RequestType::QUERY_APPS == request_type) {
using namespace NsSmartDeviceLink::NsJSONHandler::Formatters;
smart_objects::SmartObject sm_object;
@@ -542,8 +565,7 @@ void SystemRequest::Run() {
return;
}
- ApplicationManagerImpl::instance()->ProcessQueryApp(sm_object,
- connection_key());
+ application_manager_.ProcessQueryApp(sm_object, connection_key());
SendResponse(true, mobile_apis::Result::SUCCESS);
return;
}
@@ -557,7 +579,7 @@ void SystemRequest::Run() {
}
if (mobile_apis::RequestType::PROPRIETARY != request_type) {
- msg_params[strings::app_id] = (application->mobile_app_id());
+ msg_params[strings::app_id] = (application->policy_app_id());
}
msg_params[strings::request_type] =
(*message_)[strings::msg_params][strings::request_type];
@@ -584,7 +606,7 @@ void SystemRequest::on_event(const event_engine::Event& event) {
mobile_api::Result::WARNINGS);
ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(connection_key());
+ application_manager_.application(connection_key());
if (!(application.valid())) {
LOG4CXX_ERROR(logger_, "NULL pointer");
@@ -595,6 +617,7 @@ void SystemRequest::on_event(const event_engine::Event& event) {
file_system::DeleteFile(processing_file_);
processing_file_.clear();
}
+
SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
break;
}
@@ -606,7 +629,7 @@ void SystemRequest::on_event(const event_engine::Event& event) {
}
bool SystemRequest::ValidateQueryAppData(
- const smart_objects::SmartObject& data) const {
+ smart_objects::SmartObject& data) const {
if (!data.isValid()) {
LOG4CXX_ERROR(logger_,
kQueryAppsValidationFailedPrefix
@@ -620,10 +643,8 @@ bool SystemRequest::ValidateQueryAppData(
<< json::response << "' parameter.");
return false;
}
- ApplicationManagerImpl* manager = ApplicationManagerImpl::instance();
- DCHECK(manager);
- QueryAppsDataValidator validator(data, *manager);
+ QueryAppsDataValidator validator(data, application_manager_);
return validator.Validate();
}
diff --git a/src/components/application_manager/src/commands/mobile/system_response.cc b/src/components/application_manager/src/commands/mobile/system_response.cc
index 8b4fdafd1b..f5bc03f4a5 100644
--- a/src/components/application_manager/src/commands/mobile/system_response.cc
+++ b/src/components/application_manager/src/commands/mobile/system_response.cc
@@ -32,23 +32,21 @@
*/
#include "application_manager/commands/mobile/system_response.h"
-#include "application_manager/application_manager_impl.h"
namespace application_manager {
namespace commands {
-SystemResponse::SystemResponse(const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+SystemResponse::SystemResponse(const MessageSharedPtr& message,
+ ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-SystemResponse::~SystemResponse() {
-}
+SystemResponse::~SystemResponse() {}
void SystemResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc
index dc63a11941..d7056a624e 100644
--- a/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc
+++ b/src/components/application_manager/src/commands/mobile/unregister_app_interface_request.cc
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/unregister_app_interface_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/message_helper.h"
namespace application_manager {
@@ -42,19 +42,19 @@ namespace commands {
void UnregisterAppInterfaceRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl* app_manager = ApplicationManagerImpl::instance();
-
- if (!app_manager->application(connection_key())) {
+ if (!application_manager_.application(connection_key())) {
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
LOG4CXX_ERROR(logger_, "Application is not registered");
return;
}
- MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile(
- connection_key(),
- mobile_api::AppInterfaceUnregisteredReason::INVALID_ENUM);
- app_manager->UnregisterApplication(connection_key(),
- mobile_apis::Result::SUCCESS);
+ application_manager_.ManageMobileCommand(
+ MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile(
+ connection_key(),
+ mobile_api::AppInterfaceUnregisteredReason::INVALID_ENUM),
+ commands::Command::ORIGIN_SDL);
+ application_manager_.UnregisterApplication(connection_key(),
+ mobile_apis::Result::SUCCESS);
SendResponse(true, mobile_apis::Result::SUCCESS);
}
diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc
index a2958342ea..86df8fabb1 100644
--- a/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc
+++ b/src/components/application_manager/src/commands/mobile/unsubscribe_button_request.cc
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/unsubscribe_button_request.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
namespace application_manager {
@@ -42,21 +42,18 @@ namespace commands {
namespace str = strings;
UnsubscribeButtonRequest::UnsubscribeButtonRequest(
- const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
-UnsubscribeButtonRequest::~UnsubscribeButtonRequest() {
-}
+UnsubscribeButtonRequest::~UnsubscribeButtonRequest() {}
void UnsubscribeButtonRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()->application(connection_key());
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
- LOG4CXX_ERROR_EXT(logger_, "APPLICATION_NOT_REGISTERED");
+ LOG4CXX_ERROR(logger_, "APPLICATION_NOT_REGISTERED");
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
return;
}
@@ -64,13 +61,15 @@ void UnsubscribeButtonRequest::Run() {
const uint32_t btn_id =
(*message_)[str::msg_params][str::button_name].asUInt();
- if (!app->IsSubscribedToButton(static_cast<mobile_apis::ButtonName::eType>(btn_id))) {
- LOG4CXX_ERROR_EXT(logger_, "App doesn't subscibe to button " << btn_id);
+ if (!app->IsSubscribedToButton(
+ static_cast<mobile_apis::ButtonName::eType>(btn_id))) {
+ LOG4CXX_ERROR(logger_, "App doesn't subscibe to button " << btn_id);
SendResponse(false, mobile_apis::Result::IGNORED);
return;
}
- app->UnsubscribeFromButton(static_cast<mobile_apis::ButtonName::eType>(btn_id));
+ app->UnsubscribeFromButton(
+ static_cast<mobile_apis::ButtonName::eType>(btn_id));
SendUnsubscribeButtonNotification();
const bool is_succedeed = true;
diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_button_response.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_button_response.cc
index 8bece66157..409579b294 100644
--- a/src/components/application_manager/src/commands/mobile/unsubscribe_button_response.cc
+++ b/src/components/application_manager/src/commands/mobile/unsubscribe_button_response.cc
@@ -32,19 +32,16 @@
*/
#include "application_manager/commands/mobile/unsubscribe_button_response.h"
-#include "application_manager/application_manager_impl.h"
namespace application_manager {
namespace commands {
UnsubscribeButtonResponse::UnsubscribeButtonResponse(
- const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-UnsubscribeButtonResponse::~UnsubscribeButtonResponse() {
-}
+UnsubscribeButtonResponse::~UnsubscribeButtonResponse() {}
void UnsubscribeButtonResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
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 051f1819ba..4fcc04c7be 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
@@ -33,65 +33,81 @@
#include "application_manager/commands/mobile/unsubscribe_vehicle_data_request.h"
#include "application_manager/commands/command_impl.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
#include "interfaces/MOBILE_API.h"
#include "interfaces/HMI_API.h"
#include "application_manager/smart_object_keys.h"
+#include "utils/helpers.h"
namespace application_manager {
namespace commands {
UnsubscribeVehicleDataRequest::UnsubscribeVehicleDataRequest(
- const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
-UnsubscribeVehicleDataRequest::~UnsubscribeVehicleDataRequest() {
-}
+UnsubscribeVehicleDataRequest::~UnsubscribeVehicleDataRequest() {}
#ifdef HMI_DBUS_API
namespace {
- struct Subrequest {
- hmi_apis::FunctionID::eType func_id;
- const char* str;
- };
- Subrequest subrequests[] = {
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeGps, strings::gps},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeSpeed, strings::speed},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeRpm, strings::rpm},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeFuelLevel, strings::fuel_level},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeFuelLevel_State, strings::fuel_level_state},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeInstantFuelConsumption, strings::instant_fuel_consumption},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeExternalTemperature, strings::external_temp},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeVin, strings::vin},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribePrndl, strings::prndl},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeTirePressure, strings::tire_pressure},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeOdometer, strings::odometer},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeBeltStatus, strings::belt_status},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeBodyInformation, strings::body_information},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeDeviceStatus, strings::device_status},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeDriverBraking, strings::driver_braking},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeWiperStatus, strings::wiper_status},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeHeadLampStatus, strings::head_lamp_status},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeEngineTorque, strings::engine_torque},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeAccPedalPosition, strings::acc_pedal_pos},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeSteeringWheelAngle, strings::steering_wheel_angle},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeECallInfo, strings::e_call_info},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeAirbagStatus, strings::airbag_status},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeEmergencyEvent, strings::emergency_event},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeClusterModeStatus, strings::cluster_mode_status},
- { hmi_apis::FunctionID::VehicleInfo_UnsubscribeMyKey, strings::my_key},
- };
+struct Subrequest {
+ hmi_apis::FunctionID::eType func_id;
+ const char* str;
+};
+Subrequest subrequests[] = {
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeGps, strings::gps},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeSpeed, strings::speed},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeRpm, strings::rpm},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeFuelLevel,
+ strings::fuel_level},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeFuelLevel_State,
+ strings::fuel_level_state},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeInstantFuelConsumption,
+ strings::instant_fuel_consumption},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeExternalTemperature,
+ strings::external_temp},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeVin, strings::vin},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribePrndl, strings::prndl},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeTirePressure,
+ strings::tire_pressure},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeOdometer, strings::odometer},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeBeltStatus,
+ strings::belt_status},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeBodyInformation,
+ strings::body_information},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeDeviceStatus,
+ strings::device_status},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeDriverBraking,
+ strings::driver_braking},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeWiperStatus,
+ strings::wiper_status},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeHeadLampStatus,
+ strings::head_lamp_status},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeEngineTorque,
+ strings::engine_torque},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeAccPedalPosition,
+ strings::acc_pedal_pos},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeSteeringWheelAngle,
+ strings::steering_wheel_angle},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeECallInfo,
+ strings::e_call_info},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeAirbagStatus,
+ strings::airbag_status},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeEmergencyEvent,
+ strings::emergency_event},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeClusterModeStatus,
+ strings::cluster_mode_status},
+ {hmi_apis::FunctionID::VehicleInfo_UnsubscribeMyKey, strings::my_key},
+};
}
-#endif // #ifdef HMI_DBUS_API
+#endif // #ifdef HMI_DBUS_API
void UnsubscribeVehicleDataRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
- CommandRequestImpl::connection_key());
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
LOG4CXX_ERROR(logger_, "NULL pointer");
@@ -99,62 +115,111 @@ void UnsubscribeVehicleDataRequest::Run() {
return;
}
- // counter for items to subscribe
int32_t items_to_unsubscribe = 0;
- // counter for subscribed items by application
int32_t unsubscribed_items = 0;
const VehicleData& vehicle_data = MessageHelper::vehicle_data();
VehicleData::const_iterator it = vehicle_data.begin();
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
-
- smart_objects::SmartObject response_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
- msg_params[strings::app_id] = app->app_id();
+ smart_objects::SmartObject response_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
for (; vehicle_data.end() != it; ++it) {
- std::string key_name = it->first;
+ const std::string& key_name = it->first;
if ((*message_)[strings::msg_params].keyExists(key_name)) {
bool is_key_enabled = (*message_)[strings::msg_params][key_name].asBool();
if (is_key_enabled) {
++items_to_unsubscribe;
- msg_params[key_name] = is_key_enabled;
VehicleDataType key_type = it->second;
- if (app->UnsubscribeFromIVI(static_cast<uint32_t>(key_type))) {
+ if (!app->IsSubscribedToIVI(key_type)) {
++unsubscribed_items;
- } else {
+ vi_already_unsubscribed_by_this_app_.insert(key_type);
response_params[key_name][strings::data_type] = key_type;
response_params[key_name][strings::result_code] =
mobile_apis::VehicleDataResultCode::VDRC_DATA_NOT_SUBSCRIBED;
+ continue;
+ }
+
+ if (!app->UnsubscribeFromIVI(static_cast<uint32_t>(key_type))) {
+ LOG4CXX_ERROR(logger_,
+ "Unable to unsubscribe from "
+ "VehicleDataType: "
+ << key_type);
+ continue;
}
+
+ LOG4CXX_DEBUG(logger_,
+ "Unsubscribed app with connection key "
+ << connection_key()
+ << " from VehicleDataType: " << key_type);
+
+ ++unsubscribed_items;
+
+ if (IsSomeoneSubscribedFor(key_type)) {
+ LOG4CXX_DEBUG(logger_,
+ "There are another apps still subscribed for "
+ "VehicleDataType: "
+ << key_type);
+
+ vi_still_subscribed_by_another_apps_.insert(key_type);
+ response_params[key_name][strings::data_type] = key_type;
+ response_params[key_name][strings::result_code] =
+ mobile_apis::VehicleDataResultCode::VDRC_SUCCESS;
+ continue;
+ }
+
+ msg_params[key_name] = is_key_enabled;
}
}
}
+ bool is_everything_already_unsubscribed =
+ static_cast<uint32_t>(items_to_unsubscribe) ==
+ vi_still_subscribed_by_another_apps_.size() +
+ vi_already_unsubscribed_by_this_app_.size();
+
if (0 == items_to_unsubscribe) {
if (HasDisallowedParams()) {
SendResponse(false, mobile_apis::Result::DISALLOWED);
} else {
- SendResponse(false, mobile_apis::Result::INVALID_DATA,
- "No data in the request.");
+ SendResponse(
+ false, mobile_apis::Result::INVALID_DATA, "No data in the request.");
}
return;
- } else if (0 == unsubscribed_items) {
- SendResponse(false, mobile_apis::Result::IGNORED,
- "Was not subscribed on any VehicleData.", &response_params);
+ }
+
+ if (0 == unsubscribed_items) {
+ SendResponse(false,
+ mobile_apis::Result::IGNORED,
+ "Was not subscribed on any VehicleData.",
+ &response_params);
+ return;
+ }
+
+ if (is_everything_already_unsubscribed) {
+ mobile_apis::Result::eType result_code =
+ vi_already_unsubscribed_by_this_app_.size()
+ ? mobile_apis::Result::IGNORED
+ : mobile_apis::Result::SUCCESS;
+
+ const char* info = vi_already_unsubscribed_by_this_app_.size()
+ ? "Already subscribed on some provided VehicleData."
+ : NULL;
+
+ SendResponse(true, result_code, info, &response_params);
return;
}
#ifdef HMI_DBUS_API
- //Generate list of subrequests
+ // Generate list of subrequests
for (size_t i = 0; i < sizeof(subrequests) / sizeof(subrequests[0]); ++i) {
const Subrequest& sr = subrequests[i];
- if (true == (*message_)[strings::msg_params].keyExists(sr.str)
- && true == (*message_)[strings::msg_params][sr.str].asBool()) {
+ if (true == (*message_)[strings::msg_params].keyExists(sr.str) &&
+ true == (*message_)[strings::msg_params][sr.str].asBool()) {
HmiRequest hmi_request;
hmi_request.str = sr.str;
hmi_request.func_id = sr.func_id;
@@ -165,40 +230,49 @@ void UnsubscribeVehicleDataRequest::Run() {
LOG4CXX_INFO(logger_,
hmi_requests_.size() << " requests are going to be sent to HMI");
- //Send subrequests
+ // Send subrequests
for (HmiRequests::const_iterator it = hmi_requests_.begin();
- it != hmi_requests_.end(); ++it)
+ it != hmi_requests_.end();
+ ++it)
SendHMIRequest(it->func_id, &msg_params, true);
#else
SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData,
- &msg_params, true);
-#endif // #ifdef HMI_DBUS_API
+ &msg_params,
+ true);
+#endif // #ifdef HMI_DBUS_API
}
void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
+ using namespace helpers;
const smart_objects::SmartObject& message = event.smart_object();
+ if (hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData != event.id()) {
+ LOG4CXX_ERROR(logger_, "Received unknown event.");
+ return;
+ }
+
#ifdef HMI_DBUS_API
for (HmiRequests::iterator it = hmi_requests_.begin();
- it != hmi_requests_.end(); ++it) {
- HmiRequest & hmi_request = *it;
+ it != hmi_requests_.end();
+ ++it) {
+ HmiRequest& hmi_request = *it;
if (hmi_request.func_id == event.id()) {
- hmi_request.status =
- static_cast<hmi_apis::Common_Result::eType>(message[strings::params][hmi_response::code]
- .asInt());
+ hmi_request.status = static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
if (hmi_apis::Common_Result::SUCCESS == hmi_request.status)
hmi_request.value = message[strings::msg_params][hmi_request.str];
hmi_request.complete = true;
break;
}
}
- bool all_complete = true;
+ bool all_complete = true;
bool any_arg_success = false;
mobile_api::Result::eType status = mobile_api::Result::eType::SUCCESS;
for (HmiRequests::const_iterator it = hmi_requests_.begin();
- it != hmi_requests_.end(); ++it) {
+ it != hmi_requests_.end();
+ ++it) {
if (!it->complete) {
all_complete = false;
break;
@@ -206,73 +280,129 @@ void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
if (hmi_apis::Common_Result::SUCCESS != it->status) {
if (mobile_api::Result::SUCCESS == status) {
status = static_cast<mobile_apis::Result::eType>(it->status);
- } else if (status
- != static_cast<mobile_apis::Result::eType>(it->status)) {
+ } else if (status !=
+ static_cast<mobile_apis::Result::eType>(it->status)) {
status = mobile_api::Result::eType::GENERIC_ERROR;
- } LOG4CXX_TRACE(logger_, "Status from HMI: " << it->status <<
- ", so response status become " << status);
+ }
+ LOG4CXX_TRACE(logger_,
+ "Status from HMI: " << it->status
+ << ", so response status become "
+ << status);
} else {
any_arg_success = true;
}
}
- if (all_complete) {
+ if (all_complete) {
smart_objects::SmartObject response_params(smart_objects::SmartType_Map);
if (any_arg_success) {
for (HmiRequests::const_iterator it = hmi_requests_.begin();
- it != hmi_requests_.end(); ++it) {
+ it != hmi_requests_.end();
+ ++it) {
response_params[it->str] = it->value;
}
}
+
LOG4CXX_INFO(logger_, "All HMI requests are complete");
+ if (true == any_arg_success) {
+ SetAllowedToTerminate(false);
+ }
SendResponse(any_arg_success, status, NULL, &response_params);
+ if (true == any_arg_success) {
+ UpdateHash();
+ }
}
#else
hmi_apis::Common_Result::eType hmi_result =
static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());
- bool result =
- hmi_result == hmi_apis::Common_Result::SUCCESS;
+ bool is_succeeded = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
+ hmi_result,
+ hmi_apis::Common_Result::SUCCESS,
+ hmi_apis::Common_Result::WARNINGS);
mobile_apis::Result::eType result_code =
- hmi_result == hmi_apis::Common_Result::SUCCESS
- ? mobile_apis::Result::SUCCESS
- : static_cast<mobile_apis::Result::eType>(
- message[strings::params][hmi_response::code].asInt());
+ MessageHelper::HMIToMobileResult(hmi_result);
const char* return_info = NULL;
- if (result) {
- if (IsAnythingAlreadyUnsubscribed(message[strings::msg_params])) {
+ if (is_succeeded) {
+ if (vi_already_unsubscribed_by_this_app_.size()) {
result_code = mobile_apis::Result::IGNORED;
return_info = "Some provided VehicleData was not subscribed.";
}
}
- SendResponse(result, result_code, return_info,
- &(message[strings::msg_params]));
-#endif // #ifdef HMI_DBUS_API
+ if (!vi_still_subscribed_by_another_apps_.empty() ||
+ !vi_already_unsubscribed_by_this_app_.empty()) {
+ AddAlreadyUnsubscribedVI(
+ const_cast<smart_objects::SmartObject&>(message[strings::msg_params]));
+ }
+
+ if (is_succeeded) {
+ SetAllowedToTerminate(false);
+ }
+ SendResponse(
+ is_succeeded, result_code, return_info, &(message[strings::msg_params]));
+ if (is_succeeded) {
+ UpdateHash();
+ }
+#endif // #ifdef HMI_DBUS_API
}
-bool UnsubscribeVehicleDataRequest::IsAnythingAlreadyUnsubscribed(
- const smart_objects::SmartObject& msg_params) const {
- LOG4CXX_INFO(logger_, "IsAnythingAlreadyUnsubscribed");
+struct SubscribedToIVIPredicate {
+ int32_t vehicle_info_;
+ SubscribedToIVIPredicate(int32_t vehicle_info)
+ : vehicle_info_(vehicle_info) {}
+ bool operator()(const ApplicationSharedPtr app) const {
+ return app ? app->IsSubscribedToIVI(vehicle_info_) : false;
+ }
+};
- const VehicleData& vehicle_data = MessageHelper::vehicle_data();
- VehicleData::const_iterator it = vehicle_data.begin();
+bool UnsubscribeVehicleDataRequest::IsSomeoneSubscribedFor(
+ const uint32_t param_id) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ SubscribedToIVIPredicate finder(param_id);
+ DataAccessor<ApplicationSet> accessor = application_manager_.applications();
+ ApplicationSetConstIt it = std::find_if(
+ accessor.GetData().begin(), accessor.GetData().end(), finder);
+ return it != accessor.GetData().end();
+}
- for (; vehicle_data.end() != it; ++it) {
- if (msg_params.keyExists(it->first)) {
- if (msg_params[it->first][strings::result_code].asInt() ==
- hmi_apis::Common_VehicleDataResultCode::VDRC_DATA_NOT_SUBSCRIBED) {
- return true;
- }
- }
+void UnsubscribeVehicleDataRequest::AddAlreadyUnsubscribedVI(
+ smart_objects::SmartObject& response) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ using namespace mobile_apis;
+ VehicleInfoSubscriptions::const_iterator it_same_app =
+ vi_already_unsubscribed_by_this_app_.begin();
+ for (; vi_already_unsubscribed_by_this_app_.end() != it_same_app;
+ ++it_same_app) {
+ response[*it_same_app][strings::result_code] =
+ VehicleDataResultCode::VDRC_DATA_NOT_SUBSCRIBED;
}
- return false;
+ VehicleInfoSubscriptions::const_iterator it_another_app =
+ vi_still_subscribed_by_another_apps_.begin();
+ for (; vi_still_subscribed_by_another_apps_.end() != it_another_app;
+ ++it_another_app) {
+ response[*it_another_app][strings::result_code] =
+ VehicleDataResultCode::VDRC_SUCCESS;
+ }
}
+void UnsubscribeVehicleDataRequest::UpdateHash() const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ ApplicationSharedPtr application =
+ application_manager_.application(connection_key());
+ if (application) {
+ application->UpdateHash();
+ } else {
+ LOG4CXX_ERROR(logger_,
+ "Application with connection_key = " << connection_key()
+ << " doesn't exist.");
+ }
+ application_manager_.TerminateRequest(connection_key(), correlation_id());
+}
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_response.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_response.cc
index 87b2e6e5e1..e06158e4eb 100644
--- a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_response.cc
+++ b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_response.cc
@@ -37,12 +37,10 @@ namespace application_manager {
namespace commands {
UnsubscribeVehicleDataResponse::UnsubscribeVehicleDataResponse(
- const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-UnsubscribeVehicleDataResponse::~UnsubscribeVehicleDataResponse() {
-}
+UnsubscribeVehicleDataResponse::~UnsubscribeVehicleDataResponse() {}
void UnsubscribeVehicleDataResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
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
new file mode 100644
index 0000000000..b19e292025
--- /dev/null
+++ b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc
@@ -0,0 +1,65 @@
+#include "application_manager/application_manager.h"
+#include "application_manager/commands/mobile/unsubscribe_way_points_request.h"
+
+namespace application_manager {
+
+namespace commands {
+
+UnSubscribeWayPointsRequest::UnSubscribeWayPointsRequest(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
+
+UnSubscribeWayPointsRequest::~UnSubscribeWayPointsRequest() {}
+
+void UnSubscribeWayPointsRequest::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
+
+ if (!app) {
+ LOG4CXX_ERROR(logger_,
+ "An application with connection key "
+ << connection_key() << " is not registered.");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ if (!application_manager_.IsAppSubscribedForWayPoints(app->app_id())) {
+ SendResponse(false, mobile_apis::Result::IGNORED);
+ return;
+ }
+
+ SendHMIRequest(
+ hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints, NULL, true);
+}
+
+void UnSubscribeWayPointsRequest::on_event(const event_engine::Event& event) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ ApplicationSharedPtr app = application_manager_.application(connection_key());
+ const smart_objects::SmartObject& message = event.smart_object();
+ switch (event.id()) {
+ case hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints: {
+ LOG4CXX_INFO(logger_, "Received Navigation_UnSubscribeWayPoints event");
+ mobile_apis::Result::eType result_code =
+ GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
+ message[strings::params][hmi_response::code].asUInt()));
+ bool result = mobile_apis::Result::SUCCESS == result_code;
+ if (result) {
+ application_manager_.UnsubscribeAppFromWayPoints(app->app_id());
+ }
+ SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
+ if (result) {
+ app->UpdateHash();
+ }
+ break;
+ }
+ default: {
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
+ break;
+ }
+ }
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_response.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_response.cc
new file mode 100644
index 0000000000..f6430d1f0d
--- /dev/null
+++ b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_response.cc
@@ -0,0 +1,22 @@
+#include "application_manager/application_manager.h"
+#include "application_manager/commands/mobile/unsubscribe_way_points_response.h"
+
+namespace application_manager {
+
+namespace commands {
+
+UnsubscribeWayPointsResponse::UnsubscribeWayPointsResponse(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
+
+UnsubscribeWayPointsResponse::~UnsubscribeWayPointsResponse() {}
+
+void UnsubscribeWayPointsResponse::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ application_manager_.SendMessageToMobile(message_);
+}
+
+} // namespace commands
+
+} // namespace application_manager
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 650e698bf4..9b3b221446 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
@@ -33,27 +33,30 @@
#include <string>
#include "application_manager/commands/mobile/update_turn_list_request.h"
-#include "application_manager/application_manager_impl.h"
+
+#include "application_manager/policies/policy_handler.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/custom_string.h"
namespace application_manager {
namespace commands {
-UpdateTurnListRequest::UpdateTurnListRequest(const MessageSharedPtr& message)
- : CommandRequestImpl(message) {
-}
+namespace custom_str = utils::custom_string;
-UpdateTurnListRequest::~UpdateTurnListRequest() {
-}
+UpdateTurnListRequest::UpdateTurnListRequest(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandRequestImpl(message, application_manager) {}
+
+UpdateTurnListRequest::~UpdateTurnListRequest() {}
void UpdateTurnListRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ ApplicationSharedPtr app = application_manager_.application(
(*message_)[strings::params][strings::connection_key].asUInt());
if (!app) {
@@ -69,10 +72,13 @@ void UpdateTurnListRequest::Run() {
return;
}
- //ProcessSoftButtons checks strings on the contents incorrect character
+ // ProcessSoftButtons checks strings on the contents incorrect character
mobile_apis::Result::eType processing_result =
- MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params], app);
+ MessageHelper::ProcessSoftButtons((*message_)[strings::msg_params],
+ app,
+ application_manager_.GetPolicyHandler(),
+ application_manager_);
if (mobile_apis::Result::SUCCESS != processing_result) {
LOG4CXX_ERROR(logger_, "INVALID_DATA!");
@@ -84,20 +90,21 @@ void UpdateTurnListRequest::Run() {
smart_objects::SmartObject& turn_list_array =
((*message_)[strings::msg_params][strings::turn_list]);
for (uint32_t i = 0; i < turn_list_array.length(); ++i) {
- if((turn_list_array[i].keyExists(strings::turn_icon)) &&
- (mobile_apis::Result::SUCCESS != MessageHelper::VerifyImage(
- turn_list_array[i][strings::turn_icon], app))) {
- LOG4CXX_ERROR_EXT(
- logger_,
- "MessageHelper::VerifyImage return INVALID_DATA");
+ if ((turn_list_array[i].keyExists(strings::turn_icon)) &&
+ (mobile_apis::Result::SUCCESS !=
+ MessageHelper::VerifyImage(turn_list_array[i][strings::turn_icon],
+ app,
+ application_manager_))) {
+ LOG4CXX_ERROR(logger_,
+ "MessageHelper::VerifyImage return INVALID_DATA");
SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
}
}
}
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
msg_params = (*message_)[strings::msg_params];
if ((*message_)[strings::msg_params].keyExists(strings::turn_list)) {
@@ -109,15 +116,15 @@ void UpdateTurnListRequest::Run() {
for (uint32_t i = 0; i < msg_params[strings::turn_list].length(); ++i) {
if (msg_params[strings::turn_list][i].keyExists(hmi_request::navi_text)) {
- std::string navigation_text =
- msg_params[strings::turn_list][i][hmi_request::navi_text].asString();
+ const custom_str::CustomString& navigation_text =
+ msg_params[strings::turn_list][i][hmi_request::navi_text]
+ .asCustomString();
msg_params[strings::turn_list][i].erase(hmi_request::navi_text);
- msg_params[strings::turn_list]
- [i][hmi_request::navi_text][hmi_request::field_name] =
- static_cast<int>(hmi_apis::Common_TextFieldName::turnText);
- msg_params[strings::turn_list]
- [i][hmi_request::navi_text][hmi_request::field_text] =
- navigation_text;
+ msg_params[strings::turn_list][i][hmi_request::navi_text]
+ [hmi_request::field_name] = static_cast<int>(
+ hmi_apis::Common_TextFieldName::turnText);
+ msg_params[strings::turn_list][i][hmi_request::navi_text]
+ [hmi_request::field_text] = navigation_text;
}
}
}
@@ -125,14 +132,14 @@ void UpdateTurnListRequest::Run() {
msg_params[strings::app_id] = app->app_id();
if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) {
- MessageHelper::SubscribeApplicationToSoftButton((*message_)[strings::msg_params],
- app, function_id());
+ MessageHelper::SubscribeApplicationToSoftButton(
+ (*message_)[strings::msg_params], app, function_id());
}
if ((*message_)[strings::msg_params].keyExists(strings::turn_list) ||
(*message_)[strings::msg_params].keyExists(strings::soft_buttons)) {
- SendHMIRequest(hmi_apis::FunctionID::Navigation_UpdateTurnList, &msg_params,
- true);
+ SendHMIRequest(
+ hmi_apis::FunctionID::Navigation_UpdateTurnList, &msg_params, true);
} else {
// conditional mandatory
LOG4CXX_ERROR(logger_, "INVALID_DATA!");
@@ -150,20 +157,20 @@ void UpdateTurnListRequest::on_event(const event_engine::Event& event) {
mobile_apis::Result::eType result_code =
static_cast<mobile_apis::Result::eType>(
- message[strings::params][hmi_response::code].asInt());
+ message[strings::params][hmi_response::code].asInt());
HMICapabilities& hmi_capabilities =
- ApplicationManagerImpl::instance()->hmi_capabilities();
+ application_manager_.hmi_capabilities();
- bool result = (mobile_apis::Result::SUCCESS == result_code) ||
+ bool result =
+ (mobile_apis::Result::SUCCESS == result_code) ||
((mobile_apis::Result::UNSUPPORTED_RESOURCE == result_code) &&
- (hmi_capabilities.is_ui_cooperating()));
-
+ (hmi_capabilities.is_ui_cooperating()));
SendResponse(result, result_code, NULL, &(message[strings::msg_params]));
break;
}
default: {
- LOG4CXX_ERROR(logger_,"Received unknown event" << event.id());
+ LOG4CXX_ERROR(logger_, "Received unknown event" << event.id());
break;
}
}
@@ -177,10 +184,10 @@ bool UpdateTurnListRequest::CheckTurnListArray() {
}
for (int32_t i = 0; i < length; ++i) {
- if (!((*message_)[strings::msg_params][strings::turn_list][i].
- keyExists(hmi_request::navi_text)) &&
- !((*message_)[strings::msg_params][strings::turn_list][i].
- keyExists(strings::turn_icon))) {
+ if (!((*message_)[strings::msg_params][strings::turn_list][i].keyExists(
+ hmi_request::navi_text)) &&
+ !((*message_)[strings::msg_params][strings::turn_list][i].keyExists(
+ strings::turn_icon))) {
return false;
}
}
@@ -202,7 +209,8 @@ bool UpdateTurnListRequest::IsWhiteSpaceExist() {
if ((*it_tl).keyExists(strings::navigation_text)) {
str = (*it_tl)[strings::navigation_text].asCharArray();
if (!CheckSyntax(str)) {
- LOG4CXX_ERROR(logger_,
+ LOG4CXX_ERROR(
+ logger_,
"Invalid turn_list navigation_text text syntax check failed");
return true;
}
@@ -211,12 +219,11 @@ bool UpdateTurnListRequest::IsWhiteSpaceExist() {
if ((*it_tl).keyExists(strings::turn_icon)) {
str = (*it_tl)[strings::turn_icon][strings::value].asCharArray();
if (!CheckSyntax(str)) {
- LOG4CXX_ERROR(logger_,
- "Invalid turn_list turn_icon value syntax check failed");
+ LOG4CXX_ERROR(
+ logger_, "Invalid turn_list turn_icon value syntax check failed");
return true;
}
}
-
}
}
return false;
diff --git a/src/components/application_manager/src/commands/mobile/update_turn_list_response.cc b/src/components/application_manager/src/commands/mobile/update_turn_list_response.cc
index 26e5c460d3..d40a4546fc 100644
--- a/src/components/application_manager/src/commands/mobile/update_turn_list_response.cc
+++ b/src/components/application_manager/src/commands/mobile/update_turn_list_response.cc
@@ -32,24 +32,23 @@
*/
#include "application_manager/commands/mobile/update_turn_list_response.h"
-#include "application_manager/application_manager_impl.h"
+
#include "interfaces/HMI_API.h"
namespace application_manager {
namespace commands {
-UpdateTurnListResponse::UpdateTurnListResponse(const MessageSharedPtr& message)
- : CommandResponseImpl(message) {
-}
+UpdateTurnListResponse::UpdateTurnListResponse(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandResponseImpl(message, application_manager) {}
-UpdateTurnListResponse::~UpdateTurnListResponse() {
-}
+UpdateTurnListResponse::~UpdateTurnListResponse() {}
void UpdateTurnListResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- ApplicationManagerImpl::instance()->SendMessageToMobile(message_);
+ application_manager_.SendMessageToMobile(message_);
}
} // namespace commands