Support GnssMeasurement

Support the new GnssMeasurement and GnssClock
data structures for the new gps.h

Change-Id: I40e00711501432760c82d27fb82702b1bf57ebb6
diff --git a/msm8996/core/LocAdapterBase.cpp b/msm8996/core/LocAdapterBase.cpp
index 4f6b9c5..d4727d8 100644
--- a/msm8996/core/LocAdapterBase.cpp
+++ b/msm8996/core/LocAdapterBase.cpp
@@ -80,7 +80,7 @@
 }
 
 void LocAdapterBase::
-    reportSv(QtiGnssSvStatus &svStatus,
+    reportSv(GnssSvStatus &svStatus,
              GpsLocationExtended &locationExtended,
              void* svExt)
 DEFAULT_IMPL()
@@ -137,6 +137,6 @@
 DEFAULT_IMPL(false)
 
 void LocAdapterBase::
-    reportGpsMeasurementData(GpsData &gpsMeasurementData)
+    reportGnssMeasurementData(GnssData &gnssMeasurementData)
 DEFAULT_IMPL()
 } // namespace loc_core
diff --git a/msm8996/core/LocAdapterBase.h b/msm8996/core/LocAdapterBase.h
index 6a282cc..3334bda 100644
--- a/msm8996/core/LocAdapterBase.h
+++ b/msm8996/core/LocAdapterBase.h
@@ -92,7 +92,7 @@
                                 void* locationExt,
                                 enum loc_sess_status status,
                                 LocPosTechMask loc_technology_mask);
-    virtual void reportSv(QtiGnssSvStatus &svStatus,
+    virtual void reportSv(GnssSvStatus &svStatus,
                           GpsLocationExtended &locationExtended,
                           void* svExt);
     virtual void reportStatus(GpsStatusValue status);
@@ -111,7 +111,7 @@
                                  const void* data);
     inline virtual bool isInSession() { return false; }
     ContextBase* getContext() const { return mContext; }
-    virtual void reportGpsMeasurementData(GpsData &gpsMeasurementData);
+    virtual void reportGnssMeasurementData(GnssData &gnssMeasurementData);
 };
 
 } // namespace loc_core
diff --git a/msm8996/core/LocApiBase.cpp b/msm8996/core/LocApiBase.cpp
index c09439e..3a274ed 100644
--- a/msm8996/core/LocApiBase.cpp
+++ b/msm8996/core/LocApiBase.cpp
@@ -253,23 +253,21 @@
     );
 }
 
