summaryrefslogtreecommitdiff
path: root/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc')
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc
index fe9bb5eec3..0c513cb01e 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc
@@ -140,7 +140,9 @@ AcquireResult::eType ResourceAllocationManagerImpl::AcquireResource(
<< module_type << " " << module_id);
return AcquireResult::ALLOWED;
}
- default: { DCHECK_OR_RETURN(false, AcquireResult::IN_USE); }
+ default: {
+ DCHECK_OR_RETURN(false, AcquireResult::IN_USE);
+ }
}
}
@@ -486,6 +488,28 @@ bool ResourceAllocationManagerImpl::IsResourceFree(
return ResourceState::FREE == resource->second;
}
+bool ResourceAllocationManagerImpl::IsResourceAllocated(
+ const std::string& module_type,
+ const std::string& module_id,
+ const uint32_t app_id) {
+ ModuleUid module(module_type, module_id);
+ sync_primitives::AutoLock lock(allocated_resources_lock_);
+ const auto allocation = allocated_resources_.find(module);
+ if (allocated_resources_.end() == allocation) {
+ SDL_LOG_DEBUG("Resource " << module_type << " is not allocated.");
+ return false;
+ }
+
+ if (app_id != allocation->second) {
+ SDL_LOG_DEBUG("Resource " << module_type
+ << " is allocated by different application "
+ << allocation->second);
+ return true;
+ }
+
+ return false;
+}
+
void ResourceAllocationManagerImpl::SetAccessMode(
const hmi_apis::Common_RCAccessMode::eType access_mode) {
if (hmi_apis::Common_RCAccessMode::ASK_DRIVER != access_mode) {