summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h5
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h2
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h2
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h2
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h11
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_request.h3
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc10
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc10
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc39
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc71
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc22
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc42
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc47
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc29
-rw-r--r--src/components/application_manager/src/hmi_interfaces_impl.cc7
15 files changed, 204 insertions, 98 deletions
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h
index 07c6bf40a0..963078c2e3 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h
@@ -22,9 +22,10 @@ class RCOnInteriorVehicleDataNotification
~RCOnInteriorVehicleDataNotification();
- bool Init() OVERRIDE;
+ /**
+ * @brief Execute command
+ **/
void Run() OVERRIDE;
- void on_event(const application_manager::event_engine::Event& event);
};
} // namespace commands
} // namespace rc_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h
index 354092803e..a733c199f7 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h
@@ -53,6 +53,8 @@ class ButtonPressRequest : public RCCommandRequest {
*/
void on_event(const app_mngr::event_engine::Event& event) FINAL;
+ std::string ModuleType() FINAL;
+
/**
* @brief ButtonPressRequest class destructor
*/
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h
index 62388bc0a4..d88c9c7ad8 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h
@@ -55,6 +55,8 @@ class GetInteriorVehicleDataRequest : public RCCommandRequest {
* @param request_params request parameters to handle
*/
void RemoveExcessiveSubscription();
+
+ std::string ModuleType() FINAL;
};
} // namespace commands
} // namespace rc_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h
index 3a119266e5..b0ca8cba39 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h
@@ -22,6 +22,8 @@ class OnInteriorVehicleDataNotification
void Run() OVERRIDE;
+ std::string ModuleType();
+
~OnInteriorVehicleDataNotification();
};
} // namespace commands
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h
index cc408e1e5e..57d34e2dab 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h
@@ -71,10 +71,21 @@ class SetInteriorVehicleDataRequest : public RCCommandRequest {
*/
void CutOffReadOnlyParams(smart_objects::SmartObject& module_data);
+ std::string ModuleType() FINAL;
+
/**
* @brief SetInteriorVehicleDataRequest class destructor
*/
~SetInteriorVehicleDataRequest();
+
+ private:
+ /**
+ * @brief ControlData
+ * @param module_data received params
+ * @return value of module data depending on module type
+ */
+ const smart_objects::SmartObject& ControlData(
+ const smart_objects::SmartObject& module_data);
};
} // namespace commands
} // namespace rc_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_request.h
index d469215556..671ef9f48d 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_request.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_request.h
@@ -67,6 +67,7 @@ class RCCommandRequest : public app_mngr::commands::CommandRequestImpl {
virtual void on_event(const app_mngr::event_engine::Event& event) OVERRIDE;
protected:
+ bool is_subscribed;
ResourceAllocationManager& resource_allocation_manager_;
bool auto_allowed_;
@@ -130,6 +131,8 @@ class RCCommandRequest : public app_mngr::commands::CommandRequestImpl {
disallowed_info_ = info;
}
+ virtual std::string ModuleType() = 0;
+
private:
/**
* @brief CheckDriverConsent checks driver consent defined in policy table
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc
index a7318a1ac1..c2e5d74851 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc
@@ -21,12 +21,12 @@ RCOnInteriorVehicleDataNotification::RCOnInteriorVehicleDataNotification(
RCOnInteriorVehicleDataNotification::~RCOnInteriorVehicleDataNotification() {}
-bool RCOnInteriorVehicleDataNotification::Init() {
- return true;
+void RCOnInteriorVehicleDataNotification::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ (*message_)[app_mngr::strings::params][app_mngr::strings::function_id] =
+ static_cast<int>(mobile_apis::FunctionID::eType::OnInteriorVehicleDataID);
+ SendNotificationToMobile(message_);
}
-void RCOnInteriorVehicleDataNotification::Run() {}
-void RCOnInteriorVehicleDataNotification::on_event(
- const application_manager::event_engine::Event& event) {}
} // namespace commands
} // namespace rc_rpc_plugin
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 9626f8b364..d67f8973e4 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
@@ -98,12 +98,12 @@ void RCOnRemoteControlSettingsNotification::Run() {
LOG4CXX_DEBUG(logger_, "Allowing RC Functionality");
if ((*message_)[app_mngr::strings::msg_params].keyExists(
message_params::kAccessMode)) {
- const std::string access_mode_str =
+ access_mode = static_cast<hmi_apis::Common_RCAccessMode::eType>(
(*message_)[app_mngr::strings::msg_params]
- [message_params::kAccessMode].asString();
-
- access_mode = AccessModeFromString(access_mode_str);
- LOG4CXX_DEBUG(logger_, "Setting up access mode : " << access_mode_str);
+ [message_params::kAccessMode].asUInt());
+ LOG4CXX_DEBUG(
+ logger_,
+ "Setting up access mode : " << AccessModeToString(access_mode));
} else {
access_mode = resource_allocation_manager_.GetAccessMode();
LOG4CXX_DEBUG(logger_,
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc
index f70215fefc..4cfe955bbf 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc
@@ -1,5 +1,6 @@
#include "rc_rpc_plugin/commands/mobile/button_press_request.h"
#include "rc_rpc_plugin/rc_module_constants.h"
+#include "smart_objects/enum_schema_item.h"
#include "utils/macro.h"
#include "json/json.h"
#include "utils/helpers.h"
@@ -148,13 +149,15 @@ bool CheckButtonName(const std::string& module_type,
void ButtonPressRequest::Execute() {
LOG4CXX_AUTO_TRACE(logger_);
- const std::string button_name =
- (*message_)[app_mngr::strings::msg_params][message_params::kButtonName]
- .asString();
- const std::string module_type =
- (*message_)[app_mngr::strings::msg_params][message_params::kModuleType]
- .asString();
+ const char* button_name;
+ NsSmartDeviceLink::NsSmartObjects::
+ EnumConversionHelper<mobile_apis::ButtonName::eType>::EnumToCString(
+ static_cast<mobile_apis::ButtonName::eType>(
+ (*message_)[app_mngr::strings::msg_params]
+ [message_params::kButtonName].asUInt()),
+ &button_name);
+ const std::string module_type = ModuleType();
static ButtonsMap btn_map = buttons_map();
mobile_apis::ButtonName::eType button_id =
mobile_apis::ButtonName::INVALID_ENUM;
@@ -170,17 +173,25 @@ void ButtonPressRequest::Execute() {
rc_capabilities &&
CheckIfButtonExistInRCCaps(*rc_capabilities, button_id);
+ app_mngr::ApplicationSharedPtr app =
+ application_manager_.application(connection_key());
+
+ (*message_)[app_mngr::strings::msg_params][app_mngr::strings::app_id] =
+ app->app_id();
+
if (button_name_matches_module_type && button_id_exist_in_caps) {
SendHMIRequest(hmi_apis::FunctionID::Buttons_ButtonPress,
&(*message_)[app_mngr::strings::msg_params],
true);
} else if (!button_name_matches_module_type) {
LOG4CXX_WARN(logger_, "Request module type and button name mismatch!");
+ SetResourceState(module_type, ResourceState::FREE);
SendResponse(false,
mobile_apis::Result::INVALID_DATA,
"Request module type and button name mismatch!");
} else {
LOG4CXX_WARN(logger_, "Requested button is not exists in capabilities!");
+ SetResourceState(module_type, ResourceState::FREE);
SendResponse(false,
mobile_apis::Result::UNSUPPORTED_RESOURCE,
"Requested button is not exists in capabilities!");
@@ -190,9 +201,7 @@ void ButtonPressRequest::Execute() {
AcquireResult::eType ButtonPressRequest::AcquireResource(
const app_mngr::commands::MessageSharedPtr& message) {
LOG4CXX_AUTO_TRACE(logger_);
- const std::string module_type =
- (*message_)[app_mngr::strings::msg_params][message_params::kModuleType]
- .asString();
+ const std::string module_type = ModuleType();
app_mngr::ApplicationSharedPtr app =
application_manager_.application(CommandRequestImpl::connection_key());
return resource_allocation_manager_.AcquireResource(module_type,
@@ -239,8 +248,20 @@ void ButtonPressRequest::on_event(const app_mngr::event_engine::Event& event) {
}
std::string response_info;
GetInfo(message, response_info);
+ SetResourceState(ModuleType(), ResourceState::FREE);
SendResponse(result, result_code, response_info.c_str());
}
+std::string ButtonPressRequest::ModuleType() {
+ mobile_apis::ModuleType::eType module_type = static_cast<
+ mobile_apis::ModuleType::eType>(
+ (*message_)[app_mngr::strings::msg_params][message_params::kModuleType]
+ .asUInt());
+ const char* str;
+ const bool ok = NsSmartDeviceLink::NsSmartObjects::EnumConversionHelper<
+ mobile_apis::ModuleType::eType>::EnumToCString(module_type, &str);
+ return ok ? str : "unknown";
+}
+
} // namespace commands
} // namespace rc_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc
index 1b207b6e91..7fa5c43279 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc
@@ -1,5 +1,6 @@
#include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h"
#include "rc_rpc_plugin/rc_module_constants.h"
+#include "smart_objects/enum_schema_item.h"
#include "utils/macro.h"
#include "interfaces/MOBILE_API.h"
@@ -24,6 +25,7 @@ GetInteriorVehicleDataRequest::GetInteriorVehicleDataRequest(
hmi_capabilities,
policy_handle,
resource_allocation_manager) {}
+
bool CheckIfModuleTypeExistInCapabilities(
const smart_objects::SmartObject& rc_capabilities,
const std::string& module_type) {
@@ -47,21 +49,30 @@ void GetInteriorVehicleDataRequest::Execute() {
const smart_objects::SmartObject* rc_capabilities =
application_manager_.hmi_capabilities().rc_capability();
- const std::string module_type =
- (*message_)[app_mngr::strings::msg_params][message_params::kModuleType]
- .asString();
+ const std::string module_type = ModuleType();
if (rc_capabilities &&
!CheckIfModuleTypeExistInCapabilities(*rc_capabilities, module_type)) {
LOG4CXX_WARN(logger_, "Accessing not supported module data");
+ SetResourceState(ModuleType(), ResourceState::FREE);
SendResponse(false,
mobile_apis::Result::UNSUPPORTED_RESOURCE,
"Accessing not supported module data");
return;
}
+
+ app_mngr::ApplicationSharedPtr app =
+ application_manager_.application(connection_key());
+
if (HasRequestExcessiveSubscription()) {
RemoveExcessiveSubscription();
+ is_subscribed =
+ (*message_)[app_mngr::strings::msg_params][message_params::kSubscribe]
+ .asBool();
}
+ (*message_)[app_mngr::strings::msg_params][app_mngr::strings::app_id] =
+ app->app_id();
+
SendHMIRequest(hmi_apis::FunctionID::RC_GetInteriorVehicleData,
&(*message_)[app_mngr::strings::msg_params],
true);
@@ -70,11 +81,14 @@ void GetInteriorVehicleDataRequest::Execute() {
void GetInteriorVehicleDataRequest::on_event(
const app_mngr::event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
+ RCCommandRequest::on_event(event);
+
if (hmi_apis::FunctionID::RC_GetInteriorVehicleData != event.id()) {
return;
}
- const smart_objects::SmartObject& hmi_response = event.smart_object();
+ smart_objects::SmartObject& hmi_response =
+ const_cast<smart_objects::SmartObject&>(event.smart_object());
mobile_apis::Result::eType result_code =
GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>(
@@ -94,10 +108,19 @@ void GetInteriorVehicleDataRequest::on_event(
if (result) {
ProccessSubscription(hmi_response);
+ if (!hmi_response[app_mngr::strings::msg_params].keyExists(
+ message_params::kIsSubscribed)) {
+ hmi_response[app_mngr::strings::msg_params]
+ [message_params::kIsSubscribed] = is_subscribed;
+ }
}
std::string response_info;
GetInfo(hmi_response, response_info);
- SendResponse(result, result_code, response_info.c_str());
+ SetResourceState(ModuleType(), ResourceState::FREE);
+ SendResponse(result,
+ result_code,
+ response_info.c_str(),
+ &hmi_response[app_mngr::strings::msg_params]);
}
GetInteriorVehicleDataRequest::~GetInteriorVehicleDataRequest() {}
@@ -109,8 +132,10 @@ void GetInteriorVehicleDataRequest::ProccessSubscription(
const bool is_subscribe_present_in_request =
(*message_)[app_mngr::strings::msg_params].keyExists(
message_params::kSubscribe);
+
const bool isSubscribed_present_in_response =
- hmi_response[json_keys::kResult].keyExists(message_params::kIsSubscribed);
+ hmi_response[app_mngr::strings::msg_params].keyExists(
+ message_params::kIsSubscribed);
if (!is_subscribe_present_in_request && !isSubscribed_present_in_response) {
return;
@@ -124,6 +149,15 @@ void GetInteriorVehicleDataRequest::ProccessSubscription(
"conditional mandatory parameter "
<< message_params::kIsSubscribed
<< " missed in hmi response");
+
+ const char* module_type;
+ NsSmartDeviceLink::NsSmartObjects::
+ EnumConversionHelper<mobile_apis::ModuleType::eType>::EnumToCString(
+ static_cast<mobile_apis::ModuleType::eType>(
+ hmi_response[app_mngr::strings::msg_params]
+ [message_params::kModuleType].asUInt()),
+ &module_type);
+ is_subscribed = extension->IsSubscibedToInteriorVehicleData(module_type);
return;
}
@@ -140,13 +174,14 @@ void GetInteriorVehicleDataRequest::ProccessSubscription(
(*message_)[app_mngr::strings::msg_params][message_params::kSubscribe]
.asBool();
const bool response_subscribe =
- hmi_response[json_keys::kResult][message_params::kIsSubscribed].asBool();
+ hmi_response[app_mngr::strings::msg_params][message_params::kIsSubscribed]
+ .asBool();
+ is_subscribed = response_subscribe;
+
LOG4CXX_TRACE(logger_, "request_subscribe = " << request_subscribe);
LOG4CXX_TRACE(logger_, "response_subscribe = " << response_subscribe);
if (request_subscribe == response_subscribe) {
- const std::string module_type =
- (*message_)[app_mngr::strings::msg_params][message_params::kModuleData]
- [message_params::kModuleType].asString();
+ const std::string module_type = ModuleType();
if (response_subscribe) {
LOG4CXX_DEBUG(logger_,
"SubscribeToInteriorVehicleData " << app->app_id() << " "
@@ -174,10 +209,7 @@ bool GetInteriorVehicleDataRequest::HasRequestExcessiveSubscription() {
resource_allocation_manager_.GetApplicationExtention(app);
const bool is_app_already_subscribed =
- extension->IsSubscibedToInteriorVehicleData(
- (*message_)[app_mngr::strings::msg_params]
- [message_params::kModuleData]
- [message_params::kModuleType].asString());
+ extension->IsSubscibedToInteriorVehicleData(ModuleType());
const bool app_wants_to_subscribe =
(*message_)[app_mngr::strings::msg_params][message_params::kSubscribe]
.asBool();
@@ -194,5 +226,16 @@ void GetInteriorVehicleDataRequest::RemoveExcessiveSubscription() {
(*message_)[app_mngr::strings::msg_params].erase(message_params::kSubscribe);
}
+std::string GetInteriorVehicleDataRequest::ModuleType() {
+ mobile_apis::ModuleType::eType module_type = static_cast<
+ mobile_apis::ModuleType::eType>(
+ (*message_)[app_mngr::strings::msg_params][message_params::kModuleType]
+ .asUInt());
+ const char* str;
+ const bool ok = NsSmartDeviceLink::NsSmartObjects::EnumConversionHelper<
+ mobile_apis::ModuleType::eType>::EnumToCString(module_type, &str);
+ return ok ? str : "unknown";
+}
+
} // namespace commands
} // namespace rc_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc
index 1b5d76c7c8..e37264cfbf 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc
@@ -1,6 +1,7 @@
#include "rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h"
#include "rc_rpc_plugin/rc_rpc_plugin.h"
#include "rc_rpc_plugin/rc_module_constants.h"
+#include "smart_objects/enum_schema_item.h"
#include "utils/macro.h"
namespace rc_rpc_plugin {
@@ -28,9 +29,7 @@ OnInteriorVehicleDataNotification::~OnInteriorVehicleDataNotification() {}
void OnInteriorVehicleDataNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- const std::string module_type =
- (*message_)[app_mngr::strings::msg_params][message_params::kModuleType]
- .asString();
+ const std::string module_type = ModuleType();
typedef std::vector<application_manager::ApplicationSharedPtr> AppPtrs;
AppPtrs apps = RCRPCPlugin::GetRCApplications(application_manager_);
@@ -43,12 +42,27 @@ void OnInteriorVehicleDataNotification::Run() {
application_manager::AppExtensionPtr::static_pointer_cast<
RCAppExtension>(app.QueryInterface(RCRPCPlugin::kRCPluginID));
DCHECK(extension);
- LOG4CXX_TRACE(logger_, "Check subscription for " << app.app_id());
+ LOG4CXX_TRACE(logger_,
+ "Check subscription for "
+ << app.app_id() << "and module type " << module_type);
if (extension->IsSubscibedToInteriorVehicleData(module_type)) {
+ (*message_)[app_mngr::strings::params]
+ [app_mngr::strings::connection_key] = app.app_id();
SendNotification();
}
}
}
+std::string OnInteriorVehicleDataNotification::ModuleType() {
+ mobile_apis::ModuleType::eType module_type = static_cast<
+ mobile_apis::ModuleType::eType>(
+ (*message_)[app_mngr::strings::msg_params][message_params::kModuleType]
+ .asUInt());
+ const char* str;
+ const bool ok = NsSmartDeviceLink::NsSmartObjects::EnumConversionHelper<
+ mobile_apis::ModuleType::eType>::EnumToCString(module_type, &str);
+ return ok ? str : "unknown";
+}
+
} // namespace commands
} // namespace rc_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc
index 1ae844def8..081289ee00 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc
@@ -1,5 +1,6 @@
#include "rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h"
#include "rc_rpc_plugin/rc_module_constants.h"
+#include "smart_objects/enum_schema_item.h"
#include "utils/macro.h"
#include "json/json.h"
#include "utils/helpers.h"
@@ -143,8 +144,7 @@ void SetInteriorVehicleDataRequest::Execute() {
auto module_data =
(*message_)[app_mngr::strings::msg_params][message_params::kModuleData];
- const std::string module_type =
- module_data[message_params::kModuleType].asString();
+ const std::string module_type = ModuleType();
bool module_type_and_data_match = true;
if (enums_value::kRadio == module_type) {
@@ -181,6 +181,12 @@ void SetInteriorVehicleDataRequest::Execute() {
CutOffReadOnlyParams(module_data);
}
application_manager_.RemoveHMIFakeParameters(message_);
+
+ app_mngr::ApplicationSharedPtr app =
+ application_manager_.application(connection_key());
+ (*message_)[app_mngr::strings::msg_params][app_mngr::strings::app_id] =
+ app->app_id();
+
SendHMIRequest(hmi_apis::FunctionID::RC_SetInteriorVehicleData,
&(*message_)[app_mngr::strings::msg_params],
true);
@@ -195,6 +201,8 @@ void SetInteriorVehicleDataRequest::Execute() {
void SetInteriorVehicleDataRequest::on_event(
const app_mngr::event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
+ RCCommandRequest::on_event(event);
+
if (hmi_apis::FunctionID::RC_SetInteriorVehicleData != event.id()) {
return;
}
@@ -220,10 +228,9 @@ void SetInteriorVehicleDataRequest::on_event(
SendResponse(result, result_code, info.c_str());
}
-const smart_objects::SmartObject& ControlData(
+const smart_objects::SmartObject& SetInteriorVehicleDataRequest::ControlData(
const smart_objects::SmartObject& module_data) {
- const std::string module =
- module_data[message_params::kModuleType].asString();
+ const std::string module = ModuleType();
if (enums_value::kRadio == module) {
return module_data[message_params::kRadioControlData];
@@ -238,8 +245,7 @@ bool SetInteriorVehicleDataRequest::AreAllParamsReadOnly(
const smart_objects::SmartObject& module_type_params =
ControlData(module_data);
auto it = module_type_params.map_begin();
- std::vector<std::string> ro_params = GetModuleReadOnlyParams(
- module_data[message_params::kModuleType].asString());
+ std::vector<std::string> ro_params = GetModuleReadOnlyParams(ModuleType());
for (; it != module_type_params.map_end(); ++it) {
if (!helpers::in_range(ro_params, it->first)) {
return false;
@@ -254,8 +260,7 @@ bool SetInteriorVehicleDataRequest::AreReadOnlyParamsPresent(
const smart_objects::SmartObject& module_type_params =
ControlData(module_data);
auto it = module_type_params.map_begin();
- std::vector<std::string> ro_params = GetModuleReadOnlyParams(
- module_data[message_params::kModuleType].asString());
+ std::vector<std::string> ro_params = GetModuleReadOnlyParams(ModuleType());
for (; it != module_type_params.map_end(); ++it) {
if (helpers::in_range(ro_params, it->first)) {
return true;
@@ -270,8 +275,7 @@ void SetInteriorVehicleDataRequest::CutOffReadOnlyParams(
const smart_objects::SmartObject& module_type_params =
ControlData(module_data);
auto it = module_type_params.map_begin();
- const std::string module_type =
- module_data[message_params::kModuleType].asString();
+ const std::string module_type = ModuleType();
std::vector<std::string> ro_params = GetModuleReadOnlyParams(module_type);
for (; it != module_type_params.map_end(); ++it) {
if (helpers::in_range(ro_params, it->first)) {
@@ -288,12 +292,22 @@ void SetInteriorVehicleDataRequest::CutOffReadOnlyParams(
}
}
+std::string SetInteriorVehicleDataRequest::ModuleType() {
+ mobile_apis::ModuleType::eType module_type =
+ static_cast<mobile_apis::ModuleType::eType>(
+ (*message_)[app_mngr::strings::msg_params]
+ [message_params::kModuleData][message_params::kModuleType]
+ .asUInt());
+ const char* str;
+ const bool ok = NsSmartDeviceLink::NsSmartObjects::EnumConversionHelper<
+ mobile_apis::ModuleType::eType>::EnumToCString(module_type, &str);
+ return ok ? str : "unknown";
+}
+
AcquireResult::eType SetInteriorVehicleDataRequest::AcquireResource(
const app_mngr::commands::MessageSharedPtr& message) {
LOG4CXX_AUTO_TRACE(logger_);
- const std::string module_type =
- (*message_)[app_mngr::strings::msg_params][message_params::kModuleData]
- [message_params::kModuleType].asString();
+ const std::string module_type = ModuleType();
app_mngr::ApplicationSharedPtr app =
application_manager_.application(CommandRequestImpl::connection_key());
return resource_allocation_manager_.AcquireResource(module_type,
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 d6aaaab04a..62c1cd4005 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
@@ -34,6 +34,7 @@
#include "rc_rpc_plugin/rc_module_constants.h"
#include "application_manager/message_helper.h"
#include "application_manager/hmi_interfaces.h"
+#include "smart_objects/enum_schema_item.h"
CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule")
@@ -67,10 +68,8 @@ bool RCCommandRequest::IsInterfaceAvailable(
void RCCommandRequest::onTimeOut() {
LOG4CXX_AUTO_TRACE(logger_);
- SetResourceState(
- (*message_)[app_mngr::strings::msg_params][message_params::kModuleType]
- .asString(),
- ResourceState::FREE);
+ const std::string module_type = ModuleType();
+ SetResourceState(module_type, ResourceState::FREE);
SendResponse(
false, mobile_apis::Result::GENERIC_ERROR, "Request timeout expired");
}
@@ -85,9 +84,8 @@ bool RCCommandRequest::CheckDriverConsent() {
LOG4CXX_ERROR(logger_, "NULL pointer.");
return false;
}
- const std::string module_type =
- (*message_)[app_mngr::strings::msg_params][message_params::kModuleType]
- .asString();
+
+ const std::string module_type = ModuleType();
rc_rpc_plugin::TypeAccess access = CheckModule(module_type, app);
if (rc_rpc_plugin::kAllowed == access) {
@@ -119,19 +117,34 @@ void RCCommandRequest::SendDisallowed(rc_rpc_plugin::TypeAccess access) {
return;
}
LOG4CXX_ERROR(logger_, info);
+ SetResourceState(ModuleType(), ResourceState::FREE);
SendResponse(false, mobile_apis::Result::DISALLOWED, info.c_str());
}
void RCCommandRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
+ app_mngr::ApplicationSharedPtr app =
+ application_manager_.application(CommandRequestImpl::connection_key());
+
if (!IsInterfaceAvailable(app_mngr::HmiInterfaces::HMI_INTERFACE_RC)) {
LOG4CXX_WARN(logger_, "HMI interface RC is not available");
+ SetResourceState(ModuleType(), ResourceState::FREE);
SendResponse(false,
mobile_apis::Result::UNSUPPORTED_RESOURCE,
"Remote control is not supported by system");
return;
}
LOG4CXX_TRACE(logger_, "RC interface is available!");
+ if (!policy_handler_.CheckHMIType(
+ app->policy_app_id(),
+ mobile_apis::AppHMIType::eType::REMOTE_CONTROL,
+ app->app_types())) {
+ LOG4CXX_WARN(logger_, "Application has no remote control functions");
+ SetResourceState(ModuleType(), ResourceState::FREE);
+ SendResponse(false, mobile_apis::Result::DISALLOWED, "");
+ return;
+ }
+
if (CheckDriverConsent()) {
if (AcquireResources()) {
Execute(); // run child's logic
@@ -144,12 +157,11 @@ void RCCommandRequest::Run() {
bool RCCommandRequest::AcquireResources() {
LOG4CXX_AUTO_TRACE(logger_);
- const std::string module_type =
- (*message_)[app_mngr::strings::msg_params][message_params::kModuleType]
- .asString();
+ const std::string module_type = ModuleType();
if (!IsResourceFree(module_type)) {
LOG4CXX_WARN(logger_, "Resource is busy.");
+ SetResourceState(ModuleType(), ResourceState::FREE);
SendResponse(false, mobile_apis::Result::IN_USE, "");
return false;
}
@@ -161,6 +173,7 @@ bool RCCommandRequest::AcquireResources() {
return true;
}
case AcquireResult::IN_USE: {
+ SetResourceState(ModuleType(), ResourceState::FREE);
SendResponse(false, mobile_apis::Result::IN_USE, "");
return false;
}
@@ -170,6 +183,7 @@ bool RCCommandRequest::AcquireResources() {
return false;
}
case AcquireResult::REJECTED: {
+ SetResourceState(ModuleType(), ResourceState::FREE);
SendResponse(false, mobile_apis::Result::REJECTED, "");
return false;
}
@@ -179,10 +193,8 @@ bool RCCommandRequest::AcquireResources() {
void RCCommandRequest::on_event(const app_mngr::event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
- const std::string module_type =
- (*message_)[app_mngr::strings::msg_params][message_params::kModuleType]
- .asString();
+ const std::string module_type = ModuleType();
SetResourceState(module_type, ResourceState::FREE);
if (event.id() == hmi_apis::FunctionID::RC_GetInteriorVehicleDataConsent) {
@@ -195,11 +207,10 @@ void RCCommandRequest::ProcessAccessResponse(
LOG4CXX_AUTO_TRACE(logger_);
app_mngr::ApplicationSharedPtr app =
application_manager_.application(CommandRequestImpl::connection_key());
- const std::string module_type =
- (*message_)[app_mngr::strings::msg_params][message_params::kModuleType]
- .asString();
+ const std::string module_type = ModuleType();
if (!app) {
LOG4CXX_ERROR(logger_, "NULL pointer.");
+ SetResourceState(ModuleType(), ResourceState::FREE);
SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED, "");
return;
}
@@ -230,6 +241,7 @@ void RCCommandRequest::ProcessAccessResponse(
} else {
resource_allocation_manager_.OnDriverDisallowed(module_type,
app->app_id());
+ SetResourceState(ModuleType(), ResourceState::FREE);
SendResponse(
false,
mobile_apis::Result::REJECTED,
@@ -239,6 +251,7 @@ void RCCommandRequest::ProcessAccessResponse(
} else {
std::string response_info;
GetInfo(message, response_info);
+ SetResourceState(ModuleType(), ResourceState::FREE);
SendResponse(false, result_code, response_info.c_str());
}
}
@@ -250,7 +263,7 @@ void RCCommandRequest::SendGetUserConsent(const std::string& module_type) {
DCHECK(app);
smart_objects::SmartObject msg_params =
smart_objects::SmartObject(smart_objects::SmartType_Map);
- msg_params[json_keys::kAppId] = app->hmi_app_id();
+ msg_params[app_mngr::strings::app_id] = app->app_id();
msg_params[app_mngr::strings::msg_params][message_params::kModuleType] =
module_type;
SendHMIRequest(hmi_apis::FunctionID::RC_GetInteriorVehicleDataConsent,
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 4d978f2fcc..4bf2abd607 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
@@ -27,34 +27,7 @@ bool RCRPCPlugin::IsAbleToProcess(
const int32_t function_id,
const application_manager::commands::Command::CommandSource
message_source) {
- namespace MobileFunctions = mobile_apis::FunctionID;
- namespace HMIFunctions = hmi_apis::FunctionID;
- namespace commands = application_manager::commands;
- using helpers::in_range;
- std::vector<MobileFunctions::eType> mobile_functions;
- mobile_functions.push_back(MobileFunctions::GetInteriorVehicleDataID);
- mobile_functions.push_back(MobileFunctions::SetInteriorVehicleDataID);
- mobile_functions.push_back(MobileFunctions::OnInteriorVehicleDataID);
- mobile_functions.push_back(MobileFunctions::ButtonPressID);
- // mobile_functions.push_back(MobileFunctions::OnRCStatusID);
-
- std::vector<HMIFunctions::eType> hmi_functions;
- hmi_functions.push_back(HMIFunctions::RC_GetInteriorVehicleData);
- hmi_functions.push_back(HMIFunctions::RC_SetInteriorVehicleData);
- hmi_functions.push_back(HMIFunctions::RC_OnInteriorVehicleData);
- hmi_functions.push_back(HMIFunctions::RC_OnRemoteControlSettings);
- hmi_functions.push_back(HMIFunctions::Buttons_OnButtonPress);
- // hmi_functions.push_back(HMIFunctions::RC_OnRCStatus);
-
- if (commands::Command::SOURCE_MOBILE == message_source) {
- return in_range(mobile_functions,
- static_cast<MobileFunctions::eType>(function_id));
- }
- if (commands::Command::SOURCE_HMI == message_source) {
- return in_range(hmi_functions,
- static_cast<HMIFunctions::eType>(function_id));
- }
- return false;
+ return command_factory_->IsAbleToProcess(function_id, message_source);
}
std::string RCRPCPlugin::PluginName() {
diff --git a/src/components/application_manager/src/hmi_interfaces_impl.cc b/src/components/application_manager/src/hmi_interfaces_impl.cc
index 4479665f64..e6636ed38f 100644
--- a/src/components/application_manager/src/hmi_interfaces_impl.cc
+++ b/src/components/application_manager/src/hmi_interfaces_impl.cc
@@ -222,6 +222,13 @@ generate_function_to_interface_convert_map() {
convert_map[SDL_GetURLS] = HmiInterfaces::HMI_INTERFACE_SDL;
convert_map[RC_IsReady] = HmiInterfaces::HMI_INTERFACE_RC;
convert_map[RC_GetCapabilities] = HmiInterfaces::HMI_INTERFACE_RC;
+ convert_map[Buttons_ButtonPress] = HmiInterfaces::HMI_INTERFACE_RC;
+ convert_map[RC_SetInteriorVehicleData] = HmiInterfaces::HMI_INTERFACE_RC;
+ convert_map[RC_GetInteriorVehicleData] = HmiInterfaces::HMI_INTERFACE_RC;
+ convert_map[RC_GetInteriorVehicleDataConsent] =
+ HmiInterfaces::HMI_INTERFACE_RC;
+ convert_map[RC_OnInteriorVehicleData] = HmiInterfaces::HMI_INTERFACE_RC;
+ convert_map[RC_OnRemoteControlSettings] = HmiInterfaces::HMI_INTERFACE_RC;
return convert_map;
}