Merge lp:~morphis/ubuntu-system-settings/fix-lp1539158 into lp:ubuntu-system-settings

Proposed by Simon Fels
Status: Merged
Approved by: Ken VanDine
Approved revision: 1609
Merged at revision: 1621
Proposed branch: lp:~morphis/ubuntu-system-settings/fix-lp1539158
Merge into: lp:ubuntu-system-settings
Diff against target: 205 lines (+52/-27)
5 files modified
plugins/bluetooth/agent.cpp (+24/-14)
plugins/bluetooth/agent.h (+2/-0)
plugins/bluetooth/device.cpp (+1/-0)
plugins/bluetooth/devicemodel.cpp (+22/-11)
plugins/bluetooth/devicemodel.h (+3/-2)
To merge this branch: bzr merge lp:~morphis/ubuntu-system-settings/fix-lp1539158
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Ken VanDine Needs Fixing
Konrad Zapałowicz (community) Approve
Review via email: mp+288740@code.launchpad.net

Commit message

Process pairing attempts for unknown devices correctly

Sometimes we get the pairing request for a device first before our device
model is able to add the new device. Because of that we're rejecting an
incoming pairing request which we should not. We're now adding the new
device as first step in our process of handling the pairing request if we
don't know it yet.

Description of the change

Process pairing attempts for unknown devices correctly

Sometimes we get the pairing request for a device first before our device
model is able to add the new device. Because of that we're rejecting an
incoming pairing request which we should not. We're now adding the new
device as first step in our process of handling the pairing request if we
don't know it yet.

To post a comment you must log in.
Revision history for this message
Konrad Zapałowicz (kzapalowicz) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ken VanDine (ken-vandine) wrote :

Looks good, thanks!

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

Sorry, this no longer merges cleanly now that your other branch has landed.

review: Needs Fixing
1609. By Simon Fels

Merge trunk

