summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Keeler <jacob.keeler@livioradio.com>2019-03-17 13:18:01 -0400
committerGitHub <noreply@github.com>2019-03-17 13:18:01 -0400
commit499cc74f2b633ed5a070507d81413af3432a0279 (patch)
tree9f9e8a3d831863a9edd944c954ba0fa2c2e319f0
parent79503c9389855137c4a14d5f9d9c153ec1d87a0d (diff)
parent14b83db71c0fd4249f5753134a33e4e36f6a775f (diff)
downloadsdl_core-499cc74f2b633ed5a070507d81413af3432a0279.tar.gz
Merge pull request #2847 from smartdevicelink/feature/app_service_manager_tests
App service manager tests and app service related fixes
-rw-r--r--src/components/application_manager/include/application_manager/app_service_manager.h179
-rw-r--r--src/components/application_manager/include/application_manager/application_manager_impl.h6
-rw-r--r--src/components/application_manager/include/application_manager/rpc_passing_handler.h4
-rw-r--r--src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h2
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h2
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc8
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_request.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc4
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_perform_app_service_interaction_request_from_hmi.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_publish_app_service_request.cc6
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc21
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/perform_app_service_interaction_request.cc11
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc2
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h2
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h2
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc4
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc3
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc4
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc4
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc2
-rw-r--r--src/components/application_manager/src/app_launch/app_launch_data_db.cc2
-rw-r--r--src/components/application_manager/src/app_service_manager.cc47
-rw-r--r--src/components/application_manager/src/commands/command_request_impl.cc4
-rw-r--r--src/components/application_manager/src/commands/request_from_hmi.cc2
-rw-r--r--src/components/application_manager/src/hmi_capabilities_impl.cc4
-rw-r--r--src/components/application_manager/src/resumption/resumption_data_json.cc2
-rw-r--r--src/components/application_manager/src/rpc_handler_impl.cc2
-rw-r--r--src/components/application_manager/src/rpc_passing_handler.cc15
-rw-r--r--src/components/application_manager/src/rpc_service_impl.cc2
-rw-r--r--src/components/application_manager/src/system_time/system_time_handler_impl.cc2
-rwxr-xr-xsrc/components/application_manager/test/CMakeLists.txt1
-rw-r--r--src/components/application_manager/test/app_service_manager_test.cc439
-rw-r--r--src/components/application_manager/test/application_manager_impl_test.cc12
-rw-r--r--src/components/application_manager/test/commands/command_impl_test.cc11
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_app_service_manager.h93
-rw-r--r--src/components/application_manager/test/message_helper/message_helper_test.cc2
-rw-r--r--src/components/include/application_manager/application_manager.h3
-rw-r--r--src/components/include/test/application_manager/mock_application_manager.h21
-rw-r--r--src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h2
41 files changed, 806 insertions, 133 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 4c0877a456..9690d7cd46 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
@@ -34,10 +34,9 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_SERVICE_MANAGER_H_
#include "application_manager/application.h"
+#include "application_manager/rpc_passing_handler.h"
#include "interfaces/MOBILE_API.h"
#include "smart_objects/smart_object.h"
-#include "application_manager/application.h"
-#include "application_manager/rpc_passing_handler.h"
namespace resumption {
class LastState;
@@ -52,6 +51,7 @@ struct AppService {
smart_objects::SmartObject record;
};
+class RPCPassingHandler;
class ApplicationManager;
/**
* @brief The AppServiceManager is TODO.
@@ -70,95 +70,153 @@ class AppServiceManager {
/**
* @brief Class destructor
*/
- ~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
*/
- smart_objects::SmartObject PublishAppService(
+ 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
*/
- bool UnpublishAppService(const std::string service_id);
-
- void OnAppActivated(ApplicationConstSharedPtr app);
+ virtual bool UnpublishAppService(const std::string service_id);
/**
- * @brief TODO
- * @param connection_key
+ * @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.
*/
- void UnpublishServices(const uint32_t connection_key);
+ virtual void OnAppActivated(ApplicationConstSharedPtr app);
/**
- * @brief TODO
- * @param service_id
+ * @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.
*/
- bool SetDefaultService(const std::string service_id);
+ 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
*/
- bool RemoveDefaultService(const std::string service_id);
+ 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
*/
- bool ActivateAppService(const std::string service_id);
+ 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
*/
- bool DeactivateAppService(const std::string service_id);
+ virtual bool ActivateAppService(const std::string service_id);
/**
- * @brief TODO
- * @param manifest
+ * @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
*/
- std::vector<smart_objects::SmartObject> GetAllServices();
- std::vector<std::pair<std::string, AppService> > GetActiveServices();
+ virtual bool DeactivateAppService(const std::string service_id);
- void GetProviderByType(const std::string& service_type,
- bool mobile_consumer,
- ApplicationSharedPtr& app,
- bool& hmi_service);
+ /**
+ * @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();
- void GetProviderByID(const std::string& service_id,
- bool mobile_consumer,
- ApplicationSharedPtr& app,
- bool& hmi_service);
+ /**
+ * @brief Get a list of all active app services.
+ * @return A list of all all active app services.
+ */
+ virtual std::vector<AppService> GetActiveServices();
- AppService* ActiveServiceByType(std::string service_type);
+ /**
+ * @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);
- AppService* EmbeddedServiceForType(std::string service_type);
+ /**
+ * @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);
- AppService* FindServiceByID(std::string service_id);
+ /**
+ * @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);
- std::string DefaultServiceByType(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);
/**
- * @brief TODO
- * @param service_id
- * @param service_published
+ * @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
*/
- void SetServicePublished(const std::string service_id,
- bool service_published);
+ virtual AppService* FindServiceByID(const std::string service_id);
/**
- * @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)
*/
- bool UpdateNavigationCapabilities(smart_objects::SmartObject& out_params);
+ virtual bool UpdateNavigationCapabilities(
+ smart_objects::SmartObject& out_params);
- RPCPassingHandler& GetRPCPassingHandler();
+ /**
+ * @brief Get the RPCPassingHandler tied to this object
+ * @return The RPCPassingHandler tied to this object
+ */
+ virtual RPCPassingHandler& GetRPCPassingHandler();
private:
ApplicationManager& app_manager_;
@@ -168,16 +226,27 @@ 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,
smart_objects::SmartObject& msg_params);
void GetProviderFromService(const AppService& service,
- bool mobile_consumer,
+ const bool mobile_consumer,
ApplicationSharedPtr& app,
bool& hmi_service);
- AppService* FindServiceByPolicyAppID(std::string policy_app_id,
- std::string type);
+
+ /**
+ * @brief Get the policy app ID of the default service provider for a given
+ * service type.
+ * @param service_type - The service type
+ * @return The policy app ID of the default service provider for the given
+ * service type on success, "" on failure
+ */
+ std::string DefaultServiceByType(const std::string service_type);
+ AppService* FindServiceByPolicyAppID(const std::string policy_app_id,
+ const std::string type);
std::string GetPolicyAppID(AppService service);
};
diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h
index 007b3433f0..cba9cdfd79 100644
--- a/src/components/application_manager/include/application_manager/application_manager_impl.h
+++ b/src/components/application_manager/include/application_manager/application_manager_impl.h
@@ -42,6 +42,7 @@
#include <memory>
#include "application_manager/application_manager.h"
+#include "application_manager/app_service_manager.h"
#include "application_manager/hmi_capabilities.h"
#include "application_manager/message.h"
#include "application_manager/message_helper.h"
@@ -1586,9 +1587,8 @@ class ApplicationManagerImpl
plugin_manager_.reset(plugin_manager.release());
}
- virtual void SetAppServiceManager(
- std::unique_ptr<AppServiceManager>& app_service_manager) {
- app_service_manager_.reset(app_service_manager.release());
+ virtual void SetAppServiceManager(AppServiceManager* app_service_manager) {
+ app_service_manager_.reset(app_service_manager);
}
private:
diff --git a/src/components/application_manager/include/application_manager/rpc_passing_handler.h b/src/components/application_manager/include/application_manager/rpc_passing_handler.h
index 3ed10ff1e6..ab85b1374f 100644
--- a/src/components/application_manager/include/application_manager/rpc_passing_handler.h
+++ b/src/components/application_manager/include/application_manager/rpc_passing_handler.h
@@ -33,11 +33,11 @@
#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RPC_PASSING_HANDLER_H_
#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RPC_PASSING_HANDLER_H_
+#include <deque>
#include "application_manager/application.h"
+#include "application_manager/commands/command.h"
#include "interfaces/MOBILE_API.h"
#include "smart_objects/smart_object.h"
-#include "application_manager/app_service_manager.h"
-#include <deque>
#include "utils/timer.h"
namespace application_manager {
diff --git a/src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h b/src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h
index add440ad80..05565861f6 100644
--- a/src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h
+++ b/src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h
@@ -39,7 +39,7 @@
#include "utils/lock.h"
#include "utils/macro.h"
#include "utils/system_time_handler.h"
-#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_manager.h"
#include "application_manager/event_engine/event_observer.h"
namespace application_manager {
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h
index 70cf0dc6b9..7c80ec5e03 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h
@@ -77,6 +77,8 @@ class GetAppServiceDataRequest : public app_mngr::commands::CommandRequestImpl {
virtual void on_event(const app_mngr::event_engine::MobileEvent& event);
private:
+ void HandleSubscribe();
+
DISALLOW_COPY_AND_ASSIGN(GetAppServiceDataRequest);
};
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc
index 63812056f1..6d8b0c08cc 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2018, Ford Motor Company
+ Copyright (c) 2019, Ford Motor Company, Livio
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -13,9 +13,9 @@
disclaimer in the documentation and/or other materials provided with the
distribution.
- Neither the name of the Ford Motor Company nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
+ Neither the name of the the copyright holders nor the names of their
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_request.cc
index 7c32d9bbe1..fd7312ca98 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_request.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_request.cc
@@ -32,6 +32,8 @@
#include "app_service_rpc_plugin/commands/hmi/as_app_service_activation_request.h"
+#include "application_manager/app_service_manager.h"
+
namespace app_service_rpc_plugin {
using namespace application_manager;
namespace commands {
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc
index 1131448d2f..fa704c1995 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc
@@ -32,6 +32,8 @@
#include "app_service_rpc_plugin/commands/hmi/as_get_app_service_records_request.h"
+#include "application_manager/app_service_manager.h"
+
namespace app_service_rpc_plugin {
using namespace application_manager;
namespace commands {
@@ -61,7 +63,7 @@ void ASGetAppServiceRecordsRequest::Run() {
smart_objects::SmartObject records =
smart_objects::SmartObject(smart_objects::SmartType_Array);
std::vector<smart_objects::SmartObject> service_records =
- application_manager_.GetAppServiceManager().GetAllServices();
+ application_manager_.GetAppServiceManager().GetAllServiceRecords();
int index = 0;
for (auto& record : service_records) {
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 2b66993d8f..70a5a10be0 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
@@ -31,6 +31,8 @@
*/
#include "app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_request_from_hmi.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/message_helper.h"
namespace app_service_rpc_plugin {
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 b816016fa7..637240666d 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
@@ -31,6 +31,8 @@
*/
#include "app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/message_helper.h"
namespace app_service_rpc_plugin {
@@ -59,8 +61,8 @@ void ASPublishAppServiceRequest::Run() {
smart_objects::SmartObject manifest =
(*message_)[strings::msg_params][strings::app_service_manifest];
smart_objects::SmartObject service_record =
- application_manager_.GetAppServiceManager().PublishAppService(
- manifest, false, UINT32_MAX);
+ application_manager_.GetAppServiceManager().PublishAppService(manifest,
+ false);
response_params[strings::app_service_record] = service_record;
SendResponse(true,
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 d8ff1d8040..7c2e62abe2 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
@@ -59,11 +59,17 @@ GetAppServiceDataRequest::~GetAppServiceDataRequest() {}
void GetAppServiceDataRequest::Run() {
LOG4CXX_AUTO_TRACE(logger_);
+ SendProviderRequest(mobile_apis::FunctionID::GetAppServiceDataID,
+ hmi_apis::FunctionID::AppService_GetAppServiceData,
+ &(*message_),
+ true);
+}
+
+void GetAppServiceDataRequest::HandleSubscribe() {
std::string service_type =
(*message_)[strings::msg_params][strings::service_type].asString();
-
ApplicationSharedPtr app = application_manager_.application(connection_key());
- if ((*message_)[strings::msg_params].keyExists(strings::subscribe)) {
+ if (app && (*message_)[strings::msg_params].keyExists(strings::subscribe)) {
bool subscribe =
(*message_)[strings::msg_params][strings::subscribe].asBool();
auto& ext = AppServiceAppExtension::ExtractASExtension(*app);
@@ -73,11 +79,6 @@ void GetAppServiceDataRequest::Run() {
ext.UnsubscribeFromAppService(service_type);
}
}
-
- SendProviderRequest(mobile_apis::FunctionID::GetAppServiceDataID,
- hmi_apis::FunctionID::AppService_GetAppServiceData,
- &(*message_),
- true);
}
void GetAppServiceDataRequest::on_event(
@@ -89,6 +90,9 @@ void GetAppServiceDataRequest::on_event(
mobile_apis::Result::eType result = static_cast<mobile_apis::Result::eType>(
msg_params[strings::result_code].asInt());
bool success = IsMobileResultSuccess(result);
+ if (success) {
+ HandleSubscribe();
+ }
const char* info = msg_params.keyExists(strings::info)
? msg_params[strings::info].asCharArray()
@@ -110,6 +114,9 @@ void GetAppServiceDataRequest::on_event(const event_engine::Event& event) {
MessageHelper::HMIToMobileResult(hmi_result);
bool success = PrepareResultForMobileResponse(
hmi_result, HmiInterfaces::HMI_INTERFACE_AppService);
+ if (success) {
+ HandleSubscribe();
+ }
const char* info = msg_params.keyExists(strings::info)
? msg_params[strings::info].asCharArray()
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 2c6ba414e0..fd3891e0e8 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
@@ -31,7 +31,9 @@
*/
#include "app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h"
+
#include "app_service_rpc_plugin/app_service_app_extension.h"
+#include "application_manager/app_service_manager.h"
#include "application_manager/application_impl.h"
#include "application_manager/helpers/application_helper.h"
#include "application_manager/message_helper.h"
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 9e262f0ca3..4046ac7379 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
@@ -31,6 +31,8 @@
*/
#include "app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_request.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
#include "interfaces/MOBILE_API.h"
@@ -73,6 +75,15 @@ void PerformAppServiceInteractionRequest::Run() {
return;
}
+ if (!service->record[strings::service_manifest][strings::allow_app_consumers]
+ .asBool()) {
+ SendResponse(
+ false,
+ mobile_apis::Result::REJECTED,
+ "The requested service ID does not allow mobile app consumers");
+ return;
+ }
+
bool request_service_active = false;
if (msg_params.keyExists(strings::request_service_active)) {
request_service_active =
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 22d8e50c3a..171c10913e 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
@@ -31,6 +31,8 @@
*/
#include "app_service_rpc_plugin/commands/mobile/publish_app_service_request.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
#include "application_manager/rpc_service.h"
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt
index 63b52da062..97d2efaf07 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt
@@ -30,6 +30,7 @@ set(LIBRARIES
MOBILE_API
connectionHandler
app_service_rpc_plugin
+ sdl_rpc_plugin
jsoncpp
Policy
)
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h
index 90160d9953..3a97ebdfb5 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h
@@ -36,7 +36,7 @@
#include "application_manager/commands/response_from_hmi.h"
#include "utils/macro.h"
-#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_manager.h"
namespace sdl_rpc_plugin {
namespace app_mngr = application_manager;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h
index 0beba8dc6b..7cd8410d8e 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h
@@ -34,7 +34,7 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_TIME_READY_NOTIFICATION_H_
#include "application_manager/commands/notification_from_hmi.h"
-#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_manager.h"
namespace sdl_rpc_plugin {
namespace app_mngr = application_manager;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc
index 73ec1137a8..0677c97db8 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc
@@ -31,6 +31,8 @@
*/
#include "sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/application_impl.h"
#include "application_manager/message_helper.h"
#include "application_manager/rpc_service.h"
@@ -120,7 +122,7 @@ void OnBCSystemCapabilityUpdatedNotification::Run() {
break;
case hmi_apis::Common_SystemCapabilityType::APP_SERVICES: {
auto all_services =
- application_manager_.GetAppServiceManager().GetAllServices();
+ application_manager_.GetAppServiceManager().GetAllServiceRecords();
auto app_service_caps =
MessageHelper::CreateAppServiceCapabilities(all_services);
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc
index 2b3611fece..a582670426 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc
@@ -31,11 +31,12 @@
*/
#include "sdl_rpc_plugin/commands/mobile/get_file_request.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/application_impl.h"
#include "application_manager/rpc_service.h"
#include "interfaces/MOBILE_API.h"
#include "application_manager/message_helper.h"
-#include "application_manager/app_service_manager.h"
#include "utils/file_system.h"
#include <boost/crc.hpp>
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc
index 63a4416139..2a25928b97 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc
@@ -31,7 +31,9 @@
*/
#include "sdl_rpc_plugin/commands/mobile/get_system_capability_request.h"
+
#include "sdl_rpc_plugin/extensions/system_capability_app_extension.h"
+#include "application_manager/app_service_manager.h"
#include "application_manager/message_helper.h"
#include <set>
@@ -143,7 +145,7 @@ void GetSystemCapabilityRequest::Run() {
break;
case mobile_apis::SystemCapabilityType::APP_SERVICES: {
auto all_services =
- application_manager_.GetAppServiceManager().GetAllServices();
+ application_manager_.GetAppServiceManager().GetAllServiceRecords();
response_params
[strings::system_capability][strings::app_services_capabilities] =
MessageHelper::CreateAppServiceCapabilities(all_services);
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc
index b5e3a73ee4..a8544ae643 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc
@@ -1,4 +1,6 @@
#include "sdl_rpc_plugin/commands/mobile/on_system_capability_updated_notification.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/application_manager.h"
#include "application_manager/helpers/application_helper.h"
#include "application_manager/message_helper.h"
@@ -86,7 +88,7 @@ void OnSystemCapabilityUpdatedNotification::Run() {
break;
case mobile_apis::SystemCapabilityType::APP_SERVICES: {
auto all_services =
- application_manager_.GetAppServiceManager().GetAllServices();
+ application_manager_.GetAppServiceManager().GetAllServiceRecords();
auto app_service_caps =
MessageHelper::CreateAppServiceCapabilities(all_services);
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc
index 3cfe4d7118..fb809e8834 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc
@@ -248,6 +248,8 @@
namespace sdl_rpc_plugin {
using namespace application_manager;
+CREATE_LOGGERPTR_GLOBAL(logger_, "HMICommandFactory")
+
HMICommandFactory::HMICommandFactory(
ApplicationManager& application_manager,
rpc_service::RPCService& rpc_service,
diff --git a/src/components/application_manager/src/app_launch/app_launch_data_db.cc b/src/components/application_manager/src/app_launch/app_launch_data_db.cc
index 393b01c952..22d2790183 100644
--- a/src/components/application_manager/src/app_launch/app_launch_data_db.cc
+++ b/src/components/application_manager/src/app_launch/app_launch_data_db.cc
@@ -33,7 +33,7 @@
#include <unistd.h>
#include "application_manager/app_launch/app_launch_data_db.h"
-#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_manager.h"
#include "application_manager/app_launch/app_launch_sql_queries.h"
#include "application_manager/smart_object_keys.h"
#include "application_manager/message_helper.h"
diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc
index e1464f08e0..1711180980 100644
--- a/src/components/application_manager/src/app_service_manager.cc
+++ b/src/components/application_manager/src/app_service_manager.cc
@@ -30,7 +30,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "application_manager/help_prompt_manager_impl.h"
+#include "application_manager/app_service_manager.h"
#include <algorithm>
#include <iterator>
@@ -103,7 +103,8 @@ smart_objects::SmartObject AppServiceManager::PublishAppService(
}
}
}
- app_service.default_service = GetPolicyAppID(app_service) == default_app_id;
+ app_service.default_service =
+ !default_app_id.empty() && GetPolicyAppID(app_service) == default_app_id;
auto ret = published_services_.insert(
std::pair<std::string, AppService>(service_id, app_service));
@@ -120,7 +121,7 @@ smart_objects::SmartObject AppServiceManager::PublishAppService(
// Activate the new service if it is the default for its service type, or if
// no service is active of its service type
- AppService* active_service = ActiveServiceByType(service_type);
+ AppService* active_service = ActiveServiceForType(service_type);
if (!active_service || app_service.default_service) {
ActivateAppService(service_id);
}
@@ -189,7 +190,8 @@ void AppServiceManager::OnAppActivated(ApplicationConstSharedPtr app) {
}
}
-std::vector<smart_objects::SmartObject> AppServiceManager::GetAllServices() {
+std::vector<smart_objects::SmartObject>
+AppServiceManager::GetAllServiceRecords() {
LOG4CXX_AUTO_TRACE(logger_);
std::vector<smart_objects::SmartObject> services;
sync_primitives::AutoLock lock(published_services_lock_);
@@ -201,11 +203,11 @@ std::vector<smart_objects::SmartObject> AppServiceManager::GetAllServices() {
}
void AppServiceManager::GetProviderByType(const std::string& service_type,
- bool mobile_consumer,
+ const bool mobile_consumer,
ApplicationSharedPtr& app,
bool& hmi_service) {
LOG4CXX_AUTO_TRACE(logger_);
- auto active_service = ActiveServiceByType(service_type);
+ auto active_service = ActiveServiceForType(service_type);
if (!active_service) {
LOG4CXX_ERROR(logger_,
"There is no active service for the given service type: "
@@ -218,7 +220,7 @@ void AppServiceManager::GetProviderByType(const std::string& service_type,
}
void AppServiceManager::GetProviderByID(const std::string& service_id,
- bool mobile_consumer,
+ const bool mobile_consumer,
ApplicationSharedPtr& app,
bool& hmi_service) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -234,7 +236,7 @@ void AppServiceManager::GetProviderByID(const std::string& service_id,
}
void AppServiceManager::GetProviderFromService(const AppService& service,
- bool mobile_consumer,
+ const bool mobile_consumer,
ApplicationSharedPtr& app,
bool& hmi_service) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -327,7 +329,7 @@ bool AppServiceManager::ActivateAppService(const std::string service_id) {
const std::string service_type =
service[strings::service_manifest][strings::service_type].asString();
- auto active_service = ActiveServiceByType(service_type);
+ auto active_service = ActiveServiceForType(service_type);
if (active_service) {
active_service->record[strings::service_active] = false;
AppServiceUpdated(active_service->record,
@@ -374,7 +376,9 @@ bool AppServiceManager::DeactivateAppService(const std::string service_id) {
const std::string service_type =
service[strings::service_manifest][strings::service_type].asString();
auto embedded_service = EmbeddedServiceForType(service_type);
- if (embedded_service) {
+ if (embedded_service &&
+ embedded_service->record[strings::service_id].asString() !=
+ service[strings::service_id].asString()) {
embedded_service->record[strings::service_active] = true;
AppServiceUpdated(embedded_service->record,
mobile_apis::ServiceUpdateReason::ACTIVATED,
@@ -391,7 +395,8 @@ bool AppServiceManager::DeactivateAppService(const std::string service_id) {
return true;
}
-AppService* AppServiceManager::ActiveServiceByType(std::string service_type) {
+AppService* AppServiceManager::ActiveServiceForType(
+ const std::string service_type) {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(published_services_lock_);
for (auto it = published_services_.begin(); it != published_services_.end();
@@ -407,7 +412,7 @@ AppService* AppServiceManager::ActiveServiceByType(std::string service_type) {
}
AppService* AppServiceManager::EmbeddedServiceForType(
- std::string service_type) {
+ const std::string service_type) {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(published_services_lock_);
for (auto it = published_services_.begin(); it != published_services_.end();
@@ -422,7 +427,7 @@ AppService* AppServiceManager::EmbeddedServiceForType(
}
AppService* AppServiceManager::FindServiceByPolicyAppID(
- std::string policy_app_id, std::string type) {
+ const std::string policy_app_id, const std::string type) {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(published_services_lock_);
for (auto it = published_services_.begin(); it != published_services_.end();
@@ -439,7 +444,7 @@ AppService* AppServiceManager::FindServiceByPolicyAppID(
return NULL;
}
-AppService* AppServiceManager::FindServiceByID(std::string service_id) {
+AppService* AppServiceManager::FindServiceByID(const std::string service_id) {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(published_services_lock_);
@@ -451,7 +456,8 @@ AppService* AppServiceManager::FindServiceByID(std::string service_id) {
return &(it->second);
}
-std::string AppServiceManager::DefaultServiceByType(std::string service_type) {
+std::string AppServiceManager::DefaultServiceByType(
+ const std::string service_type) {
LOG4CXX_AUTO_TRACE(logger_);
Json::Value& dictionary = last_state_.get_dictionary();
if (dictionary[kAppServiceSection][kDefaults].isMember(service_type)) {
@@ -461,7 +467,7 @@ std::string AppServiceManager::DefaultServiceByType(std::string service_type) {
}
void AppServiceManager::SetServicePublished(const std::string service_id,
- bool service_published) {
+ const bool service_published) {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(published_services_lock_);
auto it = published_services_.find(service_id);
@@ -487,7 +493,7 @@ bool AppServiceManager::UpdateNavigationCapabilities(
ns_smart_device_link::ns_smart_objects::
EnumConversionHelper<mobile_apis::AppServiceType::eType>::EnumToString(
mobile_apis::AppServiceType::NAVIGATION, &navi_service_type);
- auto service = ActiveServiceByType(navi_service_type);
+ auto service = ActiveServiceForType(navi_service_type);
if (!service) {
return false;
}
@@ -531,13 +537,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/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc
index 344831f882..2d875db387 100644
--- a/src/components/application_manager/src/commands/command_request_impl.cc
+++ b/src/components/application_manager/src/commands/command_request_impl.cc
@@ -36,9 +36,11 @@
#include "utils/macro.h"
#include "application_manager/commands/command_request_impl.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/application_manager.h"
-#include "application_manager/rpc_service.h"
#include "application_manager/message_helper.h"
+#include "application_manager/rpc_service.h"
#include "smart_objects/smart_object.h"
#include "smart_objects/enum_schema_item.h"
diff --git a/src/components/application_manager/src/commands/request_from_hmi.cc b/src/components/application_manager/src/commands/request_from_hmi.cc
index 0adb389e76..5581f027c0 100644
--- a/src/components/application_manager/src/commands/request_from_hmi.cc
+++ b/src/components/application_manager/src/commands/request_from_hmi.cc
@@ -31,6 +31,8 @@
*/
#include "application_manager/commands/request_from_hmi.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/application_manager.h"
#include "application_manager/request_info.h"
#include "application_manager/rpc_service.h"
diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc
index 6cd6747e99..060eaf011c 100644
--- a/src/components/application_manager/src/hmi_capabilities_impl.cc
+++ b/src/components/application_manager/src/hmi_capabilities_impl.cc
@@ -34,7 +34,7 @@
#include "utils/logger.h"
#include "application_manager/hmi_capabilities_impl.h"
-#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_manager.h"
#include "smart_objects/smart_object.h"
#include "application_manager/message_helper.h"
#include "application_manager/smart_object_keys.h"
@@ -46,6 +46,8 @@
namespace application_manager {
namespace formatters = ns_smart_device_link::ns_json_handler::formatters;
+CREATE_LOGGERPTR_GLOBAL(logger_, "HMICapabilities")
+
namespace {
std::map<std::string, hmi_apis::Common_VrCapabilities::eType>
vr_enum_capabilities;
diff --git a/src/components/application_manager/src/resumption/resumption_data_json.cc b/src/components/application_manager/src/resumption/resumption_data_json.cc
index c8e9032dfa..584fb4e697 100644
--- a/src/components/application_manager/src/resumption/resumption_data_json.cc
+++ b/src/components/application_manager/src/resumption/resumption_data_json.cc
@@ -30,7 +30,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_manager.h"
#include "application_manager/resumption/resumption_data_json.h"
#include "smart_objects/smart_object.h"
#include "json/json.h"
diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc
index 2574da5fb5..6205e028d0 100644
--- a/src/components/application_manager/src/rpc_handler_impl.cc
+++ b/src/components/application_manager/src/rpc_handler_impl.cc
@@ -31,6 +31,8 @@
*/
#include "application_manager/rpc_handler_impl.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/plugin_manager/plugin_keys.h"
namespace application_manager {
diff --git a/src/components/application_manager/src/rpc_passing_handler.cc b/src/components/application_manager/src/rpc_passing_handler.cc
index 8d93659a27..37b01a92f6 100644
--- a/src/components/application_manager/src/rpc_passing_handler.cc
+++ b/src/components/application_manager/src/rpc_passing_handler.cc
@@ -35,12 +35,13 @@
#include <algorithm>
#include <iterator>
+#include "application_manager/app_service_manager.h"
#include "application_manager/application.h"
#include "application_manager/application_manager.h"
-#include "application_manager/rpc_passing_handler.h"
-#include "application_manager/rpc_handler.h"
#include "application_manager/commands/command_impl.h"
#include "application_manager/message_helper.h"
+#include "application_manager/rpc_handler.h"
+#include "application_manager/rpc_passing_handler.h"
#include "application_manager/smart_object_keys.h"
#include "encryption/hashing.h"
#include "resumption/last_state.h"
@@ -82,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;
@@ -186,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/src/rpc_service_impl.cc b/src/components/application_manager/src/rpc_service_impl.cc
index dfb5839764..96882d472f 100644
--- a/src/components/application_manager/src/rpc_service_impl.cc
+++ b/src/components/application_manager/src/rpc_service_impl.cc
@@ -31,6 +31,8 @@
*/
#include "application_manager/rpc_service_impl.h"
+
+#include "application_manager/app_service_manager.h"
#include "application_manager/plugin_manager/plugin_keys.h"
namespace application_manager {
diff --git a/src/components/application_manager/src/system_time/system_time_handler_impl.cc b/src/components/application_manager/src/system_time/system_time_handler_impl.cc
index 06343af5a3..f5d08a8ebf 100644
--- a/src/components/application_manager/src/system_time/system_time_handler_impl.cc
+++ b/src/components/application_manager/src/system_time/system_time_handler_impl.cc
@@ -41,6 +41,8 @@
namespace application_manager {
+CREATE_LOGGERPTR_GLOBAL(logger_, "SystemTimeHandler")
+
SystemTimeHandlerImpl::SystemTimeHandlerImpl(
ApplicationManager& application_manager)
: event_engine::EventObserver(application_manager.event_dispatcher())
diff --git a/src/components/application_manager/test/CMakeLists.txt b/src/components/application_manager/test/CMakeLists.txt
index 02cf58485a..4851a6b37e 100755
--- a/src/components/application_manager/test/CMakeLists.txt
+++ b/src/components/application_manager/test/CMakeLists.txt
@@ -63,6 +63,7 @@ set(testSources
${AM_TEST_DIR}/application_state_test.cc
${AM_TEST_DIR}/usage_statistics_test.cc
${AM_TEST_DIR}/policy_handler_test.cc
+ ${AM_TEST_DIR}/app_service_manager_test.cc
${AM_TEST_DIR}/application_manager_impl_test.cc
${AM_TEST_DIR}/application_helper_test.cc
${AM_TEST_DIR}/command_holder_test.cc
diff --git a/src/components/application_manager/test/app_service_manager_test.cc b/src/components/application_manager/test/app_service_manager_test.cc
new file mode 100644
index 0000000000..960e8e31f6
--- /dev/null
+++ b/src/components/application_manager/test/app_service_manager_test.cc
@@ -0,0 +1,439 @@
+/*
+ * Copyright (c) 2017, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <gmock/gmock.h>
+
+#include "application_manager/commands/command.h"
+#include "application_manager/mock_application.h"
+#include "application_manager/mock_application_manager.h"
+#include "application_manager/mock_application_manager_settings.h"
+#include "application_manager/mock_message_helper.h"
+#include "application_manager/smart_object_keys.h"
+#include "resumption/mock_last_state.h"
+#include "smart_objects/smart_object.h"
+
+namespace test {
+namespace components {
+namespace application_manager_test {
+
+using testing::_;
+using ::testing::DoAll;
+using ::testing::Mock;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using ::testing::SaveArg;
+
+namespace am = application_manager;
+
+const char* kAppServiceSection = "AppServices";
+const char* kDefaults = "defaults";
+const std::string kServiceType = "MEDIA";
+const std::string kServiceName = "service_name";
+const std::string kServiceId = "service_id";
+const std::string kPolicyAppId = "p_app_id";
+const uint32_t kConnectionKey = 43629;
+const uint32_t kHMIConnectionKey = 0;
+
+MATCHER_P(CapabilityUpdateMatcher, reason, "") {
+ smart_objects::SmartObject& services_updated =
+ arg[am::strings::system_capability]
+ [am::strings::app_services_capabilities][am::strings::app_services];
+ if (smart_objects::SmartType_Array != services_updated.getType()) {
+ return false;
+ }
+ for (size_t i = 0; i < services_updated.length(); i++) {
+ smart_objects::SmartObject& service_cap = services_updated[i];
+ if (reason == service_cap[am::strings::update_reason].asInt()) {
+ return true;
+ }
+ }
+ return false;
+}
+
+class AppServiceManagerTest : public testing::Test {
+ public:
+ AppServiceManagerTest()
+ : mock_app_ptr_(new MockApplication)
+ , app_service_manager_(mock_app_manager_, mock_last_state_)
+ , mock_message_helper_(
+ application_manager::MockMessageHelper::message_helper_mock()) {
+ Mock::VerifyAndClearExpectations(mock_message_helper_);
+ }
+ ~AppServiceManagerTest() {
+ Mock::VerifyAndClearExpectations(mock_message_helper_);
+ }
+
+ void SetUp() OVERRIDE {
+ ON_CALL(*mock_message_helper_, BroadcastCapabilityUpdate(_, _))
+ .WillByDefault(Return());
+ ON_CALL(mock_settings_, embedded_services())
+ .WillByDefault(ReturnRef(embedded_services_));
+ ON_CALL(mock_app_manager_, get_settings())
+ .WillByDefault(ReturnRef(mock_settings_));
+ ON_CALL(*mock_app_ptr_, policy_app_id())
+ .WillByDefault(Return(kPolicyAppId));
+ ON_CALL(mock_last_state_, get_dictionary()).WillByDefault(ReturnRef(dict_));
+ auto app_ptr = std::static_pointer_cast<am::Application>(mock_app_ptr_);
+ ON_CALL(mock_app_manager_, application(kConnectionKey))
+ .WillByDefault(Return(app_ptr));
+ }
+
+ protected:
+ smart_objects::SmartObject GenerateMediaManifest(
+ bool allow_app_consumers, std::string app_service_name = kServiceName) {
+ smart_objects::SmartObject manifest(smart_objects::SmartType_Map);
+ manifest[am::strings::service_type] = "MEDIA";
+ manifest[am::strings::service_name] = app_service_name;
+ manifest[am::strings::allow_app_consumers] = allow_app_consumers;
+ manifest[am::strings::media_service_manifest] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ return manifest;
+ }
+
+ smart_objects::SmartObject PublishService(
+ uint32_t connection_key = kConnectionKey, bool first_run = true) {
+ smart_objects::SmartObject manifest = GenerateMediaManifest(true);
+
+ Json::Value empty_json;
+ EXPECT_CALL(mock_last_state_, get_dictionary())
+ .WillOnce(ReturnRef(empty_json));
+
+ EXPECT_CALL(*mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(
+ mobile_apis::ServiceUpdateReason::PUBLISHED),
+ _)).WillOnce(Return());
+ if (first_run) {
+ EXPECT_CALL(*mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(
+ mobile_apis::ServiceUpdateReason::ACTIVATED),
+ _)).WillOnce(Return());
+ }
+ bool mobile_service = connection_key != kHMIConnectionKey;
+ return app_service_manager_.PublishAppService(
+ manifest, mobile_service, connection_key);
+ }
+
+ void CheckCapabilityUpdate(smart_objects::SmartObject& msg_params,
+ size_t length,
+ std::string service_id,
+ mobile_apis::ServiceUpdateReason::eType reason,
+ bool published,
+ bool active) {
+ smart_objects::SmartObject& services_updated = msg_params
+ [am::strings::system_capability][am::strings::app_services_capabilities]
+ [am::strings::app_services];
+ ASSERT_EQ(smart_objects::SmartType_Array, services_updated.getType());
+ EXPECT_EQ(length, services_updated.length());
+ for (size_t i = 0; i < services_updated.length(); i++) {
+ smart_objects::SmartObject& service_cap = services_updated[i];
+ if (service_id ==
+ service_cap[am::strings::updated_app_service_record]
+ [am::strings::service_id].asString()) {
+ CheckCapability(service_cap, service_id, reason, published, active);
+ return;
+ }
+ }
+ FAIL() << "Unable to find service in capability update with service_id: "
+ << service_id;
+ }
+
+ void CheckCapability(smart_objects::SmartObject& app_service_capability,
+ std::string service_id,
+ mobile_apis::ServiceUpdateReason::eType reason,
+ bool published,
+ bool active) {
+ EXPECT_EQ(reason,
+ app_service_capability[am::strings::update_reason].asInt());
+ smart_objects::SmartObject& updated_record =
+ app_service_capability[am::strings::updated_app_service_record];
+ EXPECT_EQ(service_id, updated_record[am::strings::service_id].asString());
+ EXPECT_EQ(published,
+ updated_record[am::strings::service_published].asBool());
+ EXPECT_EQ(active, updated_record[am::strings::service_active].asBool());
+ }
+
+ Json::Value dict_;
+ std::vector<std::string> embedded_services_;
+ std::shared_ptr<MockApplication> mock_app_ptr_;
+ MockApplicationManager mock_app_manager_;
+ resumption_test::MockLastState mock_last_state_;
+ MockApplicationManagerSettings mock_settings_;
+ application_manager::AppServiceManager app_service_manager_;
+ application_manager::MockMessageHelper* mock_message_helper_;
+};
+
+TEST_F(AppServiceManagerTest, PublishAppService_Mobile_SUCCESS) {
+ smart_objects::SmartObject manifest = GenerateMediaManifest(true);
+
+ Json::Value empty_json;
+ EXPECT_CALL(mock_last_state_, get_dictionary())
+ .WillOnce(ReturnRef(empty_json));
+
+ smart_objects::SmartObject syscap_update_published;
+ EXPECT_CALL(
+ *mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::PUBLISHED),
+ _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_published), Return()));
+
+ smart_objects::SmartObject syscap_update_activated;
+ EXPECT_CALL(
+ *mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED),
+ _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return()));
+
+ auto record =
+ app_service_manager_.PublishAppService(manifest, true, kConnectionKey);
+
+ // Check final record
+ std::string service_id = record[am::strings::service_id].asString();
+ EXPECT_EQ(manifest, record[am::strings::service_manifest]);
+ EXPECT_TRUE(record[am::strings::service_published].asBool());
+ EXPECT_TRUE(record[am::strings::service_active].asBool());
+
+ // Check first capability update
+ CheckCapabilityUpdate(syscap_update_published,
+ 1,
+ service_id,
+ mobile_apis::ServiceUpdateReason::PUBLISHED,
+ true,
+ false);
+
+ // Check second capability update
+ CheckCapabilityUpdate(syscap_update_activated,
+ 1,
+ service_id,
+ mobile_apis::ServiceUpdateReason::ACTIVATED,
+ true,
+ true);
+}
+
+TEST_F(AppServiceManagerTest, PublishAppService_HMI_SUCCESS) {
+ smart_objects::SmartObject manifest = GenerateMediaManifest(true);
+
+ Json::Value empty_json;
+ EXPECT_CALL(mock_last_state_, get_dictionary())
+ .WillOnce(ReturnRef(empty_json));
+
+ smart_objects::SmartObject syscap_update_published;
+ EXPECT_CALL(
+ *mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::PUBLISHED),
+ _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_published), Return()));
+
+ smart_objects::SmartObject syscap_update_activated;
+ EXPECT_CALL(
+ *mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED),
+ _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return()));
+
+ auto record = app_service_manager_.PublishAppService(manifest, false);
+
+ // Check final record
+ std::string service_id = record[am::strings::service_id].asString();
+ EXPECT_EQ(manifest, record[am::strings::service_manifest]);
+ EXPECT_TRUE(record[am::strings::service_published].asBool());
+ EXPECT_TRUE(record[am::strings::service_active].asBool());
+
+ // Check first capability update
+ CheckCapabilityUpdate(syscap_update_published,
+ 1,
+ service_id,
+ mobile_apis::ServiceUpdateReason::PUBLISHED,
+ true,
+ false);
+
+ // Check second capability update
+ CheckCapabilityUpdate(syscap_update_activated,
+ 1,
+ service_id,
+ mobile_apis::ServiceUpdateReason::ACTIVATED,
+ true,
+ true);
+}
+
+TEST_F(AppServiceManagerTest, UnpublishAppService_SUCCESS) {
+ auto record = PublishService();
+
+ smart_objects::SmartObject syscap_update_unpublished;
+ EXPECT_CALL(
+ *mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::REMOVED),
+ _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_unpublished), Return()));
+ std::string service_id = record[am::strings::service_id].asString();
+
+ EXPECT_TRUE(app_service_manager_.UnpublishAppService(service_id));
+
+ // Check removed capability update
+ CheckCapabilityUpdate(syscap_update_unpublished,
+ 1,
+ service_id,
+ mobile_apis::ServiceUpdateReason::REMOVED,
+ false,
+ false);
+}
+
+TEST_F(AppServiceManagerTest, ActivateAppService_AlreadyActivated) {
+ auto record = PublishService();
+
+ // No capability update
+ EXPECT_CALL(
+ *mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED),
+ _)).Times(0);
+ std::string service_id = record[am::strings::service_id].asString();
+
+ EXPECT_TRUE(app_service_manager_.ActivateAppService(service_id));
+}
+
+TEST_F(AppServiceManagerTest, ActivateAppService_TwoApps_SUCCESS) {
+ // Register two services with the same service type, the first is activated
+ // automatically
+ auto record = PublishService();
+ auto record2 = PublishService(kConnectionKey + 1, false);
+
+ // No capability update
+ smart_objects::SmartObject syscap_update_activated;
+ EXPECT_CALL(
+ *mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED),
+ _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return()));
+ std::string service_id = record[am::strings::service_id].asString();
+ std::string service_id2 = record2[am::strings::service_id].asString();
+
+ // Activate the second service
+ EXPECT_TRUE(app_service_manager_.ActivateAppService(service_id2));
+
+ // Check that the first service is deactivated
+ CheckCapabilityUpdate(syscap_update_activated,
+ 2,
+ service_id,
+ mobile_apis::ServiceUpdateReason::DEACTIVATED,
+ true,
+ false);
+
+ // Check that the second service is activated
+ CheckCapabilityUpdate(syscap_update_activated,
+ 2,
+ service_id2,
+ mobile_apis::ServiceUpdateReason::ACTIVATED,
+ true,
+ true);
+}
+
+TEST_F(AppServiceManagerTest, DeactivateAppService_SUCCESS) {
+ auto record = PublishService();
+
+ smart_objects::SmartObject syscap_update_deactivated;
+ EXPECT_CALL(*mock_message_helper_,
+ BroadcastCapabilityUpdate(
+ CapabilityUpdateMatcher(
+ mobile_apis::ServiceUpdateReason::DEACTIVATED),
+ _))
+ .WillOnce(DoAll(SaveArg<0>(&syscap_update_deactivated), Return()));
+ std::string service_id = record[am::strings::service_id].asString();
+
+ EXPECT_TRUE(app_service_manager_.DeactivateAppService(service_id));
+
+ // Check deactivated capability update
+ CheckCapabilityUpdate(syscap_update_deactivated,
+ 1,
+ service_id,
+ mobile_apis::ServiceUpdateReason::DEACTIVATED,
+ true,
+ false);
+}
+
+TEST_F(AppServiceManagerTest, ActiveServiceForType_SUCCESS) {
+ auto record = PublishService();
+
+ auto service = app_service_manager_.ActiveServiceForType(kServiceType);
+
+ ASSERT_FALSE(service == NULL);
+ EXPECT_EQ(record, service->record);
+ EXPECT_EQ(kConnectionKey, service->connection_key);
+ EXPECT_TRUE(service->mobile_service);
+}
+
+TEST_F(AppServiceManagerTest, EmbeddedServiceForType_SUCCESS) {
+ auto record = PublishService(kHMIConnectionKey);
+
+ auto service = app_service_manager_.EmbeddedServiceForType(kServiceType);
+
+ ASSERT_FALSE(service == NULL);
+ EXPECT_EQ(record, service->record);
+ EXPECT_FALSE(service->mobile_service);
+}
+
+TEST_F(AppServiceManagerTest, FindServiceByID_SUCCESS) {
+ auto record = PublishService();
+
+ std::string service_id = record[am::strings::service_id].asString();
+ auto service = app_service_manager_.FindServiceByID(service_id);
+
+ ASSERT_FALSE(service == NULL);
+ EXPECT_EQ(record, service->record);
+ EXPECT_EQ(kConnectionKey, service->connection_key);
+ EXPECT_TRUE(service->mobile_service);
+}
+
+TEST_F(AppServiceManagerTest, GetAllServiceRecords_OneService_SUCCESS) {
+ auto record = PublishService();
+
+ auto records = app_service_manager_.GetAllServiceRecords();
+
+ ASSERT_EQ(1u, records.size());
+ EXPECT_EQ(record, records[0]);
+}
+
+TEST_F(AppServiceManagerTest, GetActiveServices_OneService_SUCCESS) {
+ auto record = PublishService();
+
+ auto services = app_service_manager_.GetActiveServices();
+
+ ASSERT_EQ(1u, services.size());
+ EXPECT_EQ(record, services[0].record);
+ EXPECT_EQ(kConnectionKey, services[0].connection_key);
+ EXPECT_TRUE(services[0].mobile_service);
+}
+
+} // namespace application_manager_test
+} // namespace components
+} // namespace test \ No newline at end of file
diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc
index f27e252142..e88d10d3e0 100644
--- a/src/components/application_manager/test/application_manager_impl_test.cc
+++ b/src/components/application_manager/test/application_manager_impl_test.cc
@@ -42,6 +42,7 @@
#include "application_manager/mock_application.h"
#include "application_manager/mock_application_manager_settings.h"
#include "application_manager/mock_resumption_data.h"
+#include "application_manager/mock_app_service_manager.h"
#include "application_manager/mock_rpc_plugin_manager.h"
#include "application_manager/mock_rpc_service.h"
#include "application_manager/resumption/resume_ctrl_impl.h"
@@ -115,6 +116,8 @@ class ApplicationManagerImplTest : public ::testing::Test {
std::make_shared<NiceMock<resumption_test::MockResumptionData> >(
mock_app_mngr_))
, mock_rpc_service_(new MockRPCService)
+ , mock_app_service_manager_(
+ new MockAppServiceManager(mock_app_mngr_, mock_last_state_))
, mock_message_helper_(
application_manager::MockMessageHelper::message_helper_mock())
@@ -139,11 +142,13 @@ class ApplicationManagerImplTest : public ::testing::Test {
app_manager_impl_->resume_controller().set_resumption_storage(
mock_storage_);
app_manager_impl_->set_connection_handler(&mock_connection_handler_);
+ ON_CALL(*mock_app_service_manager_, UnpublishServices(_))
+ .WillByDefault(Return());
+ ON_CALL(*mock_app_service_manager_, OnAppActivated(_))
+ .WillByDefault(Return());
+ app_manager_impl_->SetAppServiceManager(mock_app_service_manager_);
Json::Value empty;
ON_CALL(mock_last_state_, get_dictionary()).WillByDefault(ReturnRef(empty));
- std::unique_ptr<AppServiceManager> app_service_manager_ptr(
- new AppServiceManager(*app_manager_impl_, mock_last_state_));
- app_manager_impl_->SetAppServiceManager(app_service_manager_ptr);
}
void CreateAppManager() {
@@ -221,6 +226,7 @@ class ApplicationManagerImplTest : public ::testing::Test {
NiceMock<MockApplicationManagerSettings> mock_application_manager_settings_;
application_manager_test::MockApplicationManager mock_app_mngr_;
std::unique_ptr<am::ApplicationManagerImpl> app_manager_impl_;
+ MockAppServiceManager* mock_app_service_manager_;
application_manager::MockMessageHelper* mock_message_helper_;
std::shared_ptr<MockApplication> mock_app_ptr_;
diff --git a/src/components/application_manager/test/commands/command_impl_test.cc b/src/components/application_manager/test/commands/command_impl_test.cc
index 222f16ef46..53e8534c2b 100644
--- a/src/components/application_manager/test/commands/command_impl_test.cc
+++ b/src/components/application_manager/test/commands/command_impl_test.cc
@@ -85,11 +85,12 @@ class CommandImplTest : public CommandsTest<CommandsTestMocks::kIsNice> {
using CommandImpl::ReplaceMobileWithHMIAppId;
using CommandImpl::ReplaceHMIWithMobileAppId;
- UnwrappedCommandImpl(const MessageSharedPtr& message,
- ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler)
+ UnwrappedCommandImpl(
+ const MessageSharedPtr& message,
+ ApplicationManager& application_manager,
+ application_manager::rpc_service::RPCService& rpc_service,
+ application_manager::HMICapabilities& hmi_capabilities,
+ policy::PolicyHandlerInterface& policy_handler)
: CommandImpl(message,
application_manager,
rpc_service,
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
new file mode 100644
index 0000000000..311268689a
--- /dev/null
+++ b/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h
@@ -0,0 +1,93 @@
+/*
+ Copyright (c) 2019, Ford Motor Company, Livio
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the the copyright holders nor the names of their
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APP_SERVICE_MANAGER_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APP_SERVICE_MANAGER_H_
+
+#include <gmock/gmock.h>
+#include "application_manager/app_service_manager.h"
+
+namespace test {
+namespace components {
+namespace application_manager_test {
+
+class MockAppServiceManager : public application_manager::AppServiceManager {
+ public:
+ MockAppServiceManager(application_manager::ApplicationManager& app_manager,
+ resumption::LastState& last_state)
+ : application_manager::AppServiceManager(app_manager, last_state) {}
+ MOCK_METHOD3(
+ PublishAppService,
+ smart_objects::SmartObject(const smart_objects::SmartObject& manifest,
+ const bool mobile_service,
+ const uint32_t connection_key));
+ MOCK_METHOD1(UnpublishAppService, bool(const std::string service_id));
+ MOCK_METHOD1(UnpublishServices, void(const uint32_t connection_key));
+ MOCK_METHOD1(OnAppActivated,
+ void(application_manager::ApplicationConstSharedPtr app));
+ MOCK_METHOD1(SetDefaultService, bool(const std::string service_id));
+ MOCK_METHOD1(RemoveDefaultService, bool(const std::string service_id));
+ MOCK_METHOD1(ActivateAppService, bool(const std::string service_id));
+ MOCK_METHOD1(DeactivateAppService, bool(const std::string service_id));
+ MOCK_METHOD0(GetAllServiceRecords, std::vector<smart_objects::SmartObject>());
+ MOCK_METHOD0(GetActiveServices,
+ std::vector<application_manager::AppService>());
+ MOCK_METHOD4(GetProviderByType,
+ void(const std::string& service_type,
+ const bool mobile_consumer,
+ application_manager::ApplicationSharedPtr& app,
+ bool& hmi_service));
+ MOCK_METHOD4(GetProviderByID,
+ void(const std::string& service_id,
+ const bool mobile_consumer,
+ application_manager::ApplicationSharedPtr& app,
+ bool& hmi_service));
+ MOCK_METHOD1(
+ ActiveServiceForType,
+ application_manager::AppService*(const std::string service_type));
+ MOCK_METHOD1(
+ EmbeddedServiceForType,
+ application_manager::AppService*(const std::string service_type));
+ MOCK_METHOD1(FindServiceByID,
+ application_manager::AppService*(const std::string service_id));
+ MOCK_METHOD2(SetServicePublished,
+ void(const std::string service_id,
+ const bool service_published));
+ MOCK_METHOD1(UpdateNavigationCapabilities,
+ bool(smart_objects::SmartObject& out_params));
+};
+
+} // namespace application_manager_test
+} // namespace components
+} // namespace test
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APP_SERVICE_MANAGER_H_
diff --git a/src/components/application_manager/test/message_helper/message_helper_test.cc b/src/components/application_manager/test/message_helper/message_helper_test.cc
index f43062dc53..92be221ec9 100644
--- a/src/components/application_manager/test/message_helper/message_helper_test.cc
+++ b/src/components/application_manager/test/message_helper/message_helper_test.cc
@@ -42,7 +42,7 @@
#include "utils/custom_string.h"
#include "utils/lock.h"
#include "policy/mock_policy_settings.h"
-#include "application_manager/policies/policy_handler.h"
+#include "application_manager/commands/command_impl.h"
#include "application_manager/mock_application_manager.h"
#include "application_manager/mock_rpc_service.h"
#include "application_manager/event_engine/event_dispatcher.h"
diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h
index 97140a18f1..e8f646c1e5 100644
--- a/src/components/include/application_manager/application_manager.h
+++ b/src/components/include/application_manager/application_manager.h
@@ -51,7 +51,7 @@
#include "application_manager/hmi_interfaces.h"
#include "policy/policy_types.h"
#include "application_manager/plugin_manager/rpc_plugin_manager.h"
-#include "application_manager/app_service_manager.h"
+
namespace resumption {
class LastState;
}
@@ -90,6 +90,7 @@ class RPCHandler;
}
class Application;
+class AppServiceManager;
class StateControllerImpl;
struct CommandParametersPermissions;
using policy::RPCParams;
diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h
index 4f09d2c2f9..679e6ccfb3 100644
--- a/src/components/include/test/application_manager/mock_application_manager.h
+++ b/src/components/include/test/application_manager/mock_application_manager.h
@@ -39,21 +39,24 @@
#include "gmock/gmock.h"
-#include "application_manager/application_manager.h"
-#include "application_manager/application_manager_impl.h"
+#include "application_manager/app_launch/app_launch_ctrl.h"
+#include "application_manager/app_service_manager.h"
#include "application_manager/application_manager_settings.h"
+#include "application_manager/command_factory.h"
#include "application_manager/commands/command.h"
+#include "application_manager/event_engine/event_dispatcher.h"
#include "application_manager/hmi_capabilities.h"
-#include "application_manager/state_controller.h"
#include "application_manager/message.h"
-#include "resumption/last_state.h"
-#include "interfaces/MOBILE_API.h"
-#include "application_manager/app_launch/app_launch_ctrl.h"
-#include "application_manager/event_engine/event_dispatcher.h"
+#include "application_manager/message_helper.h"
+#include "application_manager/plugin_manager/rpc_plugin_manager.h"
+#include "application_manager/resumption/resume_ctrl.h"
+#include "application_manager/rpc_handler.h"
+#include "application_manager/rpc_service.h"
#include "application_manager/state_controller.h"
+#include "interfaces/HMI_API.h"
+#include "interfaces/MOBILE_API.h"
+#include "resumption/last_state.h"
#include "smart_objects/smart_object.h"
-#include "application_manager/plugin_manager/rpc_plugin_manager.h"
-#include "application_manager/command_factory.h"
namespace test {
namespace components {
diff --git a/src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h b/src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h
index ff7b9da9d6..0d31573d8e 100644
--- a/src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h
+++ b/src/components/telemetry_monitor/include/telemetry_monitor/telemetry_monitor.h
@@ -40,7 +40,7 @@
#include "utils/threads/thread_delegate.h"
#include "telemetry_monitor/metric_wrapper.h"
#include "telemetry_monitor/application_manager_observer.h"
-#include "application_manager/application_manager_impl.h"
+#include "application_manager/application_manager.h"
#include "telemetry_monitor/transport_manager_observer.h"
#include "transport_manager/transport_manager_impl.h"
#include "protocol_handler_observer.h"