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 // IWYU pragma: private, include "chre_api/chre.h"
18 // IWYU pragma: friend chre/.*\.h
19 
20 #ifndef _CHRE_WWAN_H_
21 #define _CHRE_WWAN_H_
22 
23 /**
24  * @file
25  * Wireless Wide Area Network (WWAN, i.e. mobile/cellular network) API relevant
26  * for querying cell tower identity and associated information that can be
27  * useful in determining location.
28  *
29  * Based on Android N RIL definitions (located at this path as of the time of
30  * this comment: hardware/ril/include/telephony/ril.h), version 12. Updated
31  * based on Android radio HAL definition (hardware/interfaces/radio) for more
32  * recent Android builds. Refer to those files and associated documentation for
33  * further details.
34  *
35  * In general, the parts of this API that are taken from the RIL follow the
36  * field naming conventions established in that interface rather than the CHRE
37  * API conventions, in order to avoid confusion and enable code re-use where
38  * applicable. Note that structure names include the chreWwan* prefix rather
39  * than RIL_*, but field names are the same. If necessary to enable code
40  * sharing, it is recommended to create typedefs that map from the CHRE
41  * structures to the associated RIL type names, for example "typedef struct
42  * chreWwanCellIdentityGsm RIL_CellIdentityGsm_v12", etc.
43  */
44 
45 #include <chre/common.h>
46 
47 #include <stdbool.h>
48 #include <stdint.h>
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 /**
55  * The set of flags returned by chreWwanGetCapabilities().
56  * @defgroup CHRE_WWAN_CAPABILITIES
57  * @{
58  */
59 
60 //! No WWAN APIs are supported
61 #define CHRE_WWAN_CAPABILITIES_NONE  UINT32_C(0)
62 
63 //! Current cell information can be queried via chreWwanGetCellInfoAsync()
64 #define CHRE_WWAN_GET_CELL_INFO      UINT32_C(1 << 0)
65 
66 /** @} */
67 
68 /**
69  * Produce an event ID in the block of IDs reserved for WWAN
70  * @param offset  Index into WWAN event ID block; valid range [0,15]
71  */
72 #define CHRE_WWAN_EVENT_ID(offset)  (CHRE_EVENT_WWAN_FIRST_EVENT + (offset))
73 
74 /**
75  * nanoappHandleEvent argument: struct chreWwanCellInfoResult
76  *
77  * Provides the result of an asynchronous request for cell info sent via
78  * chreWwanGetCellInfoAsync().
79  */
80 #define CHRE_EVENT_WWAN_CELL_INFO_RESULT  CHRE_WWAN_EVENT_ID(0)
81 
82 // NOTE: Do not add new events with ID > 15; only values 0-15 are reserved
83 // (see chre/event.h)
84 
85 /**
86  * The current version of struct chreWwanCellInfoResult associated with this
87  * API definition.
88  */
89 #define CHRE_WWAN_CELL_INFO_RESULT_VERSION  UINT8_C(1)
90 
91 //! Reference: RIL_CellIdentityGsm_v12
92 struct chreWwanCellIdentityGsm {
93     //! 3-digit Mobile Country Code, 0..999, INT32_MAX if unknown
94     int32_t mcc;
95 
96     //! 2 or 3-digit Mobile Network Code, 0..999, INT32_MAX if unknown
97     int32_t mnc;
98 
99     //! 16-bit Location Area Code, 0..65535, INT32_MAX if unknown
100     int32_t lac;
101 
102     //! 16-bit GSM Cell Identity described in TS 27.007, 0..65535,
103     //! INT32_MAX if unknown
104     int32_t cid;
105 
106     //! 16-bit GSM Absolute RF channel number, INT32_MAX if unknown
107     int32_t arfcn;
108 
109     //! 6-bit Base Station Identity Code, UINT8_MAX if unknown
110     uint8_t bsic;
111 
112     //! Reserved for future use; must be set to 0
113     uint8_t reserved[3];
114 };
115 
116 //! Reference: RIL_CellIdentityWcdma_v12
117 struct chreWwanCellIdentityWcdma {
118     //! 3-digit Mobile Country Code, 0..999, INT32_MAX if unknown
119     int32_t mcc;
120 
121     //! 2 or 3-digit Mobile Network Code, 0..999, INT32_MAX if unknown
122     int32_t mnc;
123 
124     //! 16-bit Location Area Code, 0..65535, INT32_MAX if unknown
125     int32_t lac;
126 
127     //! 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455,
128     //! INT32_MAX if unknown
129     int32_t cid;
130 
131     //! 9-bit UMTS Primary Scrambling Code described in TS 25.331, 0..511,
132     //! INT32_MAX if unknown
133     int32_t psc;
134 
135     //! 16-bit UMTS Absolute RF Channel Number, INT32_MAX if unknown
136     int32_t uarfcn;
137 };
138 
139 //! Reference: RIL_CellIdentityCdma
140 struct chreWwanCellIdentityCdma {
141     //! Network Id 0..65535, INT32_MAX if unknown
142     int32_t networkId;
143 
144     //! CDMA System Id 0..32767, INT32_MAX if unknown
145     int32_t systemId;
146 
147     //! Base Station Id 0..65535, INT32_MAX if unknown
148     int32_t basestationId;
149 
150     //! Longitude is a decimal number as specified in 3GPP2 C.S0005-A v6.0.
151     //! It is represented in units of 0.25 seconds and ranges from -2592000
152     //! to 2592000, both values inclusive (corresponding to a range of -180
153     //! to +180 degrees). INT32_MAX if unknown
154     int32_t longitude;
155 
156     //! Latitude is a decimal number as specified in 3GPP2 C.S0005-A v6.0.
157     //! It is represented in units of 0.25 seconds and ranges from -1296000
158     //! to 1296000, both values inclusive (corresponding to a range of -90
159     //! to +90 degrees). INT32_MAX if unknown
160     int32_t latitude;
161 };
162 
163 //! Reference: RIL_CellIdentityLte_v12
164 struct chreWwanCellIdentityLte {
165     //! 3-digit Mobile Country Code, 0..999, INT32_MAX if unknown
166     int32_t mcc;
167 
168     //! 2 or 3-digit Mobile Network Code, 0..999, INT32_MAX if unknown
169     int32_t mnc;
170 
171     //! 28-bit Cell Identity described in TS ???, INT32_MAX if unknown
172     int32_t ci;
173 
174     //! physical cell id 0..503, INT32_MAX if unknown
175     int32_t pci;
176 
177     //! 16-bit tracking area code, INT32_MAX if unknown
178     int32_t tac;
179 
180     //! 18-bit LTE Absolute RF Channel Number, INT32_MAX if unknown
181     int32_t earfcn;
182 };
183 
184 //! Reference: RIL_CellIdentityTdscdma
185 struct chreWwanCellIdentityTdscdma {
186     //! 3-digit Mobile Country Code, 0..999, INT32_MAX if unknown
187     int32_t mcc;
188 
189     //! 2 or 3-digit Mobile Network Code, 0..999, INT32_MAX if unknown
190     int32_t mnc;
191 
192     //! 16-bit Location Area Code, 0..65535, INT32_MAX if unknown
193     int32_t lac;
194 
195     //! 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455,
196     //! INT32_MAX if unknown
197     int32_t cid;
198 
199     //! 8-bit Cell Parameters ID described in TS 25.331, 0..127, INT32_MAX if
200     //! unknown
201     int32_t cpid;
202 };
203 
204 //! Reference: android.hardware.radio@1.4 CellIdentityNr
205 //! @since v1.4
206 struct chreWwanCellIdentityNr {
207     //! 3-digit Mobile Country Code, in range [0, 999]. This value must be valid
208     //! for registered or camped cells. INT32_MAX means invalid/unreported.
209     int32_t mcc;
210 
211     //! 2 or 3-digit Mobile Network Code, in range [0, 999]. This value must be
212     //! valid for registered or camped cells. INT32_MAX means
213     //! invalid/unreported.
214     int32_t mnc;
215 
216     //! NR Cell Identity in range [0, 68719476735] (36 bits), which
217     //! unambiguously identifies a cell within a public land mobile network
218     //! (PLMN). This value must be valid for registered or camped cells.
219     //! Reference: TS 38.413 section 9.3.1.7.
220     //!
221     //! Note: for backward compatibility reasons, the nominally int64_t nci is
222     //! split into two uint32_t values, with nci0 being the least significant 4
223     //! bytes. If chreWwanUnpackNrNci returns INT64_MAX, it means nci is
224     //! invalid/unreported.
225     //!
226     //! Users are recommended to use the helper accessor chreWwanUnpackNrNci to
227     //! access the nci field.
228     //!
229     //! @see chreWwanUnpackNrNci
230     uint32_t nci0;
231     uint32_t nci1;
232 
233     //! Physical cell id in range [0, 1007]. This value must be valid.
234     //! Reference: TS 38.331 section 6.3.2.
235     int32_t pci;
236 
237     //! 24-bit tracking area code in range [0, 16777215]. INT32_MAX means
238     //! invalid/unreported.
239     //! Reference: TS 38.413 section 9.3.3.10 and TS 29.571 section 5.4.2.
240     int32_t tac;
241 
242     //! NR Absolute Radio Frequency Channel Number, in range [0, 3279165]. This
243     //! value must be valid.
244     //! Reference: TS 38.101-1 section 5.4.2.1 and TS 38.101-2 section 5.4.2.1.
245     int32_t nrarfcn;
246 };
247 
248 //! Reference: RIL_GSM_SignalStrength_v12
249 struct chreWwanSignalStrengthGsm {
250     //! Valid values are (0-31, 99) as defined in TS 27.007 8.5
251     //! INT32_MAX means invalid/unreported.
252     int32_t signalStrength;
253 
254     //! bit error rate (0-7, 99) as defined in TS 27.007 8.5
255     //! INT32_MAX means invalid/unreported.
256     int32_t bitErrorRate;
257 
258     //! Timing Advance in bit periods. 1 bit period = 48.13 us.
259     //! INT32_MAX means invalid/unreported.
260     int32_t timingAdvance;
261 };
262 
263 //! Reference: RIL_SignalStrengthWcdma
264 struct chreWwanSignalStrengthWcdma {
265     //! Valid values are (0-31, 99) as defined in TS 27.007 8.5
266     //! INT32_MAX means invalid/unreported.
267     int32_t signalStrength;
268 
269     //! bit error rate (0-7, 99) as defined in TS 27.007 8.5
270     //! INT32_MAX means invalid/unreported.
271     int32_t bitErrorRate;
272 };
273 
274 //! Reference: RIL_CDMA_SignalStrength
275 struct chreWwanSignalStrengthCdma {
276     //! Valid values are positive integers.  This value is the actual RSSI value
277     //! multiplied by -1.  Example: If the actual RSSI is -75, then this
278     //! response value will be 75.
279     //! INT32_MAX means invalid/unreported.
280     int32_t dbm;
281 
282     //! Valid values are positive integers.  This value is the actual Ec/Io
283     //! multiplied by -10.  Example: If the actual Ec/Io is -12.5 dB, then this
284     //! response value will be 125.
285     //! INT32_MAX means invalid/unreported.
286     int32_t ecio;
287 };
288 
289 //! Reference: RIL_EVDO_SignalStrength
290 struct chreWwanSignalStrengthEvdo {
291     //! Valid values are positive integers.  This value is the actual RSSI value
292     //! multiplied by -1.  Example: If the actual RSSI is -75, then this
293     //! response value will be 75.
294     //! INT32_MAX means invalid/unreported.
295     int32_t dbm;
296 
297     //! Valid values are positive integers.  This value is the actual Ec/Io
298     //! multiplied by -10.  Example: If the actual Ec/Io is -12.5 dB, then this
299     //! response value will be 125.
300     //! INT32_MAX means invalid/unreported.
301     int32_t ecio;
302 
303     //! Valid values are 0-8.  8 is the highest signal to noise ratio.
304     //! INT32_MAX means invalid/unreported.
305     int32_t signalNoiseRatio;
306 };
307 
308 //! Reference: RIL_LTE_SignalStrength_v8
309 struct chreWwanSignalStrengthLte {
310     //! Valid values are (0-31, 99) as defined in TS 27.007 8.5
311     int32_t signalStrength;
312 
313     //! The current Reference Signal Receive Power in dBm multiplied by -1.
314     //! Range: 44 to 140 dBm
315     //! INT32_MAX means invalid/unreported.
316     //! Reference: 3GPP TS 36.133 9.1.4
317     int32_t rsrp;
318 
319     //! The current Reference Signal Receive Quality in dB multiplied by -1.
320     //! Range: 3 to 20 dB.
321     //! INT32_MAX means invalid/unreported.
322     //! Reference: 3GPP TS 36.133 9.1.7
323     int32_t rsrq;
324 
325     //! The current reference signal signal-to-noise ratio in 0.1 dB units.
326     //! Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB).
327     //! INT32_MAX means invalid/unreported.
328     //! Reference: 3GPP TS 36.101 8.1.1
329     int32_t rssnr;
330 
331     //! The current Channel Quality Indicator.
332     //! Range: 0 to 15.
333     //! INT32_MAX means invalid/unreported.
334     //! Reference: 3GPP TS 36.101 9.2, 9.3, A.4
335     int32_t cqi;
336 
337     //! timing advance in micro seconds for a one way trip from cell to device.
338     //! Approximate distance can be calculated using 300m/us * timingAdvance.
339     //! Range: 0 to 0x7FFFFFFE
340     //! INT32_MAX means invalid/unreported.
341     //! Reference: 3GPP 36.321 section 6.1.3.5
342     //! also: http://www.cellular-planningoptimization.com/2010/02/timing-advance-with-calculation.html
343     int32_t timingAdvance;
344 };
345 
346 //! Reference: RIL_TD_SCDMA_SignalStrength
347 struct chreWwanSignalStrengthTdscdma {
348     //! The Received Signal Code Power in dBm multiplied by -1.
349     //! Range : 25 to 120
350     //! INT32_MAX means invalid/unreported.
351     //! Reference: 3GPP TS 25.123, section 9.1.1.1
352     int32_t rscp;
353 };
354 
355 //! Reference: android.hardware.radio@1.4 NrSignalStrength
356 //! @since v1.4
357 struct chreWwanSignalStrengthNr {
358     //! SS (second synchronization) reference signal received power in dBm
359     //! multiplied by -1.
360     //! Range [44, 140], INT32_MAX means invalid/unreported.
361     //! Reference: TS 38.215 section 5.1.1 and TS 38.133 section 10.1.6.
362     int32_t ssRsrp;
363 
364     //! SS reference signal received quality in 0.5 dB units.
365     //! Range [-86, 41] with -86 = -43.0 dB and 41 = 20.5 dB.
366     //! INT32_MAX means invalid/unreported.
367     //! Reference: TS 38.215 section 5.1.3 and TS 38.133 section 10.1.11.1.
368     int32_t ssRsrq;
369 
370     //! SS signal-to-noise and interference ratio in 0.5 dB units.
371     //! Range [-46, 81] with -46 = -23.0 dB and 81 = 40.5 dB.
372     //! INT32_MAX means invalid/unreported.
373     //! Reference: TS 38.215 section 5.1.5 and TS 38.133 section 10.1.16.1.
374     int32_t ssSinr;
375 
376     //! CSI reference signal received power in dBm multiplied by -1.
377     //! Range [44, 140], INT32_MAX means invalid/unreported.
378     //! Reference: TS 38.215 section 5.1.2 and TS 38.133 section 10.1.6.
379     int32_t csiRsrp;
380 
381     //! CSI reference signal received quality in 0.5 dB units.
382     //! Range [-86, 41] with -86 = -43.0 dB and 41 = 20.5 dB.
383     //! INT32_MAX means invalid/unreported.
384     //! Reference: TS 38.215 section 5.1.4 and TS 38.133 section 10.1.11.1.
385     int32_t csiRsrq;
386 
387     //! CSI signal-to-noise and interference ratio in 0.5 dB units.
388     //! Range [-46, 81] with -46 = -23.0 dB and 81 = 40.5 dB.
389     //! INT32_MAX means invalid/unreported.
390     //! Reference: TS 38.215 section 5.1.6 and TS 38.133 section 10.1.16.1.
391     int32_t csiSinr;
392 };
393 
394 //! Reference: RIL_CellInfoGsm_v12
395 struct chreWwanCellInfoGsm {
396     struct chreWwanCellIdentityGsm    cellIdentityGsm;
397     struct chreWwanSignalStrengthGsm  signalStrengthGsm;
398 };
399 
400 //! Reference: RIL_CellInfoWcdma_v12
401 struct chreWwanCellInfoWcdma {
402     struct chreWwanCellIdentityWcdma    cellIdentityWcdma;
403     struct chreWwanSignalStrengthWcdma  signalStrengthWcdma;
404 };
405 
406 //! Reference: RIL_CellInfoCdma
407 struct chreWwanCellInfoCdma {
408     struct chreWwanCellIdentityCdma    cellIdentityCdma;
409     struct chreWwanSignalStrengthCdma  signalStrengthCdma;
410     struct chreWwanSignalStrengthEvdo  signalStrengthEvdo;
411 };
412 
413 //! Reference: RIL_CellInfoLte_v12
414 struct chreWwanCellInfoLte {
415     struct chreWwanCellIdentityLte    cellIdentityLte;
416     struct chreWwanSignalStrengthLte  signalStrengthLte;
417 };
418 
419 //! Reference: RIL_CellInfoTdscdma
420 struct chreWwanCellInfoTdscdma {
421     struct chreWwanCellIdentityTdscdma    cellIdentityTdscdma;
422     struct chreWwanSignalStrengthTdscdma  signalStrengthTdscdma;
423 };
424 
425 //! Reference: android.hardware.radio@1.4 CellInfoNr
426 //! @since v1.4
427 struct chreWwanCellInfoNr {
428     struct chreWwanCellIdentityNr    cellIdentityNr;
429     struct chreWwanSignalStrengthNr  signalStrengthNr;
430 };
431 
432 //! Reference: RIL_CellInfoType
433 //! All other values are reserved and should be ignored by nanoapps.
434 enum chreWwanCellInfoType {
435     CHRE_WWAN_CELL_INFO_TYPE_GSM      = 1,
436     CHRE_WWAN_CELL_INFO_TYPE_CDMA     = 2,
437     CHRE_WWAN_CELL_INFO_TYPE_LTE      = 3,
438     CHRE_WWAN_CELL_INFO_TYPE_WCDMA    = 4,
439     CHRE_WWAN_CELL_INFO_TYPE_TD_SCDMA = 5,
440     CHRE_WWAN_CELL_INFO_TYPE_NR       = 6,  //! @since v1.4
441 };
442 
443 //! Reference: RIL_TimeStampType
444 enum chreWwanCellTimeStampType {
445     CHRE_WWAN_CELL_TIMESTAMP_TYPE_UNKNOWN  = 0,
446     CHRE_WWAN_CELL_TIMESTAMP_TYPE_ANTENNA  = 1,
447     CHRE_WWAN_CELL_TIMESTAMP_TYPE_MODEM    = 2,
448     CHRE_WWAN_CELL_TIMESTAMP_TYPE_OEM_RIL  = 3,
449     CHRE_WWAN_CELL_TIMESTAMP_TYPE_JAVA_RIL = 4,
450 };
451 
452 //! Reference: RIL_CellInfo_v12
453 struct chreWwanCellInfo {
454     //! Timestamp in nanoseconds; must be in the same time base as chreGetTime()
455     uint64_t timeStamp;
456 
457     //! A value from enum {@link #CellInfoType} indicating the radio access
458     //! technology of the cell, and which field in union CellInfo can be used
459     //! to retrieve additional information
460     uint8_t cellInfoType;
461 
462     //! A value from enum {@link #CellTimeStampType} that identifies the source
463     //! of the value in timeStamp. This is typically set to
464     //! CHRE_WWAN_CELL_TIMESTAMP_TYPE_OEM_RIL, and indicates the time given by
465     //! chreGetTime() that an intermediate module received the data from the
466     //! modem and forwarded it to the requesting CHRE client.
467     uint8_t timeStampType;
468 
469     //! !0 if this cell is registered, 0 if not registered
470     uint8_t registered;
471 
472     //! Reserved for future use; must be set to 0
473     uint8_t reserved;
474 
475     //! The value in cellInfoType indicates which field in this union is valid
476     union chreWwanCellInfoPerRat {
477         struct chreWwanCellInfoGsm     gsm;
478         struct chreWwanCellInfoCdma    cdma;
479         struct chreWwanCellInfoLte     lte;
480         struct chreWwanCellInfoWcdma   wcdma;
481         struct chreWwanCellInfoTdscdma tdscdma;
482         struct chreWwanCellInfoNr      nr;  //! @since v1.4
483     } CellInfo;
484 };
485 
486 /**
487  * Data structure provided with events of type CHRE_EVENT_WWAN_CELL_INFO_RESULT.
488  */
489 struct chreWwanCellInfoResult {
490     //! Indicates the version of the structure, for compatibility purposes.
491     //! Clients do not normally need to worry about this field; the CHRE
492     //! implementation guarantees that the client only receives the structure
493     //! version it expects.
494     uint8_t version;
495 
496     //! Populated with a value from enum {@link #chreError}, indicating whether
497     //! the request failed, and if so, provides the cause of the failure
498     uint8_t errorCode;
499 
500     //! The number of valid entries in cells[]
501     uint8_t cellInfoCount;
502 
503     //! Reserved for future use; must be set to 0
504     uint8_t reserved;
505 
506     //! Set to the cookie parameter given to chreWwanGetCellInfoAsync()
507     const void *cookie;
508 
509     //! Pointer to an array of cellInfoCount elements containing information
510     //! about serving and neighbor cells
511     const struct chreWwanCellInfo *cells;
512 };
513 
514 
515 /**
516  * Retrieves a set of flags indicating the WWAN features supported by the
517  * current CHRE implementation. The value returned by this function must be
518  * consistent for the entire duration of the Nanoapp's execution.
519  *
520  * The client must allow for more flags to be set in this response than it knows
521  * about, for example if the implementation supports a newer version of the API
522  * than the client was compiled against.
523  *
524  * @return A bitmask with zero or more CHRE_WWAN_CAPABILITIES_* flags set
525  *
526  * @since v1.1
527  */
528 uint32_t chreWwanGetCapabilities(void);
529 
530 /**
531  * Nanoapps must define CHRE_NANOAPP_USES_WWAN somewhere in their build
532  * system (e.g. Makefile) if the nanoapp needs to use the following WWAN APIs.
533  * In addition to allowing access to these APIs, defining this macro will also
534  * ensure CHRE enforces that all host clients this nanoapp talks to have the
535  * required Android permissions needed to listen to WWAN data by adding metadata
536  * to the nanoapp.
537  */
538 #if defined(CHRE_NANOAPP_USES_WWAN) || !defined(CHRE_IS_NANOAPP_BUILD)
539 
540 /**
541  * Query information about the current serving cell and its neighbors. This does
542  * not perform a network scan, but should return state from the current network
543  * registration data stored in the cellular modem. This is effectively the same
544  * as a request for RIL_REQUEST_GET_CELL_INFO_LIST in the RIL.
545  *
546  * The requested cellular information is returned asynchronously via
547  * CHRE_EVENT_WWAN_CELL_INFO_RESULT. The implementation must send this event,
548  * either with successful data or an error status, within
549  * CHRE_ASYNC_RESULT_TIMEOUT_NS.
550  *
551  * If the airplane mode setting is enabled at the Android level, the CHRE
552  * implementation is expected to return a successful asynchronous result with an
553  * empty cell info list.
554  *
555  * @param cookie An opaque value that will be included in the
556  *               chreWwanCellInfoResult sent in relation to this request.
557  *
558  * @return true if the request was accepted for processing, false otherwise
559  *
560  * @since v1.1
561  * @note Requires WWAN permission
562  */
563 bool chreWwanGetCellInfoAsync(const void *cookie);
564 
565 /**
566  * Helper accessor for nci in the chreWwanCellIdentityNr struct.
567  *
568  * @return nci or INT64_MAX if invalid/unreported.
569  *
570  * @see chreWwanCellIdentityNr
571  *
572  * @since v1.4
573  * @note Requires WWAN permission
574  */
chreWwanUnpackNrNci(const struct chreWwanCellIdentityNr * nrCellId)575 static inline int64_t chreWwanUnpackNrNci(
576     const struct chreWwanCellIdentityNr *nrCellId) {
577   return (int64_t) (((uint64_t) nrCellId->nci1 << 32) | nrCellId->nci0);
578 }
579 
580 #else  /* defined(CHRE_NANOAPP_USES_WWAN) || !defined(CHRE_IS_NANOAPP_BUILD) */
581 #define CHRE_WWAN_PERM_ERROR_STRING \
582     "CHRE_NANOAPP_USES_WWAN must be defined when building this nanoapp in " \
583     "order to refer to "
584 #define chreWwanGetCellInfoAsync(...) \
585     CHRE_BUILD_ERROR(CHRE_WWAN_PERM_ERROR_STRING "chreWwanGetCellInfoAsync")
586 #define chreWwanUnpackNrNci(...) \
587     CHRE_BUILD_ERROR(CHRE_WWAN_PERM_ERROR_STRING "chreWwanUnpackNrNci")
588 #endif  /* defined(CHRE_NANOAPP_USES_WWAN) || !defined(CHRE_IS_NANOAPP_BUILD) */
589 
590 #ifdef __cplusplus
591 }
592 #endif
593 
594 #endif  /* _CHRE_WWAN_H_ */
595