-void LocApiBase::reportSv(QtiGnssSvStatus &svStatus,
+void LocApiBase::reportSv(GnssSvStatus &svStatus,
                   GpsLocationExtended &locationExtended,
                   void* svExt)
 {
     // print the SV info before delivering
-    LOC_LOGV("num sv: %d\n  ephemeris mask: %dxn  almanac mask: %x\n  gps/glo/bds in use"
-             " mask: %x/%x/%x\n      sv: prn         snr       elevation      azimuth",
-             svStatus.num_svs, svStatus.ephemeris_mask,
-             svStatus.almanac_mask, svStatus.gps_used_in_fix_mask,
-             svStatus.glo_used_in_fix_mask, svStatus.bds_used_in_fix_mask);
-    for (int i = 0; i < svStatus.num_svs && i < GPS_MAX_SVS; i++) {
-        LOC_LOGV("   %d:   %d    %f    %f    %f",
+    LOC_LOGV("num sv: %d", svStatus.num_svs);
+    for (int i = 0; i < svStatus.num_svs && i < GNSS_MAX_SVS; i++) {
+        LOC_LOGV("   %03d:   %02d    %d    %f    %f    %f   0x%02X",
                  i,
-                 svStatus.sv_list[i].prn,
-                 svStatus.sv_list[i].snr,
-                 svStatus.sv_list[i].elevation,
-                 svStatus.sv_list[i].azimuth);
+                 svStatus.gnss_sv_list[i].svid,
+                 svStatus.gnss_sv_list[i].constellation,
+                 svStatus.gnss_sv_list[i].c_n0_dbhz,
+                 svStatus.gnss_sv_list[i].elevation,
+                 svStatus.gnss_sv_list[i].azimuth,
+                 svStatus.gnss_sv_list[i].flags);
     }
     // loop through adapters, and deliver to all adapters.
     TO_ALL_LOCADAPTERS(
@@ -364,10 +362,10 @@
 LocApiProxyBase* LocApiBase :: getLocApiProxy()
     DEFAULT_IMPL(NULL)
 
-void LocApiBase::reportGpsMeasurementData(GpsData &gpsMeasurementData)
+void LocApiBase::reportGnssMeasurementData(GnssData &gnssMeasurementData)
 {
     // loop through adapters, and deliver to all adapters.
-    TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGpsMeasurementData(gpsMeasurementData));
+    TO_ALL_LOCADAPTERS(mLocAdapters[i]->reportGnssMeasurementData(gnssMeasurementData));
 }
 
 enum loc_api_adapter_err LocApiBase::
diff --git a/msm8996/core/LocApiBase.h b/msm8996/core/LocApiBase.h
index 730bc5c..7658f1f 100644
--- a/msm8996/core/LocApiBase.h
+++ b/msm8996/core/LocApiBase.h
@@ -113,7 +113,7 @@
                         enum loc_sess_status status,
                         LocPosTechMask loc_technology_mask =
                                   LOC_POS_TECH_MASK_DEFAULT);
-    void reportSv(QtiGnssSvStatus &svStatus,
+    void reportSv(GnssSvStatus &svStatus,
                   GpsLocationExtended &locationExtended,
                   void* svExt);
     void reportStatus(GpsStatusValue status);
@@ -130,7 +130,7 @@
     void reportDataCallClosed();
     void requestNiNotify(GpsNiNotification &notify, const void* data);
     void saveSupportedMsgList(uint64_t supportedMsgList);
-    void reportGpsMeasurementData(GpsData &gpsMeasurementData);
+    void reportGnssMeasurementData(GnssData &gnssMeasurementData);
 
     // downward calls
     // All below functions are to be defined by adapter specific modules:
diff --git a/msm8996/core/UlpProxyBase.h b/msm8996/core/UlpProxyBase.h
index ab17294..cb169a5 100644
--- a/msm8996/core/UlpProxyBase.h
+++ b/msm8996/core/UlpProxyBase.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -59,7 +59,7 @@
                                        LocPosTechMask loc_technology_mask) {
         return false;
     }
-    inline virtual bool reportSv(QtiGnssSvStatus &svStatus,
+    inline virtual bool reportSv(GnssSvStatus &svStatus,
                                  GpsLocationExtended &locationExtended,
                                  void* svExt) {
         return false;
@@ -70,7 +70,7 @@
     inline virtual void setAdapter(LocAdapterBase* adapter) {}
     inline virtual void setCapabilities(unsigned long capabilities) {}
     inline virtual bool reportBatchingSession(FlpExtBatchOptions &options,
-                                              bool active) {
+        bool active) {
         return false;
     }
     inline virtual bool reportPositions(const FlpExtLocation* locations,
diff --git a/msm8996/core/gps_extended_c.h b/msm8996/core/gps_extended_c.h
index 054f645..50438db 100644
--- a/msm8996/core/gps_extended_c.h
+++ b/msm8996/core/gps_extended_c.h
@@ -254,47 +254,6 @@
     LocReliability  vertical_reliability;
 } GpsLocationExtended;
 
-/** Represents SV status. */
-typedef struct {
-    /** set to sizeof(QtiGnssSvStatus) */
-    size_t          size;
-
-    /** Number of SVs currently visible. */
-    int         num_svs;
-
-    /** Contains an array of SV information. */
-    GpsSvInfo   sv_list[GPS_MAX_SVS];
-
-    /** Represents a bit mask indicating which SVs
-     * have ephemeris data.
-     */
-    uint32_t    ephemeris_mask;
-
-    /** Represents a bit mask indicating which SVs
-     * have almanac data.
-     */
-    uint32_t    almanac_mask;
-
-    /**
-     * Represents a bit mask indicating which GPS SVs
-     * were used for computing the most recent position fix.
-     */
-    uint32_t    gps_used_in_fix_mask;
-
-    /**
-     * Represents a bit mask indicating which GLONASS SVs
-     * were used for computing the most recent position fix.
-     */
-    uint32_t    glo_used_in_fix_mask;
-
-    /**
-     * Represents a bit mask indicating which BDS SVs
-     * were used for computing the most recent position fix.
-     */
-    uint64_t    bds_used_in_fix_mask;
-
-} QtiGnssSvStatus;
-
 enum loc_sess_status {
     LOC_SESS_SUCCESS,
     LOC_SESS_INTERMEDIATE,
diff --git a/msm8996/loc_api/libloc_api_50001/LocEngAdapter.cpp b/msm8996/loc_api/libloc_api_50001/LocEngAdapter.cpp
index c674fdf..4229929 100644
--- a/msm8996/loc_api/libloc_api_50001/LocEngAdapter.cpp
+++ b/msm8996/loc_api/libloc_api_50001/LocEngAdapter.cpp
@@ -375,14 +375,14 @@
     }
 }
 
-void LocInternalAdapter::reportSv(QtiGnssSvStatus &svStatus,
+void LocInternalAdapter::reportSv(GnssSvStatus &svStatus,
                                   GpsLocationExtended &locationExtended,
                                   void* svExt){
     sendMsg(new LocEngReportSv(mLocEngAdapter, svStatus,
                                locationExtended, svExt));
 }
 
-void LocEngAdapter::reportSv(QtiGnssSvStatus &svStatus,
+void LocEngAdapter::reportSv(GnssSvStatus &svStatus,
                              GpsLocationExtended &locationExtended,
                              void* svExt)
 {
@@ -564,10 +564,10 @@
     return ret;
 }
 
-void LocEngAdapter::reportGpsMeasurementData(GpsData &gpsMeasurementData)
+void LocEngAdapter::reportGnssMeasurementData(GnssData &gnssMeasurementData)
 {
-    sendMsg(new LocEngReportGpsMeasurement(mOwner,
-                                           gpsMeasurementData));
+    sendMsg(new LocEngReportGnssMeasurement(mOwner,
+                                           gnssMeasurementData));
 }
 
 /*
diff --git a/msm8996/loc_api/libloc_api_50001/LocEngAdapter.h b/msm8996/loc_api/libloc_api_50001/LocEngAdapter.h
index d6295d1..0e0fdbe 100644
--- a/msm8996/loc_api/libloc_api_50001/LocEngAdapter.h
+++ b/msm8996/loc_api/libloc_api_50001/LocEngAdapter.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2016, The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -55,7 +55,7 @@
                                 void* locationExt,
                                 enum loc_sess_status status,
                                 LocPosTechMask loc_technology_mask);
-    virtual void reportSv(QtiGnssSvStatus &svStatus,
+    virtual void reportSv(GnssSvStatus &svStatus,
                           GpsLocationExtended &locationExtended,
                           void* svExt);
     virtual void reportStatus(GpsStatusValue status);
@@ -85,6 +85,7 @@
     bool mSupportsAgpsRequests;
     bool mSupportsPositionInjection;
     bool mSupportsTimeInjection;
+    GnssSystemInfo mGnssInfo;
 
     LocEngAdapter(LOC_API_ADAPTER_EVENT_MASK_T mask,
                   void* owner, ContextBase* context,
@@ -269,7 +270,7 @@
                                 void* locationExt,
                                 enum loc_sess_status status,
                                 LocPosTechMask loc_technology_mask);
-    virtual void reportSv(QtiGnssSvStatus &svStatus,
+    virtual void reportSv(GnssSvStatus &svStatus,
                           GpsLocationExtended &locationExtended,
                           void* svExt);
     virtual void reportStatus(GpsStatusValue status);
@@ -284,7 +285,7 @@
     virtual bool requestSuplES(int connHandle);
     virtual bool reportDataCallOpened();
     virtual bool reportDataCallClosed();
-    virtual void reportGpsMeasurementData(GpsData &gpsMeasurementData);
+    virtual void reportGnssMeasurementData(GnssData &gnssMeasurementData);
 
     inline const LocPosMode& getPositionMode() const
     {return mFixCriteria;}
diff --git a/msm8996/loc_api/libloc_api_50001/loc.cpp b/msm8996/loc_api/libloc_api_50001/loc.cpp
index 505fc94..34a844d 100644
--- a/msm8996/loc_api/libloc_api_50001/loc.cpp
+++ b/msm8996/loc_api/libloc_api_50001/loc.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2016, The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -285,6 +285,7 @@
     }
 
     event = LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT |
+            LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT |
             LOC_API_ADAPTER_BIT_SATELLITE_REPORT |
             LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST |
             LOC_API_ADAPTER_BIT_ASSISTANCE_DATA_REQUEST |
@@ -304,7 +305,9 @@
                                     NULL, /* location_ext_parser */
                                     NULL, /* sv_ext_parser */
                                     callbacks->request_utc_time_cb, /* request_utc_time_cb */
-                                    };
+                                    callbacks->set_system_info_cb, /* set_system_info_cb */
+                                    callbacks->gnss_sv_status_cb, /* gnss_sv_status_cb */
+    };
 
     gps_loc_cb = callbacks->location_cb;
     gps_sv_cb = callbacks->sv_status_cb;
diff --git a/msm8996/loc_api/libloc_api_50001/loc.h b/msm8996/loc_api/libloc_api_50001/loc.h
index e56fdcf..02ca538 100644
--- a/msm8996/loc_api/libloc_api_50001/loc.h
+++ b/msm8996/loc_api/libloc_api_50001/loc.h
@@ -57,6 +57,8 @@
     loc_ext_parser location_ext_parser;
     loc_ext_parser sv_ext_parser;
     gps_request_utc_time request_utc_time_cb;
+    gnss_set_system_info set_system_info_cb;
+    gnss_sv_status_callback gnss_sv_status_cb;
 } LocCallbacks;
 
 #ifdef __cplusplus
diff --git a/msm8996/loc_api/libloc_api_50001/loc_eng.cpp b/msm8996/loc_api/libloc_api_50001/loc_eng.cpp
index 73b0226..e39242c 100644
--- a/msm8996/loc_api/libloc_api_50001/loc_eng.cpp
+++ b/msm8996/loc_api/libloc_api_50001/loc_eng.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2009-2016, The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -828,7 +828,7 @@
 
 //        case LOC_ENG_MSG_REPORT_SV:
 LocEngReportSv::LocEngReportSv(LocAdapterBase* adapter,
-                               QtiGnssSvStatus &sv,
+                               GnssSvStatus &sv,
                                GpsLocationExtended &locExtended,
                                void* svExt) :
     LocMsg(), mAdapter(adapter), mSvStatus(sv),
@@ -845,9 +845,9 @@
 
     if (locEng->mute_session_state != LOC_MUTE_SESS_IN_SESSION)
     {
-        if (locEng->sv_status_cb != NULL) {
-            locEng->sv_status_cb((GpsSvStatus*)&(mSvStatus),
-                                 (void*)mSvExt);
+        if (locEng->gnss_sv_status_cb != NULL) {
+            LOC_LOGE("Calling gnss_sv_status_cb");
+            locEng->gnss_sv_status_cb((GnssSvStatus*)&(mSvStatus));
         }
 
         if (locEng->generateNmea)
@@ -1377,6 +1377,33 @@
     }
 };
 
+struct LocEngSetSystemInfo : public LocMsg {
+    loc_eng_data_s_type* mLocEng;
+    inline LocEngSetSystemInfo(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_system_info_cb 0x%x",
+                mLocEng->adapter->mGnssInfo.year_of_hw);
+            mLocEng->set_system_info_cb(&(mLocEng->adapter->mGnssInfo));
+        }
+        else {
+            LOC_LOGV("set_system_info_cb is NULL.\n");
+        }
+    }
+    inline void locallog() const
+    {
+        LOC_LOGV("LocEngSetSystemInfo");
+    }
+    inline virtual void log() const
+    {
+        locallog();
+    }
+};
+
 //        case LOC_ENG_MSG_LOC_INIT:
 struct LocEngInit : public LocMsg {
     loc_eng_data_s_type* mLocEng;
@@ -1389,6 +1416,7 @@
         loc_eng_reinit(*mLocEng);
         // set the capabilities
         mLocEng->adapter->sendMsg(new LocEngSetCapabilities(mLocEng));
+        mLocEng->adapter->sendMsg(new LocEngSetSystemInfo(mLocEng));
     }
     inline void locallog() const
     {
@@ -1608,10 +1636,13 @@
         locallog();
     }
     inline virtual void proc() const {
+        mAdapter->mGnssInfo.size = sizeof(GnssSystemInfo);
         if (mAdapter->gnssConstellationConfig()) {
             LOC_LOGV("Modem supports GNSS measurements\n");
             gps_conf.CAPABILITIES |= GPS_CAPABILITY_MEASUREMENTS;
+            mAdapter->mGnssInfo.year_of_hw = 2016;
         } else {
+            mAdapter->mGnssInfo.year_of_hw = 2015;
             LOC_LOGV("Modem does not support GNSS measurements\n");
         }
     }
