summaryrefslogtreecommitdiff
path: root/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc
diff options
context:
space:
mode:
authorArtem Nosach <ANosach@luxoft.com>2015-04-17 17:46:56 +0300
committerArtem Nosach <ANosach@luxoft.com>2015-04-23 15:33:15 +0300
commit81208d859b07241abe8706d51eccbb74db72140b (patch)
treeb5a5d6be8d014229d419ca1dc65d54b5ef9de341 /src/components/application_manager/src/commands/mobile/subscribe_button_request.cc
parent6750a2c7de94e01949d79c9cd0d4bfbbb88df772 (diff)
downloadsdl_core-81208d859b07241abe8706d51eccbb74db72140b.tar.gz
Add CheckHMICapabilities() to SubscribeButton request.
Diffstat (limited to 'src/components/application_manager/src/commands/mobile/subscribe_button_request.cc')
-rw-r--r--src/components/application_manager/src/commands/mobile/subscribe_button_request.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc
index 64ef9f7a17..ece7c8332e 100644
--- a/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc
+++ b/src/components/application_manager/src/commands/mobile/subscribe_button_request.cc
@@ -70,6 +70,13 @@ void SubscribeButtonRequest::Run() {
return;
}
+ if (!CheckHMICapabilities(btn_id)) {
+ LOG4CXX_ERROR_EXT(logger_, "Subscribe on button " << btn_id
+ << " isn't allowed by HMI capabilities");
+ SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE);
+ return;
+ }
+
if (app->IsSubscribedToButton(btn_id)) {
LOG4CXX_ERROR_EXT(logger_, "Already subscribed to button " << btn_id);
SendResponse(false, mobile_apis::Result::IGNORED);
@@ -97,6 +104,37 @@ bool SubscribeButtonRequest::IsSubscriptionAllowed(
return true;
}
+bool SubscribeButtonRequest::CheckHMICapabilities(
+ mobile_apis::ButtonName::eType button) {
+ using namespace smart_objects;
+ using namespace mobile_apis;
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ ApplicationManagerImpl* app_mgr = ApplicationManagerImpl::instance();
+ DCHECK_OR_RETURN(app_mgr, false);
+
+ const HMICapabilities& hmi_caps = app_mgr->hmi_capabilities();
+ if (!hmi_caps.is_ui_cooperating()) {
+ LOG4CXX_ERROR_EXT(logger_, "UI is not supported by HMI.");
+ return false;
+ }
+
+ const SmartObject* button_caps_ptr = hmi_caps.button_capabilities();
+ if (button_caps_ptr) {
+ const SmartObject& button_caps = *button_caps_ptr;
+ const size_t length = button_caps.length();
+ for (size_t i = 0; i < length; ++i) {
+ const SmartObject& caps = button_caps[i];
+ const ButtonName::eType name =
+ static_cast<ButtonName::eType>(caps.getElement(hmi_response::button_name).asInt());
+ if (name == button) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
void SubscribeButtonRequest::SendSubscribeButtonNotification() {
using namespace smart_objects;
using namespace hmi_apis;