GNSS measurement

Implementation of GNSS Measurements support.
In GPS HAL, Only GPS Measurements report
will be collected from modem.

bug: 16630595

Change-Id: Ief4368099df4ff573ad1a764f4156d63685e936d
diff --git a/core/LocAdapterBase.cpp b/core/LocAdapterBase.cpp
index eea8edd..23184df 100644
--- a/core/LocAdapterBase.cpp
+++ b/core/LocAdapterBase.cpp
@@ -132,4 +132,8 @@
 void LocAdapterBase::
     shutdown()
 DEFAULT_IMPL()
+
+void LocAdapterBase::
+    reportGpsMeasurementData(GpsData &gpsMeasurementData)
+DEFAULT_IMPL()
 } // namespace loc_core
diff --git a/core/LocAdapterBase.h b/core/LocAdapterBase.h
index 9348a89..e6ff26a 100644
--- a/core/LocAdapterBase.h
+++ b/core/LocAdapterBase.h
@@ -102,6 +102,7 @@
     inline virtual bool isInSession() { return false; }
     virtual void shutdown();
     ContextBase* getContext() const { return mContext; }
+    virtual void reportGpsMeasurementData(GpsData &gpsMeasurementData);
 };
 
 } // namespace loc_core
diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp
index 9298a7a..6969fe5 100644
--- a/core/LocApiBase.cpp
+++ b/core/LocApiBase.cpp
@@ -328,6 +328,12 @@
 LocApiProxyBase* LocApiBase :: getLocApiProxy()
     DEFAULT_IMPL(NULL)
 
+void LocApiBase::reportGpsMeasurementData(GpsData &gpsMeasurementData)
+{
+    // loop through adapters, and deliver to all adapters.
+    TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGpsMeasurementData(gpsMeasurementData));
+}
+
 enum loc_api_adapter_err LocApiBase::
    open(LOC_API_ADAPTER_EVENT_MASK_T mask)
 DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
@@ -487,4 +493,14 @@
 int LocApiBase::
     getGpsLock()
 DEFAULT_IMPL(-1)
+
+int LocApiBase::
+    updateRegistrationMask(LOC_API_ADAPTER_EVENT_MASK_T event,
+                           loc_registration_mask_status isEnabled)
+DEFAULT_IMPL(-1)
+
+bool LocApiBase::
+    gnssConstellationConfig()
+DEFAULT_IMPL(false)
+
 } // namespace loc_core
diff --git a/core/LocApiBase.h b/core/LocApiBase.h
index 2d2b887..46950e6 100644
--- a/core/LocApiBase.h
+++ b/core/LocApiBase.h
@@ -121,6 +121,7 @@
     void reportDataCallOpened();
     void reportDataCallClosed();
     void requestNiNotify(GpsNiNotification &notify, const void* data);
+    void reportGpsMeasurementData(GpsData &gpsMeasurementData);
 
     // downward calls
     // All below functions are to be defined by adapter specific modules:
@@ -220,6 +221,16 @@
       -1 on failure
      */
     virtual int getGpsLock(void);
+
+    /*
+      Update gps reporting events
+     */
+    virtual int updateRegistrationMask(LOC_API_ADAPTER_EVENT_MASK_T event,
+                                       loc_registration_mask_status isEnabled);
+    /*
+      Check if the modem support the service
+     */
+    virtual bool gnssConstellationConfig();
 };
 
 typedef LocApiBase* (getLocApi_t)(const MsgTask* msgTask,
diff --git a/core/LocDualContext.cpp b/core/LocDualContext.cpp
index ab15110..41ad4f0 100644
--- a/core/LocDualContext.cpp
+++ b/core/LocDualContext.cpp
@@ -50,7 +50,8 @@
      LOC_API_ADAPTER_BIT_NMEA_POSITION_REPORT |
      LOC_API_ADAPTER_BIT_IOCTL_REPORT |
      LOC_API_ADAPTER_BIT_STATUS_REPORT |
-     LOC_API_ADAPTER_BIT_GEOFENCE_GEN_ALERT);
+     LOC_API_ADAPTER_BIT_GEOFENCE_GEN_ALERT |
+     LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT);
 
 const MsgTask* LocDualContext::mMsgTask = NULL;
 ContextBase* LocDualContext::mFgContext = NULL;
