diff options
Diffstat (limited to 'src/components/application_manager/src')
-rw-r--r-- | src/components/application_manager/src/commands/mobile/on_button_event_notification.cc | 31 | ||||
-rw-r--r-- | src/components/application_manager/src/commands/mobile/on_button_press_notification.cc | 31 |
2 files changed, 30 insertions, 32 deletions
diff --git a/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc b/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc index 5f14ad953f..b2ed8f8bfc 100644 --- a/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc @@ -57,10 +57,16 @@ void OnButtonEventNotification::Run() { 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( + (*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 (false == (*message_)[strings::msg_params].keyExists(strings::app_id)) { + if (!is_app_id_exists) { LOG4CXX_ERROR_EXT(logger_, "CUSTOM_BUTTON OnButtonEvent without app_id."); return; } @@ -73,10 +79,7 @@ void OnButtonEventNotification::Run() { return; } - ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( - (*message_)[strings::msg_params][strings::app_id].asUInt()); - - if (false == app.valid()) { + if (!app) { LOG4CXX_ERROR_EXT(logger_, "Application doesn't exist."); return; } @@ -95,31 +98,27 @@ void OnButtonEventNotification::Run() { return; } - const std::vector<ApplicationSharedPtr>& subscribedApps = + const std::vector<ApplicationSharedPtr>& subscribed_apps = ApplicationManagerImpl::instance()->applications_by_button(btn_id); - std::vector<ApplicationSharedPtr>::const_iterator it = subscribedApps.begin(); - for (; subscribedApps.end() != it; ++it) { + 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."); continue; } - //Send ButtonEvent notification only in HMI_FULL or HMI_LIMITED mode + // Send ButtonEvent 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_, "OnButtonEvent in HMI_BACKGROUND or NONE"); continue; } - - //Send ButtonEvent notification for OK button only in HMI_FULL mode - if ((static_cast<uint32_t>(mobile_apis::ButtonName::OK) == btn_id) && - (!subscribed_app->IsFullscreen())) { - continue; + // if "app_id" absent send notification only in HMI_FULL mode + if (is_app_id_exists || subscribed_app->IsFullscreen()) { + SendButtonEvent(subscribed_app); } - - SendButtonEvent(subscribed_app); } } 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 86fe664f86..72677c0f77 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 @@ -57,10 +57,16 @@ void OnButtonPressNotification::Run() { 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( + (*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 (false == (*message_)[strings::msg_params].keyExists(strings::app_id)) { + if (!is_app_id_exists) { LOG4CXX_ERROR_EXT(logger_, "CUSTOM_BUTTON OnButtonPress without app_id."); return; } @@ -73,10 +79,7 @@ void OnButtonPressNotification::Run() { return; } - ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application( - (*message_)[strings::msg_params][strings::app_id].asUInt()); - - if (false == app.valid()) { + if (!app) { LOG4CXX_ERROR_EXT(logger_, "Application doesn't exist."); return; } @@ -95,31 +98,27 @@ void OnButtonPressNotification::Run() { return; } - const std::vector<ApplicationSharedPtr>& subscribedApps = + const std::vector<ApplicationSharedPtr>& subscribed_apps = ApplicationManagerImpl::instance()->applications_by_button(btn_id); - std::vector<ApplicationSharedPtr>::const_iterator it = subscribedApps.begin(); - for (; subscribedApps.end() != it; ++it) { + 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."); continue; } - //Send ButtonPress notification only in HMI_FULL or HMI_LIMITED mode + // 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"); continue; } - - //Send ButtonPress notification for OK button only in HMI_FULL mode - if ((static_cast<uint32_t>(mobile_apis::ButtonName::OK) == btn_id) && - (mobile_api::HMILevel::HMI_FULL != subscribed_app->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); } } |