From dd4763d22efe6c9f45585c1ac7d83403ea2b2766 Mon Sep 17 00:00:00 2001 From: Jacob Keeler Date: Wed, 6 Oct 2021 17:01:19 -0400 Subject: Check specifically for invalid HMI level when suspending notifications (#3784) * Check specifically for invalid HMI level before suspending notifications Checking for main window ID caused a very rare race condition where the notification was not suspended when necessary --- src/components/application_manager/src/rpc_service_impl.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/application_manager/src/rpc_service_impl.cc b/src/components/application_manager/src/rpc_service_impl.cc index a610bd4371..36dcb335c1 100644 --- a/src/components/application_manager/src/rpc_service_impl.cc +++ b/src/components/application_manager/src/rpc_service_impl.cc @@ -148,8 +148,10 @@ bool RPCServiceImpl::ManageMobileCommand( if (app_ptr && (app_manager_.IsAppInReconnectMode(app_ptr->device(), app_ptr->policy_app_id()) || - (!app_ptr->WindowIdExists(window_id) && - mobile_apis::PredefinedWindows::DEFAULT_WINDOW == window_id && + (mobile_apis::PredefinedWindows::DEFAULT_WINDOW == window_id && + (!app_ptr->WindowIdExists(window_id) || + mobile_apis::HMILevel::INVALID_ENUM == + app_ptr->hmi_level(window_id)) && mobile_apis::messageType::notification == message_type))) { commands_holder_.Suspend( app_ptr, CommandHolder::CommandType::kMobileCommand, source, message); -- cgit v1.2.1 From 2a24f99931161e2cb3c6f8e5cd9f9e6d31ccb9a2 Mon Sep 17 00:00:00 2001 From: "Andrii Kalinich (GitHub)" Date: Mon, 11 Oct 2021 13:35:34 -0400 Subject: Fix SDL build with USE_COTIRE=OFF (#3791) --- .../test/commands/hmi/subscribe_button_request_test.cc | 4 ++++ .../test/commands/hmi/subscribe_button_response_test.cc | 4 +++- .../test/commands/hmi/unsubscribe_button_request_test.cc | 5 +++++ .../test/commands/hmi/unsubscribe_button_response_test.cc | 3 ++- .../test/commands/mobile/get_system_capability_request_test.cc | 1 + 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/subscribe_button_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/subscribe_button_request_test.cc index 61214d64a3..c518bdf9b2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/subscribe_button_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/subscribe_button_request_test.cc @@ -33,7 +33,11 @@ #include "hmi/subscribe_button_request.h" #include #include +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application.h" #include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_resume_ctrl.h" +#include "application_manager/resumption/resumption_data_processor.h" #include "gtest/gtest.h" diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/subscribe_button_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/subscribe_button_response_test.cc index ca4c2ee41b..490a3bc2e5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/subscribe_button_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/subscribe_button_response_test.cc @@ -32,10 +32,12 @@ #include +#include "application_manager/commands/command_request_test.h" #include "application_manager/mock_event_dispatcher.h" -#include "gtest/gtest.h" #include "hmi/subscribe_button_response.h" +#include "gtest/gtest.h" + namespace test { namespace components { namespace commands_test { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/unsubscribe_button_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/unsubscribe_button_request_test.cc index 434738a2e1..5a0790a5e0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/unsubscribe_button_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/unsubscribe_button_request_test.cc @@ -35,7 +35,12 @@ #include #include +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application.h" #include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_resume_ctrl.h" +#include "application_manager/resumption/resumption_data_processor.h" + #include "gtest/gtest.h" namespace test { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/unsubscribe_button_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/unsubscribe_button_response_test.cc index 3d9572a743..1659081e69 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/unsubscribe_button_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/unsubscribe_button_response_test.cc @@ -31,9 +31,10 @@ */ #include +#include "gtest/gtest.h" +#include "application_manager/commands/command_request_test.h" #include "application_manager/mock_event_dispatcher.h" -#include "gtest/gtest.h" #include "hmi/unsubscribe_button_response.h" namespace test { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_system_capability_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_system_capability_request_test.cc index 3574385274..f783df387a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_system_capability_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_system_capability_request_test.cc @@ -34,6 +34,7 @@ #include "application_manager/commands/command_request_test.h" #include "application_manager/message_helper.h" +#include "application_manager/mock_app_service_manager.h" #include "gtest/gtest.h" #include "interfaces/MOBILE_API.h" #include "resumption/last_state_impl.h" -- cgit v1.2.1 From bb738ffc106bbc231bd0ade9dde65fff32c8b5ba Mon Sep 17 00:00:00 2001 From: "Andrii Kalinich (GitHub)" Date: Tue, 12 Oct 2021 14:33:23 -0400 Subject: Fix wrong behavior of RCOnRemoteControlSettingsNotification (#3792) * Fix wrong behavior of RCOnRemoteControlSettingsNotification Looks like `kAllowed` parameter was swithing on/off the RC functionality even if it was not present and previous value should be taken. Processing of `kAllowed` and `kAccessMode` was split on two separate and independent functions make it really isolated. Processing of both parameters was aligned, so now core does not perform extra actions if one of parameter is missing. --- .../rc_on_remote_control_settings_notification.h | 12 ++++++ .../rc_rpc_plugin/resource_allocation_manager.h | 8 ++++ .../rc_on_remote_control_settings_notification.cc | 49 ++++++++++++++-------- .../commands/on_remote_control_settings_test.cc | 49 ++++++++++++++++++++-- 4 files changed, 98 insertions(+), 20 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h index 82e0a8c13b..bb5e7a9b8f 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h @@ -76,6 +76,18 @@ class RCOnRemoteControlSettingsNotification * notifications */ void DisallowRCFunctionality(); + + /** + * @brief Performs the set of actions depending on access mode param received + * in the message + */ + void ProcessAccessModeParam(); + + /** + * @brief Performs the set of actions depending on allowed param received in + * the message + */ + void ProcessAllowedParam(); }; } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h index 623498dac7..db785e4a4f 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h @@ -209,8 +209,16 @@ class ResourceAllocationManager { NotificationTrigger::eType event, application_manager::ApplicationSharedPtr application) = 0; + /** + * @brief Returns current state of RC functionality + * @return current state of RC functionality + */ virtual bool is_rc_enabled() const = 0; + /** + * @brief Sets current state of RC functionality to a new one + * @param value new RC functionality state + */ virtual void set_rc_enabled(const bool value) = 0; /** diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc index 860e18a105..580937bc8a 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc @@ -93,35 +93,50 @@ void RCOnRemoteControlSettingsNotification::Run() { return; } - hmi_apis::Common_RCAccessMode::eType access_mode = - hmi_apis::Common_RCAccessMode::INVALID_ENUM; - if ((*message_)[app_mngr::strings::msg_params].keyExists( + ProcessAccessModeParam(); + ProcessAllowedParam(); +} + +void RCOnRemoteControlSettingsNotification::ProcessAccessModeParam() { + if (!(*message_)[app_mngr::strings::msg_params].keyExists( message_params::kAccessMode)) { - access_mode = static_cast( - (*message_)[app_mngr::strings::msg_params][message_params::kAccessMode] - .asUInt()); SDL_LOG_DEBUG( - "Setting up access mode : " << AccessModeToString(access_mode)); - } else { - access_mode = resource_allocation_manager_.GetAccessMode(); - SDL_LOG_DEBUG("No access mode received. Using last known: " - << AccessModeToString(access_mode)); + "No access mode received. Using last known: " + << AccessModeToString(resource_allocation_manager_.GetAccessMode())); + return; } + + const auto access_mode = static_cast( + (*message_)[app_mngr::strings::msg_params][message_params::kAccessMode] + .asUInt()); + SDL_LOG_DEBUG("Setting up access mode : " << AccessModeToString(access_mode)); resource_allocation_manager_.SetAccessMode(access_mode); +} + +void RCOnRemoteControlSettingsNotification::ProcessAllowedParam() { + if (!(*message_)[app_mngr::strings::msg_params].keyExists( + message_params::kAllowed)) { + SDL_LOG_DEBUG("No allowed param received. Using last known: " + << std::boolalpha + << resource_allocation_manager_.is_rc_enabled()); + return; + } const bool is_allowed = (*message_)[app_mngr::strings::msg_params][message_params::kAllowed] .asBool(); + if (is_allowed) { SDL_LOG_DEBUG("Allowing RC Functionality"); resource_allocation_manager_.set_rc_enabled(true); - } else { - SDL_LOG_DEBUG("Disallowing RC Functionality"); - DisallowRCFunctionality(); - resource_allocation_manager_.ResetAllAllocations(); - resource_allocation_manager_.set_rc_enabled(false); - rc_consent_manager_.RemoveAllConsents(); + return; } + + SDL_LOG_DEBUG("Disallowing RC Functionality"); + DisallowRCFunctionality(); + resource_allocation_manager_.ResetAllAllocations(); + resource_allocation_manager_.set_rc_enabled(false); + rc_consent_manager_.RemoveAllConsents(); } } // namespace commands diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc index 7907013fa3..5d569e93d2 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc @@ -117,18 +117,61 @@ class RCOnRemoteControlSettingsNotificationTest }; TEST_F(RCOnRemoteControlSettingsNotificationTest, - Run_Allowed_SetAccessMode) { // Arrange + Run_Allowed_MissedAccessMode) { // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[application_manager::strings::msg_params] [message_params::kAllowed] = true; // Expectations + EXPECT_CALL(mock_allocation_manager_, SetAccessMode(_)).Times(0); + EXPECT_CALL(mock_allocation_manager_, set_rc_enabled(true)); - ON_CALL(mock_allocation_manager_, GetAccessMode()) - .WillByDefault(Return(hmi_apis::Common_RCAccessMode::ASK_DRIVER)); + // Act + std::shared_ptr< + rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification> + command = CreateRCCommand< + rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification>( + mobile_message); + command->Run(); +} + +TEST_F(RCOnRemoteControlSettingsNotificationTest, + Run_AccessMode_MissedAllowed) { // Arrange + MessageSharedPtr mobile_message = CreateBasicMessage(); + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kAccessMode] = + hmi_apis::Common_RCAccessMode::ASK_DRIVER; + + // Expectations + EXPECT_CALL(mock_allocation_manager_, set_rc_enabled(_)).Times(0); EXPECT_CALL(mock_allocation_manager_, SetAccessMode(hmi_apis::Common_RCAccessMode::ASK_DRIVER)); + + // Act + std::shared_ptr< + rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification> + command = CreateRCCommand< + rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification>( + mobile_message); + + command->Run(); +} + +TEST_F(RCOnRemoteControlSettingsNotificationTest, + Run_AccessModeAndAllowed_BothPresent) { // Arrange + MessageSharedPtr mobile_message = CreateBasicMessage(); + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kAllowed] = true; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kAccessMode] = + hmi_apis::Common_RCAccessMode::ASK_DRIVER; + + // Expectations + EXPECT_CALL(mock_allocation_manager_, set_rc_enabled(true)); + EXPECT_CALL(mock_allocation_manager_, + SetAccessMode(hmi_apis::Common_RCAccessMode::ASK_DRIVER)); + // Act std::shared_ptr< rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification> -- cgit v1.2.1 From b0ccb4809af33a1b8fd30c16bfa77ac738e860ea Mon Sep 17 00:00:00 2001 From: "Andrii Kalinich (GitHub)" Date: Wed, 13 Oct 2021 15:46:18 -0400 Subject: Fix VR.ChangeRegistration issue (#3794) There was found a misprint for a VR interface in `ChangeRegistration` request. Because of that, there might be a situations when HMI responds to one part of request faster than another part was actually sent. All required ordering and checks were updated. --- .../src/commands/mobile/change_registration_request.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc index 47ff7cbea1..f7fc7d2284 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc @@ -230,21 +230,28 @@ void ChangeRegistrationRequest::Run() { SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE); return; } + if (HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE != vr_state) { StartAwaitForInterface(HmiInterfaces::InterfaceID::HMI_INTERFACE_VR); } + if (HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE != tts_state) { StartAwaitForInterface(HmiInterfaces::InterfaceID::HMI_INTERFACE_TTS); } if (HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE != ui_state) { + StartAwaitForInterface(HmiInterfaces::InterfaceID::HMI_INTERFACE_UI); + } + + if (IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_UI)) { SendUIRequest(app, msg_params, hmi_language); } if (IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_TTS)) { SendTTSRequest(app, msg_params); } - if (IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_UI)) { + + if (IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_VR)) { SendVRRequest(app, msg_params); } } -- cgit v1.2.1 From c1ae269995ac18a5fd2cbbb9ed0ab2beb213d7d2 Mon Sep 17 00:00:00 2001 From: "Andrii Kalinich (GitHub)" Date: Thu, 14 Oct 2021 16:48:26 -0400 Subject: Fix/crash after ptu for another app hmi type (#3795) * Added RC plugin extension after PTU * Add new event `kAppHmiTypesChanged` Co-authored-by: OlhaVorobiova --- .../plugin_manager/rpc_plugin.h | 1 + .../app_service_app_extension.h | 3 +- .../src/app_service_app_extension.cc | 2 - .../src/app_service_rpc_plugin.cc | 21 ++++-- .../include/rc_rpc_plugin/rc_app_extension.h | 5 +- .../include/rc_rpc_plugin/rc_rpc_plugin.h | 12 +++- .../rc_rpc_plugin/src/rc_app_extension.cc | 7 +- .../rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc | 3 +- .../rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc | 77 +++++++++++++++------- .../test/commands/button_press_request_test.cc | 5 +- .../get_interior_vehicle_data_request_test.cc | 6 +- .../on_interior_vehicle_data_notification_test.cc | 3 +- .../rc_get_interior_vehicle_data_consent_test.cc | 5 +- .../set_interior_vehicle_data_request_test.cc | 4 +- .../rc_rpc_plugin/test/rc_app_extension_test.cc | 6 +- .../test/rc_pending_resumption_handler_test.cc | 9 +-- .../resource_allocation_manager_impl_test.cc | 37 ++++------- .../extensions/system_capability_app_extension.h | 2 +- .../sdl_rpc_plugin/waypoints_app_extension.h | 2 +- .../extensions/system_capability_app_extension.cc | 3 - .../sdl_rpc_plugin/src/sdl_rpc_plugin.cc | 41 +++++++----- .../sdl_rpc_plugin/src/waypoints_app_extension.cc | 1 - .../vehicle_info_app_extension.h | 2 +- .../src/vehicle_info_app_extension.cc | 2 - .../vehicle_info_plugin/src/vehicle_info_plugin.cc | 22 +++++-- .../application_manager/src/application_impl.cc | 13 +++- .../src/application_manager_impl.cc | 13 +++- 27 files changed, 186 insertions(+), 121 deletions(-) diff --git a/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h b/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h index 0c7538e809..4f143dc365 100644 --- a/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h +++ b/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h @@ -62,6 +62,7 @@ enum ApplicationEvent { kApplicationUnregistered, kDeleteApplicationData, kGlobalPropertiesUpdated, + kAppHmiTypesChanged, kRCStatusChanged }; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_app_extension.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_app_extension.h index 8d307325fc..b7898709ab 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_app_extension.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_app_extension.h @@ -44,7 +44,6 @@ class AppServiceRpcPlugin; namespace app_mngr = application_manager; -typedef int AppExtensionUID; typedef mobile_apis::VehicleDataType::eType VehicleDataType; /** * @brief Defines set of app service types @@ -114,6 +113,8 @@ class AppServiceAppExtension : public app_mngr::AppExtension { static AppServiceAppExtension& ExtractASExtension( application_manager::Application& app); + static const app_mngr::AppExtensionUID AppServiceAppExtensionUID = 455; + private: AppServiceSubscriptions subscribed_data_; AppServiceRpcPlugin& plugin_; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc index 1b8c5bfd1d..1cd2fd690a 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc @@ -38,8 +38,6 @@ SDL_CREATE_LOG_VARIABLE("AppServiceRpcPlugin") namespace app_service_rpc_plugin { -const AppExtensionUID AppServiceAppExtensionUID = 455; - AppServiceAppExtension::AppServiceAppExtension( AppServiceRpcPlugin& plugin, application_manager::Application& app) : app_mngr::AppExtension(AppServiceAppExtensionUID) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc index 0e805da46c..e842ea7276 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc @@ -76,11 +76,22 @@ void AppServiceRpcPlugin::OnPolicyEvent(plugins::PolicyEvent event) {} void AppServiceRpcPlugin::OnApplicationEvent( plugins::ApplicationEvent event, app_mngr::ApplicationSharedPtr application) { - if (plugins::ApplicationEvent::kApplicationRegistered == event) { - application->AddExtension( - std::make_shared(*this, *application)); - } else if (plugins::ApplicationEvent::kDeleteApplicationData == event) { - DeleteSubscriptions(application); + switch (event) { + case plugins::ApplicationEvent::kApplicationRegistered: { + application->AddExtension( + std::make_shared(*this, *application)); + break; + } + + case plugins::ApplicationEvent::kApplicationUnregistered: + case plugins::ApplicationEvent::kDeleteApplicationData: { + DeleteSubscriptions(application); + break; + } + + default: { + break; + } } } diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h index 8b2162c9ab..031e89fd85 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h @@ -143,8 +143,7 @@ class RCRPCPlugin; class RCAppExtension : public application_manager::AppExtension { public: - explicit RCAppExtension(application_manager::AppExtensionUID uid, - RCRPCPlugin& plugin, + explicit RCAppExtension(RCRPCPlugin& plugin, application_manager::Application& application); ~RCAppExtension(); @@ -232,6 +231,8 @@ class RCAppExtension : public application_manager::AppExtension { */ void SetUserLocation(const Grid& grid); + static const application_manager::AppExtensionUID RCAppExtensionID = 153; + private: /** * @brief Checks if the application's pointer is valid and update the diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h index c1f7339aa3..e45d48d63a 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h @@ -125,7 +125,17 @@ class RCRPCPlugin : public plugins::RPCPlugin { bool IsOtherAppsSubscribed(const rc_rpc_types::ModuleUid& module, const uint32_t app_id); - static const uint32_t kRCPluginID = 153; + /** + * @brief Creates the RC extension for specified application + * @param application pointer to app to work with + */ + void CreateRcExtension(application_manager::ApplicationSharedPtr application); + + /** + * @brief Removes the RC extensions for specified application + * @param application pointer to app to work with + */ + void RemoveRcExtension(application_manager::ApplicationSharedPtr application); typedef std::vector Apps; static Apps GetRCApplications( diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc index b623350388..b38df8f985 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc @@ -71,10 +71,11 @@ std::set ConvertSmartObjectToModuleCollection( } // namespace namespace rc_rpc_plugin { -RCAppExtension::RCAppExtension(application_manager::AppExtensionUID uid, - RCRPCPlugin& plugin, +RCAppExtension::RCAppExtension(RCRPCPlugin& plugin, application_manager::Application& application) - : AppExtension(uid), plugin_(plugin), application_(application) {} + : AppExtension(RCAppExtensionID) + , plugin_(plugin) + , application_(application) {} void RCAppExtension::SubscribeToInteriorVehicleData(const ModuleUid& module) { subscribed_interior_vehicle_data_.insert(module); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc index b2d1f1513b..7b6d5041c0 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc @@ -186,7 +186,8 @@ const std::vector RCHelpers::GetModuleTypesList() { RCAppExtensionPtr RCHelpers::GetRCExtension( application_manager::Application& app) { SDL_LOG_AUTO_TRACE(); - auto extension_interface = app.QueryInterface(RCRPCPlugin::kRCPluginID); + auto extension_interface = + app.QueryInterface(RCAppExtension::RCAppExtensionID); auto extension = std::static_pointer_cast(extension_interface); return extension; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc index 8250437e78..b110d3157d 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc @@ -111,42 +111,50 @@ void RCRPCPlugin::OnApplicationEvent( application_manager::plugin_manager::ApplicationEvent event, application_manager::ApplicationSharedPtr application) { SDL_LOG_AUTO_TRACE(); - if (!application->is_remote_control_supported()) { - SDL_LOG_DEBUG( - "Remote control is not supported for application with app_id: " - << application->app_id()); - return; - } + switch (event) { case plugins::kApplicationRegistered: { - auto extension = std::shared_ptr( - new RCAppExtension(kRCPluginID, *this, *application)); - DCHECK_OR_RETURN_VOID(application->AddExtension(extension)); - const auto driver_location = - rc_capabilities_manager_ - ->GetDriverLocationFromSeatLocationCapability(); - extension->SetUserLocation(driver_location); + if (application->is_remote_control_supported()) { + CreateRcExtension(application); + } + break; } + case plugins::kApplicationUnregistered: case plugins::kApplicationExit: { - resource_allocation_manager_->OnApplicationEvent(event, application); - interior_data_manager_->OnApplicationEvent(event, application); - break; - } - case plugins::kApplicationUnregistered: { - resource_allocation_manager_->OnApplicationEvent(event, application); - interior_data_manager_->OnApplicationEvent(event, application); + if (application->is_remote_control_supported()) { + resource_allocation_manager_->OnApplicationEvent(event, application); + interior_data_manager_->OnApplicationEvent(event, application); + } + break; } case plugins::kGlobalPropertiesUpdated: { - const auto user_location = application->get_user_location(); - auto extension = RCHelpers::GetRCExtension(*application); - extension->SetUserLocation(user_location); + if (application->is_remote_control_supported()) { + const auto user_location = application->get_user_location(); + auto extension = RCHelpers::GetRCExtension(*application); + extension->SetUserLocation(user_location); + } + break; } case plugins::kRCStatusChanged: { - resource_allocation_manager_->SendOnRCStatusNotifications( - NotificationTrigger::APP_REGISTRATION, application); + if (application->is_remote_control_supported()) { + resource_allocation_manager_->SendOnRCStatusNotifications( + NotificationTrigger::APP_REGISTRATION, application); + } + + break; + } + case plugins::kAppHmiTypesChanged: { + auto extension = + application->QueryInterface(RCAppExtension::RCAppExtensionID); + if (!application->is_remote_control_supported() && extension) { + RemoveRcExtension(application); + } else if (application->is_remote_control_supported() && !extension) { + CreateRcExtension(application); + } + break; } default: @@ -154,6 +162,25 @@ void RCRPCPlugin::OnApplicationEvent( } } +void RCRPCPlugin::CreateRcExtension( + application_manager::ApplicationSharedPtr application) { + auto extension = + std::shared_ptr(new RCAppExtension(*this, *application)); + DCHECK_OR_RETURN_VOID(application->AddExtension(extension)); + const auto driver_location = + rc_capabilities_manager_->GetDriverLocationFromSeatLocationCapability(); + extension->SetUserLocation(driver_location); +} + +void RCRPCPlugin::RemoveRcExtension( + application_manager::ApplicationSharedPtr application) { + resource_allocation_manager_->OnApplicationEvent( + plugins::kApplicationUnregistered, application); + interior_data_manager_->OnApplicationEvent(plugins::kApplicationUnregistered, + application); + application->RemoveExtension(RCAppExtension::RCAppExtensionID); +} + void RCRPCPlugin::ProcessResumptionSubscription( application_manager::Application& app, RCAppExtension& ext) { SDL_LOG_AUTO_TRACE(); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc index 3772a25f47..f4ef39f488 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc @@ -65,7 +65,6 @@ using ::testing::ReturnRef; using ::testing::SaveArg; namespace { -const int kModuleId = 153u; const uint32_t kConnectionKey = 1u; const uint32_t kAppId = 0u; const std::string kPolicyAppId = "Test"; @@ -83,13 +82,13 @@ class ButtonPressRequestTest smart_objects::SmartType_Map)) , mock_app_(std::make_shared >()) , rc_app_extension_(std::make_shared( - kModuleId, rc_plugin_, *mock_app_)) {} + rc_plugin_, *mock_app_)) {} void SetUp() OVERRIDE { smart_objects::SmartObject control_caps((smart_objects::SmartType_Array)); (*rc_capabilities_)[strings::kradioControlCapabilities] = control_caps; ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_)); - ON_CALL(*mock_app_, QueryInterface(RCRPCPlugin::kRCPluginID)) + ON_CALL(*mock_app_, QueryInterface(RCAppExtension::RCAppExtensionID)) .WillByDefault(Return(rc_app_extension_)); ON_CALL(app_mngr_, GetPolicyHandler()) .WillByDefault(ReturnRef(mock_policy_handler_)); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc index fdfa3ea03a..5fa474c631 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc @@ -95,9 +95,9 @@ class GetInteriorVehicleDataRequestTest : mock_app_(std::make_shared >()) , mock_app2_(std::make_shared >()) , rc_app_extension_( - std::make_shared(kModuleId, rc_plugin_, *mock_app_)) - , rc_app_extension2_(std::make_shared( - kModuleId, rc_plugin_, *mock_app2_)) + std::make_shared(rc_plugin_, *mock_app_)) + , rc_app_extension2_( + std::make_shared(rc_plugin_, *mock_app2_)) , apps_lock_(std::make_shared()) , apps_da_(apps_, apps_lock_) , rc_capabilities_(std::make_shared( diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_interior_vehicle_data_notification_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_interior_vehicle_data_notification_test.cc index 6c7a7ba67e..9acfc084c5 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_interior_vehicle_data_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_interior_vehicle_data_notification_test.cc @@ -62,7 +62,6 @@ const uint32_t kConnectionKey = 1u; const std::string kPolicyAppId = "Test"; const std::string module_type = "CLIMATE"; const std::string module_id = "34045662-a9dc-4823-8435-91056d4c26cb"; -const int kModuleId = 153u; } // namespace namespace rc_rpc_plugin_test { @@ -75,7 +74,7 @@ class OnInteriorVehicleDataNotificationTest OnInteriorVehicleDataNotificationTest() : mock_app_(std::make_shared >()) , rc_app_extension_( - std::make_shared(kModuleId, rc_plugin_, *mock_app_)) + std::make_shared(rc_plugin_, *mock_app_)) , apps_lock_(std::make_shared()) , apps_da_(apps_, apps_lock_) { ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc index 1b83034daf..82d1b128f0 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc @@ -99,7 +99,6 @@ const std::string kResource = "CLIMATE"; const std::string kResourceId = "34045662-a9dc-4823-8435-91056d4c26cb"; const std::string kPolicyAppId = "policy_app_id"; const std::string kMacAddress = "device1"; -const uint32_t kPluginID = RCRPCPlugin::kRCPluginID; } // namespace class RCGetInteriorVehicleDataConsentTest @@ -124,7 +123,7 @@ class RCGetInteriorVehicleDataConsentTest hmi_so_factory_, mobile_so_factoy_) , rc_app_extension_( - std::make_shared(kPluginID, rc_plugin_, *mock_app_)) + std::make_shared(rc_plugin_, *mock_app_)) , mock_rpc_plugin_manager( std::make_shared >()) , rpc_plugin(mock_rpc_plugin) @@ -140,7 +139,7 @@ class RCGetInteriorVehicleDataConsentTest .WillByDefault(Return(application_manager::HmiInterfaces:: InterfaceState::STATE_AVAILABLE)); ON_CALL(app_mngr_, application(kAppId)).WillByDefault(Return(mock_app_)); - ON_CALL(*mock_app_, QueryInterface(RCRPCPlugin::kRCPluginID)) + ON_CALL(*mock_app_, QueryInterface(RCAppExtension::RCAppExtensionID)) .WillByDefault(Return(rc_app_extension_)); testing::NiceMock mock_interior_data_cache_; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc index 9ba959de29..fe190a796f 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc @@ -74,7 +74,7 @@ class SetInteriorVehicleDataRequestTest SetInteriorVehicleDataRequestTest() : mock_app_(std::make_shared >()) , rc_app_extension_( - std::make_shared(kModuleId, rc_plugin_, *mock_app_)) + std::make_shared(rc_plugin_, *mock_app_)) , rc_capabilities_(std::make_shared( smart_objects::SmartType::SmartType_Array)) {} @@ -89,7 +89,7 @@ class SetInteriorVehicleDataRequestTest .WillByDefault(Return(application_manager::HmiInterfaces:: InterfaceState::STATE_AVAILABLE)); ON_CALL(app_mngr_, application(kAppId)).WillByDefault(Return(mock_app_)); - ON_CALL(*mock_app_, QueryInterface(RCRPCPlugin::kRCPluginID)) + ON_CALL(*mock_app_, QueryInterface(RCAppExtension::RCAppExtensionID)) .WillByDefault(Return(rc_app_extension_)); ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kPolicyAppId)); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/rc_app_extension_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/rc_app_extension_test.cc index 60c3fb9135..ea099ef901 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/rc_app_extension_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/rc_app_extension_test.cc @@ -40,10 +40,6 @@ #include "rc_rpc_plugin/rc_module_constants.h" #include "rc_rpc_plugin/rc_rpc_plugin.h" -namespace { -const uint32_t kRCAppExtensionId = 1ull; -} // namespace - namespace test { namespace components { namespace rc_rpc_plugin_test { @@ -57,7 +53,7 @@ class RcAppExtensionTest : public testing::Test { RcAppExtensionTest() : mock_app_(new NiceMock()) , rc_app_extension_(std::make_shared( - kRCAppExtensionId, rc_plugin_, *mock_app_)) {} + rc_plugin_, *mock_app_)) {} protected: std::unique_ptr mock_app_; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/rc_pending_resumption_handler_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/rc_pending_resumption_handler_test.cc index 077d0d2927..8ea478cd19 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/rc_pending_resumption_handler_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/rc_pending_resumption_handler_test.cc @@ -78,7 +78,6 @@ const std::string kModuleType_1 = "CLIMATE"; const std::string kModuleId_1 = "9cb963f3-c5e8-41cb-b001-19421cc16552"; const std::string kModuleType_2 = "RADIO"; const std::string kModuleId_2 = "357a3918-9f35-4d86-a8b6-60cd4308d76f"; -const uint32_t kRCPluginID = rc_rpc_plugin::RCRPCPlugin::kRCPluginID; const auto kSourceHMI = application_manager::commands::Command::SOURCE_HMI; } // namespace @@ -171,9 +170,11 @@ class RCPendingResumptionHandlerTest : public ::testing::Test { } rc_rpc_plugin::RCAppExtensionPtr CreateExtension(MockApplication& app) { - auto rc_app_ext = std::make_shared( - kRCPluginID, rc_plugin_, app); - ON_CALL(app, QueryInterface(kRCPluginID)).WillByDefault(Return(rc_app_ext)); + auto rc_app_ext = + std::make_shared(rc_plugin_, app); + ON_CALL(app, + QueryInterface(rc_rpc_plugin::RCAppExtension::RCAppExtensionID)) + .WillByDefault(Return(rc_app_ext)); return rc_app_ext; } diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager/resource_allocation_manager_impl_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager/resource_allocation_manager_impl_test.cc index 501fbc323d..bae6ed805c 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager/resource_allocation_manager_impl_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager/resource_allocation_manager_impl_test.cc @@ -112,9 +112,8 @@ class RAManagerTest : public ::testing::Test { , mock_rc_helpers_(MockRCHelpers::rc_helpers_mock()) { ON_CALL(mock_app_mngr_, GetPolicyHandler()) .WillByDefault(ReturnRef(mock_policy_handler_)); - auto plugin_id = rc_rpc_plugin::RCRPCPlugin::kRCPluginID; app_ext_ptr_ = std::make_shared( - plugin_id, rc_plugin_, *mock_app_1_); + rc_plugin_, *mock_app_1_); ON_CALL(*mock_app_1_, app_id()).WillByDefault(Return(kAppId1)); PrepareResources(); @@ -130,13 +129,12 @@ class RAManagerTest : public ::testing::Test { ON_CALL(mock_app_mngr_, application(kAppId1)) .WillByDefault(Return(mock_app_1_)); ON_CALL(*mock_app_1_, - QueryInterface(rc_rpc_plugin::RCRPCPlugin::kRCPluginID)) + QueryInterface(rc_rpc_plugin::RCAppExtension::RCAppExtensionID)) .WillByDefault(Return(app_ext_ptr_)); ON_CALL(mock_app_mngr_, application(kAppId2)) .WillByDefault(Return(mock_app_2_)); - ON_CALL(*mock_app_2_, - QueryInterface(rc_rpc_plugin::RCRPCPlugin::kRCPluginID)) + ON_CALL(*mock_app_2_, QueryInterface(RCAppExtension::RCAppExtensionID)) .WillByDefault(Return(app_ext_ptr_)); OnRCStatusNotificationExpectations(); @@ -144,10 +142,7 @@ class RAManagerTest : public ::testing::Test { void SetUp() OVERRIDE { rc_app_extension_ = std::make_shared( - static_cast( - rc_rpc_plugin::RCRPCPlugin::kRCPluginID), - rc_plugin_, - *mock_app_1_); + rc_plugin_, *mock_app_1_); ON_CALL(mock_rc_capabilities_manager_, GetDriverLocationFromSeatLocationCapability()) .WillByDefault(Return(kDriverLocation)); @@ -407,11 +402,8 @@ TEST_F(RAManagerTest, AppUnregistered_ReleaseResource) { mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::eType::AUTO_DENY); - RCAppExtensionPtr rc_extension_ptr = std::make_shared( - application_manager::AppExtensionUID( - rc_rpc_plugin::RCRPCPlugin::kRCPluginID), - rc_plugin_, - *mock_app_1_); + RCAppExtensionPtr rc_extension_ptr = + std::make_shared(rc_plugin_, *mock_app_1_); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); @@ -483,13 +475,10 @@ TEST_F(RAManagerTest, AppsDisallowed_ReleaseAllResources) { EXPECT_CALL(mock_app_mngr_, applications()).WillRepeatedly(Return(apps_da)); - RCAppExtensionPtr rc_extension_ptr = std::make_shared( - application_manager::AppExtensionUID( - rc_rpc_plugin::RCRPCPlugin::kRCPluginID), - rc_plugin_, - *mock_app_1_); + RCAppExtensionPtr rc_extension_ptr = + std::make_shared(rc_plugin_, *mock_app_1_); - EXPECT_CALL(*mock_app_1_, QueryInterface(RCRPCPlugin::kRCPluginID)) + EXPECT_CALL(*mock_app_1_, QueryInterface(RCAppExtension::RCAppExtensionID)) .WillRepeatedly(Return(rc_extension_ptr)); // Act @@ -517,13 +506,9 @@ TEST_F(RAManagerTest, AppGotRevokedModulesWithPTU_ReleaseRevokedResource) { .WillRepeatedly(Return(mock_app_1_)); RCAppExtensionPtr rc_extension_ptr = - std::make_shared( - application_manager::AppExtensionUID( - rc_rpc_plugin::RCRPCPlugin::kRCPluginID), - rc_plugin_, - *mock_app_1_); + std::make_shared(rc_plugin_, *mock_app_1_); - EXPECT_CALL(*mock_app_1_, QueryInterface(RCRPCPlugin::kRCPluginID)) + EXPECT_CALL(*mock_app_1_, QueryInterface(RCAppExtension::RCAppExtensionID)) .WillRepeatedly(Return(rc_extension_ptr)); ON_CALL(*mock_app_1_, is_remote_control_supported()) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/extensions/system_capability_app_extension.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/extensions/system_capability_app_extension.h index 09fbc565c5..6b25bb7316 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/extensions/system_capability_app_extension.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/extensions/system_capability_app_extension.h @@ -69,7 +69,7 @@ class SystemCapabilityAppExtension : public app_mngr_::AppExtension { void RevertResumption( const smart_objects::SmartObject& subscriptions) OVERRIDE; - static const app_mngr_::AppExtensionUID SystemCapabilityAppExtensionUID; + static const app_mngr_::AppExtensionUID SystemCapabilityAppExtensionUID = 200; static SystemCapabilityAppExtension& ExtractExtension( app_mngr_::Application& app); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/waypoints_app_extension.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/waypoints_app_extension.h index 9243baedee..ce4f56bd84 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/waypoints_app_extension.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/waypoints_app_extension.h @@ -59,7 +59,7 @@ class WayPointsAppExtension : public app_mngr::AppExtension { * @brief WayPointsAppExtensionUID unique identifier of waypoints * aplication extension */ - static unsigned WayPointsAppExtensionUID; + static const app_mngr::AppExtensionUID WayPointsAppExtensionUID = 138; private: SDLRPCPlugin& plugin_; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/extensions/system_capability_app_extension.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/extensions/system_capability_app_extension.cc index 117e65d2cb..0217c6f6a5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/extensions/system_capability_app_extension.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/extensions/system_capability_app_extension.cc @@ -7,9 +7,6 @@ SDL_CREATE_LOG_VARIABLE("GetSystemCapabilitiesAppExtension") namespace app_mngr_ = application_manager; namespace strings = app_mngr::strings; -const app_mngr_::AppExtensionUID - SystemCapabilityAppExtension::SystemCapabilityAppExtensionUID = 200; - SystemCapabilityAppExtension::SystemCapabilityAppExtension( sdl_rpc_plugin::SDLRPCPlugin& plugin, app_mngr_::Application& app) : app_mngr_::AppExtension( diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc index 7cdfc73ed0..a0ad320cac 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc @@ -81,21 +81,32 @@ void SDLRPCPlugin::OnApplicationEvent( plugins::ApplicationEvent event, app_mngr::ApplicationSharedPtr application) { SDL_LOG_AUTO_TRACE(); - if (plugins::ApplicationEvent::kApplicationRegistered == event) { - application->AddExtension( - std::make_shared(*this, *application)); - - auto sys_cap_ext_ptr = - std::make_shared(*this, *application); - application->AddExtension(sys_cap_ext_ptr); - // Processing automatic subscription to SystemCapabilities for DISPLAY type - const auto capability_type = - mobile_apis::SystemCapabilityType::eType::DISPLAYS; - SDL_LOG_DEBUG("Subscription to DISPLAYS capability is enabled"); - sys_cap_ext_ptr->SubscribeTo(capability_type); - - } else if (plugins::ApplicationEvent::kDeleteApplicationData == event) { - ClearSubscriptions(application); + switch (event) { + case plugins::ApplicationEvent::kApplicationRegistered: { + application->AddExtension( + std::make_shared(*this, *application)); + + auto sys_cap_ext_ptr = + std::make_shared(*this, *application); + application->AddExtension(sys_cap_ext_ptr); + // Processing automatic subscription to SystemCapabilities for DISPLAY + // type + const auto capability_type = + mobile_apis::SystemCapabilityType::eType::DISPLAYS; + SDL_LOG_DEBUG("Subscription to DISPLAYS capability is enabled"); + sys_cap_ext_ptr->SubscribeTo(capability_type); + break; + } + + case plugins::ApplicationEvent::kApplicationUnregistered: + case plugins::ApplicationEvent::kDeleteApplicationData: { + ClearSubscriptions(application); + break; + } + + default: { + break; + } } } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/waypoints_app_extension.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/waypoints_app_extension.cc index ed8283e1f9..3c73a61f1b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/waypoints_app_extension.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/waypoints_app_extension.cc @@ -32,7 +32,6 @@ SDL_CREATE_LOG_VARIABLE("WayPointsAppExtension") namespace sdl_rpc_plugin { namespace strings = application_manager::strings; -unsigned WayPointsAppExtension::WayPointsAppExtensionUID = 138; WayPointsAppExtension::WayPointsAppExtension( SDLRPCPlugin& plugin, application_manager::Application& app) diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_app_extension.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_app_extension.h index 7e3eabb6a1..1d3fcd1e74 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_app_extension.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_app_extension.h @@ -152,7 +152,7 @@ class VehicleInfoAppExtension : public app_mngr::AppExtension { * @brief VehicleInfoAppExtensionUID unique identifier of VehicleInfo * aplication extension */ - static unsigned VehicleInfoAppExtensionUID; + static const app_mngr::AppExtensionUID VehicleInfoAppExtensionUID = 146; /** * @brief ExtractVIExtension utility function to extract application extension diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc index 1b503ff943..cff5d294ad 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc @@ -38,8 +38,6 @@ SDL_CREATE_LOG_VARIABLE("VehicleInfoPlugin") namespace vehicle_info_plugin { namespace strings = application_manager::strings; -unsigned VehicleInfoAppExtension::VehicleInfoAppExtensionUID = 146; - VehicleInfoAppExtension::VehicleInfoAppExtension( VehicleInfoPlugin& plugin, application_manager::Application& app) : app_mngr::AppExtension( diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc index b20e52636c..84bd9f6b04 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc @@ -110,12 +110,22 @@ void VehicleInfoPlugin::OnApplicationEvent( plugins::ApplicationEvent event, app_mngr::ApplicationSharedPtr application) { SDL_LOG_AUTO_TRACE(); - if (plugins::ApplicationEvent::kApplicationRegistered == event) { - application->AddExtension( - std::make_shared(*this, *application)); - } else if ((plugins::ApplicationEvent::kDeleteApplicationData == event) || - (plugins::ApplicationEvent::kApplicationUnregistered == event)) { - DeleteSubscriptions(application); + switch (event) { + case plugins::ApplicationEvent::kApplicationRegistered: { + application->AddExtension( + std::make_shared(*this, *application)); + break; + } + + case plugins::ApplicationEvent::kApplicationUnregistered: + case plugins::ApplicationEvent::kDeleteApplicationData: { + DeleteSubscriptions(application); + break; + } + + default: { + break; + } } } diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index a53141b5be..42afd93459 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -204,6 +204,7 @@ void ApplicationImpl::ChangeSupportingAppHMIType() { set_voice_communication_supported(false); set_mobile_projection_enabled(false); set_webengine_projection_enabled(false); + set_remote_control_supported(false); const smart_objects::SmartObject& array_app_types = *app_types_; uint32_t lenght_app_types = array_app_types.length(); @@ -224,6 +225,9 @@ void ApplicationImpl::ChangeSupportingAppHMIType() { case mobile_apis::AppHMIType::WEB_VIEW: set_webengine_projection_enabled(true); break; + case mobile_apis::AppHMIType::REMOTE_CONTROL: + set_remote_control_supported(true); + break; default: break; } @@ -1302,6 +1306,7 @@ AppExtensionPtr ApplicationImpl::QueryInterface(AppExtensionUID uid) { } bool ApplicationImpl::AddExtension(AppExtensionPtr extension) { + SDL_LOG_AUTO_TRACE(); if (!QueryInterface(extension->uid())) { SDL_LOG_TRACE("Add extenstion to add id" << app_id() << " with uid " << extension->uid()); @@ -1312,12 +1317,18 @@ bool ApplicationImpl::AddExtension(AppExtensionPtr extension) { } bool ApplicationImpl::RemoveExtension(AppExtensionUID uid) { + SDL_LOG_AUTO_TRACE(); auto it = std::find_if( extensions_.begin(), extensions_.end(), [uid](AppExtensionPtr extension) { return extension->uid() == uid; }); - return it != extensions_.end(); + if (extensions_.end() != it) { + extensions_.erase(it); + return true; + } + + return false; } const std::list& ApplicationImpl::Extensions() const { diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index f350c9fc5a..b0b05a3031 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -4493,8 +4493,17 @@ void ApplicationManagerImpl::OnUpdateHMIAppType( } if (flag_diffirence_app_hmi_type) { - (*it)->set_app_types(transform_app_hmi_types); - (*it)->ChangeSupportingAppHMIType(); + ApplicationSharedPtr app = *it; + + app->set_app_types(transform_app_hmi_types); + app->ChangeSupportingAppHMIType(); + + auto on_app_hmi_types_changed = [app]( + plugin_manager::RPCPlugin& plugin) { + plugin.OnApplicationEvent(plugin_manager::kAppHmiTypesChanged, app); + }; + ApplyFunctorForEachPlugin(on_app_hmi_types_changed); + const mobile_apis::HMILevel::eType app_hmi_level = (*it)->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); if (app_hmi_level == mobile_api::HMILevel::HMI_BACKGROUND) { -- cgit v1.2.1 From 0ed38e8d2f7cb3a61a303cca2806a06ce9a1d58d Mon Sep 17 00:00:00 2001 From: "Andrii Kalinich (GitHub)" Date: Thu, 14 Oct 2021 17:25:42 -0400 Subject: Fix early IsRegistered() state of application (#3796) * Fix early IsRegistered state of application Mark application as registered only when app registration was finalized and all corresponding requests were sent to HMI. This prevents data races in case when language has been changed by HMI and application is in intermediate registration state yet. * fixup! Fix early IsRegistered state of application --- .../hmi/on_tts_language_change_notification.cc | 15 +++--- .../hmi/on_vr_language_change_notification.cc | 9 +++- .../src/commands/hmi/sdl_activate_app_request.cc | 50 ++++++++++++------ .../mobile/register_app_interface_request.cc | 3 +- .../test/commands/hmi/hmi_notifications_test.cc | 4 ++ .../commands/hmi/sdl_activate_app_request_test.cc | 61 ++++++++++++++++++---- .../src/application_manager_impl.cc | 3 -- .../src/message_helper/message_helper.cc | 2 +- 8 files changed, 108 insertions(+), 39 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_language_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_language_change_notification.cc index 3c25ff5386..d693c00ac3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_language_change_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_language_change_notification.cc @@ -88,12 +88,15 @@ void OnTTSLanguageChangeNotification::Run() { (*message_)[strings::params][strings::function_id] = static_cast(mobile_apis::FunctionID::OnLanguageChangeID); - const ApplicationSet& accessor = - application_manager_.applications().GetData(); - ApplicationSetIt it = accessor.begin(); - for (; accessor.end() != it;) { - ApplicationSharedPtr app = *it; - ++it; + const auto applications = application_manager_.applications().GetData(); + for (const auto& app : applications) { + if (!app->IsRegistered()) { + SDL_LOG_DEBUG("Skipping app " + << app->app_id() + << " which has not finished the registration process"); + continue; + } + (*message_)[strings::params][strings::connection_key] = app->app_id(); SendNotificationToMobile(message_); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_language_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_language_change_notification.cc index bf00291c88..23c1ec1b80 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_language_change_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_language_change_notification.cc @@ -79,10 +79,17 @@ void OnVRLanguageChangeNotification::Run() { static_cast(mobile_apis::FunctionID::OnLanguageChangeID); const auto applications = application_manager_.applications().GetData(); - for (auto app : applications) { + if (!app->IsRegistered()) { + SDL_LOG_DEBUG("Skipping app " + << app->app_id() + << " which has not finished the registration process"); + continue; + } + (*message_)[strings::params][strings::connection_key] = app->app_id(); SendNotificationToMobile(message_); + if (static_cast(app->language()) != (*message_)[strings::msg_params][strings::language].asInt()) { application_manager_.state_controller().SetRegularState( diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc index a8b34bf2d4..88b3065fb0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc @@ -136,18 +136,10 @@ void SDLActivateAppRequest::Run() { static_cast(function_id()), hmi_apis::Common_Result::REJECTED, "HMIDeactivate is active"); - } else if (app && !app->IsRegistered() && app->is_cloud_app()) { - SDL_LOG_DEBUG("Starting cloud application."); - const ApplicationManagerSettings& settings = - application_manager_.get_settings(); - uint32_t total_retry_timeout = (settings.cloud_app_retry_timeout() * - settings.cloud_app_max_retry_attempts()); - application_manager_.UpdateRequestTimeout( - 0, correlation_id(), default_timeout_ + total_retry_timeout); - subscribe_on_event(BasicCommunication_OnAppRegistered); - application_manager_.connection_handler().ConnectToDevice(app->device()); - } else { - const uint32_t application_id = app_id(); + return; + } + + if (!app->is_cloud_app() || app->IsRegistered()) { auto main_state = app->CurrentHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); if (mobile_apis::HMILevel::INVALID_ENUM == main_state->hmi_level()) { @@ -156,11 +148,30 @@ void SDLActivateAppRequest::Run() { "yet, postpone activation"); auto& postponed_activation_ctrl = application_manager_.state_controller() .GetPostponedActivationController(); - postponed_activation_ctrl.AddAppToActivate(application_id, + postponed_activation_ctrl.AddAppToActivate(app->app_id(), correlation_id()); return; } + } + + const uint32_t application_id = app_id(); + if (app->IsRegistered()) { + SDL_LOG_DEBUG("Application is registered. Activating."); policy_handler_.OnActivateApp(application_id, correlation_id()); + return; + } + + if (app->is_cloud_app()) { + SDL_LOG_DEBUG("Starting cloud application."); + const ApplicationManagerSettings& settings = + application_manager_.get_settings(); + uint32_t total_retry_timeout = (settings.cloud_app_retry_timeout() * + settings.cloud_app_max_retry_attempts()); + application_manager_.UpdateRequestTimeout( + 0, correlation_id(), default_timeout_ + total_retry_timeout); + subscribe_on_event(BasicCommunication_OnAppRegistered); + application_manager_.connection_handler().ConnectToDevice(app->device()); + return; } } @@ -205,8 +216,7 @@ void SDLActivateAppRequest::Run() { return; } - if (app_to_activate->IsRegistered()) { - SDL_LOG_DEBUG("Application is registered. Activating."); + if (!app_to_activate->is_cloud_app() || app_to_activate->IsRegistered()) { auto main_state = app_to_activate->CurrentHmiState( mobile_apis::PredefinedWindows::DEFAULT_WINDOW); if (mobile_apis::HMILevel::INVALID_ENUM == main_state->hmi_level()) { @@ -215,13 +225,19 @@ void SDLActivateAppRequest::Run() { "yet, postpone activation"); auto& postponed_activation_ctrl = application_manager_.state_controller() .GetPostponedActivationController(); - postponed_activation_ctrl.AddAppToActivate(application_id, + postponed_activation_ctrl.AddAppToActivate(app_to_activate->app_id(), correlation_id()); return; } + } + + if (app_to_activate->IsRegistered()) { + SDL_LOG_DEBUG("Application is registered. Activating."); policy_handler_.OnActivateApp(application_id, correlation_id()); return; - } else if (app_to_activate->is_cloud_app()) { + } + + if (app_to_activate->is_cloud_app()) { SDL_LOG_DEBUG("Starting cloud application."); const ApplicationManagerSettings& settings = application_manager_.get_settings(); 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 2224f17c4e..9a9aa0c533 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 @@ -440,6 +440,8 @@ void FinishSendingResponseToMobile(const smart_objects::SmartObject& msg_params, &(msg_params[strings::app_hmi_type])); } + application->MarkRegistered(); + // Default HMI level should be set before any permissions validation, since // it relies on HMI level. app_manager.OnApplicationRegistered(application); @@ -732,7 +734,6 @@ void RegisterAppInterfaceRequest::Run() { } CheckLanguage(); - SendRegisterAppInterfaceResponseToMobile( ApplicationType::kNewApplication, status_notifier, add_info); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc index 82a5b536a8..53b1fdfc67 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc @@ -1368,6 +1368,7 @@ TEST_F(HMICommandsNotificationsTest, EXPECT_CALL(mock_hmi_capabilities_, set_active_vr_language(_)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); + EXPECT_CALL(*app_ptr_, IsRegistered()).WillOnce(Return(true)); EXPECT_CALL(*app_ptr_, app_id()).WillOnce(Return(kAppId_)); EXPECT_CALL(*app_ptr_, language()).WillRepeatedly(ReturnRef(kLang)); @@ -1412,6 +1413,7 @@ TEST_F(HMICommandsNotificationsTest, EXPECT_CALL(mock_hmi_capabilities_, set_active_vr_language(_)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); + EXPECT_CALL(*app_ptr_, IsRegistered()).WillOnce(Return(true)); EXPECT_CALL(*app_ptr_, app_id()).WillRepeatedly(Return(kAppId_)); EXPECT_CALL(*app_ptr_, language()).WillRepeatedly(ReturnRef(kLang)); EXPECT_CALL(app_mngr_, state_controller()) @@ -1697,6 +1699,7 @@ TEST_F(HMICommandsNotificationsTest, EXPECT_CALL(mock_hmi_capabilities_, set_active_tts_language(_)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); + EXPECT_CALL(*app_ptr_, IsRegistered()).WillOnce(Return(true)); EXPECT_CALL(*app_ptr_, app_id()).WillOnce(Return(kAppId_)); EXPECT_CALL(*app_ptr_, language()).WillRepeatedly(ReturnRef(kLang)); @@ -1742,6 +1745,7 @@ TEST_F(HMICommandsNotificationsTest, EXPECT_CALL(mock_hmi_capabilities_, set_active_tts_language(_)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); + EXPECT_CALL(*app_ptr_, IsRegistered()).WillOnce(Return(true)); EXPECT_CALL(*app_ptr_, app_id()).WillRepeatedly(Return(kAppId_)); EXPECT_CALL(*app_ptr_, language()).WillRepeatedly(ReturnRef(kLang)); EXPECT_CALL(mock_message_helper_, diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc index 443050b47f..44bd7f4a80 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc @@ -157,6 +157,8 @@ TEST_F(SDLActivateAppRequestTest, Run_ActivateApp_SUCCESS) { CurrentHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) .WillOnce(Return(state)); + EXPECT_CALL(*mock_app, IsRegistered()).WillOnce(Return(true)); + EXPECT_CALL(mock_policy_handler_, OnActivateApp(kAppID, kCorrelationID)); command->Run(); @@ -202,8 +204,14 @@ TEST_F(SDLActivateAppRequestTest, FindAppToRegister_SUCCESS) { IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) .WillOnce(Return(false)); - EXPECT_CALL(*mock_app, IsRegistered()).WillOnce(Return(false)); - EXPECT_CALL(*mock_app, is_cloud_app()).WillOnce(Return(false)); + am::HmiStatePtr state = std::make_shared(mock_app, app_mngr_); + state->set_hmi_level(mobile_apis::HMILevel::HMI_NONE); + EXPECT_CALL(*mock_app, + CurrentHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) + .WillOnce(Return(state)); + + ON_CALL(*mock_app, IsRegistered()).WillByDefault(Return(false)); + ON_CALL(*mock_app, is_cloud_app()).WillByDefault(Return(false)); ON_CALL(*mock_app, device()).WillByDefault(Return(kHandle)); MockAppPtr mock_app_first(CreateMockApp()); @@ -264,8 +272,14 @@ TEST_F(SDLActivateAppRequestTest, DevicesAppsEmpty_SUCCESS) { IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) .WillOnce(Return(false)); - EXPECT_CALL(*mock_app, IsRegistered()).WillOnce(Return(false)); - EXPECT_CALL(*mock_app, is_cloud_app()).WillOnce(Return(false)); + am::HmiStatePtr state = std::make_shared(mock_app, app_mngr_); + state->set_hmi_level(mobile_apis::HMILevel::HMI_NONE); + EXPECT_CALL(*mock_app, + CurrentHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) + .WillOnce(Return(state)); + + ON_CALL(*mock_app, IsRegistered()).WillByDefault(Return(false)); + ON_CALL(*mock_app, is_cloud_app()).WillByDefault(Return(false)); ON_CALL(*mock_app, device()).WillByDefault(Return(kHandle)); DataAccessor accessor(app_list_, lock_); @@ -291,6 +305,12 @@ TEST_F(SDLActivateAppRequestTest, FirstAppActive_SUCCESS) { .WillOnce(Return(false)); EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle)); + am::HmiStatePtr state = std::make_shared(mock_app, app_mngr_); + state->set_hmi_level(mobile_apis::HMILevel::HMI_NONE); + EXPECT_CALL(*mock_app, + CurrentHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) + .WillOnce(Return(state)); + DataAccessor accessor(app_list_, lock_); EXPECT_CALL(app_mngr_, applications()).WillRepeatedly(Return(accessor)); @@ -327,14 +347,15 @@ TEST_F(SDLActivateAppRequestTest, FirstAppNotActiveNONE_SUCCESS) { EXPECT_CALL(mock_state_controller_, IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) .WillOnce(Return(false)); - EXPECT_CALL(*mock_app, IsRegistered()).WillOnce(Return(true)); + am::HmiStatePtr state = std::make_shared(mock_app, app_mngr_); state->set_hmi_level(mobile_apis::HMILevel::HMI_NONE); - EXPECT_CALL(*mock_app, CurrentHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) .WillOnce(Return(state)); + EXPECT_CALL(*mock_app, IsRegistered()).WillOnce(Return(true)); + EXPECT_CALL(mock_policy_handler_, OnActivateApp(kAppID, kCorrelationID)); command->Run(); @@ -356,9 +377,16 @@ TEST_F(SDLActivateAppRequestTest, FirstAppIsForeground_SUCCESS) { ON_CALL(app_mngr_, application(kAppID)).WillByDefault(Return(mock_app)); + am::HmiStatePtr state = std::make_shared(mock_app, app_mngr_); + state->set_hmi_level(mobile_apis::HMILevel::HMI_NONE); + EXPECT_CALL(*mock_app, + CurrentHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) + .WillOnce(Return(state)); + EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle)); - EXPECT_CALL(*mock_app, IsRegistered()).WillOnce(Return(false)); - EXPECT_CALL(*mock_app, is_cloud_app()).WillOnce(Return(false)); + ON_CALL(*mock_app, IsRegistered()).WillByDefault(Return(false)); + ON_CALL(*mock_app, is_cloud_app()).WillByDefault(Return(false)); + EXPECT_CALL(app_mngr_, state_controller()) .WillOnce(ReturnRef(mock_state_controller_)); EXPECT_CALL(mock_state_controller_, @@ -397,6 +425,12 @@ TEST_F(SDLActivateAppRequestTest, FirstAppNotRegisteredAndEmpty_SUCCESS) { IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) .WillOnce(Return(false)); + am::HmiStatePtr state = std::make_shared(mock_app, app_mngr_); + state->set_hmi_level(mobile_apis::HMILevel::HMI_NONE); + EXPECT_CALL(*mock_app, + CurrentHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) + .WillOnce(Return(state)); + MockAppPtr mock_app_first(CreateMockApp()); ON_CALL(*mock_app_first, device()).WillByDefault(Return(kHandle)); ON_CALL(*mock_app_first, is_foreground()).WillByDefault(Return(false)); @@ -429,6 +463,13 @@ TEST_F(SDLActivateAppRequestTest, FirstAppNotRegistered_SUCCESS) { EXPECT_CALL(mock_state_controller_, IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) .WillOnce(Return(false)); + + am::HmiStatePtr state = std::make_shared(mock_app, app_mngr_); + state->set_hmi_level(mobile_apis::HMILevel::HMI_NONE); + EXPECT_CALL(*mock_app, + CurrentHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) + .WillOnce(Return(state)); + DataAccessor accessor(app_list_, lock_); EXPECT_CALL(app_mngr_, applications()).WillRepeatedly(Return(accessor)); @@ -460,8 +501,8 @@ TEST_F(SDLActivateAppRequestTest, WaitingCloudApplication_ConnectDevice) { MockAppPtr mock_app(CreateMockApp()); EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle)); - EXPECT_CALL(*mock_app, IsRegistered()).WillOnce(Return(false)); - EXPECT_CALL(*mock_app, is_cloud_app()).WillOnce(Return(true)); + ON_CALL(*mock_app, IsRegistered()).WillByDefault(Return(false)); + ON_CALL(*mock_app, is_cloud_app()).WillByDefault(Return(true)); #ifndef EXTERNAL_PROPRIETARY_MODE EXPECT_CALL(app_mngr_, application(kAppID)) diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index b0b05a3031..8d2875364d 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -4744,9 +4744,6 @@ void ApplicationManagerImpl::AddAppToRegisteredAppList( SDL_LOG_AUTO_TRACE(); DCHECK_OR_RETURN_VOID(application); sync_primitives::AutoLock lock(applications_list_lock_ptr_); - - // Add application to registered app list and set appropriate mark. - application->MarkRegistered(); applications_.insert(application); SDL_LOG_DEBUG("App with app_id: " << application->app_id() diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 606bc4c3f0..94d0a75c7f 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -1848,7 +1848,7 @@ bool MessageHelper::CreateHMIApplicationStruct( if (file_system::FileExists(app->app_icon_path())) { message[strings::icon] = icon_path; } - if (app->IsRegistered()) { + if (!app->is_cloud_app() || app->IsRegistered()) { message[strings::hmi_display_language_desired] = app->ui_language(); message[strings::is_media_application] = app->is_media_application(); } else { -- cgit v1.2.1 From e44e292b2f0a87349e6297259474abb35cb5e542 Mon Sep 17 00:00:00 2001 From: RomanReznichenkoLuxoft <85177915+RomanReznichenkoLuxoft@users.noreply.github.com> Date: Fri, 15 Oct 2021 20:21:12 +0300 Subject: =?UTF-8?q?Removed=20the=20unit=20that=20interrupted=20the=20seque?= =?UTF-8?q?nce=20of=20closing=20the=20connect=E2=80=A6=20(#3785)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Removed the unit that interrupted the sequence of closing the connection to the device via usb * Update logic for USB in transfer * fixup! Update logic for USB in transfer Co-authored-by: Andrii Kalinich --- .../src/usb/libusb/usb_connection.cc | 112 ++++++++++++--------- 1 file changed, 63 insertions(+), 49 deletions(-) diff --git a/src/components/transport_manager/src/usb/libusb/usb_connection.cc b/src/components/transport_manager/src/usb/libusb/usb_connection.cc index 44e037e2b5..865784e9a5 100644 --- a/src/components/transport_manager/src/usb/libusb/usb_connection.cc +++ b/src/components/transport_manager/src/usb/libusb/usb_connection.cc @@ -81,7 +81,6 @@ UsbConnection::UsbConnection(const DeviceUID& device_uid, UsbConnection::~UsbConnection() { SDL_LOG_TRACE("enter with this" << this); Finalise(); - libusb_free_transfer(in_transfer_); delete[] in_buffer_; SDL_LOG_TRACE("exit"); } @@ -97,6 +96,12 @@ void OutTransferCallback(libusb_transfer* transfer) { bool UsbConnection::PostInTransfer() { SDL_LOG_TRACE("enter"); + + if (nullptr == in_transfer_) { + SDL_LOG_TRACE("exit with FALSE. Condition: nullptr == in_transfer_"); + return false; + } + libusb_fill_bulk_transfer(in_transfer_, device_handle_, in_endpoint_, @@ -128,36 +133,41 @@ std::string hex_data(const unsigned char* const buffer, } void UsbConnection::OnInTransfer(libusb_transfer* transfer) { - SDL_LOG_AUTO_TRACE(); - if (transfer->status == LIBUSB_TRANSFER_CANCELLED) { - SDL_LOG_DEBUG("Free already canceled transfer."); - libusb_free_transfer(transfer); - return; - } - SDL_LOG_TRACE("enter with Libusb_transfer*: " << transfer); - if (transfer->status == LIBUSB_TRANSFER_COMPLETED) { - SDL_LOG_DEBUG("USB incoming transfer, size:" - << transfer->actual_length << ", data:" - << hex_data(transfer->buffer, transfer->actual_length)); - ::protocol_handler::RawMessagePtr data(new protocol_handler::RawMessage( - 0, 0, in_buffer_, transfer->actual_length, false)); - controller_->DataReceiveDone(device_uid_, app_handle_, data); - } else { - SDL_LOG_ERROR("USB incoming transfer failed: " - << libusb_error_name(transfer->status)); - controller_->DataReceiveFailed( - device_uid_, app_handle_, DataReceiveError()); + switch (transfer->status) { + case LIBUSB_TRANSFER_COMPLETED: { + SDL_LOG_DEBUG("USB incoming transfer, size:" + << transfer->actual_length << ", data:" + << hex_data(transfer->buffer, transfer->actual_length)); + ::protocol_handler::RawMessagePtr data(new protocol_handler::RawMessage( + 0, 0, in_buffer_, transfer->actual_length, false)); + controller_->DataReceiveDone(device_uid_, app_handle_, data); + break; + } + + case LIBUSB_TRANSFER_CANCELLED: { + SDL_LOG_DEBUG("Free already canceled transfer."); + break; + } + + default: { + SDL_LOG_ERROR("USB incoming transfer failed: " + << libusb_error_name(transfer->status)); + controller_->DataReceiveFailed( + device_uid_, app_handle_, DataReceiveError()); + } } - if (disconnecting_) { + + if (waiting_in_transfer_cancel_) { + libusb_free_transfer(in_transfer_); + in_transfer_ = nullptr; waiting_in_transfer_cancel_ = false; - } else { - if (!PostInTransfer()) { - SDL_LOG_ERROR("USB incoming transfer failed with " - << "LIBUSB_TRANSFER_NO_DEVICE. Abort connection."); - AbortConnection(); - } + } else if (!PostInTransfer()) { + SDL_LOG_ERROR("USB incoming transfer failed with " + << "LIBUSB_TRANSFER_NO_DEVICE. Abort connection."); + AbortConnection(); } + SDL_LOG_TRACE("exit"); } @@ -208,44 +218,48 @@ TransportAdapter::Error UsbConnection::PostOutTransfer() { void UsbConnection::OnOutTransfer(libusb_transfer* transfer) { SDL_LOG_AUTO_TRACE(); - if (transfer->status == LIBUSB_TRANSFER_CANCELLED) { - SDL_LOG_DEBUG("Free already canceled transfer."); - libusb_free_transfer(transfer); - return; - } - SDL_LOG_TRACE("enter with Libusb_transfer*: " << transfer); auto error_code = TransportAdapter::OK; { sync_primitives::AutoLock locker(out_messages_mutex_); - if (LIBUSB_TRANSFER_COMPLETED == transfer->status) { - bytes_sent_ += transfer->actual_length; - if (current_out_message_->data_size() == bytes_sent_) { - SDL_LOG_DEBUG( - "USB out transfer, data sent: " << current_out_message_.get()); - controller_->DataSendDone( - device_uid_, app_handle_, current_out_message_); + switch (transfer->status) { + case LIBUSB_TRANSFER_COMPLETED: { + bytes_sent_ += transfer->actual_length; + if (current_out_message_->data_size() == bytes_sent_) { + SDL_LOG_DEBUG( + "USB out transfer, data sent: " << current_out_message_.get()); + controller_->DataSendDone( + device_uid_, app_handle_, current_out_message_); + error_code = PopOutMessage(); + } + break; + } + + case LIBUSB_TRANSFER_CANCELLED: { + SDL_LOG_DEBUG("Free already canceled transfer."); + break; + } + + default: { + SDL_LOG_ERROR( + "USB out transfer failed: " << libusb_error_name(transfer->status)); + controller_->DataSendFailed( + device_uid_, app_handle_, current_out_message_, DataSendError()); error_code = PopOutMessage(); } - } else { - SDL_LOG_ERROR( - "USB out transfer failed: " << libusb_error_name(transfer->status)); - controller_->DataSendFailed( - device_uid_, app_handle_, current_out_message_, DataSendError()); - error_code = PopOutMessage(); } - if (current_out_message_.use_count() == 0) { + + if (waiting_out_transfer_cancel_ || current_out_message_.use_count() == 0) { libusb_free_transfer(transfer); out_transfer_ = nullptr; waiting_out_transfer_cancel_ = false; + return; } } if (TransportAdapter::FAIL == error_code) { AbortConnection(); } - - SDL_LOG_TRACE("exit"); } TransportAdapter::Error UsbConnection::SendData( -- cgit v1.2.1 From a0f004003ec76a92fac941cea37e8014822938c8 Mon Sep 17 00:00:00 2001 From: "Andrii Kalinich (GitHub)" Date: Thu, 21 Oct 2021 10:30:53 -0400 Subject: Fix issues with web app activation (#3799) * Add initial states for pending applications This would prevent crashes for cases when app will be attempted to be activated. * Fix UpdateAppList content * Fix checks in SDL.ActivateApp * Fix unit tests --- .../src/commands/hmi/sdl_activate_app_request.cc | 13 +++++-- .../commands/hmi/sdl_activate_app_request_test.cc | 41 ++-------------------- .../src/application_manager_impl.cc | 26 ++++++++++++++ .../src/message_helper/message_helper.cc | 2 +- 4 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc index 88b3065fb0..e25ee93400 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc @@ -139,7 +139,7 @@ void SDLActivateAppRequest::Run() { return; } - if (!app->is_cloud_app() || app->IsRegistered()) { + if (app->app_id() > 0 || app->IsRegistered()) { auto main_state = app->CurrentHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); if (mobile_apis::HMILevel::INVALID_ENUM == main_state->hmi_level()) { @@ -173,6 +173,15 @@ void SDLActivateAppRequest::Run() { application_manager_.connection_handler().ConnectToDevice(app->device()); return; } + + connection_handler::DeviceHandle device_handle = app->device(); + SDL_LOG_ERROR( + "Can't find regular foreground app with the same connection id: " + << device_handle); + SendErrorResponse(correlation_id(), + SDL_ActivateApp, + hmi_apis::Common_Result::NO_APPS_REGISTERED, + ""); } #else // EXTERNAL_PROPRIETARY_MODE @@ -216,7 +225,7 @@ void SDLActivateAppRequest::Run() { return; } - if (!app_to_activate->is_cloud_app() || app_to_activate->IsRegistered()) { + if (app_to_activate->app_id() > 0 || app_to_activate->IsRegistered()) { auto main_state = app_to_activate->CurrentHmiState( mobile_apis::PredefinedWindows::DEFAULT_WINDOW); if (mobile_apis::HMILevel::INVALID_ENUM == main_state->hmi_level()) { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc index 44bd7f4a80..b110d4bf9e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc @@ -157,6 +157,7 @@ TEST_F(SDLActivateAppRequestTest, Run_ActivateApp_SUCCESS) { CurrentHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) .WillOnce(Return(state)); + EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppID)); EXPECT_CALL(*mock_app, IsRegistered()).WillOnce(Return(true)); EXPECT_CALL(mock_policy_handler_, OnActivateApp(kAppID, kCorrelationID)); @@ -204,12 +205,6 @@ TEST_F(SDLActivateAppRequestTest, FindAppToRegister_SUCCESS) { IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) .WillOnce(Return(false)); - am::HmiStatePtr state = std::make_shared(mock_app, app_mngr_); - state->set_hmi_level(mobile_apis::HMILevel::HMI_NONE); - EXPECT_CALL(*mock_app, - CurrentHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) - .WillOnce(Return(state)); - ON_CALL(*mock_app, IsRegistered()).WillByDefault(Return(false)); ON_CALL(*mock_app, is_cloud_app()).WillByDefault(Return(false)); ON_CALL(*mock_app, device()).WillByDefault(Return(kHandle)); @@ -272,12 +267,6 @@ TEST_F(SDLActivateAppRequestTest, DevicesAppsEmpty_SUCCESS) { IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) .WillOnce(Return(false)); - am::HmiStatePtr state = std::make_shared(mock_app, app_mngr_); - state->set_hmi_level(mobile_apis::HMILevel::HMI_NONE); - EXPECT_CALL(*mock_app, - CurrentHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) - .WillOnce(Return(state)); - ON_CALL(*mock_app, IsRegistered()).WillByDefault(Return(false)); ON_CALL(*mock_app, is_cloud_app()).WillByDefault(Return(false)); ON_CALL(*mock_app, device()).WillByDefault(Return(kHandle)); @@ -305,12 +294,6 @@ TEST_F(SDLActivateAppRequestTest, FirstAppActive_SUCCESS) { .WillOnce(Return(false)); EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle)); - am::HmiStatePtr state = std::make_shared(mock_app, app_mngr_); - state->set_hmi_level(mobile_apis::HMILevel::HMI_NONE); - EXPECT_CALL(*mock_app, - CurrentHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) - .WillOnce(Return(state)); - DataAccessor accessor(app_list_, lock_); EXPECT_CALL(app_mngr_, applications()).WillRepeatedly(Return(accessor)); @@ -348,14 +331,14 @@ TEST_F(SDLActivateAppRequestTest, FirstAppNotActiveNONE_SUCCESS) { IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) .WillOnce(Return(false)); + ON_CALL(*mock_app, IsRegistered()).WillByDefault(Return(true)); + am::HmiStatePtr state = std::make_shared(mock_app, app_mngr_); state->set_hmi_level(mobile_apis::HMILevel::HMI_NONE); EXPECT_CALL(*mock_app, CurrentHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) .WillOnce(Return(state)); - EXPECT_CALL(*mock_app, IsRegistered()).WillOnce(Return(true)); - EXPECT_CALL(mock_policy_handler_, OnActivateApp(kAppID, kCorrelationID)); command->Run(); @@ -377,12 +360,6 @@ TEST_F(SDLActivateAppRequestTest, FirstAppIsForeground_SUCCESS) { ON_CALL(app_mngr_, application(kAppID)).WillByDefault(Return(mock_app)); - am::HmiStatePtr state = std::make_shared(mock_app, app_mngr_); - state->set_hmi_level(mobile_apis::HMILevel::HMI_NONE); - EXPECT_CALL(*mock_app, - CurrentHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) - .WillOnce(Return(state)); - EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle)); ON_CALL(*mock_app, IsRegistered()).WillByDefault(Return(false)); ON_CALL(*mock_app, is_cloud_app()).WillByDefault(Return(false)); @@ -425,12 +402,6 @@ TEST_F(SDLActivateAppRequestTest, FirstAppNotRegisteredAndEmpty_SUCCESS) { IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) .WillOnce(Return(false)); - am::HmiStatePtr state = std::make_shared(mock_app, app_mngr_); - state->set_hmi_level(mobile_apis::HMILevel::HMI_NONE); - EXPECT_CALL(*mock_app, - CurrentHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) - .WillOnce(Return(state)); - MockAppPtr mock_app_first(CreateMockApp()); ON_CALL(*mock_app_first, device()).WillByDefault(Return(kHandle)); ON_CALL(*mock_app_first, is_foreground()).WillByDefault(Return(false)); @@ -464,12 +435,6 @@ TEST_F(SDLActivateAppRequestTest, FirstAppNotRegistered_SUCCESS) { IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) .WillOnce(Return(false)); - am::HmiStatePtr state = std::make_shared(mock_app, app_mngr_); - state->set_hmi_level(mobile_apis::HMILevel::HMI_NONE); - EXPECT_CALL(*mock_app, - CurrentHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) - .WillOnce(Return(state)); - DataAccessor accessor(app_list_, lock_); EXPECT_CALL(app_mngr_, applications()).WillRepeatedly(Return(accessor)); diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 8d2875364d..7a5d5fc0dc 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1200,6 +1200,19 @@ void ApplicationManagerImpl::CreatePendingApplication( application->set_hybrid_app_preference(hybrid_app_preference_enum); application->set_cloud_app_certificate(app_properties.certificate); + HmiStatePtr initial_state = + CreateRegularState(application, + mobile_apis::WindowType::MAIN, + mobile_apis::HMILevel::INVALID_ENUM, + mobile_apis::AudioStreamingState::INVALID_ENUM, + mobile_apis::VideoStreamingState::INVALID_ENUM, + mobile_api::SystemContext::SYSCTXT_MAIN); + + application->SetInitialState( + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + std::string(), // should not be tracked for main window + initial_state); + { sync_primitives::AutoLock lock(apps_to_register_list_lock_ptr_); SDL_LOG_DEBUG( @@ -1284,6 +1297,19 @@ void ApplicationManagerImpl::CreatePendingLocalApplication( application->set_hybrid_app_preference(hybrid_app_preference_enum); application->set_cloud_app_certificate(app_properties.certificate); + HmiStatePtr initial_state = + CreateRegularState(application, + mobile_apis::WindowType::MAIN, + mobile_apis::HMILevel::INVALID_ENUM, + mobile_apis::AudioStreamingState::INVALID_ENUM, + mobile_apis::VideoStreamingState::INVALID_ENUM, + mobile_api::SystemContext::SYSCTXT_MAIN); + + application->SetInitialState( + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + std::string(), // should not be tracked for main window + initial_state); + sync_primitives::AutoLock lock(apps_to_register_list_lock_ptr_); apps_to_register_.insert(application); SDL_LOG_DEBUG("Insert " << application->name().c_str() diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 94d0a75c7f..bbe6189bc9 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -1848,7 +1848,7 @@ bool MessageHelper::CreateHMIApplicationStruct( if (file_system::FileExists(app->app_icon_path())) { message[strings::icon] = icon_path; } - if (!app->is_cloud_app() || app->IsRegistered()) { + if (app->app_id() > 0 || app->IsRegistered()) { message[strings::hmi_display_language_desired] = app->ui_language(); message[strings::is_media_application] = app->is_media_application(); } else { -- cgit v1.2.1