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

Fix VD items subscriptions after PTU #3081

Merged
merged 6 commits into from
Oct 23, 2019

Conversation

AKalinich-Luxoft
Copy link
Contributor

@AKalinich-Luxoft AKalinich-Luxoft commented Oct 16, 2019

Fixes #3079 and #3080

This PR is ready for review.

Risk

This PR makes no API changes.

Testing Plan

Covered with ATF scripts

Summary

There was found an issue that SDL still kept subscriptions for custom vehicle data items even
for case when they were removed during PTU. By that reason, SDL was crashing with DCHECK on
attempt to unsubscribe from non existing custom data.

There was added missing logic of internal unsubscribe in case some custom vehicle data was removed by policies.

CLA

@AKalinich-Luxoft AKalinich-Luxoft changed the title Fix revoked VD items subscription after PTU Fix VD items subscriptions after PTU Oct 16, 2019
@AKalinich-Luxoft AKalinich-Luxoft force-pushed the fix/fix_vd_items_subscription_after_ptu branch from 178a3b4 to f2756a7 Compare October 16, 2019 13:18
@@ -72,6 +72,7 @@ class VehicleInfoPlugin : public plugins::RPCPlugin {
VehicleInfoAppExtension& ext);

private:
void UnsubscribeFromNotExistingVDItems();
Copy link
Contributor

Choose a reason for hiding this comment

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

@AKalinich-Luxoft ...NonExisting...

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 334284c

There was found an issue that SDL still kept
subscriptions for custom vehicle data items even
for case when they were removed during PTU. By
that reason, SDL was crashing with DCHECK on
attempt to unsubscribe from non existing custom
data.
There was added missing logic of internal
unsubscribe in case  some custom vehicle data
was removed by policies.
@AKalinich-Luxoft AKalinich-Luxoft force-pushed the fix/fix_vd_items_subscription_after_ptu branch from f2756a7 to 334284c Compare October 16, 2019 13:27
Was added a missing part of logic of subscriptions
control - cache manager was updated to keep the
vehicle data which was removed by last PTU.
Custom vehicle data manager was updated to
consider the removed vehicle data and also prepare
and send unsubscribe requests to HMI for case when
some vehicle data was removed and some application
was subscribed on it.
ext.unsubscribeFromVehicleInfo(subscription_name);
typedef std::vector<std::string> StringsVector;

auto get_items_to_unsubscribe = [this](StringsVector& out_items) {
Copy link
Contributor

@AByzhynar AByzhynar Oct 17, 2019

Choose a reason for hiding this comment

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

@AKalinich-Luxoft get ... name should return something. Make it return value and use like value = get...();
Or rename to write_items_to... (StringsVector& ..)

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 added a return type for a getter.
See 7aa5625

};

StringsVector items_to_unsubscribe;
get_items_to_unsubscribe(items_to_unsubscribe);
Copy link
Contributor

@AByzhynar AByzhynar Oct 17, 2019

Choose a reason for hiding this comment

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

@AKalinich-Luxoft I would rather use it like

StringsVector items_to_unsubscribe = get_items_to_unsubscribe();

Or even without get_ prefix StringsVector items_to_unsubscribe = ItemsToUnsubscribe()

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 I choose the option 1 with get_ prefix. It's a labmda and I am considering it as a local variable so kept appropriate naming. Please take a look at 7aa5625

* @brief Gets removed vehicle data items
* @return Structure with vehicle data items
*/
virtual const std::vector<policy_table::VehicleDataItem>
Copy link
Contributor

@AByzhynar AByzhynar Oct 17, 2019

Choose a reason for hiding this comment

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

@AKalinich-Luxoft What is the sense of returning of const by value? In returning by value - copying occurs.

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 good point. There is no sense while copying. Mostly it was a copy-past of the neighbour function :)
However, today I noticed one funny thing when removing const from return type - it makes sense when you are declaring smth like that:

auto& removed_oem_items = vehicle_data_provider_.GetRemovedVehicleDataItems();

So when const is removed from the return type, you will get a compilation error:

invalid initialization of non-const reference of type ‘std::vector<rpc::policy_table_interface_base::VehicleDataItem, std::allocator<rpc::policy_table_interface_base::VehicleDataItem> >&’ from an rvalue of type ‘std::vector<rpc::policy_table_interface_base::VehicleDataItem, std::allocator<rpc::policy_table_interface_base::VehicleDataItem> >’

That's because auto is deducted depending on function return type. So in that case it's enough just to add const if returned value is non-const:

const auto& removed_oem_items = vehicle_data_provider_.GetRemovedVehicleDataItems();

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 agree that there is no sense in const return type here. Removed it from everywhere in interfaces. See 7aa5625

* @param items_before list of vehicle data items before PTU was applied
* @param items_after list of vehicle data items after PTU was applied
*/
void SetRemovedCustomVdItems(
Copy link
Contributor

Choose a reason for hiding this comment

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

@AKalinich-Luxoft I would recommend to divide this method into 2 :

  • One calculates and returns the difference
  • Second stores calculated difference into appropriate place

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 agree. Splitted on two separate functions. See 7aa5625

@AKalinich-Luxoft AKalinich-Luxoft force-pushed the fix/fix_vd_items_subscription_after_ptu branch from db06441 to 8b2a3e4 Compare October 17, 2019 20:47
@jordynmackool
Copy link

@AKalinich-Luxoft please advise when this is ready for Livio review

@dboltovskyi
Copy link
Contributor

@jordynmackool Please notice this PR is ready for review.

@dboltovskyi
Copy link
Contributor

Please notice our team decided to extend test coverage regarding related issue.
Additional ATF test scripts created in smartdevicelink/sdl_atf_test_scripts#2286
However on a current head commit 8b2a3e4 of this PR one new script is failed.
So please notice we're going to push an update.

@dboltovskyi
Copy link
Contributor

@theresalech Please notice update is completed and PR is ready for review.

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.

8 participants