Merge lp://staging/~kzapalowicz/ubuntu-system-settings/fix-1539158 into lp://staging/ubuntu-system-settings

Proposed by Konrad Zapałowicz
Status: Merged
Approved by: Ken VanDine
Approved revision: 1636
Merged at revision: 1665
Proposed branch: lp://staging/~kzapalowicz/ubuntu-system-settings/fix-1539158
Merge into: lp://staging/ubuntu-system-settings
Diff against target: 42 lines (+26/-0)
1 file modified
plugins/bluetooth/devicemodel.cpp (+26/-0)
To merge this branch: bzr merge lp://staging/~kzapalowicz/ubuntu-system-settings/fix-1539158
Reviewer Review Type Date Requested Status
Simon Fels (community) Approve
Jim Hodapp (community) code Approve
Ken VanDine Approve
Review via email: mp+293854@code.staging.launchpad.net

Commit message

Fix pin code request is rejected because device is not valid

When the new device is created either almost or at the same time as the
pin code request is requested there is a race between pin code request
handler and the device initialization code. The pin code request handler
works only with devices which are valid. On the other hand the device is
valid only when it's type is updated. This happens when the properties
are gathered which is done in an asynchronous way. Because of this
asynchronousity it happens too late and by that time the pin code request
is rejected which denies the bonding.

This commit works around this issue by implementing a wait for device to
become valid. In order not to stall the wait is not infinite and the
nullptr is returned when the device cannot be set to valid. This has an
effect only when the addDevice is called from the FindOrCreateDevice
context as in any other case the properties are known by that point.

Description of the change

Fix pin code request is rejected because device is not valid

When the new device is created either almost or at the same time as the
pin code request is requested there is a race between pin code request
handler and the device initialization code. The pin code request handler
works only with devices which are valid. On the other hand the device is
valid only when it's type is updated. This happens when the properties
are gathered which is done in an asynchronous way. Because of this
asynchronousity it happens too late and by that time the pin code request
is rejected which denies the bonding.

This commit works around this issue by implementing a wait for device to
become valid. In order not to stall the wait is not infinite and the
nullptr is returned when the device cannot be set to valid. This has an
effect only when the addDevice is called from the FindOrCreateDevice
context as in any other case the properties are known by that point.

To post a comment you must log in.
Revision history for this message
Ken VanDine (ken-vandine) wrote :

The code looks fine, besides a typo in your comment. Could you please fix "oly" in the comment?

I'm not sure how I can test it though, my car doesn't require a pin.

review: Needs Fixing
1634. By Konrad Zapałowicz

Fix typo in the comment

Revision history for this message
Ken VanDine (ken-vandine) wrote :

Thanks, looks good

review: Approve
Revision history for this message
Jim Hodapp (jhodapp) wrote :

A few comments inline.

review: Needs Fixing (code)
1635. By Konrad Zapałowicz

Improve the documentation and add const correctness

Revision history for this message
Jim Hodapp (jhodapp) wrote :

One minor grammar change in a comment.

review: Needs Fixing
1636. By Konrad Zapałowicz

Fix a typo in the documentation

Revision history for this message
Jim Hodapp (jhodapp) wrote :

LGTM

review: Approve (code)
Revision history for this message
Simon Fels (morphis) wrote :

LGTM

review: Approve
Revision history for this message
Michał Sawicz (saviq) wrote :

FWIW this didn't help in my car, will come up with logs again in a bit.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches