diff options
Diffstat (limited to 'src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc')
-rw-r--r-- | src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc | 128 |
1 files changed, 96 insertions, 32 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc index 5fb66c25ac..417806064f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc @@ -81,6 +81,8 @@ mobile_apis::AppHMIType::eType StringToAppHMIType(const std::string& str) { return mobile_apis::AppHMIType::PROJECTION; } else if ("REMOTE_CONTROL" == str) { return mobile_apis::AppHMIType::REMOTE_CONTROL; + } else if ("WEB_VIEW" == str) { + return mobile_apis::AppHMIType::WEB_VIEW; } else { return mobile_apis::AppHMIType::INVALID_ENUM; } @@ -99,7 +101,8 @@ std::string AppHMITypeToString(mobile_apis::AppHMIType::eType type) { {mobile_apis::AppHMIType::BACKGROUND_PROCESS, "BACKGROUND_PROCESS"}, {mobile_apis::AppHMIType::TESTING, "TESTING"}, {mobile_apis::AppHMIType::SYSTEM, "SYSTEM"}, - {mobile_apis::AppHMIType::PROJECTION, "PROJECTION"}}; + {mobile_apis::AppHMIType::PROJECTION, "PROJECTION"}, + {mobile_apis::AppHMIType::WEB_VIEW, "WEB_VIEW"}}; std::map<mobile_apis::AppHMIType::eType, std::string>::const_iterator iter = app_hmi_type_map.find(type); @@ -293,7 +296,7 @@ void RegisterAppInterfaceRequest::Run() { policy_result, mobile_apis::Result::SUCCESS, mobile_apis::Result::WARNINGS)) { - SendResponse(false, policy_result); + SendResponse(false, policy_result, response_info_.c_str()); return; } @@ -481,6 +484,10 @@ void RegisterAppInterfaceRequest::Run() { application->set_remote_control_supported(true); break; } + case mobile_apis::AppHMIType::WEB_VIEW: { + application->set_webengine_projection_enabled(true); + break; + } default: {} } } @@ -1138,14 +1145,14 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() { return mobile_apis::Result::WARNINGS; } - smart_objects::SmartObject& message = *message_; + auto& message = *message_; policy::StringArray app_nicknames; - policy::StringArray app_hmi_types; + policy::StringArray app_hmi_types_in_policy; const std::string mobile_app_id = application_manager_.GetCorrectMobileIDFromMessage(message_); const bool init_result = GetPolicyHandler().GetInitialAppData( - mobile_app_id, &app_nicknames, &app_hmi_types); + mobile_app_id, &app_nicknames, &app_hmi_types_in_policy); if (!init_result) { LOG4CXX_ERROR(logger_, "Error during initial application data check."); @@ -1171,36 +1178,20 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() { } } - mobile_apis::Result::eType result = mobile_apis::Result::SUCCESS; + auto result = mobile_apis::Result::SUCCESS; // If AppHMIType is not included in policy - allow any type - if (!app_hmi_types.empty()) { - if (message[strings::msg_params].keyExists(strings::app_hmi_type)) { - // If AppHmiTypes are partially same, the system should allow those listed - // in the policy table and send warning info on missed values - smart_objects::SmartArray app_types = - *(message[strings::msg_params][strings::app_hmi_type].asArray()); - - std::string log; - CheckMissedTypes checker(app_hmi_types, log); - std::for_each(app_types.begin(), app_types.end(), checker); - if (!log.empty()) { - response_info_ = - "Following AppHmiTypes are not present in policy " - "table:" + - log; - result_code_ = mobile_apis::Result::WARNINGS; - } + if (!app_hmi_types_in_policy.empty()) { + result = ProcessingAppHMITypesPolicies(message, app_hmi_types_in_policy); + } else { + result = ProcessingAppHMITypesInMessage(message); + if (mobile_apis::Result::DISALLOWED == result) { + response_info_ = + "WEB_VIEW AppHmiType is absent in application policies, because they " + "are empty"; + LOG4CXX_DEBUG(logger_, response_info_); + return result; } - // Replace AppHmiTypes in request with values allowed by policy table - message[strings::msg_params][strings::app_hmi_type] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - - smart_objects::SmartObject& app_hmi_type = - message[strings::msg_params][strings::app_hmi_type]; - - AppHMITypeInserter inserter(app_hmi_type); - std::for_each(app_hmi_types.begin(), app_hmi_types.end(), inserter); } return result; @@ -1538,6 +1529,79 @@ bool RegisterAppInterfaceRequest::GetDataOnSessionKey( return true; } +mobile_apis::Result::eType +RegisterAppInterfaceRequest::ProcessingAppHMITypesInMessage( + const smart_objects::SmartObject& message) { + const bool app_hmi_types_exist = + message[strings::msg_params].keyExists(strings::app_hmi_type); + + const auto result = mobile_apis::Result::SUCCESS; + + if (!app_hmi_types_exist) { + return result; + } + + auto app_types_in_message = + *(message[strings::msg_params][strings::app_hmi_type].asArray()); + + auto it = std::find(app_types_in_message.begin(), + app_types_in_message.end(), + mobile_apis::AppHMIType::WEB_VIEW); + if (app_types_in_message.end() != it) { + return mobile_apis::Result::DISALLOWED; + } + + return result; +} + +mobile_apis::Result::eType +RegisterAppInterfaceRequest::ProcessingAppHMITypesPolicies( + smart_objects::SmartObject& message, + policy::StringArray& app_hmi_types_in_policy) { + auto result = mobile_apis::Result::SUCCESS; + const bool app_hmi_types_exist = + message[strings::msg_params].keyExists(strings::app_hmi_type); + + if (app_hmi_types_exist) { + // If AppHmiTypes are partially same, the system should allow those listed + // in the policy table and send warning info on missed values + auto app_types_in_message = + *(message[strings::msg_params][strings::app_hmi_type].asArray()); + + std::string log; + CheckMissedTypes checker(app_hmi_types_in_policy, log); + std::for_each( + app_types_in_message.begin(), app_types_in_message.end(), checker); + if (!log.empty()) { + result = ProcessingAppHMITypesInMessage(message); + + if (mobile_apis::Result::DISALLOWED == result) { + response_info_ = + "WEB_VIEW AppHmiType is absent in application policies"; + LOG4CXX_DEBUG(logger_, response_info_); + return result; + } + + response_info_ = + "Following AppHmiTypes are not present in policy " + "table:" + + log; + result_code_ = mobile_apis::Result::WARNINGS; + } + } + // Replace AppHmiTypes in request with values allowed by policy table + message[strings::msg_params][strings::app_hmi_type] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + auto& app_hmi_type = message[strings::msg_params][strings::app_hmi_type]; + + AppHMITypeInserter inserter(app_hmi_type); + std::for_each( + app_hmi_types_in_policy.begin(), app_hmi_types_in_policy.end(), inserter); + + return result; +} + policy::PolicyHandlerInterface& RegisterAppInterfaceRequest::GetPolicyHandler() { return policy_handler_; |