diff options
author | LitvinenkoIra <ilytvynenko@luxoft.com> | 2019-08-30 20:17:46 +0300 |
---|---|---|
committer | LitvinenkoIra <ilytvynenko@luxoft.com> | 2019-08-30 20:17:46 +0300 |
commit | 0943168a5dc887fde126d39e56a7772f51049f9b (patch) | |
tree | 1983b171e3bb9cd749267e6f3884b70525e53a37 | |
parent | 2935a6b8225bd6998fe4f08de99d2ac162e9a855 (diff) | |
download | sdl_core-feature/multiple_modules.tar.gz |
Update logic for allowMultipleAccess=falsefeature/multiple_modules
3 files changed, 44 insertions, 0 deletions
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_request.h index 8314ede63a..4ac1ee59cd 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_request.h @@ -92,6 +92,10 @@ class GetInteriorVehicleDataConsentRequest */ bool GetCalculatedVehicleDataConsent( smart_objects::SmartObject& out_response) const; + + bool MultipleAccessAllowed( + const smart_objects::SmartArray& module_ids, + smart_objects::SmartArray& out_consents_array) const; }; } // namespace commands diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_consent_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_consent_request.cc index 33aa627c72..c45b1a8c99 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_consent_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_consent_request.cc @@ -185,6 +185,10 @@ bool GetInteriorVehicleDataConsentRequest::GetCalculatedVehicleDataConsent( (*message_)[app_mngr::strings::msg_params][message_params::kModuleIds] .asArray(); + if (!MultipleAccessAllowed((*module_ids), (*modules_consent_array))) { + return true; + } + auto fill_auto_allow_consents = [&module_ids](smart_objects::SmartArray& out_consents_array) { for (uint32_t i = 0; i < module_ids->size(); ++i) { @@ -277,6 +281,40 @@ bool GetInteriorVehicleDataConsentRequest::GetCalculatedVehicleDataConsent( return false; } +bool GetInteriorVehicleDataConsentRequest::MultipleAccessAllowed( + const smart_objects::SmartArray& module_ids, + smart_objects::SmartArray& out_consents_array) const { + LOG4CXX_AUTO_TRACE(logger_); + for (auto& module_id : module_ids) { + const std::string module_type = ModuleType(); + auto app = application_manager_.application(connection_key()); + const uint32_t app_id = app->app_id(); + const ModuleUid module_uid(module_type, module_id.asString()); + const bool is_multiple_access_allowed = + rc_capabilities_manager_.IsMultipleAccessAllowed(module_uid); + if (!is_multiple_access_allowed) { + const bool is_resource_free = + (resource_allocation_manager_.AcquireResource( + module_uid.first, module_uid.second, app_id) == + AcquireResult::ALLOWED); + + out_consents_array.push_back( + smart_objects::SmartObject(is_resource_free)); + } else { + out_consents_array.clear(); + break; + } + } + + if (!out_consents_array.empty()) { + LOG4CXX_DEBUG(logger_, + "Multiple access disallowed, returning true only for " + "FREE resources"); + return false; + } + return true; +} + bool GetInteriorVehicleDataConsentRequest::SaveModuleIdConsents( std::string& info_out, const smart_objects::SmartObject& msg_params) { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_consent_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_consent_request_test.cc index bde4f190b9..29708d05bd 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_consent_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_consent_request_test.cc @@ -97,6 +97,8 @@ class GetInteriorVehicleDataConsentRequestTest message_ = CreateBasicMessage(); ON_CALL(mock_rc_capabilities_manager_, CheckIfModuleExistsInCapabilities(_)) .WillByDefault(Return(true)); + ON_CALL(mock_rc_capabilities_manager_, IsMultipleAccessAllowed(_)) + .WillByDefault(Return(true)); } void PrepareNoConsentExistInCache() { |