Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditions to transfer on button press on button event #775

Merged
merged 3 commits into from
Aug 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OHerasym, seems there are same actions in "if" and in "else if". Can it be just one "if"? (is there important side effects in IsFullscreen?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

SendButtonPress(subscribed_app);
}
}

Expand Down
14 changes: 9 additions & 5 deletions src/components/interfaces/HMI_API.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1938,7 +1938,7 @@

</interface>

<interface name="Buttons" version="1.0" date="2013-04-12">
<interface name="Buttons" version="1.1" date="2016-08-18">
<function name="GetCapabilities" messagetype="request">
<description>Method is invoked at system start-up. SDL requests the information about all supported hardware buttons and their capabilities</description>
</function>
Expand All @@ -1961,8 +1961,10 @@
</param>
<param name="appID" type="Integer" mandatory="false">
<description>
In case the ButtonName is CUSTOM_BUTTON, HMI must include appID parameters to OnButtonPress notification sent to SDL.
Otherwise, if appID is not sent together with CUSTOM_BUTTON, this notification will be ignored by SDL.
In case the ButtonName is CUSTOM_BUTTON or OK, HMI must include appID parameters to OnButtonPress notification sent to SDL.
If appID is not sent together with CUSTOM_BUTTON, this notification will be ignored by SDL.
If appID is present for OK button -> SDL transfers notification to the named app only if it is in FULL or LIMITED (ignores if app is in NONE or BACKGROUND).
If appID is omited for OK button -> SDL transfers notification to app in FULL
</description>
</param>
</function>
Expand All @@ -1976,8 +1978,10 @@
</param>
<param name="appID" type="Integer" mandatory="false">
<description>
In case the ButtonName is CUSTOM_BUTTON, HMI must include appID parameters to OnButtonEvent notification sent to SDL.
Otherwise, if appID is not sent together with CUSTOM_BUTTON, this notification will be ignored by SDL.
In case the ButtonName is CUSTOM_BUTTON or OK, HMI must include appID parameters to OnButtonEvent notification sent to SDL.
If appID is not sent together with CUSTOM_BUTTON, this notification will be ignored by SDL.
If appID is present for OK button -> SDL transfers notification to the named app only if it is in FULL or LIMITED (ignores if app is in NONE or BACKGROUND).
If appID is omited for OK button -> SDL transfers notification to app in FULL
</description>
</param>
</function>
Expand Down