* Rework Bluetooth device discovery handling
[ Ken VanDine ]
* Added status tracking for updates to be used for system updates.
  Added handling of started signal from system-image-dbus as well as
  ForceAllowGSMDownload (LP: #1508081)
[ Ken VanDine ]
* Enable mouse test and use LD_PRELOAD to fix crash running with Xvfb
* Hide MouseDoubleClickSpeed and TouchpadDoubleClickSpeed settings
  because they are not supported by USC yet.
* Use accountsservice for properties instead of gsettings

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/bluetooth/agent.cpp'
2--- plugins/bluetooth/agent.cpp 2015-10-26 13:19:47 +0000
3+++ plugins/bluetooth/agent.cpp 2016-03-15 14:44:59 +0000
4@@ -40,6 +40,22 @@
5 m_connection.send(msg.createErrorReply(name, text));
6 }
7
8+QSharedPointer<Device> Agent::findOrCreateDevice(const QDBusObjectPath &path)
9+{
10+ auto device = m_devices.getDeviceFromPath(path.path());
11+
12+ // If the device doesn't exist we just couldn't add it to our
13+ // internal list as we didn't received the corresponding dbus
14+ // signal for that yet. This normally happens when a remote device
15+ // wants to pair with us but we didn't discovered that device yet.
16+ // We simply create an entry for this new device then and will
17+ // continue as normal.
18+ if (!device)
19+ device = m_devices.addDeviceFromPath(path);
20+
21+ return device;
22+}
23+
24 /***
25 ****
26 ***/
27@@ -76,8 +92,7 @@
28 */
29 void Agent::RequestConfirmation(const QDBusObjectPath &objectPath, uint passkey)
30 {
31- auto device = m_devices.getDeviceFromPath(objectPath.path());
32- if (device) {
33+ if (auto device = findOrCreateDevice(objectPath)) {
34 const uint tag = m_tag++;
35
36 setDelayedReply(true);
37@@ -114,8 +129,7 @@
38
39 QString Agent::RequestPinCode(const QDBusObjectPath &objectPath)
40 {
41- auto device = m_devices.getDeviceFromPath(objectPath.path());
42- if (device) {
43+ if (auto device = findOrCreateDevice(objectPath)) {
44 const uint tag = m_tag++;
45
46 setDelayedReply(true);
47@@ -142,8 +156,7 @@
48 */
49 unsigned int Agent::RequestPasskey(const QDBusObjectPath &objectPath)
50 {
51- auto device = m_devices.getDeviceFromPath(objectPath.path());
52- if (device) {
53+ if (auto device = findOrCreateDevice(objectPath)) {
54 const uint tag = m_tag++;
55
56 setDelayedReply(true);
57@@ -206,8 +219,7 @@
58
59 void Agent::DisplayPinCode(const QDBusObjectPath &objectPath, QString pincode)
60 {
61- auto device = m_devices.getDeviceFromPath(objectPath.path());
62- if (device) {
63+ if (auto device = findOrCreateDevice(objectPath)) {
64 Q_EMIT(displayPinCodeNeeded(device.data(), pincode));
65 } else {
66 reject(message(), __func__);
67@@ -216,8 +228,7 @@
68
69 void Agent::DisplayPasskey(const QDBusObjectPath &objectPath, uint passkey, ushort entered)
70 {
71- auto device = m_devices.getDeviceFromPath(objectPath.path());
72- if (device) {
73+ if (auto device = findOrCreateDevice(objectPath)) {
74 QString passkeyStr = QString("%1").arg(passkey, 6, 10, QChar('0'));
75 Q_EMIT(displayPasskeyNeeded(device.data(), passkeyStr, entered));
76 } else {
77@@ -236,13 +247,12 @@
78 Q_EMIT(cancelNeeded());
79 }
80
81-void Agent::RequestAuthorization(const QDBusObjectPath &path)
82+void Agent::RequestAuthorization(const QDBusObjectPath &objectPath)
83 {
84 qWarning() << "Authorization requested for device"
85- << path.path();
86+ << objectPath.path();
87
88- auto device = m_devices.getDeviceFromPath(path.path());
89- if (device) {
90+ if (auto device = findOrCreateDevice(objectPath)) {
91 const uint tag = m_tag++;
92
93 setDelayedReply(true);
94
95=== modified file 'plugins/bluetooth/agent.h'
96--- plugins/bluetooth/agent.h 2015-10-26 13:19:47 +0000
97+++ plugins/bluetooth/agent.h 2016-03-15 14:44:59 +0000
98@@ -75,6 +75,8 @@
99
100 void cancel(QDBusMessage msg, const char *functionName);
101 void reject(QDBusMessage msg, const char *functionName);
102+
103+ QSharedPointer<Device> findOrCreateDevice(const QDBusObjectPath &path);
104 };
105
106 Q_DECLARE_METATYPE(Agent*)
107
108=== modified file 'plugins/bluetooth/device.cpp'
109--- plugins/bluetooth/device.cpp 2015-11-19 07:39:12 +0000
110+++ plugins/bluetooth/device.cpp 2016-03-15 14:44:59 +0000
111@@ -27,6 +27,7 @@
112 #include "dbus-shared.h"
113
114 Device::Device(const QString &path, QDBusConnection &bus) :
115+ m_name("unknown"),
116 m_strength(Device::None)
117 {
118 initDevice(path, bus);
119
120=== modified file 'plugins/bluetooth/devicemodel.cpp'
121--- plugins/bluetooth/devicemodel.cpp 2016-03-10 07:51:03 +0000
122+++ plugins/bluetooth/devicemodel.cpp 2016-03-15 14:44:59 +0000
123@@ -494,23 +494,25 @@
124 unblockDiscovery();
125 }
126
127-void DeviceModel::addDevice(const QString &path, const QVariantMap &properties)
128+QSharedPointer<Device> DeviceModel::addDevice(const QString &path, const QVariantMap &properties)
129 {
130 QSharedPointer<Device> device(new Device(path, m_dbus));
131 device->setProperties(properties);
132
133- if (device->isValid()) {
134- QObject::connect(device.data(), SIGNAL(deviceChanged()),
135- this, SLOT(slotDeviceChanged()));
136- QObject::connect(device.data(), SIGNAL(pairingDone(bool)),
137- this, SLOT(slotDevicePairingDone(bool)));
138- QObject::connect(device.data(), SIGNAL(connectionChanged()),
139- this, SLOT(slotDeviceConnectionChanged()));
140- addDevice(device);
141- }
142+ if (!device->isValid())
143+ return QSharedPointer<Device>(nullptr);
144+
145+ QObject::connect(device.data(), SIGNAL(deviceChanged()),
146+ this, SLOT(slotDeviceChanged()));
147+ QObject::connect(device.data(), SIGNAL(pairingDone(bool)),
148+ this, SLOT(slotDevicePairingDone(bool)));
149+ QObject::connect(device.data(), SIGNAL(connectionChanged()),
150+ this, SLOT(slotDeviceConnectionChanged()));
151+
152+ return addDevice(device);
153 }
154
155-void DeviceModel::addDevice(QSharedPointer<Device> &device)
156+QSharedPointer<Device> DeviceModel::addDevice(QSharedPointer<Device> &device)
157 {
158 int row = findRowFromAddress(device->getAddress());
159
160@@ -523,6 +525,8 @@
161 m_devices.append(device);
162 endInsertRows();
163 }
164+
165+ return device;
166 }
167
168 void DeviceModel::removeRow(int row)
169@@ -577,6 +581,13 @@
170 return QSharedPointer<Device>();
171 }
172
173+QSharedPointer<Device> DeviceModel::addDeviceFromPath(const QDBusObjectPath &path)
174+{
175+ qWarning() << "Creating device object for path" << path.path();
176+ QVariantMap noProps;
177+ return addDevice(path.path(), noProps);
178+}
179+
180 void DeviceModel::slotRemoveFinished(QDBusPendingCallWatcher *call)
181 {
182 QDBusPendingReply<void> reply = *call;
183
184=== modified file 'plugins/bluetooth/devicemodel.h'
185--- plugins/bluetooth/devicemodel.h 2016-03-10 07:28:42 +0000
186+++ plugins/bluetooth/devicemodel.h 2016-03-15 14:44:59 +0000
187@@ -67,6 +67,7 @@
188
189 QSharedPointer<Device> getDeviceFromAddress(const QString &address);
190 QSharedPointer<Device> getDeviceFromPath(const QString &path);
191+ QSharedPointer<Device> addDeviceFromPath(const QDBusObjectPath &path);
192 QString adapterName() const { return m_adapterName; }
193 QString adapterAddress() const { return m_adapterAddress; }
194
195@@ -122,8 +123,8 @@
196
197 QList<QSharedPointer<Device> > m_devices;
198 void updateDevices();
199- void addDevice(QSharedPointer<Device> &device);
200- void addDevice(const QString &objectPath, const QVariantMap &properties);
201+ QSharedPointer<Device> addDevice(QSharedPointer<Device> &device);
202+ QSharedPointer<Device> addDevice(const QString &objectPath, const QVariantMap &properties);
203 void removeRow(int i);
204 int findRowFromAddress(const QString &address) const;
205 void emitRowChanged(int row);

Subscribers

People subscribed via source and target branches