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

Feature/button subscription response from hmi #2731

Conversation

mked-luxoft
Copy link
Contributor

@mked-luxoft mked-luxoft commented Oct 30, 2018

Fixes #2508

This PR is [ready] for review.

Risk

This PR makes [major] API changes.

Testing Plan

ATF tests are provided

Summary

In this PR OnButtonSubscription notification is replaced with
(Un)SubscribeButton request/response.

Changelog

API was updated, as well as new request/response classes were introduces in SDL core.
Pending subscription resolution mechanism was introduced in case HMI responds to request after default timeout.

Bug Fixes

#967 is fixed in scope of this feature

CLA

}

SubscribeButtonRequest::~SubscribeButtonRequest() {
unsubscribe_from_event(hmi_apis::FunctionID::Buttons_SubscribeButton);
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft Base class EventObserver already contains unsubscribing from all events in his distructor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@IGapchuk fixed in 2b001c6

* @brief Get map of pending button subscription requests correlation ids
* to button names
* @return pending button subscriptions map
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft Remove descriptions from impl class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AByzhynar fixed in 2b001c6

* to button names
* @return pending button unsubscriptions map
*/
const virtual std::map<int32_t, hmi_apis::Common_ButtonName::eType>&
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft Move const qualifier to return type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AByzhynar fixed in 2b001c6

@@ -493,6 +537,10 @@ class ApplicationImpl : public virtual Application,
std::string bundle_id_;
AppFilesMap app_files_;
std::set<mobile_apis::ButtonName::eType> subscribed_buttons_;
std::map<int32_t, hmi_apis::Common_ButtonName::eType>
pending_subscription_buttons_;
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft May be pending_button_subscriptions? As well as related function names

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AByzhynar fixed in 2b001c6

#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_BUTTON_NOTIFICATION_TO_MOBILE_H_

#include "application_manager/application.h"
#include "command_notification_impl.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft Move it to first place of all includes

Copy link
Contributor Author

@mked-luxoft mked-luxoft Nov 5, 2018

Choose a reason for hiding this comment

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

@AByzhynar fixed in 2b001c6

#include "interfaces/MOBILE_API.h"

namespace application_manager {

Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft
Redundant empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AByzhynar fixed in 2b001c6


/**
* @brief Class is intended to encapsulate shared button notification logic in
*base class
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft missed indent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AByzhynar fixed in 2b001c6

**/
class ButtonNotificationToMobile
: public app_mngr::commands::CommandNotificationImpl {
protected:
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft A class definition should usually start with a public: section, followed by protected:, then private:. Omit sections that would be empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AByzhynar fixed in 2b001c6

namespace app_mngr = application_manager;

namespace commands {

Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft
Redundant empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AByzhynar fixed in 2b001c6


} // namespace hmi
} // namespace commands

Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft
Redundant empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AByzhynar fixed in 2b001c6

} // namespace hmi

} // namespace commands

Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft
Redundant empty line

Copy link
Contributor Author

@mked-luxoft mked-luxoft Nov 5, 2018

Choose a reason for hiding this comment

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

@AByzhynar fixed in 2b001c6

#include "application_manager/application_impl.h"
#include "application_manager/commands/command_request_impl.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft Wrong includes order. It was right before

Copy link
Contributor Author

@mked-luxoft mked-luxoft Nov 5, 2018

Choose a reason for hiding this comment

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

@AByzhynar fixed in 2b001c6

* @brief Sends ButtonSubscription notification
* to notify HMI that app unsubscribed from the button.
* @brief Interface method that is called whenever new event received
* @param event The received event
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft REmove description form impl class

Copy link
Contributor Author

@mked-luxoft mked-luxoft Nov 5, 2018

Choose a reason for hiding this comment

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

@AByzhynar fixed in 2b001c6

static_cast<hmi_apis::Common_Result::eType>(
message[strings::params][hmi_response::code].asInt());

const bool is_in_pending = app->PendingSubscriptionButtons().find(
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft I would recommend to split it to several expressions.

Copy link
Contributor Author

@mked-luxoft mked-luxoft Nov 5, 2018

Choose a reason for hiding this comment

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

@AByzhynar fixed in 2b001c6

event.smart_object_correlation_id()) !=
app->PendingSubscriptionButtons().end();

if (hmi_apis::Common_Result::SUCCESS == hmi_result && is_in_pending) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft What if HMI result will be some other positive like WARNING ?

Copy link
Contributor Author

@mked-luxoft mked-luxoft Nov 5, 2018

Choose a reason for hiding this comment

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

@AByzhynar fixed in 2b001c6

CreateHMINotification(FunctionID::Buttons_OnButtonSubscription, msg_params);

SendHMIRequest(
hmi_apis::FunctionID::Buttons_SubscribeButton, &msg_params, false);
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft We are not waiting for HMI response here...What if HMI will not subscribe app for CUSTOM BUTTON?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AByzhynar, are you referring to handling events from HMI in on_event method? if so, i think that it will be handled in implementation of SubscribeButtonRequest class, since this request will be constructed and run as a result of call to SendHMIRequest

Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft Yes. But what code will be responsible as you explicitly stated that we are not going to subscribe for HMI response?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AByzhynar if i understand correctly, we are not subscribing to HMI response in RAIRequest instance. However, we are still subscribing to HMI responses in SubscribeButtonRequest::Run(). Hence, we are handling these responses.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft Thanks. 👍

