1 /* Copyright (c) 2011-2014,2016-2017,2020 The Linux Foundation. All rights reserved.
2  *
3  * Redistribution and use in source and binary forms, with or without
4  * modification, are permitted provided that the following conditions are
5  * met:
6  *     * Redistributions of source code must retain the above copyright
7  *       notice, this list of conditions and the following disclaimer.
8  *     * Redistributions in binary form must reproduce the above
9  *       copyright notice, this list of conditions and the following
10  *       disclaimer in the documentation and/or other materials provided
11  *       with the distribution.
12  *     * Neither the name of The Linux Foundation, nor the names of its
13  *       contributors may be used to endorse or promote products derived
14  *       from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  */
29 #define LOG_NDEBUG 0
30 #define LOG_TAG "LocSvc_CtxBase"
31 
32 #include <dlfcn.h>
33 #include <unistd.h>
34 #include <ContextBase.h>
35 #include <msg_q.h>
36 #include <loc_target.h>
37 #include <loc_pla.h>
38 #include <loc_log.h>
39 
40 namespace loc_core {
41 
42 #define SLL_LOC_API_LIB_NAME "libsynergy_loc_api.so"
43 #define LOC_APIV2_0_LIB_NAME "libloc_api_v02.so"
44 #define IS_SS5_HW_ENABLED  1
45 
46 loc_gps_cfg_s_type ContextBase::mGps_conf {};
47 loc_sap_cfg_s_type ContextBase::mSap_conf {};
48 bool ContextBase::sIsEngineCapabilitiesKnown = false;
49 uint64_t ContextBase::sSupportedMsgMask = 0;
50 bool ContextBase::sGnssMeasurementSupported = false;
51 uint8_t ContextBase::sFeaturesSupported[MAX_FEATURE_LENGTH];
52 GnssNMEARptRate ContextBase::sNmeaReportRate = GNSS_NMEA_REPORT_RATE_NHZ;
53 LocationCapabilitiesMask ContextBase::sQwesFeatureMask = 0;
54 
55 const loc_param_s_type ContextBase::mGps_conf_table[] =
56 {
57   {"GPS_LOCK",                       &mGps_conf.GPS_LOCK,                       NULL, 'n'},
58   {"SUPL_VER",                       &mGps_conf.SUPL_VER,                       NULL, 'n'},
59   {"LPP_PROFILE",                    &mGps_conf.LPP_PROFILE,                    NULL, 'n'},
60   {"A_GLONASS_POS_PROTOCOL_SELECT",  &mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT,  NULL, 'n'},
61   {"LPPE_CP_TECHNOLOGY",             &mGps_conf.LPPE_CP_TECHNOLOGY,             NULL, 'n'},
62   {"LPPE_UP_TECHNOLOGY",             &mGps_conf.LPPE_UP_TECHNOLOGY,             NULL, 'n'},
63   {"AGPS_CERT_WRITABLE_MASK",        &mGps_conf.AGPS_CERT_WRITABLE_MASK,        NULL, 'n'},
64   {"SUPL_MODE",                      &mGps_conf.SUPL_MODE,                      NULL, 'n'},
65   {"SUPL_ES",                        &mGps_conf.SUPL_ES,                        NULL, 'n'},
66   {"INTERMEDIATE_POS",               &mGps_conf.INTERMEDIATE_POS,               NULL, 'n'},
67   {"ACCURACY_THRES",                 &mGps_conf.ACCURACY_THRES,                 NULL, 'n'},
68   {"NMEA_PROVIDER",                  &mGps_conf.NMEA_PROVIDER,                  NULL, 'n'},
69   {"NMEA_REPORT_RATE",               &mGps_conf.NMEA_REPORT_RATE,               NULL, 's'},
70   {"CAPABILITIES",                   &mGps_conf.CAPABILITIES,                   NULL, 'n'},
71   {"XTRA_SERVER_1",                  &mGps_conf.XTRA_SERVER_1,                  NULL, 's'},
72   {"XTRA_SERVER_2",                  &mGps_conf.XTRA_SERVER_2,                  NULL, 's'},
73   {"XTRA_SERVER_3",                  &mGps_conf.XTRA_SERVER_3,                  NULL, 's'},
74   {"USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL",
75            &mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL,          NULL, 'n'},
76   {"AGPS_CONFIG_INJECT",             &mGps_conf.AGPS_CONFIG_INJECT,             NULL, 'n'},
77   {"EXTERNAL_DR_ENABLED",            &mGps_conf.EXTERNAL_DR_ENABLED,                  NULL, 'n'},
78   {"SUPL_HOST",                      &mGps_conf.SUPL_HOST,                      NULL, 's'},
79   {"SUPL_PORT",                      &mGps_conf.SUPL_PORT,                      NULL, 'n'},
80   {"MODEM_TYPE",                     &mGps_conf.MODEM_TYPE,                     NULL, 'n' },
81   {"MO_SUPL_HOST",                   &mGps_conf.MO_SUPL_HOST,                   NULL, 's' },
82   {"MO_SUPL_PORT",                   &mGps_conf.MO_SUPL_PORT,                   NULL, 'n' },
83   {"CONSTRAINED_TIME_UNCERTAINTY_ENABLED",
84            &mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED,      NULL, 'n'},
85   {"CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD",
86            &mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD,    NULL, 'f'},
87   {"CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET",
88            &mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET, NULL, 'n'},
89   {"POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED",
90            &mGps_conf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED, NULL, 'n'},
91   {"PROXY_APP_PACKAGE_NAME",         &mGps_conf.PROXY_APP_PACKAGE_NAME,         NULL, 's' },
92   {"CP_MTLR_ES",                     &mGps_conf.CP_MTLR_ES,                     NULL, 'n' },
93   {"GNSS_DEPLOYMENT",  &mGps_conf.GNSS_DEPLOYMENT, NULL, 'n'},
94   {"CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED",
95            &mGps_conf.CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED, NULL, 'n'},
96   {"NMEA_TAG_BLOCK_GROUPING_ENABLED", &mGps_conf.NMEA_TAG_BLOCK_GROUPING_ENABLED, NULL, 'n'},
97   {"NI_SUPL_DENY_ON_NFW_LOCKED",  &mGps_conf.NI_SUPL_DENY_ON_NFW_LOCKED, NULL, 'n'},
98   {"ENABLE_NMEA_PRINT",  &mGps_conf.ENABLE_NMEA_PRINT, NULL, 'n'}
99 };
100 
101 const loc_param_s_type ContextBase::mSap_conf_table[] =
102 {
103   {"GYRO_BIAS_RANDOM_WALK",          &mSap_conf.GYRO_BIAS_RANDOM_WALK,          &mSap_conf.GYRO_BIAS_RANDOM_WALK_VALID, 'f'},
104   {"ACCEL_RANDOM_WALK_SPECTRAL_DENSITY",     &mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY,    &mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
105   {"ANGLE_RANDOM_WALK_SPECTRAL_DENSITY",     &mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY,    &mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
106   {"RATE_RANDOM_WALK_SPECTRAL_DENSITY",      &mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY,     &mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
107   {"VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY",  &mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY, &mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID, 'f'},
108   {"SENSOR_ACCEL_BATCHES_PER_SEC",   &mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC,   NULL, 'n'},
109   {"SENSOR_ACCEL_SAMPLES_PER_BATCH", &mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH, NULL, 'n'},
110   {"SENSOR_GYRO_BATCHES_PER_SEC",    &mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC,    NULL, 'n'},
111   {"SENSOR_GYRO_SAMPLES_PER_BATCH",  &mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH,  NULL, 'n'},
112   {"SENSOR_ACCEL_BATCHES_PER_SEC_HIGH",   &mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH,   NULL, 'n'},
113   {"SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH", &mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH, NULL, 'n'},
114   {"SENSOR_GYRO_BATCHES_PER_SEC_HIGH",    &mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH,    NULL, 'n'},
115   {"SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH",  &mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH,  NULL, 'n'},
116   {"SENSOR_CONTROL_MODE",            &mSap_conf.SENSOR_CONTROL_MODE,            NULL, 'n'},
117   {"SENSOR_ALGORITHM_CONFIG_MASK",   &mSap_conf.SENSOR_ALGORITHM_CONFIG_MASK,   NULL, 'n'}
118 };
119 
readConfig()120 void ContextBase::readConfig()
121 {
122     static bool confReadDone = false;
123     if (!confReadDone) {
124         confReadDone = true;
125         /*Defaults for gps.conf*/
126         mGps_conf.INTERMEDIATE_POS = 0;
127         mGps_conf.ACCURACY_THRES = 0;
128         mGps_conf.NMEA_PROVIDER = 0;
129         mGps_conf.GPS_LOCK = GNSS_CONFIG_GPS_LOCK_MO_AND_NI;
130         mGps_conf.SUPL_VER = 0x10000;
131         mGps_conf.SUPL_MODE = 0x1;
132         mGps_conf.SUPL_ES = 0;
133         mGps_conf.CP_MTLR_ES = 0;
134         mGps_conf.SUPL_HOST[0] = 0;
135         mGps_conf.SUPL_PORT = 0;
136         mGps_conf.CAPABILITIES = 0x7;
137         /* LTE Positioning Profile configuration is disable by default*/
138         mGps_conf.LPP_PROFILE = 0;
139         /*By default no positioning protocol is selected on A-GLONASS system*/
140         mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT = 0;
141         /*Use emergency PDN by default*/
142         mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL = 1;
143         /* By default no LPPe CP technology is enabled*/
144         mGps_conf.LPPE_CP_TECHNOLOGY = 0;
145         /* By default no LPPe UP technology is enabled*/
146         mGps_conf.LPPE_UP_TECHNOLOGY = 0;
147         /* By default we use unknown modem type*/
148         mGps_conf.MODEM_TYPE = 2;
149 
150         /*Defaults for sap.conf*/
151         mSap_conf.GYRO_BIAS_RANDOM_WALK = 0;
152         mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC = 2;
153         mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH = 5;
154         mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC = 2;
155         mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH = 5;
156         mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH = 4;
157         mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH = 25;
158         mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH = 4;
159         mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH = 25;
160         mSap_conf.SENSOR_CONTROL_MODE = 0; /* AUTO */
161         mSap_conf.SENSOR_ALGORITHM_CONFIG_MASK = 0; /* INS Disabled = FALSE*/
162         /* Values MUST be set by OEMs in configuration for sensor-assisted
163           navigation to work. There are NO default values */
164         mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY = 0;
165         mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY = 0;
166         mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY = 0;
167         mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY = 0;
168         mSap_conf.GYRO_BIAS_RANDOM_WALK_VALID = 0;
169         mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
170         mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
171         mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
172         mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
173 
174         /* None of the 10 slots for agps certificates are writable by default */
175         mGps_conf.AGPS_CERT_WRITABLE_MASK = 0;
176 
177         /* inject supl config to modem with config values from config.xml or gps.conf, default 1 */
178         mGps_conf.AGPS_CONFIG_INJECT = 1;
179 
180         /* default configuration value of constrained time uncertainty mode:
181            feature disabled, time uncertainty threshold defined by modem,
182            and unlimited power budget */
183 #ifdef FEATURE_AUTOMOTIVE
184         mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED = 1;
185 #else
186         mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENABLED = 0;
187 #endif
188         mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_THRESHOLD = 0.0;
189         mGps_conf.CONSTRAINED_TIME_UNCERTAINTY_ENERGY_BUDGET = 0;
190 
191         /* default configuration value of position assisted clock estimator mode */
192         mGps_conf.POSITION_ASSISTED_CLOCK_ESTIMATOR_ENABLED = 0;
193         /* default configuration QTI GNSS H/W */
194         mGps_conf.GNSS_DEPLOYMENT = 0;
195         mGps_conf.CUSTOM_NMEA_GGA_FIX_QUALITY_ENABLED = 0;
196         /* default NMEA Tag Block Grouping is disabled */
197         mGps_conf.NMEA_TAG_BLOCK_GROUPING_ENABLED = 0;
198         /* default configuration for NI_SUPL_DENY_ON_NFW_LOCKED */
199         mGps_conf.NI_SUPL_DENY_ON_NFW_LOCKED = 1;
200         /* By default NMEA Printing is disabled */
201         mGps_conf.ENABLE_NMEA_PRINT = 0;
202 
203         UTIL_READ_CONF(LOC_PATH_GPS_CONF, mGps_conf_table);
204         UTIL_READ_CONF(LOC_PATH_SAP_CONF, mSap_conf_table);
205 
206         if (strncmp(mGps_conf.NMEA_REPORT_RATE, "1HZ", sizeof(mGps_conf.NMEA_REPORT_RATE)) == 0) {
207             /* NMEA reporting is configured at 1Hz*/
208             sNmeaReportRate = GNSS_NMEA_REPORT_RATE_1HZ;
209         } else {
210             sNmeaReportRate = GNSS_NMEA_REPORT_RATE_NHZ;
211         }
212         LOC_LOGI("%s] GNSS Deployment: %s", __FUNCTION__,
213                 ((mGps_conf.GNSS_DEPLOYMENT == 1) ? "SS5" :
214                 ((mGps_conf.GNSS_DEPLOYMENT == 2) ? "QFUSION" : "QGNSS")));
215 
216         switch (getTargetGnssType(loc_get_target())) {
217           case GNSS_GSS:
218           case GNSS_AUTO:
219              // For APQ targets, MSA/MSB capabilities should be reset
220              mGps_conf.CAPABILITIES &= ~(LOC_GPS_CAPABILITY_MSA | LOC_GPS_CAPABILITY_MSB);
221              break;
222           default:
223              break;
224         }
225     }
226 }
227 
getCarrierCapabilities()228 uint32_t ContextBase::getCarrierCapabilities() {
229     #define carrierMSA (uint32_t)0x2
230     #define carrierMSB (uint32_t)0x1
231     #define gpsConfMSA (uint32_t)0x4
232     #define gpsConfMSB (uint32_t)0x2
233     uint32_t capabilities = mGps_conf.CAPABILITIES;
234     if ((mGps_conf.SUPL_MODE & carrierMSA) != carrierMSA) {
235         capabilities &= ~gpsConfMSA;
236     }
237     if ((mGps_conf.SUPL_MODE & carrierMSB) != carrierMSB) {
238         capabilities &= ~gpsConfMSB;
239     }
240 
241     LOC_LOGV("getCarrierCapabilities: CAPABILITIES %x, SUPL_MODE %x, carrier capabilities %x",
242              mGps_conf.CAPABILITIES, mGps_conf.SUPL_MODE, capabilities);
243     return capabilities;
244 }
245 
getLBSProxy(const char * libName)246 LBSProxyBase* ContextBase::getLBSProxy(const char* libName)
247 {
248     LBSProxyBase* proxy = NULL;
249     LOC_LOGD("%s:%d]: getLBSProxy libname: %s\n", __func__, __LINE__, libName);
250     void* lib = dlopen(libName, RTLD_NOW);
251 
252     if ((void*)NULL != lib) {
253         getLBSProxy_t* getter = (getLBSProxy_t*)dlsym(lib, "getLBSProxy");
254         if (NULL != getter) {
255             proxy = (*getter)();
256         }
257     }
258     else
259     {
260         LOC_LOGW("%s:%d]: FAILED TO LOAD libname: %s\n", __func__, __LINE__, libName);
261     }
262     if (NULL == proxy) {
263         proxy = new LBSProxyBase();
264     }
265     LOC_LOGD("%s:%d]: Exiting\n", __func__, __LINE__);
266     return proxy;
267 }
268 
createLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask)269 LocApiBase* ContextBase::createLocApi(LOC_API_ADAPTER_EVENT_MASK_T exMask)
270 {
271     LocApiBase* locApi = NULL;
272     const char* libname = LOC_APIV2_0_LIB_NAME;
273 
274     // Check the target
275     if (TARGET_NO_GNSS != loc_get_target()){
276 
277         if (NULL == (locApi = mLBSProxy->getLocApi(exMask, this))) {
278             void *handle = NULL;
279 
280             if (IS_SS5_HW_ENABLED == mGps_conf.GNSS_DEPLOYMENT) {
281                 libname = SLL_LOC_API_LIB_NAME;
282             }
283 
284             if ((handle = dlopen(libname, RTLD_NOW)) != NULL) {
285                 LOC_LOGD("%s:%d]: %s is present", __func__, __LINE__, libname);
286                 getLocApi_t* getter = (getLocApi_t*) dlsym(handle, "getLocApi");
287                 if (getter != NULL) {
288                     LOC_LOGD("%s:%d]: getter is not NULL of %s", __func__,
289                             __LINE__, libname);
290                     locApi = (*getter)(exMask, this);
291                 }
292             }
293             // only RPC is the option now
294             else {
295                 LOC_LOGD("%s:%d]: libloc_api_v02.so is NOT present. Trying RPC",
296                         __func__, __LINE__);
297                 handle = dlopen("libloc_api-rpc-qc.so", RTLD_NOW);
298                 if (NULL != handle) {
299                     getLocApi_t* getter = (getLocApi_t*) dlsym(handle, "getLocApi");
300                     if (NULL != getter) {
301                         LOC_LOGD("%s:%d]: getter is not NULL in RPC", __func__,
302                                 __LINE__);
303                         locApi = (*getter)(exMask, this);
304                     }
305                 }
306             }
307         }
308     }
309 
310     // locApi could still be NULL at this time
311     // we would then create a dummy one
312     if (NULL == locApi) {
313         locApi = new LocApiBase(exMask, this);
314     }
315 
316     return locApi;
317 }
318 
ContextBase(const MsgTask * msgTask,LOC_API_ADAPTER_EVENT_MASK_T exMask,const char * libName)319 ContextBase::ContextBase(const MsgTask* msgTask,
320                          LOC_API_ADAPTER_EVENT_MASK_T exMask,
321                          const char* libName) :
322     mLBSProxy(getLBSProxy(libName)),
323     mMsgTask(msgTask),
324     mLocApi(createLocApi(exMask)),
325     mLocApiProxy(mLocApi->getLocApiProxy())
326 {
327 }
328 
setEngineCapabilities(uint64_t supportedMsgMask,uint8_t * featureList,bool gnssMeasurementSupported)329 void ContextBase::setEngineCapabilities(uint64_t supportedMsgMask,
330        uint8_t *featureList, bool gnssMeasurementSupported) {
331 
332     if (ContextBase::sIsEngineCapabilitiesKnown == false) {
333         ContextBase::sSupportedMsgMask = supportedMsgMask;
334         ContextBase::sGnssMeasurementSupported = gnssMeasurementSupported;
335         if (featureList != NULL) {
336             memcpy((void *)ContextBase::sFeaturesSupported,
337                     (void *)featureList, sizeof(ContextBase::sFeaturesSupported));
338         }
339 
340         /* */
341         if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_MEASUREMENTS_CORRECTION)) {
342             static uint8_t isSapModeKnown = 0;
343 
344             if (!isSapModeKnown) {
345                 /* Check if SAP is PREMIUM_ENV_AIDING in izat.conf */
346                 char conf_feature_sap[LOC_MAX_PARAM_STRING];
347                 loc_param_s_type izat_conf_feature_table[] =
348                 {
349                     { "SAP",           &conf_feature_sap,           &isSapModeKnown, 's' }
350                 };
351                 UTIL_READ_CONF(LOC_PATH_IZAT_CONF, izat_conf_feature_table);
352 
353                 /* Disable this feature if SAP is not PREMIUM_ENV_AIDING in izat.conf */
354                 if (strcmp(conf_feature_sap, "PREMIUM_ENV_AIDING") != 0) {
355                     uint8_t arrayIndex = LOC_SUPPORTED_FEATURE_MEASUREMENTS_CORRECTION >> 3;
356                     uint8_t bitPos = LOC_SUPPORTED_FEATURE_MEASUREMENTS_CORRECTION & 7;
357 
358                     if (arrayIndex < MAX_FEATURE_LENGTH) {
359                         /* To disable the feature we need to reset the bit on the "bitPos"
360                            position, so shift a "1" to the left by "bitPos" */
361                         ContextBase::sFeaturesSupported[arrayIndex] &= ~(1 << bitPos);
362                     }
363                 }
364             }
365         }
366         ContextBase::sIsEngineCapabilitiesKnown = true;
367     }
368 }
369 
370 
isFeatureSupported(uint8_t featureVal)371 bool ContextBase::isFeatureSupported(uint8_t featureVal)
372 {
373     uint8_t arrayIndex = featureVal >> 3;
374     uint8_t bitPos = featureVal & 7;
375 
376     if (arrayIndex >= MAX_FEATURE_LENGTH) return false;
377     return ((ContextBase::sFeaturesSupported[arrayIndex] >> bitPos ) & 0x1);
378 }
379 
gnssConstellationConfig()380 bool ContextBase::gnssConstellationConfig() {
381     return sGnssMeasurementSupported;
382 }
383 
384 }
385