summaryrefslogtreecommitdiff
path: root/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/src/commands/mobile/on_button_press_notification.cc')
-rw-r--r--src/components/application_manager/src/commands/mobile/on_button_press_notification.cc56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc b/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc
index 72677c0f77..56673f921d 100644
--- a/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc
@@ -32,7 +32,7 @@
*/
#include "application_manager/commands/mobile/on_button_press_notification.h"
-#include "application_manager/application_manager_impl.h"
+
#include "application_manager/application_impl.h"
#include "interfaces/MOBILE_API.h"
@@ -43,53 +43,51 @@ namespace commands {
namespace mobile {
OnButtonPressNotification::OnButtonPressNotification(
- const MessageSharedPtr& message)
- : CommandNotificationImpl(message) {
-}
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : CommandNotificationImpl(message, application_manager) {}
-OnButtonPressNotification::~OnButtonPressNotification() {
-}
+OnButtonPressNotification::~OnButtonPressNotification() {}
void OnButtonPressNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
- const uint32_t btn_id =
- static_cast<uint32_t>(
- (*message_)[strings::msg_params][hmi_response::button_name].asInt());
+ const uint32_t btn_id = static_cast<uint32_t>(
+ (*message_)[strings::msg_params][hmi_response::button_name].asInt());
const bool is_app_id_exists =
(*message_)[strings::msg_params].keyExists(strings::app_id);
const ApplicationSharedPtr app =
- ApplicationManagerImpl::instance()->application(
+ application_manager_.application(
(*message_)[strings::msg_params][strings::app_id].asUInt());
// CUSTOM_BUTTON notification
if (static_cast<uint32_t>(mobile_apis::ButtonName::CUSTOM_BUTTON) == btn_id) {
// app_id is mandatory for CUSTOM_BUTTON notification
if (!is_app_id_exists) {
- LOG4CXX_ERROR_EXT(logger_, "CUSTOM_BUTTON OnButtonPress without app_id.");
+ LOG4CXX_ERROR(logger_, "CUSTOM_BUTTON OnButtonPress without app_id.");
return;
}
// custom_button_id is mandatory for CUSTOM_BUTTON notification
if (false == (*message_)[strings::msg_params].keyExists(
- hmi_response::custom_button_id)) {
- LOG4CXX_ERROR_EXT(logger_,
- "CUSTOM_BUTTON OnButtonPress without custom_button_id.");
+ hmi_response::custom_button_id)) {
+ LOG4CXX_ERROR(logger_,
+ "CUSTOM_BUTTON OnButtonPress without custom_button_id.");
return;
}
if (!app) {
- LOG4CXX_ERROR_EXT(logger_, "Application doesn't exist.");
+ LOG4CXX_ERROR(logger_, "Application doesn't exist.");
return;
}
uint32_t custom_btn_id = 0;
- custom_btn_id = (*message_)[strings::msg_params]
- [hmi_response::custom_button_id].asUInt();
+ custom_btn_id =
+ (*message_)[strings::msg_params][hmi_response::custom_button_id]
+ .asUInt();
if (false == app->IsSubscribedToSoftButton(custom_btn_id)) {
- LOG4CXX_ERROR_EXT(logger_,
+ LOG4CXX_ERROR(logger_,
"Application doesn't subscribed to this custom_button_id.");
return;
}
@@ -99,43 +97,45 @@ void OnButtonPressNotification::Run() {
}
const std::vector<ApplicationSharedPtr>& subscribed_apps =
- ApplicationManagerImpl::instance()->applications_by_button(btn_id);
+ application_manager_.applications_by_button(btn_id);
std::vector<ApplicationSharedPtr>::const_iterator it = subscribed_apps.begin();
for (; subscribed_apps.end() != it; ++it) {
ApplicationSharedPtr subscribed_app = *it;
if (!subscribed_app) {
- LOG4CXX_WARN_EXT(logger_, "Null pointer to subscribed app.");
+ LOG4CXX_WARN(logger_, "Null pointer to subscribed app.");
continue;
}
// Send ButtonPress notification only in HMI_FULL or HMI_LIMITED mode
if ((mobile_api::HMILevel::HMI_FULL != subscribed_app->hmi_level()) &&
(mobile_api::HMILevel::HMI_LIMITED != subscribed_app->hmi_level())) {
- LOG4CXX_WARN_EXT(logger_, "OnButtonPress in HMI_BACKGROUND or NONE");
+ LOG4CXX_WARN(logger_,
+ "OnButtonPress notification is allowed only"
+ << "in FULL or LIMITED hmi level");
continue;
}
// if "app_id" absent send notification only in HMI_FULL mode
if (is_app_id_exists || subscribed_app->IsFullscreen()) {
- SendButtonPress(subscribed_app);
- }
+ SendButtonPress(subscribed_app);
}
}
+}
void OnButtonPressNotification::SendButtonPress(ApplicationConstSharedPtr app) {
if (!app) {
- LOG4CXX_ERROR_EXT(logger_, "OnButtonPress NULL pointer");
+ LOG4CXX_ERROR(logger_, "OnButtonPress NULL pointer");
return;
}
- smart_objects::SmartObjectSPtr on_btn_press = new smart_objects::SmartObject();
+ smart_objects::SmartObjectSPtr on_btn_press =
+ new smart_objects::SmartObject();
if (!on_btn_press) {
- LOG4CXX_ERROR_EXT(logger_, "OnButtonPress NULL pointer");
+ LOG4CXX_ERROR(logger_, "OnButtonPress NULL pointer");
return;
}
-
(*on_btn_press)[strings::params][strings::connection_key] = app->app_id();
(*on_btn_press)[strings::params][strings::function_id] =
@@ -147,7 +147,7 @@ void OnButtonPressNotification::SendButtonPress(ApplicationConstSharedPtr app) {
(*message_)[strings::msg_params][hmi_response::button_mode];
if ((*message_)[strings::msg_params].keyExists(
- hmi_response::custom_button_id)) {
+ hmi_response::custom_button_id)) {
(*on_btn_press)[strings::msg_params][strings::custom_button_id] =
(*message_)[strings::msg_params][strings::custom_button_id];
}