@@ -1624,50 +1655,59 @@
 };
 
 //        case LOC_ENG_MSG_REPORT_GNSS_MEASUREMENT:
-LocEngReportGpsMeasurement::LocEngReportGpsMeasurement(void* locEng,
-                                                       GpsData &gpsData) :
-    LocMsg(), mLocEng(locEng), mGpsData(gpsData)
+LocEngReportGnssMeasurement::LocEngReportGnssMeasurement(void* locEng,
+                                                       GnssData &gnssData) :
+    LocMsg(), mLocEng(locEng), mGnssData(gnssData)
 {
     locallog();
 }
-void LocEngReportGpsMeasurement::proc() const {
+void LocEngReportGnssMeasurement::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));
+        if (locEng->gnss_measurement_cb != NULL) {
+            LOC_LOGV("Calling gnss_measurement_cb");
+            locEng->gnss_measurement_cb((GnssData*)&(mGnssData));
         }
     }
 }
-void LocEngReportGpsMeasurement::locallog() const {
+void LocEngReportGnssMeasurement::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++) {
+                 __func__, __LINE__, mGnssData.measurement_count);
+        for (int i =0; i< mGnssData.measurement_count && i < GNSS_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 |"
+                         " GPS_HAL => Measurement ID | svid | time_offset_ns | state |"
+                         " 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",
+                         " GPS_HAL => %d | %d | %f | %d | %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);
+                         mGnssData.measurements[i].svid,
+                         mGnssData.measurements[i].time_offset_ns,
+                         mGnssData.measurements[i].state,
+                         mGnssData.measurements[i].c_n0_dbhz,
+                         mGnssData.measurements[i].pseudorange_rate_mps,
+                         mGnssData.measurements[i].pseudorange_rate_uncertainty_mps,
+                         mGnssData.measurements[i].accumulated_delta_range_state,
+                         mGnssData.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);
+        LOC_LOGV(" GPS_HAL => Clocks Info: \n"
+                 " time_ns | full_bias_ns | bias_ns | bias_uncertainty_ns | "
+                 " drift_nsps | drift_uncertainty_nsps | hw_clock_discontinuity_count | flags"
+                 " GPS_HAL => Clocks Info: %lld | %lld | %g | %g | %g | %g | %d | 0x%04x\n",
+            mGnssData.clock.time_ns,
+            mGnssData.clock.full_bias_ns,
+            mGnssData.clock.bias_ns,
+            mGnssData.clock.bias_uncertainty_ns,
+            mGnssData.clock.drift_nsps,
+            mGnssData.clock.drift_uncertainty_nsps,
+            mGnssData.clock.hw_clock_discontinuity_count,
+            mGnssData.clock.flags);
     }
 }
