AppFile() {
}
AppFile(const std::string& name, bool persistent, bool download_complete,
- mobile_apis::FileType::eType type)
+ mobile_apis::FileType::eType type)
: is_persistent(persistent),
is_download_complete(download_complete),
file_name(name),
*/
ResumeCtrl& resume_controller() { return resume_ctrl_; }
+ uint32_t GetGrammarID();
/*
* @brief Save binary data to specified directory
*
private:
+ /*
+ * @brief Sends VR AddCommand request to HMI
+ *
+ * @param app_id Application ID
+ *
+ */
+ void SendVRAddCommandRequest(application_manager::ApplicationSharedPtr const app);
+
/*
* @brief Checks incoming choiseSet params.
* @param app Registred mobile application
void ProcessPerformInteractionResponse
(const smart_objects::SmartObject& message);
- /*
- * @brief Sends VR AddCommand request to HMI
- *
- * @param app_id Application ID
- *
- */
- void SendVRAddCommandRequest(application_manager::ApplicationSharedPtr const app);
/*
* @brief Sends UI PerformInteraction request to HMI
#include "application_manager/commands/command_request_impl.h"
#include "utils/macro.h"
+#include "application_manager/application_manager_impl.h"
namespace application_manager {
const char interaction_choice_set_id_list[] = "interactionChoiceSetIDList";
const char choice_set[] = "choiceSet";
const char choice_id[] = "choiceID";
+const char grammar_id[] = "grammarID";
const char navigation_text_1[] = "navigationText1";
const char navigation_text_2[] = "navigationText2";
const char alert_text1[] = "alertText1";
const char sync_file_name[] = "syncFileName";
const char file_name[] = "fileName";
const char file_type[] = "fileType";
+const char file_size[] = "fileSize";
+const char request_type[] = "requestType";
const char persistent_file[] = "persistentFile";
const char file_data[] = "fileData";
const char space_available[] = "spaceAvailable";
namespace application_manager {
-ApplicationImpl::ApplicationImpl(
- uint32_t application_id,
- const std::string& global_app_id,
- usage_statistics::StatisticsManager* statistics_manager)
+ApplicationImpl::ApplicationImpl(uint32_t application_id)
: app_id_(application_id),
active_message_(NULL),
is_media_(false),
is_app_allowed_(true),
has_been_activated_(false),
tts_speak_state_(false),
- device_(0),
- usage_report_(global_app_id, statistics_manager) {
+ device_(0) {
}
ApplicationImpl::~ApplicationImpl() {
}
hmi_level_ = hmi_level;
- usage_report_.RecordHmiStateChanged(hmi_level);
}
void ApplicationImpl::set_hmi_supports_navi_streaming(const bool& supports) {
return (subscribed_vehicle_info_.size() == old_size - 1);
}
-ApplicationUsageReport& ApplicationImpl::usage_report() {
- return usage_report_;
-}
-
const std::set<mobile_apis::ButtonName::eType>& ApplicationImpl::SubscribedButtons() const {
return subscribed_buttons_;
}
resume_ctrl_(this)
{
LOG4CXX_INFO(logger_, "Creating ApplicationManager");
+ srand(time(NULL));
if (!policies_manager_.Init()) {
LOG4CXX_ERROR(logger_, "Policies manager initialization failed.");
return;
return false;
}
+uint32_t ApplicationManagerImpl::GetGrammarID() {
+ return rand();
+}
+
bool ApplicationManagerImpl::OnServiceStartedCallback(
const connection_handler::DeviceHandle& device_handle,
const int32_t& session_key,
void OnPutFileNotification::Run() {
LOG4CXX_INFO(logger_, "OnPutFileNotification::Run");
-
- //(*message_)[strings::params][strings::function_id] =
- // static_cast<int32_t>(mobile_apis::FunctionID::eType::OnSystemRequestID);
SendNotification();
}
(*message_)[strings::params][strings::function_id] =
static_cast<int32_t>(mobile_apis::FunctionID::eType::OnSystemRequestID);
- ApplicationManagerImpl* app_mgr = ApplicationManagerImpl::instance();
- const std::set<ApplicationSharedPtr>& app_list = app_mgr->applications();
- std::set<ApplicationSharedPtr>::const_iterator it = app_list.begin();
- for (; app_list.end() != it; ++it) {
- (*message_)[strings::params][strings::connection_key] =
- static_cast<int32_t>((*it)->app_id());
- SendNotificationToMobile(message_);
- }
+ (*message_)[strings::params][strings::connection_key] =
+ (*message_)[strings::msg_params][strings::app_id];
+ SendNotificationToMobile(message_);
}
} // namespace commands
vr_msg_params[strings::app_id] = app->app_id();
vr_msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command;
+ vr_msg_params[strings::grammar_id] = ApplicationManagerImpl::instance()->GetGrammarID();
send_vr_ = true;
}
SendResponse(false, result);
return;
}
-
+ uint32_t grammar_id = ApplicationManagerImpl::instance()->GetGrammarID();
+ (*message_)[strings::msg_params][strings::grammar_id] = grammar_id;
app->AddChoiceSet(choice_set_id, (*message_)[strings::msg_params]);
-
+ SendVRAddCommandRequest(app);
SendResponse(true, result_);
app->UpdateHash();
}
return 0 == strcasecmp(str1.asCharArray(), str2.asCharArray());
}
+void CreateInteractionChoiceSetRequest::SendVRAddCommandRequest(
+ application_manager::ApplicationSharedPtr const app) {
+
+ smart_objects::SmartObject* choice_set = &(*message_)[strings::msg_params];
+
+ for (size_t j = 0; j < (*choice_set)[strings::choice_set].length(); ++j) {
+ 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] =
+ (*choice_set)[strings::choice_set][j][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][j][strings::vr_commands];
+
+ msg_params[strings::type] = hmi_apis::Common_VRCommandType::Choice;
+ msg_params[strings::grammar_id] = (*choice_set)[strings::grammar_id];
+
+ SendHMIRequest(hmi_apis::FunctionID::VR_AddCommand, &msg_params);
+ }
+
+}
+
} // namespace commands
*/
#include "application_manager/commands/mobile/on_system_request_notification.h"
+#include "interfaces/MOBILE_API.h"
+#include "utils/file_system.h"
namespace application_manager {
void OnSystemRequestNotification::Run() {
LOG4CXX_INFO(logger_, "OnSystemRequestNotification::Run");
+ mobile_apis::RequestType::eType request_type = static_cast<mobile_apis::RequestType::eType>
+ ((*message_)[strings::msg_params][strings::request_type].asInt());
+
+ if (false == (*message_)[strings::msg_params].keyExists(strings::file_name)) {
+ return;
+ }
+ std::string filename = (*message_)[strings::msg_params][strings::file_name].asString();
+
+ if (mobile_apis::RequestType::PROPRIETARY == request_type) {
+ std::vector<uint8_t> binary_data;
+ file_system::ReadBinaryFile(filename, binary_data);
+ (*message_)[strings::msg_params][strings::binary_data] = binary_data;
+ }
+
SendNotification();
}
// timer_.start(2);
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
- (*message_)[strings::params][strings::connection_key].asUInt());
+ ApplicationSharedPtr app =
+ ApplicationManagerImpl::instance()->application(connection_key());
if (!app) {
LOG4CXX_ERROR(logger_, "Application is not registered");
}
app->set_perform_interaction_active(correlation_id);
- SendVRAddCommandRequest(app);
SendTTSPerformInteractionRequest(app);
SendUIPerformInteractionRequest(app);
break;
// TODO(DK): need to implement timeout
app->set_perform_interaction_active(correlation_id);
- SendVRAddCommandRequest(app);
SendTTSPerformInteractionRequest(app);
SendUIPerformInteractionRequest(app);
break;
void PerformInteractionRequest::onTimeOut() {
LOG4CXX_INFO(logger_, "PerformInteractionRequest::onTimeOut");
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
- (*message_)[strings::params][strings::connection_key].asUInt());
- if (app) {
-
- // Unsubscribe from event on UIPerformInteractionResponse to
- // avoid of double execution of SendVrDeleteCommand()
- unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction);
- SendVrDeleteCommand(app);
- app->set_perform_interaction_active(0);
- app->set_perform_interaction_mode(-1);
- app->DeletePerformInteractionChoiceSetMap();
- }
+
+ // Unsubscribe from event on UIPerformInteractionResponse to
+ // avoid of double execution of SendVrDeleteCommand()
+ unsubscribe_from_event(hmi_apis::FunctionID::UI_PerformInteraction);
+ DisablePerformInteraction();
CommandRequestImpl::onTimeOut();
}
+
void PerformInteractionRequest::ProcessVRNotification(
const smart_objects::SmartObject& message) {
LOG4CXX_INFO(logger_, "PerformInteractionRequest::ProcessVRNotification");
smart_objects::SmartType_Map);
c_p_request_so[hmi_request::method_name] = "UI.PerformInteraction";
SendHMIRequest(hmi_apis::FunctionID::UI_ClosePopUp, &(c_p_request_so));
- SendVrDeleteCommand(app);
- app->set_perform_interaction_mode(-1);
- app->DeletePerformInteractionChoiceSetMap();
- app->set_perform_interaction_active(0);
+ DisablePerformInteraction();
(*message_)[strings::params][strings::function_id] =
static_cast<int32_t>(mobile_apis::FunctionID::PerformInteractionID);
(const smart_objects::SmartObject& message) {
LOG4CXX_INFO(logger_,
"PerformInteractionRequest::ProcessAppUnregisteredNotification");
- const uint32_t app_id = (*message_)[strings::params]
- [strings::connection_key].asUInt();
+ const uint32_t app_id = connection_key();
if (app_id == message[strings::msg_params][strings::app_id].asUInt()) {
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id);
- if (!app) {
- LOG4CXX_ERROR(logger_, "NULL pointer");
- return;
- }
- if (app->is_perform_interaction_active()) {
- if (static_cast<int32_t>(mobile_apis::InteractionMode::MANUAL_ONLY) !=
- app->perform_interaction_mode()) {
- SendVrDeleteCommand(app);
- }
- app->set_perform_interaction_mode(-1);
- app->DeletePerformInteractionChoiceSetMap();
- app->set_perform_interaction_active(0);
- }
+ DisablePerformInteraction();
} else {
LOG4CXX_INFO(logger_, "Notification was sent from another application");
}
void PerformInteractionRequest::SendVrDeleteCommand(
application_manager::ApplicationSharedPtr const app) {
LOG4CXX_INFO(logger_, "PerformInteractionRequest::SendVrDeleteCommand");
- const PerformChoiceSetMap& choice_set_map = app
- ->performinteraction_choice_set_map();
+
+ const PerformChoiceSetMap& choice_set_map =
+ app->performinteraction_choice_set_map();
+
PerformChoiceSetMap::const_iterator it = choice_set_map.begin();
for (; choice_set_map.end() != it; ++it) {
const smart_objects::SmartObject& choice_set = (*it->second).getElement(
const smart_objects::SmartObject& message) {
LOG4CXX_INFO(logger_,
"PerformInteractionRequest::ProcessPerformInteractionResponse");
- ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
- (*message_)[strings::params][strings::connection_key].asUInt());
- if (!app) {
- LOG4CXX_ERROR(logger_, "NULL pointer");
- return;
- }
- if (app->is_perform_interaction_active()) {
- if (static_cast<int32_t>(mobile_apis::InteractionMode::MANUAL_ONLY)
- != app->perform_interaction_mode()) {
- SendVrDeleteCommand(app);
- }
- app->set_perform_interaction_mode(-1);
- app->DeletePerformInteractionChoiceSetMap();
- app->set_perform_interaction_active(0);
- }
- (*message_)[strings::params][strings::function_id] =
- static_cast<int32_t>(mobile_apis::FunctionID::PerformInteractionID);
- smart_objects::SmartObject msg_params = smart_objects::SmartObject(
- smart_objects::SmartType_Map);
- msg_params = message[strings::msg_params];
- bool result = false;
- int32_t hmi_response_code =
- message[strings::params][hmi_response::code].asInt();
- if (hmi_apis::Common_Result::SUCCESS ==
- hmi_apis::Common_Result::eType(hmi_response_code)) {
- if (message[strings::msg_params].keyExists(strings::manual_text_entry)) {
- msg_params[strings::trigger_source] = mobile_apis::TriggerSource::TS_KEYBOARD;
- } else {
- msg_params[strings::trigger_source] = mobile_apis::TriggerSource::TS_MENU;
- }
- result = true;
- }
-
- const char* return_info = NULL;
- mobile_apis::Result::eType result_code =
- static_cast<mobile_apis::Result::eType>(hmi_response_code);
- if (result) {
- if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE ==
- hmi_apis::Common_Result::eType(hmi_response_code)) {
- result_code = mobile_apis::Result::WARNINGS;
- return_info = std::string(
- "Unsupported phoneme type sent in any item").c_str();
- }
- }
- SendResponse(result,
- result_code,
- return_info,
- &(msg_params));
-}
+ DisablePerformInteraction();
-void PerformInteractionRequest::SendVRAddCommandRequest(
- application_manager::ApplicationSharedPtr const app) {
- smart_objects::SmartObject& choice_list =
- (*message_)[strings::msg_params][strings::interaction_choice_set_id_list];
-
- mobile_apis::InteractionMode::eType mode =
- static_cast<mobile_apis::InteractionMode::eType>(
- (*message_)[strings::msg_params][strings::interaction_mode].asInt());
-
- if (mobile_apis::InteractionMode::VR_ONLY == mode) {
- // TODO(DK): We need subscribe perform interaction with on command
- // notification
- /*CreateHMIRequest(hmi_apis::FunctionID::UI_PerformInteraction,
- smart_objects::SmartObject(smart_objects::SmartType_Map), true, 1);*/
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ msg_params = message[strings::msg_params];
+
+ bool result = false;
+ int32_t hmi_response_code =
+ message[strings::params][hmi_response::code].asInt();
+ if (hmi_apis::Common_Result::SUCCESS ==
+ hmi_apis::Common_Result::eType(hmi_response_code)) {
+ if (message[strings::msg_params].keyExists(strings::manual_text_entry)) {
+ msg_params[strings::trigger_source] = mobile_apis::TriggerSource::TS_KEYBOARD;
+ } else {
+ msg_params[strings::trigger_source] = mobile_apis::TriggerSource::TS_MENU;
+ }
+ result = true;
}
- for (size_t i = 0; i < choice_list.length(); ++i) {
- smart_objects::SmartObject* choice_set = app->FindChoiceSet(
- choice_list[i].asInt());
-
- if (choice_set) {
- for (size_t j = 0; j < (*choice_set)[strings::choice_set].length(); ++j) {
- 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] =
- (*choice_set)[strings::choice_set][j][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][j][strings::vr_commands];
-
- msg_params[strings::type] = hmi_apis::Common_VRCommandType::Choice;
- SendHMIRequest(hmi_apis::FunctionID::VR_AddCommand, &msg_params);
- }
+ const char* return_info = NULL;
+ mobile_apis::Result::eType result_code =
+ static_cast<mobile_apis::Result::eType>(hmi_response_code);
+ if (result) {
+ if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE ==
+ hmi_apis::Common_Result::eType(hmi_response_code)) {
+ result_code = mobile_apis::Result::WARNINGS;
+ return_info = std::string(
+ "Unsupported phoneme type sent in any item").c_str();
}
}
+
+ SendResponse(result, result_code, return_info, &(msg_params));
}
+
+
void PerformInteractionRequest::SendUIPerformInteractionRequest(
application_manager::ApplicationSharedPtr const app) {
smart_objects::SmartObject& choice_set_id_list =
smart_objects::SmartObject(smart_objects::SmartType_Array);
int32_t index = 0;
+ int32_t grammar_id_index = 0;
+
+ msg_params[strings::grammar_id] = smart_objects::SmartObject(smart_objects::SmartType_Array);
for (uint32_t i = 0; i < choice_list.length(); ++i) {
smart_objects::SmartObject* choice_set =
app->FindChoiceSet(choice_list[i].asInt());
msg_params[strings::help_prompt][index++] = item;
}
}
+ msg_params[strings::grammar_id][grammar_id_index++]= (*choice_set)[strings::grammar_id];
+ } else {
+ LOG4CXX_ERROR(logger_, "Can't found choiset!")
}
}
}
return true;
}
+void PerformInteractionRequest::DisablePerformInteraction() {
+ ApplicationSharedPtr app =
+ ApplicationManagerImpl::instance()->application(connection_key());
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "NULL pointer");
+ return;
+ }
+
+ if (app->is_perform_interaction_active()) {
+ app->set_perform_interaction_active(0);
+ app->set_perform_interaction_mode(-1);
+ app->DeletePerformInteractionChoiceSetMap();
+ }
+}
+
} // namespace commands
} // namespace application_manager
if (offset_exist) {
offset_ = (*message_)[strings::msg_params][strings::offset].asInt();
}
- if ((*message_)[strings::msg_params].keyExists(strings::length)) {
- length_ =
- (*message_)[strings::msg_params][strings::length].asInt();
- }
+
if ((*message_)[strings::msg_params].
keyExists(strings::persistent_file)) {
is_persistent_file_ =
application->increment_put_file_in_none_count();
}
}
-// For future implementation ( when length will contains file size)
-// if (offset + binary_data.size() == length) {
-// LOG4CXX_INFO(logger_, "File is Fully downloaded");
-// if (!application->UpdateFile(file)) {
-// // If it is impossible to update file, application doesn't know about existing this file
-// SendResponse(false, mobile_apis::Result::INVALID_DATA);
-// return;
-// }
-// } else {
-// //TODO: Maybe need to save in AppFile information about downloading progress
-// }
- SendResponse(true, save_result, "File downloaded", &response_params);
+
+ SendResponse(true, save_result, "File is downloaded", &response_params);
if (is_system_file) {
SendOnPutFileNotification();
}
}
void PutFileRequest::SendOnPutFileNotification() {
-
+ LOG4CXX_INFO(logger_, "SendOnPutFileNotification" );
smart_objects::SmartObject* notification = new smart_objects::SmartObject(
smart_objects::SmartType_Map);
message[strings::msg_params][strings::app_id] = connection_key();
message[strings::msg_params][strings::sync_file_name] = sync_file_name_;
message[strings::msg_params][strings::offset] = offset_;
+ if ( offset_ == 0 ) {
+ message[strings::msg_params][strings::file_size] =
+ (*message_)[strings::msg_params][strings::length];
+ }
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(&message);
}
Formatters::CFormatterJsonBase::jsonValueToObj(json_choiset , msg_param);
const int32_t choice_set_id = msg_param
[strings::interaction_choice_set_id].asInt();
+ uint32_t grammar_id = msg_param[strings::grammar_id].asUInt();
application->AddChoiceSet(choice_set_id, msg_param);
+
+ for (size_t j = 0; j < msg_param[strings::choice_set].length(); ++j) {
+ smart_objects::SmartObject choise_params = smart_objects::SmartObject(
+ smart_objects::SmartType_Map);
+ choise_params[strings::app_id] = application->app_id();
+ choise_params[strings::cmd_id] =
+ msg_param[strings::choice_set][j][strings::choice_id];
+ choise_params[strings::vr_commands] = smart_objects::SmartObject(
+ smart_objects::SmartType_Array);
+ choise_params[strings::vr_commands] =
+ msg_param[strings::choice_set][j][strings::vr_commands];
+
+ choise_params[strings::type] = hmi_apis::Common_VRCommandType::Choice;
+ choise_params[strings::grammar_id] = grammar_id;
+
+ SendHMIRequest(hmi_apis::FunctionID::VR_AddCommand, &choise_params);
+ }
}
//setglobal properties
<element name="FILE_RESUME" />
<element name="AUTH_REQUEST" />
<element name="AUTH_CHALLENGE" />
- <element name="AUTH_ACK" />
+ <element name="AUTH_ACK" />
+ <element name="PROPRIETARY" />
</enum>
<enum name="ECallConfirmationStatus">
<description>Must be true if allowed</description>
</param>
</function>
+
<function name="OnSystemRequest" messagetype="notification" >
<description>
An asynchronous request from the system for specific data from the device or the cloud or response to a request from the device or cloud
</param>
<param name="timeout" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="false">
</param>
+ <param name="fileName" type="String" maxlength="255" mandatory="true">
+ <description>File reference name.</description>
+ </param>
+ <param name="appID" type="Integer" mandatory="true">
+ <description>ID of application that requested this RPC.</description>
+ </param>
</function>
+
<function name="OnSDLClose" messagetype="notification">
<description>SDL must notify HMI about finish working application</description>
</function>
<element name="FILE_RESUME" />
<element name="AUTH_REQUEST" />
<element name="AUTH_CHALLENGE" />
- <element name="AUTH_ACK" />
+ <element name="AUTH_ACK" />
+ <element name="PROPRIETARY" />
</enum>
<enum name="AppHMIType">
</param>
<param name="length" type="Integer" minvalue="0" maxvalue="100000000000" mandatory="false">
<description>Optional length in bytes for resuming partial data chunks</description>
- </param>
+ </param>
</function>
<!-- ~~~~~~~~~~~~~~~~~~ -->
<element name="FILE_RESUME" />
<element name="AUTH_REQUEST" />
<element name="AUTH_CHALLENGE" />
- <element name="AUTH_ACK" />
+ <element name="AUTH_ACK" />
+ <element name="PROPRIETARY" />
</enum>
<enum name="ECallConfirmationStatus">
</param>
<param name="timeout" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="false">
</param>
+ <param name="fileName" type="String" maxlength="255" mandatory="true">
+ <description>File reference name.</description>
+ </param>
+ <param name="appID" type="Integer" mandatory="true">
+ <description>ID of application that requested this RPC.</description>
+ </param>
</function>
<function name="OnPutFile" messagetype="notification" >