summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndriy Byzhynar <abyzhynar@luxoft.com>2019-07-11 18:42:39 +0300
committerAndriy Byzhynar (GitHub) <AByzhynar@luxoft.com>2019-08-20 21:17:13 +0300
commit0f2c199add2a3708a163022ac025bb74456f54ad (patch)
tree36561986cbe2e171f15e57a401ed3c08d9b803be
parent3341ad77b7ba65b0f61c03b9ba659f74bee6177e (diff)
downloadsdl_core-0f2c199add2a3708a163022ac025bb74456f54ad.tar.gz
Implement hmi capabilties handling
Added handling of hmi capablities Updated related RPCs Updated unit tests Added unit tests for new RPCs
-rw-r--r--src/components/application_manager/include/application_manager/hmi_capabilities_impl.h20
-rw-r--r--src/components/application_manager/include/application_manager/message_helper.h1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc9
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc6
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc53
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc66
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_bc_system_capability_updated_notification_test.cc116
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc19
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_system_capability_request_test.cc118
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_capability_updated_notification_test.cc226
-rw-r--r--src/components/application_manager/src/hmi_capabilities_impl.cc16
-rw-r--r--src/components/application_manager/src/rpc_handler_impl.cc5
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h5
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_message_helper.h1
-rw-r--r--src/components/include/application_manager/hmi_capabilities.h18
15 files changed, 656 insertions, 23 deletions
diff --git a/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h b/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h
index 2ca1706214..d18932bac5 100644
--- a/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h
+++ b/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h
@@ -230,6 +230,20 @@ class HMICapabilitiesImpl : public HMICapabilities {
const smart_objects::SmartObject& display_capabilities) OVERRIDE;
/*
+ * @brief Retrieves information about the display capability
+ * @return Currently supported display capability
+ */
+ const smart_objects::SmartObject* system_display_capabilities()
+ const OVERRIDE;
+
+ /*
+ * @brief Sets supported display capability
+ * @param display_capabilities supported display capability
+ */
+ void set_system_display_capabilities(
+ const smart_objects::SmartObject& display_capabilities);
+
+ /*
* @brief Retrieves information about the HMI zone capabilities
*
* @return Currently supported HMI zone capabilities
@@ -578,7 +592,13 @@ class HMICapabilitiesImpl : public HMICapabilities {
smart_objects::SmartObject* ui_supported_languages_;
smart_objects::SmartObject* tts_supported_languages_;
smart_objects::SmartObject* vr_supported_languages_;
+ /*
+ * display_capabilities_ is deprecated and replaced by
+ * system_display_capabilities_. For backward compatibility
+ * display_capabilities_ is not removed.
+ */
smart_objects::SmartObject* display_capabilities_;
+ smart_objects::SmartObject* system_display_capabilities_;
smart_objects::SmartObject* hmi_zone_capabilities_;
smart_objects::SmartObject* soft_buttons_capabilities_;
smart_objects::SmartObject* button_capabilities_;
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 ab94d69083..00c365d334 100644
--- a/src/components/application_manager/include/application_manager/message_helper.h
+++ b/src/components/application_manager/include/application_manager/message_helper.h
@@ -42,6 +42,7 @@
#include <application_manager/smart_object_keys.h>
#include "application_manager/application.h"
+#include "application_manager/hmi_capabilities.h"
#include "application_manager/policies/policy_handler_interface.h"
#include "connection_handler/device.h"
#include "interfaces/HMI_API.h"
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 37dca47793..86f7fb25b4 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
@@ -161,6 +161,15 @@ void OnBCSystemCapabilityUpdatedNotification::Run() {
[strings::app_services_capabilities] = app_service_caps;
break;
}
+ case mobile_apis::SystemCapabilityType::DISPLAY: {
+ if (!hmi_capabilities_.system_display_capabilities()) {
+ LOG4CXX_INFO(logger_, "system_display_capabilities are not available");
+ return;
+ }
+ msg_params[strings::system_capability][strings::display_capabilities] =
+ *hmi_capabilities_.system_display_capabilities();
+ break;
+ }
default:
return;
}
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc
index d2e15d7350..a3eb9244bd 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc
@@ -121,6 +121,12 @@ void UIGetCapabilitiesResponse::Run() {
msg_params[strings::system_capabilities]
[strings::video_streaming_capability]);
}
+ if (msg_params[strings::system_capabilities].keyExists(
+ strings::display_capabilities)) {
+ hmi_capabilities.set_system_display_capabilities(
+ msg_params[strings::system_capabilities]
+ [strings::display_capabilities]);
+ }
}
}
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 0655da27c0..5aca122508 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
@@ -152,27 +152,54 @@ void GetSystemCapabilityRequest::Run() {
all_services);
break;
}
+ case mobile_apis::SystemCapabilityType::DISPLAY: {
+ auto capabilities = hmi_capabilities.system_display_capabilities();
+ if (app->display_capabilities()) {
+ capabilities = app->display_capabilities().get();
+ }
+
+ if (!capabilities) {
+ SendResponse(false, mobile_apis::Result::DATA_NOT_AVAILABLE);
+ LOG4CXX_INFO(logger_, "system_display_capabilities are not available");
+ return;
+ }
+
+ response_params[strings::system_capability]
+ [strings::display_capabilities] = *capabilities;
+ break;
+ }
default: // Return unsupported resource
SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE);
return;
}
- if ((*message_)[app_mngr::strings::msg_params].keyExists(
- strings::subscribe)) {
- auto& ext = SystemCapabilityAppExtension::ExtractExtension(*app);
- if ((*message_)[app_mngr::strings::msg_params][strings::subscribe]
- .asBool() == true) {
- LOG4CXX_DEBUG(logger_,
- "Subscribe to system capability: " << response_type);
- ext.SubscribeTo(response_type);
- } else {
- LOG4CXX_DEBUG(logger_,
- "Unsubscribe from system capability: " << response_type);
- ext.UnsubscribeFrom(response_type);
+ const char* info = nullptr;
+ // Ignore subscription/unsubscription for DISPLAY type
+ if (mobile_apis::SystemCapabilityType::DISPLAY != response_type) {
+ if ((*message_)[app_mngr::strings::msg_params].keyExists(
+ strings::subscribe)) {
+ auto& ext = SystemCapabilityAppExtension::ExtractExtension(*app);
+ if ((*message_)[app_mngr::strings::msg_params][strings::subscribe]
+ .asBool() == true) {
+ LOG4CXX_DEBUG(logger_,
+ "Subscribe to system capability: " << response_type);
+ ext.SubscribeTo(response_type);
+ } else {
+ LOG4CXX_DEBUG(logger_,
+ "Unsubscribe from system capability: " << response_type);
+ ext.UnsubscribeFrom(response_type);
+ }
+ }
+ } else {
+ if ((*message_)[app_mngr::strings::msg_params].keyExists(
+ strings::subscribe)) {
+ info =
+ "Subscribe parameter is ignored. Auto Subscription/Unsubscription is "
+ "used for DISPLAY capability type.";
}
}
- SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params);
+ SendResponse(true, mobile_apis::Result::SUCCESS, info, &response_params);
}
void GetSystemCapabilityRequest::on_event(const event_engine::Event& event) {
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 515279c5f9..20dae7224f 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
@@ -31,7 +31,7 @@ void OnSystemCapabilityUpdatedNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params];
- mobile_apis::SystemCapabilityType::eType system_capability_type =
+ const auto system_capability_type =
static_cast<mobile_apis::SystemCapabilityType::eType>(
msg_params[strings::system_capability]
[strings::system_capability_type]
@@ -127,8 +127,21 @@ void OnSystemCapabilityUpdatedNotification::Run() {
[strings::app_services_capabilities] = app_service_caps;
break;
}
- default:
+
+ case mobile_apis::SystemCapabilityType::DISPLAY: {
+ // Display capabilities content will be populated in the code after the
+ // switch so just breaking here
+ break;
+ }
+
+ default: {
+ LOG4CXX_ERROR(logger_,
+ "Unknown system capability type: "
+ << msg_params[strings::system_capability]
+ [strings::system_capability_type]
+ .asInt());
return;
+ }
}
const char* capability_type_string;
@@ -136,11 +149,34 @@ void OnSystemCapabilityUpdatedNotification::Run() {
mobile_apis::SystemCapabilityType::eType>::
EnumToCString(system_capability_type, &capability_type_string);
+ const auto initial_connection_key =
+ (*message_)[strings::params][strings::connection_key].asUInt();
+
auto subscribed_to_capability_predicate =
- [&system_capability_type](const ApplicationSharedPtr app) {
+ [&system_capability_type,
+ &initial_connection_key](const ApplicationSharedPtr app) {
DCHECK_OR_RETURN(app, false);
auto& ext = SystemCapabilityAppExtension::ExtractExtension(*app);
- return ext.IsSubscribedTo(system_capability_type);
+ if (!ext.IsSubscribedTo(system_capability_type)) {
+ LOG4CXX_DEBUG(logger_,
+ "App " << app->app_id()
+ << " is not subscribed to this capability type");
+ return false;
+ }
+
+ if (mobile_apis::SystemCapabilityType::DISPLAY ==
+ system_capability_type &&
+ initial_connection_key > 0) {
+ LOG4CXX_DEBUG(logger_,
+ "Display capabilities notification for app "
+ << initial_connection_key << " only");
+ return app->app_id() == initial_connection_key;
+ }
+
+ LOG4CXX_DEBUG(logger_,
+ "App " << app->app_id()
+ << " is subscribed to specified capability type");
+ return true;
};
const std::vector<ApplicationSharedPtr>& applications = FindAllApps(
@@ -167,6 +203,28 @@ void OnSystemCapabilityUpdatedNotification::Run() {
ext.UnsubscribeFrom(system_capability_type);
continue;
}
+
+ if (mobile_apis::SystemCapabilityType::DISPLAY == system_capability_type) {
+ LOG4CXX_DEBUG(logger_, "Using common display capabilities");
+ auto capabilities = hmi_capabilities_.system_display_capabilities();
+
+ if (app->display_capabilities()) {
+ LOG4CXX_DEBUG(logger_,
+ "Application " << app->app_id()
+ << " has specific display capabilities");
+ capabilities = app->display_capabilities().get();
+ }
+
+ if (!capabilities) {
+ LOG4CXX_WARN(logger_,
+ "No available display capabilities for sending. Skipping");
+ continue;
+ }
+
+ msg_params[strings::system_capability][strings::display_capabilities] =
+ *capabilities;
+ }
+
LOG4CXX_INFO(logger_,
"Sending OnSystemCapabilityUpdated " << capability_type_string
<< " application id "
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_bc_system_capability_updated_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_bc_system_capability_updated_notification_test.cc
new file mode 100644
index 0000000000..f2073dcfc0
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_bc_system_capability_updated_notification_test.cc
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2019, 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 "hmi/on_bc_system_capability_updated_notification.h"
+
+#include "application_manager/commands/commands_test.h"
+#include "gtest/gtest.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace hmi_commands_test {
+namespace on_bc_system_capability_updated_notification {
+
+using sdl_rpc_plugin::commands::OnBCSystemCapabilityUpdatedNotification;
+using ::testing::_;
+using ::testing::Return;
+
+typedef std::shared_ptr<OnBCSystemCapabilityUpdatedNotification>
+ OnBCSystemCapabilityUpdatedNotificationPtr;
+
+namespace strings = application_manager::strings;
+namespace {
+const uint32_t kConnectionKey = 1u;
+}
+
+MATCHER_P(CheckDisplayCapabilities, display_capabilities, "") {
+ return display_capabilities ==
+ (*arg)[strings::msg_params][strings::system_capability]
+ [strings::display_capabilities];
+}
+
+class OnBCSystemCapabilityUpdatedNotificationTest
+ : public CommandsTest<CommandsTestMocks::kIsNice> {
+ protected:
+ void SetUp() OVERRIDE {
+ message_ = CreateMessage();
+ (*message_)[strings::params][strings::connection_key] = kConnectionKey;
+
+ command_ = CreateCommand<OnBCSystemCapabilityUpdatedNotification>(message_);
+ mock_app_ = CreateMockApp();
+ }
+
+ OnBCSystemCapabilityUpdatedNotificationPtr command_;
+ MockAppPtr mock_app_;
+ MessageSharedPtr message_;
+};
+
+TEST_F(OnBCSystemCapabilityUpdatedNotificationTest,
+ SystemDisplayCapabilities_SUCCESS) {
+ (*message_)[am::strings::msg_params][strings::system_capability]
+ [am::strings::system_capability_type] =
+ mobile_apis::SystemCapabilityType::DISPLAY;
+
+ smart_objects::SmartObject system_display_capabilities;
+
+ EXPECT_CALL(mock_hmi_capabilities_, system_display_capabilities())
+ .Times(2)
+ .WillRepeatedly(Return(&system_display_capabilities));
+
+ EXPECT_CALL(
+ mock_rpc_service_,
+ SendMessageToHMI(CheckDisplayCapabilities(system_display_capabilities)));
+
+ ASSERT_TRUE(command_->Init());
+ command_->Run();
+}
+
+TEST_F(OnBCSystemCapabilityUpdatedNotificationTest,
+ SystemDisplayCapabilities_DATA_NOT_AVAILABLE) {
+ (*message_)[am::strings::msg_params][strings::system_capability]
+ [am::strings::system_capability_type] =
+ mobile_apis::SystemCapabilityType::DISPLAY;
+ EXPECT_CALL(mock_hmi_capabilities_, system_display_capabilities())
+ .WillOnce(Return(nullptr));
+
+ EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(_)).Times(0);
+
+ ASSERT_TRUE(command_->Init());
+ command_->Run();
+}
+
+} // namespace on_bc_system_capability_updated_notification
+} // namespace hmi_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc
index f2feb75b63..8242522cd8 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc
@@ -337,6 +337,25 @@ TEST_F(UIGetCapabilitiesResponseTest, SetVideoStreamingCapability_SUCCESS) {
command->Run();
}
+TEST_F(UIGetCapabilitiesResponseTest, SetSystemDisplayCapabilities_SUCCESS) {
+ MessageSharedPtr command_msg = CreateCommandMsg();
+ (*command_msg)[strings::msg_params][strings::system_capabilities] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+
+ ResponseFromHMIPtr command(
+ CreateCommand<UIGetCapabilitiesResponse>(command_msg));
+
+ const auto& display_capability_so =
+ (*command_msg)[strings::msg_params][strings::system_capabilities]
+ [strings::display_capabilities];
+
+ EXPECT_CALL(mock_hmi_capabilities_,
+ set_system_display_capabilities(display_capability_so));
+
+ ASSERT_TRUE(command->Init());
+ command->Run();
+}
+
} // namespace ui_get_capabilities_response
} // namespace hmi_commands_test
} // namespace commands_test
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_system_capability_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_system_capability_request_test.cc
new file mode 100644
index 0000000000..2db4d451b1
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_system_capability_request_test.cc
@@ -0,0 +1,118 @@
+/*
+ Copyright (c) 2019, 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 "mobile/get_system_capability_request.h"
+
+#include "application_manager/commands/command_request_test.h"
+#include "gtest/gtest.h"
+#include "interfaces/MOBILE_API.h"
+#include "smart_objects/smart_object.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+namespace get_system_capability_request_test {
+
+using sdl_rpc_plugin::commands::GetSystemCapabilityRequest;
+using ::testing::_;
+using ::testing::Return;
+typedef std::shared_ptr<GetSystemCapabilityRequest>
+ GetSystemCapabilityRequestPtr;
+
+namespace strings = application_manager::strings;
+namespace {
+const uint32_t kConnectionKey = 1u;
+}
+
+class GetSystemCapabilityRequestTest
+ : public CommandRequestTest<CommandsTestMocks::kIsNice> {
+ protected:
+ void SetUp() OVERRIDE {
+ message_ = CreateMessage();
+ (*message_)[strings::params][strings::connection_key] = kConnectionKey;
+
+ command_ = CreateCommand<GetSystemCapabilityRequest>(message_);
+ mock_app_ = CreateMockApp();
+
+ ON_CALL(app_mngr_, application(kConnectionKey))
+ .WillByDefault(Return(mock_app_));
+ }
+
+ GetSystemCapabilityRequestPtr command_;
+ MessageSharedPtr message_;
+ MockAppPtr mock_app_;
+};
+
+TEST_F(
+ GetSystemCapabilityRequestTest,
+ Run_GetSystemDisplayCapabilities_SendMessageToMobileWithSUCCESSResultCode) {
+ (*message_)[strings::msg_params][strings::system_capability_type] =
+ mobile_apis::SystemCapabilityType::DISPLAY;
+
+ smart_objects::SmartObjectSPtr system_display_capabilities(
+ std::make_shared<smart_objects::SmartObject>());
+
+ ON_CALL(*mock_app_, display_capabilities())
+ .WillByDefault(Return(system_display_capabilities));
+
+ EXPECT_CALL(
+ mock_rpc_service_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS),
+ Command::CommandSource::SOURCE_SDL));
+
+ ASSERT_TRUE(command_->Init());
+ command_->Run();
+}
+
+TEST_F(
+ GetSystemCapabilityRequestTest,
+ Run_GetSystemDisplayCapabilities_CapabilitiesNotExistSendMessageToMobileWithDATA_NOT_AVAILABLEResultCode) {
+ (*message_)[strings::msg_params][strings::system_capability_type] =
+ mobile_apis::SystemCapabilityType::DISPLAY;
+
+ EXPECT_CALL(*mock_app_, display_capabilities()).WillOnce(Return(nullptr));
+
+ EXPECT_CALL(mock_rpc_service_,
+ ManageMobileCommand(
+ MobileResultCodeIs(mobile_apis::Result::DATA_NOT_AVAILABLE),
+ Command::CommandSource::SOURCE_SDL));
+
+ ASSERT_TRUE(command_->Init());
+ command_->Run();
+}
+
+} // namespace get_system_capability_request_test
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_capability_updated_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_capability_updated_notification_test.cc
new file mode 100644
index 0000000000..bf3eca3e88
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_capability_updated_notification_test.cc
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 2019, 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 "mobile/on_system_capability_updated_notification.h"
+
+#include "application_manager/commands/commands_test.h"
+#include "gtest/gtest.h"
+#include "sdl_rpc_plugin/extensions/system_capability_app_extension.h"
+#include "sdl_rpc_plugin/sdl_rpc_plugin.h"
+
+namespace test {
+namespace components {
+namespace commands_test {
+namespace mobile_commands_test {
+namespace on_system_capability_updated_notification {
+
+using sdl_rpc_plugin::commands::mobile::OnSystemCapabilityUpdatedNotification;
+using ::testing::_;
+using ::testing::Return;
+
+typedef std::shared_ptr<OnSystemCapabilityUpdatedNotification>
+ OnSystemCapabilityUpdatedNotificationPtr;
+
+namespace strings = application_manager::strings;
+namespace {
+const uint32_t kConnectionKey = 1u;
+const uint32_t kAppId = 2u;
+} // namespace
+
+MATCHER_P(CheckDisplayCapabilities, display_capabilities, "") {
+ return display_capabilities ==
+ (*arg)[strings::msg_params][strings::system_capability]
+ [strings::display_capabilities];
+}
+
+class OnSystemCapabilityUpdatedNotificationTest
+ : public CommandsTest<CommandsTestMocks::kIsNice> {
+ protected:
+ void SetUp() OVERRIDE {
+ message_ = CreateMessage();
+ (*message_)[strings::params][strings::connection_key] = kConnectionKey;
+
+ command_ = CreateCommand<OnSystemCapabilityUpdatedNotification>(message_);
+ mock_app_ = CreateMockApp();
+ }
+
+ OnSystemCapabilityUpdatedNotificationPtr command_;
+ MockAppPtr mock_app_;
+ MessageSharedPtr message_;
+};
+
+TEST_F(
+ OnSystemCapabilityUpdatedNotificationTest,
+ Run_AppExistSubscribedToNotification_SystemDisplayCapabilitiesSendToMobile) {
+ (*message_)[am::strings::msg_params][strings::system_capability]
+ [am::strings::system_capability_type] =
+ mobile_apis::SystemCapabilityType::DISPLAY;
+
+ smart_objects::SmartObject system_display_capabilities;
+
+ ON_CALL(mock_hmi_capabilities_, system_display_capabilities())
+ .WillByDefault(Return(&system_display_capabilities));
+
+ sdl_rpc_plugin::SDLRPCPlugin sdl_rpc_plugin;
+
+ std::shared_ptr<sdl_rpc_plugin::SystemCapabilityAppExtension>
+ system_capability_app_extension(
+ std::make_shared<sdl_rpc_plugin::SystemCapabilityAppExtension>(
+ sdl_rpc_plugin, *mock_app_));
+ system_capability_app_extension->SubscribeTo(
+ mobile_apis::SystemCapabilityType::DISPLAY);
+ application_manager::ApplicationSet apps({mock_app_});
+ std::shared_ptr<sync_primitives::Lock> apps_lock_(
+ std::make_shared<sync_primitives::Lock>());
+ DataAccessor<application_manager::ApplicationSet> apps_data(
+ DataAccessor<application_manager::ApplicationSet>(apps, apps_lock_));
+
+ ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_data));
+ ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
+ ON_CALL(*mock_app_, display_capabilities()).WillByDefault(Return(nullptr));
+ ON_CALL(*mock_app_,
+ QueryInterface(sdl_rpc_plugin::SystemCapabilityAppExtension::
+ SystemCapabilityAppExtensionUID))
+ .WillByDefault(Return(system_capability_app_extension));
+
+ EXPECT_CALL(
+ mock_rpc_service_,
+ SendMessageToMobile(CheckDisplayCapabilities(system_display_capabilities),
+ false));
+
+ ASSERT_TRUE(command_->Init());
+ command_->Run();
+}
+
+TEST_F(
+ OnSystemCapabilityUpdatedNotificationTest,
+ Run_AppExistConnectionKeyNotEqualWithAppId_SystemDisplayCapabilitiesNotSendToMobile) {
+ (*message_)[am::strings::msg_params][strings::system_capability]
+ [am::strings::system_capability_type] =
+ mobile_apis::SystemCapabilityType::DISPLAY;
+
+ smart_objects::SmartObject system_display_capabilities;
+
+ ON_CALL(mock_hmi_capabilities_, system_display_capabilities())
+ .WillByDefault(Return(&system_display_capabilities));
+
+ sdl_rpc_plugin::SDLRPCPlugin sdl_rpc_plugin;
+
+ std::shared_ptr<sdl_rpc_plugin::SystemCapabilityAppExtension>
+ system_capability_app_extension(
+ std::make_shared<sdl_rpc_plugin::SystemCapabilityAppExtension>(
+ sdl_rpc_plugin, *mock_app_));
+ system_capability_app_extension->SubscribeTo(
+ mobile_apis::SystemCapabilityType::DISPLAY);
+ application_manager::ApplicationSet apps({mock_app_});
+ std::shared_ptr<sync_primitives::Lock> apps_lock_(
+ std::make_shared<sync_primitives::Lock>());
+ DataAccessor<application_manager::ApplicationSet> apps_data(
+ DataAccessor<application_manager::ApplicationSet>(apps, apps_lock_));
+
+ ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_data));
+ ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId));
+ ON_CALL(*mock_app_, display_capabilities()).WillByDefault(Return(nullptr));
+ ON_CALL(*mock_app_,
+ QueryInterface(sdl_rpc_plugin::SystemCapabilityAppExtension::
+ SystemCapabilityAppExtensionUID))
+ .WillByDefault(Return(system_capability_app_extension));
+
+ EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, _)).Times(0);
+
+ ASSERT_TRUE(command_->Init());
+ command_->Run();
+}
+
+TEST_F(
+ OnSystemCapabilityUpdatedNotificationTest,
+ Run_AppExistNotSubscribedToNotification_SystemDisplayCapabilitiesNotSendToMobile) {
+ (*message_)[am::strings::msg_params][strings::system_capability]
+ [am::strings::system_capability_type] =
+ mobile_apis::SystemCapabilityType::DISPLAY;
+
+ smart_objects::SmartObject system_display_capabilities;
+
+ ON_CALL(mock_hmi_capabilities_, system_display_capabilities())
+ .WillByDefault(Return(&system_display_capabilities));
+
+ sdl_rpc_plugin::SDLRPCPlugin sdl_rpc_plugin;
+
+ std::shared_ptr<sdl_rpc_plugin::SystemCapabilityAppExtension>
+ system_capability_app_extension(
+ std::make_shared<sdl_rpc_plugin::SystemCapabilityAppExtension>(
+ sdl_rpc_plugin, *mock_app_));
+
+ application_manager::ApplicationSet apps({mock_app_});
+ std::shared_ptr<sync_primitives::Lock> apps_lock_(
+ std::make_shared<sync_primitives::Lock>());
+ DataAccessor<application_manager::ApplicationSet> apps_data(
+ DataAccessor<application_manager::ApplicationSet>(apps, apps_lock_));
+
+ ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_data));
+ ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
+ ON_CALL(*mock_app_, display_capabilities()).WillByDefault(Return(nullptr));
+ ON_CALL(*mock_app_,
+ QueryInterface(sdl_rpc_plugin::SystemCapabilityAppExtension::
+ SystemCapabilityAppExtensionUID))
+ .WillByDefault(Return(system_capability_app_extension));
+
+ EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, _)).Times(0);
+
+ ASSERT_TRUE(command_->Init());
+ command_->Run();
+}
+
+TEST_F(
+ OnSystemCapabilityUpdatedNotificationTest,
+ Run_AppDataEmpty_SystemDisplayCapabilitiesUpdatedNotificationNotSendToMobile) {
+ (*message_)[am::strings::msg_params][strings::system_capability]
+ [am::strings::system_capability_type] =
+ mobile_apis::SystemCapabilityType::DISPLAY;
+ application_manager::ApplicationSet apps;
+ std::shared_ptr<sync_primitives::Lock> apps_lock_(
+ std::make_shared<sync_primitives::Lock>());
+ DataAccessor<application_manager::ApplicationSet> apps_data(
+ DataAccessor<application_manager::ApplicationSet>(apps, apps_lock_));
+
+ ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_data));
+ EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, _)).Times(0);
+
+ ASSERT_TRUE(command_->Init());
+ command_->Run();
+}
+
+} // namespace on_system_capability_updated_notification
+} // namespace mobile_commands_test
+} // namespace commands_test
+} // namespace components
+} // namespace test
diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc
index 7c0e9b71fd..1356502b34 100644
--- a/src/components/application_manager/src/hmi_capabilities_impl.cc
+++ b/src/components/application_manager/src/hmi_capabilities_impl.cc
@@ -436,6 +436,7 @@ HMICapabilitiesImpl::HMICapabilitiesImpl(ApplicationManager& app_mngr)
, tts_supported_languages_(NULL)
, vr_supported_languages_(NULL)
, display_capabilities_(NULL)
+ , system_display_capabilities_(NULL)
, hmi_zone_capabilities_(NULL)
, soft_buttons_capabilities_(NULL)
, button_capabilities_(NULL)
@@ -472,6 +473,7 @@ HMICapabilitiesImpl::~HMICapabilitiesImpl() {
delete tts_supported_languages_;
delete vr_supported_languages_;
delete display_capabilities_;
+ delete system_display_capabilities_;
delete hmi_zone_capabilities_;
delete soft_buttons_capabilities_;
delete button_capabilities_;
@@ -616,6 +618,15 @@ void HMICapabilitiesImpl::set_display_capabilities(
}
}
+void HMICapabilitiesImpl::set_system_display_capabilities(
+ const smart_objects::SmartObject& display_capabilities) {
+ if (system_display_capabilities_) {
+ delete system_display_capabilities_;
+ }
+ system_display_capabilities_ =
+ new smart_objects::SmartObject(display_capabilities);
+}
+
void HMICapabilitiesImpl::set_hmi_zone_capabilities(
const smart_objects::SmartObject& hmi_zone_capabilities) {
if (hmi_zone_capabilities_) {
@@ -806,6 +817,11 @@ const smart_objects::SmartObject* HMICapabilitiesImpl::display_capabilities()
return display_capabilities_;
}
+const smart_objects::SmartObject*
+HMICapabilitiesImpl::system_display_capabilities() const {
+ return system_display_capabilities_;
+}
+
const smart_objects::SmartObject* HMICapabilitiesImpl::hmi_zone_capabilities()
const {
return hmi_zone_capabilities_;
diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc
index 3fceaf573c..49877ce3ef 100644
--- a/src/components/application_manager/src/rpc_handler_impl.cc
+++ b/src/components/application_manager/src/rpc_handler_impl.cc
@@ -159,10 +159,6 @@ void RPCHandlerImpl::ProcessMessageFromHMI(
smart_objects::SmartObjectSPtr smart_object =
std::make_shared<smart_objects::SmartObject>();
bool allow_unknown_parameters = false;
- if (!smart_object) {
- LOG4CXX_ERROR(logger_, "Null pointer");
- return;
- }
smart_objects::SmartObject converted_result;
formatters::FormatterJsonRpc::FromString<hmi_apis::FunctionID::eType,
@@ -198,6 +194,7 @@ void RPCHandlerImpl::ProcessMessageFromHMI(
LOG4CXX_ERROR(logger_, "Received command didn't run successfully");
}
}
+
void RPCHandlerImpl::Handle(const impl::MessageFromMobile message) {
LOG4CXX_AUTO_TRACE(logger_);
diff --git a/src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h b/src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h
index a662b211d7..854a72be20 100644
--- a/src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h
+++ b/src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h
@@ -103,6 +103,11 @@ class MockHMICapabilities : public ::application_manager::HMICapabilities {
MOCK_METHOD1(set_display_capabilities,
void(const smart_objects::SmartObject& display_capabilities));
+ MOCK_CONST_METHOD0(system_display_capabilities,
+ const smart_objects::SmartObject*());
+ MOCK_METHOD1(set_system_display_capabilities,
+ void(const smart_objects::SmartObject& display_capabilities));
+
MOCK_CONST_METHOD0(hmi_zone_capabilities,
const smart_objects::SmartObject*());
MOCK_METHOD1(set_hmi_zone_capabilities,
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 8287e77a6f..c486a420f5 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
@@ -34,6 +34,7 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_MESSAGE_HELPER_H_
#include "application_manager/application.h"
#include "application_manager/application_manager.h"
+#include "application_manager/hmi_capabilities.h"
#include "application_manager/message_helper.h"
#include "application_manager/policies/policy_handler_interface.h"
#include "gmock/gmock.h"
diff --git a/src/components/include/application_manager/hmi_capabilities.h b/src/components/include/application_manager/hmi_capabilities.h
index ee3a2f4b4c..1bd463381d 100644
--- a/src/components/include/application_manager/hmi_capabilities.h
+++ b/src/components/include/application_manager/hmi_capabilities.h
@@ -63,9 +63,9 @@ class HMICapabilities {
virtual HMILanguageHandler& get_hmi_language_handler() = 0;
/*
- * @brief Checks is image type(Static/Dynamic) requested by
+ * @brief Checks if image type(Static/Dynamic) requested by
* Mobile Device is supported on current HMI.
- * @param image_type recieved type of image from Enum.
+ * @param image_type received type of image from Enum.
* @return Bool true if supported
*/
virtual bool VerifyImageType(const int32_t image_type) const = 0;
@@ -230,6 +230,20 @@ class HMICapabilities {
const smart_objects::SmartObject& display_capabilities) = 0;
/*
+ * @brief Retrieves information about the display capability
+ * @return Currently supported display capability
+ */
+ virtual const smart_objects::SmartObject* system_display_capabilities()
+ const = 0;
+
+ /*
+ * @brief Sets supported display capability
+ * @param display_capabilities supported display capability
+ */
+ virtual void set_system_display_capabilities(
+ const smart_objects::SmartObject& display_capabilities) = 0;
+
+ /*
* @brief Retrieves information about the HMI zone capabilities
*
* @return Currently supported HMI zone capabilities