diff options
author | Andrii Kalinich (GitHub) <AKalinich@luxoft.com> | 2021-08-11 09:12:02 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-11 09:12:02 -0400 |
commit | 50457915a4081e8c135d6a400eb30330f0d37c9d (patch) | |
tree | 46c2db9e4423954a226ff6b60722020eac4a4572 | |
parent | f51f4fd4c7475b30cbf2c2dbc4507ac13583b7bf (diff) | |
download | sdl_core-50457915a4081e8c135d6a400eb30330f0d37c9d.tar.gz |
Remove dependency between optional params in OnRemoteControlSettings (#3749)
* Removed dependence on allowed when updating accessMode
* Update src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc
Co-authored-by: Shobhit Adlakha <ShobhitAd@users.noreply.github.com>
Co-authored-by: Roman Reznichenko <roman.reznichenko@dxc.com>
Co-authored-by: Shobhit Adlakha <ShobhitAd@users.noreply.github.com>
2 files changed, 21 insertions, 21 deletions
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 217258b086..860e18a105 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 @@ -87,35 +87,34 @@ void RCOnRemoteControlSettingsNotification::DisallowRCFunctionality() { void RCOnRemoteControlSettingsNotification::Run() { SDL_LOG_AUTO_TRACE(); - if (!(*message_)[app_mngr::strings::msg_params].keyExists( - message_params::kAllowed)) { - SDL_LOG_DEBUG("Notification is ignored due to \"allow\" parameter absense"); + if ((*message_)[app_mngr::strings::msg_params].empty()) { + SDL_LOG_DEBUG("Notification is ignored due to absence of any parameters"); SDL_LOG_DEBUG("RC Functionality remains unchanged"); return; } + hmi_apis::Common_RCAccessMode::eType access_mode = + hmi_apis::Common_RCAccessMode::INVALID_ENUM; + if ((*message_)[app_mngr::strings::msg_params].keyExists( + message_params::kAccessMode)) { + access_mode = static_cast<hmi_apis::Common_RCAccessMode::eType>( + (*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)); + } + resource_allocation_manager_.SetAccessMode(access_mode); + const bool is_allowed = (*message_)[app_mngr::strings::msg_params][message_params::kAllowed] .asBool(); if (is_allowed) { - hmi_apis::Common_RCAccessMode::eType access_mode = - hmi_apis::Common_RCAccessMode::INVALID_ENUM; SDL_LOG_DEBUG("Allowing RC Functionality"); resource_allocation_manager_.set_rc_enabled(true); - if ((*message_)[app_mngr::strings::msg_params].keyExists( - message_params::kAccessMode)) { - access_mode = static_cast<hmi_apis::Common_RCAccessMode::eType>( - (*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)); - } - resource_allocation_manager_.SetAccessMode(access_mode); } else { SDL_LOG_DEBUG("Disallowing RC Functionality"); DisallowRCFunctionality(); 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 62b726ac60..7907013fa3 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 @@ -145,9 +145,10 @@ TEST_F(RCOnRemoteControlSettingsNotificationTest, MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[application_manager::strings::msg_params] [message_params::kAllowed] = false; - - EXPECT_CALL(mock_allocation_manager_, ResetAllAllocations()); + ON_CALL(mock_allocation_manager_, GetAccessMode()) + .WillByDefault(Return(hmi_apis::Common_RCAccessMode::ASK_DRIVER)); EXPECT_CALL(mock_interior_data_manager_, OnDisablingRC()); + EXPECT_CALL(mock_allocation_manager_, ResetAllAllocations()); EXPECT_CALL(mock_rc_consent_manger_, RemoveAllConsents()); // Act |