summaryrefslogtreecommitdiff
path: root/src/components/application_manager/src
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/src')
-rw-r--r--src/components/application_manager/src/app_service_manager.cc70
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc2
-rw-r--r--src/components/application_manager/src/message_helper/message_helper.cc51
-rw-r--r--src/components/application_manager/src/smart_object_keys.cc5
4 files changed, 125 insertions, 3 deletions
diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc
index 8fea64b228..57b319c680 100644
--- a/src/components/application_manager/src/app_service_manager.cc
+++ b/src/components/application_manager/src/app_service_manager.cc
@@ -37,6 +37,7 @@
#include "application_manager/app_service_manager.h"
#include "application_manager/application.h"
+#include "application_manager/app_service_manager.h"
#include "application_manager/application_manager.h"
#include "application_manager/commands/command_impl.h"
#include "application_manager/message_helper.h"
@@ -78,19 +79,73 @@ smart_objects::SmartObject AppServiceManager::PublishAppService(
service_record[strings::service_id] = service_id;
service_record[strings::service_published] = true;
service_record[strings::service_active] = true;
-
app_service.record = service_record;
published_services_.insert(
std::pair<std::string, AppService>(service_id, app_service));
+ auto all_services = GetAllServices();
+ smart_objects::SmartObjectSPtr notification =
+ std::make_shared<smart_objects::SmartObject>(
+ MessageHelper::CreateMobileSystemCapabilityNotification(
+ all_services,
+ service_id,
+ mobile_apis::ServiceUpdateReason::PUBLISHED));
+ app_manager_.GetRPCService().ManageMobileCommand(
+ notification, commands::Command::CommandSource::SOURCE_SDL);
+ smart_objects::SmartObjectSPtr hmi_notification =
+ std::make_shared<smart_objects::SmartObject>(
+ MessageHelper::CreateHMISystemCapabilityNotification(
+ all_services,
+ service_id,
+ mobile_apis::ServiceUpdateReason::PUBLISHED));
+ app_manager_.GetRPCService().ManageHMICommand(hmi_notification);
return service_record;
}
bool AppServiceManager::UnpublishAppService(const std::string service_id) {
LOG4CXX_AUTO_TRACE(logger_);
- // TODO
- return false;
+
+ auto it = published_services_.find(service_id);
+ if (it == published_services_.end()) {
+ LOG4CXX_ERROR(logger_, "Service id does not exist in published services");
+ return false;
+ }
+ LOG4CXX_DEBUG(logger_, "Unpublishing app service: " << service_id);
+
+ SetServicePublished(service_id, false);
+
+ auto all_services = GetAllServices();
+ smart_objects::SmartObjectSPtr notification =
+ std::make_shared<smart_objects::SmartObject>(
+ MessageHelper::CreateMobileSystemCapabilityNotification(
+ all_services,
+ service_id,
+ mobile_apis::ServiceUpdateReason::REMOVED));
+ app_manager_.GetRPCService().ManageMobileCommand(
+ notification, commands::Command::CommandSource::SOURCE_SDL);
+ smart_objects::SmartObjectSPtr hmi_notification =
+ std::make_shared<smart_objects::SmartObject>(
+ MessageHelper::CreateHMISystemCapabilityNotification(
+ all_services,
+ service_id,
+ mobile_apis::ServiceUpdateReason::REMOVED));
+ app_manager_.GetRPCService().ManageHMICommand(hmi_notification);
+
+ published_services_.erase(it);
+
+ return true;
+}
+
+void AppServiceManager::UnpublishServices(const uint32_t connection_key) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_DEBUG(logger_, "Unpublishing all app services: " << connection_key);
+ for (auto it = published_services_.begin(); it != published_services_.end();
+ ++it) {
+ if (it->second.connection_key == connection_key) {
+ UnpublishAppService(it->first);
+ }
+ }
}
std::vector<smart_objects::SmartObject> AppServiceManager::GetAllServices() {
@@ -103,6 +158,15 @@ std::vector<smart_objects::SmartObject> AppServiceManager::GetAllServices() {
return services;
}
+void AppServiceManager::SetServicePublished(const std::string service_id,
+ bool service_published) {
+ auto it = published_services_.find(service_id);
+ if (it == published_services_.end()) {
+ LOG4CXX_ERROR(logger_, "Service id does not exist in published services");
+ return;
+ }
+ it->second.record[strings::service_published] = service_published;
+}
std::pair<std::string, AppService> AppServiceManager::ActiveServiceByType(
std::string service_type) {
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index d82eeb776c..6ee221f56f 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -2619,6 +2619,8 @@ void ApplicationManagerImpl::UnregisterApplication(
<< is_unexpected_disconnect);
size_t subscribed_for_way_points_app_count = 0;
+ GetAppServiceManager().UnpublishServices(app_id);
+
// SDL sends UnsubscribeWayPoints only for last application
{
sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_);
diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc
index 58d5171f84..1d3a553711 100644
--- a/src/components/application_manager/src/message_helper/message_helper.cc
+++ b/src/components/application_manager/src/message_helper/message_helper.cc
@@ -327,6 +327,57 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateMessageForHMI(
return message;
}
+smart_objects::SmartObject
+MessageHelper::CreateMobileSystemCapabilityNotification(
+ std::vector<smart_objects::SmartObject>& all_services,
+ const std::string service_id,
+ mobile_apis::ServiceUpdateReason::eType update_reason) {
+ smart_objects::SmartObject message(smart_objects::SmartType_Map);
+
+ message[strings::params][strings::message_type] = MessageType::kNotification;
+ message[strings::params][strings::function_id] =
+ mobile_apis::FunctionID::OnSystemCapabilityUpdatedID;
+
+ smart_objects::SmartObject system_capability =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ system_capability[strings::system_capability_type] =
+ mobile_apis::SystemCapabilityType::APP_SERVICES;
+
+ smart_objects::SmartObject app_service_capabilities(
+ smart_objects::SmartType_Map);
+ smart_objects::SmartObject app_services(smart_objects::SmartType_Array);
+
+ std::vector<smart_objects::SmartObject> service_records = all_services;
+
+ for (auto& record : service_records) {
+ smart_objects::SmartObject app_services_capabilities(
+ smart_objects::SmartType_Map);
+ app_services_capabilities[strings::updated_app_service_record] = record;
+ if (record[strings::service_id].asString() == service_id) {
+ app_services_capabilities[strings::update_reason] = update_reason;
+ }
+ app_services.asArray()->push_back(app_services_capabilities);
+ }
+
+ app_service_capabilities[strings::app_services] = app_services;
+ system_capability[strings::app_services_capabilities] =
+ app_service_capabilities;
+
+ message[strings::msg_params][strings::system_capability] = system_capability;
+ return message;
+}
+
+smart_objects::SmartObject MessageHelper::CreateHMISystemCapabilityNotification(
+ std::vector<smart_objects::SmartObject>& all_services,
+ const std::string service_id,
+ mobile_apis::ServiceUpdateReason::eType update_reason) {
+ auto message = CreateMobileSystemCapabilityNotification(
+ all_services, service_id, update_reason);
+ message[strings::params][strings::function_id] =
+ hmi_apis::FunctionID::BasicCommunication_OnSystemCapabilityUpdated;
+ return message;
+}
+
smart_objects::SmartObjectSPtr MessageHelper::CreateHashUpdateNotification(
const uint32_t app_id) {
LOG4CXX_AUTO_TRACE(logger_);
diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc
index 1b6dfe2b8b..4900726d48 100644
--- a/src/components/application_manager/src/smart_object_keys.cc
+++ b/src/components/application_manager/src/smart_object_keys.cc
@@ -27,6 +27,7 @@ const char* app_launch_last_session = "app_launch_last_session";
const char* policy_app_id = "policyAppID";
const char* hmi_app_id = "hmiAppID";
const char* device_id = "deviceID";
+const char* subscribe = "subscribe";
const char* subscribed_for_way_points = "subscribed_for_way_points";
const char* url = "url";
const char* urlScheme = "urlScheme";
@@ -145,6 +146,7 @@ const char* navigation_capability = "navigationCapability";
const char* phone_capability = "phoneCapability";
const char* video_streaming_capability = "videoStreamingCapability";
const char* rc_capability = "remoteControlCapability";
+const char* app_services_capabilities = "appServicesCapabilities";
const char* day_color_scheme = "dayColorScheme";
const char* night_color_scheme = "nightColorScheme";
const char* primary_color = "primaryColor";
@@ -283,6 +285,9 @@ const char* service_id = "serviceID";
const char* service_manifest = "serviceManifest";
const char* service_published = "servicePublished";
const char* service_active = "serviceActive";
+const char* app_services = "appServices";
+const char* update_reason = "updateReason";
+const char* updated_app_service_record = "updatedAppServiceRecord";
// resuming
const char* application_commands = "applicationCommands";