const MessageSharedPtr& message)
: CommandRequestImpl(message),
timer_(this, &PerformInteractionRequest::onTimer),
- tts_perform_interaction_code_(mobile_apis::Result::INVALID_ENUM) {
+ vr_perform_interaction_code_(mobile_apis::Result::INVALID_ENUM),
+ interaction_mode_(mobile_apis::InteractionMode::INVALID_ENUM),
+ ui_response_recived(false),
+ vr_response_recived(false) {
subscribe_on_event(hmi_apis::FunctionID::UI_OnResetTimeout);
subscribe_on_event(hmi_apis::FunctionID::VR_OnCommand);
app->set_perform_interaction_mode(mode);
- mobile_apis::InteractionMode::eType interaction_mode =
+ interaction_mode_ =
static_cast<mobile_apis::InteractionMode::eType>(mode);
- switch (interaction_mode) {
+ switch (interaction_mode_) {
case mobile_apis::InteractionMode::BOTH: {
LOG4CXX_INFO(logger_, "Interaction Mode: BOTH");
if (!CheckChoiceSetVRSynonyms(app)) {
}
app->set_perform_interaction_active(correlation_id);
- SendVRPerformInteractionRequest(app);
SendUIPerformInteractionRequest(app);
break;
}
default_timeout());
break;
}
- case hmi_apis::FunctionID::VR_OnCommand: {
- LOG4CXX_INFO(logger_, "Received VR_OnCommand event");
- ProcessVRNotification(event.smart_object());
- break;
- }
+
case hmi_apis::FunctionID::UI_PerformInteraction: {
LOG4CXX_INFO(logger_, "Received UI_PerformInteraction event");
ProcessPerformInteractionResponse(event.smart_object());
}
case hmi_apis::FunctionID::VR_PerformInteraction: {
LOG4CXX_INFO(logger_, "Received TTS_PerformInteraction");
- tts_perform_interaction_code_ = static_cast<mobile_apis::Result::eType>(
- event.smart_object()[strings::params][hmi_response::code].asInt());
+ ProcessVRResponse(event.smart_object());
break;
}
default: {
void PerformInteractionRequest::onTimeOut() {
LOG4CXX_INFO(logger_, "PerformInteractionRequest::onTimeOut");
- // Unsubscribe from event on UIPerformInteractionResponse to
- // avoid of double execution of SendVrDeleteCommand()
- unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction);
- DisablePerformInteraction();
- CommandRequestImpl::onTimeOut();
+
+ switch (interaction_mode_) {
+ case mobile_apis::InteractionMode::BOTH: {
+ if (true == vr_response_recived) {
+ unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction);
+ DisablePerformInteraction();
+ CommandRequestImpl::onTimeOut();
+ } else {
+ ApplicationManagerImpl::instance()->updateRequestTimeout(connection_key(),
+ correlation_id(),
+ default_timeout());
+ }
+ break;
+ }
+ case mobile_apis::InteractionMode::VR_ONLY: {
+ ApplicationManagerImpl::instance()->updateRequestTimeout(connection_key(),
+ correlation_id(),
+ default_timeout());
+ break;
+ }
+ case mobile_apis::InteractionMode::MANUAL_ONLY: {
+ unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction);
+ DisablePerformInteraction();
+ CommandRequestImpl::onTimeOut();
+ break;
+ }
+ };
}
-void PerformInteractionRequest::ProcessVRNotification(
+void PerformInteractionRequest::ProcessVRResponse(
const smart_objects::SmartObject& message) {
LOG4CXX_INFO(logger_, "PerformInteractionRequest::ProcessVRNotification");
- const uint32_t app_id = message[strings::msg_params][strings::app_id]
- .asUInt();
+ const uint32_t app_id = connection_key();
ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
- if (!app) {
+ if (!app.get()) {
LOG4CXX_ERROR(logger_, "NULL pointer");
return;
}
- int32_t cmd_id = message[strings::msg_params][strings::cmd_id].asInt();
+
+ vr_response_recived = true;
+ vr_perform_interaction_code_ = static_cast<mobile_apis::Result::eType>(
+ message[strings::params][hmi_response::code].asInt());
+ if (mobile_apis::Result::ABORTED == vr_perform_interaction_code_) {
+ LOG4CXX_INFO(logger_, "VR response abborted");
+ if (mobile_apis::InteractionMode::VR_ONLY == interaction_mode_) {
+ LOG4CXX_INFO(logger_, "Abort send Close Popup");
+ smart_objects::SmartObject c_p_request_so = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+ c_p_request_so[hmi_request::method_name] = "UI.PerformInteraction";
+ SendHMIRequest(hmi_apis::FunctionID::UI_ClosePopUp, &(c_p_request_so));
+ DisablePerformInteraction();
+ SendResponse(false, mobile_apis::Result::ABORTED);
+ return;
+ } else {
+ LOG4CXX_INFO(logger_, "Update timeout for UI");
+ ApplicationManagerImpl::instance()->updateRequestTimeout(connection_key(),
+ correlation_id(),
+ default_timeout());
+ return;
+ }
+ }
+
+ int32_t choise_id = message[strings::msg_params][strings::choice_id].asInt();
const PerformChoiceSetMap& choice_set_map = app
->performinteraction_choice_set_map();
bool choice_id_chosen = false;
const smart_objects::SmartObject& choice_set = (*it->second).getElement(
strings::choice_set);
for (size_t j = 0; j < choice_set.length(); ++j) {
- if (cmd_id ==
+ if (choise_id ==
choice_set.getElement(j).getElement(strings::choice_id).asInt()) {
choice_id_chosen = true;
break;
static_cast<int32_t>(mobile_apis::FunctionID::PerformInteractionID);
smart_objects::SmartObject msg_params = smart_objects::SmartObject(
smart_objects::SmartType_Map);
- msg_params[strings::choice_id] = cmd_id;
+ msg_params[strings::choice_id] = choise_id;
msg_params[strings::trigger_source] =
static_cast<int32_t>(mobile_apis::TriggerSource::TS_VR);
SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &(msg_params));
const smart_objects::SmartObject& message) {
LOG4CXX_INFO(logger_,
"PerformInteractionRequest::ProcessPerformInteractionResponse");
-
+ ui_response_recived = true;
DisablePerformInteraction();
smart_objects::SmartObject msg_params =