Snap for 8558685 from 006bcc84252ab45226cf61c7ad4f0dbca200cfb7 to tm-frc-extservices-release

Change-Id: Iab0ea1bedef6563a77ce94552fc6f7a8340819a0
diff --git a/Android.bp b/Android.bp
index 12d580a..3c3e893 100644
--- a/Android.bp
+++ b/Android.bp
@@ -48,18 +48,6 @@
     "-Wno-error=date-time",
 ]
 
-/* Activate the following for regression testing */
-GNSS_SANITIZE = {
-/*  address: true,*/
-    cfi: true,
-    misc_undefined: [
-        "bounds",
-        "null",
-        "unreachable",
-        "integer",
-    ],
-}
-
 /* Activate the following for debug purposes only,
    comment out for production */
 GNSS_SANITIZE_DIAG = {
diff --git a/Android.mk b/Android.mk
index 77d61c9..88bb0f4 100644
--- a/Android.mk
+++ b/Android.mk
@@ -36,9 +36,6 @@
 LOCAL_PATH := $(call my-dir)
 include $(call all-makefiles-under,$(LOCAL_PATH))
 
-GNSS_SANITIZE := cfi bounds null unreachable integer
-# Activate the following two lines for regression testing
-#GNSS_SANITIZE += address
-#GNSS_SANITIZE_DIAG := $(GNSS_SANITIZE)
+GNSS_SANITIZE_DIAG := cfi bounds null unreachable integer address
 
 endif # ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
diff --git a/android/1.0/Android.mk b/android/1.0/Android.mk
index 90bc754..27c697b 100644
--- a/android/1.0/Android.mk
+++ b/android/1.0/Android.mk
@@ -4,7 +4,6 @@
 LOCAL_MODULE := android.hardware.gnss@1.0-impl-qti
 LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD legacy_not_a_contribution
 LOCAL_LICENSE_CONDITIONS := by_exception_only not_allowed notice
-LOCAL_SANITIZE += $(GNSS_SANITIZE)
 # activate the following line for debug purposes only, comment out for production
 #LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG)
 LOCAL_VENDOR_MODULE := true
@@ -63,7 +62,6 @@
 LOCAL_MODULE := android.hardware.gnss@1.0-service-qti
 LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD legacy_not_a_contribution
 LOCAL_LICENSE_CONDITIONS := by_exception_only not_allowed notice
-LOCAL_SANITIZE += $(GNSS_SANITIZE)
 # activate the following line for debug purposes only, comment out for production
 #LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG)
 LOCAL_VINTF_FRAGMENTS := android.hardware.gnss@1.0-service-qti.xml
diff --git a/android/1.1/Android.mk b/android/1.1/Android.mk
index 2ddb513..0a8f1d3 100644
--- a/android/1.1/Android.mk
+++ b/android/1.1/Android.mk
@@ -4,7 +4,6 @@
 LOCAL_MODULE := android.hardware.gnss@1.1-impl-qti
 LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD legacy_not_a_contribution
 LOCAL_LICENSE_CONDITIONS := by_exception_only not_allowed notice
-LOCAL_SANITIZE += $(GNSS_SANITIZE)
 # activate the following line for debug purposes only, comment out for production
 #LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG)
 LOCAL_VENDOR_MODULE := true
@@ -64,7 +63,6 @@
 LOCAL_MODULE := android.hardware.gnss@1.1-service-qti
 LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD legacy_not_a_contribution
 LOCAL_LICENSE_CONDITIONS := by_exception_only not_allowed notice
-LOCAL_SANITIZE += $(GNSS_SANITIZE)
 # activate the following line for debug purposes only, comment out for production
 #LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG)
 LOCAL_VINTF_FRAGMENTS := android.hardware.gnss@1.1-service-qti.xml
diff --git a/android/2.0/Android.mk b/android/2.0/Android.mk
index 73c287b..a0af746 100644
--- a/android/2.0/Android.mk
+++ b/android/2.0/Android.mk
@@ -4,7 +4,6 @@
 LOCAL_MODULE := android.hardware.gnss@2.0-impl-qti
 LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD legacy_not_a_contribution
 LOCAL_LICENSE_CONDITIONS := by_exception_only not_allowed notice
-LOCAL_SANITIZE += $(GNSS_SANITIZE)
 # activate the following line for debug purposes only, comment out for production
 #LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG)
 LOCAL_VENDOR_MODULE := true
@@ -75,7 +74,6 @@
 LOCAL_MODULE := android.hardware.gnss@2.0-service-qti
 LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD legacy_not_a_contribution
 LOCAL_LICENSE_CONDITIONS := by_exception_only not_allowed notice
-LOCAL_SANITIZE += $(GNSS_SANITIZE)
 # activate the following line for debug purposes only, comment out for production
 #LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG)
 LOCAL_VINTF_FRAGMENTS := android.hardware.gnss@2.0-service-qti.xml
diff --git a/android/2.1/Android.mk b/android/2.1/Android.mk
index 79f3273..6bd2be1 100644
--- a/android/2.1/Android.mk
+++ b/android/2.1/Android.mk
@@ -4,7 +4,6 @@
 LOCAL_MODULE := android.hardware.gnss@2.1-impl-qti
 LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD legacy_not_a_contribution
 LOCAL_LICENSE_CONDITIONS := by_exception_only not_allowed notice
-LOCAL_SANITIZE += $(GNSS_SANITIZE)
 # activate the following line for debug purposes only, comment out for production
 #LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG)
 LOCAL_VENDOR_MODULE := true
@@ -78,7 +77,6 @@
 LOCAL_MODULE := android.hardware.gnss@2.1-service-qti
 LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD legacy_not_a_contribution
 LOCAL_LICENSE_CONDITIONS := by_exception_only not_allowed notice
-LOCAL_SANITIZE += $(GNSS_SANITIZE)
 # activate the following line for debug purposes only, comment out for production
 #LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG)
 LOCAL_VINTF_FRAGMENTS := android.hardware.gnss@2.1-service-qti.xml
diff --git a/android/utils/Android.bp b/android/utils/Android.bp
index d887eb0..dcbff22 100644
--- a/android/utils/Android.bp
+++ b/android/utils/Android.bp
@@ -12,7 +12,7 @@
     name: "liblocbatterylistener",
     vendor: true,
 
-    sanitize: GNSS_SANITIZE,
+
 
     cflags: GNSS_CFLAGS + ["-DBATTERY_LISTENER_ENABLED"],
     local_include_dirs: ["."],
diff --git a/batching/Android.bp b/batching/Android.bp
index b7d84de..7b1f8ba 100644
--- a/batching/Android.bp
+++ b/batching/Android.bp
@@ -13,7 +13,7 @@
     name: "libbatching",
     vendor: true,
 
-    sanitize: GNSS_SANITIZE,
+
 
     shared_libs: [
         "libutils",
diff --git a/batching/BatchingAdapter.cpp b/batching/BatchingAdapter.cpp
index d9f7945..4f1a43c 100644
--- a/batching/BatchingAdapter.cpp
+++ b/batching/BatchingAdapter.cpp
@@ -37,7 +37,9 @@
 using namespace loc_core;
 
 BatchingAdapter::BatchingAdapter() :
-    LocAdapterBase(0, LocContext::getLocContext(LocContext::mLocationHalName)),
+    LocAdapterBase(0,
+                   LocContext::getLocContext(LocContext::mLocationHalName),
+                   false, nullptr, true),
     mOngoingTripDistance(0),
     mOngoingTripTBFInterval(0),
     mTripWithOngoingTBFDropped(false),
@@ -50,6 +52,10 @@
     LOC_LOGD("%s]: Constructor", __func__);
     readConfigCommand();
     setConfigCommand();
+
+    // at last step, let us inform adapater base that we are done
+    // with initialization, e.g.: ready to process handleEngineUpEvent
+    doneInit();
 }
 
 void
diff --git a/core/Android.bp b/core/Android.bp
index a41032f..2d9a804 100644
--- a/core/Android.bp
+++ b/core/Android.bp
@@ -13,7 +13,7 @@
     name: "libloc_core",
     vendor: true,
 
-    sanitize: GNSS_SANITIZE,
+
 
     shared_libs: [
         "liblog",
diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp
index 6a0ff84..860da2e 100644
--- a/core/LocApiBase.cpp
+++ b/core/LocApiBase.cpp
@@ -1034,7 +1034,7 @@
     struct timespec sinceBootTime;
     struct timespec sinceBootTimeTest;
     bool clockGetTimeSuccess = false;
-    const uint32_t MAX_TIME_DELTA_VALUE_NANOS = 10000;
+    const uint32_t MAX_TIME_DELTA_VALUE_NANOS = 15000;
     const uint32_t MAX_GET_TIME_COUNT = 20;
     /* Attempt to get CLOCK_REALTIME and CLOCK_BOOTIME in succession without an interruption
     or context switch (for up to MAX_GET_TIME_COUNT times) to avoid errors in the calculation */
diff --git a/core/LocApiBase.h b/core/LocApiBase.h
index 121f795..cbe5f9f 100644
--- a/core/LocApiBase.h
+++ b/core/LocApiBase.h
@@ -101,6 +101,7 @@
     inline virtual void* getSibling2() { return NULL; }
     inline virtual double getGloRfLoss(uint32_t left,
             uint32_t center, uint32_t right, uint8_t gloFrequency) { return 0.0; }
+    inline virtual float getGeoidalSeparation(double latitude, double longitude) { return 0.0; }
 };
 
 class LocApiBase {
diff --git a/core/SystemStatus.cpp b/core/SystemStatus.cpp
index d792577..fe11de0 100644
--- a/core/SystemStatus.cpp
+++ b/core/SystemStatus.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-2021, 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
@@ -1586,6 +1586,7 @@
             break;
     }
     pthread_mutex_unlock(&mMutexSystemStatus);
+    LOC_LOGv("DataItemId: %d, whether to record dateitem in cache: %d", dataitem->getId(), ret);
     return ret;
 }
 
