diff options
author | sniukalov <sniukaov@luxoft.com> | 2020-04-01 19:41:31 +0300 |
---|---|---|
committer | sniukalov <sniukaov@luxoft.com> | 2020-07-03 11:57:12 +0300 |
commit | 36834e171466c6605b3c47ab8b17a30d78a8b382 (patch) | |
tree | 7e3a554a6fd73022cccfb6ed7028807242429f2e | |
parent | 6339826096ef42d854937175b33d0beff0db4533 (diff) | |
download | sdl_core-36834e171466c6605b3c47ab8b17a30d78a8b382.tar.gz |
Add app registration support of the hmi type WEB_VIEW
5 files changed, 156 insertions, 46 deletions
diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index e9dcf2bcb0..496130c341 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -609,6 +609,9 @@ class Application : public virtual InitialApplicationData, virtual void set_mobile_projection_enabled(bool option) = 0; virtual bool mobile_projection_enabled() const = 0; + virtual void set_webengine_projection_enabled(const bool option) = 0; + virtual bool webengine_projection_enabled() const = 0; + virtual bool video_streaming_approved() const = 0; virtual void set_video_streaming_approved(bool state) = 0; virtual bool audio_streaming_approved() const = 0; diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h index 185d700d58..a11a9461bf 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -123,6 +123,9 @@ class ApplicationImpl : public virtual Application, bool mobile_projection_enabled() const; + void set_webengine_projection_enabled(const bool option) OVERRIDE; + bool webengine_projection_enabled() const OVERRIDE; + bool video_streaming_approved() const; void set_video_streaming_approved(bool state); bool audio_streaming_approved() const; @@ -565,6 +568,7 @@ class ApplicationImpl : public virtual Application, bool is_navi_; bool is_remote_control_supported_; bool mobile_projection_enabled_; + bool webengine_projection_enabled_; bool video_streaming_approved_; bool audio_streaming_approved_; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h index d59964bbc7..07c32ea5af 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h @@ -236,6 +236,30 @@ class RegisterAppInterfaceRequest connection_handler::DeviceHandle* device_id = nullptr, std::string* mac_address = nullptr) const; + /** + * @brief Processes AppHMITypes in the received message from mobile and in the + * policy table + * @param message A message from mobile that could contain AppHMIType + * collection + * @param app_hmi_types_in_policy AppHMITypes that describes in the policy + * table for the app that sent the message + * @return Result of processing + */ + mobile_apis::Result::eType ProcessingAppHMITypesPolicies( + smart_objects::SmartObject& message, + policy::StringArray& app_hmi_types_in_policy); + + /** + * @brief Processes AppHMITypes in the received message + * @param message A message received from the mobile + * @param info Info in a string representation that should be added to the + * response info + * @param log A log in a string represenation that could contain the + * AppHMITypes that are absent in the policy table. + */ + mobile_apis::Result::eType ProcessingAppHMITypesInMessage( + const smart_objects::SmartObject& message); + private: std::string response_info_; mobile_apis::Result::eType result_code_; 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_; diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 11d038fee2..8aac39b268 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -106,6 +106,7 @@ ApplicationImpl::ApplicationImpl( , is_navi_(false) , is_remote_control_supported_(false) , mobile_projection_enabled_(false) + , webengine_projection_enabled_(false) , video_streaming_approved_(false) , audio_streaming_approved_(false) , video_streaming_allowed_(false) @@ -202,24 +203,29 @@ void ApplicationImpl::ChangeSupportingAppHMIType() { is_navi_ = false; is_voice_communication_application_ = false; mobile_projection_enabled_ = false; + webengine_projection_enabled_ = false; const smart_objects::SmartObject& array_app_types = *app_types_; uint32_t lenght_app_types = array_app_types.length(); for (uint32_t i = 0; i < lenght_app_types; ++i) { - if (mobile_apis::AppHMIType::NAVIGATION == - static_cast<mobile_apis::AppHMIType::eType>( - array_app_types[i].asUInt())) { - is_navi_ = true; - } - if (mobile_apis::AppHMIType::COMMUNICATION == - static_cast<mobile_apis::AppHMIType::eType>( - array_app_types[i].asUInt())) { - is_voice_communication_application_ = true; - } - if (mobile_apis::AppHMIType::PROJECTION == - static_cast<mobile_apis::AppHMIType::eType>( - array_app_types[i].asUInt())) { - mobile_projection_enabled_ = true; + const auto app_hmi_type = static_cast<mobile_apis::AppHMIType::eType>( + array_app_types[i].asUInt()); + + switch (app_hmi_type) { + case mobile_apis::AppHMIType::NAVIGATION: + is_navi_ = true; + break; + case mobile_apis::AppHMIType::COMMUNICATION: + is_voice_communication_application_ = true; + break; + case mobile_apis::AppHMIType::PROJECTION: + mobile_projection_enabled_ = true; + break; + case mobile_apis::AppHMIType::WEB_VIEW: + webengine_projection_enabled_ = true; + break; + default: + break; } } } @@ -294,6 +300,15 @@ bool ApplicationImpl::mobile_projection_enabled() const { return mobile_projection_enabled_; } +void ApplicationImpl::set_webengine_projection_enabled(const bool option) { + LOG4CXX_AUTO_TRACE(logger_); + webengine_projection_enabled_ = option; +} + +bool ApplicationImpl::webengine_projection_enabled() const { + return webengine_projection_enabled_; +} + struct StateIDComparator { HmiState::StateID state_id_; StateIDComparator(HmiState::StateID state_id) : state_id_(state_id) {} |