Merge lp:~thomas-voss/platform-api/add-controller-and-accuracy into lp:platform-api
- add-controller-and-accuracy
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Ricardo Mendoza |
Approved revision: | 237 |
Merged at revision: | 234 |
Proposed branch: | lp:~thomas-voss/platform-api/add-controller-and-accuracy |
Merge into: | lp:platform-api |
Diff against target: |
724 lines (+351/-78) 15 files modified
debian/control (+1/-1) debian/libubuntu-application-api2.symbols (+4/-0) include/ubuntu/application/location/position_update.h (+40/-0) include/ubuntu/visibility.h (+2/-0) src/ubuntu/application/common/application/location/controller.cpp (+27/-1) src/ubuntu/application/common/application/location/controller_p.h (+1/-0) src/ubuntu/application/common/application/location/heading_update.cpp (+1/-1) src/ubuntu/application/common/application/location/instance.h (+71/-0) src/ubuntu/application/common/application/location/position_update.cpp (+32/-4) src/ubuntu/application/common/application/location/ref_counted.h (+1/-1) src/ubuntu/application/common/application/location/service.cpp (+16/-41) src/ubuntu/application/common/application/location/session.cpp (+50/-24) src/ubuntu/application/common/application/location/session_p.h (+100/-4) src/ubuntu/application/common/application/location/velocity_update.cpp (+1/-1) src/ubuntu/application/ubuntu_application_api.cpp (+4/-0) |
To merge this branch: | bzr merge lp:~thomas-voss/platform-api/add-controller-and-accuracy |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Needs Fixing | |
Ubuntu Phablet Team | Pending | ||
Review via email: mp+224107@code.launchpad.net |
Commit message
Adjust to API changes in location service.
Implement controller interface.
Add functions to query the accuracy estimates for a position update.
Description of the change
Adjust to API changes in location service.
Implement controller interface.
Add functions to query the accuracy estimates for a position update.
PS Jenkins bot (ps-jenkins) wrote : | # |
- 230. By Thomas Voß
-
Adjust flags value correctly.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:230
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 231. By Thomas Voß
-
Catch possible exceptions when interacting with the remote location service instance.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:231
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 232. By Thomas Voß
-
Remove Google log macros with sprintfs.
- 233. By Thomas Voß
-
sprintf really should be fprintf.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:232
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:233
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 234. By Thomas Voß
-
[ Ricardo Mendoza ]
* Added orientation sensor, extended existing sensor API to allow
for dynamic event rate setting.
[ Ubuntu daily release ]
* debian/*symbols: auto-update new symbols to released version - 235. By Thomas Voß
-
Expose symbols for horizontal and vertical accuracy.
- 236. By Thomas Voß
-
Adjust symbols file.
- 237. By Thomas Voß
-
Add a versioned build-dependency on location service.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:236
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:237
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 238. By Thomas Voß
-
[ Ricardo Mendoza ]
Add missing enable/disable functions for haptic - 239. By Thomas Voß
-
Clean up event connections on destruction.
- 240. By Thomas Voß
-
Make destruction thread-safe.
- 241. By Thomas Voß
-
Make sure that handlers and contexts are setup before creating event connections.
- 242. By Thomas Voß
-
Make sure that refcounted elements are actually deleted.
Preview Diff
1 | === modified file 'debian/control' |
2 | --- debian/control 2014-06-13 16:31:35 +0000 |
3 | +++ debian/control 2014-06-26 20:03:03 +0000 |
4 | @@ -15,7 +15,7 @@ |
5 | liburl-dispatcher1-dev, |
6 | libdbus-1-dev, |
7 | libdbus-cpp-dev (>= 2.0.0), |
8 | - libubuntu-location-service-dev, |
9 | + libubuntu-location-service-dev (>= 1.0.0),, |
10 | libgtest-dev, |
11 | libprocess-cpp-dev (>= 0.0.1+14.04.20131212), |
12 | libproperties-cpp-dev, |
13 | |
14 | === modified file 'debian/libubuntu-application-api2.symbols' |
15 | --- debian/libubuntu-application-api2.symbols 2014-06-23 16:39:57 +0000 |
16 | +++ debian/libubuntu-application-api2.symbols 2014-06-26 20:03:03 +0000 |
17 | @@ -25,10 +25,14 @@ |
18 | ua_location_heading_update_ref@Base 0.18.3+13.10.20130807 |
19 | ua_location_heading_update_unref@Base 0.18.3+13.10.20130807 |
20 | ua_location_position_update_get_altitude_in_meter@Base 0.18.3+13.10.20130807 |
21 | + ua_location_position_update_get_horizontal_accuracy_in_meter@Base 0replaceme |
22 | ua_location_position_update_get_latitude_in_degree@Base 0.18.3+13.10.20130807 |
23 | ua_location_position_update_get_longitude_in_degree@Base 0.18.3+13.10.20130807 |
24 | ua_location_position_update_get_timestamp@Base 0.18.3+13.10.20130807 |
25 | + ua_location_position_update_get_vertical_accuracy_in_meter@Base 0replaceme |
26 | ua_location_position_update_has_altitude@Base 0.18.3+13.10.20130807 |
27 | + ua_location_position_update_has_horizontal_accuracy@Base 0replaceme |
28 | + ua_location_position_update_has_vertical_accuracy@Base 0replaceme |
29 | ua_location_position_update_ref@Base 0.18.3+13.10.20130807 |
30 | ua_location_position_update_unref@Base 0.18.3+13.10.20130807 |
31 | ua_location_service_controller_disable_gps@Base 0.18.3+13.10.20130826 |
32 | |
33 | === modified file 'include/ubuntu/application/location/position_update.h' |
34 | --- include/ubuntu/application/location/position_update.h 2013-08-22 07:03:49 +0000 |
35 | +++ include/ubuntu/application/location/position_update.h 2014-06-26 20:03:03 +0000 |
36 | @@ -103,6 +103,46 @@ |
37 | ua_location_position_update_get_altitude_in_meter( |
38 | UALocationPositionUpdate *update); |
39 | |
40 | + /** |
41 | + * \brief Checks if the position update contains a horizontal accuracy estimate. |
42 | + * \ingroup location_service |
43 | + * \returns TRUE if the update contains a horizontal accuracy estimate, else FALSE. |
44 | + * \param[in] update The position update instance to be queried. |
45 | + */ |
46 | + UBUNTU_DLL_PUBLIC bool |
47 | + ua_location_position_update_has_horizontal_accuracy( |
48 | + UALocationPositionUpdate *update); |
49 | + |
50 | + /** |
51 | + * \brief Queries the horizontal accuracy contained in the position update. |
52 | + * \ingroup location_service |
53 | + * \returns The horizontal accuracy of the position update in [m]. |
54 | + * \param[in] update The position update instance to be queried. |
55 | + */ |
56 | + UBUNTU_DLL_PUBLIC double |
57 | + ua_location_position_update_get_horizontal_accuracy_in_meter( |
58 | + UALocationPositionUpdate *update); |
59 | + |
60 | + /** |
61 | + * \brief Checks if the position update contains a vertical accuracy estimate. |
62 | + * \ingroup location_service |
63 | + * \returns TRUE if the update contains a vertical accuracy estimate, else FALSE. |
64 | + * \param[in] update The position update instance to be queried. |
65 | + */ |
66 | + UBUNTU_DLL_PUBLIC bool |
67 | + ua_location_position_update_has_vertical_accuracy( |
68 | + UALocationPositionUpdate *update); |
69 | + |
70 | + /** |
71 | + * \brief Queries the vertical accuracy contained in the position update. |
72 | + * \ingroup location_service |
73 | + * \returns The vertical accuracy of the position update in [m]. |
74 | + * \param[in] update The position update instance to be queried. |
75 | + */ |
76 | + UBUNTU_DLL_PUBLIC double |
77 | + ua_location_position_update_get_vertical_accuracy_in_meter( |
78 | + UALocationPositionUpdate *update); |
79 | + |
80 | #ifdef __cplusplus |
81 | } |
82 | #endif |
83 | |
84 | === modified file 'include/ubuntu/visibility.h' |
85 | --- include/ubuntu/visibility.h 2013-08-22 06:32:14 +0000 |
86 | +++ include/ubuntu/visibility.h 2014-06-26 20:03:03 +0000 |
87 | @@ -21,8 +21,10 @@ |
88 | |
89 | #if __GNUC__ >= 4 |
90 | #define UBUNTU_DLL_PUBLIC __attribute__ ((visibility ("default"))) |
91 | +#define UBUNTU_DLL_LOCAL __attribute__ ((visibility ("hidden"))) |
92 | #else |
93 | #define UBUNTU_DLL_PUBLIC |
94 | +#define UBUNTU_DLL_LOCAL |
95 | #endif |
96 | |
97 | #endif /* UBUNTU_VISIBILITY_H_ */ |
98 | |
99 | === modified file 'src/ubuntu/application/common/application/location/controller.cpp' |
100 | --- src/ubuntu/application/common/application/location/controller.cpp 2013-08-23 10:55:16 +0000 |
101 | +++ src/ubuntu/application/common/application/location/controller.cpp 2014-06-26 20:03:03 +0000 |
102 | @@ -19,6 +19,7 @@ |
103 | #include "ubuntu/application/location/controller.h" |
104 | |
105 | #include "controller_p.h" |
106 | +#include "instance.h" |
107 | |
108 | void |
109 | ua_location_service_controller_ref( |
110 | @@ -51,7 +52,20 @@ |
111 | UALocationServiceStatusFlags *out_flags) |
112 | { |
113 | (void) controller; |
114 | - (void) out_flags; |
115 | + |
116 | + *out_flags = 0; |
117 | + |
118 | + auto service = Instance::instance().get_service(); |
119 | + |
120 | + if (service->is_online().get()) |
121 | + *out_flags |= UA_LOCATION_SERVICE_ENABLED; |
122 | + else |
123 | + *out_flags |= UA_LOCATION_SERVICE_DISABLED; |
124 | + |
125 | + if (service->does_satellite_based_positioning().get()) |
126 | + *out_flags |= UA_LOCATION_SERVICE_GPS_ENABLED; |
127 | + else |
128 | + *out_flags |= UA_LOCATION_SERVICE_GPS_DISABLED; |
129 | |
130 | return U_STATUS_SUCCESS; |
131 | } |
132 | @@ -62,6 +76,9 @@ |
133 | { |
134 | (void) controller; |
135 | |
136 | + auto service = Instance::instance().get_service(); |
137 | + service->is_online().set(true); |
138 | + |
139 | return U_STATUS_SUCCESS; |
140 | } |
141 | |
142 | @@ -70,6 +87,9 @@ |
143 | UALocationServiceController *controller) |
144 | { |
145 | (void) controller; |
146 | + |
147 | + auto service = Instance::instance().get_service(); |
148 | + service->is_online().set(false); |
149 | |
150 | return U_STATUS_SUCCESS; |
151 | } |
152 | @@ -80,6 +100,9 @@ |
153 | { |
154 | (void) controller; |
155 | |
156 | + auto service = Instance::instance().get_service(); |
157 | + service->does_satellite_based_positioning().set(true); |
158 | + |
159 | return U_STATUS_SUCCESS; |
160 | } |
161 | |
162 | @@ -89,5 +112,8 @@ |
163 | { |
164 | (void) controller; |
165 | |
166 | + auto service = Instance::instance().get_service(); |
167 | + service->does_satellite_based_positioning().set(false); |
168 | + |
169 | return U_STATUS_SUCCESS; |
170 | } |
171 | |
172 | === modified file 'src/ubuntu/application/common/application/location/controller_p.h' |
173 | --- src/ubuntu/application/common/application/location/controller_p.h 2013-08-21 14:59:45 +0000 |
174 | +++ src/ubuntu/application/common/application/location/controller_p.h 2014-06-26 20:03:03 +0000 |
175 | @@ -25,6 +25,7 @@ |
176 | |
177 | struct UbuntuApplicationLocationServiceController : public detail::RefCounted |
178 | { |
179 | + |
180 | }; |
181 | |
182 | #endif // CONTROLLER_PRIVATE_H_ |
183 | |
184 | === modified file 'src/ubuntu/application/common/application/location/heading_update.cpp' |
185 | --- src/ubuntu/application/common/application/location/heading_update.cpp 2013-08-19 06:46:47 +0000 |
186 | +++ src/ubuntu/application/common/application/location/heading_update.cpp 2014-06-26 20:03:03 +0000 |
187 | @@ -51,5 +51,5 @@ |
188 | ua_location_heading_update_get_heading_in_degree( |
189 | UALocationHeadingUpdate *update) |
190 | { |
191 | - return update->update.value.value.value(); |
192 | + return update->update.value.value(); |
193 | } |
194 | |
195 | === added file 'src/ubuntu/application/common/application/location/instance.h' |
196 | --- src/ubuntu/application/common/application/location/instance.h 1970-01-01 00:00:00 +0000 |
197 | +++ src/ubuntu/application/common/application/location/instance.h 2014-06-26 20:03:03 +0000 |
198 | @@ -0,0 +1,71 @@ |
199 | +/* |
200 | + * Copyright © 2013 Canonical Ltd. |
201 | + * |
202 | + * This program is free software: you can redistribute it and/or modify |
203 | + * it under the terms of the GNU Lesser General Public License version 3 as |
204 | + * published by the Free Software Foundation. |
205 | + * |
206 | + * This program is distributed in the hope that it will be useful, |
207 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
208 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
209 | + * GNU Lesser General Public License for more details. |
210 | + * |
211 | + * You should have received a copy of the GNU Lesser General Public License |
212 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
213 | + * |
214 | + * Authored by: Thomas Voß <thomas.voss@canonical.com> |
215 | + */ |
216 | + |
217 | +#ifndef INSTANCE_H_ |
218 | +#define INSTANCE_H_ |
219 | + |
220 | +#include "ubuntu/visibility.h" |
221 | + |
222 | +#include <com/ubuntu/location/service/stub.h> |
223 | + |
224 | +#include <core/dbus/resolver.h> |
225 | +#include <core/dbus/asio/executor.h> |
226 | + |
227 | +#include <thread> |
228 | + |
229 | +class UBUNTU_DLL_LOCAL Instance |
230 | +{ |
231 | + public: |
232 | + static Instance& instance() |
233 | + { |
234 | + static Instance inst; |
235 | + return inst; |
236 | + } |
237 | + |
238 | + const com::ubuntu::location::service::Interface::Ptr& get_service() const |
239 | + { |
240 | + return service; |
241 | + } |
242 | + |
243 | + private: |
244 | + Instance() : bus(std::make_shared<core::dbus::Bus>(core::dbus::WellKnownBus::system)), |
245 | + executor(core::dbus::asio::make_executor(bus)), |
246 | + service(core::dbus::resolve_service_on_bus< |
247 | + com::ubuntu::location::service::Interface, |
248 | + com::ubuntu::location::service::Stub |
249 | + >(bus)) |
250 | + { |
251 | + bus->install_executor(executor); |
252 | + worker = std::move(std::thread([&]() { bus->run(); })); |
253 | + } |
254 | + |
255 | + ~Instance() noexcept |
256 | + { |
257 | + bus->stop(); |
258 | + |
259 | + if (worker.joinable()) |
260 | + worker.join(); |
261 | + } |
262 | + |
263 | + core::dbus::Bus::Ptr bus; |
264 | + core::dbus::Executor::Ptr executor; |
265 | + com::ubuntu::location::service::Interface::Ptr service; |
266 | + std::thread worker; |
267 | +}; |
268 | + |
269 | +#endif // INSTANCE_H_ |
270 | |
271 | === modified file 'src/ubuntu/application/common/application/location/position_update.cpp' |
272 | --- src/ubuntu/application/common/application/location/position_update.cpp 2013-08-19 06:46:47 +0000 |
273 | +++ src/ubuntu/application/common/application/location/position_update.cpp 2014-06-26 20:03:03 +0000 |
274 | @@ -51,26 +51,54 @@ |
275 | ua_location_position_update_get_latitude_in_degree( |
276 | UALocationPositionUpdate *update) |
277 | { |
278 | - return update->update.value.latitude().value.value(); |
279 | + return update->update.value.latitude.value.value(); |
280 | } |
281 | |
282 | double |
283 | ua_location_position_update_get_longitude_in_degree( |
284 | UALocationPositionUpdate *update) |
285 | { |
286 | - return update->update.value.longitude().value.value(); |
287 | + return update->update.value.longitude.value.value(); |
288 | } |
289 | |
290 | bool |
291 | ua_location_position_update_has_altitude( |
292 | UALocationPositionUpdate *update) |
293 | { |
294 | - return update->update.value.has_altitude(); |
295 | + return update->update.value.altitude; |
296 | } |
297 | |
298 | double |
299 | ua_location_position_update_get_altitude_in_meter( |
300 | UALocationPositionUpdate *update) |
301 | { |
302 | - return update->update.value.altitude().value.value(); |
303 | + return update->update.value.altitude->value.value(); |
304 | +} |
305 | + |
306 | +bool |
307 | +ua_location_position_update_has_horizontal_accuracy( |
308 | + UALocationPositionUpdate *update) |
309 | +{ |
310 | + return update->update.value.accuracy.horizontal; |
311 | +} |
312 | + |
313 | +double |
314 | +ua_location_position_update_get_horizontal_accuracy_in_meter( |
315 | + UALocationPositionUpdate *update) |
316 | +{ |
317 | + return update->update.value.accuracy.horizontal->value(); |
318 | +} |
319 | + |
320 | +bool |
321 | +ua_location_position_update_has_vertical_accuracy( |
322 | + UALocationPositionUpdate *update) |
323 | +{ |
324 | + return update->update.value.accuracy.vertical; |
325 | +} |
326 | + |
327 | +double |
328 | +ua_location_position_update_get_vertical_accuracy_in_meter( |
329 | + UALocationPositionUpdate *update) |
330 | +{ |
331 | + return update->update.value.accuracy.vertical->value(); |
332 | } |
333 | |
334 | === modified file 'src/ubuntu/application/common/application/location/ref_counted.h' |
335 | --- src/ubuntu/application/common/application/location/ref_counted.h 2013-08-19 06:47:19 +0000 |
336 | +++ src/ubuntu/application/common/application/location/ref_counted.h 2014-06-26 20:03:03 +0000 |
337 | @@ -32,7 +32,7 @@ |
338 | bool operator==(const RefCounted&) const = delete; |
339 | |
340 | void ref() { counter.fetch_add(1); } |
341 | - void unref() { if (0 == counter.fetch_sub(1)) { delete this; } } |
342 | + void unref() { if (1 == counter.fetch_sub(1)) { delete this; } } |
343 | |
344 | protected: |
345 | RefCounted() : counter(1) |
346 | |
347 | === modified file 'src/ubuntu/application/common/application/location/service.cpp' |
348 | --- src/ubuntu/application/common/application/location/service.cpp 2014-01-31 13:35:28 +0000 |
349 | +++ src/ubuntu/application/common/application/location/service.cpp 2014-06-26 20:03:03 +0000 |
350 | @@ -19,6 +19,7 @@ |
351 | #include "ubuntu/application/location/service.h" |
352 | |
353 | #include "controller_p.h" |
354 | +#include "instance.h" |
355 | #include "session_p.h" |
356 | |
357 | #include <com/ubuntu/location/service/stub.h> |
358 | @@ -30,45 +31,6 @@ |
359 | namespace cul = com::ubuntu::location; |
360 | namespace culs = com::ubuntu::location::service; |
361 | |
362 | -namespace |
363 | -{ |
364 | -class Instance |
365 | -{ |
366 | - public: |
367 | - static Instance& instance() |
368 | - { |
369 | - static Instance inst; |
370 | - return inst; |
371 | - } |
372 | - |
373 | - const culs::Interface::Ptr& get_service() const |
374 | - { |
375 | - return service; |
376 | - } |
377 | - |
378 | - private: |
379 | - Instance() : bus(std::make_shared<dbus::Bus>(dbus::WellKnownBus::system)), |
380 | - executor(dbus::asio::make_executor(bus)), |
381 | - service(dbus::resolve_service_on_bus<culs::Interface, culs::Stub>(bus)) |
382 | - { |
383 | - bus->install_executor(executor); |
384 | - worker = std::move(std::thread([&]() { bus->run(); })); |
385 | - } |
386 | - |
387 | - ~Instance() noexcept |
388 | - { |
389 | - if (worker.joinable()) |
390 | - worker.join(); |
391 | - } |
392 | - |
393 | - dbus::Bus::Ptr bus; |
394 | - dbus::Executor::Ptr executor; |
395 | - culs::Interface::Ptr service; |
396 | - std::thread worker; |
397 | -}; |
398 | - |
399 | -} |
400 | - |
401 | UALocationServiceSession* |
402 | ua_location_service_create_session_for_low_accuracy( |
403 | UALocationServiceRequirementsFlags /*flags*/) |
404 | @@ -81,8 +43,21 @@ |
405 | ua_location_service_create_session_for_high_accuracy( |
406 | UALocationServiceRequirementsFlags /*flags*/) |
407 | { |
408 | - return new UbuntuApplicationLocationServiceSession{ |
409 | - Instance::instance().get_service()->create_session_for_criteria(cul::Criteria{})}; |
410 | + try |
411 | + { |
412 | + return new UbuntuApplicationLocationServiceSession |
413 | + { |
414 | + Instance::instance().get_service()->create_session_for_criteria(cul::Criteria{}) |
415 | + }; |
416 | + } catch(const std::exception& e) |
417 | + { |
418 | + fprintf(stderr, "Error creating session for high accuracy: %s \n", e.what()); |
419 | + } catch(...) |
420 | + { |
421 | + fprintf(stderr, "Error creating session for high accuracy.\n"); |
422 | + } |
423 | + |
424 | + return NULL; |
425 | } |
426 | |
427 | UALocationServiceController* |
428 | |
429 | === modified file 'src/ubuntu/application/common/application/location/session.cpp' |
430 | --- src/ubuntu/application/common/application/location/session.cpp 2013-08-19 06:46:47 +0000 |
431 | +++ src/ubuntu/application/common/application/location/session.cpp 2014-06-26 20:03:03 +0000 |
432 | @@ -24,6 +24,8 @@ |
433 | #include "position_update_p.h" |
434 | #include "velocity_update_p.h" |
435 | |
436 | +namespace location = com::ubuntu::location; |
437 | + |
438 | void |
439 | ua_location_service_session_ref( |
440 | UALocationServiceSession *session) |
441 | @@ -47,12 +49,18 @@ |
442 | void *context) |
443 | { |
444 | auto s = static_cast<UbuntuApplicationLocationServiceSession*>(session); |
445 | - s->session->install_position_updates_handler( |
446 | - [handler, context](const com::ubuntu::location::Update<com::ubuntu::location::Position>& new_position) |
447 | - { |
448 | - UbuntuApplicationLocationPositionUpdate pu{new_position}; |
449 | - handler(std::addressof(pu), context); |
450 | - }); |
451 | + try |
452 | + { |
453 | + std::lock_guard<std::mutex> lg(s->position_updates.guard); |
454 | + s->position_updates.handler = handler; |
455 | + s->position_updates.context = context; |
456 | + } catch(const std::exception& e) |
457 | + { |
458 | + fprintf(stderr, "Error setting up position updates handler: %s \n", e.what()); |
459 | + } catch(...) |
460 | + { |
461 | + fprintf(stderr, "Error setting up position updates handler.\n"); |
462 | + } |
463 | } |
464 | |
465 | void |
466 | @@ -62,12 +70,18 @@ |
467 | void *context) |
468 | { |
469 | auto s = static_cast<UbuntuApplicationLocationServiceSession*>(session); |
470 | - s->session->install_heading_updates_handler( |
471 | - [handler, context](const com::ubuntu::location::Update<com::ubuntu::location::Heading>& new_heading) |
472 | - { |
473 | - UbuntuApplicationLocationHeadingUpdate hu{new_heading}; |
474 | - handler(std::addressof(hu), context); |
475 | - }); |
476 | + try |
477 | + { |
478 | + std::lock_guard<std::mutex> lg(s->heading_updates.guard); |
479 | + s->heading_updates.handler = handler; |
480 | + s->heading_updates.context = context; |
481 | + } catch(const std::exception& e) |
482 | + { |
483 | + fprintf(stderr, "Error setting up heading updates handler: %s \n", e.what()); |
484 | + } catch(...) |
485 | + { |
486 | + fprintf(stderr, "Error setting up heading updates handler. \n"); |
487 | + } |
488 | } |
489 | |
490 | void |
491 | @@ -77,12 +91,18 @@ |
492 | void *context) |
493 | { |
494 | auto s = static_cast<UbuntuApplicationLocationServiceSession*>(session); |
495 | - s->session->install_velocity_updates_handler( |
496 | - [handler, context](const com::ubuntu::location::Update<com::ubuntu::location::Velocity>& new_velocity) |
497 | - { |
498 | - UbuntuApplicationLocationVelocityUpdate vu{new_velocity}; |
499 | - handler(std::addressof(vu), context); |
500 | - }); |
501 | + try |
502 | + { |
503 | + std::lock_guard<std::mutex> lg(s->velocity_updates.guard); |
504 | + s->velocity_updates.handler = handler; |
505 | + s->velocity_updates.context = context; |
506 | + } catch(const std::exception& e) |
507 | + { |
508 | + fprintf(stderr, "Error setting up velocity updates handler: %s \n", e.what()); |
509 | + } catch(...) |
510 | + { |
511 | + fprintf(stderr, "Error setting up velocity updates handler."); |
512 | + } |
513 | } |
514 | |
515 | UStatus |
516 | @@ -95,7 +115,8 @@ |
517 | |
518 | try |
519 | { |
520 | - s->session->start_position_updates(); |
521 | + s->session->updates().position_status.set( |
522 | + location::service::session::Interface::Updates::Status::enabled); |
523 | } catch(...) |
524 | { |
525 | return U_STATUS_ERROR; |
526 | @@ -114,7 +135,8 @@ |
527 | |
528 | try |
529 | { |
530 | - s->session->stop_position_updates(); |
531 | + s->session->updates().position_status.set( |
532 | + location::service::session::Interface::Updates::Status::disabled); |
533 | } catch(...) |
534 | { |
535 | } |
536 | @@ -130,7 +152,8 @@ |
537 | |
538 | try |
539 | { |
540 | - s->session->start_heading_updates(); |
541 | + s->session->updates().heading_status.set( |
542 | + location::service::session::Interface::Updates::Status::enabled); |
543 | } catch(...) |
544 | { |
545 | return U_STATUS_ERROR; |
546 | @@ -149,7 +172,8 @@ |
547 | |
548 | try |
549 | { |
550 | - s->session->stop_heading_updates(); |
551 | + s->session->updates().heading_status.set( |
552 | + location::service::session::Interface::Updates::Status::disabled); |
553 | } catch(...) |
554 | { |
555 | } |
556 | @@ -165,7 +189,8 @@ |
557 | |
558 | try |
559 | { |
560 | - s->session->start_velocity_updates(); |
561 | + s->session->updates().velocity_status.set( |
562 | + location::service::session::Interface::Updates::Status::enabled); |
563 | } catch(...) |
564 | { |
565 | return U_STATUS_ERROR; |
566 | @@ -184,7 +209,8 @@ |
567 | |
568 | try |
569 | { |
570 | - s->session->stop_velocity_updates(); |
571 | + s->session->updates().velocity_status.set( |
572 | + location::service::session::Interface::Updates::Status::disabled); |
573 | } catch(...) |
574 | { |
575 | } |
576 | |
577 | === modified file 'src/ubuntu/application/common/application/location/session_p.h' |
578 | --- src/ubuntu/application/common/application/location/session_p.h 2013-08-19 06:46:47 +0000 |
579 | +++ src/ubuntu/application/common/application/location/session_p.h 2014-06-26 20:03:03 +0000 |
580 | @@ -22,18 +22,114 @@ |
581 | |
582 | #include "ref_counted.h" |
583 | |
584 | +#include "heading_update_p.h" |
585 | +#include "position_update_p.h" |
586 | +#include "velocity_update_p.h" |
587 | + |
588 | #include <com/ubuntu/location/service/session/interface.h> |
589 | |
590 | +#include <mutex> |
591 | + |
592 | +namespace cul = com::ubuntu::location; |
593 | namespace culss = com::ubuntu::location::service::session; |
594 | |
595 | struct UbuntuApplicationLocationServiceSession : public detail::RefCounted |
596 | { |
597 | UbuntuApplicationLocationServiceSession(const culss::Interface::Ptr& session) |
598 | - : session(session) |
599 | - { |
600 | - } |
601 | - |
602 | + : session(session), |
603 | + connections |
604 | + { |
605 | + session->updates().position.changed().connect( |
606 | + [this](const cul::Update<cul::Position>& new_position) |
607 | + { |
608 | + try |
609 | + { |
610 | + std::lock_guard<std::mutex> lg(position_updates.guard); |
611 | + |
612 | + UbuntuApplicationLocationPositionUpdate pu{new_position}; |
613 | + if (position_updates.handler) position_updates.handler( |
614 | + std::addressof(pu), |
615 | + position_updates.context); |
616 | + } catch(...) |
617 | + { |
618 | + // We silently ignore the issue and keep going. |
619 | + } |
620 | + }), |
621 | + session->updates().heading.changed().connect( |
622 | + [this](const cul::Update<cul::Heading>& new_heading) |
623 | + { |
624 | + try |
625 | + { |
626 | + std::lock_guard<std::mutex> lg(heading_updates.guard); |
627 | + UbuntuApplicationLocationHeadingUpdate hu{new_heading}; |
628 | + if (heading_updates.handler) heading_updates.handler( |
629 | + std::addressof(hu), |
630 | + heading_updates.context); |
631 | + } catch(...) |
632 | + { |
633 | + // We silently ignore the issue and keep going. |
634 | + } |
635 | + }), |
636 | + session->updates().velocity.changed().connect( |
637 | + [this](const cul::Update<cul::Velocity>& new_velocity) |
638 | + { |
639 | + try |
640 | + { |
641 | + std::lock_guard<std::mutex> lg(velocity_updates.guard); |
642 | + |
643 | + UbuntuApplicationLocationVelocityUpdate vu{new_velocity}; |
644 | + if (velocity_updates.handler) velocity_updates.handler( |
645 | + std::addressof(vu), |
646 | + velocity_updates.context); |
647 | + } catch(...) |
648 | + { |
649 | + // We silently ignore the issue and keep going. |
650 | + } |
651 | + }), |
652 | + } |
653 | + { |
654 | + } |
655 | + |
656 | + ~UbuntuApplicationLocationServiceSession() |
657 | + { |
658 | + std::lock_guard<std::mutex> lgp(position_updates.guard); |
659 | + std::lock_guard<std::mutex> lgh(heading_updates.guard); |
660 | + std::lock_guard<std::mutex> lgv(velocity_updates.guard); |
661 | + |
662 | + position_updates.handler = nullptr; |
663 | + heading_updates.handler = nullptr; |
664 | + velocity_updates.handler = nullptr; |
665 | + } |
666 | + |
667 | culss::Interface::Ptr session; |
668 | + |
669 | + struct |
670 | + { |
671 | + std::mutex guard; |
672 | + UALocationServiceSessionPositionUpdatesHandler handler{nullptr}; |
673 | + void* context{nullptr}; |
674 | + } position_updates{}; |
675 | + |
676 | + struct |
677 | + { |
678 | + std::mutex guard; |
679 | + UALocationServiceSessionHeadingUpdatesHandler handler{nullptr}; |
680 | + void* context{nullptr}; |
681 | + } heading_updates{}; |
682 | + |
683 | + struct |
684 | + { |
685 | + std::mutex guard; |
686 | + UALocationServiceSessionVelocityUpdatesHandler handler{nullptr}; |
687 | + void* context{nullptr}; |
688 | + } velocity_updates{}; |
689 | + |
690 | + struct |
691 | + { |
692 | + core::ScopedConnection position_updates; |
693 | + core::ScopedConnection heading_updates; |
694 | + core::ScopedConnection velocity_updates; |
695 | + } connections; |
696 | }; |
697 | |
698 | #endif // SESSION_PRIVATE_H_ |
699 | |
700 | === modified file 'src/ubuntu/application/common/application/location/velocity_update.cpp' |
701 | --- src/ubuntu/application/common/application/location/velocity_update.cpp 2013-08-19 06:46:47 +0000 |
702 | +++ src/ubuntu/application/common/application/location/velocity_update.cpp 2014-06-26 20:03:03 +0000 |
703 | @@ -51,5 +51,5 @@ |
704 | ua_location_velocity_update_get_velocity_in_meters_per_second( |
705 | UALocationVelocityUpdate *update) |
706 | { |
707 | - return update->update.value.value.value(); |
708 | + return update->update.value.value(); |
709 | } |
710 | |
711 | === modified file 'src/ubuntu/application/ubuntu_application_api.cpp' |
712 | --- src/ubuntu/application/ubuntu_application_api.cpp 2014-06-16 13:42:24 +0000 |
713 | +++ src/ubuntu/application/ubuntu_application_api.cpp 2014-06-26 20:03:03 +0000 |
714 | @@ -214,6 +214,10 @@ |
715 | IMPLEMENT_FUNCTION1(double, ua_location_position_update_get_longitude_in_degree, UALocationPositionUpdate*); |
716 | IMPLEMENT_FUNCTION1(bool, ua_location_position_update_has_altitude, UALocationPositionUpdate*); |
717 | IMPLEMENT_FUNCTION1(double, ua_location_position_update_get_altitude_in_meter, UALocationPositionUpdate*); |
718 | +IMPLEMENT_FUNCTION1(bool, ua_location_position_update_has_horizontal_accuracy, UALocationPositionUpdate*); |
719 | +IMPLEMENT_FUNCTION1(double, ua_location_position_update_get_horizontal_accuracy_in_meter, UALocationPositionUpdate*); |
720 | +IMPLEMENT_FUNCTION1(bool, ua_location_position_update_has_vertical_accuracy, UALocationPositionUpdate*); |
721 | +IMPLEMENT_FUNCTION1(double, ua_location_position_update_get_vertical_accuracy_in_meter, UALocationPositionUpdate*); |
722 | IMPLEMENT_FUNCTION1(UALocationServiceSession*, ua_location_service_create_session_for_low_accuracy, UALocationServiceRequirementsFlags); |
723 | IMPLEMENT_FUNCTION1(UALocationServiceSession*, ua_location_service_create_session_for_high_accuracy, UALocationServiceRequirementsFlags); |
724 | IMPLEMENT_CTOR0(UALocationServiceController*, ua_location_service_create_controller); |
FAILED: Continuous integration, rev:229 jenkins. qa.ubuntu. com/job/ platform- api-ci/ 323/ jenkins. qa.ubuntu. com/job/ platform- api-utopic- amd64-ci/ 56/console jenkins. qa.ubuntu. com/job/ platform- api-utopic- armhf-ci/ 56/console jenkins. qa.ubuntu. com/job/ platform- api-utopic- i386-ci/ 56/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/platform- api-ci/ 323/rebuild
http://