diff --git a/core/SystemStatus.h b/core/SystemStatus.h
index 2720c96..21036cd 100644
--- a/core/SystemStatus.h
+++ b/core/SystemStatus.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-2021, 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
@@ -509,9 +509,11 @@
         for (uint8_t i = 0; rtv && i < MAX_NETWORK_HANDLES; ++i) {
             rtv &= (mAllNetworkHandles[i] == peer.mAllNetworkHandles[i]);
         }
-        return peer.mApn.compare(mApn);
+        return rtv && !peer.mApn.compare(mApn);
     }
     inline virtual SystemStatusItemBase& collate(SystemStatusItemBase& curInfo) {
+        LOC_LOGv("NetworkInfo: mAllTypes=%" PRIx64 " connected=%u mType=%x mApn=%s",
+                 mAllTypes, mConnected, mType, mApn.c_str());
         uint64_t allTypes = (static_cast<SystemStatusNetworkInfo&>(curInfo)).mAllTypes;
         string& apn = (static_cast<SystemStatusNetworkInfo&>(curInfo)).mApn;
         // Replace current with cached table for now and then update
diff --git a/etc/gnss_antenna_info.conf b/etc/gnss_antenna_info.conf
index 79a2aef..e037daa 100644
--- a/etc/gnss_antenna_info.conf
+++ b/etc/gnss_antenna_info.conf
@@ -80,7 +80,8 @@
 # NUMBER_OF_ROWS_SGC_ and NUMBER_OF_COLUMNS_SGC_ represent the number of
 # rows/columns for signal gain corrections
 
-ANTENNA_INFO_VECTOR_SIZE = 2
+# ANTENNA_INFO_VECTOR_SIZE must be non zero if antenna corrections are sent
+# ANTENNA_INFO_VECTOR_SIZE = 2
 
 CARRIER_FREQUENCY_0 = 1575.42
 
diff --git a/etc/seccomp_policy/gnss@2.0-base.policy b/etc/seccomp_policy/gnss@2.0-base.policy
index 7b93037..0a2e17b 100644
--- a/etc/seccomp_policy/gnss@2.0-base.policy
+++ b/etc/seccomp_policy/gnss@2.0-base.policy
@@ -93,3 +93,27 @@
 sendto: 1
 recvfrom: 1
 
+getsockname: 1
+nanosleep: 1
+clone: 1
+setsockopt: 1
+getsockopt: 1
+madvise: 1
+
+getitimer: 1
+setitimer: 1
+getpid: 1
+bind: 1
+listen: 1
+getpeername: 1
+socketpair: 1
+wait4: 1
+chown: 1
+fchown: 1
+lchown: 1
+umask: 1
+mmap2: 1
+fstat64: 1
+fstatat64: 1
+_llseek: 1
+geteuid: 1
diff --git a/etc/seccomp_policy/gnss@2.0-xtwifi-client.policy b/etc/seccomp_policy/gnss@2.0-xtwifi-client.policy
index 17df31a..38a41f9 100644
--- a/etc/seccomp_policy/gnss@2.0-xtwifi-client.policy
+++ b/etc/seccomp_policy/gnss@2.0-xtwifi-client.policy
@@ -32,7 +32,7 @@
 fdatasync: 1
 getdents64: 1
 gettimeofday: 1
-#ioctl: arg1 == _IOC(_IOC_NONE || arg1 == _IOC(_IOC_READ || arg1 == VSOC_MAYBE_SEND_INTERRUPT_TO_HOST
+ioctl: 1
 lseek: 1
 madvise: 1
 mkdirat: 1
@@ -43,3 +43,31 @@
 epoll_create1: 1
 epoll_pwait: 1
 epoll_ctl: 1
+
+sched_getaffinity: 1
+gettid: 1
+fchown: 1
+fchmod: 1
+fchmodat: 1
+getsockopt: 1
+fchownat: 1
+fstat: 1
+fstatfs: 1
+newfstatat: 1
+sendmsg: 1
+recvmsg: 1
+gettimeofday: 1
+setsockopt: 1
+rt_tgsigqueueinfo: 1
+ioctl: 1
+mmap: 1
+getuid32: 1
+getuid: 1
+fstat64: 1
+fstatat64: 1
+mkdir: 1
+rmdir: 1
+creat: 1
+chmod: 1
+lseek: 1
+geteuid32: 1
diff --git a/etc/seccomp_policy/gnss@2.0-xtwifi-inet-agent.policy b/etc/seccomp_policy/gnss@2.0-xtwifi-inet-agent.policy
index 00df6c7..024600a 100644
--- a/etc/seccomp_policy/gnss@2.0-xtwifi-inet-agent.policy
+++ b/etc/seccomp_policy/gnss@2.0-xtwifi-inet-agent.policy
@@ -31,3 +31,13 @@
 
 unlinkat: 1
 sched_getaffinity: 1
+newfstatat: 1
+fchmodat: 1
+madvise: 1
+mmap: 1
+getuid: 1
+getuid32: 1
+fstat64: 1
+fstatat64: 1
+gettimeofday: 1
+getdents64: 1
diff --git a/geofence/Android.bp b/geofence/Android.bp
index eedd286..1c57f24 100644
--- a/geofence/Android.bp
+++ b/geofence/Android.bp
@@ -14,7 +14,7 @@
     name: "libgeofencing",
     vendor: true,
 
-    sanitize: GNSS_SANITIZE,
+
 
     srcs: [
         "GeofenceAdapter.cpp",
diff --git a/geofence/GeofenceAdapter.cpp b/geofence/GeofenceAdapter.cpp
index f024e3f..1aeea0a 100644
--- a/geofence/GeofenceAdapter.cpp
+++ b/geofence/GeofenceAdapter.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2020, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2021, 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
@@ -38,9 +38,13 @@
 GeofenceAdapter::GeofenceAdapter() :
     LocAdapterBase(0,
                    LocContext::getLocContext(LocContext::mLocationHalName),
-                   true /*isMaster*/)
+                   true /*isMaster*/, nullptr, true)
 {
     LOC_LOGD("%s]: Constructor", __func__);
+
+    // at last step, let us inform adapater base that we are done
+    // with initialization, e.g.: ready to process handleEngineUpEvent
+    doneInit();
 }
 
 void
diff --git a/gnss/Agps.cpp b/gnss/Agps.cpp
index 4344a6f..0b95f99 100644
--- a/gnss/Agps.cpp
+++ b/gnss/Agps.cpp
@@ -590,7 +590,7 @@
     sm->setApnTypeMask(apnTypeMask);
 
     /* Invoke AGPS SM processing */
-    AgpsSubscriber subscriber(connHandle, false, false, apnTypeMask);
+    AgpsSubscriber subscriber(connHandle, true, false, apnTypeMask);
     sm->setCurrentSubscriber(&subscriber);
     /* Send subscriber event */
     sm->processAgpsEvent(AGPS_EVENT_SUBSCRIBE);
diff --git a/gnss/Android.bp b/gnss/Android.bp
index 227ddc1..97c0efe 100644
--- a/gnss/Android.bp
+++ b/gnss/Android.bp
@@ -14,7 +14,7 @@
     name: "libgnss",
     vendor: true,
 
-    sanitize: GNSS_SANITIZE,
+
 
     shared_libs: [
         "libutils",
diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp
index daca704..c9ea7ca 100644
--- a/gnss/GnssAdapter.cpp
+++ b/gnss/GnssAdapter.cpp
@@ -77,6 +77,8 @@
 
 typedef const CdfwInterface* (*getCdfwInterface)();
 
+typedef void getPdnTypeFromWds(const std::string& apnName, std::function<void(int)> pdnCb);
+
 inline bool GnssReportLoggerUtil::isLogEnabled() {
     return (mLogLatency != nullptr);
 }
@@ -889,6 +891,8 @@
                       ContextBase::mGps_conf.MO_SUPL_PORT,
                       LOC_AGPS_MO_SUPL_SERVER);
 
+    std::string moServerUrl = getMoServerUrl();
+    std::string serverUrl = getServerUrl();
     // inject the configurations into modem
     loc_gps_cfg_s gpsConf = ContextBase::mGps_conf;
     loc_sap_cfg_s_type sapConf = ContextBase::mSap_conf;
@@ -936,8 +940,10 @@
     gnssConfigRequested.blacklistedSvIds.assign(mBlacklistedSvIds.begin(),
                                                 mBlacklistedSvIds.end());
     mLocApi->sendMsg(new LocApiMsg(
-            [this, gpsConf, sapConf, oldMoServerUrl, gnssConfigRequested] () mutable {
-        gnssUpdateConfig(oldMoServerUrl, gnssConfigRequested, gnssConfigRequested);
+            [this, gpsConf, sapConf, oldMoServerUrl, moServerUrl,
+            serverUrl, gnssConfigRequested] () mutable {
+        gnssUpdateConfig(oldMoServerUrl, moServerUrl, serverUrl,
+                gnssConfigRequested, gnssConfigRequested);
 
         // set nmea mask type
         uint32_t mask = 0;
@@ -1025,6 +1031,7 @@
 }
 
 std::vector<LocationError> GnssAdapter::gnssUpdateConfig(const std::string& oldMoServerUrl,
+        const std::string& moServerUrl, const std::string& serverUrl,
         GnssConfig& gnssConfigRequested, GnssConfig& gnssConfigNeedEngineUpdate, size_t count) {
     loc_gps_cfg_s gpsConf = ContextBase::mGps_conf;
     size_t index = 0;
@@ -1034,9 +1041,6 @@
         errsList.insert(errsList.begin(), count, LOCATION_ERROR_SUCCESS);
     }
 
-    std::string serverUrl = getServerUrl();
-    std::string moServerUrl = getMoServerUrl();
-
     int serverUrlLen = serverUrl.length();
     int moServerUrlLen = moServerUrl.length();
 
@@ -1428,10 +1432,14 @@
                     adapter.reportResponse(countOfConfigs, errs.data(), ids.data());
             });
 
+            std::string moServerUrl = adapter.getMoServerUrl();
+            std::string serverUrl = adapter.getServerUrl();
             mApi.sendMsg(new LocApiMsg(
                     [&adapter, gnssConfigRequested, gnssConfigNeedEngineUpdate,
-                    countOfConfigs, configCollectiveResponse, errs] () mutable {
+                    moServerUrl, serverUrl, countOfConfigs, configCollectiveResponse,
+                    errs] () mutable {
                 std::vector<LocationError> errsList = adapter.gnssUpdateConfig("",
+                        moServerUrl, serverUrl,
                         gnssConfigRequested, gnssConfigNeedEngineUpdate, countOfConfigs);
 
                 configCollectiveResponse->returnToSender(errsList);
@@ -5218,6 +5226,38 @@
     return true;
 }
 
+void GnssAdapter::reportPdnTypeFromWds(int pdnType, AGpsExtType agpsType, std::string apnName,
+        AGpsBearerType bearerType) {
+    LOC_LOGd("pdnType from WDS QMI: %d, agpsType: %d, apnName: %s, bearerType: %d",
+            pdnType, agpsType, apnName.c_str(), bearerType);
+
+    struct MsgReportAtlPdn : public LocMsg {
+        GnssAdapter& mAdapter;
+        int mPdnType;
+        AgpsManager* mAgpsManager;
+        AGpsExtType mAgpsType;
+        string mApnName;
+        AGpsBearerType mBearerType;
+
+        inline MsgReportAtlPdn(GnssAdapter& adapter, int pdnType,
+                AgpsManager* agpsManager, AGpsExtType agpsType,
+                const string& apnName, AGpsBearerType bearerType) :
+            LocMsg(), mAgpsManager(agpsManager), mAgpsType(agpsType),
+            mApnName(apnName), mBearerType(bearerType),
+            mAdapter(adapter), mPdnType(pdnType) {}
+        inline virtual void proc() const {
+            mAgpsManager->reportAtlOpenSuccess(mAgpsType,
+                    const_cast<char*>(mApnName.c_str()),
+                    mApnName.length(), mPdnType<=0? mBearerType:mPdnType);
+        }
+    };
+
+    AGpsBearerType atlPdnType = (pdnType+1) & 3; // convert WDS QMI pdn type to AgpsBearerType
+    sendMsg(new MsgReportAtlPdn(*this, atlPdnType, &mAgpsManager,
+                agpsType, apnName, bearerType));
+}
+
+
 void GnssAdapter::dataConnOpenCommand(
         AGpsExtType agpsType,
         const char* apnName, int apnLen, AGpsBearerType bearerType){
@@ -5225,17 +5265,16 @@
     LOC_LOGI("GnssAdapter::frameworkDataConnOpen");
 
     struct AgpsMsgAtlOpenSuccess: public LocMsg {
-
+        GnssAdapter& mAdapter;
         AgpsManager* mAgpsManager;
         AGpsExtType mAgpsType;
         char* mApnName;
-        int mApnLen;
         AGpsBearerType mBearerType;
 
-        inline AgpsMsgAtlOpenSuccess(AgpsManager* agpsManager, AGpsExtType agpsType,
-                const char* apnName, int apnLen, AGpsBearerType bearerType) :
+        inline AgpsMsgAtlOpenSuccess(GnssAdapter& adapter, AgpsManager* agpsManager,
+                AGpsExtType agpsType, const char* apnName, int apnLen, AGpsBearerType bearerType) :
                 LocMsg(), mAgpsManager(agpsManager), mAgpsType(agpsType), mApnName(
-                        new char[apnLen + 1]), mApnLen(apnLen), mBearerType(bearerType) {
+                        new char[apnLen + 1]), mBearerType(bearerType), mAdapter(adapter) {
 
             LOC_LOGV("AgpsMsgAtlOpenSuccess");
             if (mApnName == nullptr) {
@@ -5253,9 +5292,27 @@
         }
 
         inline virtual void proc() const {
+            LOC_LOGv("AgpsMsgAtlOpenSuccess::proc()");
+            string apn(mApnName);
+            //Use QMI WDS API to query IP Protocol from modem profile
+            void* libHandle = nullptr;
+            getPdnTypeFromWds* getPdnTypeFunc = (getPdnTypeFromWds*)dlGetSymFromLib(libHandle,
+            #ifdef USE_GLIB
+                    "libloc_api_wds.so", "_Z10getPdnTypeRKNSt7__cxx1112basic_string"\
+                    "IcSt11char_traitsIcESaIcEEESt8functionIFviEE");
+            #else
+                    "libloc_api_wds.so", "_Z10getPdnTypeRKNSt3__112basic_stringIcNS_11char_traits"\
+                    "IcEENS_9allocatorIcEEEENS_8functionIFviEEE");
+            #endif
 
-            LOC_LOGV("AgpsMsgAtlOpenSuccess::proc()");
-            mAgpsManager->reportAtlOpenSuccess(mAgpsType, mApnName, mApnLen, mBearerType);
+            std::function<void(int)> wdsPdnTypeCb = std::bind(&GnssAdapter::reportPdnTypeFromWds,
+                    &mAdapter, std::placeholders::_1, mAgpsType, apn, mBearerType);
+           if (getPdnTypeFunc != nullptr) {
+               LOC_LOGv("dlGetSymFromLib success");
+               (*getPdnTypeFunc)(apn, wdsPdnTypeCb);
+           } else {
+               mAgpsManager->reportAtlOpenSuccess(mAgpsType, mApnName, apn.length(), mBearerType);
+           }
         }
     };
     // Added inital length checks for apnlen check to avoid security issues
@@ -5264,7 +5321,7 @@
         LOC_LOGe("%s]: incorrect apnlen length or incorrect apnName", __func__);
         mAgpsManager.reportAtlClosed(agpsType);
     } else {
-        sendMsg( new AgpsMsgAtlOpenSuccess(
+        sendMsg( new AgpsMsgAtlOpenSuccess(*this,
                     &mAgpsManager, agpsType, apnName, apnLen, bearerType));
     }
 }
@@ -6714,8 +6771,9 @@
         }
         gnssAntennaInformations.push_back(std::move(gnssAntennaInfo));
     }
-    if (antennaInfoVectorSize > 0)
+    if (antennaInfoVectorSize > 0) {
         antennaInfoCallback(gnssAntennaInformations);
+    }
 }
 
 /* ==== DGnss Usable Reporter ========================================================= */
@@ -6752,10 +6810,15 @@
                                               bool enableRTKEngine) {
 
     (void)enableRTKEngine; //future parameter, not used
+    if (0 == params.size || params.hostNameOrIp.empty() || params.mountPoint.empty() ||
+            params.username.empty() || params.password.empty()) {
+        LOC_LOGe("Ntrip parameters are invalid!");
+        return;
+    }
 
     struct enableNtripMsg : public LocMsg {
         GnssAdapter& mAdapter;
-        const GnssNtripConnectionParams& mParams;
+        const GnssNtripConnectionParams mParams;
 
         inline enableNtripMsg(GnssAdapter& adapter,
                 const GnssNtripConnectionParams& params) :
diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h
index 6b8d024..d7b4275 100644
--- a/gnss/GnssAdapter.h
+++ b/gnss/GnssAdapter.h
@@ -321,7 +321,6 @@
     void logLatencyInfo();
 
 public:
-
     GnssAdapter();
     virtual inline ~GnssAdapter() { }
 
@@ -409,6 +408,8 @@
     void deleteAidingData(const GnssAidingData &data, uint32_t sessionId);
     void gnssUpdateXtraThrottleCommand(const bool enabled);
     std::vector<LocationError> gnssUpdateConfig(const std::string& oldMoServerUrl,
+            const std::string& moServerUrl,
+            const std::string& serverUrl,
             GnssConfig& gnssConfigRequested,
             GnssConfig& gnssConfigNeedEngineUpdate, size_t count = 0);
 
@@ -525,6 +526,8 @@
     (
         const std::unordered_map<LocationQwesFeatureType, bool> &featureMap
     );
+    void reportPdnTypeFromWds(int pdnType, AGpsExtType agpsType, std::string apnName,
+            AGpsBearerType bearerType);
 
     /* ======== UTILITIES ================================================================= */
     bool needReportForGnssClient(const UlpLocation& ulpLocation,
diff --git a/gnss/location_gnss.cpp b/gnss/location_gnss.cpp
index 0454a13..8f67369 100644
--- a/gnss/location_gnss.cpp
+++ b/gnss/location_gnss.cpp
@@ -519,7 +519,7 @@
 static void antennaInfoClose() {
     if (NULL != gGnssAdapter) {
         return gGnssAdapter->antennaInfoCloseCommand();
-	}
+    }
 }
 
 static uint32_t configRobustLocation(bool enable, bool enableForE911){
diff --git a/gps_vendor_product.mk b/gps_vendor_product.mk
index 0e578e8..cd35684 100644
--- a/gps_vendor_product.mk
+++ b/gps_vendor_product.mk
@@ -27,6 +27,10 @@
 PRODUCT_PACKAGES += gps.conf
 PRODUCT_PACKAGES += flp.conf
 PRODUCT_PACKAGES += gnss_antenna_info.conf
+PRODUCT_PACKAGES += gnss@2.0-base.policy
+PRODUCT_PACKAGES += gnss@2.0-xtra-daemon.policy
+PRODUCT_PACKAGES += gnss@2.0-xtwifi-client.policy
+PRODUCT_PACKAGES += gnss@2.0-xtwifi-inet-agent.policy
 PRODUCT_PACKAGES += libloc_pla_headers
 PRODUCT_PACKAGES += liblocation_api_headers
 PRODUCT_PACKAGES += libgps.utils_headers
diff --git a/location/Android.bp b/location/Android.bp
index 343427f..9126305 100644
--- a/location/Android.bp
+++ b/location/Android.bp
@@ -13,7 +13,7 @@
     name: "liblocation_api",
     vendor: true,
 
-    sanitize: GNSS_SANITIZE,
+
 
     shared_libs: [
         "libutils",
diff --git a/utils/Android.bp b/utils/Android.bp
index 42bde9d..bdaba99 100644
--- a/utils/Android.bp
+++ b/utils/Android.bp
@@ -14,7 +14,7 @@
     name: "libgps.utils",
     vendor: true,
 
-    sanitize: GNSS_SANITIZE,
+
 
     //# Libs
     shared_libs: [