diff --git a/core/gps_extended_c.h b/core/gps_extended_c.h
index 8de0472..0c35893 100644
--- a/core/gps_extended_c.h
+++ b/core/gps_extended_c.h
@@ -71,6 +71,11 @@
 #define AGPS_CERTIFICATE_MAX_LENGTH 2000
 #define AGPS_CERTIFICATE_MAX_SLOTS 10
 
+enum loc_registration_mask_status {
+    LOC_REGISTRATION_MASK_ENABLED,
+    LOC_REGISTRATION_MASK_DISABLED
+};
+
 typedef struct {
     /** set to sizeof(UlpLocation) */
     size_t          size;
@@ -347,6 +352,7 @@
     LOC_API_ADAPTER_BATCH_FULL,                        // Batching on full
     LOC_API_ADAPTER_BATCHED_POSITION_REPORT,           // Batching on fix
     LOC_API_ADAPTER_BATCHED_GENFENCE_BREACH_REPORT,    //
+    LOC_API_ADAPTER_GNSS_MEASUREMENT,                  // GNSS Measurement report
 
     LOC_API_ADAPTER_EVENT_MAX
 };
@@ -373,6 +379,7 @@
 #define LOC_API_ADAPTER_BIT_REQUEST_WIFI_AP_DATA             (1<<LOC_API_ADAPTER_REQUEST_WIFI_AP_DATA)
 #define LOC_API_ADAPTER_BIT_BATCH_FULL                       (1<<LOC_API_ADAPTER_BATCH_FULL)
 #define LOC_API_ADAPTER_BIT_BATCHED_POSITION_REPORT          (1<<LOC_API_ADAPTER_BATCHED_POSITION_REPORT)
+#define LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT                 (1<<LOC_API_ADAPTER_GNSS_MEASUREMENT)
 
 typedef unsigned int LOC_API_ADAPTER_EVENT_MASK_T;
 
diff --git a/loc_api/libloc_api_50001/LocEngAdapter.cpp b/loc_api/libloc_api_50001/LocEngAdapter.cpp
index 184f83d..16a150d 100644
--- a/loc_api/libloc_api_50001/LocEngAdapter.cpp
+++ b/loc_api/libloc_api_50001/LocEngAdapter.cpp
@@ -345,3 +345,36 @@
 {
     sendMsg(new LocEngUp(mOwner));
 }
+
+void LocEngAdapter::reportGpsMeasurementData(GpsData &gpsMeasurementData)
+{
+    sendMsg(new LocEngReportGpsMeasurement(mOwner,
+                                           gpsMeasurementData));
+}
+
+/*
+  Update Registration Mask
+ */
+void LocEngAdapter::updateRegistrationMask(LOC_API_ADAPTER_EVENT_MASK_T event,
+                                           loc_registration_mask_status isEnabled)
+{
+    LOC_LOGD("entering %s", __func__);
+    int result = LOC_API_ADAPTER_ERR_FAILURE;
+    result = mLocApi->updateRegistrationMask(event, isEnabled);
+    if (result == LOC_API_ADAPTER_ERR_SUCCESS) {
+        LOC_LOGD("%s] update registration mask succeed.", __func__);
+    } else {
+        LOC_LOGE("%s] update registration mask failed.", __func__);
+    }
+}
+
+/*
+  Set Gnss Constellation Config
+ */
+bool LocEngAdapter::gnssConstellationConfig()
+{
+    LOC_LOGD("entering %s", __func__);
+    bool result = false;
+    result = mLocApi->gnssConstellationConfig();
+    return result;
+}
diff --git a/loc_api/libloc_api_50001/LocEngAdapter.h b/loc_api/libloc_api_50001/LocEngAdapter.h
index 1a1159d..fe5df3c 100644
--- a/loc_api/libloc_api_50001/LocEngAdapter.h
+++ b/loc_api/libloc_api_50001/LocEngAdapter.h
@@ -286,6 +286,7 @@
     virtual bool requestSuplES(int connHandle);
     virtual bool reportDataCallOpened();
     virtual bool reportDataCallClosed();
