diff options
author | Alexander Kutsan (GitHub) <akutsan@luxoft.com> | 2020-08-21 18:30:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-21 11:30:02 -0400 |
commit | 2bfbdcea6c70219c66eb422fe98bdeda559ff335 (patch) | |
tree | 62ce75afc06bea3451dbe7a2757f858e5a933c20 /src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src | |
parent | 71d659da53a230ea352901974ec0adb3711c3ee2 (diff) | |
download | sdl_core-2bfbdcea6c70219c66eb422fe98bdeda559ff335.tar.gz |
[SDL 0273] WebEngine Projection mode (#3457)
* Temporary commit. Changes rpc_spec submodule reference.
NOTE: should be removed before merge
* Update Mobile API for the new App HMI type WEB_VIEW
* Update HMI API for the new App HMI type WEB_VIEW
* Add app registration support of the hmi type WEB_VIEW
* Update Unit tests related to app registration
Add the new one case to check app registration with AppHMItype WEB_VIEW
Update existing Application Manager UTs with the new methods for WEB_VIEW
Update Application Mock
* Add Unit tests for RAI request test
* Implement HMI states management for WEP apps
* Add new application exit reason RESOURCE_CONSTRAINT
Add RESOURCE_CONSTRAINT to HMI API and its processing to
OnExitApplicationNotification, update unit tests
* Add web socket connection closing on RESOURCE_CONSTRAINT
* Update ProtocolHandlerImpl::OnTMMessageSendFailed
* Add Unit test for OnAppInterfaceUnregistedNotification
* Remove redundant code
* Add WEP media & nonmedia to general test cases
* Move function to iface class to allow its testing
* Add WEP media/nonmedia apps registration for HMI state checks
Added unit test cases for WEP media and non-media applications,
which allow to check HMI Level, system context, audio
and video streaming states calculation after the following actions:
- Initial HMI state after registration
- HMI state after app activaion
- HMI State after app deactivation
- HMI state after app exit
Note: HMI state includes HMI level, audio, video streaming state, system
context
* Make code more clear & easy for debug
* Add test case for WEP app in resuming mode
* Add missed logging
* Close connection after RESOURCE_CONSTRAINT
RESOURCE_CONSTRAINT unregister reason will close connection for all
applications, but not only Web engine projection
* Refactoring no functional changes
Use setters instead of direct access to app_hmi_type bool var
* Use PolicyHandler::CheckHMIType to avoid code duplication
* Update src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
Co-authored-by: JackLivio <jack@livio.io>
* Use log to check if web engine is allowed
* fixup! Use log to check if web engine is allowed
* Revert "fixup! Use log to check if web engine is allowed"
This reverts commit baad4aae5ffdeba5502a533b2eeb18de84d92b05.
* Revert "Use log to check if web engine is allowed"
This reverts commit 94c6a7d9efc6912777834bb5aca22c7b46d43497.
* Revert "Update src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc"
This reverts commit 3296fcc399588f01624c1a27f64ab8bc9176e197.
* Revert "Use PolicyHandler::CheckHMIType to avoid code duplication"
This reverts commit 2c695099a63b838915cb9b5c91c46ad7fc013b47.
* Use log string to check if WEB engine is not allowed
* Update submodules
Co-authored-by: Igor Gapchuk <igapchuck@luxoft.com>
Co-authored-by: sniukalov <sniukaov@luxoft.com>
Co-authored-by: Andriy Byzhynar (GitHub) <AByzhynar@luxoft.com>
Co-authored-by: Mykhailo Vorobiov (GitHub) <61186891+mvorobio@users.noreply.github.com>
Co-authored-by: Your Name <you@example.com>
Co-authored-by: JackLivio <jack@livio.io>
Co-authored-by: YarikMamykin <ymamykin@gmail.com>
Co-authored-by: Andrii Kalinich <AKalinich@luxoft.com>
Diffstat (limited to 'src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src')
3 files changed, 115 insertions, 33 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_application_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_application_notification.cc index 3eec6c5d1a..34365c12e5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_application_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_application_notification.cc @@ -112,6 +112,14 @@ void OnExitApplicationNotification::Run() { break; } #endif // CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT + case Common_ApplicationExitReason::RESOURCE_CONSTRAINT: { + const auto message = + MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( + app_id, AppInterfaceUnregisteredReason::RESOURCE_CONSTRAINT); + SendNotificationToMobile(message); + application_manager_.UnregisterApplication(app_id, Result::SUCCESS); + return; + } default: { LOG4CXX_WARN(logger_, "Unhandled reason"); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_app_interface_unregistered_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_app_interface_unregistered_notification.cc index 5714043a51..30d9853d97 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_app_interface_unregistered_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_app_interface_unregistered_notification.cc @@ -57,7 +57,15 @@ OnAppInterfaceUnregisteredNotification:: void OnAppInterfaceUnregisteredNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); - SendNotification(); + const bool final_message = IsFinalMessage(); + SendNotification(final_message); +} + +bool OnAppInterfaceUnregisteredNotification::IsFinalMessage() const { + using Reason = mobile_apis::AppInterfaceUnregisteredReason::eType; + const auto reason = static_cast<Reason>( + (*message_)[strings::msg_params][strings::reason].asInt()); + return Reason::RESOURCE_CONSTRAINT == reason; } } // namespace commands } // namespace sdl_rpc_plugin 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 70bd47e232..bd36f060ed 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: {} } } @@ -1140,14 +1147,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."); @@ -1173,36 +1180,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; @@ -1540,6 +1531,81 @@ 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 = log.find("WEB_VIEW") != std::string::npos + ? mobile_apis::Result::DISALLOWED + : mobile_apis::Result::WARNINGS; + + 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_; |