summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJacob Keeler <jacob.keeler@livioradio.com>2019-02-23 12:35:11 -0500
committerGitHub <noreply@github.com>2019-02-23 12:35:11 -0500
commit2a26de5bc0f3a357e28e6a83c9a7d439d2673431 (patch)
tree21475ca531caf403cc20102ab31fdcdb32c4ae1c /src
parenta4011490d9aa4606d6d835690bc8703c4375526b (diff)
downloadsdl_core-2a26de5bc0f3a357e28e6a83c9a7d439d2673431.tar.gz
App Service Activation Logic (#2809)
* Add AS.AppServiceActivation and AS.GetAppServiceRecords RPCs * Initialize AppServiceManager in Application manager tests * Moved create notification functions to message helper class * Fix style * Removed setServiceActive function * Add OnSystemCapabilityUpdated triggers to AppServiceManager Includes refactoring of OnSystemCapabilityUpdated notification classes. * Remove servicesSupported parameter * Update SystemCapability structs with new revisions * Include additional cases for activation 1. Services are activated if their publishing app is in the foreground. 2. If a service is deactivated without another being activated, the embedded service becomes active if available. * Fixed error from previous commit and addressed style comments * Addressed review comments * Address review comments * Fix LastState usage in app service manager * Addressed review comments and removed extra debug statements * Fix style
Diffstat (limited to 'src')
-rw-r--r--src/components/application_manager/include/application_manager/app_service_manager.h21
-rw-r--r--src/components/application_manager/include/application_manager/message_helper.h11
-rw-r--r--src/components/application_manager/include/application_manager/smart_object_keys.h3
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_app_service_activation_request.h80
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_app_service_activation_response.h80
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_records_request.h80
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_records_response.h80
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc14
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_request.cc87
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_response.cc59
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc88
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_response.cc59
-rw-r--r--src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc5
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc80
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc22
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc95
-rw-r--r--src/components/application_manager/src/app_service_manager.cc285
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc5
-rw-r--r--src/components/application_manager/src/message_helper/message_helper.cc46
-rw-r--r--src/components/application_manager/src/smart_object_keys.cc3
-rw-r--r--src/components/application_manager/test/application_manager_impl_test.cc12
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_message_helper.h11
-rw-r--r--src/components/application_manager/test/mock_message_helper.cc21
-rw-r--r--src/components/interfaces/HMI_API.xml36
24 files changed, 1142 insertions, 141 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 c1f8a52370..253ed2a439 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
@@ -33,8 +33,14 @@
#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_SERVICE_MANAGER_H_
#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_SERVICE_MANAGER_H_
+#include "application_manager/application.h"
+#include "interfaces/MOBILE_API.h"
#include "smart_objects/smart_object.h"
+namespace resumption {
+class LastState;
+}
+
namespace application_manager {
struct AppService {
@@ -55,7 +61,8 @@ class AppServiceManager {
* @brief Class constructor
* @param app_manager
*/
- AppServiceManager(ApplicationManager& app_manager);
+ AppServiceManager(ApplicationManager& app_manager,
+ resumption::LastState& last_state);
/**
* @brief Class destructor
@@ -77,6 +84,8 @@ class AppServiceManager {
*/
bool UnpublishAppService(const std::string service_id);
+ void OnAppActivated(ApplicationConstSharedPtr app);
+
/**
* @brief TODO
* @param connection_key
@@ -124,13 +133,23 @@ class AppServiceManager {
std::pair<std::string, AppService> ActiveServiceByType(
std::string service_type);
+ std::pair<std::string, AppService> EmbeddedServiceForType(
+ std::string service_type);
+
std::pair<std::string, AppService> FindServiceByName(std::string name);
std::string DefaultServiceByType(std::string service_type);
private:
ApplicationManager& app_manager_;
+ resumption::LastState& last_state_;
std::map<std::string, AppService> published_services_;
+
+ void BroadcastAppServiceUpdate(smart_objects::SmartObject& msg_params);
+ void AppServiceUpdated(
+ const smart_objects::SmartObject& service_record,
+ const mobile_apis::ServiceUpdateReason::eType update_reason,
+ smart_objects::SmartObject& msg_params);
};
} // namespace application_manager
diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h
index 0487355056..fd16d57740 100644
--- a/src/components/application_manager/include/application_manager/message_helper.h
+++ b/src/components/application_manager/include/application_manager/message_helper.h
@@ -878,15 +878,8 @@ class MessageHelper {
static smart_objects::SmartObjectSPtr CreateMessageForHMI(
hmi_apis::messageType::eType message_type, const uint32_t correlation_id);
- static smart_objects::SmartObject CreateMobileSystemCapabilityNotification(
- std::vector<smart_objects::SmartObject>& all_services,
- const std::string service_id,
- mobile_apis::ServiceUpdateReason::eType update_reason);
-
- static smart_objects::SmartObject CreateHMISystemCapabilityNotification(
- std::vector<smart_objects::SmartObject>& all_services,
- const std::string service_id,
- mobile_apis::ServiceUpdateReason::eType update_reason);
+ static smart_objects::SmartObject CreateAppServiceCapabilities(
+ std::vector<smart_objects::SmartObject>& all_services);
private:
/**
diff --git a/src/components/application_manager/include/application_manager/smart_object_keys.h b/src/components/application_manager/include/application_manager/smart_object_keys.h
index af334d5e97..615b8ab767 100644
--- a/src/components/application_manager/include/application_manager/smart_object_keys.h
+++ b/src/components/application_manager/include/application_manager/smart_object_keys.h
@@ -321,6 +321,9 @@ extern const char* service_active;
extern const char* app_services;
extern const char* update_reason;
extern const char* updated_app_service_record;
+extern const char* service_records;
+extern const char* activate;
+extern const char* set_as_default;
// resuming
extern const char* application_commands;
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_app_service_activation_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_app_service_activation_request.h
new file mode 100644
index 0000000000..c98979da0f
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_app_service_activation_request.h
@@ -0,0 +1,80 @@
+/*
+ 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_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_APP_SERVICE_ACTIVATION_REQUEST_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_APP_SERVICE_ACTIVATION_REQUEST_H_
+
+#include "app_service_rpc_plugin/app_service_rpc_plugin.h"
+#include "application_manager/commands/request_from_hmi.h"
+
+namespace app_service_rpc_plugin {
+namespace app_mngr = application_manager;
+
+namespace commands {
+
+/**
+ * @brief ASAppServiceActivationRequest command class
+ **/
+class ASAppServiceActivationRequest
+ : public app_mngr::commands::RequestFromHMI {
+ public:
+ /**
+ * @brief ASAppServiceActivationRequest class constructor
+ *
+ * @param message Incoming SmartObject message
+ **/
+ ASAppServiceActivationRequest(
+ const app_mngr::commands::MessageSharedPtr& message,
+ app_mngr::ApplicationManager& application_manager,
+ app_mngr::rpc_service::RPCService& rpc_service,
+ app_mngr::HMICapabilities& hmi_capabilities,
+ policy::PolicyHandlerInterface& policy_handle);
+
+ /**
+ * @brief ASAppServiceActivationRequest class destructor
+ **/
+ virtual ~ASAppServiceActivationRequest();
+
+ /**
+ * @brief Execute command
+ **/
+ virtual void Run();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ASAppServiceActivationRequest);
+};
+
+} // namespace commands
+
+} // namespace app_service_rpc_plugin
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_APP_SERVICE_ACTIVATION_REQUEST_H_
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_app_service_activation_response.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_app_service_activation_response.h
new file mode 100644
index 0000000000..68b77cb7e3
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_app_service_activation_response.h
@@ -0,0 +1,80 @@
+/*
+ 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_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_APP_SERVICE_ACTIVATION_RESPONSE_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_APP_SERVICE_ACTIVATION_RESPONSE_H_
+
+#include "app_service_rpc_plugin/app_service_rpc_plugin.h"
+#include "application_manager/commands/response_to_hmi.h"
+
+namespace app_service_rpc_plugin {
+namespace app_mngr = application_manager;
+
+namespace commands {
+
+/**
+ * @brief ASAppServiceActivationResponse command class
+ **/
+class ASAppServiceActivationResponse
+ : public app_mngr::commands::ResponseToHMI {
+ public:
+ /**
+ * @brief ASAppServiceActivationResponse class constructor
+ *
+ * @param message Incoming SmartObject message
+ **/
+ ASAppServiceActivationResponse(
+ const app_mngr::commands::MessageSharedPtr& message,
+ app_mngr::ApplicationManager& application_manager,
+ app_mngr::rpc_service::RPCService& rpc_service,
+ app_mngr::HMICapabilities& hmi_capabilities,
+ policy::PolicyHandlerInterface& policy_handle);
+
+ /**
+ * @brief ASAppServiceActivationResponse class destructor
+ **/
+ virtual ~ASAppServiceActivationResponse();
+
+ /**
+ * @brief Execute command
+ **/
+ virtual void Run();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ASAppServiceActivationResponse);
+};
+
+} // namespace commands
+
+} // namespace app_service_rpc_plugin
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_APP_SERVICE_ACTIVATION_RESPONSE_H_
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_records_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_records_request.h
new file mode 100644
index 0000000000..79ea0922a8
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_records_request.h
@@ -0,0 +1,80 @@
+/*
+ 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_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_RECORDS_REQUEST_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_RECORDS_REQUEST_H_
+
+#include "app_service_rpc_plugin/app_service_rpc_plugin.h"
+#include "application_manager/commands/request_from_hmi.h"
+
+namespace app_service_rpc_plugin {
+namespace app_mngr = application_manager;
+
+namespace commands {
+
+/**
+ * @brief ASGetAppServiceRecordsRequest command class
+ **/
+class ASGetAppServiceRecordsRequest
+ : public app_mngr::commands::RequestFromHMI {
+ public:
+ /**
+ * @brief ASGetAppServiceRecordsRequest class constructor
+ *
+ * @param message Incoming SmartObject message
+ **/
+ ASGetAppServiceRecordsRequest(
+ const app_mngr::commands::MessageSharedPtr& message,
+ app_mngr::ApplicationManager& application_manager,
+ app_mngr::rpc_service::RPCService& rpc_service,
+ app_mngr::HMICapabilities& hmi_capabilities,
+ policy::PolicyHandlerInterface& policy_handle);
+
+ /**
+ * @brief ASGetAppServiceRecordsRequest class destructor
+ **/
+ virtual ~ASGetAppServiceRecordsRequest();
+
+ /**
+ * @brief Execute command
+ **/
+ virtual void Run();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ASGetAppServiceRecordsRequest);
+};
+
+} // namespace commands
+
+} // namespace app_service_rpc_plugin
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_RECORDS_REQUEST_H_
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_records_response.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_records_response.h
new file mode 100644
index 0000000000..6db24132af
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_records_response.h
@@ -0,0 +1,80 @@
+/*
+ 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_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_RECORDS_RESPONSE_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_RECORDS_RESPONSE_H_
+
+#include "app_service_rpc_plugin/app_service_rpc_plugin.h"
+#include "application_manager/commands/response_to_hmi.h"
+
+namespace app_service_rpc_plugin {
+namespace app_mngr = application_manager;
+
+namespace commands {
+
+/**
+ * @brief ASGetAppServiceRecordsResponse command class
+ **/
+class ASGetAppServiceRecordsResponse
+ : public app_mngr::commands::ResponseToHMI {
+ public:
+ /**
+ * @brief ASGetAppServiceRecordsResponse class constructor
+ *
+ * @param message Incoming SmartObject message
+ **/
+ ASGetAppServiceRecordsResponse(
+ const app_mngr::commands::MessageSharedPtr& message,
+ app_mngr::ApplicationManager& application_manager,
+ app_mngr::rpc_service::RPCService& rpc_service,
+ app_mngr::HMICapabilities& hmi_capabilities,
+ policy::PolicyHandlerInterface& policy_handle);
+
+ /**
+ * @brief ASGetAppServiceRecordsResponse class destructor
+ **/
+ virtual ~ASGetAppServiceRecordsResponse();
+
+ /**
+ * @brief Execute command
+ **/
+ virtual void Run();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ASGetAppServiceRecordsResponse);
+};
+
+} // namespace commands
+
+} // namespace app_service_rpc_plugin
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_GET_APP_SERVICE_RECORDS_RESPONSE_H_
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc
index e741d7bfd4..7afc04c8e9 100644
--- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc
@@ -34,6 +34,10 @@
#include "application_manager/message.h"
#include "interfaces/HMI_API.h"
+#include "app_service_rpc_plugin/commands/hmi/as_app_service_activation_request.h"
+#include "app_service_rpc_plugin/commands/hmi/as_app_service_activation_response.h"
+#include "app_service_rpc_plugin/commands/hmi/as_get_app_service_records_request.h"
+#include "app_service_rpc_plugin/commands/hmi/as_get_app_service_records_response.h"
#include "app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h"
#include "app_service_rpc_plugin/commands/hmi/as_publish_app_service_response.h"
#include "app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h"
@@ -111,6 +115,16 @@ app_mngr::CommandCreator& AppServiceHmiCommandFactory::buildCommandCreator(
commands::OnASAppServiceDataNotificationFromHMI>()
: factory
.GetCreator<commands::OnASAppServiceDataNotification>();
+ case hmi_apis::FunctionID::AppService_GetAppServiceRecords:
+ return hmi_apis::messageType::request == message_type
+ ? factory.GetCreator<commands::ASGetAppServiceRecordsRequest>()
+ : factory
+ .GetCreator<commands::ASGetAppServiceRecordsResponse>();
+ case hmi_apis::FunctionID::AppService_AppServiceActivation:
+ return hmi_apis::messageType::request == message_type
+ ? factory.GetCreator<commands::ASAppServiceActivationRequest>()
+ : factory
+ .GetCreator<commands::ASAppServiceActivationResponse>();
default:
LOG4CXX_WARN(logger_, "Unsupported function_id: " << function_id);
return factory.GetCreator<app_mngr::InvalidCommand>();
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
new file mode 100644
index 0000000000..7c32d9bbe1
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_request.cc
@@ -0,0 +1,87 @@
+/*
+ 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.
+ */
+
+#include "app_service_rpc_plugin/commands/hmi/as_app_service_activation_request.h"
+
+namespace app_service_rpc_plugin {
+using namespace application_manager;
+namespace commands {
+
+ASAppServiceActivationRequest::ASAppServiceActivationRequest(
+ const application_manager::commands::MessageSharedPtr& message,
+ ApplicationManager& application_manager,
+ app_mngr::rpc_service::RPCService& rpc_service,
+ app_mngr::HMICapabilities& hmi_capabilities,
+ policy::PolicyHandlerInterface& policy_handler)
+ : RequestFromHMI(message,
+ application_manager,
+ rpc_service,
+ hmi_capabilities,
+ policy_handler) {}
+
+ASAppServiceActivationRequest::~ASAppServiceActivationRequest() {}
+
+void ASAppServiceActivationRequest::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ AppServiceManager& service_manager =
+ application_manager_.GetAppServiceManager();
+ smart_objects::SmartObject params = (*message_)[strings::msg_params];
+ smart_objects::SmartObject response_params(smart_objects::SmartType_Map);
+ std::string service_id = params[strings::service_id].asString();
+ response_params[strings::service_id] = service_id;
+ if (params[strings::activate].asBool()) {
+ response_params[strings::activate] =
+ service_manager.ActivateAppService(service_id);
+ } else {
+ service_manager.DeactivateAppService(service_id);
+ response_params[strings::activate] = false;
+ }
+
+ if (params.keyExists(strings::set_as_default)) {
+ if (params[strings::set_as_default].asBool()) {
+ response_params[strings::set_as_default] =
+ service_manager.SetDefaultService(service_id);
+ } else {
+ service_manager.RemoveDefaultService(service_id);
+ response_params[strings::set_as_default] = false;
+ }
+ }
+
+ SendResponse(true,
+ (*message_)[strings::params][strings::correlation_id].asUInt(),
+ hmi_apis::FunctionID::AppService_AppServiceActivation,
+ hmi_apis::Common_Result::SUCCESS,
+ &response_params);
+}
+
+} // namespace commands
+} // namespace app_service_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_response.cc
new file mode 100644
index 0000000000..c77d3ed381
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_app_service_activation_response.cc
@@ -0,0 +1,59 @@
+/*
+ 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.
+ */
+
+#include "app_service_rpc_plugin/commands/hmi/as_app_service_activation_response.h"
+
+namespace app_service_rpc_plugin {
+using namespace application_manager;
+namespace commands {
+
+ASAppServiceActivationResponse::ASAppServiceActivationResponse(
+ const application_manager::commands::MessageSharedPtr& message,
+ ApplicationManager& application_manager,
+ app_mngr::rpc_service::RPCService& rpc_service,
+ app_mngr::HMICapabilities& hmi_capabilities,
+ policy::PolicyHandlerInterface& policy_handler)
+ : ResponseToHMI(message,
+ application_manager,
+ rpc_service,
+ hmi_capabilities,
+ policy_handler) {}
+
+ASAppServiceActivationResponse::~ASAppServiceActivationResponse() {}
+
+void ASAppServiceActivationResponse::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ rpc_service_.SendMessageToHMI(message_);
+}
+
+} // namespace commands
+} // namespace app_service_rpc_plugin
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
new file mode 100644
index 0000000000..1131448d2f
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_request.cc
@@ -0,0 +1,88 @@
+/*
+ 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.
+ */
+
+#include "app_service_rpc_plugin/commands/hmi/as_get_app_service_records_request.h"
+
+namespace app_service_rpc_plugin {
+using namespace application_manager;
+namespace commands {
+
+ASGetAppServiceRecordsRequest::ASGetAppServiceRecordsRequest(
+ const application_manager::commands::MessageSharedPtr& message,
+ ApplicationManager& application_manager,
+ app_mngr::rpc_service::RPCService& rpc_service,
+ app_mngr::HMICapabilities& hmi_capabilities,
+ policy::PolicyHandlerInterface& policy_handler)
+ : RequestFromHMI(message,
+ application_manager,
+ rpc_service,
+ hmi_capabilities,
+ policy_handler) {}
+
+ASGetAppServiceRecordsRequest::~ASGetAppServiceRecordsRequest() {}
+
+void ASGetAppServiceRecordsRequest::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ std::string type;
+ if ((*message_)[strings::msg_params].keyExists(strings::service_type)) {
+ type = (*message_)[strings::msg_params][strings::service_type].asString();
+ }
+ smart_objects::SmartObject response_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ smart_objects::SmartObject records =
+ smart_objects::SmartObject(smart_objects::SmartType_Array);
+ std::vector<smart_objects::SmartObject> service_records =
+ application_manager_.GetAppServiceManager().GetAllServices();
+
+ int index = 0;
+ for (auto& record : service_records) {
+ if (!type.empty() &&
+ record[strings::service_manifest][strings::service_type].asString() !=
+ type) {
+ continue;
+ }
+ records[index] = record;
+ index++;
+ }
+
+ if (!records.empty()) {
+ response_params[strings::service_records] = records;
+ }
+ SendResponse(true,
+ (*message_)[strings::params][strings::correlation_id].asUInt(),
+ hmi_apis::FunctionID::AppService_GetAppServiceRecords,
+ hmi_apis::Common_Result::SUCCESS,
+ &response_params);
+}
+
+} // namespace commands
+} // namespace app_service_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_response.cc
new file mode 100644
index 0000000000..0479aa8d31
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_records_response.cc
@@ -0,0 +1,59 @@
+/*
+ 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.
+ */
+
+#include "app_service_rpc_plugin/commands/hmi/as_get_app_service_records_response.h"
+
+namespace app_service_rpc_plugin {
+using namespace application_manager;
+namespace commands {
+
+ASGetAppServiceRecordsResponse::ASGetAppServiceRecordsResponse(
+ const application_manager::commands::MessageSharedPtr& message,
+ ApplicationManager& application_manager,
+ app_mngr::rpc_service::RPCService& rpc_service,
+ app_mngr::HMICapabilities& hmi_capabilities,
+ policy::PolicyHandlerInterface& policy_handler)
+ : ResponseToHMI(message,
+ application_manager,
+ rpc_service,
+ hmi_capabilities,
+ policy_handler) {}
+
+ASGetAppServiceRecordsResponse::~ASGetAppServiceRecordsResponse() {}
+
+void ASGetAppServiceRecordsResponse::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ rpc_service_.SendMessageToHMI(message_);
+}
+
+} // namespace commands
+} // namespace app_service_rpc_plugin
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 96f17f732a..ab82bf77dd 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
@@ -99,6 +99,11 @@ void PublishAppServiceRequest::Run() {
smart_objects::SmartObject service_record =
application_manager_.GetAppServiceManager().PublishAppService(
manifest, true, connection_key());
+ if (app->is_foreground()) {
+ // Service should be activated if app is in the foreground
+ application_manager_.GetAppServiceManager().ActivateAppService(
+ service_record[strings::service_id].asString());
+ }
response_params[strings::app_service_record] = service_record;
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 3f8dcf08f6..d0c33e76d9 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
@@ -32,6 +32,7 @@
#include "sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification.h"
#include "application_manager/application_impl.h"
+#include "application_manager/message_helper.h"
#include "application_manager/rpc_service.h"
#include "interfaces/HMI_API.h"
@@ -60,6 +61,85 @@ void OnBCSystemCapabilityUpdatedNotification::Run() {
LOG4CXX_DEBUG(logger_,
"Sending BasicCommunication.OnSystemCapabilityUpdated "
"Notification to HMI");
+
+ smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params];
+
+ hmi_apis::Common_SystemCapabilityType::eType system_capability_type =
+ static_cast<hmi_apis::Common_SystemCapabilityType::eType>(
+ msg_params[strings::system_capability]
+ [strings::system_capability_type].asInt());
+ switch (system_capability_type) {
+ case hmi_apis::Common_SystemCapabilityType::NAVIGATION: {
+ if (hmi_capabilities_.navigation_capability()) {
+ msg_params[strings::system_capability][strings::navigation_capability] =
+ *hmi_capabilities_.navigation_capability();
+ }
+ break;
+ }
+ case hmi_apis::Common_SystemCapabilityType::PHONE_CALL: {
+ if (hmi_capabilities_.phone_capability()) {
+ msg_params[strings::system_capability][strings::phone_capability] =
+ *hmi_capabilities_.phone_capability();
+ }
+ break;
+ }
+ case hmi_apis::Common_SystemCapabilityType::REMOTE_CONTROL: {
+ if (!hmi_capabilities_.is_rc_cooperating()) {
+ return;
+ }
+ if (hmi_capabilities_.rc_capability()) {
+ msg_params[strings::system_capability][strings::rc_capability] =
+ *hmi_capabilities_.rc_capability();
+ }
+ break;
+ }
+ case hmi_apis::Common_SystemCapabilityType::VIDEO_STREAMING:
+ if (hmi_capabilities_.video_streaming_capability()) {
+ msg_params[strings::system_capability]
+ [strings::video_streaming_capability] =
+ *hmi_capabilities_.video_streaming_capability();
+ }
+ break;
+ case hmi_apis::Common_SystemCapabilityType::APP_SERVICES: {
+ auto all_services =
+ application_manager_.GetAppServiceManager().GetAllServices();
+ auto app_service_caps =
+ MessageHelper::CreateAppServiceCapabilities(all_services);
+
+ smart_objects::SmartArray* app_services =
+ app_service_caps[strings::app_services].asArray();
+ smart_objects::SmartObject& updated_capabilities =
+ msg_params[strings::system_capability]
+ [strings::app_services_capabilities][strings::app_services];
+ for (size_t i = 0; i < updated_capabilities.length(); i++) {
+ std::string service_id =
+ updated_capabilities[i][strings::updated_app_service_record]
+ [strings::service_id].asString();
+ auto matching_service_predicate = [&service_id](
+ const smart_objects::SmartObject& app_service_capability) {
+ return service_id ==
+ app_service_capability[strings::updated_app_service_record]
+ [strings::service_id].asString();
+ };
+
+ auto it = std::find_if(app_services->begin(),
+ app_services->end(),
+ matching_service_predicate);
+ if (it != app_services->end()) {
+ LOG4CXX_DEBUG(logger_,
+ "Replacing updated record with service_id "
+ << service_id);
+ app_services->erase(it);
+ }
+ app_services->push_back(updated_capabilities[i]);
+ }
+ msg_params[strings::system_capability]
+ [strings::app_services_capabilities] = app_service_caps;
+ break;
+ }
+ default:
+ return;
+ }
SendNotification();
}
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 1449f0e061..b551db0008 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
@@ -132,25 +132,11 @@ void GetSystemCapabilityRequest::Run() {
}
break;
case mobile_apis::SystemCapabilityType::APP_SERVICES: {
- smart_objects::SmartObject app_service_capabilities(
- smart_objects::SmartType_Map);
- smart_objects::SmartObject app_services(smart_objects::SmartType_Array);
-
- std::vector<smart_objects::SmartObject> service_records =
+ auto all_services =
application_manager_.GetAppServiceManager().GetAllServices();
-
- for (auto& record : service_records) {
- smart_objects::SmartObject app_services_capabilities(
- smart_objects::SmartType_Map);
- app_services_capabilities[strings::updated_app_service_record] = record;
- app_services.asArray()->push_back(app_services_capabilities);
- }
-
- app_service_capabilities[strings::app_services] = app_services;
- response_params[strings::system_capability]
- [strings::app_services_capabilities] =
- app_service_capabilities;
-
+ response_params
+ [strings::system_capability][strings::app_services_capabilities] =
+ MessageHelper::CreateAppServiceCapabilities(all_services);
break;
}
default: // Return unsupported resource
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 6a1f0844d9..0745bc08dc 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
@@ -28,10 +28,84 @@ OnSystemCapabilityUpdatedNotification::
void OnSystemCapabilityUpdatedNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- mobile_apis::SystemCapabilityType::eType system_capability_type =
- static_cast<mobile_apis::SystemCapabilityType::eType>(
- (*message_)[strings::msg_params][strings::system_capability]
- [strings::system_capability_type].asInt());
+ smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params];
+ mobile_apis::SystemCapabilityType::eType system_capability_type = static_cast<
+ mobile_apis::SystemCapabilityType::eType>(
+ msg_params[strings::system_capability][strings::system_capability_type]
+ .asInt());
+
+ switch (system_capability_type) {
+ case mobile_apis::SystemCapabilityType::NAVIGATION: {
+ if (hmi_capabilities_.navigation_capability()) {
+ msg_params[strings::system_capability][strings::navigation_capability] =
+ *hmi_capabilities_.navigation_capability();
+ }
+ break;
+ }
+ case mobile_apis::SystemCapabilityType::PHONE_CALL: {
+ if (hmi_capabilities_.phone_capability()) {
+ msg_params[strings::system_capability][strings::phone_capability] =
+ *hmi_capabilities_.phone_capability();
+ }
+ break;
+ }
+ case mobile_apis::SystemCapabilityType::REMOTE_CONTROL: {
+ if (!hmi_capabilities_.is_rc_cooperating()) {
+ return;
+ }
+ if (hmi_capabilities_.rc_capability()) {
+ msg_params[strings::system_capability][strings::rc_capability] =
+ *hmi_capabilities_.rc_capability();
+ }
+ break;
+ }
+ case mobile_apis::SystemCapabilityType::VIDEO_STREAMING:
+ if (hmi_capabilities_.video_streaming_capability()) {
+ msg_params[strings::system_capability]
+ [strings::video_streaming_capability] =
+ *hmi_capabilities_.video_streaming_capability();
+ }
+ break;
+ case mobile_apis::SystemCapabilityType::APP_SERVICES: {
+ auto all_services =
+ application_manager_.GetAppServiceManager().GetAllServices();
+ auto app_service_caps =
+ MessageHelper::CreateAppServiceCapabilities(all_services);
+
+ smart_objects::SmartArray* app_services =
+ app_service_caps[strings::app_services].asArray();
+ smart_objects::SmartObject& updated_capabilities =
+ msg_params[strings::system_capability]
+ [strings::app_services_capabilities][strings::app_services];
+ for (size_t i = 0; i < updated_capabilities.length(); i++) {
+ std::string service_id =
+ updated_capabilities[i][strings::updated_app_service_record]
+ [strings::service_id].asString();
+ auto matching_service_predicate = [&service_id](
+ const smart_objects::SmartObject& app_service_capability) {
+ return service_id ==
+ app_service_capability[strings::updated_app_service_record]
+ [strings::service_id].asString();
+ };
+
+ auto it = std::find_if(app_services->begin(),
+ app_services->end(),
+ matching_service_predicate);
+ if (it != app_services->end()) {
+ LOG4CXX_DEBUG(logger_,
+ "Replacing updated record with service_id "
+ << service_id);
+ app_services->erase(it);
+ }
+ app_services->push_back(updated_capabilities[i]);
+ }
+ msg_params[strings::system_capability]
+ [strings::app_services_capabilities] = app_service_caps;
+ break;
+ }
+ default:
+ return;
+ }
const char* capability_type_string;
ns_smart_device_link::ns_smart_objects::EnumConversionHelper<
@@ -56,6 +130,19 @@ void OnSystemCapabilityUpdatedNotification::Run() {
for (; applications.end() != app_it; ++app_it) {
const ApplicationSharedPtr app = *app_it;
+ if (system_capability_type ==
+ mobile_apis::SystemCapabilityType::REMOTE_CONTROL &&
+ !app->is_remote_control_supported()) {
+ LOG4CXX_WARN(
+ logger_,
+ "App with connection key: "
+ << app->app_id()
+ << " was subcribed to REMOTE_CONTROL system capabilities, but "
+ "does not have RC permissions. Unsubscribing");
+ auto& ext = SystemCapabilityAppExtension::ExtractExtension(*app);
+ ext.UnsubscribeFrom(system_capability_type);
+ continue;
+ }
LOG4CXX_INFO(logger_,
"Sending OnSystemCapabilityUpdated " << capability_type_string
<< " application id "
diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc
index 57b319c680..bc9d363839 100644
--- a/src/components/application_manager/src/app_service_manager.cc
+++ b/src/components/application_manager/src/app_service_manager.cc
@@ -43,14 +43,19 @@
#include "application_manager/message_helper.h"
#include "application_manager/smart_object_keys.h"
#include "encryption/hashing.h"
+#include "resumption/last_state.h"
#include "utils/logger.h"
CREATE_LOGGERPTR_GLOBAL(logger_, "AppServiceManager")
namespace application_manager {
-AppServiceManager::AppServiceManager(ApplicationManager& app_manager)
- : app_manager_(app_manager) {}
+const char* kAppServiceSection = "AppServices";
+const char* kDefaults = "defaults";
+
+AppServiceManager::AppServiceManager(ApplicationManager& app_manager,
+ resumption::LastState& last_state)
+ : app_manager_(app_manager), last_state_(last_state) {}
AppServiceManager::~AppServiceManager() {
LOG4CXX_AUTO_TRACE(logger_);
@@ -78,28 +83,31 @@ smart_objects::SmartObject AppServiceManager::PublishAppService(
service_record[strings::service_manifest] = manifest;
service_record[strings::service_id] = service_id;
service_record[strings::service_published] = true;
- service_record[strings::service_active] = true;
+ service_record[strings::service_active] = false;
app_service.record = service_record;
+ std::string service_type = manifest[strings::service_type].asString();
+ Json::Value& dictionary = last_state_.get_dictionary();
+ app_service.default_service =
+ (dictionary[kAppServiceSection][kDefaults][service_type].asString() ==
+ manifest[strings::service_name].asString());
+
published_services_.insert(
std::pair<std::string, AppService>(service_id, app_service));
- auto all_services = GetAllServices();
- smart_objects::SmartObjectSPtr notification =
- std::make_shared<smart_objects::SmartObject>(
- MessageHelper::CreateMobileSystemCapabilityNotification(
- all_services,
- service_id,
- mobile_apis::ServiceUpdateReason::PUBLISHED));
- app_manager_.GetRPCService().ManageMobileCommand(
- notification, commands::Command::CommandSource::SOURCE_SDL);
- smart_objects::SmartObjectSPtr hmi_notification =
- std::make_shared<smart_objects::SmartObject>(
- MessageHelper::CreateHMISystemCapabilityNotification(
- all_services,
- service_id,
- mobile_apis::ServiceUpdateReason::PUBLISHED));
- app_manager_.GetRPCService().ManageHMICommand(hmi_notification);
+ smart_objects::SmartObject msg_params;
+ AppServiceUpdated(
+ service_record, mobile_apis::ServiceUpdateReason::PUBLISHED, msg_params);
+ BroadcastAppServiceUpdate(msg_params);
+
+ // Activate the new service if it is the default for its service type, or if
+ // no service is active of its service type
+ std::pair<std::string, AppService> active_service =
+ ActiveServiceByType(service_type);
+ if (active_service.first.empty() || app_service.default_service) {
+ ActivateAppService(service_id);
+ }
+
return service_record;
}
@@ -114,24 +122,25 @@ bool AppServiceManager::UnpublishAppService(const std::string service_id) {
LOG4CXX_DEBUG(logger_, "Unpublishing app service: " << service_id);
SetServicePublished(service_id, false);
+ smart_objects::SmartObject msg_params;
- auto all_services = GetAllServices();
- smart_objects::SmartObjectSPtr notification =
- std::make_shared<smart_objects::SmartObject>(
- MessageHelper::CreateMobileSystemCapabilityNotification(
- all_services,
- service_id,
- mobile_apis::ServiceUpdateReason::REMOVED));
- app_manager_.GetRPCService().ManageMobileCommand(
- notification, commands::Command::CommandSource::SOURCE_SDL);
- smart_objects::SmartObjectSPtr hmi_notification =
- std::make_shared<smart_objects::SmartObject>(
- MessageHelper::CreateHMISystemCapabilityNotification(
- all_services,
- service_id,
- mobile_apis::ServiceUpdateReason::REMOVED));
- app_manager_.GetRPCService().ManageHMICommand(hmi_notification);
+ auto record = it->second.record;
+ if (record[strings::service_active].asBool()) {
+ record[strings::service_active] = false;
+ // Activate embedded service, if available
+ auto embedded_service = EmbeddedServiceForType(
+ record[strings::service_manifest][strings::service_type].asString());
+ if (!embedded_service.first.empty()) {
+ embedded_service.second.record[strings::service_active] = true;
+ AppServiceUpdated(embedded_service.second.record,
+ mobile_apis::ServiceUpdateReason::ACTIVATED,
+ msg_params);
+ }
+ }
+ AppServiceUpdated(
+ it->second.record, mobile_apis::ServiceUpdateReason::REMOVED, msg_params);
+ BroadcastAppServiceUpdate(msg_params);
published_services_.erase(it);
return true;
@@ -148,6 +157,17 @@ void AppServiceManager::UnpublishServices(const uint32_t connection_key) {
}
}
+void AppServiceManager::OnAppActivated(ApplicationConstSharedPtr app) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ auto it = published_services_.begin();
+ // Activate all services published by the app
+ for (; it != published_services_.end(); ++it) {
+ if (it->second.connection_key == app->app_id()) {
+ ActivateAppService(it->first);
+ }
+ }
+}
+
std::vector<smart_objects::SmartObject> AppServiceManager::GetAllServices() {
LOG4CXX_AUTO_TRACE(logger_);
std::vector<smart_objects::SmartObject> services;
@@ -158,14 +178,123 @@ std::vector<smart_objects::SmartObject> AppServiceManager::GetAllServices() {
return services;
}
-void AppServiceManager::SetServicePublished(const std::string service_id,
- bool service_published) {
+bool AppServiceManager::SetDefaultService(const std::string service_id) {
+ LOG4CXX_AUTO_TRACE(logger_);
auto it = published_services_.find(service_id);
if (it == published_services_.end()) {
- LOG4CXX_ERROR(logger_, "Service id does not exist in published services");
- return;
+ LOG4CXX_ERROR(logger_, "Unable to find published service " << service_id);
+ return false;
}
- it->second.record[strings::service_published] = service_published;
+ AppService& service = it->second;
+
+ std::string service_type =
+ service.record[strings::service_manifest][strings::service_type]
+ .asString();
+ std::string default_service_name = DefaultServiceByType(service_type);
+ if (!default_service_name.empty()) {
+ auto default_service = FindServiceByName(default_service_name);
+ if (!default_service.first.empty()) {
+ default_service.second.default_service = false;
+ }
+ }
+ service.default_service = true;
+
+ Json::Value& dictionary = last_state_.get_dictionary();
+ dictionary[kAppServiceSection][kDefaults][service_type] =
+ service.record[strings::service_manifest][strings::service_name]
+ .asString();
+ return true;
+}
+
+bool AppServiceManager::RemoveDefaultService(const std::string service_id) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ auto it = published_services_.find(service_id);
+ if (it == published_services_.end()) {
+ LOG4CXX_ERROR(logger_, "Unable to find published service " << service_id);
+ return false;
+ }
+
+ AppService& service = it->second;
+ if (!service.default_service) {
+ LOG4CXX_ERROR(logger_, "Service was not default " << service_id);
+ return false;
+ }
+ service.default_service = false;
+
+ std::string service_type =
+ service.record[strings::service_manifest][strings::service_type]
+ .asString();
+ Json::Value& dictionary = last_state_.get_dictionary();
+ dictionary[kAppServiceSection][kDefaults].removeMember(service_type);
+ return true;
+}
+
+bool AppServiceManager::ActivateAppService(const std::string service_id) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ auto it = published_services_.find(service_id);
+ if (it == published_services_.end()) {
+ LOG4CXX_ERROR(logger_, "Unable to find published service " << service_id);
+ return false;
+ }
+
+ smart_objects::SmartObject& service = it->second.record;
+ if (service[strings::service_active].asBool()) {
+ LOG4CXX_DEBUG(logger_, "Service was already active " << service_id);
+ return true;
+ }
+
+ smart_objects::SmartObject msg_params;
+
+ const std::string service_type =
+ service[strings::service_manifest][strings::service_type].asString();
+ auto active_service = ActiveServiceByType(service_type);
+ if (!active_service.first.empty()) {
+ active_service.second.record[strings::service_active] = false;
+ AppServiceUpdated(active_service.second.record,
+ mobile_apis::ServiceUpdateReason::DEACTIVATED,
+ msg_params);
+ }
+ service[strings::service_active] = true;
+ AppServiceUpdated(
+ service, mobile_apis::ServiceUpdateReason::ACTIVATED, msg_params);
+
+ BroadcastAppServiceUpdate(msg_params);
+ return true;
+}
+
+bool AppServiceManager::DeactivateAppService(const std::string service_id) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ auto it = published_services_.find(service_id);
+ if (it == published_services_.end()) {
+ LOG4CXX_ERROR(logger_, "Unable to find published service " << service_id);
+ return false;
+ }
+ smart_objects::SmartObject& service = it->second.record;
+ smart_objects::SmartObject msg_params;
+ bool send_update = false;
+
+ if (service[strings::service_active].asBool()) {
+ service[strings::service_active] = false;
+ AppServiceUpdated(
+ service, mobile_apis::ServiceUpdateReason::DEACTIVATED, msg_params);
+
+ // Activate embedded service, if available
+ const std::string service_type =
+ service[strings::service_manifest][strings::service_type].asString();
+ auto embedded_service = EmbeddedServiceForType(service_type);
+ if (!embedded_service.first.empty()) {
+ embedded_service.second.record[strings::service_active] = true;
+ AppServiceUpdated(embedded_service.second.record,
+ mobile_apis::ServiceUpdateReason::ACTIVATED,
+ msg_params);
+ }
+ send_update = true;
+ }
+
+ if (send_update) {
+ BroadcastAppServiceUpdate(msg_params);
+ }
+ return true;
}
std::pair<std::string, AppService> AppServiceManager::ActiveServiceByType(
@@ -184,6 +313,21 @@ std::pair<std::string, AppService> AppServiceManager::ActiveServiceByType(
return std::make_pair(std::string(), empty);
}
+std::pair<std::string, AppService> AppServiceManager::EmbeddedServiceForType(
+ std::string service_type) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ for (auto it = published_services_.begin(); it != published_services_.end();
+ ++it) {
+ if (it->second.record[strings::service_manifest][strings::service_type]
+ .asString() == service_type &&
+ !it->second.mobile_service) {
+ return *it;
+ }
+ }
+ AppService empty;
+ return std::make_pair(std::string(), empty);
+}
+
std::pair<std::string, AppService> AppServiceManager::FindServiceByName(
std::string name) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -197,4 +341,65 @@ std::pair<std::string, AppService> AppServiceManager::FindServiceByName(
AppService empty;
return std::make_pair(std::string(), empty);
}
+
+std::string AppServiceManager::DefaultServiceByType(std::string service_type) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ Json::Value& dictionary = last_state_.get_dictionary();
+ if (dictionary[kAppServiceSection][kDefaults].isMember(service_type)) {
+ return dictionary[kAppServiceSection][kDefaults][service_type].asString();
+ }
+ return std::string();
+}
+
+void AppServiceManager::SetServicePublished(const std::string service_id,
+ bool service_published) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ auto it = published_services_.find(service_id);
+ if (it == published_services_.end()) {
+ LOG4CXX_ERROR(logger_, "Service id does not exist in published services");
+ return;
+ }
+ it->second.record[strings::service_published] = service_published;
+}
+
+void AppServiceManager::BroadcastAppServiceUpdate(
+ smart_objects::SmartObject& msg_params) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ smart_objects::SmartObject message(smart_objects::SmartType_Map);
+
+ msg_params[strings::system_capability][strings::system_capability_type] =
+ mobile_apis::SystemCapabilityType::APP_SERVICES;
+ message[strings::params][strings::message_type] = MessageType::kNotification;
+ message[strings::msg_params] = msg_params;
+
+ // Construct and send mobile notification
+ message[strings::params][strings::function_id] =
+ mobile_apis::FunctionID::OnSystemCapabilityUpdatedID;
+ smart_objects::SmartObjectSPtr notification =
+ std::make_shared<smart_objects::SmartObject>(message);
+ app_manager_.GetRPCService().ManageMobileCommand(
+ notification, commands::Command::CommandSource::SOURCE_SDL);
+
+ // Construct and send HMI notification
+ message[strings::params][strings::function_id] =
+ hmi_apis::FunctionID::BasicCommunication_OnSystemCapabilityUpdated;
+ smart_objects::SmartObjectSPtr hmi_notification =
+ std::make_shared<smart_objects::SmartObject>(message);
+ app_manager_.GetRPCService().ManageHMICommand(hmi_notification);
+}
+
+void AppServiceManager::AppServiceUpdated(
+ const smart_objects::SmartObject& service_record,
+ const mobile_apis::ServiceUpdateReason::eType update_reason,
+ smart_objects::SmartObject& msg_params) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ smart_objects::SmartObject& services =
+ msg_params[strings::system_capability][strings::app_services_capabilities]
+ [strings::app_services];
+ smart_objects::SmartObject service(smart_objects::SmartType_Map);
+ service[strings::update_reason] = update_reason;
+ service[strings::updated_app_service_record] = service_record;
+ services[-1] = service;
+}
+
} // namespace application_manager
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index 6ee221f56f..6298d547d7 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -699,6 +699,8 @@ bool ApplicationManagerImpl::ActivateApplication(ApplicationSharedPtr app) {
// remove from resumption if app was activated by user
resume_controller().OnAppActivated(app);
+ // Activate any app services published by the app
+ GetAppServiceManager().OnAppActivated(app);
const HMILevel::eType hmi_level = HMILevel::HMI_FULL;
const AudioStreamingState::eType audio_state =
app->IsAudioApplication() ? AudioStreamingState::AUDIBLE
@@ -2010,7 +2012,8 @@ bool ApplicationManagerImpl::Init(resumption::LastState& last_state,
app_launch_ctrl_.reset(new app_launch::AppLaunchCtrlImpl(
*app_launch_dto_.get(), *this, settings_));
- app_service_manager_.reset(new application_manager::AppServiceManager(*this));
+ app_service_manager_.reset(
+ new application_manager::AppServiceManager(*this, last_state));
return true;
}
diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc
index 1d3a553711..124ec80312 100644
--- a/src/components/application_manager/src/message_helper/message_helper.cc
+++ b/src/components/application_manager/src/message_helper/message_helper.cc
@@ -327,55 +327,25 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateMessageForHMI(
return message;
}
-smart_objects::SmartObject
-MessageHelper::CreateMobileSystemCapabilityNotification(
- std::vector<smart_objects::SmartObject>& all_services,
- const std::string service_id,
- mobile_apis::ServiceUpdateReason::eType update_reason) {
- smart_objects::SmartObject message(smart_objects::SmartType_Map);
-
- message[strings::params][strings::message_type] = MessageType::kNotification;
- message[strings::params][strings::function_id] =
- mobile_apis::FunctionID::OnSystemCapabilityUpdatedID;
-
- smart_objects::SmartObject system_capability =
- smart_objects::SmartObject(smart_objects::SmartType_Map);
- system_capability[strings::system_capability_type] =
- mobile_apis::SystemCapabilityType::APP_SERVICES;
-
+smart_objects::SmartObject MessageHelper::CreateAppServiceCapabilities(
+ std::vector<smart_objects::SmartObject>& all_services) {
smart_objects::SmartObject app_service_capabilities(
smart_objects::SmartType_Map);
smart_objects::SmartObject app_services(smart_objects::SmartType_Array);
std::vector<smart_objects::SmartObject> service_records = all_services;
+ int i = 0;
for (auto& record : service_records) {
- smart_objects::SmartObject app_services_capabilities(
+ smart_objects::SmartObject app_service_capability(
smart_objects::SmartType_Map);
- app_services_capabilities[strings::updated_app_service_record] = record;
- if (record[strings::service_id].asString() == service_id) {
- app_services_capabilities[strings::update_reason] = update_reason;
- }
- app_services.asArray()->push_back(app_services_capabilities);
+ app_service_capability[strings::updated_app_service_record] = record;
+ app_services[i] = app_service_capability;
+ i++;
}
app_service_capabilities[strings::app_services] = app_services;
- system_capability[strings::app_services_capabilities] =
- app_service_capabilities;
-
- message[strings::msg_params][strings::system_capability] = system_capability;
- return message;
-}
-
-smart_objects::SmartObject MessageHelper::CreateHMISystemCapabilityNotification(
- std::vector<smart_objects::SmartObject>& all_services,
- const std::string service_id,
- mobile_apis::ServiceUpdateReason::eType update_reason) {
- auto message = CreateMobileSystemCapabilityNotification(
- all_services, service_id, update_reason);
- message[strings::params][strings::function_id] =
- hmi_apis::FunctionID::BasicCommunication_OnSystemCapabilityUpdated;
- return message;
+ return app_service_capabilities;
}
smart_objects::SmartObjectSPtr MessageHelper::CreateHashUpdateNotification(
diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc
index 4900726d48..59499818d3 100644
--- a/src/components/application_manager/src/smart_object_keys.cc
+++ b/src/components/application_manager/src/smart_object_keys.cc
@@ -288,6 +288,9 @@ const char* service_active = "serviceActive";
const char* app_services = "appServices";
const char* update_reason = "updateReason";
const char* updated_app_service_record = "updatedAppServiceRecord";
+const char* service_records = "serviceRecords";
+const char* activate = "activate";
+const char* set_as_default = "setAsDefault";
// resuming
const char* application_commands = "applicationCommands";
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 0b24fa8032..389f092e50 100644
--- a/src/components/application_manager/test/application_manager_impl_test.cc
+++ b/src/components/application_manager/test/application_manager_impl_test.cc
@@ -36,25 +36,26 @@
#include <vector>
#include <bson_object.h>
-#include "gtest/gtest.h"
#include "application_manager/application.h"
#include "application_manager/application_impl.h"
#include "application_manager/application_manager_impl.h"
#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_rpc_service.h"
#include "application_manager/mock_rpc_plugin_manager.h"
+#include "application_manager/mock_rpc_service.h"
#include "application_manager/resumption/resume_ctrl_impl.h"
#include "application_manager/test/include/application_manager/mock_message_helper.h"
#include "connection_handler/mock_connection_handler.h"
+#include "gtest/gtest.h"
#include "hmi_message_handler/mock_hmi_message_handler.h"
#include "media_manager/mock_media_manager.h"
#include "policy/mock_policy_settings.h"
#include "policy/usage_statistics/mock_statistics_manager.h"
#include "protocol/bson_object_keys.h"
-#include "protocol_handler/mock_session_observer.h"
#include "protocol_handler/mock_protocol_handler.h"
+#include "protocol_handler/mock_session_observer.h"
+#include "resumption/mock_last_state.h"
#include "utils/custom_string.h"
#include "utils/file_system.h"
#include "utils/lock.h"
@@ -138,8 +139,10 @@ class ApplicationManagerImplTest : public ::testing::Test {
app_manager_impl_->resume_controller().set_resumption_storage(
mock_storage_);
app_manager_impl_->set_connection_handler(&mock_connection_handler_);
+ 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_));
+ new AppServiceManager(*app_manager_impl_, mock_last_state_));
app_manager_impl_->SetAppServiceManager(app_service_manager_ptr);
}
@@ -212,6 +215,7 @@ class ApplicationManagerImplTest : public ::testing::Test {
std::shared_ptr<NiceMock<resumption_test::MockResumptionData> > mock_storage_;
MockRPCService* mock_rpc_service_;
+ resumption_test::MockLastState mock_last_state_;
NiceMock<con_test::MockConnectionHandler> mock_connection_handler_;
NiceMock<protocol_handler_test::MockSessionObserver> mock_session_observer_;
NiceMock<MockApplicationManagerSettings> mock_application_manager_settings_;
diff --git a/src/components/application_manager/test/include/application_manager/mock_message_helper.h b/src/components/application_manager/test/include/application_manager/mock_message_helper.h
index 878d3e7dd7..8d9cf9d7ef 100644
--- a/src/components/application_manager/test/include/application_manager/mock_message_helper.h
+++ b/src/components/application_manager/test/include/application_manager/mock_message_helper.h
@@ -308,16 +308,9 @@ class MockMessageHelper {
void(mobile_apis::ButtonName::eType button,
ApplicationSharedPtr application,
ApplicationManager& app_mngr));
- MOCK_METHOD3(CreateMobileSystemCapabilityNotification,
+ MOCK_METHOD1(CreateAppServiceCapabilities,
smart_objects::SmartObject(
- std::vector<smart_objects::SmartObject>& all_services,
- const std::string service_id,
- mobile_apis::ServiceUpdateReason::eType update_reason));
- MOCK_METHOD3(CreateHMISystemCapabilityNotification,
- smart_objects::SmartObject(
- std::vector<smart_objects::SmartObject>& all_services,
- const std::string service_id,
- mobile_apis::ServiceUpdateReason::eType update_reason));
+ std::vector<smart_objects::SmartObject>& all_services));
static MockMessageHelper* message_helper_mock();
};
diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc
index 6bd42a44a1..0fe82e0dfb 100644
--- a/src/components/application_manager/test/mock_message_helper.cc
+++ b/src/components/application_manager/test/mock_message_helper.cc
@@ -572,22 +572,9 @@ void MessageHelper::SendUnsubscribeButtonNotification(
->SendUnsubscribeButtonNotification(button, application, app_mngr);
}
-smart_objects::SmartObject
-MessageHelper::CreateMobileSystemCapabilityNotification(
- std::vector<smart_objects::SmartObject>& all_services,
- const std::string service_id,
- mobile_apis::ServiceUpdateReason::eType update_reason) {
- return MockMessageHelper::message_helper_mock()
- ->CreateMobileSystemCapabilityNotification(
- all_services, service_id, update_reason);
-}
-
-smart_objects::SmartObject MessageHelper::CreateHMISystemCapabilityNotification(
- std::vector<smart_objects::SmartObject>& all_services,
- const std::string service_id,
- mobile_apis::ServiceUpdateReason::eType update_reason) {
- return MockMessageHelper::message_helper_mock()
- ->CreateHMISystemCapabilityNotification(
- all_services, service_id, update_reason);
+smart_objects::SmartObject MessageHelper::CreateAppServiceCapabilities(
+ std::vector<smart_objects::SmartObject>& all_services) {
+ return MockMessageHelper::message_helper_mock()->CreateAppServiceCapabilities(
+ all_services);
}
} // namespace application_manager
diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml
index 0ad932fe82..2875323550 100644
--- a/src/components/interfaces/HMI_API.xml
+++ b/src/components/interfaces/HMI_API.xml
@@ -6201,5 +6201,41 @@
<param name="serviceData" type="Common.AppServiceData" mandatory="true"/>
</function>
+
+ <function name="GetAppServiceRecords" messagetype="request">
+ <param name="serviceType" type="String" mandatory="false">
+ <description>If included, only service records of supplied type will be returned in response. If not included, all service records for all types will be returned. See Common.AppServiceType.</description>
+ </param>
+ </function>
+
+ <function name="GetAppServiceRecords" messagetype="response">
+ <param name="serviceRecords" type="Common.AppServiceRecord" array="true" mandatory="false">
+ <description>All app service records of requested type.</description>
+ </param>
+ </function>
+
+ <function name="AppServiceActivation" messagetype="request">
+ <param name="serviceID" type="String" mandatory="true">
+ <description>The ID of the service that should have an activation event take place on</description>
+ </param>
+ <param name="activate" type="Boolean" mandatory="true">
+ <description>True if the service is to be activated. False if the app is to be deactivated</description>
+ </param>
+ <param name="setAsDefault" type="Boolean" mandatory="false">
+ <description>True if the service is to be the default service of this type. False if the app is not to be the default</description>
+ </param>
+ </function>
+
+ <function name="AppServiceActivation" messagetype="response">
+ <param name="serviceID" type="String" mandatory="true">
+ <description>The ID of the service that was requested to have an activation event take place</description>
+ </param>
+ <param name="activate" type="Boolean" mandatory="true">
+ <description>True if the service was activated. False if the app was deactivated or unable to be activated</description>
+ </param>
+ <param name="setAsDefault" type="Boolean" mandatory="false">
+ <description>True if the service was set to the default service of this type. False if the app was not to be the default</description>
+ </param>
+ </function>
</interface>
</interfaces>