-inline void LocEngReportGpsMeasurement::log() const {
+inline void LocEngReportGnssMeasurement::log() const {
     locallog();
 }
 
@@ -1747,6 +1787,8 @@
     loc_eng_data.acquire_wakelock_cb = callbacks->acquire_wakelock_cb;
     loc_eng_data.release_wakelock_cb = callbacks->release_wakelock_cb;
     loc_eng_data.request_utc_time_cb = callbacks->request_utc_time_cb;
+    loc_eng_data.set_system_info_cb = callbacks->set_system_info_cb;
+    loc_eng_data.gnss_sv_status_cb = callbacks->gnss_sv_status_cb;
     loc_eng_data.location_ext_parser = callbacks->location_ext_parser ?
         callbacks->location_ext_parser : noProc;
     loc_eng_data.sv_ext_parser = callbacks->sv_ext_parser ?
@@ -1771,6 +1813,8 @@
         new LocEngAdapter(event, &loc_eng_data, context,
                           (LocThread::tCreate)callbacks->create_thread_cb);
 
+    loc_eng_data.adapter->mGnssInfo.size = sizeof(GnssSystemInfo);
+    loc_eng_data.adapter->mGnssInfo.year_of_hw = 2015;
     LOC_LOGD("loc_eng_init created client, id = %p\n",
              loc_eng_data.adapter);
     loc_eng_data.adapter->sendMsg(new LocEngInit(&loc_eng_data));
@@ -2942,8 +2986,8 @@
 {
     ENTRY_LOG_CALLFLOW();
 
-    STATE_CHECK((NULL == loc_eng_data.gps_measurement_cb),
-                "gps measurement already initialized",
+    STATE_CHECK((NULL == loc_eng_data.gnss_measurement_cb),
+                "gnss measurement already initialized",
                 return GPS_MEASUREMENT_ERROR_ALREADY_INIT);
     STATE_CHECK((callbacks != NULL),
                 "callbacks can not be NULL",
@@ -2959,7 +3003,7 @@
                                                         event,
                                                         LOC_REGISTRATION_MASK_ENABLED));
     // set up the callback
-    loc_eng_data.gps_measurement_cb = callbacks->measurement_callback;
+    loc_eng_data.gnss_measurement_cb = callbacks->gnss_measurement_callback;
     LOC_LOGD ("%s, event masks updated successfully", __func__);
 
     return GPS_MEASUREMENT_OPERATION_SUCCESS;
@@ -2994,6 +3038,6 @@
                                                           event,
                                                           LOC_REGISTRATION_MASK_DISABLED));
     // set up the callback
