summaryrefslogtreecommitdiff
path: root/src/components/application_manager/rpc_plugins
diff options
context:
space:
mode:
authorAndriy Byzhynar <AByzhynar@luxoft.com>2018-03-07 11:21:28 +0200
committerIra Lytvynenko (GitHub) <ILytvynenko@luxoft.com>2018-06-26 12:01:46 +0300
commit0cacf13d7df8aa08fa312612f6f3d81e970eb6bf (patch)
tree65c238bbd804e7f7e8617f1dcbef74ea638cbd1e /src/components/application_manager/rpc_plugins
parent57aa1c99210a39546106d02a26be82eeb2a7800f (diff)
downloadsdl_core-0cacf13d7df8aa08fa312612f6f3d81e970eb6bf.tar.gz
Fix SDL behavior when resource is unsupported
- Fixed response handling when required resource is unsupported - Fixed get_system_capabilities request - FIxed typo in Mobile & HMI APIs (there was duplicated value for different entities) Fix OnRCStatus notification Fix comments after review Conflicts: src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc src/components/interfaces/HMI_API.xml src/components/interfaces/MOBILE_API.xml
Diffstat (limited to 'src/components/application_manager/rpc_plugins')
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h27
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc6
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc36
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_response.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_response.cc1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc10
6 files changed, 45 insertions, 36 deletions
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h
index 23cf5aa2d0..a0180ddc9a 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h
@@ -13,12 +13,15 @@ typedef std::vector<application_manager::ApplicationSharedPtr> Apps;
class ResourceAllocationManagerImpl : public ResourceAllocationManager {
public:
ResourceAllocationManagerImpl(
- application_manager::ApplicationManager& app_mngr);
+ application_manager::ApplicationManager& app_mngr,
+ application_manager::rpc_service::RPCService& rpc_service);
~ResourceAllocationManagerImpl();
AcquireResult::eType AcquireResource(const std::string& module_type,
const uint32_t app_id) OVERRIDE FINAL;
+ void ForceAcquireResource(const std::string& module_type,
+ const uint32_t app_id) FINAL;
void SetResourceState(const std::string& module_type,
const uint32_t app_id,
@@ -31,9 +34,6 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager {
hmi_apis::Common_RCAccessMode::eType GetAccessMode() const FINAL;
- void ForceAcquireResource(const std::string& module_type,
- const uint32_t app_id) FINAL;
-
void OnDriverDisallowed(const std::string& module_type,
const uint32_t app_id) FINAL;
@@ -107,6 +107,23 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager {
void RemoveAppsSubscriptions(const Apps& apps);
/**
+ * @brief SetResourceAquired mark resourse as aquired and process logic of
+ * changing state of aquired resources
+ * @param module_type resource name
+ * @param app applicastion that aquire resource
+ */
+ void SetResourceAquired(const std::string& module_type,
+ const uint32_t app_id);
+ /**
+ * @brief SetResourceFree mark resourse as free and process logic of
+ * changing state of aquired resources
+ * @param module_type resource name
+ * @param app applicastion that aquire resource
+ */
+ void SetResourceFree(const std::string& module_type, const uint32_t app_id);
+
+ std::vector<std::string> all_supported_modules();
+ /**
* @brief AllocatedResources contains link between resource and application
* owning that resource
*/
@@ -132,7 +149,7 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager {
hmi_apis::Common_RCAccessMode::eType current_access_mode_;
application_manager::ApplicationManager& app_mngr_;
-
+ application_manager::rpc_service::RPCService& rpc_service_;
};
} // rc_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc
index fb9ade462b..e17ad50233 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc
@@ -193,11 +193,11 @@ bool RCCommandRequest::AcquireResources() {
void RCCommandRequest::on_event(const app_mngr::event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
- const std::string module_type = ModuleType();
- SetResourceState(module_type, ResourceState::FREE);
-
if (event.id() == hmi_apis::FunctionID::RC_GetInteriorVehicleDataConsent) {
ProcessAccessResponse(event);
+ } else {
+ const std::string module_type = ModuleType();
+ SetResourceState(module_type, ResourceState::FREE);
}
}
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 c5f5dd2aac..c0c2ce5412 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
@@ -3,8 +3,8 @@
#include "application_manager/application_manager.h"
#include "interfaces/HMI_API.h"
#include "interfaces/MOBILE_API.h"
+#include "smart_objects/enum_schema_item.h"
#include "rc_rpc_plugin/rc_rpc_plugin.h"
-
#include "application_manager/message_helper.h"
#include "rc_rpc_plugin/rc_module_constants.h"
#include "json/json.h"
@@ -19,9 +19,11 @@ namespace rc_rpc_plugin {
CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule")
ResourceAllocationManagerImpl::ResourceAllocationManagerImpl(
- application_manager::ApplicationManager& app_mngr)
+ application_manager::ApplicationManager& app_mngr,
+ application_manager::rpc_service::RPCService& rpc_service)
: current_access_mode_(hmi_apis::Common_RCAccessMode::AUTO_ALLOW)
- , app_mngr_(app_mngr) {}
+ , app_mngr_(app_mngr)
+ , rpc_service_(rpc_service) {}
ResourceAllocationManagerImpl::~ResourceAllocationManagerImpl() {}
@@ -39,7 +41,7 @@ AcquireResult::eType ResourceAllocationManagerImpl::AcquireResource(
const AllocatedResources::const_iterator allocated_it =
allocated_resources_.find(module_type);
if (allocated_resources_.end() == allocated_it) {
- allocated_resources_[module_type] = app_id;
+ SetResourceAquired(module_type, app_id);
LOG4CXX_DEBUG(logger_,
"Resource is not acquired yet. "
<< "App: " << app_id << " is allowed to acquire "
@@ -93,7 +95,7 @@ AcquireResult::eType ResourceAllocationManagerImpl::AcquireResource(
<< "App: " << app_id << " is allowed to acquire "
<< module_type);
- allocated_resources_[module_type] = app_id;
+ SetResourceAquired(module_type, app_id);
return AcquireResult::ALLOWED;
}
default: { DCHECK_OR_RETURN(false, AcquireResult::IN_USE); }
@@ -104,24 +106,7 @@ void ResourceAllocationManagerImpl::ReleaseResource(
const std::string& module_type, const uint32_t application_id) {
LOG4CXX_AUTO_TRACE(logger_);
LOG4CXX_DEBUG(logger_, "Release " << module_type << " by " << application_id);
- AllocatedResources::const_iterator allocation =
- allocated_resources_.find(module_type);
- if (allocated_resources_.end() == allocation) {
- LOG4CXX_DEBUG(logger_, "Resource " << module_type << " is not allocated.");
- return;
- }
-
- if (application_id != allocation->second) {
- LOG4CXX_DEBUG(logger_,
- "Resource " << module_type
- << " is allocated by different application "
- << allocation->second);
- return;
- }
-
- allocated_resources_.erase(allocation);
- LOG4CXX_DEBUG(logger_, "Resource " << module_type << " is released.");
- return;
+ SetResourceFree(module_type, application_id);
}
void ResourceAllocationManagerImpl::ProcessApplicationPolicyUpdate() {
@@ -130,7 +115,8 @@ void ResourceAllocationManagerImpl::ProcessApplicationPolicyUpdate() {
Apps::const_iterator app = app_list.begin();
for (; app_list.end() != app; ++app) {
- application_manager::ApplicationSharedPtr app_ptr = *app; const uint32_t application_id = app_ptr->app_id();
+ application_manager::ApplicationSharedPtr app_ptr = *app;
+ const uint32_t application_id = app_ptr->app_id();
Resources acquired_modules = GetAcquiredResources(application_id);
std::sort(acquired_modules.begin(), acquired_modules.end());
@@ -284,7 +270,7 @@ void ResourceAllocationManagerImpl::ForceAcquireResource(
const std::string& module_type, const uint32_t app_id) {
LOG4CXX_DEBUG(logger_, "Force " << app_id << " acquiring " << module_type);
sync_primitives::AutoLock lock(allocated_resources_lock_);
- allocated_resources_[module_type] = app_id;
+ SetResourceAquired(module_type, app_id);
}
bool ResourceAllocationManagerImpl::IsModuleTypeRejected(
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_response.cc
index 62bbfe4861..57e8969f9d 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_response.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_response.cc
@@ -58,5 +58,4 @@ void NaviIsReadyResponse::Run() {
}
} // namespace commands
-
} // namespace application_manager
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_response.cc
index 30e73b5815..ac54096dbc 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_response.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_response.cc
@@ -58,5 +58,4 @@ void RCIsReadyResponse::Run() {
}
} // namespace commands
-
} // namespace application_manager
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc
index b9de2af335..a6c627aad2 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc
@@ -67,6 +67,7 @@ void GetSystemCapabilityRequest::Run() {
SendResponse(false, mobile_apis::Result::INVALID_DATA);
return;
}
+
smart_objects::SmartObject response_params(smart_objects::SmartType_Map);
mobile_apis::SystemCapabilityType::eType response_type =
static_cast<mobile_apis::SystemCapabilityType::eType>(
@@ -100,6 +101,14 @@ void GetSystemCapabilityRequest::Run() {
break;
}
case mobile_apis::SystemCapabilityType::REMOTE_CONTROL: {
+ if (!app->is_remote_control_supported()) {
+ SendResponse(false, mobile_apis::Result::DISALLOWED);
+ return;
+ }
+ if (!hmi_capabilities.is_rc_cooperating()) {
+ SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE);
+ return;
+ }
if (hmi_capabilities.rc_capability()) {
response_params[strings::system_capability][strings::rc_capability] =
*hmi_capabilities.rc_capability();
@@ -131,5 +140,4 @@ void GetSystemCapabilityRequest::on_event(const event_engine::Event& event) {
}
} // namespace commands
-
} // namespace application_manager