+    virtual void reportGpsMeasurementData(GpsData &gpsMeasurementData);
 
     inline const LocPosMode& getPositionMode() const
     {return mFixCriteria;}
@@ -335,6 +336,17 @@
     {
         return mLocApi->getGpsLock();
     }
+
+    /*
+      Update Registration Mask
+     */
+    void updateRegistrationMask(LOC_API_ADAPTER_EVENT_MASK_T event,
+                                loc_registration_mask_status isEnabled);
+
+    /*
+      Set Gnss Constellation Config
+     */
+    bool gnssConstellationConfig();
 };
 
 #endif //LOC_API_ENG_ADAPTER_H
diff --git a/loc_api/libloc_api_50001/loc.cpp b/loc_api/libloc_api_50001/loc.cpp
index 87a878e..eb11f0b 100644
--- a/loc_api/libloc_api_50001/loc.cpp
+++ b/loc_api/libloc_api_50001/loc.cpp
@@ -127,6 +127,15 @@
 
 // For shutting down MDM in fusion devices
 static int mdm_fd = -1;
+static int loc_gps_measurement_init(GpsMeasurementCallbacks* callbacks);
+static void loc_gps_measurement_close();
+
+static const GpsMeasurementInterface sLocEngGpsMeasurementInterface =
+{
+    sizeof(GpsMeasurementInterface),
+    loc_gps_measurement_init,
+    loc_gps_measurement_close
+};
 
 static void loc_agps_ril_init( AGpsRilCallbacks* callbacks );
 static void loc_agps_ril_set_ref_location(const AGpsRefLocation *agps_reflocation, size_t sz_struct);
@@ -722,6 +731,10 @@
    {
        ret_val = &sLocEngConfigInterface;
    }