-    loc_eng_data.gps_measurement_cb = NULL;
+    loc_eng_data.gnss_measurement_cb = NULL;
     EXIT_LOG(%d, 0);
 }
diff --git a/msm8996/loc_api/libloc_api_50001/loc_eng.h b/msm8996/loc_api/libloc_api_50001/loc_eng.h
index a203e6b..5629ddd 100644
--- a/msm8996/loc_api/libloc_api_50001/loc_eng.h
+++ b/msm8996/loc_api/libloc_api_50001/loc_eng.h
@@ -94,7 +94,9 @@
     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;
+    gnss_set_system_info           set_system_info_cb;
+    gnss_sv_status_callback        gnss_sv_status_cb;
+    gnss_measurement_callback      gnss_measurement_cb;
     boolean                        intermediateFix;
     AGpsStatusValue                agps_status;
     loc_eng_xtra_data_s_type       xtra_module_data;
diff --git a/msm8996/loc_api/libloc_api_50001/loc_eng_msg.h b/msm8996/loc_api/libloc_api_50001/loc_eng_msg.h
index 31cf950..435ffbb 100644
--- a/msm8996/loc_api/libloc_api_50001/loc_eng_msg.h
+++ b/msm8996/loc_api/libloc_api_50001/loc_eng_msg.h
@@ -105,11 +105,11 @@
 
 struct LocEngReportSv : public LocMsg {
     LocAdapterBase* mAdapter;
-    const QtiGnssSvStatus mSvStatus;
+    const GnssSvStatus mSvStatus;
     const GpsLocationExtended mLocationExtended;
     const void* mSvExt;
     LocEngReportSv(LocAdapterBase* adapter,
-                   QtiGnssSvStatus &sv,
+                   GnssSvStatus &sv,
                    GpsLocationExtended &locExtended,
                    void* svExtended);
     virtual void proc() const;
@@ -289,11 +289,11 @@
     void send() const;
 };
 
