1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef _CHRE_GNSS_H_
18 #define _CHRE_GNSS_H_
19 
20 /**
21  * @file
22  * Global Navigation Satellite System (GNSS) API.
23  *
24  * These structures and definitions are based on the Android N GPS HAL.
25  * Refer to that header file (located at this path as of the time of this
26  * comment: hardware/libhardware/include/hardware/gps.h) and associated
27  * documentation for further details and explanations for these fields.
28  * References in comments like "(ref: GnssAccumulatedDeltaRangeState)" map to
29  * the relevant element in the GPS HAL where additional information can be
30  * found.
31  *
32  * In general, the parts of this API that are taken from the GPS HAL follow the
33  * naming conventions established in that interface rather than the CHRE API
34  * conventions, in order to avoid confusion and enable code re-use where
35  * applicable.
36  */
37 
38 
39 #include <stdbool.h>
40 #include <stdint.h>
41 
42 #include <chre/common.h>
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 /**
49  * The set of flags that may be returned by chreGnssGetCapabilities()
50  * @defgroup CHRE_GNSS_CAPABILITIES
51  * @{
52  */
53 
54 //! A lack of flags indicates that GNSS is not supported in this CHRE
55 #define CHRE_GNSS_CAPABILITIES_NONE          UINT32_C(0)
56 
57 //! GNSS position fixes are supported via chreGnssLocationSessionStartAsync()
58 #define CHRE_GNSS_CAPABILITIES_LOCATION      UINT32_C(1 << 0)
59 
60 //! GNSS raw measurements are supported via
61 //! chreGnssMeasurementSessionStartAsync()
62 #define CHRE_GNSS_CAPABILITIES_MEASUREMENTS  UINT32_C(1 << 1)
63 
64 //! Location fixes supplied from chreGnssConfigurePassiveLocationListener()
65 //! are tapped in at the GNSS engine level, so they include additional fixes
66 //! such as those requested by the AP, and not just those requested by other
67 //! nanoapps within CHRE (which is the case when this flag is not set)
68 #define CHRE_GNSS_CAPABILITIES_GNSS_ENGINE_BASED_PASSIVE_LISTENER \
69                                              UINT32_C(1 << 2)
70 
71 /** @} */
72 
73 /**
74  * The current version of struct chreGnssDataEvent associated with this API
75  */
76 #define CHRE_GNSS_DATA_EVENT_VERSION  UINT8_C(0)
77 
78 /**
79  * The maximum time the CHRE implementation is allowed to elapse before sending
80  * an event with the result of an asynchronous request, unless specified
81  * otherwise
82  */
83 #define CHRE_GNSS_ASYNC_RESULT_TIMEOUT_NS  (5 * CHRE_NSEC_PER_SEC)
84 
85 /**
86  * Produce an event ID in the block of IDs reserved for GNSS
87  * @param offset  Index into GNSS event ID block; valid range [0,15]
88  */
89 #define CHRE_GNSS_EVENT_ID(offset)  (CHRE_EVENT_GNSS_FIRST_EVENT + (offset))
90 
91 /**
92  * nanoappHandleEvent argument: struct chreAsyncResult
93  *
94  * Communicates the asynchronous result of a request to the GNSS API, such as
95  * starting a location session via chreGnssLocationSessionStartAsync(). The
96  * requestType field in chreAsyncResult is set to a value from enum
97  * chreGnssRequestType.
98  */
99 #define CHRE_EVENT_GNSS_ASYNC_RESULT  CHRE_GNSS_EVENT_ID(0)
100 
101 /**
102  * nanoappHandleEvent argument: struct chreGnssLocationEvent
103  *
104  * Represents a location fix provided by the GNSS subsystem.
105  */
106 #define CHRE_EVENT_GNSS_LOCATION      CHRE_GNSS_EVENT_ID(1)
107 
108 /**
109  * nanoappHandleEvent argument: struct chreGnssDataEvent
110  *
111  * Represents a set of GNSS measurements with associated clock data.
112  */
113 #define CHRE_EVENT_GNSS_DATA          CHRE_GNSS_EVENT_ID(2)
114 
115 // NOTE: Do not add new events with ID > 15; only values 0-15 are reserved
116 // (see chre/event.h)
117 
118 // Flags indicating the Accumulated Delta Range's states
119 // (ref: GnssAccumulatedDeltaRangeState)
120 #define CHRE_GNSS_ADR_STATE_UNKNOWN     UINT16_C(0)
121 #define CHRE_GNSS_ADR_STATE_VALID       UINT16_C(1 << 0)
122 #define CHRE_GNSS_ADR_STATE_RESET       UINT16_C(1 << 1)
123 #define CHRE_GNSS_ADR_STATE_CYCLE_SLIP  UINT16_C(1 << 2)
124 
125 // Flags to indicate what fields in chreGnssClock are valid (ref: GnssClockFlags)
126 #define CHRE_GNSS_CLOCK_HAS_LEAP_SECOND        UINT16_C(1 << 0)
127 #define CHRE_GNSS_CLOCK_HAS_TIME_UNCERTAINTY   UINT16_C(1 << 1)
128 #define CHRE_GNSS_CLOCK_HAS_FULL_BIAS          UINT16_C(1 << 2)
129 #define CHRE_GNSS_CLOCK_HAS_BIAS               UINT16_C(1 << 3)
130 #define CHRE_GNSS_CLOCK_HAS_BIAS_UNCERTAINTY   UINT16_C(1 << 4)
131 #define CHRE_GNSS_CLOCK_HAS_DRIFT              UINT16_C(1 << 5)
132 #define CHRE_GNSS_CLOCK_HAS_DRIFT_UNCERTAINTY  UINT16_C(1 << 6)
133 
134 // Flags to indicate which values are valid in a GpsLocation
135 // (ref: GpsLocationFlags)
136 #define CHRE_GPS_LOCATION_HAS_LAT_LONG           UINT16_C(1 << 0)
137 #define CHRE_GPS_LOCATION_HAS_ALTITUDE           UINT16_C(1 << 1)
138 #define CHRE_GPS_LOCATION_HAS_SPEED              UINT16_C(1 << 2)
139 #define CHRE_GPS_LOCATION_HAS_BEARING            UINT16_C(1 << 3)
140 #define CHRE_GPS_LOCATION_HAS_ACCURACY           UINT16_C(1 << 4)
141 
142 //! @since v1.3
143 #define CHRE_GPS_LOCATION_HAS_ALTITUDE_ACCURACY  UINT16_C(1 << 5)
144 //! @since v1.3
145 #define CHRE_GPS_LOCATION_HAS_SPEED_ACCURACY     UINT16_C(1 << 6)
146 //! @since v1.3
147 #define CHRE_GPS_LOCATION_HAS_BEARING_ACCURACY   UINT16_C(1 << 7)
148 
149 /**
150  * The maximum number of instances of struct chreGnssMeasurement that may be
151  * included in a single struct chreGnssDataEvent.
152  *
153  * The value of this struct was increased from 64 to 128 in CHRE v1.5. For
154  * nanoapps targeting CHRE v1.4 or lower, the measurement_count will be capped
155  * at 64.
156  */
157 #define CHRE_GNSS_MAX_MEASUREMENT  UINT8_C(128)
158 #define CHRE_GNSS_MAX_MEASUREMENT_PRE_1_5  UINT8_C(64)
159 
160 // Flags indicating the GNSS measurement state (ref: GnssMeasurementState)
161 #define CHRE_GNSS_MEASUREMENT_STATE_UNKNOWN                UINT16_C(0)
162 #define CHRE_GNSS_MEASUREMENT_STATE_CODE_LOCK              UINT16_C(1 << 0)
163 #define CHRE_GNSS_MEASUREMENT_STATE_BIT_SYNC               UINT16_C(1 << 1)
164 #define CHRE_GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC          UINT16_C(1 << 2)
165 #define CHRE_GNSS_MEASUREMENT_STATE_TOW_DECODED            UINT16_C(1 << 3)
166 #define CHRE_GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS         UINT16_C(1 << 4)
167 #define CHRE_GNSS_MEASUREMENT_STATE_SYMBOL_SYNC            UINT16_C(1 << 5)
168 #define CHRE_GNSS_MEASUREMENT_STATE_GLO_STRING_SYNC        UINT16_C(1 << 6)
169 #define CHRE_GNSS_MEASUREMENT_STATE_GLO_TOD_DECODED        UINT16_C(1 << 7)
170 #define CHRE_GNSS_MEASUREMENT_STATE_BDS_D2_BIT_SYNC        UINT16_C(1 << 8)
171 #define CHRE_GNSS_MEASUREMENT_STATE_BDS_D2_SUBFRAME_SYNC   UINT16_C(1 << 9)
172 #define CHRE_GNSS_MEASUREMENT_STATE_GAL_E1BC_CODE_LOCK     UINT16_C(1 << 10)
173 #define CHRE_GNSS_MEASUREMENT_STATE_GAL_E1C_2ND_CODE_LOCK  UINT16_C(1 << 11)
174 #define CHRE_GNSS_MEASUREMENT_STATE_GAL_E1B_PAGE_SYNC      UINT16_C(1 << 12)
175 #define CHRE_GNSS_MEASUREMENT_STATE_SBAS_SYNC              UINT16_C(1 << 13)
176 
177 #define CHRE_GNSS_MEASUREMENT_CARRIER_FREQUENCY_UNKNOWN    0.f
178 
179 /**
180  * Indicates a type of request made in this API. Used to populate the resultType
181  * field of struct chreAsyncResult sent with CHRE_EVENT_GNSS_ASYNC_RESULT.
182  */
183 enum chreGnssRequestType {
184     CHRE_GNSS_REQUEST_TYPE_LOCATION_SESSION_START    = 1,
185     CHRE_GNSS_REQUEST_TYPE_LOCATION_SESSION_STOP     = 2,
186     CHRE_GNSS_REQUEST_TYPE_MEASUREMENT_SESSION_START = 3,
187     CHRE_GNSS_REQUEST_TYPE_MEASUREMENT_SESSION_STOP  = 4,
188 };
189 
190 /**
191  * Constellation type associated with an SV
192  */
193 enum chreGnssConstellationType {
194     CHRE_GNSS_CONSTELLATION_UNKNOWN = 0,
195     CHRE_GNSS_CONSTELLATION_GPS     = 1,
196     CHRE_GNSS_CONSTELLATION_SBAS    = 2,
197     CHRE_GNSS_CONSTELLATION_GLONASS = 3,
198     CHRE_GNSS_CONSTELLATION_QZSS    = 4,
199     CHRE_GNSS_CONSTELLATION_BEIDOU  = 5,
200     CHRE_GNSS_CONSTELLATION_GALILEO = 6,
201 };
202 
203 /**
204  * Enumeration of available values for the chreGnssMeasurement multipath indicator
205  */
206 enum chreGnssMultipathIndicator {
207     //! The indicator is not available or unknown
208     CHRE_GNSS_MULTIPATH_INDICATOR_UNKNOWN     = 0,
209     //! The measurement is indicated to be affected by multipath
210     CHRE_GNSS_MULTIPATH_INDICATOR_PRESENT     = 1,
211     //! The measurement is indicated to be not affected by multipath
212     CHRE_GNSS_MULTIPATH_INDICATOR_NOT_PRESENT = 2,
213 };
214 
215 /**
216  * Represents an estimate of the GNSS clock time (see the Android GPS HAL for
217  * more detailed information)
218  */
219 struct chreGnssClock {
220     //! The GNSS receiver hardware clock value in nanoseconds, including
221     //! uncertainty
222     int64_t time_ns;
223 
224     //! The difference between hardware clock inside GNSS receiver and the
225     //! estimated GNSS time in nanoseconds; contains bias uncertainty
226     int64_t full_bias_ns;
227 
228     //! Sub-nanosecond bias, adds to full_bias_ns
229     float bias_ns;
230 
231     //! The clock's drift in nanoseconds per second
232     float drift_nsps;
233 
234     //! 1-sigma uncertainty associated with the clock's bias in nanoseconds
235     float bias_uncertainty_ns;
236 
237     //! 1-sigma uncertainty associated with the clock's drift in nanoseconds
238     //! per second
239     float drift_uncertainty_nsps;
240 
241     //! While this number stays the same, timeNs should flow continuously
242     uint32_t hw_clock_discontinuity_count;
243 
244     //! A set of flags indicating the validity of the fields in this data
245     //! structure (see GNSS_CLOCK_HAS_*)
246     uint16_t flags;
247 
248     //! Reserved for future use; set to 0
249     uint8_t reserved[2];
250 };
251 
252 /**
253  * Represents a GNSS measurement; contains raw and computed information (see the
254  * Android GPS HAL for more detailed information)
255  */
256 struct chreGnssMeasurement {
257     //! Hardware time offset from time_ns for this measurement, in nanoseconds
258     int64_t time_offset_ns;
259 
260     //! Accumulated delta range since the last channel reset in micro-meters
261     int64_t accumulated_delta_range_um;
262 
263     //! Received GNSS satellite time at the time of measurement, in nanoseconds
264     int64_t received_sv_time_in_ns;
265 
266     //! 1-sigma uncertainty of received GNSS satellite time, in nanoseconds
267     int64_t received_sv_time_uncertainty_in_ns;
268 
269     //! Pseudorange rate at the timestamp in meters per second (uncorrected)
270     float pseudorange_rate_mps;
271 
272     //! 1-sigma uncertainty of pseudorange rate in meters per second
273     float pseudorange_rate_uncertainty_mps;
274 
275     //! 1-sigma uncertainty of the accumulated delta range in meters
276     float accumulated_delta_range_uncertainty_m;
277 
278     //! Carrier-to-noise density in dB-Hz, in the range of [0, 63]
279     float c_n0_dbhz;
280 
281     //! Signal to noise ratio (dB), power above observed noise at correlators
282     float snr_db;
283 
284     //! Satellite sync state flags (GNSS_MEASUREMENT_STATE_*) - sets modulus for
285     //! received_sv_time_in_ns
286     uint16_t state;
287 
288     //! Set of ADR state flags (GNSS_ADR_STATE_*)
289     uint16_t accumulated_delta_range_state;
290 
291     //! Satellite vehicle ID number
292     int16_t svid;
293 
294     //! Constellation of the given satellite vehicle
295     //! @see #chreGnssConstellationType
296     uint8_t constellation;
297 
298     //! @see #chreGnssMultipathIndicator
299     uint8_t multipath_indicator;
300 
301     //! Carrier frequency of the signal tracked in Hz.
302     //! For example, it can be the GPS central frequency for L1 = 1575.45 MHz,
303     //! or L2 = 1227.60 MHz, L5 = 1176.45 MHz, various GLO channels, etc.
304     //!
305     //! Set to CHRE_GNSS_MEASUREMENT_CARRIER_FREQUENCY_UNKNOWN if not reported.
306     //!
307     //! For an L1, L5 receiver tracking a satellite on L1 and L5 at the same
308     //! time, two chreGnssMeasurement structs must be reported for this same
309     //! satellite, in one of the measurement structs, all the values related to
310     //! L1 must be filled, and in the other all of the values related to L5
311     //! must be filled.
312     //! @since v1.4
313     float carrier_frequency_hz;
314 };
315 
316 /**
317  * Data structure sent with events associated with CHRE_EVENT_GNSS_DATA, enabled
318  * via chreGnssMeasurementSessionStartAsync()
319  */
320 struct chreGnssDataEvent {
321     //! Indicates the version of the structure, for compatibility purposes.
322     //! Clients do not normally need to worry about this field; the CHRE
323     //! implementation guarantees that it only sends the client the structure
324     //! version it expects.
325     uint8_t version;
326 
327     //! Number of chreGnssMeasurement entries included in this event. Must be in
328     //! the range [0, CHRE_GNSS_MAX_MEASUREMENT]
329     uint8_t measurement_count;
330 
331     //! Reserved for future use; set to 0
332     uint8_t reserved[6];
333 
334     struct chreGnssClock clock;
335 
336     //! Pointer to an array containing measurement_count measurements
337     const struct chreGnssMeasurement *measurements;
338 };
339 
340 /**
341  * Data structure sent with events of type CHRE_EVENT_GNSS_LOCATION, enabled via
342  * chreGnssLocationSessionStartAsync(). This is modeled after GpsLocation in the
343  * GPS HAL, but does not use the double data type.
344  */
345 struct chreGnssLocationEvent {
346     //! UTC timestamp for location fix in milliseconds since January 1, 1970
347     uint64_t timestamp;
348 
349     //! Fixed point latitude, degrees times 10^7 (roughly centimeter resolution)
350     int32_t latitude_deg_e7;
351 
352     //! Fixed point longitude, degrees times 10^7 (roughly centimeter
353     //! resolution)
354     int32_t longitude_deg_e7;
355 
356     //! Altitude in meters above the WGS 84 reference ellipsoid
357     float altitude;
358 
359     //! Horizontal speed in meters per second
360     float speed;
361 
362     //! Clockwise angle between north and current heading, in degrees; range
363     //! [0, 360)
364     float bearing;
365 
366     //! Expected horizontal accuracy in meters such that a circle with a radius
367     //! of length 'accuracy' from the latitude and longitude has a 68%
368     //! probability of including the true location.
369     float accuracy;
370 
371     //! A set of flags indicating which fields in this structure are valid.
372     //! If any fields are not available, the flag must not be set and the field
373     //! must be initialized to 0.
374     //! @see #GpsLocationFlags
375     uint16_t flags;
376 
377     //! Reserved for future use; set to 0
378     //! @since v1.3
379     uint8_t reserved[2];
380 
381     //! Expected vertical accuracy in meters such that a range of
382     //! 2 * altitude_accuracy centered around altitude has a 68% probability of
383     //! including the true altitude.
384     //! @since v1.3
385     float altitude_accuracy;
386 
387     //! Expected speed accuracy in meters per second such that a range of
388     //! 2 * speed_accuracy centered around speed has a 68% probability of
389     //! including the true speed.
390     //! @since v1.3
391     float speed_accuracy;
392 
393     //! Expected bearing accuracy in degrees such that a range of
394     //! 2 * bearing_accuracy centered around bearing has a 68% probability of
395     //! including the true bearing.
396     //! @since v1.3
397     float bearing_accuracy;
398 };
399 
400 
401 /**
402  * Retrieves a set of flags indicating the GNSS features supported by the
403  * current CHRE implementation. The value returned by this function must be
404  * consistent for the entire duration of the Nanoapp's execution.
405  *
406  * The client must allow for more flags to be set in this response than it knows
407  * about, for example if the implementation supports a newer version of the API
408  * than the client was compiled against.
409  *
410  * @return A bitmask with zero or more CHRE_GNSS_CAPABILITIES_* flags set
411  *
412  * @since v1.1
413  */
414 uint32_t chreGnssGetCapabilities(void);
415 
416 /**
417  * Nanoapps must define CHRE_NANOAPP_USES_GNSS somewhere in their build
418  * system (e.g. Makefile) if the nanoapp needs to use the following GNSS APIs.
419  * In addition to allowing access to these APIs, defining this macro will also
420  * ensure CHRE enforces that all host clients this nanoapp talks to have the
421  * required Android permissions needed to listen to GNSS data by adding metadata
422  * to the nanoapp.
423  */
424 #if defined(CHRE_NANOAPP_USES_GNSS) || !defined(CHRE_IS_NANOAPP_BUILD)
425 
426 /**
427  * Initiates a GNSS positioning session, or changes the requested interval of an
428  * existing session. If starting or modifying the session was successful, then
429  * the GNSS engine will work on determining the device's position.
430  *
431  * This result of this request is delivered asynchronously via an event of type
432  * CHRE_EVENT_GNSS_ASYNC_RESULT. Refer to the note in {@link #chreAsyncResult}
433  * for more details. If the "Location" setting is disabled at the Android level,
434  * the CHRE implementation is expected to return a result with
435  * CHRE_ERROR_FUNCTION_DISABLED.
436  *
437  * If chreGnssGetCapabilities() returns a value that does not have the
438  * CHRE_GNSS_CAPABILITIES_LOCATION flag set, then this method will return false.
439  *
440  * @param minIntervalMs The desired minimum interval between location fixes
441  *        delivered to the client via CHRE_EVENT_GNSS_LOCATION, in milliseconds.
442  *        The requesting client must allow for fixes to be delivered at shorter
443  *        or longer interval than requested. For example, adverse RF conditions
444  *        may result in fixes arriving at a longer interval, etc.
445  * @param minTimeToNextFixMs The desired minimum time to the next location fix.
446  *        If this is 0, the GNSS engine should start working on the next fix
447  *        immediately. If greater than 0, the GNSS engine should not spend
448  *        measurable power to produce a location fix until this amount of time
449  *        has elapsed.
450  * @param cookie An opaque value that will be included in the chreAsyncResult
451  *        sent in relation to this request.
452  *
453  * @return true if the request was accepted for processing, false otherwise
454  *
455  * @since v1.1
456  * @note Requires GNSS permission
457  */
458 bool chreGnssLocationSessionStartAsync(uint32_t minIntervalMs,
459                                        uint32_t minTimeToNextFixMs,
460                                        const void *cookie);
461 
462 /**
463  * Terminates an existing GNSS positioning session. If no positioning session
464  * is active at the time of this request, it is treated as if an active session
465  * was successfully ended.
466  *
467  * This result of this request is delivered asynchronously via an event of type
468  * CHRE_EVENT_GNSS_ASYNC_RESULT. Refer to the note in {@link #chreAsyncResult}
469  * for more details.
470  *
471  * After CHRE_EVENT_GNSS_ASYNC_RESULT is delivered to the client, no more
472  * CHRE_EVENT_GNSS_LOCATION events will be delievered until a new location
473  * session is started.
474  *
475  * If chreGnssGetCapabilities() returns a value that does not have the
476  * CHRE_GNSS_CAPABILITIES_LOCATION flag set, then this method will return false.
477  *
478  * @param cookie An opaque value that will be included in the chreAsyncResult
479  *        sent in relation to this request.
480  *
481  * @return true if the request was accepted for processing, false otherwise
482  *
483  * @since v1.1
484  * @note Requires GNSS permission
485  */
486 bool chreGnssLocationSessionStopAsync(const void *cookie);
487 
488 /**
489  * Initiates a request to receive raw GNSS measurements. A GNSS measurement
490  * session can exist independently of location sessions. In other words, a
491  * Nanoapp is able to receive measurements at its requested interval both with
492  * and without an active location session.
493  *
494  * This result of this request is delivered asynchronously via an event of type
495  * CHRE_EVENT_GNSS_ASYNC_RESULT. Refer to the note in {@link #chreAsyncResult}
496  * for more details. If the "Location" setting is disabled at the Android level,
497  * the CHRE implementation is expected to return a result with
498  * CHRE_ERROR_FUNCTION_DISABLED.
499  *
500  * If chreGnssGetCapabilities() returns a value that does not have the
501  * CHRE_GNSS_CAPABILITIES_MEASUREMENTS flag set, then this method will return
502  * false.
503  *
504  * @param minIntervalMs The desired minimum interval between measurement reports
505  *        delivered via CHRE_EVENT_GNSS_DATA. When requested at 1000ms or
506  *        faster, and GNSS measurements are tracked, device should report
507  *        measurements as fast as requested, and shall report no slower than
508  *        once every 1000ms, on average.
509  * @param cookie An opaque value that will be included in the chreAsyncResult
510  *        sent in relation to this request.
511  *
512  * @return true if the request was accepted for processing, false otherwise
513  *
514  * @since v1.1
515  * @note Requires GNSS permission
516  */
517 bool chreGnssMeasurementSessionStartAsync(uint32_t minIntervalMs,
518                                           const void *cookie);
519 
520 /**
521  * Terminates an existing raw GNSS measurement session. If no measurement
522  * session is active at the time of this request, it is treated as if an active
523  * session was successfully ended.
524  *
525  * This result of this request is delivered asynchronously via an event of type
526  * CHRE_EVENT_GNSS_ASYNC_RESULT. Refer to the note in {@link #chreAsyncResult}
527  * for more details.
528  *
529  * If chreGnssGetCapabilities() returns a value that does not have the
530  * CHRE_GNSS_CAPABILITIES_MEASUREMENTS flag set, then this method will return
531  * false.
532  *
533  * @param cookie An opaque value that will be included in the chreAsyncResult
534  *        sent in relation to this request.
535  *
536  * @return true if the request was accepted for processing, false otherwise
537  *
538  * @since v1.1
539  * @note Requires GNSS permission
540  */
541 bool chreGnssMeasurementSessionStopAsync(const void *cookie);
542 
543 /**
544  * Controls whether this nanoapp will passively receive GNSS-based location
545  * fixes produced as a result of location sessions initiated by other entities.
546  * This function allows a nanoapp to opportunistically receive location fixes
547  * via CHRE_EVENT_GNSS_LOCATION events without imposing additional power cost,
548  * though with no guarantees as to when or how often those events will arrive.
549  * There will be no duplication of events if a passive location listener and
550  * location session are enabled in parallel.
551  *
552  * Enabling passive location listening is not required to receive events for an
553  * active location session started via chreGnssLocationSessionStartAsync(). This
554  * setting is independent of the active location session, so modifying one does
555  * not have an effect on the other.
556  *
557  * If chreGnssGetCapabilities() returns a value that does not have the
558  * CHRE_GNSS_CAPABILITIES_LOCATION flag set or the value returned by
559  * chreGetApiVersion() is less than CHRE_API_VERSION_1_2, then this method will
560  * return false.
561  *
562  * If chreGnssGetCapabilities() includes
563  * CHRE_GNSS_CAPABILITIES_GNSS_ENGINE_BASED_PASSIVE_LISTENER, the passive
564  * registration is recorded at the GNSS engine level, so events include fixes
565  * requested by the applications processor and potentially other non-CHRE
566  * clients. If this flag is not set, then only fixes requested by other nanoapps
567  * within CHRE are provided.
568  *
569  * @param enable true to receive opportunistic location fixes, false to disable
570  *
571  * @return true if the configuration was processed successfully, false on error
572  *     or if this feature is not supported
573  *
574  * @since v1.2
575  * @note Requires GNSS permission
576  */
577 bool chreGnssConfigurePassiveLocationListener(bool enable);
578 
579 #else  /* defined(CHRE_NANOAPP_USES_GNSS) || !defined(CHRE_IS_NANOAPP_BUILD) */
580 #define CHRE_GNSS_PERM_ERROR_STRING \
581     "CHRE_NANOAPP_USES_GNSS must be defined when building this nanoapp in " \
582     "order to refer to "
583 #define chreGnssLocationSessionStartAsync(...) \
584     CHRE_BUILD_ERROR(CHRE_GNSS_PERM_ERROR_STRING \
585                      "chreGnssLocationSessionStartAsync")
586 #define chreGnssLocationSessionStopAsync(...) \
587     CHRE_BUILD_ERROR(CHRE_GNSS_PERM_ERROR_STRING \
588                      "chreGnssLocationSessionStopAsync")
589 #define chreGnssMeasurementSessionStartAsync(...) \
590     CHRE_BUILD_ERROR(CHRE_GNSS_PERM_ERROR_STRING \
591                      "chreGnssMeasurementSessionStartAsync")
592 #define chreGnssMeasurementSessionStopAsync(...) \
593     CHRE_BUILD_ERROR(CHRE_GNSS_PERM_ERROR_STRING \
594                      "chreGnssMeasurementSessionStopAsync")
595 #define chreGnssConfigurePassiveLocationListener(...) \
596     CHRE_BUILD_ERROR(CHRE_GNSS_PERM_ERROR_STRING \
597                      "chreGnssConfigurePassiveLocationListener")
598 #endif  /* defined(CHRE_NANOAPP_USES_GNSS) || !defined(CHRE_IS_NANOAPP_BUILD) */
599 
600 #ifdef __cplusplus
601 }
602 #endif
603 
604 #endif  /* _CHRE_GNSS_H_ */
605