+   else if (strcmp(name, GPS_MEASUREMENT_INTERFACE) == 0)
+   {
+       ret_val = &sLocEngGpsMeasurementInterface;
+   }
    else
    {
       LOC_LOGE ("get_extension: Invalid interface passed in\n");
@@ -974,6 +987,56 @@
 }
 
 /*===========================================================================
+FUNCTION    loc_gps_measurement_init
+
+DESCRIPTION
+   This function initializes the gps measurement interface
+
+DEPENDENCIES
+   NONE
+
+RETURN VALUE
+   None
+
+SIDE EFFECTS
+   N/A
+
+===========================================================================*/
+static int loc_gps_measurement_init(GpsMeasurementCallbacks* callbacks)
+{
+    ENTRY_LOG();
+    int ret_val = loc_eng_gps_measurement_init(loc_afw_data,
+                                               callbacks);
+
+    EXIT_LOG(%d, ret_val);
+    return ret_val;
+}
+
+/*===========================================================================
+FUNCTION    loc_gps_measurement_close
+
+DESCRIPTION
+   This function closes the gps measurement interface
+
+DEPENDENCIES
+   NONE
+
+RETURN VALUE
+   None
+
+SIDE EFFECTS
+   N/A
+
+===========================================================================*/
+static void loc_gps_measurement_close()
+{
+    ENTRY_LOG();
+    loc_eng_gps_measurement_close(loc_afw_data);
+
+    EXIT_LOG(%s, VOID_RET);
+}
+
+/*===========================================================================
 FUNCTION    loc_ni_init
 
 DESCRIPTION
diff --git a/loc_api/libloc_api_50001/loc_eng.cpp b/loc_api/libloc_api_50001/loc_eng.cpp
index 8bbf8be..92f7d0e 100644
--- a/loc_api/libloc_api_50001/loc_eng.cpp
+++ b/loc_api/libloc_api_50001/loc_eng.cpp
@@ -1334,6 +1334,33 @@
 //        case LOC_ENG_MSG_INJECT_XTRA_DATA:
 // loc_eng_xtra.cpp
 
+//        case LOC_ENG_MSG_SET_CAPABILITIES:
+struct LocEngSetCapabilities : public LocMsg {
+    loc_eng_data_s_type* mLocEng;
+    inline LocEngSetCapabilities(loc_eng_data_s_type* locEng) :
+        LocMsg(), mLocEng(locEng)
+    {
+        locallog();
+    }
+    inline virtual void proc() const {
+        if (NULL != mLocEng->set_capabilities_cb) {
+            LOC_LOGV("calling set_capabilities_cb 0x%x",
+                     gps_conf.CAPABILITIES);
+            mLocEng->set_capabilities_cb(gps_conf.CAPABILITIES);
+        } else {
+            LOC_LOGV("set_capabilities_cb is NULL.\n");
+        }
+    }
+    inline void locallog() const
+    {
+        LOC_LOGV("LocEngSetCapabilities");
+    }
+    inline virtual void log() const
+    {
+        locallog();
+    }
+};
+
 //        case LOC_ENG_MSG_LOC_INIT:
 struct LocEngInit : public LocMsg {
     loc_eng_data_s_type* mLocEng;
@@ -1344,6 +1371,8 @@
     }
     inline virtual void proc() const {
         loc_eng_reinit(*mLocEng);
+        // set the capabilities
+        mLocEng->adapter->sendMsg(new LocEngSetCapabilities(mLocEng));
     }
     inline void locallog() const
     {
@@ -1533,6 +1562,99 @@
     }
 };
 
+struct LocEngUpdateRegistrationMask : public LocMsg {
+    loc_eng_data_s_type* mLocEng;
+    LOC_API_ADAPTER_EVENT_MASK_T mMask;
+    loc_registration_mask_status mIsEnabled;
+    inline LocEngUpdateRegistrationMask(loc_eng_data_s_type* locEng,
+                                        LOC_API_ADAPTER_EVENT_MASK_T mask,
+                                        loc_registration_mask_status isEnabled) :
+        LocMsg(), mLocEng(locEng), mMask(mask), mIsEnabled(isEnabled) {
+        locallog();
+    }
+    inline virtual void proc() const {
+        loc_eng_data_s_type *locEng = (loc_eng_data_s_type *)mLocEng;
+        locEng->adapter->updateRegistrationMask(mMask,
+                                                mIsEnabled);
+    }
+    void locallog() const {
+        LOC_LOGV("LocEngUpdateRegistrationMask\n");
+    }
+    virtual void log() const {
+        locallog();
+    }
+};
+
+struct LocEngGnssConstellationConfig : public LocMsg {
+    LocEngAdapter* mAdapter;
+    inline LocEngGnssConstellationConfig(LocEngAdapter* adapter) :
+        LocMsg(), mAdapter(adapter) {
+        locallog();
+    }
+    inline virtual void proc() const {
+        if (mAdapter->gnssConstellationConfig()) {
+            LOC_LOGV("Modem supports GNSS measurements\n");
+            gps_conf.CAPABILITIES |= GPS_CAPABILITY_MEASUREMENTS;
+        } else {
+            LOC_LOGV("Modem does not support GNSS measurements\n");
+        }
+    }
+    void locallog() const {
+        LOC_LOGV("LocEngGnssConstellationConfig\n");
+    }
+    virtual void log() const {
+        locallog();
+    }
+};
+
+//        case LOC_ENG_MSG_REPORT_GNSS_MEASUREMENT:
+LocEngReportGpsMeasurement::LocEngReportGpsMeasurement(void* locEng,
+                                                       GpsData &gpsData) :
+    LocMsg(), mLocEng(locEng), mGpsData(gpsData)
+{
+    locallog();
+}
+void LocEngReportGpsMeasurement::proc() const {
+    loc_eng_data_s_type* locEng = (loc_eng_data_s_type*) mLocEng;
+    if (locEng->mute_session_state != LOC_MUTE_SESS_IN_SESSION)
+    {
+        if (locEng->gps_measurement_cb != NULL) {
+            locEng->gps_measurement_cb((GpsData*)&(mGpsData));
+        }
+    }
+}
+void LocEngReportGpsMeasurement::locallog() const {
+    IF_LOC_LOGV {
+        LOC_LOGV("%s:%d]: Received in GPS HAL."
+                 "GNSS Measurements count: %d \n",
+                 __func__, __LINE__, mGpsData.measurement_count);
+        for (int i =0; i< mGpsData.measurement_count && i < GPS_MAX_SVS; i++) {
+                LOC_LOGV(" GNSS measurement data in GPS HAL: \n"
+                         " GPS_HAL => Measurement ID | prn | time_offset_ns | state |"
+                         " received_gps_tow_ns| c_n0_dbhz | pseudorange_rate_mps |"
+                         " pseudorange_rate_uncertainty_mps |"
+                         " accumulated_delta_range_state | flags \n"
+                         " GPS_HAL => %d | %d | %f | %d | %lld | %f | %f | %f | %d | %d \n",
+                         i,
+                         mGpsData.measurements[i].prn,
+                         mGpsData.measurements[i].time_offset_ns,
+                         mGpsData.measurements[i].state,
+                         mGpsData.measurements[i].received_gps_tow_ns,
+                         mGpsData.measurements[i].c_n0_dbhz,
+                         mGpsData.measurements[i].pseudorange_rate_mps,
+                         mGpsData.measurements[i].pseudorange_rate_uncertainty_mps,
+                         mGpsData.measurements[i].accumulated_delta_range_state,
+                         mGpsData.measurements[i].flags);
+        }
+        LOC_LOGV(" GPS_HAL => Clocks Info: type | time_ns \n"
+                 " GPS_HAL => Clocks Info: %d | %lld", mGpsData.clock.type,
+                 mGpsData.clock.time_ns);
+    }
+}
+inline void LocEngReportGpsMeasurement::log() const {
+    locallog();
+}
+
 /*********************************************************************
 * Initialization checking macros
  *********************************************************************/
