diff options
Diffstat (limited to 'src/components/application_manager/src/message_helper.cc')
-rw-r--r-- | src/components/application_manager/src/message_helper.cc | 253 |
1 files changed, 113 insertions, 140 deletions
diff --git a/src/components/application_manager/src/message_helper.cc b/src/components/application_manager/src/message_helper.cc index 8ac9de416e..d0d967b8ab 100644 --- a/src/components/application_manager/src/message_helper.cc +++ b/src/components/application_manager/src/message_helper.cc @@ -383,16 +383,41 @@ smart_objects::SmartObject* MessageHelper::GetHashUpdateNotification( return message; } +smart_objects::SmartObject* MessageHelper::GetLockScreenIconUrlNotification(const uint32_t connection_key) { + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(connection_key); + DCHECK(app.get()); + + smart_objects::SmartObject* message = new 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] = + "http://www.livioconnect.com/wp-content/uploads/2012/03/icon-Livio-Connect.png"; + + return message; +} + +void MessageHelper::SendLockScreenIconUrlNotification(const uint32_t connection_key) { + LOG4CXX_INFO(logger_, "SendLockScreenIconUrlNotification"); + + smart_objects::SmartObject* so = GetLockScreenIconUrlNotification(connection_key); + PrintSmartObject(*so); + DCHECK(ApplicationManagerImpl::instance()->ManageMobileCommand(so)); +} + void MessageHelper::SendHashUpdateNotification(const uint32_t app_id) { - LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_INFO(logger_, "SendHashUpdateNotification"); smart_objects::SmartObject* so = GetHashUpdateNotification(app_id); if (so) { PrintSmartObject(*so); if (!ApplicationManagerImpl::instance()->ManageMobileCommand(so)) { LOG4CXX_ERROR_EXT(logger_, "Failed to send HashUpdate notification."); - } else { - ApplicationManagerImpl::instance()->resume_controller().ApplicationsDataUpdated(); } } } @@ -448,7 +473,6 @@ std::string MessageHelper::StringifiedHMILevel( std::string MessageHelper::StringifiedFunctionID( mobile_apis::FunctionID::eType function_id) { - LOG4CXX_AUTO_TRACE(logger_); using namespace NsSmartDeviceLink::NsSmartObjects; const char* str = 0; if (EnumConversionHelper<mobile_apis::FunctionID::eType>::EnumToCString( @@ -498,7 +522,6 @@ static std::map<std::string, uint16_t> vehicle_data_args = create_get_vehicle_da #endif void MessageHelper::CreateGetVehicleDataRequest(uint32_t correlation_id, const std::vector<std::string>& params) { - LOG4CXX_AUTO_TRACE(logger_); #ifdef HMI_DBUS_API for (std::vector<std::string>::const_iterator it = params.begin(); it != params.end(); it++) { @@ -538,8 +561,10 @@ smart_objects::SmartObject* MessageHelper::CreateBlockedByPoliciesResponse( mobile_apis::FunctionID::eType function_id, mobile_apis::Result::eType result, uint32_t correlation_id, uint32_t connection_key) { - LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObject* response = new smart_objects::SmartObject; + if (!response) { + return NULL; + } (*response)[strings::params][strings::function_id] = static_cast<int>(function_id); @@ -559,10 +584,13 @@ smart_objects::SmartObject* MessageHelper::CreateBlockedByPoliciesResponse( smart_objects::SmartObject* MessageHelper::CreateDeviceListSO( const connection_handler::DeviceMap& devices) { - LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObject* device_list_so = new smart_objects::SmartObject( smart_objects::SmartType_Map); + if (NULL == device_list_so) { + return NULL; + } + (*device_list_so)[strings::device_list] = smart_objects::SmartObject( smart_objects::SmartType_Array); smart_objects::SmartObject& list_so = (*device_list_so)[strings::device_list]; @@ -579,14 +607,13 @@ smart_objects::SmartObject* MessageHelper::CreateDeviceListSO( policy::PolicyHandler::instance()->GetUserConsentForDevice(it->second.mac_address()); list_so[index][strings::isSDLAllowed] = policy::DeviceConsent::kDeviceAllowed == device_consent; - ++index; } + ++index; return device_list_so; } smart_objects::SmartObject* MessageHelper::CreateModuleInfoSO( uint32_t function_id) { - LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObject* module_info = new smart_objects::SmartObject( smart_objects::SmartType_Map); smart_objects::SmartObject& object = *module_info; @@ -601,7 +628,6 @@ smart_objects::SmartObject* MessageHelper::CreateModuleInfoSO( smart_objects::SmartObject* MessageHelper::CreateSetAppIcon( const std::string& path_to_icon, uint32_t app_id) { - LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObject* set_icon = new smart_objects::SmartObject( smart_objects::SmartType_Map); @@ -620,40 +646,34 @@ smart_objects::SmartObject* MessageHelper::CreateSetAppIcon( } bool MessageHelper::SendIVISubscribtions(const uint32_t app_id) { - LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_INFO(logger_, " MessageHelper::SendIVISubscribtions "); - bool result = true; + bool succes = true; ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( app_id); + DCHECK(app.get()); - if (!app.valid()) { - LOG4CXX_ERROR(logger_, "Invalid application " << app_id); - return result; - } - - SmartObjectList requests = GetIVISubscriptionRequests(app); + SmartObjectList requests = GetIVISubscribtionRequests(app_id); for (SmartObjectList::const_iterator it = requests.begin(); it != requests.end(); ++it) { if (!ApplicationManagerImpl::instance()->ManageHMICommand(*it)) { - result = false; + succes = false; } } - return result; + return succes; } -MessageHelper::SmartObjectList MessageHelper::GetIVISubscriptionRequests( - ApplicationSharedPtr app) { - LOG4CXX_AUTO_TRACE(logger_); +MessageHelper::SmartObjectList MessageHelper::GetIVISubscribtionRequests( + const uint32_t app_id) { + LOG4CXX_INFO(logger_, " MessageHelper::GetIVISubscribtionRequests "); - SmartObjectList hmi_requests; - if (!app.valid()) { - LOG4CXX_ERROR(logger_, "Invalid application pointer "); - return hmi_requests; - } + ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( + app_id); + DCHECK(app); smart_objects::SmartObject msg_params = smart_objects::SmartObject( smart_objects::SmartType_Map); - msg_params[strings::app_id] = app->app_id(); + msg_params[strings::app_id] = app_id; const VehicleData& vehicle_data = MessageHelper::vehicle_data_; VehicleData::const_iterator ivi_it = vehicle_data.begin(); const std::set<uint32_t>& subscribes = app->SubscribesIVI(); @@ -666,6 +686,7 @@ MessageHelper::SmartObjectList MessageHelper::GetIVISubscriptionRequests( } } + SmartObjectList hmi_requests; #ifdef HMI_JSON_API smart_objects::SmartObject* request = MessageHelper::CreateModuleInfoSO( hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData); @@ -689,7 +710,6 @@ MessageHelper::SmartObjectList MessageHelper::GetIVISubscriptionRequests( } void MessageHelper::SendAppDataToHMI(ApplicationConstSharedPtr app) { - LOG4CXX_AUTO_TRACE(logger_); uint32_t id = app->app_id(); utils::SharedPtr<smart_objects::SmartObject> set_app_icon( @@ -709,7 +729,7 @@ void MessageHelper::SendAppDataToHMI(ApplicationConstSharedPtr app) { so_to_send[strings::msg_params] = smart_objects::SmartObject( smart_objects::SmartType_Map); - utils::SharedPtr<smart_objects::SmartObject> msg_params = MessageHelper::CreateSetAppIcon( + smart_objects::SmartObject* msg_params = MessageHelper::CreateSetAppIcon( app->app_icon_path(), id); if (msg_params) { @@ -724,10 +744,7 @@ void MessageHelper::SendAppDataToHMI(ApplicationConstSharedPtr app) { } void MessageHelper::SendGlobalPropertiesToHMI(ApplicationConstSharedPtr app) { - if (!app.valid()) { - LOG4CXX_ERROR(logger_, "Invalid application"); - return; - } + DCHECK(app.get()); SmartObjectList requests = CreateGlobalPropertiesRequestsToHMI(app); for (SmartObjectList::const_iterator it = requests.begin(); @@ -738,13 +755,9 @@ void MessageHelper::SendGlobalPropertiesToHMI(ApplicationConstSharedPtr app) { MessageHelper::SmartObjectList MessageHelper::CreateGlobalPropertiesRequestsToHMI( ApplicationConstSharedPtr app) { - LOG4CXX_AUTO_TRACE(logger_); SmartObjectList requests; - if (!app.valid()) { - LOG4CXX_ERROR(logger_, "Invalid application"); - return requests; - } + DCHECK(app.get()); // UI global properties @@ -830,7 +843,6 @@ MessageHelper::SmartObjectList MessageHelper::CreateGlobalPropertiesRequestsToHM void MessageHelper::SendTTSGlobalProperties( ApplicationSharedPtr app, bool default_help_prompt) { - LOG4CXX_AUTO_TRACE(logger_); if (!app.valid()) { return; } @@ -853,8 +865,7 @@ void MessageHelper::SendTTSGlobalProperties( msg_params[strings::help_prompt] = smart_objects::SmartObject( smart_objects::SmartType_Array); if (default_help_prompt) { - const DataAccessor<CommandsMap> accessor = app->commands_map(); - const CommandsMap& commands = accessor.GetData(); + const CommandsMap& commands = app->commands_map(); CommandsMap::const_iterator it = commands.begin(); uint32_t index = 0; for (; commands.end() != it; ++it) { @@ -900,8 +911,7 @@ smart_objects::SmartObject* MessageHelper::CreateAppVrHelp( } // copy all app VR commands - const DataAccessor<CommandsMap> cmd_accessor = app->commands_map(); - const CommandsMap& commands = cmd_accessor.GetData(); + const CommandsMap& commands = app->commands_map(); CommandsMap::const_iterator it = commands.begin(); for (; commands.end() != it; ++it) { @@ -915,16 +925,12 @@ smart_objects::SmartObject* MessageHelper::CreateAppVrHelp( MessageHelper::SmartObjectList MessageHelper::CreateShowRequestToHMI( ApplicationConstSharedPtr app) { + DCHECK(app.get()); SmartObjectList requests; - if (!app) { - LOG4CXX_ERROR(logger_, "Invalid application"); - return requests; - } - + smart_objects::SmartObject* ui_show = new smart_objects::SmartObject( + smart_objects::SmartType_Map); if (app->show_command()) { - smart_objects::SmartObject* ui_show = new smart_objects::SmartObject( - smart_objects::SmartType_Map); (*ui_show)[strings::params][strings::function_id] = static_cast<int>(hmi_apis::FunctionID::UI_Show); (*ui_show)[strings::params][strings::message_type] = @@ -960,12 +966,14 @@ void MessageHelper::SendShowConstantTBTRequestToHMI( return; } + smart_objects::SmartObject* navi_show_tbt = new smart_objects::SmartObject( + smart_objects::SmartType_Map); + + if (!navi_show_tbt) { + return; + } + if (app->tbt_show_command()) { - utils::SharedPtr<smart_objects::SmartObject> navi_show_tbt = new smart_objects::SmartObject( - smart_objects::SmartType_Map); - if (!navi_show_tbt) { - return; - } (*navi_show_tbt)[strings::params][strings::function_id] = static_cast<int>(hmi_apis::FunctionID::Navigation_ShowConstantTBT); (*navi_show_tbt)[strings::params][strings::message_type] = @@ -994,15 +1002,10 @@ void MessageHelper::SendAddCommandRequestToHMI(ApplicationConstSharedPtr app) { MessageHelper::SmartObjectList MessageHelper::CreateAddCommandRequestToHMI( ApplicationConstSharedPtr app) { + DCHECK(app.get()); SmartObjectList requests; - if (!app.valid()) { - LOG4CXX_ERROR(logger_, "Invalid application"); - return requests; - } - - const DataAccessor<CommandsMap> accessor = app->commands_map(); - const CommandsMap& commands = accessor.GetData(); + const CommandsMap& commands = app->commands_map(); CommandsMap::const_iterator i = commands.begin(); for (; commands.end() != i; ++i) { // UI Interface @@ -1051,8 +1054,7 @@ MessageHelper::SmartObjectList MessageHelper::CreateAddCommandRequestToHMI( } smart_objects::SmartObject* MessageHelper::CreateChangeRegistration( - int32_t function_id, int32_t language, uint32_t app_id, - const smart_objects::SmartObject* app_types) { + int32_t function_id, int32_t language, uint32_t app_id) { smart_objects::SmartObject* command = new smart_objects::SmartObject( smart_objects::SmartType_Map); if (!command) { @@ -1077,31 +1079,10 @@ smart_objects::SmartObject* MessageHelper::CreateChangeRegistration( msg_params[strings::language] = language; msg_params[strings::app_id] = app_id; - if (app_types != NULL) { - msg_params[strings::app_hmi_type] = *app_types; - } - params[strings::msg_params] = msg_params; return command; } -void MessageHelper::SendUIChangeRegistrationRequestToHMI(ApplicationConstSharedPtr app) { - if (!app.valid()) { - LOG4CXX_ERROR(logger_, "Application is not valid"); - return; - } - - if (NULL != app->app_types()) { - smart_objects::SmartObject* ui_command = CreateChangeRegistration( - hmi_apis::FunctionID::UI_ChangeRegistration, app->ui_language(), - app->app_id(), app->app_types()); - - if (ui_command) { - ApplicationManagerImpl::instance()->ManageHMICommand(ui_command); - } - } -} - void MessageHelper::SendChangeRegistrationRequestToHMI(ApplicationConstSharedPtr app) { if (!app.valid()) { return; @@ -1217,11 +1198,7 @@ bool MessageHelper::CreateHMIApplicationStruct(ApplicationConstSharedPtr app, } void MessageHelper::SendAddSubMenuRequestToHMI(ApplicationConstSharedPtr app) { - if (!app.valid()) { - LOG4CXX_ERROR(logger_, "Invalid application"); - return; - } - + DCHECK(app.get()); SmartObjectList requests = CreateAddSubMenuRequestToHMI(app); for (SmartObjectList::iterator it = requests.begin(); it != requests.end(); ++it) { @@ -1232,8 +1209,7 @@ void MessageHelper::SendAddSubMenuRequestToHMI(ApplicationConstSharedPtr app) { MessageHelper::SmartObjectList MessageHelper::CreateAddSubMenuRequestToHMI( ApplicationConstSharedPtr app) { SmartObjectList requsets; - const DataAccessor<SubMenuMap> accessor = app->sub_menu_map(); - const SubMenuMap& sub_menu = accessor.GetData(); + const SubMenuMap& sub_menu = app->sub_menu_map(); SubMenuMap::const_iterator i = sub_menu.begin(); for (; sub_menu.end() != i; ++i) { smart_objects::SmartObject* ui_sub_menu = new smart_objects::SmartObject( @@ -1292,19 +1268,18 @@ void MessageHelper::SendOnAppUnregNotificationToHMI( } void MessageHelper::SendActivateAppToHMI(uint32_t const app_id, - hmi_apis::Common_HMILevel::eType level, - bool send_policy_priority) { + hmi_apis::Common_HMILevel::eType level) { + smart_objects::SmartObject* message = new smart_objects::SmartObject( + smart_objects::SmartType_Map); + application_manager::ApplicationConstSharedPtr app = application_manager::ApplicationManagerImpl::instance() ->application(app_id); - if (!app) { + if (!app.valid()) { LOG4CXX_WARN(logger_, "Invalid app_id: " << app_id); return; } - utils::SharedPtr<smart_objects::SmartObject> message = new smart_objects::SmartObject( - smart_objects::SmartType_Map); - (*message)[strings::params][strings::function_id] = hmi_apis::FunctionID::BasicCommunication_ActivateApp; (*message)[strings::params][strings::message_type] = MessageType::kRequest; @@ -1312,25 +1287,23 @@ void MessageHelper::SendActivateAppToHMI(uint32_t const app_id, ApplicationManagerImpl::instance()->GetNextHMICorrelationID(); (*message)[strings::msg_params][strings::app_id] = app_id; - if (send_policy_priority) { - std::string priority; - // TODO(KKolodiy): need remove method policy_manager + std::string priority; + // TODO(KKolodiy): need remove method policy_manager - policy::PolicyHandler::instance()->GetPriority( + policy::PolicyHandler::instance()->GetPriority( app->mobile_app_id()->asString(), &priority); - // According SDLAQ-CRS-2794 - // SDL have to send ActivateApp without "proirity" parameter to HMI. - // in case of unconsented device - std::string mac_adress; - connection_handler::DeviceHandle device_handle = app->device(); - connection_handler::ConnectionHandlerImpl::instance()-> - GetDataOnDeviceID(device_handle, NULL, NULL, &mac_adress, NULL); - - policy::DeviceConsent consent = - policy::PolicyHandler::instance()->GetUserConsentForDevice(mac_adress); - if (!priority.empty() && (policy::DeviceConsent::kDeviceAllowed == consent)) { - (*message)[strings::msg_params][strings::priority] = GetPriorityCode(priority); - } + // According SDLAQ-CRS-2794 + // SDL have to send ActivateApp without "proirity" parameter to HMI. + // in case of unconsented device + std::string mac_adress; + connection_handler::DeviceHandle device_handle = app->device(); + connection_handler::ConnectionHandlerImpl::instance()-> + GetDataOnDeviceID(device_handle, NULL, NULL, &mac_adress, NULL); + + policy::DeviceConsent consent = + policy::PolicyHandler::instance()->GetUserConsentForDevice(mac_adress); + if (!priority.empty() && (policy::DeviceConsent::kDeviceAllowed == consent)) { + (*message)[strings::msg_params]["priority"] = GetPriorityCode(priority); } // We haven't send HMI level to HMI in case it FULL. @@ -1344,17 +1317,17 @@ void MessageHelper::SendActivateAppToHMI(uint32_t const app_id, void MessageHelper::SendOnResumeAudioSourceToHMI(const uint32_t app_id) { LOG4CXX_WARN(logger_, "SendOnResumeAudioSourceToHMI app_id: " << app_id); + + smart_objects::SmartObject* message = new smart_objects::SmartObject( + smart_objects::SmartType_Map); application_manager::ApplicationConstSharedPtr app = application_manager::ApplicationManagerImpl::instance() ->application(app_id); - if (!app) { + if (!app.valid()) { LOG4CXX_WARN(logger_, "Invalid app_id: " << app_id); return; } - utils::SharedPtr<smart_objects::SmartObject> message = new smart_objects::SmartObject( - smart_objects::SmartType_Map); - (*message)[strings::params][strings::function_id] = hmi_apis::FunctionID::BasicCommunication_OnResumeAudioSource; (*message)[strings::params][strings::message_type] = MessageType::kNotification; @@ -1399,7 +1372,6 @@ void MessageHelper::GetDeviceInfoForApp(uint32_t connection_key, void MessageHelper::SendSDLActivateAppResponse(policy::AppPermissions& permissions, uint32_t correlation_id) { - LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObject* message = new smart_objects::SmartObject( smart_objects::SmartType_Map); if (!message) { @@ -1446,6 +1418,15 @@ void MessageHelper::SendSDLActivateAppResponse(policy::AppPermissions& permissio if (permissions.appRevoked || !permissions.isSDLAllowed) { return; } + + // Send HMI status notification to mobile + ApplicationSharedPtr app = ApplicationManagerImpl::instance() + ->application_by_policy_id(permissions.application_id); + if (app) { + ApplicationManagerImpl::instance()->ActivateApplication(app); + } else { + LOG4CXX_WARN(logger_, "Unable to find app_id: " << permissions.application_id); + } } void MessageHelper::SendOnSDLConsentNeeded( @@ -1625,7 +1606,7 @@ smart_objects::SmartObject* MessageHelper::CreateNegativeResponse( } void MessageHelper::SendNaviStartStream(int32_t connection_key) { - LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_INFO(logger_, "MessageHelper::SendNaviStartStream"); smart_objects::SmartObject* start_stream = new smart_objects::SmartObject( smart_objects::SmartType_Map); @@ -1841,10 +1822,10 @@ void MessageHelper::SendPolicySnapshotNotification( void MessageHelper::SendOnPermissionsChangeNotification( uint32_t connection_key, const policy::Permissions& permissions) { - utils::SharedPtr<smart_objects::SmartObject> notification = new smart_objects::SmartObject( + smart_objects::SmartObject* notification = new smart_objects::SmartObject( smart_objects::SmartType_Map); smart_objects::SmartObject& content = *notification; - + ; content[strings::params][strings::function_id] = mobile_apis::FunctionID::OnPermissionsChangeID; content[strings::params][strings::message_type] = @@ -1855,7 +1836,7 @@ void MessageHelper::SendOnPermissionsChangeNotification( commands::CommandImpl::protocol_version_; content[strings::params][strings::connection_key] = connection_key; - utils::SharedPtr<smart_objects::SmartObject> p_msg_params = new smart_objects::SmartObject( + smart_objects::SmartObject* p_msg_params = new smart_objects::SmartObject( smart_objects::SmartType_Map); smart_objects::SmartObject& msg_params = *p_msg_params; @@ -2207,17 +2188,6 @@ bool MessageHelper::VerifySoftButtonString(const std::string& str) { return true; } -bool MessageHelper::CheckWithPolicy( - int system_action, const std::string& app_mobile_id) { - bool result = true; - policy::PolicyHandler* policy_handler = policy::PolicyHandler::instance(); - if (NULL != policy_handler && policy_handler->PolicyEnabled()) { - result = policy_handler->CheckKeepContext(system_action, app_mobile_id) || - policy_handler->CheckStealFocus(system_action, app_mobile_id); - } - return result; -} - mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( smart_objects::SmartObject& message_params, ApplicationConstSharedPtr app) { if (!message_params.keyExists(strings::soft_buttons)) { @@ -2245,14 +2215,17 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( smart_objects::SmartObject soft_buttons = smart_objects::SmartObject( smart_objects::SmartType_Array); + policy::PolicyHandler* policy_handler = policy::PolicyHandler::instance(); + std::string app_mobile_id = app->mobile_app_id()->asString(); uint32_t j = 0; size_t size = request_soft_buttons.length(); for (uint32_t i = 0; i < size; ++i) { - const int system_action = request_soft_buttons[i][strings::system_action].asInt(); - - if (!CheckWithPolicy(system_action, app->mobile_app_id()->asString())) + int system_action = request_soft_buttons[i][strings::system_action].asInt(); + if (!policy_handler->CheckKeepContext(system_action, app_mobile_id) || + !policy_handler->CheckStealFocus(system_action, app_mobile_id)) { return mobile_apis::Result::DISALLOWED; + } switch (request_soft_buttons[i][strings::type].asInt()) { case mobile_apis::SoftButtonType::SBT_IMAGE: { |