summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjacobkeeler <jacob.keeler@livioradio.com>2019-03-16 12:06:30 -0400
committerjacobkeeler <jacob.keeler@livioradio.com>2019-03-16 12:06:30 -0400
commit02d737241c5024c51d9fef20223b49afff5817f1 (patch)
treee9e9057c19d407fe63969931f2b4ae48a94ede93
parent2ff8225f536a1595d6a409ddeb7e46c3ec9ebb95 (diff)
downloadsdl_core-02d737241c5024c51d9fef20223b49afff5817f1.tar.gz
API changes to app service manager
-rw-r--r--src/components/application_manager/include/application_manager/app_service_manager.h121
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc2
-rw-r--r--src/components/application_manager/src/app_service_manager.cc7
-rw-r--r--src/components/application_manager/src/rpc_passing_handler.cc10
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_app_service_manager.h2
5 files changed, 104 insertions, 38 deletions
diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h
index 47a60780bc..b5b8598a0f 100644
--- a/src/components/application_manager/include/application_manager/app_service_manager.h
+++ b/src/components/application_manager/include/application_manager/app_service_manager.h
@@ -73,94 +73,159 @@ class AppServiceManager {
virtual ~AppServiceManager();
/**
- * @brief TODO
- * @param manifest
+ * @brief Publish an app service. This service will be activated if it is the
+ * default service for its type, or if it is the first service to register of
+ * its type.
+ * @param manifest - The app service manifest of the service to be published
+ * @param mobile_service - True, if the service is being published by a mobile
+ * app. False, if published by the embedded system.
+ * @param connection_key - If mobile_service is true, the connection key of
+ * the app publishing this service.
+ * @return The app service record of the published app service
*/
virtual smart_objects::SmartObject PublishAppService(
const smart_objects::SmartObject& manifest,
const bool mobile_service,
- const uint32_t connection_key);
+ const uint32_t connection_key = 0u);
/**
- * @brief TODO
- * @param service_id
+ * @brief Unpublish an existing app service
+ * @param service_id - The ID of the app service to be deleted.
+ * @return True on success, false otherwise
*/
virtual bool UnpublishAppService(const std::string service_id);
+ /**
+ * @brief Callback for when an application is activated. Will activate all
+ * services which were published by this app.
+ * @param app - The application that was activated.
+ */
virtual void OnAppActivated(ApplicationConstSharedPtr app);
/**
- * @brief TODO
- * @param connection_key
+ * @brief Unpublish any published services for a given mobile application
+ * @param connection_key - The connection key of the application from which
+ * all published services should be deleted.
*/
virtual void UnpublishServices(const uint32_t connection_key);
/**
- * @brief TODO
- * @param service_id
+ * @brief Sets a service to the default service for its type
+ * @param service_id - The ID of the service to become the default
+ * @return True on success, false otherwise
*/
virtual bool SetDefaultService(const std::string service_id);
/**
- * @brief TODO
- * @param service_id
+ * @brief Removes a service from the list of default services.
+ * @param service_id - The ID of the existing default service.
+ * @return True on success, false otherwise
*/
virtual bool RemoveDefaultService(const std::string service_id);
/**
- * @brief TODO
- * @param service_id
+ * @brief Activate an existing service
+ * @param service_id - The ID of the service to be activated.
+ * @return True if the service is active, false otherwise
*/
virtual bool ActivateAppService(const std::string service_id);
/**
- * @brief TODO
- * @param service_id
+ * @brief Deactivate an existing active service
+ * @param service_id - The ID of the service to be deactivated.
+ * @return True if the service was deactivated, false otherwise
*/
virtual bool DeactivateAppService(const std::string service_id);
/**
- * @brief TODO
- * @param manifest
+ * @brief Get a list of all published service records.
+ * @return A list of all all published service records.
*/
virtual std::vector<smart_objects::SmartObject> GetAllServiceRecords();
- virtual std::vector<std::pair<std::string, AppService> > GetActiveServices();
+
+ /**
+ * @brief Get a list of all active app services.
+ * @return A list of all all active app services.
+ */
+ virtual std::vector<AppService> GetActiveServices();
+ /**
+ * @brief Retrieve the active service provider for a given service type
+ * @param service_type - The service type of the provider to be retrieved
+ * @param mobile_consumer - True, if the consumer trying to communicate with
+ * the provider is a mobile application
+ * @param app - Output parameter that will be filled with the application
+ * providing the requested service on success, unchanged on failure
+ * @param hmi_service - Output parameter set to true if the service
+ * provider is the HMI, unchanged on failure
+ */
virtual void GetProviderByType(const std::string& service_type,
const bool mobile_consumer,
ApplicationSharedPtr& app,
bool& hmi_service);
+ /**
+ * @brief Retrieve the service provider with a given service ID
+ * @param service_type - The service type of the provider to be retrieved
+ * @param mobile_consumer - True, if the consumer trying to communicate with
+ * the provider is a mobile application
+ * @param app - Output parameter that will be filled with the application
+ * providing the requested service on success, unchanged on failure
+ * @param hmi_service - Output parameter set to true if the service
+ * provider is the HMI, unchanged on failure
+ */
virtual void GetProviderByID(const std::string& service_id,
const bool mobile_consumer,
ApplicationSharedPtr& app,
bool& hmi_service);
+ /**
+ * @brief Get the active service for a given service type.
+ * @param service_type - The service type
+ * @return A pointer to the active service for the given service type on
+ * success, NULL on failure
+ */
virtual AppService* ActiveServiceForType(const std::string service_type);
+ /**
+ * @brief Get the embedded service for a given service type.
+ * @param service_type - The service type
+ * @return A pointer to the embedded service for the given service type on
+ * success, NULL on failure
+ */
virtual AppService* EmbeddedServiceForType(const std::string service_type);
AppService* FindServiceByName(const std::string name);
+ /**
+ * @brief Get the service with a given service ID.
+ * @param service_type - The service ID
+ * @return A pointer to requested service on success, NULL on failure
+ */
virtual AppService* FindServiceByID(const std::string service_id);
- virtual std::string DefaultServiceByType(const std::string service_type);
-
/**
- * @brief TODO
- * @param service_id
- * @param service_published
+ * @brief Get the service ID of the default service for a given service type.
+ * @param service_type - The service type
+ * @return The service ID of the default service for the given service type on
+ * success, "" on failure
*/
- virtual void SetServicePublished(const std::string service_id,
- bool service_published);
+ virtual std::string DefaultServiceByType(const std::string service_type);
/**
- * @brief TODO
- * @param out_params
+ * @brief Update a navigation system capability struct with the capabilities
+ * of the active navigation service.
+ * @param out_params - The struct to be modified
+ * @return True on success, false otherwise (if there was no active NAVIGATION
+ * service)
*/
virtual bool UpdateNavigationCapabilities(
smart_objects::SmartObject& out_params);
+ /**
+ * @brief Get the RPCPassingHandler tied to this object
+ * @return The RPCPassingHandler tied to this object
+ */
virtual RPCPassingHandler& GetRPCPassingHandler();
private:
@@ -171,6 +236,8 @@ class AppServiceManager {
std::map<std::string, AppService> published_services_;
RPCPassingHandler rpc_passing_handler_;
+ void SetServicePublished(const std::string service_id,
+ bool service_published);
void AppServiceUpdated(
const smart_objects::SmartObject& service_record,
const mobile_apis::ServiceUpdateReason::eType update_reason,
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 c9466ff52d..6d2f516f0f 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
@@ -62,7 +62,7 @@ void ASPublishAppServiceRequest::Run() {
(*message_)[strings::msg_params][strings::app_service_manifest];
smart_objects::SmartObject service_record =
application_manager_.GetAppServiceManager().PublishAppService(
- manifest, false, UINT32_MAX);
+ manifest, false);
response_params[strings::app_service_record] = service_record;
SendResponse(true,
diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc
index 83551b1a13..5643611526 100644
--- a/src/components/application_manager/src/app_service_manager.cc
+++ b/src/components/application_manager/src/app_service_manager.cc
@@ -547,13 +547,12 @@ void AppServiceManager::AppServiceUpdated(
services[-1] = service;
}
-std::vector<std::pair<std::string, AppService> >
-AppServiceManager::GetActiveServices() {
- std::vector<std::pair<std::string, AppService> > active_services;
+std::vector<AppService> AppServiceManager::GetActiveServices() {
+ std::vector<AppService> active_services;
for (auto it = published_services_.begin(); it != published_services_.end();
++it) {
if (it->second.record[strings::service_active].asBool()) {
- active_services.push_back(*it);
+ active_services.push_back(it->second);
}
}
return active_services;
diff --git a/src/components/application_manager/src/rpc_passing_handler.cc b/src/components/application_manager/src/rpc_passing_handler.cc
index 7ff01756f7..37b01a92f6 100644
--- a/src/components/application_manager/src/rpc_passing_handler.cc
+++ b/src/components/application_manager/src/rpc_passing_handler.cc
@@ -83,7 +83,7 @@ bool RPCPassingHandler::CanHandleFunctionID(int32_t function_id) {
auto services = app_service_manager_.GetActiveServices();
for (auto it = services.begin(); it != services.end(); ++it) {
auto handled_rpcs =
- it->second.record[strings::service_manifest][strings::handled_rpcs];
+ it->record[strings::service_manifest][strings::handled_rpcs];
for (size_t i = 0; i < handled_rpcs.length(); i++) {
if (handled_rpcs[i].asInt() == function_id) {
return true;
@@ -187,13 +187,13 @@ void RPCPassingHandler::PopulateRPCRequestQueue(
for (auto services_it = services.begin(); services_it != services.end();
++services_it) {
auto handled_rpcs =
- services_it->second
- .record[strings::service_manifest][strings::handled_rpcs];
+ services_it->record[strings::service_manifest][strings::handled_rpcs];
for (size_t i = 0; i < handled_rpcs.length(); i++) {
if (handled_rpcs[i].asInt() == function_id) {
// Add requests to queue
- ServiceInfo service_info{services_it->first,
- services_it->second.connection_key};
+ ServiceInfo service_info{
+ services_it->record[strings::service_id].asString(),
+ services_it->connection_key};
entry.second.push_back(service_info);
app_manager_.IncreaseForwardedRequestTimeout(origin_connection_key,
correlation_id);
diff --git a/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h b/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h
index 030c130cbc..7459e40061 100644
--- a/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h
+++ b/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h
@@ -60,7 +60,7 @@ class MockAppServiceManager : public application_manager::AppServiceManager {
MOCK_METHOD0(GetAllServiceRecords, std::vector<smart_objects::SmartObject>());
MOCK_METHOD0(
GetActiveServices,
- std::vector<std::pair<std::string, application_manager::AppService> >());
+ std::vector<application_manager::AppService>());
MOCK_METHOD4(GetProviderByType,
void(const std::string& service_type,
const bool mobile_consumer,