summaryrefslogtreecommitdiff
path: root/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src
diff options
context:
space:
mode:
authorjacobkeeler <jacob.keeler@livioradio.com>2019-03-06 15:02:13 -0500
committerjacobkeeler <jacob.keeler@livioradio.com>2019-03-06 15:02:13 -0500
commit2396b961e40c471680bba84f20fa0d90fe68e579 (patch)
tree939eb879ccd5d77ffb061bc113dec3618032198a /src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src
parent82f77e91d31a8a5507c8cdd2388e24642e1c846f (diff)
parent222ec0566594288744d73ef30174e714bd6f29ce (diff)
downloadsdl_core-2396b961e40c471680bba84f20fa0d90fe68e579.tar.gz
Merge remote-tracking branch 'origin/feature/base_app_services_implementation' into feature/forwarded_request_timeout
Diffstat (limited to 'src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src')
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc26
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc20
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc16
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc21
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc7
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc18
6 files changed, 52 insertions, 56 deletions
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc
index 8f52268f19..2b66993d8f 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc
@@ -57,10 +57,29 @@ void ASPerformAppServiceInteractionRequestFromHMI::Run() {
LOG4CXX_AUTO_TRACE(logger_);
smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params];
+ std::string hmi_origin_id =
+ application_manager_.get_settings().hmi_origin_id();
+ if (!msg_params.keyExists(strings::origin_app)) {
+ if (hmi_origin_id.empty()) {
+ smart_objects::SmartObject response_params;
+ response_params[strings::info] =
+ "No HMI origin ID to use for interaction passthrough";
+ SendResponse(
+ false,
+ correlation_id(),
+ hmi_apis::FunctionID::AppService_PerformAppServiceInteraction,
+ hmi_apis::Common_Result::INVALID_DATA,
+ &response_params,
+ application_manager::commands::Command::SOURCE_SDL_TO_HMI);
+ return;
+ }
+ msg_params[strings::origin_app] = hmi_origin_id;
+ }
+
std::string service_id = msg_params[strings::service_id].asString();
auto service =
application_manager_.GetAppServiceManager().FindServiceByID(service_id);
- if (service.first.empty()) {
+ if (!service) {
smart_objects::SmartObject response_params;
response_params[strings::info] = "The requested service ID does not exist";
SendResponse(false,
@@ -80,9 +99,8 @@ void ASPerformAppServiceInteractionRequestFromHMI::Run() {
}
// Only activate service if it is not already active
- bool activate_service =
- request_service_active &&
- !service.second.record[strings::service_active].asBool();
+ bool activate_service = request_service_active &&
+ !service->record[strings::service_active].asBool();
if (activate_service) {
application_manager_.GetAppServiceManager().ActivateAppService(service_id);
}
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc
index 5e20ca20d1..b816016fa7 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc
@@ -51,23 +51,6 @@ ASPublishAppServiceRequest::ASPublishAppServiceRequest(
ASPublishAppServiceRequest::~ASPublishAppServiceRequest() {}
-bool ASPublishAppServiceRequest::ValidateManifest(
- smart_objects::SmartObject& manifest) {
- if (manifest.keyExists(strings::uri_scheme)) {
- Json::Value value;
- Json::Reader reader;
- if (!reader.parse(manifest[strings::uri_scheme].asString(), value)) {
- SendResponse(
- false,
- (*message_)[strings::params][strings::correlation_id].asUInt(),
- hmi_apis::FunctionID::AppService_PublishAppService,
- hmi_apis::Common_Result::INVALID_DATA);
- return false;
- }
- }
- return true;
-}
-
void ASPublishAppServiceRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
LOG4CXX_DEBUG(logger_, "Received a PublishAppService request from HMI");
@@ -75,9 +58,6 @@ void ASPublishAppServiceRequest::Run() {
smart_objects::SmartObject(smart_objects::SmartType_Map);
smart_objects::SmartObject manifest =
(*message_)[strings::msg_params][strings::app_service_manifest];
- if (!ValidateManifest(manifest)) {
- return;
- }
smart_objects::SmartObject service_record =
application_manager_.GetAppServiceManager().PublishAppService(
manifest, false, UINT32_MAX);
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc
index b54071068f..0d387785ee 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc
@@ -70,16 +70,16 @@ void GetAppServiceDataRequest::Run() {
std::string service_type =
(*message_)[strings::msg_params][strings::service_type].asString();
- bool subscribe = false;
- if ((*message_)[strings::msg_params].keyExists(strings::subscribe)) {
- subscribe = (*message_)[strings::msg_params][strings::subscribe].asBool();
- }
-
ApplicationSharedPtr app = application_manager_.application(connection_key());
-
- if (subscribe) {
+ if ((*message_)[strings::msg_params].keyExists(strings::subscribe)) {
+ bool subscribe =
+ (*message_)[strings::msg_params][strings::subscribe].asBool();
auto& ext = AppServiceAppExtension::ExtractASExtension(*app);
- ext.SubscribeToAppService(service_type);
+ if (subscribe) {
+ ext.SubscribeToAppService(service_type);
+ } else {
+ ext.UnsubscribeFromAppService(service_type);
+ }
}
SendProviderRequest(mobile_apis::FunctionID::GetAppServiceDataID,
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc
index a016d1fe16..2c6ba414e0 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc
@@ -61,10 +61,27 @@ OnAppServiceDataNotification::~OnAppServiceDataNotification() {}
void OnAppServiceDataNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
LOG4CXX_DEBUG(logger_, "Sending OnAppServiceData to consumer");
- MessageHelper::PrintSmartObject(*message_);
+
+ std::string service_id =
+ (*message_)[strings::msg_params][strings::service_data]
+ [strings::service_id].asString();
+ auto service =
+ application_manager_.GetAppServiceManager().FindServiceByID(service_id);
+
+ if (!service) {
+ LOG4CXX_ERROR(logger_, "Service sending OnAppServiceData is not published");
+ return;
+ } else if (!service->record[strings::service_manifest]
+ [strings::allow_app_consumers].asBool()) {
+ LOG4CXX_ERROR(logger_,
+ "Service does not allow for app consumers, skipping mobile "
+ "OnAppServiceData notification");
+ return;
+ }
std::string service_type =
- (*message_)[strings::msg_params][strings::service_type].asString();
+ (*message_)[strings::msg_params][strings::service_data]
+ [strings::service_type].asString();
auto subscribed_to_app_service_predicate =
[service_type](const ApplicationSharedPtr app) {
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc
index 9623cffd36..9e262f0ca3 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc
@@ -66,7 +66,7 @@ void PerformAppServiceInteractionRequest::Run() {
std::string service_id = msg_params[strings::service_id].asString();
auto service =
application_manager_.GetAppServiceManager().FindServiceByID(service_id);
- if (service.first.empty()) {
+ if (!service) {
SendResponse(false,
mobile_apis::Result::INVALID_ID,
"The requested service ID does not exist");
@@ -81,9 +81,8 @@ void PerformAppServiceInteractionRequest::Run() {
}
// Only activate service if it is not already active
- bool activate_service =
- request_service_active &&
- !service.second.record[strings::service_active].asBool();
+ bool activate_service = request_service_active &&
+ !service->record[strings::service_active].asBool();
if (activate_service) {
if (app->is_foreground()) {
// App is in foreground, we can just activate the service
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc
index 05210208ca..22d8e50c3a 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc
@@ -55,21 +55,6 @@ PublishAppServiceRequest::PublishAppServiceRequest(
PublishAppServiceRequest::~PublishAppServiceRequest() {}
-bool PublishAppServiceRequest::ValidateManifest(
- smart_objects::SmartObject& manifest) {
- if (manifest.keyExists(strings::uri_scheme)) {
- Json::Value value;
- Json::Reader reader;
- if (!reader.parse(manifest[strings::uri_scheme].asString(), value)) {
- SendResponse(false,
- mobile_apis::Result::INVALID_DATA,
- "Provided uriScheme was not valid JSON");
- return false;
- }
- }
- return true;
-}
-
void PublishAppServiceRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
LOG4CXX_DEBUG(logger_, "Received a PublishAppService " << connection_key());
@@ -79,9 +64,6 @@ void PublishAppServiceRequest::Run() {
smart_objects::SmartObject(smart_objects::SmartType_Map);
smart_objects::SmartObject manifest =
(*message_)[strings::msg_params][strings::app_service_manifest];
- if (!ValidateManifest(manifest)) {
- return;
- }
ApplicationSharedPtr app = application_manager_.application(connection_key());