-struct LocEngReportGpsMeasurement : public LocMsg {
+struct LocEngReportGnssMeasurement : public LocMsg {
     void* mLocEng;
-    const GpsData mGpsData;
-    LocEngReportGpsMeasurement(void* locEng,
-                               GpsData &gpsData);
+    const GnssData mGnssData;
+    LocEngReportGnssMeasurement(void* locEng,
+                               GnssData &gnssData);
     virtual void proc() const;
     void locallog() const;
     virtual void log() const;
diff --git a/msm8996/loc_api/libloc_api_50001/loc_eng_nmea.cpp b/msm8996/loc_api/libloc_api_50001/loc_eng_nmea.cpp
index aec4c91..424038c 100644
--- a/msm8996/loc_api/libloc_api_50001/loc_eng_nmea.cpp
+++ b/msm8996/loc_api/libloc_api_50001/loc_eng_nmea.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012, 2016, The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -29,10 +29,6 @@
 
 #define LOG_NDDEBUG 0
 #define LOG_TAG "LocSvc_eng_nmea"
-#define GPS_PRN_START 1
-#define GPS_PRN_END   32
-#define GLONASS_PRN_START 65
-#define GLONASS_PRN_END   96
 #include <loc_eng.h>
 #include <loc_eng_nmea.h>
 #include <math.h>
@@ -605,7 +601,7 @@
 
 ===========================================================================*/
 void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p,
-                              const QtiGnssSvStatus &svStatus, const GpsLocationExtended &locationExtended)
+                              const GnssSvStatus &svStatus, const GpsLocationExtended &locationExtended)
 {
     ENTRY_LOG();
 
@@ -622,14 +618,19 @@
 
     //Count GPS SVs for saparating GPS from GLONASS and throw others
 
+    loc_eng_data_p->sv_used_mask = 0;
     for(svNumber=1; svNumber <= svCount; svNumber++) {
-        if( (svStatus.sv_list[svNumber-1].prn >= GPS_PRN_START)&&
-            (svStatus.sv_list[svNumber-1].prn <= GPS_PRN_END) )
+        if (GNSS_CONSTELLATION_GPS == svStatus.gnss_sv_list[svNumber - 1].constellation)
         {
+            // cache the used in fix mask, as it will be needed to send $GPGSA
+            // during the position report
+            if (GNSS_SV_FLAGS_USED_IN_FIX == (svStatus.gnss_sv_list[svNumber - 1].flags & GNSS_SV_FLAGS_USED_IN_FIX))
+            {
+                loc_eng_data_p->sv_used_mask |= (1 << (svStatus.gnss_sv_list[svNumber - 1].svid - 1));
+            }
             gpsCount++;
         }
-        else if( (svStatus.sv_list[svNumber-1].prn >= GLONASS_PRN_START) &&
-                 (svStatus.sv_list[svNumber-1].prn <= GLONASS_PRN_END) )
+        else if (GNSS_CONSTELLATION_GLONASS == svStatus.gnss_sv_list[svNumber - 1].constellation)
         {
             glnCount++;
         }
@@ -670,13 +671,12 @@
 
             for (int i=0; (svNumber <= svCount) && (i < 4);  svNumber++)
             {
-                if( (svStatus.sv_list[svNumber-1].prn >= GPS_PRN_START) &&
-                    (svStatus.sv_list[svNumber-1].prn <= GPS_PRN_END) )
+                if (GNSS_CONSTELLATION_GPS == svStatus.gnss_sv_list[svNumber - 1].constellation)
                 {
                     length = snprintf(pMarker, lengthRemaining,",%02d,%02d,%03d,",
-                                  svStatus.sv_list[svNumber-1].prn,
-                                  (int)(0.5 + svStatus.sv_list[svNumber-1].elevation), //float to int
-                                  (int)(0.5 + svStatus.sv_list[svNumber-1].azimuth)); //float to int
+                                      svStatus.gnss_sv_list[svNumber-1].svid,
+                                      (int)(0.5 + svStatus.gnss_sv_list[svNumber-1].elevation), //float to int
+                                      (int)(0.5 + svStatus.gnss_sv_list[svNumber-1].azimuth)); //float to int
 
                     if (length < 0 || length >= lengthRemaining)
                     {
@@ -686,10 +686,10 @@
                     pMarker += length;
                     lengthRemaining -= length;
 
-                    if (svStatus.sv_list[svNumber-1].snr > 0)
+                    if (svStatus.gnss_sv_list[svNumber-1].c_n0_dbhz > 0)
                     {
                         length = snprintf(pMarker, lengthRemaining,"%02d",
-                                         (int)(0.5 + svStatus.sv_list[svNumber-1].snr)); //float to int
+                                         (int)(0.5 + svStatus.gnss_sv_list[svNumber-1].c_n0_dbhz)); //float to int
 
                         if (length < 0 || length >= lengthRemaining)
                         {
@@ -699,10 +699,8 @@
                         pMarker += length;
                         lengthRemaining -= length;
                     }
-
                     i++;
-               }
-
+                }
             }
 
             length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
@@ -748,13 +746,12 @@
 
             for (int i=0; (svNumber <= svCount) && (i < 4);  svNumber++)
             {
-                if( (svStatus.sv_list[svNumber-1].prn >= GLONASS_PRN_START) &&
-                    (svStatus.sv_list[svNumber-1].prn <= GLONASS_PRN_END) )      {
-
-                    length = snprintf(pMarker, lengthRemaining,",%02d,%02d,%03d,",
-                                  svStatus.sv_list[svNumber-1].prn,
-                                  (int)(0.5 + svStatus.sv_list[svNumber-1].elevation), //float to int
-                                  (int)(0.5 + svStatus.sv_list[svNumber-1].azimuth)); //float to int
+                if (GNSS_CONSTELLATION_GLONASS == svStatus.gnss_sv_list[svNumber - 1].constellation)
+                {
+                    length = snprintf(pMarker, lengthRemaining, ",%02d,%02d,%03d,",
+                        svStatus.gnss_sv_list[svNumber - 1].svid,
+                        (int)(0.5 + svStatus.gnss_sv_list[svNumber - 1].elevation), //float to int
+                        (int)(0.5 + svStatus.gnss_sv_list[svNumber - 1].azimuth)); //float to int
 
                     if (length < 0 || length >= lengthRemaining)
                     {
@@ -764,10 +761,10 @@
                     pMarker += length;
                     lengthRemaining -= length;
 
-                    if (svStatus.sv_list[svNumber-1].snr > 0)
+                    if (svStatus.gnss_sv_list[svNumber - 1].c_n0_dbhz > 0)
                     {
-                        length = snprintf(pMarker, lengthRemaining,"%02d",
-                                         (int)(0.5 + svStatus.sv_list[svNumber-1].snr)); //float to int
+                        length = snprintf(pMarker, lengthRemaining, "%02d",
+                            (int)(0.5 + svStatus.gnss_sv_list[svNumber - 1].c_n0_dbhz)); //float to int
 
                         if (length < 0 || length >= lengthRemaining)
                         {
@@ -779,8 +776,7 @@
                     }
 
                     i++;
-               }
-
+                }
             }
 
             length = loc_eng_nmea_put_checksum(sentence, sizeof(sentence));
@@ -791,10 +787,6 @@
 
     }//if
 
-    // cache the used in fix mask, as it will be needed to send $GPGSA
-    // during the position report
-    loc_eng_data_p->sv_used_mask = svStatus.gps_used_in_fix_mask;
-
     // For RPC, the DOP are sent during sv report, so cache them
     // now to be sent during position report.
     // For QMI, the DOP will be in position report.
diff --git a/msm8996/loc_api/libloc_api_50001/loc_eng_nmea.h b/msm8996/loc_api/libloc_api_50001/loc_eng_nmea.h
index f7ef7fb..066943a 100644
--- a/msm8996/loc_api/libloc_api_50001/loc_eng_nmea.h
+++ b/msm8996/loc_api/libloc_api_50001/loc_eng_nmea.h
@@ -37,7 +37,7 @@
 
 void loc_eng_nmea_send(char *pNmea, int length, loc_eng_data_s_type *loc_eng_data_p);
 int loc_eng_nmea_put_checksum(char *pNmea, int maxSize);
-void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p, const QtiGnssSvStatus &svStatus, const GpsLocationExtended &locationExtended);
+void loc_eng_nmea_generate_sv(loc_eng_data_s_type *loc_eng_data_p, const GnssSvStatus &svStatus, const GpsLocationExtended &locationExtended);
 void loc_eng_nmea_generate_pos(loc_eng_data_s_type *loc_eng_data_p, const UlpLocation &location, const GpsLocationExtended &locationExtended, unsigned char generate_nmea);
 
 #endif // LOC_ENG_NMEA_H