Merge lp:~thomas-voss/platform-api/support-glonass-and-other-satellite-networks into lp:platform-api

Proposed by Thomas Voß
Status: Needs review
Proposed branch: lp:~thomas-voss/platform-api/support-glonass-and-other-satellite-networks
Merge into: lp:platform-api
Diff against target: 233 lines (+100/-33)
6 files modified
android/hybris/Android.mk (+4/-0)
android/hybris/event_loop.h (+2/-0)
android/hybris/ubuntu_application_gps_for_hybris.cpp (+54/-3)
include/ubuntu/hardware/gps.h (+28/-28)
src/ubuntu/hardware/tests/test_gps_api.cpp (+6/-2)
src/ubuntu/hardware/ubuntu_platform_hardware_api.cpp (+6/-0)
To merge this branch: bzr merge lp:~thomas-voss/platform-api/support-glonass-and-other-satellite-networks
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ubuntu Phablet Team Pending
Review via email: mp+282192@code.launchpad.net

Commit message

Make UHardwareGpsSvStatus an opaque type.

Description of the change

Make UHardwareGpsSvStatus an opaque type.

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

Only depend on element count for extracting sv info flags.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
320. By Thomas Voß

Move UHardwareGps_ out of anonymous namespace.

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

Unmerged revisions

320. By Thomas Voß

Move UHardwareGps_ out of anonymous namespace.

319. By Thomas Voß

Only depend on element count for extracting sv info flags.

318. By Thomas Voß

Make UHardwareGpsSvStatus an opaque type.

317. By Thomas Voß

