-
Notifications
You must be signed in to change notification settings - Fork 244
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
Feature/button subscription response from hmi #2731
Conversation
moved shared logic of OnButtonEvent and OnButtonPress to ButtonNotificationToMobile base class
} | ||
|
||
SubscribeButtonRequest::~SubscribeButtonRequest() { | ||
unsubscribe_from_event(hmi_apis::FunctionID::Buttons_SubscribeButton); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @brief Get map of pending button subscription requests correlation ids | ||
* to button names | ||
* @return pending button subscriptions map | ||
*/ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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>& |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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_; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 { | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mked-luxoft missed indent
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 | ||
*/ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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_ |
There was a problem hiding this comment.
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_
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LitvinenkoIra fixed in 2b001c6
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); |
There was a problem hiding this comment.
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:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LitvinenkoIra fixed in 2b001c6
|
||
ButtonNotificationToMobile::~ButtonNotificationToMobile() {} | ||
|
||
bool ButtonNotificationToMobile::IsAppIDExist() const { |
There was a problem hiding this comment.
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
...
There was a problem hiding this comment.
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 == |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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>& |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abfab39
to
2b001c6
Compare
return; | ||
} | ||
|
||
uint32_t custom_btn_id = 0; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this 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"> |
There was a problem hiding this comment.
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
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