@@ -1582,10 +1704,6 @@
 
     memset(&loc_eng_data, 0, sizeof (loc_eng_data));
 
-    if (NULL != callbacks->set_capabilities_cb) {
-        callbacks->set_capabilities_cb(gps_conf.CAPABILITIES);
-    }
-
     // Save callbacks
     loc_eng_data.location_cb  = callbacks->location_cb;
     loc_eng_data.sv_status_cb = callbacks->sv_status_cb;
@@ -1637,6 +1755,7 @@
         LOC_LOGD("loc_eng_reinit reinit() successful");
 
         LocEngAdapter* adapter = loc_eng_data.adapter;
+        adapter->sendMsg(new LocEngGnssConstellationConfig(adapter));
         adapter->sendMsg(new LocEngSuplVer(adapter, gps_conf.SUPL_VER));
         adapter->sendMsg(new LocEngLppConfig(adapter, gps_conf.LPP_PROFILE));
         adapter->sendMsg(new LocEngSensorControlConfig(adapter, sap_conf.SENSOR_USAGE,
@@ -2568,31 +2687,28 @@
     ENTRY_LOG_CALLFLOW();
 
     if (config_data && length > 0) {
-        loc_gps_cfg_s_type gps_conf_old = gps_conf;
+        loc_gps_cfg_s_type gps_conf_tmp = gps_conf;
         UTIL_UPDATE_CONF(config_data, length, gps_conf_table);
         LocEngAdapter* adapter = loc_eng_data.adapter;
 
         // it is possible that HAL is not init'ed at this time
         if (adapter) {
-            if (gps_conf_old.SUPL_VER != gps_conf.SUPL_VER) {
+            if (gps_conf_tmp.SUPL_VER != gps_conf.SUPL_VER) {
                 adapter->sendMsg(new LocEngSuplVer(adapter, gps_conf.SUPL_VER));
             }
-            if (gps_conf_old.LPP_PROFILE != gps_conf.LPP_PROFILE) {
+            if (gps_conf_tmp.LPP_PROFILE != gps_conf.LPP_PROFILE) {
                 adapter->sendMsg(new LocEngLppConfig(adapter, gps_conf.LPP_PROFILE));
             }
-            if (gps_conf_old.A_GLONASS_POS_PROTOCOL_SELECT != gps_conf.A_GLONASS_POS_PROTOCOL_SELECT) {
+            if (gps_conf_tmp.A_GLONASS_POS_PROTOCOL_SELECT != gps_conf.A_GLONASS_POS_PROTOCOL_SELECT) {
                 adapter->sendMsg(new LocEngAGlonassProtocol(adapter,
                                                             gps_conf.A_GLONASS_POS_PROTOCOL_SELECT));
             }
-            if (NULL != loc_eng_data.set_capabilities_cb) {
-                gps_conf.CAPABILITIES &= gps_conf_old.CAPABILITIES;
-                if (gps_conf.CAPABILITIES != gps_conf_old.CAPABILITIES) {
-                    loc_eng_data.set_capabilities_cb(gps_conf.CAPABILITIES);
-                }
-            }
         }
 
-        gps_conf.CAPABILITIES = gps_conf_old.CAPABILITIES;
+        gps_conf_tmp.SUPL_VER = gps_conf.SUPL_VER;
+        gps_conf_tmp.LPP_PROFILE = gps_conf.LPP_PROFILE;
+        gps_conf_tmp.A_GLONASS_POS_PROTOCOL_SELECT = gps_conf.A_GLONASS_POS_PROTOCOL_SELECT;
+        gps_conf = gps_conf_tmp;
     }
 
     EXIT_LOG(%s, VOID_RET);
@@ -2802,3 +2918,80 @@
     locEng.shutdown_cb();
     EXIT_LOG(%d, 0);
 }
+
+/*===========================================================================
+FUNCTION    loc_eng_gps_measurement_init
+
+DESCRIPTION
+   Initialize gps measurement module.
+
+DEPENDENCIES
+   N/A
+
+RETURN VALUE
+   0: success
+
+SIDE EFFECTS
+   N/A
+
+===========================================================================*/
+int loc_eng_gps_measurement_init(loc_eng_data_s_type &loc_eng_data,
+                                 GpsMeasurementCallbacks* callbacks)
+{
+    ENTRY_LOG_CALLFLOW();
+
+    STATE_CHECK((NULL == loc_eng_data.gps_measurement_cb),
+                "gps measurement already initialized",
+                return GPS_MEASUREMENT_ERROR_ALREADY_INIT);
+    STATE_CHECK((callbacks != NULL),
+                "callbacks can not be NULL",
+                return GPS_MEASUREMENT_ERROR_GENERIC);
+    STATE_CHECK(loc_eng_data.adapter,
+                "GpsInterface must be initialized first",
+                return GPS_MEASUREMENT_ERROR_GENERIC);
+
+    // updated the mask
+    LOC_API_ADAPTER_EVENT_MASK_T event = LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT;
+    loc_eng_data.adapter->sendMsg(new LocEngUpdateRegistrationMask(
+                                                        &loc_eng_data,
+                                                        event,
+                                                        LOC_REGISTRATION_MASK_ENABLED));
+    // set up the callback
+    loc_eng_data.gps_measurement_cb = callbacks->measurement_callback;
+    LOC_LOGD ("%s, event masks updated successfully", __func__);
+
+    return GPS_MEASUREMENT_OPERATION_SUCCESS;
+}
+
+/*===========================================================================
+FUNCTION    loc_eng_gps_measurement_close
+
+DESCRIPTION
+   Close gps measurement module.
+
+DEPENDENCIES
+   N/A
+
+RETURN VALUE
+   N/A
+
+SIDE EFFECTS
+   N/A
+
+===========================================================================*/
+void loc_eng_gps_measurement_close(loc_eng_data_s_type &loc_eng_data)
+{
+    ENTRY_LOG_CALLFLOW();
+
+    INIT_CHECK(loc_eng_data.adapter, return);
+
+    // updated the mask
+    LOC_API_ADAPTER_EVENT_MASK_T event = LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT;
+    loc_eng_data.adapter->sendMsg(new LocEngUpdateRegistrationMask(
+                                                          &loc_eng_data,
+                                                          event,
+                                                          LOC_REGISTRATION_MASK_DISABLED));
+    // set up the callback
+    loc_eng_data.gps_measurement_cb = NULL;
+    EXIT_LOG(%d, 0);
+}
diff --git a/loc_api/libloc_api_50001/loc_eng.h b/loc_api/libloc_api_50001/loc_eng.h
index b3e2bd1..fa3f19b 100644
--- a/loc_api/libloc_api_50001/loc_eng.h
+++ b/loc_api/libloc_api_50001/loc_eng.h
@@ -92,6 +92,7 @@
     gps_acquire_wakelock           acquire_wakelock_cb;
     gps_release_wakelock           release_wakelock_cb;
     gps_request_utc_time           request_utc_time_cb;
+    gps_measurement_callback       gps_measurement_cb;
     boolean                        intermediateFix;
     AGpsStatusValue                agps_status;
     loc_eng_xtra_data_s_type       xtra_module_data;
@@ -246,6 +247,7 @@
                                    const GpsNiNotification *notif,
                                    const void* passThrough);
 extern void loc_eng_ni_reset_on_engine_restart(loc_eng_data_s_type &loc_eng_data);
+
 int loc_eng_read_config(void);
 
 int loc_eng_agps_install_certificates(loc_eng_data_s_type &loc_eng_data,
@@ -254,6 +256,9 @@
 
 void loc_eng_configuration_update (loc_eng_data_s_type &loc_eng_data,
                                    const char* config_data, int32_t length);
+int loc_eng_gps_measurement_init(loc_eng_data_s_type &loc_eng_data,
+                                 GpsMeasurementCallbacks* callbacks);
+void loc_eng_gps_measurement_close(loc_eng_data_s_type &loc_eng_data);
 
 #ifdef __cplusplus
 }
diff --git a/loc_api/libloc_api_50001/loc_eng_msg.h b/loc_api/libloc_api_50001/loc_eng_msg.h
index b767dc5..e3c48fb 100644
--- a/loc_api/libloc_api_50001/loc_eng_msg.h
+++ b/loc_api/libloc_api_50001/loc_eng_msg.h
@@ -289,6 +289,16 @@
     void send() const;
 };
 
+struct LocEngReportGpsMeasurement : public LocMsg {
+    void* mLocEng;
+    const GpsData mGpsData;
+    LocEngReportGpsMeasurement(void* locEng,
+                               GpsData &gpsData);
+    virtual void proc() const;
+    void locallog() const;
+    virtual void log() const;
+};
+
 struct LocEngShutdown : public LocMsg {
     LocEngAdapter* mAdapter;
     LocEngShutdown(LocEngAdapter* adapter);