Add a timeout to render remote_agent_tests more robust.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'android/hybris/Android.mk'
2--- android/hybris/Android.mk 2015-06-23 21:35:21 +0000
3+++ android/hybris/Android.mk 2016-01-12 07:30:28 +0000
4@@ -13,6 +13,10 @@
5 -DANDROID_VERSION_MINOR=$(ANDROID_VERSION_MINOR) \
6 -DANDROID_VERSION_PATCH=$(ANDROID_VERSION_PATCH)
7
8+ifeq ($(BOARD_HAS_SUPPORT_FOR_ADDITIONAL_SATELLITE_NETWORKS),true)
9+ LOCAL_CFLAGS += -DBOARD_HAS_SUPPORT_FOR_ADDITIONAL_SATELLITE_NETWORKS
10+endif
11+
12 UPAPI_PATH := $(LOCAL_PATH)/../../
13
14 LOCAL_CFLAGS += -std=gnu++0x
15
16=== modified file 'android/hybris/event_loop.h'
17--- android/hybris/event_loop.h 2013-02-05 07:46:29 +0000
18+++ android/hybris/event_loop.h 2016-01-12 07:30:28 +0000
19@@ -18,6 +18,8 @@
20 #ifndef EVENT_LOOP_H_
21 #define EVENT_LOOP_H_
22
23+#include <android/looper.h>
24+
25 #include <utils/Looper.h>
26 #include <utils/threads.h>
27
28
29=== modified file 'android/hybris/ubuntu_application_gps_for_hybris.cpp'
30--- android/hybris/ubuntu_application_gps_for_hybris.cpp 2014-05-13 10:00:55 +0000
31+++ android/hybris/ubuntu_application_gps_for_hybris.cpp 2016-01-12 07:30:28 +0000
32@@ -77,8 +77,25 @@
33
34 namespace
35 {
36+namespace bits
37+{
38+// is_set determines if bit is set in the bitset over
39+// a unique_integral
40+bool is_set(uint32_t bit, uint32_t* it, uint32_t* itE)
41+{
42+ static const uint32_t bits_per_element = sizeof(uint32_t) * 8;
43+
44+ uint32_t element_count = itE - it;
45+ uint32_t idx = bit / (element_count * bits_per_element);
46+
47+ if (idx >= element_count)
48+ return false;
49+
50+ return *(it + idx) & (1 << (bit % bits_per_element));
51+}
52+}
53+
54 UHardwareGps hybris_gps_instance = NULL;
55-}
56
57 static void location_callback(GpsLocation* location)
58 {
59@@ -142,7 +159,6 @@
60 hybris_gps_instance->request_utc_time_cb(hybris_gps_instance->context);
61 }
62
63-
64 typedef struct
65 {
66 void (*func)(void *);
67@@ -251,7 +267,7 @@
68 agps_request_ref_location,
69 create_thread_callback,
70 };
71-
72+}
73
74 UHardwareGps_::UHardwareGps_(UHardwareGpsParams* params)
75 : gps_interface(NULL),
76@@ -518,3 +534,38 @@
77 {
78 self->inject_xtra_data(data, length);
79 }
80+
81+void u_hardware_gps_sv_status_enumerate_svs(UHardwareGpsSvStatus* status, UHardwareGpsSvEnumerator enumerator, void* cookie)
82+{
83+ GpsSvStatus* s = reinterpret_cast<GpsSvStatus*>(status);
84+
85+#if defined(BOARD_HAS_SUPPORT_FOR_ADDITIONAL_SATELLITE_NETWORKS)
86+ const unsigned int element_count = 8;
87+#else
88+ const unsigned int element_count = 1;
89+#endif
90+
91+ for (int i = 0; i < s->num_svs; i++)
92+ {
93+ UHardwareGpsSvInfo info; ::memset(&info, 0, sizeof(info));
94+ info.prn = s->sv_list[i].prn;
95+ info.snr = s->sv_list[i].snr;
96+ info.elevation = s->sv_list[i].elevation;
97+ info.azimuth = s->sv_list[i].azimuth;
98+
99+ // PRN is in the range of [1, 32], adjusting it to make sure we
100+ // can use it for bitfield flag testing operations.
101+ int prn = s->sv_list[i].prn - 1;
102+ if (prn < 0)
103+ continue;
104+
105+ if (bits::is_set(prn, &s->almanac_mask, &s->almanac_mask + element_count))
106+ info.flags |= U_HARDWARE_GPS_SV_INFO_FLAG_HAS_ALMANAC;
107+ if (bits::is_set(prn, &s->ephemeris_mask, &s->ephemeris_mask + element_count))
108+ info.flags |= U_HARDWARE_GPS_SV_INFO_FLAG_HAS_EPHEMERIS;
109+ if (bits::is_set(prn, &s->used_in_fix_mask, &s->used_in_fix_mask + element_count))
110+ info.flags |= U_HARDWARE_GPS_SV_INFO_FLAG_USED_IN_FIX;
111+
112+ enumerator(&info, cookie);
113+ }
114+}
115
116=== modified file 'include/ubuntu/hardware/gps.h'
117--- include/ubuntu/hardware/gps.h 2014-05-14 16:55:19 +0000
118+++ include/ubuntu/hardware/gps.h 2016-01-12 07:30:28 +0000
119@@ -180,6 +180,19 @@
120 U_HARDWARE_GPS_AGPS_DATA_CONN_FAILED = 5
121 };
122
123+typedef enum
124+{
125+ /** The respective space vehicle has almanac data available. */
126+ U_HARDWARE_GPS_SV_INFO_FLAG_HAS_ALMANAC = 1 << 0,
127+ /** The respective space vehicle has ephemeris data available. */
128+ U_HARDWARE_GPS_SV_INFO_FLAG_HAS_EPHEMERIS = 1 << 1,
129+ /** The respective satellite is used in calculating the current position estimate. */
130+ U_HARDWARE_GPS_SV_INFO_FLAG_USED_IN_FIX = 1 << 2
131+} UbuntuHardwareGpsSvInfoFlags;
132+
133+/** Bundles together flags describing a visible space vehicle. */
134+typedef UbuntuHardwareGpsSvInfoFlags UHardwareGpsSvInfoFlags;
135+
136 /** Flags used to specify which aiding data to delete
137 when calling delete_aiding_data(). */
138 typedef uint16_t UHardwareGpsAidingData;
139@@ -255,12 +268,12 @@
140 * \ingroup gps_access
141 */
142 typedef struct {
143- /** set to sizeof(UHardwareGpsSvInfo) */
144- size_t size;
145 /** Pseudo-random number for the SV. */
146 int prn;
147 /** Signal to noise ratio. */
148 float snr;
149+ /** Describes ephimeris/almanac/used in fix, contains U_HARDWARE_GPS_SV_INFO_* */
150+ uint32_t flags;
151 /** Elevation of SV in degrees. */
152 float elevation;
153 /** Azimuth of SV in degrees. */
154@@ -271,32 +284,19 @@
155 * Represents SV (Space Vehicle) status.
156 * \ingroup gps_access
157 */
158-typedef struct {
159- /** set to sizeof(GpsSvStatus) */
160- size_t size;
161-
162- /** Number of SVs currently visible. */
163- int num_svs;
164-
165- /** Contains an array of SV information. */
166- UHardwareGpsSvInfo sv_list[U_HARDWARE_GPS_MAX_SVS];
167-
168- /** Represents a bit mask indicating which SVs
169- * have ephemeris data.
170- */
171- uint32_t ephemeris_mask;
172-
173- /** Represents a bit mask indicating which SVs
174- * have almanac data.
175- */
176- uint32_t almanac_mask;
177-
178- /**
179- * Represents a bit mask indicating which SVs
180- * were used for computing the most recent position fix.
181- */
182- uint32_t used_in_fix_mask;
183-} UHardwareGpsSvStatus;
184+typedef struct UbuntuHardwareGpsSvStatus UHardwareGpsSvStatus;
185+
186+/**
187+ * Invoked for every satellite that is part of a space vehicle visibility update.
188+ * \ingroup gps_access
189+ */
190+typedef void(*UHardwareGpsSvEnumerator)(UHardwareGpsSvInfo*, void*);
191+
192+/**
193+ * @brief u_hardware_gps_sv_status_enumerate_svs invokes enumerator for all space vehicles in status.
194+ * \ingroup gps_access
195+ */
196+UBUNTU_DLL_PUBLIC void u_hardware_gps_sv_status_enumerate_svs(UHardwareGpsSvStatus*, UHardwareGpsSvEnumerator enumerator, void*);
197
198 /**
199 * Represents the status of AGPS.
200
201=== modified file 'src/ubuntu/hardware/tests/test_gps_api.cpp'
202--- src/ubuntu/hardware/tests/test_gps_api.cpp 2014-06-11 12:19:37 +0000
203+++ src/ubuntu/hardware/tests/test_gps_api.cpp 2016-01-12 07:30:28 +0000
204@@ -67,9 +67,13 @@
205 };
206 }
207
208-void gps_sb_status_cb(UHardwareGpsSvStatus* sv_info, void* context)
209+void gps_sb_status_cb(UHardwareGpsSvStatus* status, void* context)
210 {
211- printf("gps_sb_status_cb() called, listing %d space vehicles\n", sv_info->num_svs);
212+ printf("gps_status_cb() called:\n");
213+ u_hardware_gps_sv_status_enumerate_svs(status, [](UHardwareGpsSvInfo* info, void*)
214+ {
215+ printf(" [%d] snr=%f elevation=%f azimuth=%f flags=%x \n", info->prn, info->snr, info->elevation, info->azimuth, info->flags);
216+ }, nullptr);
217 }
218
219 void gps_nmea_cb(int64_t timestamp, const char* nmea, int length, void* context)
220
221=== modified file 'src/ubuntu/hardware/ubuntu_platform_hardware_api.cpp'
222--- src/ubuntu/hardware/ubuntu_platform_hardware_api.cpp 2014-05-23 07:55:33 +0000
223+++ src/ubuntu/hardware/ubuntu_platform_hardware_api.cpp 2016-01-12 07:30:28 +0000
224@@ -101,3 +101,9 @@
225 UHardwareGps,
226 char*,
227 int);
228+
229+IMPLEMENT_VOID_FUNCTION3(
230+u_hardware_gps_sv_status_enumerate_svs,
231+UHardwareGpsSvStatus*,
232+UHardwareGpsSvEnumerator,
233+void*);

Subscribers

People subscribed via source and target branches