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

Proposed by Thomas Voß
Status: Needs review
Proposed branch: lp:~thomas-voss/platform-api/add_missing_agps_hooks
Merge into: lp:platform-api
Diff against target: 2182 lines (+403/-1168)
32 files modified
CMakeLists.txt (+0/-6)
android/default/default_ubuntu_application_ui.cpp (+0/-11)
android/hybris/test_gps_api.cpp (+2/-0)
android/hybris/ubuntu_application_gps_for_hybris.cpp (+147/-8)
debian/changelog (+0/-26)
debian/control (+2/-20)
debian/libubuntu-application-api-test1.docs (+0/-1)
debian/libubuntu-application-api-test1.install (+0/-1)
debian/rules (+1/-7)
doc/Doxyfile.in (+1/-1)
include/ubuntu/application/ui/window_properties.h (+0/-6)
include/ubuntu/hardware/gps.h (+153/-23)
src/ubuntu/CMakeLists.txt (+1/-2)
src/ubuntu/hybris/CMakeLists.txt (+0/-1)
src/ubuntu/hybris/bridge.h (+17/-29)
src/ubuntu/hybris/tests/test_gps_api.cpp (+40/-7)
src/ubuntu/hybris/ubuntu_application_api_hybris.cpp (+0/-1)
src/ubuntu/hybris/ubuntu_platform_hardware_api.cpp (+27/-1)
src/ubuntu/mirclient/ubuntu_application_api_mirclient.cpp (+0/-6)
src/ubuntu/mirclient/window_properties_mirclient.cpp (+0/-6)
src/ubuntu/mirclient/window_properties_mirclient_priv.h (+0/-1)
src/ubuntu/mircommon/application_options_mir.cpp (+3/-62)
src/ubuntu/mircommon/lifecycle_delegate_mir_priv.h (+1/-1)
src/ubuntu/mirserver/CMakeLists.txt (+2/-0)
src/ubuntu/mirserver/ubuntu_application_api_mirserver.cpp (+1/-7)
src/ubuntu/mirserver/window_properties_mirserver.cpp (+3/-7)
src/ubuntu/mirserver/window_properties_mirserver_priv.h (+2/-3)
src/ubuntu/testbackend/CMakeLists.txt (+0/-21)
src/ubuntu/testbackend/README.md (+0/-77)
src/ubuntu/testbackend/ubuntu_application_sensors.cpp (+0/-553)
tests/CMakeLists.txt (+0/-30)
tests/test_ubuntu_application_sensors.cpp (+0/-243)
To merge this branch: bzr merge lp:~thomas-voss/platform-api/add_missing_agps_hooks
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Ubuntu Phablet Team Pending
Review via email: mp+199121@code.launchpad.net

Commit message

Added agps-specific functions to the gps subcomponent.

Description of the change

Added agps-specific functions to the gps subcomponent.

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

Unmerged revisions

187. By Thomas Voß

Remove uneccessary printf's.

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ß

Fix signature in bridge implementation.

184. By Thomas Voß

Revert accidental merge.

183. By Thomas Voß

