Merge lp:~thomas-voss/platform-api/expose_accuracy_and_service_status_to_platform into lp:platform-api

Proposed by Thomas Voß
Status: Superseded
Proposed branch: lp:~thomas-voss/platform-api/expose_accuracy_and_service_status_to_platform
Merge into: lp:platform-api
Diff against target: 467 lines (+146/-47)
12 files modified
doc/Doxyfile.in (+1/-1)
include/ubuntu/application/location/controller.h (+1/-3)
include/ubuntu/application/location/position_update.h (+30/-0)
src/ubuntu/application/location/CMakeLists.txt (+6/-2)
src/ubuntu/application/location/controller.cpp (+40/-13)
src/ubuntu/application/location/controller_p.h (+13/-0)
src/ubuntu/application/location/heading_update.cpp (+1/-1)
src/ubuntu/application/location/position_update.cpp (+25/-4)
src/ubuntu/application/location/service.cpp (+7/-6)
src/ubuntu/application/location/session.cpp (+20/-16)
src/ubuntu/application/location/velocity_update.cpp (+1/-1)
tests/CMakeLists.txt (+1/-0)
To merge this branch: bzr merge lp:~thomas-voss/platform-api/expose_accuracy_and_service_status_to_platform
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Ubuntu Phablet Team Pending
Review via email: mp+201884@code.launchpad.net

This proposal has been superseded by a proposal from 2014-01-22.

Commit message

Account for changes in the location service interface.
Wire up controller to talk to the service for enabling/disabling positioning and gps status.

Description of the change

Account for changes in the location service interface.
Wire up controller to talk to the service for enabling/disabling positioning and gps status.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
185. By Thomas Voß

Add missing build dependencies on libproperties-cpp-dev and libdbus-cpp-dev.

186. By Thomas Voß

[ Martin Pitt ]
* Add backend for simulated sensor data.
[ Albert Astals ]
* Build fixes and typos.
[ Ricardo Mendoza ]
* Build fixes and typos.
[ Ubuntu daily release ]
* Automatic snapshot from revision 183

187. By Thomas Voß

Add versioned dep on libubuntu-location-service-dev.

188. By Thomas Voß

debian/rules: Fix setting of compiler version to work around regression in recent cmake [Martin Pitt]

189. By Thomas Voß

Fix whitespace.

190. By Thomas Voß

Merge with lp:~xnox/platform-api/compilers.

191. By Thomas Voß

Fix i386 build.

Unmerged revisions

191. By Thomas Voß

Fix i386 build.

190. By Thomas Voß

Merge with lp:~xnox/platform-api/compilers.

189. By Thomas Voß

Fix whitespace.

188. By Thomas Voß

debian/rules: Fix setting of compiler version to work around regression in recent cmake [Martin Pitt]

187. By Thomas Voß

Add versioned dep on libubuntu-location-service-dev.

186. By Thomas Voß

[ Martin Pitt ]
* Add backend for simulated sensor data.
[ Albert Astals ]
* Build fixes and typos.
[ Ricardo Mendoza ]
* Build fixes and typos.
[ Ubuntu daily release ]
* Automatic snapshot from revision 183

185. By Thomas Voß

Add missing build dependencies on libproperties-cpp-dev and libdbus-cpp-dev.

184. By Thomas Voß