@@ -37,8 +37,8 @@
#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_
Copy link
Contributor

@LitvinenkoIra LitvinenkoIra Nov 5, 2018

Choose a reason for hiding this comment

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

@mked-luxoft please fix header guards
SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_

Copy link
Contributor Author

@mked-luxoft mked-luxoft Nov 5, 2018

Choose a reason for hiding this comment

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

const uint32_t btn_id = static_cast<uint32_t>(
(*message_)[strings::msg_params][hmi_response::button_name].asInt());

LOG4CXX_DEBUG(logger_, "reveived button id: " << btn_id);
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft typo received button id:

Copy link
Contributor Author

@mked-luxoft mked-luxoft Nov 5, 2018

Choose a reason for hiding this comment

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


ButtonNotificationToMobile::~ButtonNotificationToMobile() {}

bool ButtonNotificationToMobile::IsAppIDExist() const {
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft Does exist or is existed...

Copy link
Contributor Author

@mked-luxoft mked-luxoft Nov 5, 2018

Choose a reason for hiding this comment

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

@AByzhynar fixed in 2b001c6

}

// custom_button_id is mandatory for CUSTOM_BUTTON notification
if (false ==
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft == false is redundant. Use (! keyExists)

Copy link
Contributor Author

@mked-luxoft mked-luxoft Nov 5, 2018

Choose a reason for hiding this comment

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

@AByzhynar fixed in 2b001c6

custom_btn_id =
(*message_)[strings::msg_params][hmi_response::custom_button_id].asUInt();

if (false == app->IsSubscribedToSoftButton(custom_btn_id)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft Same as above

Copy link
Contributor Author

@mked-luxoft mked-luxoft Nov 5, 2018

Choose a reason for hiding this comment

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

@AByzhynar fixed in 2b001c6

return notification_ptr;
if (!app) {
LOG4CXX_ERROR(logger_, "application NULL pointer");
return nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft Are you sure that nullptr is good here? May return SmartObject ptr with SmartType_Null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AByzhynar fixed in 2b001c6


std::vector<ApplicationSharedPtr>::const_iterator it =
subscribed_apps.begin();
for (; subscribed_apps.end() != it; ++it) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft Range based loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AByzhynar fixed in 2b001c6

* to button names
* @return pending button subscriptions map
*/
const virtual std::map<int32_t, hmi_apis::Common_ButtonName::eType>&
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft I think we can use typedef here like a MapButtons

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ZhdanovP fixed in 704a3e5

@mked-luxoft mked-luxoft force-pushed the feature/Button_Subscription_response_from_HMI branch from abfab39 to 2b001c6 Compare November 5, 2018 16:02
return;
}

uint32_t custom_btn_id = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft What do you need intermediate initialization here for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AByzhynar fixed in 704a3e5


bool ButtonNotificationToMobile::DoesAppIDExist() const {
LOG4CXX_AUTO_TRACE(logger_);
using namespace application_manager;
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft using namespace application_manager; -> using application_manager::strings;? No?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AByzhynar fixed in 704a3e5

-added typedef to pending button subscriptions container
-removed redundant initialization
-changed to using namespace application_manager::strings where relevant
ApplicationSharedPtr app =
application_manager_.application_by_hmi_app(app_id);

if (!app) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft Will be performed the Button unsubscribing during the ApplicationManagerImpl::UnregisterApplication call ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ZhdanovP i think so, but don't beleive that there's a direct call in ApplicationManagerImpl::UnregisterApplication and i'm not sure whether there should be one.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft I think it should be done directly like a UnsubscribeAppFromWayPoints but Iam not sure that this is critical now

* ALL means all do, NONE means none do
*/
* @brief Stores whether each choice in a set has the vrCommands parameter
* MIXED means some choices have vrCommands and others don't
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft is it auto formating of clang-style check? If not ( i think not) please remove.

rpc_service,
hmi_capabilities,
policy_handler) {}
: ButtonNotificationToMobile(message,
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft please provide some havy reason to move part of logic of OnButtonEventNotification to additional layer of inheritance ButtonNotificationToMobile

Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft and describe it in PR and in comments


void ApplicationImpl::RemovePendingSubscriptionButton(
const int32_t correlation_id) {
pending_button_subscriptions_.erase(correlation_id);
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft I would make it thread safe

Copy link
Contributor

@LuxoftAKutsan LuxoftAKutsan left a comment

Choose a reason for hiding this comment

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

Please make implementation thread safe.

@@ -3424,6 +3424,35 @@
</description>
</param>
</function>
<function name="SubscribeButton" messagetype="request">
Copy link
Contributor

Choose a reason for hiding this comment

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

@mked-luxoft did you remove notification?

-removed OnButtonSubscription notification
-added comments to ButtonNotificationToMobile class
@mked-luxoft mked-luxoft closed this Nov 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants