${CMAKE_BINARY_DIR}/src/components/
${CMAKE_SOURCE_DIR}/src/components/policy/src/policy/include/
${CMAKE_SOURCE_DIR}/src/components/policy/src/policy/usage_statistics/include/
- ${CMAKE_BINARY_DIR}/src/components/policy/src/policy/
)
set (SOURCES
)
if (EXTENDED_POLICY_FLAG)
+ include_directories(
+ ${CMAKE_SOURCE_DIR}/src/components/policy/src/policy/policy_table/table_struct_ext
+ )
list(APPEND POLICIES_MANAGER
./src/policies/pt_exchange_handler_ext.cc
./src/policies/pt_exchange_handler_impl.cc
)
else ()
+ include_directories(
+ ${CMAKE_SOURCE_DIR}/src/components/policy/src/policy/policy_table/table_struct
+ )
list(APPEND POLICIES_MANAGER
./src/policies/pt_exchange_handler_impl.cc
)
target_link_libraries("ApplicationManager" ${LIBRARIES})
if(ENABLE_LOG)
- target_link_libraries("ApplicationManager" log4cxx)
+ add_dependencies("ApplicationManager" liblog4cxx)
+ target_link_libraries("ApplicationManager" log4cxx -L${LOG4CXX_LIBS_DIRECTORY})
endif()
#include "interfaces/v4_protocol_v1_2_no_extra.h"
#include "interfaces/v4_protocol_v1_2_no_extra_schema.h"
+#ifdef TIME_TESTER
#include "time_metric_observer.h"
+#endif // TIME_TESTER
#include "protocol_handler/service_type.h"
#include "utils/macro.h"
HMICapabilities& hmi_capabilities();
+#ifdef TIME_TESTER
/**
* @brief Setup observer for time metric.
*
* @param observer - pointer to observer
*/
void SetTimeMetricObserver(AMMetricObserver* observer);
+#endif // TIME_TESTER
ApplicationSharedPtr RegisterApplication(
const utils::SharedPtr<smart_objects::SmartObject>& request_for_registration);
void set_hmi_message_handler(hmi_message_handler::HMIMessageHandler* handler);
void set_connection_handler(connection_handler::ConnectionHandler* handler);
+ connection_handler::ConnectionHandler* connection_handler();
void set_protocol_handler(protocol_handler::ProtocolHandler* handler);
///////////////////////////////////////////////////////
void OnErrorSending(hmi_message_handler::MessageSharedPointer message);
void OnDeviceListUpdated(const connection_handler::DeviceList& device_list);
+ //TODO (EZamakhov): fix all indentations in this file
+ void OnApplicationListUpdated(const connection_handler::DeviceHandle& device_handle);
void RemoveDevice(const connection_handler::DeviceHandle& device_handle);
bool OnServiceStartedCallback(
const connection_handler::DeviceHandle& device_handle,
*/
bool IsHMICooperating() const;
+ /**
+ * Function used only by HMI request/response/notification base classes
+ * to change HMI app id to Mobile app id and vice versa.
+ * Dot use it inside Core
+ */
+ ApplicationSharedPtr application_by_hmi_app(int32_t hmi_app_id) const;
+
private:
ApplicationManagerImpl();
bool InitThread(threads::Thread* thread);
virtual void Handle(const impl::MessageFromHmi& message) OVERRIDE;
// CALLED ON messages_to_hmi_ thread!
- virtual void Handle(const impl::MessageToHmi& message) OVERRIDE;
-
- /**
- * Function used only by HMI request/response/notification base classes
- * to change HMI app id to Mobile app id and vice versa.
- * Dot use it inside Core
- */
- ApplicationSharedPtr application_by_hmi_app(int32_t hmi_app_id) const;
+ virtual void Handle(const impl::MessageToHmi& message) OVERRIDE;
private:
hmi_apis::HMI_API* hmi_so_factory_;
mobile_apis::MOBILE_API* mobile_so_factory_;
+#ifdef TIME_TESTER
AMMetricObserver* metric_observer_;
+#endif // TIME_TESTER
static uint32_t corelation_id_;
static const uint32_t max_corelation_id_;
namespace smart_objects = NsSmartDeviceLink::NsSmartObjects;
/*
- * @brief Typedef for HMI TextFieldName type
- */
-typedef enum {
- MAIN_FILED1 = 0,
- MAIN_FILED2,
- MAIN_FILED3,
- MAIN_FILED4,
- STATUS_BAR,
- MEDIA_CLOCK,
- MEDIA_TRACK,
- ALERT_TEXT1,
- ALERT_TEXT2,
- ALERT_TEXT3,
- SCROLLABLE_MSG_BODY,
- INITIAL_INTERACTION_TEXT,
- NAVI_TEXT1,
- NAVI_TEXT2,
- ETA,
- TOTAL_DISTANCE,
- NAVI_TEXT,
- AUDIO_DISPLAY_TEXT1,
- AUDIO_DISPLAY_TEXT2,
- SLIDER_HADER,
- SLIDER_FOOTEER
-} TextFieldName;
-
-/*
* @brief Typedef for VehicleData
*
* @param const char* Name of the parameter in mobile request
uint32_t cmd_id, const smart_objects::SmartObject& vr_commands,
uint32_t app_id);
+ /*
+ * @brief Create Common.HMIApplication struct application instance
+ * @param app : applicaton instace
+ * @param output smart object to store Common.HMIApplication struct
+ * @return true on succes, otherwise return false;
+ */
+ static bool CreateHMIApplicationStruct(ApplicationConstSharedPtr app,
+ smart_objects::SmartObject& output);
+
static void SendAddSubMenuRequestToHMI(ApplicationConstSharedPtr app);
static SmartObjectList CreateAddSubMenuRequestToHMI(ApplicationConstSharedPtr app);
static void SendOnAppUnregNotificationToHMI(ApplicationConstSharedPtr app);
static void ResetGlobalproperties(ApplicationSharedPtr app);
- static void SendActivateAppToHMI(uint32_t const app_id);
+ static void SendActivateAppToHMI(
+ uint32_t const app_id,
+ hmi_apis::Common_HMILevel::eType level = hmi_apis::Common_HMILevel::FULL);
static void SendOnResumeAudioSourceToHMI(const uint32_t app_id);
static std::string GetDeviceMacAddressForHandle(
- const uint32_t device_handle);
+ const uint32_t device_handle);
static void GetDeviceInfoForHandle(const uint32_t device_handle,
policy::DeviceParams* device_info);
*
*/
static mobile_apis::Result::eType VerifyImageFiles(
- smart_objects::SmartObject& message, ApplicationConstSharedPtr app);
+ smart_objects::SmartObject& message, ApplicationConstSharedPtr app);
static mobile_apis::Result::eType VerifyImageVrHelpItems(
- smart_objects::SmartObject& message, ApplicationConstSharedPtr app);
+ smart_objects::SmartObject& message, ApplicationConstSharedPtr app);
static bool VerifySoftButtonText(smart_objects::SmartObject& soft_button);
return policy_manager_;
}
bool InitPolicyTable();
- bool RevertPolicyTable();
+ bool ResetPolicyTable();
+ bool ClearUserConsent();
bool SendMessageToSDK(const BinaryMessage& pt_string);
bool ReceiveMessageFromSDK(const std::string& file,
const BinaryMessage& pt_string);
std::string GetAppName(const std::string& policy_app_id);
+ /**
+ * Adds http header (temporary method)
+ * @param pt_string string without htt header
+ */
+ BinaryMessageSptr AddHttpHeader(const BinaryMessageSptr& pt_string);
+
protected:
/**
* Starts next retry exchange policy table
*/
DeviceHandles pending_device_handles_;
- /**
- * @brief True, if PTS was sent, but PTU was not reseived yet,
- * otherwise - false
- * Used for limiting device consent request per PTS/PTU session
- */
- bool is_exchange_in_progress_;
-
- /**
- * @brief Holds device ids, which were unpaired
- */
- DeviceIds unpaired_device_ids_;
-
inline PolicyManager* CreateManager();
DISALLOW_COPY_AND_ASSIGN(PolicyHandler);FRIEND_BASE_SINGLETON_CLASS(PolicyHandler);
namespace policy {
class PTExchangeHandler {
- public:
- virtual ~PTExchangeHandler();
- virtual bool StartExchange() = 0;
- // TODO(PV): exchange status; exchange completed; retry etc
-
+ public:
+ virtual ~PTExchangeHandler();
+ virtual bool StartExchange() = 0;
};
} // namespace policy
/**
* @brief Save application persistent info for future resuming
* @param application is application witch need to be saved
- * In case of IGN_OFF or Ctl-C or MEATER_RESSET this info will save to to file system
*/
void SaveApplication(ApplicationConstSharedPtr application);
bool RemoveApplicationFromSaved(ApplicationConstSharedPtr application);
/**
- * @brief Save application info to FileSystem
+ * @brief Increments ignition counter for all registered applications
*/
void IgnitionOff();
const char initial_text[] = "initialText";
const char duration[] = "duration";
const char progress_indicator[] = "progressIndicator";
+const char alert_type[] = "alertType";
const char play_tone[] = "playTone";
const char soft_buttons[] = "softButtons";
const char custom_presets[] = "customPresets";
const char name[] = "name";
const char id[] = "id";
const char application[] = "application";
+const char applications[] = "applications";
const char icon[] = "icon";
const char device_name[] = "deviceName";
const char reason[] = "reason";
const char duration[] = "duration";
const char soft_buttons[] = "softButtons";
const char tts_chunks[] = "ttsChunks";
+const char speak_type[] = "speakType";
const char audio_pass_display_texts[] = "audioPassThruDisplayTexts";
const char max_duration[] = "maxDuration";
const char reason[] = "reason";
hmi_capabilities_(this),
unregister_reason_(mobile_api::AppInterfaceUnregisteredReason::IGNITION_OFF),
media_manager_(NULL),
- resume_ctrl_(this) {
+ resume_ctrl_(this)
+#ifdef TIME_TESTER
+ , metric_observer_(NULL)
+#endif // TIME_TESTER
+{
LOG4CXX_INFO(logger_, "Creating ApplicationManager");
media_manager_ = media_manager::MediaManagerImpl::instance();
CreatePoliciesManager();
if (connection_handler_) {
connection_handler::ConnectionHandlerImpl* con_handler_impl =
static_cast<connection_handler::ConnectionHandlerImpl*>(
+
connection_handler_);
if (con_handler_impl->GetDataOnSessionKey(connection_key, &app_id,
&sessions_list, &device_id)
application->set_version(version);
application->set_mobile_app_id(message[strings::msg_params][strings::app_id]);
- application->set_protocol_version(
- static_cast<ProtocolVersion>(
- message[strings::params][strings::protocol_version].asInt()));
+ ProtocolVersion protocol_version = static_cast<ProtocolVersion>(
+ message[strings::params][strings::protocol_version].asInt());
+ application->set_protocol_version(protocol_version);
+
+ if (ProtocolVersion::kV3 == protocol_version) {
+ if (connection_handler_) {
+ connection_handler_->StartSessionHeartBeat(connection_key);
+ }
+ }
sync_primitives::AutoLock lock(applications_list_lock_);
int32_t correlation_id, int32_t max_duration, int32_t sampling_rate,
int32_t bits_per_sample, int32_t audio_type) {
LOG4CXX_INFO(logger_, "START MICROPHONE RECORDER");
- if (NULL != media_manager_) {
+ if (NULL != media_manager_) {
media_manager_->StartMicrophoneRecording(
session_key,
- std::string("record.wav"),
+ profile::Profile::instance()->recording_file_name(),
max_duration);
}
}
std::vector<uint8_t> binaryData) {
LOG4CXX_TRACE_ENTER(logger_);
- {
- sync_primitives::AutoLock lock(audio_pass_thru_lock_);
- if (!audio_pass_thru_active_) {
- LOG4CXX_ERROR(logger_, "Trying to send PassThroughNotification"
- " when PassThrough is not active");
-
- return;
- }
+ if (!audio_pass_thru_active_) {
+ LOG4CXX_ERROR(logger_, "Trying to send PassThroughNotification"
+ " when PassThrough is not active");
+ return;
}
-
smart_objects::SmartObject* on_audio_pass = NULL;
on_audio_pass = new smart_objects::SmartObject();
DCHECK(connection_handler_ != 0);
std::string device_name = "";
- std::list<uint32_t> applications_list;
connection_handler::ConnectionHandlerImpl* con_handler_impl =
static_cast<connection_handler::ConnectionHandlerImpl*>(
connection_handler_);
if (con_handler_impl->GetDataOnDeviceID(handle, &device_name,
- &applications_list) == -1) {
+ NULL) == -1) {
LOG4CXX_ERROR(logger_, "Failed to extract device name for id " << handle);
} else {
LOG4CXX_INFO(logger_, "\t\t\t\t\tDevice name is " << device_name);
ManageHMICommand(update_list);
}
+void ApplicationManagerImpl::OnApplicationListUpdated(
+ const connection_handler::DeviceHandle& device_handle) {
+ LOG4CXX_INFO(logger_, "OnApplicationListUpdated. device_handle" << device_handle);
+ DCHECK(connection_handler_ != 0);
+
+ std::string device_name = "";
+ std::list<uint32_t> applications_ids;
+ connection_handler::ConnectionHandlerImpl* con_handler_impl =
+ static_cast<connection_handler::ConnectionHandlerImpl*>(
+ connection_handler_);
+ if (con_handler_impl->GetDataOnDeviceID(device_handle, &device_name,
+ &applications_ids) == -1) {
+ LOG4CXX_ERROR(logger_, "Failed to extract device list for id " << device_handle);
+ return;
+ }
+
+ smart_objects::SmartObject* request = MessageHelper::CreateModuleInfoSO(
+ hmi_apis::FunctionID::BasicCommunication_UpdateAppList);
+ (*request)[strings::msg_params][strings::applications] =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
+
+ smart_objects::SmartObject& applications =
+ (*request)[strings::msg_params][strings::applications];
+
+ uint32_t app_count = 0;
+ for (std::list<uint32_t>::iterator it = applications_ids.begin();
+ it != applications_ids.end(); ++it) {
+ ApplicationSharedPtr app = application(*it);
+
+ if (!app.valid()) {
+ LOG4CXX_ERROR(logger_, "application not foud , id = " << *it);
+ continue;
+ }
+
+ smart_objects::SmartObject hmi_application(smart_objects::SmartType_Map);;
+ if (false == MessageHelper::CreateHMIApplicationStruct(app, hmi_application)) {
+ LOG4CXX_ERROR(logger_, "can't CreateHMIApplicationStruct ', id = " << *it);
+ continue;
+ }
+ applications[app_count++] = hmi_application;
+ }
+ if (app_count > 0) {
+ ManageHMICommand(request);
+ } else {
+ LOG4CXX_WARN(logger_, "Empty applications list");
+ }
+}
+
void ApplicationManagerImpl::RemoveDevice(
- const connection_handler::DeviceHandle& device_handle) {
+ const connection_handler::DeviceHandle& device_handle) {
+ LOG4CXX_INFO(logger_, "device_handle " << device_handle);
}
bool ApplicationManagerImpl::IsAudioStreamingAllowed(uint32_t connection_key) const {
}
void ApplicationManagerImpl::ReplaceMobileByHMIAppId(
- smart_objects::SmartObject& message) {
-
+ smart_objects::SmartObject& message) {
+ MessageHelper::PrintSmartObject(message);
+ flush(std::cout);
if (message.keyExists(strings::app_id)) {
ApplicationSharedPtr application =
- ApplicationManagerImpl::instance()->application(
- message[strings::app_id].asUInt());
+ ApplicationManagerImpl::instance()->application(
+ message[strings::app_id].asUInt());
if (application.valid()) {
LOG4CXX_INFO(logger_, "ReplaceMobileByHMIAppId from " << message[strings::app_id].asInt()
<< " to " << application->hmi_app_id());
message[strings::app_id] = application->hmi_app_id();
}
} else {
- std::set<std::string> keys = message.enumerate();
- std::set<std::string>::const_iterator key = keys.begin();
- for (; key != keys.end(); ++key) {
- ReplaceMobileByHMIAppId(message[*key]);
+ switch (message.getType()) {
+ case smart_objects::SmartType::SmartType_Array: {
+ smart_objects::SmartArray* message_array = message.asArray();
+ smart_objects::SmartArray::iterator it = message_array->begin();
+ for(; it != message_array->end(); ++it) {
+ ReplaceMobileByHMIAppId(*it);
+ }
+ break;
+ }
+ case smart_objects::SmartType::SmartType_Map: {
+ std::set<std::string> keys = message.enumerate();
+ std::set<std::string>::const_iterator key = keys.begin();
+ for (; key != keys.end(); ++key) {
+ std::string k = *key;
+ ReplaceMobileByHMIAppId(message[*key]);
+ }
+ break;
+ }
+ default: {
+ break;
+ }
}
}
}
message[strings::app_id] = application->app_id();
}
} else {
- std::set<std::string> keys = message.enumerate();
- std::set<std::string>::const_iterator key = keys.begin();
- for (; key != keys.end(); ++key) {
- ReplaceHMIByMobileAppId(message[*key]);
+ switch (message.getType()) {
+ case smart_objects::SmartType::SmartType_Array: {
+ smart_objects::SmartArray* message_array = message.asArray();
+ smart_objects::SmartArray::iterator it = message_array->begin();
+ for(; it != message_array->end(); ++it) {
+ ReplaceHMIByMobileAppId(*it);
+ }
+ break;
+ }
+ case smart_objects::SmartType::SmartType_Map: {
+ std::set<std::string> keys = message.enumerate();
+ std::set<std::string>::const_iterator key = keys.begin();
+ for (; key != keys.end(); ++key) {
+ ReplaceHMIByMobileAppId(message[*key]);
+ }
+ break;
+ }
+ default: {
+ break;
+ }
}
}
}
const protocol_handler::ServiceType& type) {
LOG4CXX_INFO(logger_,
"OnServiceStartedCallback " << type << " in session " << session_key);
-
ApplicationSharedPtr app = application(session_key);
switch (type) {
case protocol_handler::kRpc: {
LOG4CXX_INFO(logger_, "Remove application.");
UnregisterApplication(session_key, mobile_apis::Result::INVALID_ENUM,
- true);
+ false);
break;
}
case protocol_handler::kMobileNav: {
connection_handler_ = handler;
}
+connection_handler::ConnectionHandler*
+ApplicationManagerImpl::connection_handler() {
+ return connection_handler_;
+}
+
void ApplicationManagerImpl::set_protocol_handler(
protocol_handler::ProtocolHandler* handler) {
protocol_handler_ = handler;
UnregisterApplication(connection_key,
mobile_apis::Result::TOO_MANY_PENDING_REQUESTS,
- true);
+ false);
return false;
} else if (result ==
request_controller::RequestController::
REQUEST_WHILE_IN_NONE_HMI_LEVEL);
UnregisterApplication(connection_key, mobile_apis::Result::INVALID_ENUM,
- true);
+ false);
return false;
} else {
LOG4CXX_ERROR_EXT(logger_, "Unable to perform request: Unknown case");
void ApplicationManagerImpl::ProcessMessageFromMobile(
const utils::SharedPtr<Message>& message) {
LOG4CXX_INFO(logger_, "ApplicationManagerImpl::ProcessMessageFromMobile()");
+#ifdef TIME_TESTER
AMMetricObserver::MessageMetricSharedPtr metric(new AMMetricObserver::MessageMetric());
metric->begin = date_time::DateTime::getCurrentTime();
+#endif // TIME_TESTER
utils::SharedPtr<smart_objects::SmartObject> so_from_mobile(
new smart_objects::SmartObject);
LOG4CXX_ERROR(logger_, "Cannot create smart object from message");
return;
}
+#ifdef TIME_TESTER
metric->message = so_from_mobile;
+#endif // TIME_TESTER
if (!ManageMobileCommand(so_from_mobile)) {
LOG4CXX_ERROR(logger_, "Received command didn't run successfully");
}
+#ifdef TIME_TESTER
metric->end = date_time::DateTime::getCurrentTime();
if (metric_observer_) {
metric_observer_->OnMessage(metric);
}
+#endif // TIME_TESTER
}
void ApplicationManagerImpl::ProcessMessageFromHMI(
return hmi_capabilities_;
}
+#ifdef TIME_TESTER
void ApplicationManagerImpl::SetTimeMetricObserver(AMMetricObserver* observer) {
metric_observer_ = observer;
}
+#endif // TIME_TESTER
void ApplicationManagerImpl::addNotification(const CommandSharedPtr& ptr) {
notification_list_.push_back(ptr);
mobile_api::AppInterfaceUnregisteredReason::eType reason) {
switch (reason) {
case mobile_api::AppInterfaceUnregisteredReason::MASTER_RESET:
- policy::PolicyHandler::instance()->InitPolicyTable();
+ policy::PolicyHandler::instance()->ResetPolicyTable();
break;
case mobile_api::AppInterfaceUnregisteredReason::FACTORY_DEFAULTS:
- policy::PolicyHandler::instance()->RevertPolicyTable();
+ policy::PolicyHandler::instance()->ClearUserConsent();
break;
}
}
hmi_cooperating_ = false;
+ bool is_ignition_off =
+ unregister_reason_ ==
+ mobile_api::AppInterfaceUnregisteredReason::IGNITION_OFF ? true : false;
+
std::set<ApplicationSharedPtr>::iterator it = application_list_.begin();
while (it != application_list_.end()) {
MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile(
(*it)->app_id(), unregister_reason_);
UnregisterApplication((*it)->app_id(), mobile_apis::Result::INVALID_ENUM,
- true);
- it = application_list_.begin();
+ is_ignition_off);
+ it = application_list_.begin();
+ }
+ if (is_ignition_off) {
+ resume_controller().IgnitionOff();
}
- resume_controller().IgnitionOff();
}
void ApplicationManagerImpl::UnregisterApplication(
(*message_)[strings::params][hmi_response::code].asInt());
if (hmi_apis::Common_Result::SUCCESS == code) {
int32_t correlation_id = ResponseFromHMI::correlation_id();
- const uint32_t app_id = ApplicationManagerImpl::instance()->
+ // Mobile id is converted to HMI id for HMI requests
+ const uint32_t hmi_app_id = ApplicationManagerImpl::instance()->
application_id(correlation_id);
- if (!app_id) {
- LOG4CXX_ERROR(logger_, "Error app_id = "<<app_id);
+ if (!hmi_app_id) {
+ LOG4CXX_ERROR(logger_, "Error hmi_app_id = "<< hmi_app_id);
return;
}
- ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(app_id);
+ ApplicationSharedPtr application = ApplicationManagerImpl::instance()->
+ application_by_hmi_app(hmi_app_id);
if (application) {
ApplicationManagerImpl::instance()->ActivateApplication(application);
} else {
- LOG4CXX_ERROR(logger_, "Application cannot activate");
+ LOG4CXX_ERROR(logger_, "Application can't be activated.");
}
} else {
LOG4CXX_ERROR(logger_, "Error result code"<<code);
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
#include "interfaces/MOBILE_API.h"
+#include "interfaces/HMI_API.h"
namespace application_manager {
LOG4CXX_ERROR(logger_, "Application does not exist");
return;
}
+ hmi_apis::Common_ApplicationToNONEReason::eType reason;
+ reason = static_cast<hmi_apis::Common_ApplicationToNONEReason::eType>
+ ((*message_)[strings::msg_params][strings::reason].asInt());
+ switch (reason) {
+#ifdef CUSTOMER_FORD
+ case hmi_apis::Common_ApplicationToNONEReason::DRIVER_DISTRACTION_VIOLATION : {
+ MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile(
+ app_impl->app_id(),
+ mobile_api::AppInterfaceUnregisteredReason::DRIVER_DISTRACTION_VIOLATION);
+ break;
+ }
+#endif
+ case hmi_apis::Common_ApplicationToNONEReason::USER_EXIT : {
+ MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile(
+ app_impl->app_id(),
+ mobile_api::AppInterfaceUnregisteredReason::USER_EXIT);
+ break;
+ }
+ default : {
+ LOG4CXX_WARN(logger_, "Bad reason");
+ break;
+ }
+ }
app_impl->set_hmi_level(mobile_apis::HMILevel::HMI_NONE);
app_impl->set_audio_streaming_state(mobile_apis::AudioStreamingState::NOT_AUDIBLE);
app_impl->set_system_context(mobile_api::SystemContext::SYSCTXT_MAIN);
} // namespace commands
} // namespace application_manager
-
app->app_id(),
mobile_api::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE);
ApplicationManagerImpl::instance()->UnregisterApplication(
- app->app_id(), mobile_apis::Result::SUCCESS, true);
+ app->app_id(), mobile_apis::Result::SUCCESS, false);
}
}
}
app->app_id(),
mobile_api::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE);
ApplicationManagerImpl::instance()->UnregisterApplication(
- app->app_id(), mobile_apis::Result::SUCCESS, true);
+ app->app_id(), mobile_apis::Result::SUCCESS, false);
}
}
}
app->app_id(),
mobile_api::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE);
ApplicationManagerImpl::instance()->UnregisterApplication(
- app->app_id(), mobile_apis::Result::SUCCESS, true);
+ app->app_id(), mobile_apis::Result::SUCCESS, false);
}
}
}
pending_requests_.Add(hmi_apis::FunctionID::Navigation_AlertManeuver);
SendHMIRequest(hmi_apis::FunctionID::Navigation_AlertManeuver,
- &msg_params,
- true);
+ &msg_params, true);
if (tts_is_ok) {
smart_objects::SmartObject msg_params = smart_objects::SmartObject(
}
bool AlertRequest::Init() {
-
/* Timeout in milliseconds.
If omitted a standard value of 10000 milliseconds is used.*/
if ((*message_)[strings::msg_params].keyExists(strings::duration)) {
default_timeout_ = def_value;
}
+ // If soft buttons are present, SDL will not use watchdog for response
+ // timeout tracking.
+ if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) {
+ LOG4CXX_INFO(logger_, "Request contains soft buttons - request timeout "
+ "will be set to 0.");
+ default_timeout_ = 0;
+ }
+
return true;
}
return;
}
- awaiting_ui_alert_response_ = true;
if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) {
if (0 < (*message_)[strings::msg_params][strings::tts_chunks].length()) {
awaiting_tts_speak_response_ = true;
switch (event.id()) {
case hmi_apis::FunctionID::UI_OnResetTimeout: {
- LOG4CXX_INFO(logger_, "Received UI_OnResetTimeout event " << awaiting_tts_speak_response_ << " "
- << awaiting_tts_stop_speaking_response_ << " " << awaiting_ui_alert_response_);
+ LOG4CXX_INFO(logger_, "Received UI_OnResetTimeout event "
+ << awaiting_tts_speak_response_ << " "
+ << awaiting_tts_stop_speaking_response_ << " "
+ << awaiting_ui_alert_response_);
ApplicationManagerImpl::instance()->updateRequestTimeout(
connection_key(), correlation_id(), default_timeout());
break;
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 timeout is not set, watchdog will not track request timeout and
+ // HMI is responsible for response returning. In this case, if ABORTED will
+ // be rerurned from HMI, success should be sent to mobile.
+ if (mobile_apis::Result::ABORTED == response_result_ &&
+ 0 == default_timeout_) {
+ response_success_ = true;
}
+
SendResponse(response_success_, response_result_,
response_info.empty() ? NULL : response_info.c_str(),
&response_params_);
int32_t index = 0;
if ((*message_)[strings::msg_params].keyExists(strings::alert_text1)) {
msg_params[hmi_request::alert_strings][index][hmi_request::field_name] =
- TextFieldName::ALERT_TEXT1;
+ hmi_apis::Common_TextFieldName::alertText1;
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] =
- TextFieldName::ALERT_TEXT2;
+ hmi_apis::Common_TextFieldName::alertText2;
msg_params[hmi_request::alert_strings][index][hmi_request::field_text] =
(*message_)[strings::msg_params][strings::alert_text2];
index++;
}
if ((*message_)[strings::msg_params].keyExists(strings::alert_text3)) {
msg_params[hmi_request::alert_strings][index][hmi_request::field_name] =
- TextFieldName::ALERT_TEXT3;
+ hmi_apis::Common_TextFieldName::alertText3;
msg_params[hmi_request::alert_strings][index][hmi_request::field_text] =
(*message_)[strings::msg_params][strings::alert_text3];
}
msg_params[strings::progress_indicator] =
(*message_)[strings::msg_params][strings::progress_indicator];
}
+
+ // PASA Alert type
+ msg_params[strings::alert_type] = hmi_apis::Common_AlertType::UI;
+ if (awaiting_tts_speak_response_) {
+ msg_params[strings::alert_type] = hmi_apis::Common_AlertType::BOTH;
+ }
+
+ // 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;
+ SendHMIRequest(hmi_apis::FunctionID::UI_Alert, &msg_params, true);
}
- SendHMIRequest(hmi_apis::FunctionID::UI_Alert, &msg_params, true);
}
void AlertRequest::SendSpeakRequest(int32_t app_id) {
msg_params[hmi_request::tts_chunks] =
(*message_)[strings::msg_params][strings::tts_chunks];
msg_params[strings::app_id] = app_id;
+ msg_params[hmi_request::speak_type] =
+ hmi_apis::Common_SpeakType::ALERT;
SendHMIRequest(hmi_apis::FunctionID::TTS_Speak, &msg_params, true);
}
msg_params[strings::cmd_id] =
(*message_)[strings::msg_params][strings::cmd_id];
msg_params[strings::app_id] = application->app_id();
- msg_params[strings::grammar_id] = application->get_grammar_id();
// we should specify amount of required responses in the 1st request
uint32_t chaining_counter = 0;
if ((*command).keyExists(strings::vr_commands)) {
is_vr_send_ = true;
+ // VR params
+ 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, true);
}
}
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) {
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();
+ msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command;
SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params);
}
void DiagnosticMessageRequest::Run() {
LOG4CXX_INFO(logger_, "DiagnosticMessageRequest::Run");
+ uint32_t app_id = (*message_)[strings::params][strings::connection_key]
+ .asUInt();
+ ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(
+ app_id);
+
+ if (!app) {
+ LOG4CXX_ERROR_EXT(logger_, "An application is not registered.");
+ SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
+ return;
+ }
+
+ // Add app_id for HMI request
+ (*message_)[strings::msg_params][strings::app_id] = app->app_id();
+
SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage,
- &(*message_), true);
+ &(*message_)[strings::msg_params], true);
+
}
void DiagnosticMessageRequest::on_event(const event_engine::Event& event) {
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>
- (application_manager::TextFieldName::AUDIO_DISPLAY_TEXT1);
+ (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>
- (application_manager::TextFieldName::AUDIO_DISPLAY_TEXT2);
+ (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 (mobile_apis::InteractionMode::VR_ONLY != mode) {
msg_params[hmi_request::initial_text][hmi_request::field_name] =
- static_cast<int32_t>(application_manager::TextFieldName::
- INITIAL_INTERACTION_TEXT);
+ static_cast<int32_t>(
+ hmi_apis::Common_TextFieldName::initialInteractionText);
msg_params[hmi_request::initial_text][hmi_request::field_text] =
(*message_)[strings::msg_params][hmi_request::initial_text];
}
&response_params);
return;
}
-
+ smart_objects::SmartType t = (*message_)[strings::msg_params][strings::system_file].getType();
sync_file_name_ =
(*message_)[strings::msg_params][strings::sync_file_name].asString();
file_type_ =
policy::PolicyHandler::instance()->policy_manager();
if (!policy_manager) {
LOG4CXX_WARN(logger_, "The shared library of policy is not loaded");
+ // TODO(AOleynik): Check is necessary to allow register application in case
+ // of disabled policy
+ // Remove this check, when HMI will support policy
+ if (profile::Profile::instance()->policy_turn_off()) {
return mobile_apis::Result::WARNINGS;
}
+ return mobile_apis::Result::DISALLOWED;
+ }
const bool init_result = policy_manager->GetInitialAppData(
message[strings::msg_params][strings::app_id].asString(), &app_nicknames,
&app_hmi_types);
bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() {
- LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::IsApplicationRegistered");
+ LOG4CXX_INFO(logger_, "RegisterAppInterfaceRequest::"
+ "IsApplicationWithSameAppIdRegistered");
- int32_t mobile_app_id = (*message_)[strings::msg_params][strings::app_id]
- .asInt();
+ const std::string mobile_app_id = (*message_)[strings::msg_params]
+ [strings::app_id].asString();
const std::set<ApplicationSharedPtr>& applications =
ApplicationManagerImpl::instance()->applications();
std::set<ApplicationSharedPtr>::const_iterator it_end = applications.end();
for (; it != it_end; ++it) {
- if (mobile_app_id == (*it)->mobile_app_id()->asInt()) {
+ if (mobile_app_id == (*it)->mobile_app_id()->asString()) {
return true;
}
}
}
}
+
+ bool close_session = false;
+ if (last_message) {
+ if (1 < ApplicationManagerImpl::instance()->connection_handler()->GetConnectionSessionsCount(
+ (*message_)[strings::params][strings::connection_key].asUInt())) {
+ last_message = false;
+ close_session = true;
+ }
+ }
+
SendResponse(success, mobile_apis::Result::INVALID_ENUM, last_message);
+ if (close_session) {
+ ApplicationManagerImpl::instance()->connection_handler()->CloseSession(
+ (*message_)[strings::params][strings::connection_key].asUInt());
+ }
+
if (success) {
ApplicationSharedPtr application =
ApplicationManagerImpl::instance()->application(
smart_objects::SmartType_Map);
msg_params[hmi_request::message_text][hmi_request::field_name] =
- static_cast<int32_t>(application_manager::TextFieldName::SCROLLABLE_MSG_BODY);
+ 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();
// erase useless parametr
msg_params.erase(strings::navigation_text_1);
msg_params[hmi_request::navi_texts][index][hmi_request::field_name] =
- static_cast<int32_t>(application_manager::TextFieldName::NAVI_TEXT1);
+ static_cast<int32_t>(hmi_apis::Common_TextFieldName::navigationText1);
msg_params[hmi_request::navi_texts][index++][hmi_request::field_text] =
(*message_)[strings::msg_params][strings::navigation_text_1];
}
// erase useless param
msg_params.erase(strings::navigation_text_2);
msg_params[hmi_request::navi_texts][index][hmi_request::field_name] =
- static_cast<int32_t>(application_manager::TextFieldName::NAVI_TEXT2);
+ static_cast<int32_t>(hmi_apis::Common_TextFieldName::navigationText2);
msg_params[hmi_request::navi_texts][index++][hmi_request::field_text] =
(*message_)[strings::msg_params][strings::navigation_text_2];
}
// erase useless param
msg_params.erase(strings::eta);
msg_params[hmi_request::navi_texts][index][hmi_request::field_name] =
- static_cast<int32_t>(application_manager::TextFieldName::ETA);
+ static_cast<int32_t>(hmi_apis::Common_TextFieldName::ETA);
msg_params[hmi_request::navi_texts][index++][hmi_request::field_text] =
(*message_)[strings::msg_params][strings::eta];
}
// erase useless param
msg_params.erase(strings::total_distance);
msg_params[hmi_request::navi_texts][index][hmi_request::field_name] =
- static_cast<int32_t>(application_manager::TextFieldName::TOTAL_DISTANCE);
+ static_cast<int32_t>(hmi_apis::Common_TextFieldName::totalDistance);
msg_params[hmi_request::navi_texts][index++][hmi_request::field_text] =
(*message_)[strings::msg_params][strings::total_distance];
}
int32_t index = 0;
if ((*message_)[strings::msg_params].keyExists(strings::main_field_1)) {
msg_params[hmi_request::show_strings][index][hmi_request::field_name] =
- static_cast<int32_t>(application_manager::TextFieldName::MAIN_FILED1);
+ static_cast<int32_t>(hmi_apis::Common_TextFieldName::mainField1);
msg_params[hmi_request::show_strings][index][hmi_request::field_text] =
(*message_)[strings::msg_params][strings::main_field_1];
++index;
if ((*message_)[strings::msg_params].keyExists(strings::main_field_2)) {
msg_params[hmi_request::show_strings][index][hmi_request::field_name] =
- static_cast<int32_t>(application_manager::TextFieldName::MAIN_FILED2);
+ static_cast<int32_t>(hmi_apis::Common_TextFieldName::mainField2);
msg_params[hmi_request::show_strings][index][hmi_request::field_text] =
(*message_)[strings::msg_params][strings::main_field_2];
++index;
if ((*message_)[strings::msg_params].keyExists(strings::main_field_3)) {
msg_params[hmi_request::show_strings][index][hmi_request::field_name] =
- static_cast<int32_t>(application_manager::TextFieldName::MAIN_FILED3);
+ static_cast<int32_t>(hmi_apis::Common_TextFieldName::mainField3);
msg_params[hmi_request::show_strings][index][hmi_request::field_text] =
(*message_)[strings::msg_params][strings::main_field_3];
++index;
if ((*message_)[strings::msg_params].keyExists(strings::main_field_4)) {
msg_params[hmi_request::show_strings][index][hmi_request::field_name] =
- static_cast<int32_t>(application_manager::TextFieldName::MAIN_FILED4);
+ static_cast<int32_t>(hmi_apis::Common_TextFieldName::mainField4);
msg_params[hmi_request::show_strings][index][hmi_request::field_text] =
(*message_)[strings::msg_params][strings::main_field_4];
++index;
if ((*message_)[strings::msg_params].keyExists(strings::media_clock)) {
msg_params[hmi_request::show_strings][index][hmi_request::field_name] =
- static_cast<int32_t>(application_manager::TextFieldName::MEDIA_CLOCK);
+ static_cast<int32_t>(hmi_apis::Common_TextFieldName::mediaClock);
msg_params[hmi_request::show_strings][index][hmi_request::field_text] =
(*message_)[strings::msg_params][strings::media_clock];
++index;
if ((*message_)[strings::msg_params].keyExists(strings::media_track)) {
msg_params[hmi_request::show_strings][index][hmi_request::field_name] =
- static_cast<int32_t>(application_manager::TextFieldName::MEDIA_TRACK);
+ static_cast<int32_t>(hmi_apis::Common_TextFieldName::mediaTrack);
msg_params[hmi_request::show_strings][index][hmi_request::field_text] =
(*message_)[strings::msg_params][strings::media_track];
++index;
if ((*message_)[strings::msg_params].keyExists(strings::status_bar)) {
msg_params[hmi_request::show_strings][index][hmi_request::field_name] =
- static_cast<int32_t>(application_manager::TextFieldName::STATUS_BAR);
+ static_cast<int32_t>(hmi_apis::Common_TextFieldName::statusBar);
msg_params[hmi_request::show_strings][index][hmi_request::field_text] =
(*message_)[strings::msg_params][strings::status_bar];
++index;
}
(*message_)[strings::msg_params][strings::app_id] = app->app_id();
+ (*message_)[strings::msg_params][hmi_request::speak_type] =
+ hmi_apis::Common_SpeakType::SPEAK;
SendHMIRequest(hmi_apis::FunctionID::TTS_Speak,
&message_->getElement(strings::msg_params), true);
}
uint32_t function_id) {
smart_objects::SmartObject* module_info = new smart_objects::SmartObject(
smart_objects::SmartType_Map);
- if (NULL == module_info) {
- return NULL;
- }
smart_objects::SmartObject& object = *module_info;
object[strings::params][strings::message_type] = static_cast<int>(kRequest);
object[strings::params][strings::function_id] = static_cast<int>(function_id);
return vr_command;
}
+bool MessageHelper::CreateHMIApplicationStruct(ApplicationConstSharedPtr app,
+ smart_objects::SmartObject& output) {
+
+ if (false == app.valid()) {
+ return false;
+ }
+
+ const smart_objects::SmartObject* app_types = app->app_types();
+ const smart_objects::SmartObject* ngn_media_screen_name = app->ngn_media_screen_name();
+ const connection_handler::DeviceHandle handle = app->device();
+ std::string device_name = ApplicationManagerImpl::instance()->GetDeviceName(handle);
+
+ output = smart_objects::SmartObject(smart_objects::SmartType_Map);
+ output[strings::app_name] = app->name();
+ output[strings::icon] = app->app_icon_path();
+ output[strings::device_name] = device_name;
+ output[strings::app_id] = app->app_id();
+ output[strings::hmi_display_language_desired] = app->ui_language();
+ output[strings::is_media_application] = app->is_media_application();
+
+ if (NULL != ngn_media_screen_name) {
+ output[strings::ngn_media_screen_app_name] = ngn_media_screen_name;
+ }
+ if (NULL != app_types) {
+ output[strings::app_type] = *app_types;
+ }
+ return true;
+}
+
void MessageHelper::SendAddSubMenuRequestToHMI(ApplicationConstSharedPtr app) {
DCHECK(app.get());
SmartObjectList requests = CreateAddSubMenuRequestToHMI(app);
ApplicationManagerImpl::instance()->ManageHMICommand(&message);
}
-void MessageHelper::SendActivateAppToHMI(uint32_t const app_id) {
+void MessageHelper::SendActivateAppToHMI(uint32_t const app_id,
+ hmi_apis::Common_HMILevel::eType level) {
smart_objects::SmartObject* message = new smart_objects::SmartObject(
smart_objects::SmartType_Map);
(*message)[strings::msg_params]["priority"] = GetPriorityCode(priority);
}
+ if (hmi_apis::Common_HMILevel::FULL != level &&
+ hmi_apis::Common_HMILevel::INVALID_ENUM != level) {
+ (*message)[strings::msg_params]["level"] = level;
+ }
+
ApplicationManagerImpl::instance()->ManageHMICommand(message);
}
#include "utils/macro.h"
#include "utils/date_time.h"
#include "json/value.h"
+#include "json/writer.h"
#include "config_profile/profile.h"
#include "application_manager/usage_statistics.h"
#include "policy/policy_types.h"
+#include "interfaces/MOBILE_API.h"
namespace policy {
typedef std::set<utils::SharedPtr<application_manager::Application>> ApplicationList;
: policy_manager_(0),
dl_handle_(0),
exchange_handler_(NULL),
- is_exchange_in_progress_(false),
on_ignition_check_done_(false),
retry_sequence_("RetrySequence", new RetrySequence(this)) {
}
}
bool PolicyHandler::InitPolicyTable() {
+ LOG4CXX_TRACE(logger_, "Init policy table.");
+ if (!policy_manager_) {
+ LOG4CXX_WARN(logger_, "The shared library of policy is not loaded");
+ return false;
+ }
std::string preloaded_file =
- profile::Profile::instance()->preloaded_pt_file();
+ profile::Profile::instance()->preloaded_pt_file();
+ return policy_manager_->InitPT(preloaded_file);
+}
+
+bool PolicyHandler::ResetPolicyTable() {
+ LOG4CXX_TRACE(logger_, "Reset policy table.");
if (!policy_manager_) {
LOG4CXX_WARN(logger_, "The shared library of policy is not loaded");
return false;
}
- return policy_manager_->LoadPTFromFile(preloaded_file);
+ std::string preloaded_file =
+ profile::Profile::instance()->preloaded_pt_file();
+ return policy_manager_->ResetPT(preloaded_file);
}
-bool PolicyHandler::RevertPolicyTable() {
+bool PolicyHandler::ClearUserConsent() {
LOG4CXX_INFO(logger_, "Removing user consent records in policy table.");
if (!policy_manager_) {
LOG4CXX_WARN(logger_, "The shared library of policy is not loaded");
return false;
}
- return policy_manager()->ResetUserConsent();
+ return policy_manager_->ResetUserConsent();
}
uint32_t PolicyHandler::GetAppIdForSending() {
} else if (!app) {
LOG4CXX_WARN(logger_, "Couldn't find application to get permissions.");
} else {
- policy_manager_->GetUserPermissionsForApp(device_params.device_mac_address,
- app->mobile_app_id()->asString(),
- group_permissions);
+ policy_manager_->GetUserConsentForApp(device_params.device_mac_address,
+ app->mobile_app_id()->asString(),
+ group_permissions);
}
application_manager::MessageHelper::SendGetListOfPermissionsResponse(
app->app_id(), permissions);
application_manager::ApplicationManagerImpl::instance()
->DeactivateApplication(app);
+ application_manager::MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile(
+ app->app_id(), mobile_apis::AppInterfaceUnregisteredReason::APP_UNAUTHORIZED);
+ application_manager::ApplicationManagerImpl::instance()->
+ UnregisterApplication(app->app_id(), mobile_apis::Result::INVALID_ENUM, false);
app->set_hmi_level(mobile_apis::HMILevel::HMI_NONE);
policy_manager_->RemovePendingPermissionChanges(policy_app_id);
return;
}
}
+BinaryMessageSptr PolicyHandler::AddHttpHeader(const BinaryMessageSptr& pt_string) {
+ Json::Value packet(Json::objectValue);
+ packet["HTTPRequest"] = Json::Value(Json::objectValue);
+ packet["HTTPRequest"]["headers"] = Json::Value(Json::objectValue);
+ packet["HTTPRequest"]["headers"]["ContentType"] = Json::Value("application/json");
+ packet["HTTPRequest"]["headers"]["ConnectTimeout"] = Json::Value(policy_manager_->TimeoutExchange());
+ packet["HTTPRequest"]["headers"]["DoOutput"] = Json::Value(true);
+ packet["HTTPRequest"]["headers"]["DoInput"] = Json::Value(true);
+ packet["HTTPRequest"]["headers"]["UseCaches"] = Json::Value(false);
+ packet["HTTPRequest"]["headers"]["RequestMethod"] = Json::Value("POST");
+ packet["HTTPRequest"]["headers"]["ReadTimeout"] = Json::Value(policy_manager_->TimeoutExchange());
+ packet["HTTPRequest"]["headers"]["InstanceFollowRedirects"] = Json::Value(false);
+ packet["HTTPRequest"]["headers"]["charset"] = Json::Value("utf-8");
+ packet["HTTPRequest"]["headers"]["Content_Length"] = Json::Value(static_cast<int>(pt_string->size()));
+ packet["HTTPRequest"]["body"] = Json::Value(Json::objectValue);
+ packet["HTTPRequest"]["body"]["data"] = Json::Value(Json::arrayValue);
+ packet["HTTPRequest"]["body"]["data"][0] = Json::Value(std::string(pt_string->begin(),
+ pt_string->end()));
+
+ Json::FastWriter writer;
+ std::string message = writer.write(packet);
+ LOG4CXX_DEBUG(logger_, "Packet PT: " << message);
+ return new BinaryMessage(message.begin(), message.end());
+}
+
bool PolicyHandler::SendMessageToSDK(const BinaryMessage& pt_string) {
LOG4CXX_INFO(logger_, "PolicyHandler::SendMessageToSDK");
if (!policy_manager_) {
LOG4CXX_WARN(logger_, "The shared library of policy is not loaded");
return false;
}
- is_exchange_in_progress_ = true;
std::string url;
uint32_t app_id = last_used_app_ids_.back();
application_manager::MessageHelper::SendPolicySnapshotNotification(app_id,
pt_string,
url, 0);
+
return true;
}
return false;
}
- is_exchange_in_progress_ = false;
+ if (policy_manager_->GetPolicyTableStatus() !=
+ PolicyTableStatus::StatusUpdatePending) {
+ LOG4CXX_WARN(logger_,
+ "Update policy is skipped because request to update was not");
+ return false;
+ }
bool ret = policy_manager_->LoadPT(file, pt_string);
LOG4CXX_INFO(logger_, "Policy table is saved: " << std::boolalpha << ret);
retry_sequence_lock_.Ackquire();
retry_sequence_.stop();
retry_sequence_lock_.Release();
+ policy_manager_->CleanupUnpairedDevices();
int32_t correlation_id =
application_manager::ApplicationManagerImpl::instance()
->GetNextHMICorrelationID();
std::vector<std::string> vehicle_data_args;
vehicle_data_args.push_back(application_manager::strings::odometer);
application_manager::MessageHelper::CreateGetVehicleDataRequest(correlation_id, vehicle_data_args);
- if (policy_manager_->CleanupUnpairedDevices(unpaired_device_ids_)) {
- unpaired_device_ids_.clear();
- }
} else {
// TODO(PV): should be exchange restarted at this point?
LOG4CXX_WARN(logger_, "Exchange wasn't successful, trying another one.");
return;
}
- if (is_exchange_in_progress_) {
+ if (policy_manager_->GetPolicyTableStatus() ==
+ PolicyTableStatus::StatusUpdatePending) {
LOG4CXX_INFO(logger_, "Starting exchange skipped, since another exchange "
"is in progress.");
return;
usage.RecordAppUserSelection();
- DeviceConsent consent = GetDeviceForSending(permissions.deviceInfo);
+ application_manager::MessageHelper::GetDeviceInfoForApp(connection_key,
+ &permissions.deviceInfo);
+ DeviceConsent consent = policy_manager_->GetUserConsentForDevice(
+ permissions.deviceInfo.device_mac_address);
permissions.isSDLAllowed = kDeviceAllowed == consent ? true : false;
if (permissions.appRevoked) {
return;
}
- policy::DeviceIds devices;
- devices.insert(device_id);
- policy_manager_->CleanupUnpairedDevices(devices);
+ policy_manager_->MarkUnpairedDevice(device_id);
}
} // namespace policy
Profile::instance()->policies_snapshot_file_name();
BinaryMessageSptr pt_snapshot = policy_manager->RequestPTUpdate();
if (pt_snapshot.valid()) {
+ pt_snapshot = policy_handler_->AddHttpHeader(pt_snapshot);
if (file_system::WriteBinaryFile(policy_snapshot_file_name, *pt_snapshot)) {
MessageHelper::SendPolicyUpdate(policy_snapshot_file_name,
policy_manager->TimeoutExchange(),
} else {
request_list_.push_back(request);
+ LOG4CXX_INFO(logger_, "RequestController size is " <<
+ request_list_.size());
+
+ if (0 == request_impl->default_timeout()) {
+ LOG4CXX_INFO(logger_, "Default timeout was set to 0. Watchdog will not "
+ "track this request.");
+ return result;
+ }
LOG4CXX_INFO(logger_, "Adding request to watchdog. Default timeout is "
<< request_impl->default_timeout());
request_impl->default_timeout(),
hmi_level));
- LOG4CXX_INFO(logger_, "Added request to watchdog.");
- LOG4CXX_INFO(logger_, "RequestController size is " << request_list_.size());
+ LOG4CXX_INFO(logger_, "Added request to watchdog.");
}
}