Account for changes in the location service interface.
Wire up controller to talk to the service for enabling/disabling positioning and gps status.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/rules' (properties changed: -x to +x)
2=== modified file 'doc/Doxyfile.in'
3--- doc/Doxyfile.in 2013-07-05 09:13:31 +0000
4+++ doc/Doxyfile.in 2014-01-16 05:55:43 +0000
5@@ -1684,7 +1684,7 @@
6 # explicitly to a value larger than 0 to get control over the balance
7 # between CPU load and processing speed.
8
9-DOT_NUM_THREADS = 0
10+DOT_NUM_THREADS = 1
11
12 # By default doxygen will use the Helvetica font for all dot files that
13 # doxygen generates. When you want a differently looking font you can specify
14
15=== modified file 'include/ubuntu/application/location/controller.h'
16--- include/ubuntu/application/location/controller.h 2013-08-23 10:55:16 +0000
17+++ include/ubuntu/application/location/controller.h 2014-01-16 05:55:43 +0000
18@@ -34,9 +34,7 @@
19 typedef enum
20 {
21 UA_LOCATION_SERVICE_ENABLED = 1 << 0, /**< The service is enabled. */
22- UA_LOCATION_SERVICE_DISABLED = 1 << 1, /**< The service is disabled. */
23- UA_LOCATION_SERVICE_GPS_ENABLED = 1 << 2, /**< GPS providers are enabled. */
24- UA_LOCATION_SERVICE_GPS_DISABLED = 1 << 3, /**< GPS providers are disabled. */
25+ UA_LOCATION_SERVICE_GPS_ENABLED = 1 << 1 /**< GPS providers are enabled. */
26 } UbuntuApplicationLocationServiceStatus;
27
28 typedef UbuntuApplicationLocationServiceStatus UALocationServiceStatus;
29
30=== modified file 'include/ubuntu/application/location/position_update.h'
31--- include/ubuntu/application/location/position_update.h 2013-08-22 07:03:49 +0000
32+++ include/ubuntu/application/location/position_update.h 2014-01-16 05:55:43 +0000
33@@ -84,6 +84,16 @@
34 UALocationPositionUpdate *update);
35
36 /**
37+ * \brief Queries the horizontal accuracy of the position update.
38+ * \ingroup location_service
39+ * \returns The horizontal accuracy of the position update in [m].
40+ * \param[in] update The position update instance to be queried.
41+ */
42+ UBUNTU_DLL_PUBLIC double
43+ ua_location_position_update_get_horizontal_accuracy_in_meter(
44+ UALocationPositionUpdate *update);
45+
46+ /**
47 * \brief Checks if the position update contains an altitude.
48 * \ingroup location_service
49 * \returns TRUE if the update contains an altitude, else FALSE.
50@@ -103,6 +113,26 @@
51 ua_location_position_update_get_altitude_in_meter(
52 UALocationPositionUpdate *update);
53
54+ /**
55+ * \brief Checks if the position update contains a vertical accuracy estimate.
56+ * \ingroup location_service
57+ * \returns TRUE if the update contains a vertical accuracy estimate, else FALSE.
58+ * \param[in] update The position update instance to be queried.
59+ */
60+ UBUNTU_DLL_PUBLIC bool
61+ ua_location_position_update_has_vertical_accuracy(
62+ UALocationPositionUpdate *update);
63+
64+ /**
65+ * \brief Queries the vertical accuracy of the position update.
66+ * \ingroup location_service
67+ * \returns The vertical accuracy of the position update in [m].
68+ * \param[in] update The position update instance to be queried.
69+ */
70+ UBUNTU_DLL_PUBLIC double
71+ ua_location_position_update_get_vertical_accuracy_in_meter(
72+ UALocationPositionUpdate *update);
73+
74 #ifdef __cplusplus
75 }
76 #endif
77
78=== modified file 'src/ubuntu/application/location/CMakeLists.txt'
79--- src/ubuntu/application/location/CMakeLists.txt 2013-08-23 10:39:34 +0000
80+++ src/ubuntu/application/location/CMakeLists.txt 2014-01-16 05:55:43 +0000
81@@ -4,12 +4,14 @@
82
83 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -fPIC")
84
85-pkg_check_modules(DBUS_CPP REQUIRED dbus-cpp)
86+pkg_check_modules(DBUS_CPP dbus-cpp REQUIRED)
87 pkg_check_modules(LOCATION_SERVICE REQUIRED ubuntu-location-service)
88
89+message(STATUS ${DBUS_CPP_LIBRARIES})
90+
91 include_directories(
92 ${Boost_INCLUDE_DIRS}
93- ${DBUS_CPP_INCLUDE_DIRS}/dbus
94+ ${DBUS_CPP_INCLUDE_DIRS}
95 ${LOCATION_SERVICE_INCLUDE_DIRS}
96 )
97
98@@ -30,6 +32,8 @@
99
100 ubuntu-location-service
101 dbus-1
102+
103+ ${DBUS_CPP_LDFLAGS}
104 ${LOCATION_SERVICE_LIBRARIES}
105 ${CMAKE_THREAD_LIBS_INIT}
106 ${Boost_LIBRARIES}
107
108=== modified file 'src/ubuntu/application/location/controller.cpp'
109--- src/ubuntu/application/location/controller.cpp 2013-08-23 10:55:16 +0000
110+++ src/ubuntu/application/location/controller.cpp 2014-01-16 05:55:43 +0000
111@@ -40,9 +40,29 @@
112 UALocationServiceStatusChangedHandler handler,
113 void *context)
114 {
115- (void) controller;
116- (void) handler;
117- (void) context;
118+ controller->service->is_online().changed().connect([controller, handler, context](bool value)
119+ {
120+ if (value)
121+ {
122+ controller->current_status |= UA_LOCATION_SERVICE_ENABLED;
123+ } else
124+ {
125+ controller->current_status &= ~UA_LOCATION_SERVICE_ENABLED;
126+ }
127+ handler(controller->current_status, context);
128+ });
129+
130+ controller->service->does_satellite_based_positioning().changed().connect([controller, handler, context](bool value)
131+ {
132+ if (value)
133+ {
134+ controller->current_status |= UA_LOCATION_SERVICE_GPS_ENABLED;
135+ } else
136+ {
137+ controller->current_status &= ~UA_LOCATION_SERVICE_GPS_ENABLED;
138+ }
139+ handler(controller->current_status, context);
140+ });
141 }
142
143 UStatus
144@@ -50,8 +70,19 @@
145 UALocationServiceController *controller,
146 UALocationServiceStatusFlags *out_flags)
147 {
148- (void) controller;
149- (void) out_flags;
150+ *out_flags = 0;
151+
152+ if (controller->service->is_online().get())
153+ *out_flags |= UA_LOCATION_SERVICE_ENABLED;
154+ else
155+ *out_flags &= ~UA_LOCATION_SERVICE_ENABLED;
156+
157+ if (controller->service->does_satellite_based_positioning().get())
158+ *out_flags |= UA_LOCATION_SERVICE_GPS_ENABLED;
159+ else
160+ *out_flags &= ~UA_LOCATION_SERVICE_GPS_ENABLED;
161+
162+ controller->current_status = *out_flags;
163
164 return U_STATUS_SUCCESS;
165 }
166@@ -60,8 +91,7 @@
167 ua_location_service_controller_enable_service(
168 UALocationServiceController *controller)
169 {
170- (void) controller;
171-
172+ controller->service->is_online() = true;
173 return U_STATUS_SUCCESS;
174 }
175
176@@ -69,8 +99,7 @@
177 ua_location_service_controller_disable_service(
178 UALocationServiceController *controller)
179 {
180- (void) controller;
181-
182+ controller->service->is_online() = false;
183 return U_STATUS_SUCCESS;
184 }
185
186@@ -78,8 +107,7 @@
187 ua_location_service_controller_enable_gps(
188 UALocationServiceController *controller)
189 {
190- (void) controller;
191-
192+ controller->service->does_satellite_based_positioning() = true;
193 return U_STATUS_SUCCESS;
194 }
195
196@@ -87,7 +115,6 @@
197 ua_location_service_controller_disable_gps(
198 UALocationServiceController *controller)
199 {
200- (void) controller;
201-
202+ controller->service->does_satellite_based_positioning() = false;
203 return U_STATUS_SUCCESS;
204 }
205
206=== modified file 'src/ubuntu/application/location/controller_p.h'
207--- src/ubuntu/application/location/controller_p.h 2013-08-21 14:59:45 +0000
208+++ src/ubuntu/application/location/controller_p.h 2014-01-16 05:55:43 +0000
209@@ -21,10 +21,23 @@
210
211 #include "ubuntu/application/location/controller.h"
212
213+#include <com/ubuntu/location/service/stub.h>
214+
215 #include "ref_counted.h"
216
217+namespace dbus = core::dbus;
218+namespace culs = com::ubuntu::location::service;
219+
220 struct UbuntuApplicationLocationServiceController : public detail::RefCounted
221 {
222+ UbuntuApplicationLocationServiceController(const culs::Interface::Ptr& service)
223+ : current_status(0),
224+ service(service)
225+ {
226+ }
227+
228+ UALocationServiceStatusFlags current_status;
229+ culs::Interface::Ptr service;
230 };
231
232 #endif // CONTROLLER_PRIVATE_H_
233
234=== modified file 'src/ubuntu/application/location/heading_update.cpp'
235--- src/ubuntu/application/location/heading_update.cpp 2013-08-19 06:46:47 +0000
236+++ src/ubuntu/application/location/heading_update.cpp 2014-01-16 05:55:43 +0000
237@@ -51,5 +51,5 @@
238 ua_location_heading_update_get_heading_in_degree(
239 UALocationHeadingUpdate *update)
240 {
241- return update->update.value.value.value();
242+ return update->update.value.value();
243 }
244
245=== modified file 'src/ubuntu/application/location/position_update.cpp'
246--- src/ubuntu/application/location/position_update.cpp 2013-08-19 06:46:47 +0000
247+++ src/ubuntu/application/location/position_update.cpp 2014-01-16 05:55:43 +0000
248@@ -51,26 +51,47 @@
249 ua_location_position_update_get_latitude_in_degree(
250 UALocationPositionUpdate *update)
251 {
252- return update->update.value.latitude().value.value();
253+ return update->update.value.latitude.value.value();
254 }
255
256 double
257 ua_location_position_update_get_longitude_in_degree(
258 UALocationPositionUpdate *update)
259 {
260- return update->update.value.longitude().value.value();
261+ return update->update.value.longitude.value.value();
262+}
263+
264+double
265+ua_location_position_update_get_horizontal_accuracy_in_meter(
266+ UALocationPositionUpdate *update)
267+{
268+ return update->update.value.accuracy.horizontal->value();
269 }
270
271 bool
272 ua_location_position_update_has_altitude(
273 UALocationPositionUpdate *update)
274 {
275- return update->update.value.has_altitude();
276+ return static_cast<bool>(update->update.value.altitude);
277 }
278
279 double
280 ua_location_position_update_get_altitude_in_meter(
281 UALocationPositionUpdate *update)
282 {
283- return update->update.value.altitude().value.value();
284+ return update->update.value.altitude->value.value();
285+}
286+
287+bool
288+ua_location_position_update_has_vertical_accuracy(
289+ UALocationPositionUpdate *update)
290+{
291+ return update->update.value.accuracy.vertical;
292+}
293+
294+double
295+ua_location_position_update_get_vertical_accuracy_in_meter(
296+ UALocationPositionUpdate *update)
297+{
298+ return update->update.value.accuracy.vertical->value();
299 }
300
301=== modified file 'src/ubuntu/application/location/service.cpp'
302--- src/ubuntu/application/location/service.cpp 2013-08-25 06:27:23 +0000
303+++ src/ubuntu/application/location/service.cpp 2014-01-16 05:55:43 +0000
304@@ -22,10 +22,11 @@
305 #include "session_p.h"
306
307 #include <com/ubuntu/location/service/stub.h>
308-#include <org/freedesktop/dbus/resolver.h>
309-#include <org/freedesktop/dbus/asio/executor.h>
310-
311-namespace dbus = org::freedesktop::dbus;
312+
313+#include <core/dbus/resolver.h>
314+#include <core/dbus/asio/executor.h>
315+
316+namespace dbus = core::dbus;
317 namespace cul = com::ubuntu::location;
318 namespace culs = com::ubuntu::location::service;
319
320@@ -47,7 +48,7 @@
321
322 private:
323 Instance() : bus(std::make_shared<dbus::Bus>(dbus::WellKnownBus::system)),
324- executor(std::make_shared<dbus::asio::Executor>(bus)),
325+ executor(dbus::asio::make_executor(bus)),
326 service(dbus::resolve_service_on_bus<culs::Interface, culs::Stub>(bus))
327 {
328 bus->install_executor(executor);
329@@ -87,5 +88,5 @@
330 UALocationServiceController*
331 ua_location_service_create_controller()
332 {
333- return new UbuntuApplicationLocationServiceController{};
334+ return new UbuntuApplicationLocationServiceController{Instance::instance().get_service()};
335 }
336
337=== modified file 'src/ubuntu/application/location/session.cpp'
338--- src/ubuntu/application/location/session.cpp 2013-08-19 06:46:47 +0000
339+++ src/ubuntu/application/location/session.cpp 2014-01-16 05:55:43 +0000
340@@ -24,6 +24,8 @@
341 #include "position_update_p.h"
342 #include "velocity_update_p.h"
343
344+namespace location = com::ubuntu::location;
345+
346 void
347 ua_location_service_session_ref(
348 UALocationServiceSession *session)
349@@ -47,12 +49,12 @@
350 void *context)
351 {
352 auto s = static_cast<UbuntuApplicationLocationServiceSession*>(session);
353- s->session->install_position_updates_handler(
354- [handler, context](const com::ubuntu::location::Update<com::ubuntu::location::Position>& new_position)
355- {
356- UbuntuApplicationLocationPositionUpdate pu{new_position};
357- handler(std::addressof(pu), context);
358- });
359+ s->session->updates().position.changed().connect([handler, context](
360+ const location::Update<location::Position>& new_position)
361+ {
362+ UbuntuApplicationLocationPositionUpdate pu{new_position};
363+ handler(std::addressof(pu), context);
364+ });
365 }
366
367 void
368@@ -62,8 +64,8 @@
369 void *context)
370 {
371 auto s = static_cast<UbuntuApplicationLocationServiceSession*>(session);
372- s->session->install_heading_updates_handler(
373- [handler, context](const com::ubuntu::location::Update<com::ubuntu::location::Heading>& new_heading)
374+ s->session->updates().heading.changed().connect(
375+ [handler, context](const location::Update<location::Heading>& new_heading)
376 {
377 UbuntuApplicationLocationHeadingUpdate hu{new_heading};
378 handler(std::addressof(hu), context);
379@@ -77,8 +79,8 @@
380 void *context)
381 {
382 auto s = static_cast<UbuntuApplicationLocationServiceSession*>(session);
383- s->session->install_velocity_updates_handler(
384- [handler, context](const com::ubuntu::location::Update<com::ubuntu::location::Velocity>& new_velocity)
385+ s->session->updates().velocity.changed().connect(
386+ [handler, context](const location::Update<location::Velocity>& new_velocity)
387 {
388 UbuntuApplicationLocationVelocityUpdate vu{new_velocity};
389 handler(std::addressof(vu), context);
390@@ -95,7 +97,8 @@
391
392 try
393 {
394- s->session->start_position_updates();
395+ s->session->updates().position_status
396+ = location::service::session::Interface::Updates::Status::enabled;
397 } catch(...)
398 {
399 return U_STATUS_ERROR;
400@@ -114,7 +117,8 @@
401
402 try
403 {
404- s->session->stop_position_updates();
405+ s->session->updates().position_status
406+ = location::service::session::Interface::Updates::Status::disabled;
407 } catch(...)
408 {
409 }
410@@ -130,7 +134,7 @@
411
412 try
413 {
414- s->session->start_heading_updates();
415+ s->session->updates().heading_status = location::service::session::Interface::Updates::Status::enabled;
416 } catch(...)
417 {
418 return U_STATUS_ERROR;
419@@ -149,7 +153,7 @@
420
421 try
422 {
423- s->session->stop_heading_updates();
424+ s->session->updates().heading_status = location::service::session::Interface::Updates::Status::disabled;
425 } catch(...)
426 {
427 }
428@@ -165,7 +169,7 @@
429
430 try
431 {
432- s->session->start_velocity_updates();
433+ s->session->updates().velocity_status = location::service::session::Interface::Updates::Status::enabled;
434 } catch(...)
435 {
436 return U_STATUS_ERROR;
437@@ -184,7 +188,7 @@
438
439 try
440 {
441- s->session->stop_velocity_updates();
442+ s->session->updates().velocity_status = location::service::session::Interface::Updates::Status::disabled;
443 } catch(...)
444 {
445 }
446
447=== modified file 'src/ubuntu/application/location/velocity_update.cpp'
448--- src/ubuntu/application/location/velocity_update.cpp 2013-08-19 06:46:47 +0000
449+++ src/ubuntu/application/location/velocity_update.cpp 2014-01-16 05:55:43 +0000
450@@ -51,5 +51,5 @@
451 ua_location_velocity_update_get_velocity_in_meters_per_second(
452 UALocationVelocityUpdate *update)
453 {
454- return update->update.value.value.value();
455+ return update->update.value.value();
456 }
457
458=== modified file 'tests/CMakeLists.txt'
459--- tests/CMakeLists.txt 2013-12-06 13:47:56 +0000
460+++ tests/CMakeLists.txt 2014-01-16 05:55:43 +0000
461@@ -17,6 +17,7 @@
462 ubuntu_application_api
463 gtest
464 gtest_main
465+
466 ${PROCESS_CPP_LIBRARIES}
467 )
468

Subscribers

People subscribed via source and target branches