* Added *_set_dimensions() function to the window properties.
[ Alexandros Frantzis ]
* mirclient: Initialize MirSurfaceParameters::output_id field.
[ Martin Pitt ]
* Fix all compiler warnings.
[ Timo Jyrinki ]
* bump debian version dependency for mir to 0.1.3 to force rebuild
[ Gerry Boland ]
* Fix FTBFS with Mir12 change - mir::geometry::PixelFormat was
  removed, using MirPixelFormat instead. (LP: #1266674)
[ Ubuntu daily release ]
* Automatic snapshot from revision 179

182. By Thomas Voß

Make sure that floating point values are transported correctly.

181. By Thomas Voß

Added deletion of GPS aiding data and supl server setup to test executable.

180. By Thomas Voß

Adjusted the command-line test executable for accessing the gps api.

179. By Thomas Voß

Compilation fixes.

178. By Thomas Voß

Added agps-specific functions to the gps subcomponent.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2013-12-05 14:58:09 +0000
3+++ CMakeLists.txt 2014-01-22 16:11:40 +0000
4@@ -93,9 +93,3 @@
5 add_subdirectory(doc/)
6 add_subdirectory(include/)
7 add_subdirectory(src/)
8-
9-#### Enable tests
10-include(CTest)
11-set(GTEST_ROOT /usr/src/gtest)
12-add_subdirectory(tests/)
13-add_subdirectory(${GTEST_ROOT} ${CMAKE_CURRENT_BINARY_DIR}/gtest)
14
15=== modified file 'android/default/default_ubuntu_application_ui.cpp'
16--- android/default/default_ubuntu_application_ui.cpp 2013-12-11 06:11:34 +0000
17+++ android/default/default_ubuntu_application_ui.cpp 2014-01-22 16:11:40 +0000
18@@ -228,17 +228,6 @@
19 p->value->set_input_event_cb_and_ctx(cb, ctx);
20 }
21
22-void
23-ua_ui_window_properties_set_dimensions(
24- UAUiWindowProperties *properties,
25- uint32_t width,
26- uint32_t height)
27-{
28- ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
29- (void) width;
30- (void) height;
31-}
32-
33 /*
34 * Session
35 */
36
37=== modified file 'android/hybris/test_gps_api.cpp'
38--- android/hybris/test_gps_api.cpp 2013-02-05 08:01:14 +0000
39+++ android/hybris/test_gps_api.cpp 2014-01-22 16:11:40 +0000
40@@ -17,6 +17,8 @@
41 */
42 #include <ubuntu/application/ubuntu_application_gps.h>
43
44+#include <pthread.h>
45+
46 #include <ctime>
47 #include <signal.h>
48 #include <stdio.h>
49
50=== modified file 'android/hybris/ubuntu_application_gps_for_hybris.cpp'
51--- android/hybris/ubuntu_application_gps_for_hybris.cpp 2013-06-14 11:42:24 +0000
52+++ android/hybris/ubuntu_application_gps_for_hybris.cpp 2014-01-22 16:11:40 +0000
53@@ -18,6 +18,7 @@
54 #include <ubuntu/hardware/gps.h>
55
56 #include <pthread.h>
57+#include <stdio.h>
58
59 // android stuff
60 #include <hardware/gps.h>
61@@ -36,7 +37,15 @@
62 bool stop();
63 void inject_time(int64_t time, int64_t timeReference, int uncertainty);
64 void inject_location(double latitude, double longitude, float accuracy);
65- void delete_aiding_data(uint16_t flags);
66+ void delete_aiding_data(UHardwareGpsAidingData flags);
67+
68+ void set_server_for_type(UHardwareGpsAGpsType type, const char* hostname, uint16_t port);
69+ void set_reference_location(UHardwareGpsAGpsRefLocation* location, size_t size_of_struct);
70+
71+ void notify_connection_is_open(const char* apn);
72+ void notify_connection_is_closed();
73+ void notify_connection_not_available();
74+
75 bool set_position_mode(uint32_t mode, uint32_t recurrence, uint32_t min_interval,
76 uint32_t preferred_accuracy, uint32_t preferred_time);
77 void inject_xtra_data(char* data, int length);
78@@ -84,6 +93,7 @@
79
80 static void status_callback(GpsStatus* status)
81 {
82+ printf("%s \n", __PRETTY_FUNCTION__);
83 if (!hybris_gps_instance)
84 return;
85
86@@ -135,7 +145,7 @@
87 }
88
89
90-typedef struct
91+typedef struct
92 {
93 void (*func)(void *);
94 void *arg;
95@@ -143,6 +153,7 @@
96
97 static void * thread_start_wrapper(void* arg)
98 {
99+ printf("%s \n", __PRETTY_FUNCTION__);
100 FuncAndArg *func_and_arg = reinterpret_cast<FuncAndArg*>(arg);
101 func_and_arg->func(func_and_arg->arg);
102 delete func_and_arg;
103@@ -158,6 +169,7 @@
104 func_and_arg->arg = arg;
105
106 pthread_create(&thread, NULL, thread_start_wrapper, func_and_arg);
107+ pthread_setname_np(thread, name);
108 return thread;
109 }
110
111@@ -228,11 +240,14 @@
112 static void agps_request_set_id(uint32_t flags)
113 {
114 if (hybris_gps_instance)
115+ {
116 hybris_gps_instance->request_setid_cb(flags, hybris_gps_instance->context);
117+ }
118 }
119
120 static void agps_request_ref_location(uint32_t flags)
121 {
122+ printf("%s \n", __PRETTY_FUNCTION__);
123 if (hybris_gps_instance)
124 hybris_gps_instance->request_refloc_cb(flags, hybris_gps_instance->context);
125 }
126@@ -308,14 +323,52 @@
127
128 // if XTRA initialization fails we will disable it by gps_Xtra_interface to null,
129 // but continue to allow the rest of the GPS interface to work.
130- if (gps_xtra_interface && gps_xtra_interface->init(&gps_xtra_callbacks) != 0)
131- gps_xtra_interface = NULL;
132+ if (gps_xtra_interface)
133+ {
134+ printf("Got GPS XTRA interface, trying to initialize ... \n");
135+ if (gps_xtra_interface->init(&gps_xtra_callbacks) != 0)
136+ {
137+ printf("error\n");
138+ gps_xtra_interface = NULL;
139+ }
140+ else
141+ {
142+ printf("success\n");
143+
144+ }
145+ } else
146+ {
147+ printf("No GPS XTRA interface available from HAL.\n");
148+ }
149+
150 if (agps_interface)
151+ {
152+ printf("Got AGPS interface, trying to initialize ...\n");
153 agps_interface->init(&agps_callbacks);
154+ } else
155+ {
156+ printf("No AGPS interface available from HAL.\n");
157+ }
158+
159 if (gps_ni_interface)
160+ {
161+ printf("Got GPS NI interface, trying to initialize ...\n");
162 gps_ni_interface->init(&gps_ni_callbacks);
163+ }
164+ else
165+ {
166+ printf("No GPS NI interface available from HAL.\n");
167+ }
168+
169 if (agps_ril_interface)
170+ {
171+ printf("Got AGPS RIL interface, trying to initialize ...\n");
172 agps_ril_interface->init(&agps_ril_callbacks);
173+ }
174+ else
175+ {
176+ printf("No AGPS RIL interface available from HAL.\n");
177+ }
178
179 return true;
180 }
181@@ -338,13 +391,16 @@
182
183 void UHardwareGps_::inject_time(int64_t time, int64_t time_reference, int uncertainty)
184 {
185+ printf("%s: %p %d %d %d \n", __PRETTY_FUNCTION__, this, time, time_reference, uncertainty);
186+
187 if (gps_interface)
188 gps_interface->inject_time(time, time_reference, uncertainty);
189 }
190
191 void UHardwareGps_::inject_location(double latitude, double longitude, float accuracy)
192 {
193- if (gps_interface)
194+ printf("%s: %p %f %f %f \n", __PRETTY_FUNCTION__, this, latitude, longitude, accuracy);
195+ if (gps_interface && gps_interface->inject_location)
196 gps_interface->inject_location(latitude, longitude, accuracy);
197 }
198
199@@ -354,9 +410,50 @@
200 gps_interface->delete_aiding_data(flags);
201 }
202
203+void UHardwareGps_::set_server_for_type(UHardwareGpsAGpsType type, const char* hostname, uint16_t port)
204+{
205+ printf("%s \n", __PRETTY_FUNCTION__);
206+ if (agps_interface)
207+ agps_interface->set_server(type, hostname, port);
208+}
209+
210+void UHardwareGps_::set_reference_location(UHardwareGpsAGpsRefLocation* location, size_t size_of_struct)
211+{
212+ AGpsRefLocation ref_loc;
213+ ref_loc.type = location->type;
214+ ref_loc.u.cellID.type = location->u.cellID.type;
215+ ref_loc.u.cellID.mcc = location->u.cellID.mcc;
216+ ref_loc.u.cellID.mnc = location->u.cellID.mnc;
217+ ref_loc.u.cellID.lac = location->u.cellID.lac;
218+ ref_loc.u.cellID.cid = location->u.cellID.cid;
219+
220+ if (agps_ril_interface)
221+ agps_ril_interface->set_ref_location(&ref_loc, sizeof(ref_loc));
222+}
223+
224+void UHardwareGps_::notify_connection_is_open(const char* apn)
225+{
226+ if (agps_interface)
227+ agps_interface->data_conn_open(apn);
228+}
229+
230+void UHardwareGps_::notify_connection_is_closed()
231+{
232+ if (agps_interface)
233+ agps_interface->data_conn_closed();
234+}
235+
236+void UHardwareGps_::notify_connection_not_available()
237+{
238+ if (agps_interface)
239+ agps_interface->data_conn_failed();
240+}
241+
242 bool UHardwareGps_::set_position_mode(uint32_t mode, uint32_t recurrence, uint32_t min_interval,
243 uint32_t preferred_accuracy, uint32_t preferred_time)
244 {
245+ printf("%s \n", __PRETTY_FUNCTION__);
246+
247 if (gps_interface)
248 return (gps_interface->set_position_mode(mode, recurrence, min_interval,
249 preferred_accuracy, preferred_time) == 0);
250@@ -372,7 +469,8 @@
251
252 /////////////////////////////////////////////////////////////////////
253 // Implementation of the C API
254-
255+extern "C"
256+{
257 UHardwareGps u_hardware_gps_new(UHardwareGpsParams* params)
258 {
259 if (hybris_gps_instance != NULL)
260@@ -416,14 +514,54 @@
261 void u_hardware_gps_inject_location(UHardwareGps self, double latitude, double longitude,
262 float accuracy)
263 {
264- self->inject_location(latitude, longitude, accuracy);
265+ printf("%s: %p %f %f %f \n", __PRETTY_FUNCTION__, hybris_gps_instance, latitude, longitude, accuracy);
266+ if (self == NULL)
267+ hybris_gps_instance->inject_location(latitude, longitude, accuracy);
268+ else
269+ self->inject_location(latitude, longitude, accuracy);
270 }
271
272-void u_hardware_gps_delete_aiding_data(UHardwareGps self, uint16_t flags)
273+void u_hardware_gps_delete_aiding_data(UHardwareGps self, UHardwareGpsAidingData flags)
274 {
275+ printf("%s: %p \n", __PRETTY_FUNCTION__, self);
276 self->delete_aiding_data(flags);
277 }
278
279+void u_hardware_gps_agps_set_server_for_type(
280+ UHardwareGps self,
281+ UHardwareGpsAGpsType type,
282+ const char* hostname,
283+ uint16_t port)
284+{
285+ self->set_server_for_type(type, hostname, port);
286+}
287+
288+void u_hardware_gps_agps_set_reference_location(
289+ UHardwareGps self,
290+ UHardwareGpsAGpsRefLocation *location,
291+ size_t size_of_struct)
292+{
293+ self->set_reference_location(location, size_of_struct);
294+}
295+
296+void u_hardware_gps_agps_notify_connection_is_open(
297+ UHardwareGps self,
298+ const char *apn)
299+{
300+ self->notify_connection_is_open(apn);
301+}
302+
303+void u_hardware_gps_agps_notify_connection_is_closed(UHardwareGps self)
304+{
305+ self->notify_connection_is_closed();
306+}
307+
308+void u_hardware_gps_agps_notify_connection_not_available(UHardwareGps self)
309+{
310+ self->notify_connection_not_available();
311+}
312+
313+
314 bool u_hardware_gps_set_position_mode(UHardwareGps self, uint32_t mode, uint32_t recurrence,
315 uint32_t min_interval, uint32_t preferred_accuracy,
316 uint32_t preferred_time)
317@@ -436,3 +574,4 @@
318 {
319 self->inject_xtra_data(data, length);
320 }
321+}
322
323=== modified file 'debian/changelog'
324--- debian/changelog 2014-01-14 10:37:31 +0000
325+++ debian/changelog 2014-01-22 16:11:40 +0000
326@@ -14,32 +14,6 @@
327
328 -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Tue, 14 Jan 2014 10:37:30 +0000
329
330-platform-api (0.20-0ubuntu1) trusty; urgency=low
331-
332- * Added *_set_dimensions() function to the window properties.
333-
334- -- Ricardo Mendoza <ricardo.mendoza@canonical.com> Tue, 10 Dec 2013 23:24:57 -0500
335-
336-platform-api (0.19+14.04.20140108.1-0ubuntu1) trusty; urgency=low
337-
338- [ Alexandros Frantzis ]
339- * mirclient: Initialize MirSurfaceParameters::output_id field.
340-
341- [ Martin Pitt ]
342- * Fix all compiler warnings.
343-
344- [ Timo Jyrinki ]
345- * bump debian version dependency for mir to 0.1.3 to force rebuild
346-
347- [ Gerry Boland ]
348- * Fix FTBFS with Mir12 change - mir::geometry::PixelFormat was
349- removed, using MirPixelFormat instead. (LP: #1266674)
350-
351- [ Ubuntu daily release ]
352- * Automatic snapshot from revision 179
353-
354- -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Wed, 08 Jan 2014 06:17:14 +0000
355-
356 platform-api (0.19+14.04.20131128.1-0ubuntu1) trusty; urgency=low
357
358 [ Kevin Gunn ]
359
360=== modified file 'debian/control'
361--- debian/control 2014-01-08 15:17:41 +0000
362+++ debian/control 2014-01-22 16:11:40 +0000
363@@ -11,14 +11,12 @@
364 g++-4.7,
365 libhybris-common-dev,
366 pkg-config,
367- libmirclient-dev (>= 0.1.3),
368- libmirserver-dev (>= 0.1.3),
369+ libmirclient-dev (>= 0.1.2),
370+ libmirserver-dev (>= 0.1.2),
371 liburl-dispatcher1-dev,
372 libdbus-1-dev,
373 dbus-cpp-dev,
374 libubuntu-location-service-dev,
375- libgtest-dev,
376- libprocess-cpp-dev (>= 0.0.1+14.04.20131212),
377 Standards-Version: 3.9.4
378 Homepage: https://launchpad.net/platform-api
379 Vcs-Bzr: lp:platform-api
380@@ -144,22 +142,6 @@
381 The produced library should be used via libhybris, to communicate with the
382 Android userspace, which is where the Ubuntu Application Manager lives.
383
384-Package: libubuntu-application-api-test1
385-Section: libs
386-Architecture: any
387-Pre-Depends: ${misc:Pre-Depends},
388-Multi-Arch: same
389-Depends: ${misc:Depends},
390- ${shlibs:Depends},
391-Description: test implementation of the Platform API
392- This package provides an implementation of the Platform API for testing. It
393- does not communicate with actual hardware, but reads input from a text file.
394- .
395- You need to explicitly enable this at runtime. Please see the README for
396- details.
397- .
398- For now this provides simulated sensors.
399-
400 Package: libplatform-api1-hybris-tests
401 Architecture: any
402 Depends: ${misc:Depends},
403
404=== removed file 'debian/libubuntu-application-api-test1.docs'
405--- debian/libubuntu-application-api-test1.docs 2014-01-08 15:17:41 +0000
406+++ debian/libubuntu-application-api-test1.docs 1970-01-01 00:00:00 +0000
407@@ -1,1 +0,0 @@
408-src/ubuntu/testbackend/README.md
409
410=== removed file 'debian/libubuntu-application-api-test1.install'
411--- debian/libubuntu-application-api-test1.install 2014-01-08 15:17:41 +0000
412+++ debian/libubuntu-application-api-test1.install 1970-01-01 00:00:00 +0000
413@@ -1,1 +0,0 @@
414-usr/lib/*/libubuntu_application_api_test.so.*
415
416=== modified file 'debian/rules' (properties changed: -x to +x)
417--- debian/rules 2014-01-09 18:52:10 +0000
418+++ debian/rules 2014-01-22 16:11:40 +0000
419@@ -11,11 +11,5 @@
420 override_dh_auto_configure:
421 dh_auto_configure -- -DENABLE_MIRCLIENT_IMPLEMENTATION=true -DENABLE_MIRSERVER_IMPLEMENTATION=true
422
423-override_dh_install:
424+overrid_dh_install:
425 dh_install --fail-missing
426-
427-override_dh_auto_test:
428-ifeq (, $(findstring nocheck, $(DEB_BUILD_OPTIONS)))
429- cd obj-* && ctest --verbose
430-endif
431-
432
433=== modified file 'doc/Doxyfile.in'
434--- doc/Doxyfile.in 2013-07-05 09:13:31 +0000
435+++ doc/Doxyfile.in 2014-01-22 16:11:40 +0000
436@@ -1684,7 +1684,7 @@
437 # explicitly to a value larger than 0 to get control over the balance
438 # between CPU load and processing speed.
439
440-DOT_NUM_THREADS = 0
441+DOT_NUM_THREADS = 1
442
443 # By default doxygen will use the Helvetica font for all dot files that
444 # doxygen generates. When you want a differently looking font you can specify
445
446=== modified file 'include/ubuntu/application/ui/window_properties.h'
447--- include/ubuntu/application/ui/window_properties.h 2013-12-11 04:56:15 +0000
448+++ include/ubuntu/application/ui/window_properties.h 2014-01-22 16:11:40 +0000
449@@ -76,12 +76,6 @@
450 UAUiWindowProperties *properties,
451 UAUiWindowInputEventCb cb,
452 void *ctx);
453-
454- UBUNTU_DLL_PUBLIC void
455- ua_ui_window_properties_set_dimensions(
456- UAUiWindowProperties *properties,
457- uint32_t width,
458- uint32_t height);
459
460 #ifdef __cplusplus
461 }
462
463=== modified file 'include/ubuntu/hardware/gps.h'
464--- include/ubuntu/hardware/gps.h 2013-08-22 07:17:47 +0000
465+++ include/ubuntu/hardware/gps.h 2014-01-22 16:11:40 +0000
466@@ -180,6 +180,37 @@
467 U_HARDWARE_GPS_AGPS_DATA_CONN_FAILED = 5
468 };
469
470+/** Flags used to specify which aiding data to delete
471+ when calling delete_aiding_data(). */
472+typedef uint16_t UHardwareGpsAidingData;
473+
474+#define U_HARDWARE_GPS_DELETE_EPHEMERIS 0x0001
475+#define U_HARDWARE_GPS_DELETE_ALMANAC 0x0002
476+#define U_HARDWARE_GPS_DELETE_POSITION 0x0004
477+#define U_HARDWARE_GPS_DELETE_TIME 0x0008
478+#define U_HARDWARE_GPS_DELETE_IONO 0x0010
479+#define U_HARDWARE_GPS_DELETE_UTC 0x0020
480+#define U_HARDWARE_GPS_DELETE_HEALTH 0x0040
481+#define U_HARDWARE_GPS_DELETE_SVDIR 0x0080
482+#define U_HARDWARE_GPS_DELETE_SVSTEER 0x0100
483+#define U_HARDWARE_GPS_DELETE_SADATA 0x0200
484+#define U_HARDWARE_GPS_DELETE_RTI 0x0400
485+#define U_HARDWARE_GPS_DELETE_CELLDB_INFO 0x8000
486+#define U_HARDWARE_GPS_DELETE_ALL 0xFFFF
487+
488+/** AGPS type */
489+typedef uint16_t UHardwareGpsAGpsType;
490+#define U_HARDWARE_GPS_AGPS_TYPE_SUPL 1
491+#define U_HARDWARE_GPS_AGPS_TYPE_C2K 2
492+
493+/** Known types for AGps reference locations. */
494+/** A GSM cell ID. */
495+#define U_HARDWARE_GPS_AGPS_REF_LOCATION_TYPE_GSM_CELLID 1
496+/** A UMTS cell ID. */
497+#define U_HARDWARE_GPS_AGPS_REF_LOCATION_TYPE_UMTS_CELLID 2
498+/** The BSSID of a visible access point. */
499+#define U_HARDWARE_GPS_AGPS_REG_LOCATION_TYPE_MAC 3
500+
501 /** UHardwareGpsLocation has valid latitude and longitude. */
502 #define U_HARDWARE_GPS_LOCATION_HAS_LAT_LONG 0x0001
503 /** UHardwareGpsLocation has valid altitude. */
504@@ -207,8 +238,7 @@
505 double latitude;
506 /** Represents longitude in degrees. */
507 double longitude;
508- /** Represents altitude in meters above the WGS 84 reference
509- * ellipsoid. */
510+ /** Represents altitude in meters above the WGS 84 reference ellipsoid. */
511 double altitude;
512 /** Represents speed in meters per second. */
513 float speed;
514@@ -281,6 +311,46 @@
515 uint32_t ipaddr;
516 } UHardwareGpsAGpsStatus;
517
518+/** \brief Describes a cell ID as understood by the GPS chipset. */
519+typedef struct
520+{
521+ /** One of:
522+ * U_HARDWARE_GPS_AGPS_REF_LOCATION_TYPE_GSM_CELLID
523+ * U_HARDWARE_GPS_AGPS_REF_LOCATION_TYPE_UMTS_CELLID
524+ */
525+ uint16_t type;
526+ /** Mobile country code. */
527+ uint16_t mcc;
528+ /** Mobile network code. */
529+ uint16_t mnc;
530+ /** Location area code. */
531+ uint16_t lac;
532+ /** The actual cell id. */
533+ uint32_t cid;
534+} UHardwareGpsAGpsRefLocationCellID;
535+
536+/** \brief Describes a wifi ID as understood by the GPS chipset. */
537+typedef struct
538+{
539+ /** The MAC address/BSSID of an AP. */
540+ uint8_t mac[6];
541+} UHardwareGpsAGpsRefLocationMac;
542+
543+/** @brief Describes a reference location, either a radio cell or a wifi. */
544+typedef struct
545+{
546+ /** One of:
547+ * U_HARDWARE_GPS_AGPS_REF_LOCATION_TYPE_GSM_CELLID
548+ * U_HARDWARE_GPS_AGPS_REF_LOCATION_TYPE_UMTS_CELLID
549+ * U_HARDWARE_GPS_AGPS_REG_LOCATION_TYPE_MAC
550+ */
551+ uint16_t type;
552+ union {
553+ UHardwareGpsAGpsRefLocationCellID cellID;
554+ UHardwareGpsAGpsRefLocationMac mac;
555+ } u;
556+} UHardwareGpsAGpsRefLocation;
557+
558 /**
559 * Represents an NI request
560 * \ingroup gps_access
561@@ -353,23 +423,18 @@
562 typedef void (*UHardwareGpsSetCapabilities)(uint32_t capabilities, void *context);
563 typedef void (*UHardwareGpsRequestUtcTime)(void *context);
564
565-/** Callback to request the client to download XTRA data.
566- * The client should download XTRA data and inject it by calling inject_xtra_data().
567- */
568+/** Callback to request the client to download XTRA data. The client should download XTRA data and inject it by calling inject_xtra_data(). */
569 typedef void (*UHardwareGpsXtraDownloadRequest)(void *context);
570
571-/** Callback with AGPS status information.
572- */
573+/** Callback with AGPS status information. */
574 typedef void (*UHardwareGpsAGpsStatusCallback)(UHardwareGpsAGpsStatus *status, void *context);
575
576-/** Callback with NI notification.
577- */
578+/** Callback with NI notification. */
579 typedef void (*UHardwareGpsNiNotifyCallback)(UHardwareGpsNiNotification *notification, void *context);
580
581-/*
582- Callback for AGPS RIL (Radio Interface Library) set id
583-*/
584+/** Callback invoked by the driver to set the set id. */
585 typedef void (*UHardwareGpsAGpsRilRequestSetId)(uint32_t flags, void *context);
586+/** Callback invoked by the driver to request a reference location (typically cell ID). */
587 typedef void (*UHardwareGpsAGpsRilRequestRefLoc)(uint32_t flags, void *context);
588
589 typedef struct
590@@ -409,10 +474,10 @@
591 UBUNTU_DLL_PUBLIC bool
592 u_hardware_gps_stop(UHardwareGps self);
593
594-/*
595- \param time NTP time, in milliseconds since Jan 1st 1970.
596- \param time_reference time from the internal clock at the moment that NTP time was taken.
597- \param uncertainty possible deviation in the time supplied (uncertainty) in milliseconds.
598+/** \brief Injects a new reference time into the GPS chipset.
599+ * \param time NTP time, in milliseconds since Jan 1st 1970.
600+ * \param time_reference time from the internal clock at the moment that NTP time was taken.
601+ * \param uncertainty possible deviation in the time supplied (uncertainty) in milliseconds.
602 */
603 UBUNTU_DLL_PUBLIC void
604 u_hardware_gps_inject_time(
605@@ -421,6 +486,13 @@
606 int64_t time_reference,
607 int uncertainty);
608
609+/**
610+ * \brief Injects a new reference location into the GPS chipset.
611+ * \param self The instance to apply the chane to.
612+ * \param latitude New coordinate, in [°].
613+ * \param longitude New coordinate, [°].
614+ * \param accuracy Accuracy estimate of the location, in [m].
615+ */
616 UBUNTU_DLL_PUBLIC void
617 u_hardware_gps_inject_location(
618 UHardwareGps self,
619@@ -428,17 +500,75 @@
620 double longitude,
621 float accuracy);
622
623+/**
624+ * \brief Informs the GPS chipset about wifi ap's or radio cells to be used in AGPS calls.
625+ * \param self The instance to inform.
626+ * \param location The reference location, that is a wifi ap or a radio cell.
627+ * \param size_of_struct The size of the reference location struct.
628+ */
629+UBUNTU_DLL_PUBLIC void
630+u_hardware_gps_agps_set_reference_location(
631+ UHardwareGps self,
632+ UHardwareGpsAGpsRefLocation *location,
633+ size_t size_of_struct);
634+
635+/**
636+ * \brief Notifies the chipset that a data connection is availble.
637+ * \param self The instance to be notified.
638+ * \param apn Name of the apn to be used for SUPL.
639+ */
640+UBUNTU_DLL_PUBLIC void
641+u_hardware_gps_agps_notify_connection_is_open(
642+ UHardwareGps self,
643+ const char *apn);
644+
645+/**
646+ * \brief Notifies the chipset that an AGPS data connection has been closed.
647+ * \param self The instance to be notified.
648+ */
649+UBUNTU_DLL_PUBLIC void
650+u_hardware_gps_agps_notify_connection_is_closed(
651+ UHardwareGps self);
652+
653+/**
654+ * \brief Notifies the chipset that an AGPS data connection is not available.
655+ * \param self The instance to be notified.
656+ */
657+UBUNTU_DLL_PUBLIC void
658+u_hardware_gps_agps_notify_connection_not_available(
659+ UHardwareGps self);
660+
661+/**
662+ * \brief Sets the hostname and port for the AGPS server.
663+ * \param self The instance to be altered.
664+ * \param type Type of the server, one of U_HARDWARE_GPS_AGPS_TYPE_SUPL or U_HARDWARE_GPS_AGPS_TYPE_C2K.
665+ * \param hostname The hostname of the AGPS server.
666+ * \param port The post of the AGPS server.
667+ */
668+UBUNTU_DLL_PUBLIC void
669+u_hardware_gps_agps_set_server_for_type(
670+ UHardwareGps self,
671+ UHardwareGpsAGpsType type,
672+ const char* hostname,
673+ uint16_t port);
674+
675+/**
676+ * \brief Requests the chipset to delete the aiding data specified in flags.
677+ * \param self The instance to apply the change to.
678+ * \param flags Specifies the aiding data that should be deleted.
679+ */
680 UBUNTU_DLL_PUBLIC void
681 u_hardware_gps_delete_aiding_data(
682 UHardwareGps self,
683- uint16_t flags);
684+ UHardwareGpsAidingData flags);
685
686-/*
687- \param mode One of the U_HARDWARE_GPS_POSITION_MODE_* values
688- \param recurrence One of the U_HARDWARE_GPS_POSITION_RECURRENCE_* values
689- \param min_interval represents the time between fixes in milliseconds.
690- \param preferred_accuracy The requested fix accuracy in meters. Can be zero.
691- \param preferred_time The requested time to first fix in milliseconds. Can be zero.
692+/**
693+ * \brief Sets the positioning mode of the chipset.
694+ * \param mode One of the U_HARDWARE_GPS_POSITION_MODE_* values
695+ * \param recurrence One of the U_HARDWARE_GPS_POSITION_RECURRENCE_* values
696+ * \param min_interval represents the time between fixes in milliseconds.
697+ * \param preferred_accuracy The requested fix accuracy in meters. Can be zero.
698+ * \param preferred_time The requested time to first fix in milliseconds. Can be zero.
699 */
700 UBUNTU_DLL_PUBLIC bool
701 u_hardware_gps_set_position_mode(
702
703=== modified file 'src/ubuntu/CMakeLists.txt'
704--- src/ubuntu/CMakeLists.txt 2013-12-02 17:03:45 +0000
705+++ src/ubuntu/CMakeLists.txt 2014-01-22 16:11:40 +0000
706@@ -3,7 +3,6 @@
707 )
708
709 add_subdirectory(application)
710-add_subdirectory(testbackend)
711
712 set(
713 UBUNTU_APPLICATION_API_LINK_LIBRARIES
714@@ -26,4 +25,4 @@
715
716 if(ENABLE_MIRCLIENT_IMPLEMENTATION)
717 add_subdirectory(mirclient/)
718-endif()
719+endif()
720\ No newline at end of file
721
722=== modified file 'src/ubuntu/hybris/CMakeLists.txt'
723--- src/ubuntu/hybris/CMakeLists.txt 2013-12-02 09:28:56 +0000
724+++ src/ubuntu/hybris/CMakeLists.txt 2014-01-22 16:11:40 +0000
725@@ -27,7 +27,6 @@
726
727 target_link_libraries(
728 ubuntu_platform_hardware_api
729- dl
730 hybris-common
731 )
732
733
734=== modified file 'src/ubuntu/hybris/bridge.h'
735--- src/ubuntu/hybris/bridge.h 2013-12-04 07:27:30 +0000
736+++ src/ubuntu/hybris/bridge.h 2014-01-22 16:11:40 +0000
737@@ -22,8 +22,6 @@
738 #include <assert.h>
739 #include <dlfcn.h>
740 #include <stddef.h>
741-#include <stdlib.h>
742-#include <string.h>
743
744 #define HIDDEN_SYMBOL __attribute__ ((visibility ("hidden")))
745
746@@ -41,24 +39,19 @@
747 namespace internal
748 {
749
750-/* By default we load the backend from /system/lib/libubuntu_application_api.so
751- * Programs can select a different backend with $UBUNTU_PLATFORM_API_BACKEND,
752- * which either needs to be a full path or just the file name (then it will be
753- * looked up in the usual library search path, see dlopen(3)).
754- */
755 struct HIDDEN_SYMBOL ToApplication
756 {
757 static const char* path()
758 {
759- static const char* cache = NULL;
760-
761- if (cache == NULL) {
762- cache = secure_getenv("UBUNTU_PLATFORM_API_BACKEND");
763- if (cache == NULL)
764- cache = "/system/lib/libubuntu_application_api.so";
765- }
766-
767- return cache;
768+ return "/system/lib/libubuntu_application_api.so";
769+ }
770+};
771+
772+struct HIDDEN_SYMBOL ToHardware
773+{
774+ static const char* path()
775+ {
776+ return "/system/lib/libubuntu_platform_hardware_api.so";
777 }
778 };
779
780@@ -74,23 +67,12 @@
781
782 void* resolve_symbol(const char* symbol) const
783 {
784- return dlsym_fn(lib_handle, symbol);
785+ return android_dlsym(lib_handle, symbol);
786 }
787
788 protected:
789 Bridge() : lib_handle(android_dlopen(Scope::path(), RTLD_LAZY))
790 {
791- const char* path = Scope::path();
792- /* use Android dl functions for Android libs in /system/, glibc dl
793- * functions for others */
794- if (strncmp(path, "/system/", 8) == 0) {
795- lib_handle = android_dlopen(path, RTLD_LAZY);
796- dlsym_fn = android_dlsym;
797- } else {
798- lib_handle = dlopen(path, RTLD_LAZY);
799- dlsym_fn = dlsym;
800- }
801-
802 assert(lib_handle && "Error loading ubuntu_application_api");
803 }
804
805@@ -100,7 +82,6 @@
806 }
807
808 void* lib_handle;
809- void* (*dlsym_fn) (void*, const char*);
810 };
811
812 }
813@@ -194,6 +175,13 @@
814 DLSYM(&f, #symbol); \
815 f(_1, _2, _3, _4); }
816
817+#define IMPLEMENT_VOID_SF_FUNCTION4(symbol, arg1, arg2, arg3, arg4) \
818+ void symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4) \
819+ { \
820+ static void (*f)(arg1, arg2, arg3, arg4) __SF_FN_ATTR = NULL; \
821+ DLSYM(&f, #symbol); \
822+ f(_1, _2, _3, _4); }
823+
824 #define IMPLEMENT_FUNCTION4(return_type, symbol, arg1, arg2, arg3, arg4) \
825 return_type symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4) \
826 { \
827
828=== modified file 'src/ubuntu/hybris/tests/test_gps_api.cpp'
829--- src/ubuntu/hybris/tests/test_gps_api.cpp 2013-06-13 08:07:21 +0000
830+++ src/ubuntu/hybris/tests/test_gps_api.cpp 2014-01-22 16:11:40 +0000
831@@ -20,6 +20,7 @@
832 #include <ctime>
833 #include <signal.h>
834 #include <stdio.h>
835+#include <stdlib.h>
836 #include <string.h>
837 #include <unistd.h>
838
839@@ -30,10 +31,10 @@
840 public:
841 GPSTest();
842 ~GPSTest();
843- bool init_and_start();
844+ bool init_and_start(const char* server, uint16_t port);
845 bool stop();
846 void inject_time();
847-
848+ void inject_reference_location(float lat, float lon, float accuracy);
849 UHardwareGps u_hardware_gps;
850 };
851
852@@ -176,10 +177,18 @@
853 10 /* possible deviation, in milliseconds*/);
854 }
855
856-bool GPSTest::init_and_start()
857+void GPSTest::inject_reference_location(float lat, float lon, float accuracy)
858+{
859+ u_hardware_gps_inject_location(u_hardware_gps,
860+ lat,
861+ lon,
862+ accuracy);
863+}
864+
865+bool GPSTest::init_and_start(const char* supl_server, uint16_t port)
866 {
867 UHardwareGpsParams gps_params;
868-
869+
870 gps_params.location_cb = gps_location_cb;
871 gps_params.status_cb = gps_status_cb;
872 gps_params.sv_status_cb = gps_sb_status_cb;
873@@ -207,6 +216,15 @@
874 return false;
875 }
876
877+ u_hardware_gps_delete_aiding_data(u_hardware_gps,
878+ U_HARDWARE_GPS_DELETE_ALL);
879+
880+ u_hardware_gps_agps_set_server_for_type(
881+ u_hardware_gps,
882+ U_HARDWARE_GPS_AGPS_TYPE_SUPL,
883+ supl_server,
884+ port);
885+
886 return true;
887 }
888
889@@ -234,13 +252,28 @@
890
891 int main(int argc, char** argv)
892 {
893+ if (argc != 6)
894+ {
895+ printf("Usage: test_gps supl_server supl_server_port lat lon accuracy\n");
896+ return 1;
897+ }
898+
899+ const char* supl_server = argv[1];
900+ uint16_t port = atoi(argv[2]);
901+
902+ double lat = atof(argv[3]);
903+ double lon = atof(argv[4]);
904+ float accuracy = atof(argv[5]);
905+
906 int return_value = 0;
907 ubuntu::GPSTest test;
908
909- if (!test.init_and_start())
910- return 1;
911+ if (!test.init_and_start(supl_server, port))
912+ return 1;
913
914- printf("GPS initialized and started. Now waiting for callbacks or SIGINT (to quit).\n");
915+ printf("GPS initialized and started. Injecting reference location: %f %f %f.\n", lat, lon, accuracy);
916+ test.inject_reference_location(lat, lon, accuracy);
917+ printf("Now waiting for callbacks or SIGINT (to quit).\n");
918 wait_for_sigint();
919 printf("Exiting...\n");
920
921
922=== modified file 'src/ubuntu/hybris/ubuntu_application_api_hybris.cpp'
923--- src/ubuntu/hybris/ubuntu_application_api_hybris.cpp 2013-12-11 02:20:26 +0000
924+++ src/ubuntu/hybris/ubuntu_application_api_hybris.cpp 2014-01-22 16:11:40 +0000
925@@ -92,7 +92,6 @@
926 IMPLEMENT_FUNCTION1(const char*, ua_ui_window_properties_get_title, UAUiWindowProperties*);
927 IMPLEMENT_VOID_FUNCTION2(ua_ui_window_properties_set_role, UAUiWindowProperties*, UAUiWindowRole);
928 IMPLEMENT_VOID_FUNCTION3(ua_ui_window_properties_set_input_cb_and_ctx, UAUiWindowProperties*, UAUiWindowInputEventCb, void*);
929-IMPLEMENT_VOID_FUNCTION3(ua_ui_window_properties_set_dimensions, UAUiWindowProperties*, uint32_t, uint32_t);
930
931 // UAUiWindow
932 IMPLEMENT_FUNCTION2(UAUiWindow*, ua_ui_window_new_for_application_with_properties, UApplicationInstance*, UAUiWindowProperties*);
933
934=== modified file 'src/ubuntu/hybris/ubuntu_platform_hardware_api.cpp'
935--- src/ubuntu/hybris/ubuntu_platform_hardware_api.cpp 2013-06-13 08:37:52 +0000
936+++ src/ubuntu/hybris/ubuntu_platform_hardware_api.cpp 2014-01-22 16:11:40 +0000
937@@ -49,7 +49,7 @@
938 int64_t,
939 int);
940
941-IMPLEMENT_VOID_FUNCTION4(
942+IMPLEMENT_VOID_SF_FUNCTION4(
943 u_hardware_gps_inject_location,
944 UHardwareGps,
945 double,
946@@ -59,6 +59,32 @@
947 IMPLEMENT_VOID_FUNCTION2(
948 u_hardware_gps_delete_aiding_data,
949 UHardwareGps,
950+UHardwareGpsAidingData);
951+
952+IMPLEMENT_VOID_FUNCTION3(
953+u_hardware_gps_agps_set_reference_location,
954+UHardwareGps,
955+UHardwareGpsAGpsRefLocation*,
956+size_t);
957+
958+IMPLEMENT_VOID_FUNCTION2(
959+u_hardware_gps_agps_notify_connection_is_open,
960+UHardwareGps,
961+const char *);
962+
963+IMPLEMENT_VOID_FUNCTION1(
964+u_hardware_gps_agps_notify_connection_is_closed,
965+UHardwareGps);
966+
967+IMPLEMENT_VOID_FUNCTION1(
968+u_hardware_gps_agps_notify_connection_not_available,
969+UHardwareGps);
970+
971+IMPLEMENT_VOID_FUNCTION4(
972+u_hardware_gps_agps_set_server_for_type,
973+UHardwareGps,
974+UHardwareGpsAGpsType,
975+const char*,
976 uint16_t);
977
978 IMPLEMENT_FUNCTION6(
979
980=== modified file 'src/ubuntu/mirclient/ubuntu_application_api_mirclient.cpp'
981--- src/ubuntu/mirclient/ubuntu_application_api_mirclient.cpp 2013-12-11 02:20:26 +0000
982+++ src/ubuntu/mirclient/ubuntu_application_api_mirclient.cpp 2014-01-22 16:11:40 +0000
983@@ -232,12 +232,6 @@
984 properties->set_input_cb_and_ctx(cb, ctx);
985 }
986
987-void ua_ui_window_properties_set_dimensions(UAUiWindowProperties *u_properties, uint32_t width, uint32_t height)
988-{
989- auto properties = uamc::WindowProperties::from_u_window_properties(u_properties);
990- properties->set_dimensions(width, height);
991-}
992-
993 UAUiWindow* ua_ui_window_new_for_application_with_properties(UApplicationInstance* u_instance, UAUiWindowProperties* u_properties)
994 {
995 auto instance = uamc::Instance::from_u_application_instance(u_instance);
996
997=== modified file 'src/ubuntu/mirclient/window_properties_mirclient.cpp'
998--- src/ubuntu/mirclient/window_properties_mirclient.cpp 2013-12-11 04:36:18 +0000
999+++ src/ubuntu/mirclient/window_properties_mirclient.cpp 2014-01-22 16:11:40 +0000
1000@@ -54,12 +54,6 @@
1001 input_ctx = ctx;
1002 }
1003
1004-void uamc::WindowProperties::set_dimensions(uint32_t width, uint32_t height)
1005-{
1006- parameters.width = width;
1007- parameters.height = height;
1008-}
1009-
1010 void uamc::WindowProperties::set_role(UAUiWindowRole role)
1011 {
1012 if (role == U_ON_SCREEN_KEYBOARD_ROLE) {
1013
1014=== modified file 'src/ubuntu/mirclient/window_properties_mirclient_priv.h'
1015--- src/ubuntu/mirclient/window_properties_mirclient_priv.h 2013-12-11 02:20:26 +0000
1016+++ src/ubuntu/mirclient/window_properties_mirclient_priv.h 2014-01-22 16:11:40 +0000
1017@@ -47,7 +47,6 @@
1018
1019 void set_title(char const* title, size_t length);
1020 void set_input_cb_and_ctx(UAUiWindowInputEventCb cb, void* ctx);
1021- void set_dimensions(uint32_t width, uint32_t height);
1022 void set_role(UAUiWindowRole role);
1023
1024 MirSurfaceParameters const& surface_parameters() const;
1025
1026=== modified file 'src/ubuntu/mircommon/application_options_mir.cpp'
1027--- src/ubuntu/mircommon/application_options_mir.cpp 2013-12-19 15:04:23 +0000
1028+++ src/ubuntu/mircommon/application_options_mir.cpp 2014-01-22 16:11:40 +0000
1029@@ -24,12 +24,8 @@
1030 #include <getopt.h>
1031
1032 #include <tuple>
1033-#include <iostream>
1034-#include <fstream>
1035 #include <string>
1036
1037-#include <unistd.h>
1038-
1039 namespace uam = ubuntu::application::mir;
1040
1041 UApplicationOptions* uam::Options::as_u_application_options()
1042@@ -47,11 +43,11 @@
1043 UAUiStage
1044 string_to_stage(std::string const& s)
1045 {
1046- if (s == "main_stage" || s == "MainStage")
1047+ if (s == "main_stage")
1048 return U_MAIN_STAGE;
1049- else if (s == "side_stage" || s == "SideStage")
1050+ else if (s == "side_stage")
1051 return U_SIDE_STAGE;
1052- else if (s == "share_stage" || s == "ShareStage")
1053+ else if (s == "share_stage")
1054 return U_SHARE_STAGE;
1055 }
1056
1057@@ -99,60 +95,6 @@
1058
1059 auto app_options = new uam::Options;
1060
1061- // Construct legacy desktop file path
1062- std::string desktop_file_name;
1063- if (getenv("APP_ID"))
1064- {
1065- desktop_file_name = getenv("APP_ID");
1066- desktop_file_name.append(".desktop");
1067- }
1068-
1069- // Click desktop path
1070- std::string local_path;
1071- if (getenv("APP_DESKTOP_FILE_PATH"))
1072- local_path = getenv("APP_DESKTOP_FILE_PATH");;
1073-
1074- // Check StageHint
1075- std::string line, stage_hint;
1076- std::string stage_key("X-Ubuntu-StageHint");
1077-
1078- std::ifstream infile;
1079- std::string search_paths[2] = {"/usr/share/applications/", local_path};
1080- search_paths[0].append(desktop_file_name);
1081- for (std::string path : search_paths)
1082- {
1083- if (path.empty())
1084- continue;
1085-
1086- infile.open(path);
1087- if (!infile)
1088- continue;
1089-
1090- std::getline(infile, line);
1091- while (std::getline(infile, line))
1092- {
1093- if (infile.eof())
1094- break;
1095-
1096- // Check for non key-value line
1097- if (line.find("=") == std::string::npos)
1098- continue;
1099-
1100- std::string lhs = line.substr(0,line.find("="));
1101- std::string rhs = line.substr(line.find("="));
1102-
1103- // Fetch Stage
1104- if (lhs.compare(stage_key) == 0)
1105- {
1106- stage_hint = rhs.substr(1);
1107- break;
1108- }
1109- }
1110- }
1111-
1112- if (!stage_hint.empty())
1113- app_options->stage = string_to_stage(stage_hint);
1114-
1115 while(true)
1116 {
1117 int option_index = 0;
1118@@ -182,7 +124,6 @@
1119 app_options->form_factor = string_to_form_factor(std::string(optarg));
1120 break;
1121 case stage_hint_index:
1122- // Override if set
1123 app_options->stage = string_to_stage(std::string(optarg));
1124 break;
1125 case desktop_file_hint_index:
1126
1127=== modified file 'src/ubuntu/mircommon/lifecycle_delegate_mir_priv.h'
1128--- src/ubuntu/mircommon/lifecycle_delegate_mir_priv.h 2014-01-07 11:00:33 +0000
1129+++ src/ubuntu/mircommon/lifecycle_delegate_mir_priv.h 2014-01-22 16:11:40 +0000
1130@@ -19,7 +19,7 @@
1131 #ifndef UBUNTU_APPLICATION_LIECYCLE_DELEGATE_MIR_PRIV_H_
1132 #define UBUNTU_APPLICATION_LIECYCLE_DELEGATE_MIR_PRIV_H_
1133
1134-#include "mir_toolkit/common.h"
1135+#include "mircommon/mir_toolkit/common.h"
1136
1137 #include <ubuntu/application/lifecycle_delegate.h>
1138
1139
1140=== modified file 'src/ubuntu/mirserver/CMakeLists.txt'
1141--- src/ubuntu/mirserver/CMakeLists.txt 2014-01-09 18:47:45 +0000
1142+++ src/ubuntu/mirserver/CMakeLists.txt 2014-01-22 16:11:40 +0000
1143@@ -25,6 +25,8 @@
1144 )
1145
1146
1147+install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ubuntu_application_api_mirserver_priv.h DESTINATION include/ubuntu/priv/mirserver)
1148+
1149 set_target_properties(
1150 ubuntu_application_api_mirserver
1151 PROPERTIES
1152
1153=== modified file 'src/ubuntu/mirserver/ubuntu_application_api_mirserver.cpp'
1154--- src/ubuntu/mirserver/ubuntu_application_api_mirserver.cpp 2014-01-08 14:45:43 +0000
1155+++ src/ubuntu/mirserver/ubuntu_application_api_mirserver.cpp 2014-01-22 16:11:40 +0000
1156@@ -214,7 +214,7 @@
1157
1158 namespace
1159 {
1160-static MirPixelFormat choose_pixel_format(std::shared_ptr<mir::graphics::GraphicBufferAllocator> const& allocator)
1161+static mir::geometry::PixelFormat choose_pixel_format(std::shared_ptr<mir::graphics::GraphicBufferAllocator> const& allocator)
1162 {
1163 auto formats = allocator->supported_pixel_formats();
1164 return formats[0];
1165@@ -259,12 +259,6 @@
1166 properties->set_input_cb_and_ctx(cb, ctx);
1167 }
1168
1169-void ua_ui_window_properties_set_dimensions(UAUiWindowProperties *u_properties, uint32_t width, uint32_t height)
1170-{
1171- auto properties = uams::WindowProperties::from_u_window_properties(u_properties);
1172- properties->set_dimensions(width, height);
1173-}
1174-
1175 UAUiWindow* ua_ui_window_new_for_application_with_properties(UApplicationInstance* u_instance, UAUiWindowProperties* u_properties)
1176 {
1177 auto input_platform = global_mirserver_context()->input_platform;
1178
1179=== modified file 'src/ubuntu/mirserver/window_properties_mirserver.cpp'
1180--- src/ubuntu/mirserver/window_properties_mirserver.cpp 2014-01-08 14:45:43 +0000
1181+++ src/ubuntu/mirserver/window_properties_mirserver.cpp 2014-01-22 16:11:40 +0000
1182@@ -22,6 +22,7 @@
1183
1184 namespace uams = ubuntu::application::mir::server;
1185 namespace msh = mir::shell;
1186+namespace geom = mir::geometry;
1187
1188 uams::WindowProperties::WindowProperties()
1189 : parameters(msh::a_surface()),
1190@@ -51,16 +52,11 @@
1191 input_ctx = ctx;
1192 }
1193
1194-void uams::WindowProperties::set_dimensions(uint32_t width, uint32_t height)
1195-{
1196- parameters = parameters.of_size(width, height);
1197-}
1198-
1199-void uams::WindowProperties::set_pixel_format(MirPixelFormat const& format)
1200+void uams::WindowProperties::set_pixel_format(geom::PixelFormat const& format)
1201 {
1202 parameters = parameters.of_pixel_format(format);
1203 }
1204-
1205+
1206 msh::SurfaceCreationParameters const& uams::WindowProperties::surface_parameters() const
1207 {
1208 return parameters;
1209
1210=== modified file 'src/ubuntu/mirserver/window_properties_mirserver_priv.h'
1211--- src/ubuntu/mirserver/window_properties_mirserver_priv.h 2014-01-08 14:45:43 +0000
1212+++ src/ubuntu/mirserver/window_properties_mirserver_priv.h 2014-01-22 16:11:40 +0000
1213@@ -22,7 +22,7 @@
1214 #include <ubuntu/application/ui/window.h>
1215
1216 #include <mir/shell/surface_creation_parameters.h>
1217-#include <mir_toolkit/common.h>
1218+#include <mir/geometry/pixel_format.h>
1219
1220 namespace ubuntu
1221 {
1222@@ -44,8 +44,7 @@
1223
1224 void set_title(char const* title, size_t length);
1225 void set_input_cb_and_ctx(UAUiWindowInputEventCb cb, void* ctx);
1226- void set_dimensions(uint32_t width, uint32_t height);
1227- void set_pixel_format( MirPixelFormat const& format);
1228+ void set_pixel_format( ::mir::geometry::PixelFormat const& format);
1229
1230 ::mir::shell::SurfaceCreationParameters const& surface_parameters() const;
1231 UAUiWindowInputEventCb input_cb() const;
1232
1233=== removed directory 'src/ubuntu/testbackend'
1234=== removed file 'src/ubuntu/testbackend/CMakeLists.txt'
1235--- src/ubuntu/testbackend/CMakeLists.txt 2014-01-08 15:17:41 +0000
1236+++ src/ubuntu/testbackend/CMakeLists.txt 1970-01-01 00:00:00 +0000
1237@@ -1,21 +0,0 @@
1238-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11")
1239-
1240-add_library(
1241- ubuntu_application_api_test SHARED
1242- ubuntu_application_sensors.cpp
1243-)
1244-
1245-set_target_properties(
1246- ubuntu_application_api_test
1247- PROPERTIES
1248- VERSION ${UBUNTU_PLATFORM_API_VERSION_MAJOR}.${UBUNTU_PLATFORM_API_VERSION_MINOR}.${UBUNTU_PLATFORM_API_VERSION_PATCH}
1249- SOVERSION ${UBUNTU_PLATFORM_API_VERSION_MAJOR}
1250-)
1251-
1252-install(
1253- TARGETS ubuntu_application_api_test
1254- # this is not a development library to compile against, users should always
1255- # specify the SONAME; so don't build a *.so
1256- LIBRARY DESTINATION "${LIB_INSTALL_DIR}" NAMELINK_SKIP
1257-)
1258-
1259
1260=== removed file 'src/ubuntu/testbackend/README.md'
1261--- src/ubuntu/testbackend/README.md 2014-01-08 15:17:41 +0000
1262+++ src/ubuntu/testbackend/README.md 1970-01-01 00:00:00 +0000
1263@@ -1,77 +0,0 @@
1264-Testing applications with simulated sensor data
1265-===============================================
1266-
1267-Purpose
1268--------
1269-platform-api's interface to sensor data is in the shared library
1270-`libubuntu_platform_hardware_api.so`. That is only a stub which dynamically
1271-(dlopen) loads a backend library which provides the actual implementation. By
1272-default this is `/system/lib/libubuntu_application_api.so` which reads sensor
1273-data from the Android side. For testing purposes this can be replaced with this
1274-`libubuntu_application_api_test.so.1` which simulates sensors and their data based
1275-on a simple text input file.
1276-
1277-Using the test sensors
1278-----------------------
1279-Run your application under test with the environment variable
1280-
1281- UBUNTU_PLATFORM_API_BACKEND=libubuntu_application_api_test.so.1
1282-
1283-and make sure that ld.so(8) can find it. If you don't have the library
1284-installed in a standard system library path, it is recommended to set
1285-`LD_LIBRARY_PATH` to the directory that contains the library (usually when using
1286-the library right out of the build tree). Alternatively you can specify the
1287-full path in `$UBUNTU_PLATFORM_API_BACKEND`.
1288-
1289-The env variable `$UBUNTU_PLATFORM_API_SENSOR_TEST` needs to point to a file that
1290-describes the desired sensor behaviour.
1291-
1292-Data format
1293------------
1294-The test sensors use a simple line based file format. The first part
1295-instantiates desired sensors with their parameters:
1296-
1297- create [accel|light] <min> <max> <resolution>
1298- # but no arguments for proximity sensor:
1299- create proximity
1300-
1301-After that, it defines events; <delay> specifies time after previous event
1302-in ms:
1303-
1304- <delay> proximity [unknown|near|far]
1305- <delay> light <value>
1306- <delay> accel <x> <y> <z>
1307-
1308-Empty lines and comment lines (starting with #) are allowed.
1309-
1310-Example file:
1311-
1312- create light 0 10 1
1313- create accel 0 1000 0.1
1314- create proximity
1315-
1316- 200 proximity near
1317- 500 light 5
1318- # simulate crash on the ground
1319- 500 accel 0.2 0.1 10
1320- 100 accel 0.2 0.2 1000
1321- 20 accel 0 0 0
1322- 10 proximity far
1323- 0 light 10
1324-
1325-
1326-Complete example
1327-----------------
1328- * Build platform-api:
1329-
1330- mkdir obj; (cd obj; cmake .. && make)
1331-
1332- * Put above example file into /tmp/test.sensors
1333-
1334- * Run the sensor test with it:
1335-
1336- LD_LIBRARY_PATH=obj/src/ubuntu/testbackend \
1337- UBUNTU_PLATFORM_API_BACKEND=libubuntu_application_api_test.so.1 \
1338- UBUNTU_PLATFORM_API_SENSOR_TEST=/tmp/test.sensors \
1339- obj/src/ubuntu/hybris/tests/test_android_sensors_api
1340-
1341
1342=== removed file 'src/ubuntu/testbackend/ubuntu_application_sensors.cpp'
1343--- src/ubuntu/testbackend/ubuntu_application_sensors.cpp 2013-12-12 14:40:21 +0000
1344+++ src/ubuntu/testbackend/ubuntu_application_sensors.cpp 1970-01-01 00:00:00 +0000
1345@@ -1,553 +0,0 @@
1346-/*
1347- * Copyright (C) 2013 Canonical Ltd
1348- *
1349- * This program is free software: you can redistribute it and/or modify
1350- * it under the terms of the GNU Lesser General Public License version 3 as
1351- * published by the Free Software Foundation.
1352- *
1353- * This program is distributed in the hope that it will be useful,
1354- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1355- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1356- * GNU Lesser General Public License for more details.
1357- *
1358- * You should have received a copy of the GNU Lesser General Public License
1359- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1360- *
1361- * Authored by: Martin Pitt <martin.pitti@ubuntu.com>
1362- */
1363-
1364-#include <ubuntu/application/sensors/ubuntu_application_sensors.h>
1365-#include <ubuntu/application/sensors/accelerometer.h>
1366-#include <ubuntu/application/sensors/proximity.h>
1367-#include <ubuntu/application/sensors/light.h>
1368-
1369-#include <cstddef>
1370-#include <cstdlib>
1371-#include <cstring>
1372-#include <cerrno>
1373-#include <csignal>
1374-#include <iostream>
1375-#include <sstream>
1376-#include <fstream>
1377-#include <stdexcept>
1378-#include <chrono>
1379-#include <map>
1380-#include <memory>
1381-
1382-using namespace std;
1383-
1384-// necessary for functions that return float
1385-// pcs attribute (calling convention) is only defined on ARM, avoid warning on
1386-// other platforms
1387-#ifdef __arm__
1388-#define __SF_FN_ATTR __attribute__((pcs("aapcs")))
1389-#else
1390-#define __SF_FN_ATTR
1391-#endif
1392-
1393-
1394-/***************************************
1395- *
1396- * test sensor implementation
1397- *
1398- ***************************************/
1399-
1400-// this is only internal API, so we make everything public
1401-struct TestSensor
1402-{
1403- TestSensor(ubuntu_sensor_type _type, float _min_value, float _max_value, float _resolution) :
1404- type(_type),
1405- enabled(false),
1406- resolution(_resolution),
1407- min_delay(0),
1408- min_value(_min_value),
1409- max_value(_max_value),
1410- on_event_cb(NULL),
1411- event_cb_context(NULL),
1412- x(_min_value),
1413- y(_min_value),
1414- z(_min_value),
1415- distance((UASProximityDistance) 0), // LP#1256969
1416- timestamp(0)
1417- {}
1418-
1419- ubuntu_sensor_type type;
1420- bool enabled;
1421- float resolution;
1422- uint32_t min_delay;
1423- float min_value, max_value;
1424- void (*on_event_cb)(void*, void*);
1425- void* event_cb_context;
1426-
1427- /* current value; note that we do not track separate Event objects/pointers
1428- * at all, and just always deliver the current value */
1429- float x, y, z;
1430- UASProximityDistance distance;
1431- uint64_t timestamp;
1432-};
1433-
1434-/* Singleton which reads the sensor data file and maintains the TestSensor
1435- * instances */
1436-class SensorController
1437-{
1438- public:
1439- // Ensure that controller is initialized, and return singleton
1440- static SensorController& instance()
1441- {
1442- static SensorController _inst;
1443- return _inst;
1444- }
1445-
1446- // Return TestSensor of given type, or NULL if it doesn't exist
1447- TestSensor* get(ubuntu_sensor_type type)
1448- {
1449- try {
1450- return sensors.at(type).get();
1451- } catch (const out_of_range&) {
1452- return NULL;
1453- }
1454- }
1455-
1456- private:
1457- SensorController();
1458- bool next_command();
1459- bool process_create_command();
1460- void process_event_command();
1461- void setup_timer(unsigned delay_ms);
1462- static void on_timer(union sigval sval);
1463-
1464- static ubuntu_sensor_type type_from_name(const string& type)
1465- {
1466- if (type == "light")
1467- return ubuntu_sensor_type_light;
1468- if (type == "proximity")
1469- return ubuntu_sensor_type_proximity;
1470- if (type == "accel")
1471- return ubuntu_sensor_type_accelerometer;
1472-
1473- cerr << "TestSensor ERROR: unknown sensor type " << type << endl;
1474- abort();
1475- }
1476-
1477- map<ubuntu_sensor_type, shared_ptr<TestSensor>> sensors;
1478- ifstream data;
1479-
1480- // current command/event
1481- string current_command;
1482- TestSensor* event_sensor;
1483- float event_x, event_y, event_z;
1484- UASProximityDistance event_distance;
1485-};
1486-
1487-SensorController::SensorController()
1488-{
1489- const char* path = getenv("UBUNTU_PLATFORM_API_SENSOR_TEST");
1490-
1491- if (path == NULL) {
1492- cerr << "TestSensor ERROR: Need $UBUNTU_PLATFORM_API_SENSOR_TEST to point to a data file\n";
1493- abort();
1494- }
1495-
1496- //cout << "SensorController ctor: opening " << path << endl;
1497-
1498- data.open(path);
1499- if (!data.is_open()) {
1500- cerr << "TestSensor ERROR: Failed to open data file " << path << ": " << strerror(errno) << endl;
1501- abort();
1502- }
1503-
1504- // process all "create" commands
1505- while (next_command()) {
1506- if (!process_create_command())
1507- break;
1508- }
1509-
1510- // start event processing
1511- if (!data.eof())
1512- process_event_command();
1513-}
1514-
1515-bool
1516-SensorController::next_command()
1517-{
1518- while (getline(data, current_command)) {
1519- // trim leading and trailing space
1520- current_command.erase(0, current_command.find_first_not_of(" \t"));
1521- current_command.erase(current_command.find_last_not_of(" \t") + 1);
1522- // ignore empty or comment lines
1523- if (current_command.size() == 0 || current_command[0] == '#')
1524- continue;
1525- return true;
1526- }
1527- return false;
1528-}
1529-
1530-bool
1531-SensorController::process_create_command()
1532-{
1533- stringstream ss(current_command, ios_base::in);
1534- string token;
1535-
1536- // we only process "create" commands here; if we have something else, stop
1537- ss >> token;
1538- if (token != "create")
1539- return false;
1540-
1541- ss >> token;
1542- ubuntu_sensor_type type = type_from_name(token);
1543-
1544- if (get(type) != NULL) {
1545- cerr << "TestSensor ERROR: duplicate creation of sensor type " << token << endl;
1546- abort();
1547- }
1548-
1549- float min = 0, max = 0, resolution = 0;
1550-
1551- if (type != ubuntu_sensor_type_proximity) {
1552- // read min, max, resolution
1553- ss >> min >> max >> resolution;
1554-
1555- if (max <= min) {
1556- cerr << "TestSensor ERROR: max_value must be >= min_value in " << current_command << endl;
1557- abort();
1558- }
1559- if (resolution <= 0) {
1560- cerr << "TestSensor ERROR: resolution must be > 0 in " << current_command << endl;
1561- abort();
1562- }
1563- }
1564-
1565- //cout << "SensorController::process_create_command: type " << type << " min " << min << " max " << max << " res " << resolution << endl;
1566-
1567- sensors[type] = make_shared<TestSensor>(type, min, max, resolution);
1568- return true;
1569-}
1570-
1571-void
1572-SensorController::process_event_command()
1573-{
1574- stringstream ss(current_command, ios_base::in);
1575- int delay;
1576-
1577- //cout << "TestSensor: processing event " << current_command << endl;
1578-
1579- // parse delay
1580- ss >> delay;
1581- if (delay <= 0) {
1582- cerr << "TestSensor ERROR: delay must be positive in command " << current_command << endl;
1583- abort();
1584- }
1585-
1586- // parse sensor type
1587- string token;
1588- ss >> token;
1589- ubuntu_sensor_type type = type_from_name(token);
1590- event_sensor = get(type);
1591- if (event_sensor == NULL) {
1592- cerr << "TestSensor ERROR: sensor does not exist, you need to create it: " << token << endl;
1593- abort();
1594- }
1595-
1596- switch (type) {
1597- case ubuntu_sensor_type_light:
1598- ss >> event_x;
1599- //cout << "got event: sensor type " << type << " (light), delay "
1600- // << delay << " ms, value " << event_x << endl;
1601- break;
1602-
1603- case ubuntu_sensor_type_accelerometer:
1604- ss >> event_x >> event_y >> event_z;
1605- //cout << "got event: sensor type " << type << " (accel), delay "
1606- // << delay << " ms, value " << event_x << "/" << event_y << "/" << event_z << endl;
1607- break;
1608-
1609- case ubuntu_sensor_type_proximity:
1610- ss >> token;
1611- if (token == "unknown")
1612- event_distance = (UASProximityDistance) 0; // LP#1256969
1613- else if (token == "near")
1614- event_distance = U_PROXIMITY_NEAR;
1615- else if (token == "far")
1616- event_distance = U_PROXIMITY_FAR;
1617- else {
1618- cerr << "TestSensor ERROR: unknown proximity value " << token << endl;
1619- abort();
1620- }
1621- //cout << "got event: sensor type " << type << " (proximity), delay "
1622- // << delay << " ms, value " << int(event_distance) << endl;
1623- break;
1624-
1625- default:
1626- cerr << "TestSensor ERROR: unhandled sensor type " << token << endl;
1627- abort();
1628- }
1629-
1630- // wake up after given delay for committing the change and processing the
1631- // next event
1632- setup_timer(unsigned(delay));
1633-}
1634-
1635-void
1636-SensorController::setup_timer(unsigned delay_ms)
1637-{
1638- static timer_t timerid; // we keep a pointer to that until on_timer
1639- struct sigevent sev;
1640- struct itimerspec its { {0, 0}, // interval
1641- {time_t(delay_ms / 1000),
1642- long((delay_ms % 1000) * 1000000L) % 1000000000L } };
1643-
1644- sev.sigev_notify = SIGEV_THREAD;
1645- sev.sigev_notify_function = SensorController::on_timer;
1646- sev.sigev_notify_attributes = NULL;
1647- sev.sigev_value.sival_ptr = &timerid;
1648-
1649- if (timer_create(CLOCK_MONOTONIC, &sev, &timerid) < 0) {
1650- perror("TestSensor ERROR: Failed to create timer");
1651- abort();
1652- }
1653- if (timer_settime(timerid, 0, &its, NULL) < 0) {
1654- perror("TestSensor ERROR: Failed to set up timer");
1655- abort();
1656- };
1657-}
1658-
1659-void
1660-SensorController::on_timer(union sigval sval)
1661-{
1662- timer_t* timerid = static_cast<timer_t*>(sval.sival_ptr);
1663- //cout << "on_timer called\n";
1664- timer_delete(*timerid);
1665-
1666- SensorController& sc = SensorController::instance();
1667-
1668- // update sensor values, call callback
1669- if (sc.event_sensor && sc.event_sensor->enabled) {
1670- sc.event_sensor->x = sc.event_x;
1671- sc.event_sensor->y = sc.event_y;
1672- sc.event_sensor->z = sc.event_z;
1673- sc.event_sensor->distance = sc.event_distance;
1674- sc.event_sensor->timestamp = chrono::duration_cast<chrono::nanoseconds>(
1675- chrono::system_clock::now().time_since_epoch()).count();
1676- if (sc.event_sensor->on_event_cb != NULL) {
1677- //cout << "TestSensor: calling sensor callback for type " << sc.event_sensor->type << endl;
1678- sc.event_sensor->on_event_cb(sc.event_sensor, sc.event_sensor->event_cb_context);
1679- } else {
1680- //cout << "TestSensor: sensor type " << sc.event_sensor->type << "has no callback\n";
1681- }
1682- } else {
1683- //cout << "TestSensor: sensor type " << sc.event_sensor->type << "disabled, not processing event\n";
1684- }
1685-
1686- // read/process next event
1687- if (sc.next_command())
1688- sc.process_event_command();
1689- else {
1690- //cout << "TestSensor: script ended, no further commands\n";
1691- }
1692-}
1693-
1694-
1695-/***************************************
1696- *
1697- * Acceleration API
1698- *
1699- ***************************************/
1700-
1701-UASensorsAccelerometer* ua_sensors_accelerometer_new()
1702-{
1703- return SensorController::instance().get(ubuntu_sensor_type_accelerometer);
1704-}
1705-
1706-UStatus ua_sensors_accelerometer_enable(UASensorsAccelerometer* s)
1707-{
1708- static_cast<TestSensor*>(s)->enabled = true;
1709- return (UStatus) 0;
1710-}
1711-
1712-UStatus ua_sensors_accelerometer_disable(UASensorsAccelerometer* s)
1713-{
1714- static_cast<TestSensor*>(s)->enabled = false;
1715- return (UStatus) 0;
1716-}
1717-
1718-uint32_t ua_sensors_accelerometer_get_min_delay(UASensorsAccelerometer* s)
1719-{
1720- return static_cast<TestSensor*>(s)->min_delay;
1721-}
1722-
1723-float ua_sensors_accelerometer_get_min_value(UASensorsAccelerometer* s) __SF_FN_ATTR;
1724-float ua_sensors_accelerometer_get_min_value(UASensorsAccelerometer* s)
1725-{
1726- return static_cast<TestSensor*>(s)->min_value;
1727-}
1728-
1729-float ua_sensors_accelerometer_get_max_value(UASensorsAccelerometer* s) __SF_FN_ATTR;
1730-float ua_sensors_accelerometer_get_max_value(UASensorsAccelerometer* s)
1731-{
1732- return static_cast<TestSensor*>(s)->max_value;
1733-}
1734-
1735-float ua_sensors_accelerometer_get_resolution(UASensorsAccelerometer* s) __SF_FN_ATTR;
1736-float ua_sensors_accelerometer_get_resolution(UASensorsAccelerometer* s)
1737-{
1738- return static_cast<TestSensor*>(s)->resolution;
1739-}
1740-
1741-void ua_sensors_accelerometer_set_reading_cb(UASensorsAccelerometer* s, on_accelerometer_event_cb cb, void* ctx)
1742-{
1743- TestSensor* sensor = static_cast<TestSensor*>(s);
1744- sensor->on_event_cb = cb;
1745- sensor->event_cb_context = ctx;
1746-}
1747-
1748-uint64_t uas_accelerometer_event_get_timestamp(UASAccelerometerEvent* e)
1749-{
1750- return static_cast<TestSensor*>(e)->timestamp;
1751-}
1752-
1753-float uas_accelerometer_event_get_acceleration_x(UASAccelerometerEvent* e) __SF_FN_ATTR;
1754-float uas_accelerometer_event_get_acceleration_x(UASAccelerometerEvent* e)
1755-{
1756- return static_cast<TestSensor*>(e)->x;
1757-}
1758-
1759-float uas_accelerometer_event_get_acceleration_y(UASAccelerometerEvent* e) __SF_FN_ATTR;
1760-float uas_accelerometer_event_get_acceleration_y(UASAccelerometerEvent* e)
1761-{
1762- return static_cast<TestSensor*>(e)->y;
1763-}
1764-
1765-float uas_accelerometer_event_get_acceleration_z(UASAccelerometerEvent* e) __SF_FN_ATTR;
1766-float uas_accelerometer_event_get_acceleration_z(UASAccelerometerEvent* e)
1767-{
1768- return static_cast<TestSensor*>(e)->z;
1769-}
1770-
1771-/***************************************
1772- *
1773- * Proximity API
1774- *
1775- ***************************************/
1776-
1777-UASensorsProximity* ua_sensors_proximity_new()
1778-{
1779- return SensorController::instance().get(ubuntu_sensor_type_proximity);
1780-}
1781-
1782-UStatus ua_sensors_proximity_enable(UASensorsProximity* s)
1783-{
1784- static_cast<TestSensor*>(s)->enabled = true;
1785- return (UStatus) 0;
1786-}
1787-
1788-UStatus ua_sensors_proximity_disable(UASensorsProximity* s)
1789-{
1790- static_cast<TestSensor*>(s)->enabled = false;
1791- return (UStatus) 0;
1792-}
1793-
1794-uint32_t ua_sensors_proximity_get_min_delay(UASensorsProximity* s)
1795-{
1796- return static_cast<TestSensor*>(s)->min_delay;
1797-}
1798-
1799-// the next three function make no sense in the API, just return zero
1800-float ua_sensors_proximity_get_min_value(UASensorsProximity*) __SF_FN_ATTR;
1801-float ua_sensors_proximity_get_min_value(UASensorsProximity*)
1802-{
1803- return 0.0;
1804-}
1805-
1806-float ua_sensors_proximity_get_max_value(UASensorsProximity*) __SF_FN_ATTR;
1807-float ua_sensors_proximity_get_max_value(UASensorsProximity*)
1808-{
1809- return 0.0;
1810-}
1811-
1812-float ua_sensors_proximity_get_resolution(UASensorsProximity*) __SF_FN_ATTR;
1813-float ua_sensors_proximity_get_resolution(UASensorsProximity*)
1814-{
1815- return 0.0;
1816-}
1817-
1818-void ua_sensors_proximity_set_reading_cb(UASensorsProximity* s, on_proximity_event_cb cb, void* ctx)
1819-{
1820- TestSensor* sensor = static_cast<TestSensor*>(s);
1821- sensor->on_event_cb = cb;
1822- sensor->event_cb_context = ctx;
1823-}
1824-
1825-uint64_t uas_proximity_event_get_timestamp(UASProximityEvent* e)
1826-{
1827- return static_cast<TestSensor*>(e)->timestamp;
1828-}
1829-
1830-UASProximityDistance uas_proximity_event_get_distance(UASProximityEvent* e)
1831-{
1832- return static_cast<TestSensor*>(e)->distance;
1833-}
1834-
1835-
1836-/***************************************
1837- *
1838- * Light API
1839- *
1840- ***************************************/
1841-
1842-UASensorsLight* ua_sensors_light_new()
1843-{
1844- return SensorController::instance().get(ubuntu_sensor_type_light);
1845-}
1846-
1847-UStatus ua_sensors_light_enable(UASensorsLight* s)
1848-{
1849- static_cast<TestSensor*>(s)->enabled = true;
1850- return (UStatus) 0;
1851-}
1852-
1853-UStatus ua_sensors_light_disable(UASensorsLight* s)
1854-{
1855- static_cast<TestSensor*>(s)->enabled = false;
1856- return (UStatus) 0;
1857-}
1858-
1859-uint32_t ua_sensors_light_get_min_delay(UASensorsLight* s)
1860-{
1861- return static_cast<TestSensor*>(s)->min_delay;
1862-}
1863-
1864-float ua_sensors_light_get_min_value(UASensorsLight* s) __SF_FN_ATTR;
1865-float ua_sensors_light_get_min_value(UASensorsLight* s)
1866-{
1867- return static_cast<TestSensor*>(s)->min_value;
1868-}
1869-
1870-float ua_sensors_light_get_max_value(UASensorsLight* s) __SF_FN_ATTR;
1871-float ua_sensors_light_get_max_value(UASensorsLight* s)
1872-{
1873- return static_cast<TestSensor*>(s)->max_value;
1874-}
1875-
1876-float ua_sensors_light_get_resolution(UASensorsLight* s) __SF_FN_ATTR;
1877-float ua_sensors_light_get_resolution(UASensorsLight* s)
1878-{
1879- return static_cast<TestSensor*>(s)->resolution;
1880-}
1881-
1882-void ua_sensors_light_set_reading_cb(UASensorsLight* s, on_light_event_cb cb, void* ctx)
1883-{
1884- TestSensor* sensor = static_cast<TestSensor*>(s);
1885- sensor->on_event_cb = cb;
1886- sensor->event_cb_context = ctx;
1887-}
1888-
1889-uint64_t uas_light_event_get_timestamp(UASLightEvent* e)
1890-{
1891- return static_cast<TestSensor*>(e)->timestamp;
1892-}
1893-
1894-float uas_light_event_get_light(UASLightEvent* e) __SF_FN_ATTR;
1895-float uas_light_event_get_light(UASLightEvent* e)
1896-{
1897- return static_cast<TestSensor*>(e)->x;
1898-}
1899
1900=== removed directory 'tests'
1901=== removed file 'tests/CMakeLists.txt'
1902--- tests/CMakeLists.txt 2013-12-06 13:47:56 +0000
1903+++ tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
1904@@ -1,30 +0,0 @@
1905-find_package(PkgConfig REQUIRED)
1906-pkg_check_modules(PROCESS_CPP process-cpp REQUIRED)
1907-
1908-include_directories(${GTEST_ROOT}/src)
1909-include_directories(${PROCESS_CPP_INCLUDE_DIRS})
1910-
1911-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11")
1912-
1913-add_executable(
1914- test_ubuntu_application_sensors
1915- test_ubuntu_application_sensors.cpp
1916-)
1917-
1918-target_link_libraries(
1919- test_ubuntu_application_sensors
1920-
1921- ubuntu_application_api
1922- gtest
1923- gtest_main
1924- ${PROCESS_CPP_LIBRARIES}
1925-)
1926-
1927-# we need to call the tests with pointing to the locally built test platform
1928-# library
1929-add_test(
1930- test_ubuntu_application_sensors
1931-
1932- env LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/src/ubuntu/testbackend ${CMAKE_CURRENT_BINARY_DIR}/test_ubuntu_application_sensors
1933-)
1934-
1935
1936=== removed file 'tests/test_ubuntu_application_sensors.cpp'
1937--- tests/test_ubuntu_application_sensors.cpp 2014-01-08 15:17:41 +0000
1938+++ tests/test_ubuntu_application_sensors.cpp 1970-01-01 00:00:00 +0000
1939@@ -1,243 +0,0 @@
1940-/*
1941- * Copyright (C) 2013 Canonical Ltd
1942- *
1943- * This program is free software: you can redistribute it and/or modify
1944- * it under the terms of the GNU Lesser General Public License version 3 as
1945- * published by the Free Software Foundation.
1946- *
1947- * This program is distributed in the hope that it will be useful,
1948- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1949- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1950- * GNU Lesser General Public License for more details.
1951- *
1952- * You should have received a copy of the GNU Lesser General Public License
1953- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1954- *
1955- * Authored by: Martin Pitt <martin.pitti@ubuntu.com>
1956- */
1957-
1958-#include <cstdlib>
1959-#include <cstdio>
1960-#include <queue>
1961-#include <chrono>
1962-
1963-#include <core/testing/fork_and_run.h>
1964-
1965-#include "gtest/gtest.h"
1966-
1967-#include <ubuntu/application/sensors/accelerometer.h>
1968-#include <ubuntu/application/sensors/event/accelerometer.h>
1969-#include <ubuntu/application/sensors/proximity.h>
1970-#include <ubuntu/application/sensors/event/proximity.h>
1971-#include <ubuntu/application/sensors/light.h>
1972-#include <ubuntu/application/sensors/event/light.h>
1973-
1974-using namespace std;
1975-
1976-typedef chrono::time_point<chrono::system_clock,chrono::nanoseconds> time_point_system_ns;
1977-
1978-struct event {
1979- uint64_t timestamp;
1980- float x, y, z;
1981- UASProximityDistance distance;
1982- void* context;
1983-};
1984-queue<struct event> events;
1985-
1986-class APITest : public testing::Test
1987-{
1988- protected:
1989- virtual void SetUp()
1990- {
1991- snprintf(data_file, sizeof(data_file), "%s", "/tmp/sensor_test.XXXXXX");
1992- data_fd = mkstemp(data_file);
1993- if (data_fd < 0) {
1994- perror("mkstemp");
1995- abort();
1996- }
1997- setenv("UBUNTU_PLATFORM_API_SENSOR_TEST", data_file, 1);
1998- setenv("UBUNTU_PLATFORM_API_BACKEND", "libubuntu_application_api_test.so.1", 1);
1999-
2000- // ensure the queue is clear
2001- while (events.size() > 0)
2002- events.pop();
2003- }
2004-
2005- virtual void TearDown()
2006- {
2007- unlink(data_file);
2008- }
2009-
2010- void set_data(const char* data)
2011- {
2012- write(data_fd, data, strlen(data));
2013- fsync(data_fd);
2014- }
2015-
2016- char data_file[100];
2017- int data_fd;
2018-};
2019-
2020-// without any data, there are no sensors defined
2021-TESTP_F(APITest, NoData, {
2022- EXPECT_EQ(NULL, ua_sensors_accelerometer_new());
2023- EXPECT_EQ(NULL, ua_sensors_proximity_new());
2024- EXPECT_EQ(NULL, ua_sensors_light_new());
2025-})
2026-
2027-TESTP_F(APITest, CreateProximity, {
2028- set_data("create proximity");
2029- EXPECT_EQ(NULL, ua_sensors_accelerometer_new());
2030- EXPECT_EQ(NULL, ua_sensors_light_new());
2031-
2032- UASensorsProximity *s = ua_sensors_proximity_new();
2033- EXPECT_TRUE(s != NULL);
2034-})
2035-
2036-TESTP_F(APITest, CreateAccelerator, {
2037- set_data("create accel 0.5 1000 0.1");
2038- EXPECT_EQ(NULL, ua_sensors_proximity_new());
2039- EXPECT_EQ(NULL, ua_sensors_light_new());
2040-
2041- UASensorsAccelerometer *s = ua_sensors_accelerometer_new();
2042- EXPECT_TRUE(s != NULL);
2043- EXPECT_FLOAT_EQ(0.5, ua_sensors_accelerometer_get_min_value(s));
2044- EXPECT_FLOAT_EQ(1000.0, ua_sensors_accelerometer_get_max_value(s));
2045- EXPECT_FLOAT_EQ(0.1, ua_sensors_accelerometer_get_resolution(s));
2046-})
2047-
2048-TESTP_F(APITest, CreateLight, {
2049- set_data("create light 0 10 0.5");
2050- EXPECT_EQ(NULL, ua_sensors_proximity_new());
2051- EXPECT_EQ(NULL, ua_sensors_accelerometer_new());
2052-
2053- UASensorsLight *s = ua_sensors_light_new();
2054- EXPECT_TRUE(s != NULL);
2055- EXPECT_FLOAT_EQ(0.0, ua_sensors_light_get_min_value(s));
2056- EXPECT_FLOAT_EQ(10.0, ua_sensors_light_get_max_value(s));
2057- EXPECT_FLOAT_EQ(0.5, ua_sensors_light_get_resolution(s));
2058-})
2059-
2060-TESTP_F(APITest, ProximityEvents, {
2061- set_data("create proximity\n"
2062- " # some comment\n"
2063- " \n"
2064- "50 proximity near\n"
2065- "100 proximity far\n"
2066- "80 proximity unknown\n"
2067- );
2068-
2069- UASensorsProximity *s = ua_sensors_proximity_new();
2070- EXPECT_TRUE(s != NULL);
2071- ua_sensors_proximity_enable(s);
2072- auto start_time = chrono::system_clock::now();
2073-
2074- ua_sensors_proximity_set_reading_cb(s,
2075- [](UASProximityEvent* ev, void* ctx) {
2076- events.push({uas_proximity_event_get_timestamp(ev),
2077- .0, .0, .0,
2078- uas_proximity_event_get_distance(ev),
2079- ctx});
2080- }, NULL);
2081-
2082- usleep(350000);
2083- EXPECT_EQ(3, events.size());
2084-
2085- auto e = events.front();
2086- events.pop();
2087- EXPECT_EQ(e.distance, U_PROXIMITY_NEAR);
2088- EXPECT_EQ(NULL, e.context);
2089- auto event_time = time_point_system_ns(std::chrono::nanoseconds(e.timestamp));
2090- auto delay = chrono::duration_cast<chrono::milliseconds>(event_time - start_time).count();
2091- EXPECT_GE(delay, 30);
2092- EXPECT_LE(delay, 70);
2093-
2094- e = events.front();
2095- events.pop();
2096- EXPECT_EQ(e.distance, U_PROXIMITY_FAR);
2097- event_time = time_point_system_ns(std::chrono::nanoseconds(e.timestamp));
2098- delay = chrono::duration_cast<chrono::milliseconds>(event_time - start_time).count();
2099- EXPECT_GE(delay, 130);
2100- EXPECT_LE(delay, 170);
2101-
2102- e = events.front();
2103- events.pop();
2104- EXPECT_EQ(e.distance, (UASProximityDistance) 0);
2105- event_time = time_point_system_ns(std::chrono::nanoseconds(e.timestamp));
2106- delay = chrono::duration_cast<chrono::milliseconds>(event_time - start_time).count();
2107- EXPECT_GE(delay, 210);
2108- EXPECT_LE(delay, 250);
2109-})
2110-
2111-TESTP_F(APITest, LightEvents, {
2112- set_data(" create light 0 10 1\n"
2113- "1 light 5\n"
2114- "100 light 8\n"
2115- );
2116-
2117- UASensorsLight *s = ua_sensors_light_new();
2118- EXPECT_TRUE(s != NULL);
2119- ua_sensors_light_enable(s);
2120- auto start_time = chrono::system_clock::now();
2121-
2122- ua_sensors_light_set_reading_cb(s,
2123- [](UASLightEvent* ev, void* ctx) {
2124- events.push({uas_light_event_get_timestamp(ev),
2125- uas_light_event_get_light(ev), .0, .0,
2126- (UASProximityDistance) 0, ctx});
2127- }, NULL);
2128-
2129- usleep(130000);
2130- EXPECT_EQ(2, events.size());
2131-
2132- auto e = events.front();
2133- events.pop();
2134- EXPECT_FLOAT_EQ(e.x, 5);
2135- EXPECT_EQ(NULL, e.context);
2136- auto event_time = time_point_system_ns(std::chrono::nanoseconds(e.timestamp));
2137- auto delay = chrono::duration_cast<chrono::milliseconds>(event_time - start_time).count();
2138- EXPECT_LE(delay, 10);
2139-
2140- e = events.front();
2141- events.pop();
2142- EXPECT_FLOAT_EQ(e.x, 8);
2143- event_time = time_point_system_ns(std::chrono::nanoseconds(e.timestamp));
2144- delay = chrono::duration_cast<chrono::milliseconds>(event_time - start_time).count();
2145- EXPECT_GE(delay, 91);
2146- EXPECT_LE(delay, 111);
2147-})
2148-
2149-TESTP_F(APITest, AccelEvents, {
2150- // cover the case of > 1 s, to ensure that we correctly do mod arithmetic
2151- set_data("create accel -1000 1000 0.1\n"
2152- "1100 accel 5.5 -8.5 9.9\n"
2153- );
2154-
2155- UASensorsAccelerometer *s = ua_sensors_accelerometer_new();
2156- EXPECT_TRUE(s != NULL);
2157- ua_sensors_accelerometer_enable(s);
2158- auto start_time = chrono::system_clock::now();
2159-
2160- ua_sensors_accelerometer_set_reading_cb(s,
2161- [](UASAccelerometerEvent* ev, void* ctx) {
2162- events.push({uas_accelerometer_event_get_timestamp(ev),
2163- uas_accelerometer_event_get_acceleration_x(ev),
2164- uas_accelerometer_event_get_acceleration_y(ev),
2165- uas_accelerometer_event_get_acceleration_z(ev),
2166- (UASProximityDistance) 0, ctx});
2167- }, NULL);
2168-
2169- usleep(1200000);
2170- EXPECT_EQ(1, events.size());
2171-
2172- auto e = events.front();
2173- events.pop();
2174- EXPECT_FLOAT_EQ(e.x, 5.5);
2175- EXPECT_FLOAT_EQ(e.y, -8.5);
2176- EXPECT_FLOAT_EQ(e.z, 9.9);
2177- EXPECT_EQ(NULL, e.context);
2178- auto event_time = time_point_system_ns(std::chrono::nanoseconds(e.timestamp));
2179- auto delay = chrono::duration_cast<chrono::milliseconds>(event_time - start_time).count();
2180- EXPECT_GE(delay, 1050);
2181- EXPECT_LE(delay, 1150);
2182-})

Subscribers

People subscribed via source and target branches