summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackLivio <jack@livio.io>2019-07-17 13:47:09 -0400
committerJackLivio <jack@livio.io>2019-07-17 13:47:09 -0400
commit1e3a86da29ece1e05543b7facb470f7e6f4a63eb (patch)
treebac0ced0092de66734f94da57525a0594c12734a
parent9fae63bfa8fb8dae78b21e768c28efcdbf11bbe0 (diff)
downloadsdl_core-1e3a86da29ece1e05543b7facb470f7e6f4a63eb.tar.gz
Address some comments
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_unpublish_app_service_request.cc12
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/unpublish_app_service_request.cc11
-rw-r--r--src/components/application_manager/src/app_service_manager.cc18
3 files changed, 32 insertions, 9 deletions
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_unpublish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_unpublish_app_service_request.cc
index 7e7757a3d4..8e117fcc70 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_unpublish_app_service_request.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_unpublish_app_service_request.cc
@@ -60,6 +60,18 @@ void ASUnpublishAppServiceRequest::Run() {
std::string service_id =
(*message_)[strings::msg_params][strings::service_id].asString();
+ auto service =
+ application_manager_.GetAppServiceManager().FindServiceByID(service_id);
+ if (service->mobile_service) {
+ SendErrorResponse(
+ (*message_)[strings::params][strings::correlation_id].asUInt(),
+ hmi_apis::FunctionID::AppService_UnpublishAppService,
+ hmi_apis::Common_Result::REJECTED,
+ "Invalid Service ID",
+ application_manager::commands::Command::SOURCE_SDL_TO_HMI);
+ return;
+ }
+
bool ret = application_manager_.GetAppServiceManager().UnpublishAppService(
service_id);
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/unpublish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/unpublish_app_service_request.cc
index 453de1d15f..1bdfd4d8e1 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/unpublish_app_service_request.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/unpublish_app_service_request.cc
@@ -61,6 +61,17 @@ void UnpublishAppServiceRequest::Run() {
std::string service_id =
(*message_)[strings::msg_params][strings::service_id].asString();
+ auto service =
+ application_manager_.GetAppServiceManager().FindServiceByID(service_id);
+
+ if (service->connection_key != connection_key()) {
+ SendResponse(
+ false,
+ mobile_apis::Result::INVALID_ID,
+ "The app service with that requested service ID does not exist");
+ return;
+ }
+
bool ret = application_manager_.GetAppServiceManager().UnpublishAppService(
service_id);
diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc
index f359f59bc3..4d4dde76a6 100644
--- a/src/components/application_manager/src/app_service_manager.cc
+++ b/src/components/application_manager/src/app_service_manager.cc
@@ -70,6 +70,12 @@ smart_objects::SmartObject AppServiceManager::PublishAppService(
std::string str_to_hash = "";
std::string service_id = "";
+ if (manifest.keyExists(strings::service_name) &&
+ FindServiceByName(manifest[strings::service_name].asString())) {
+ LOG4CXX_WARN(logger_, "A service already exists with this name, rejecting");
+ return smart_objects::SmartObject();
+ }
+
std::string service_type = manifest[strings::service_type].asString();
AppService* found_service =
@@ -96,12 +102,6 @@ smart_objects::SmartObject AppServiceManager::PublishAppService(
return updated_service_record;
}
- if (manifest.keyExists(strings::service_name) &&
- FindServiceByName(manifest[strings::service_name].asString())) {
- LOG4CXX_WARN(logger_, "A service already exists with this name, rejecting");
- return smart_objects::SmartObject();
- }
-
published_services_lock_.Acquire();
do {
str_to_hash = manifest[strings::service_type].asString() +
@@ -158,7 +158,7 @@ smart_objects::SmartObject AppServiceManager::PublishAppService(
}
if (!active_service || app_service.default_service ||
- (mobile_service && app && app->IsFullscreen())) {
+ (app && app->IsFullscreen())) {
ActivateAppService(service_id);
}
@@ -188,8 +188,8 @@ bool AppServiceManager::UnpublishAppService(const std::string service_id) {
auto embedded_service = EmbeddedServiceForType(
record[strings::service_manifest][strings::service_type].asString());
if (embedded_service &&
- (embedded_service->record[strings::service_id].asString().compare(
- service_id) > 0)) {
+ (embedded_service->record[strings::service_id].asString() !=
+ service_id)) {
embedded_service->record[strings::service_active] = true;
AppServiceUpdated(embedded_service->record,
mobile_apis::ServiceUpdateReason::ACTIVATED,