Merge remote-tracking branch 'goog/qcom/release/LA.UM.7.8.9.C2.08.00.00.618.110'

Bug: 172519827
Change-Id: I53df54b39c86deb6b8a036cfdc60c8eefcb0a584
diff --git a/METADATA b/METADATA
new file mode 100644
index 0000000..d97975c
--- /dev/null
+++ b/METADATA
@@ -0,0 +1,3 @@
+third_party {
+  license_type: NOTICE
+}
diff --git a/core/Android.mk b/core/Android.mk
index e1ac45a..859ac03 100644
--- a/core/Android.mk
+++ b/core/Android.mk
@@ -20,7 +20,8 @@
     libutils \
     libcutils \
     libgps.utils \
-    libdl
+    libdl \
+    libprocessgroup
 
 LOCAL_SRC_FILES += \
     MsgTask.cpp \
@@ -33,7 +34,8 @@
 LOCAL_CFLAGS += \
      -fno-short-enums \
      -D_ANDROID_ \
-     -Wno-unused-parameter
+     -Wno-unused-parameter \
+     -Wno-error
 
 LOCAL_C_INCLUDES:= \
     $(TARGET_OUT_HEADERS)/gps.utils
diff --git a/loc_api/libloc_api_50001/Android.mk b/loc_api/libloc_api_50001/Android.mk
index 74d5423..4992540 100644
--- a/loc_api/libloc_api_50001/Android.mk
+++ b/loc_api/libloc_api_50001/Android.mk
@@ -16,7 +16,8 @@
     libdl \
     liblog \
     libloc_core \
-    libgps.utils
+    libgps.utils \
+    libprocessgroup
 
 LOCAL_SRC_FILES += \
     loc_eng.cpp \
@@ -74,7 +75,8 @@
     libloc_eng \
     libloc_core \
     libgps.utils \
-    libdl
+    libdl \
+    libprocessgroup
 
 ifneq ($(filter $(TARGET_DEVICE), apq8084 msm8960), false)
 endif
diff --git a/msm8084/core/Android.mk b/msm8084/core/Android.mk
index c7ea75c..e1df540 100644
--- a/msm8084/core/Android.mk
+++ b/msm8084/core/Android.mk
@@ -15,7 +15,8 @@
     liblog \
     libcutils \
     libgps.utils \
-    libdl
+    libdl \
+    libprocessgroup
 
 LOCAL_SRC_FILES += \
     MsgTask.cpp \
diff --git a/msm8084/loc_api/libloc_api_50001/Android.mk b/msm8084/loc_api/libloc_api_50001/Android.mk
index e38befa..87b248e 100644
--- a/msm8084/loc_api/libloc_api_50001/Android.mk
+++ b/msm8084/loc_api/libloc_api_50001/Android.mk
@@ -16,7 +16,8 @@
     libdl \
     liblog \
     libloc_core \
-    libgps.utils
+    libgps.utils \
+    libprocessgroup
 
 LOCAL_SRC_FILES += \
     loc_eng.cpp \
@@ -74,7 +75,8 @@
     libloc_eng \
     libloc_core \
     libgps.utils \
-    libdl
+    libdl \
+    libprocessgroup
 
 LOCAL_SRC_FILES += \
     loc.cpp \
diff --git a/msm8909/loc_api/libloc_api_50001/Android.mk b/msm8909/loc_api/libloc_api_50001/Android.mk
index 2353a37..08835d6 100644
--- a/msm8909/loc_api/libloc_api_50001/Android.mk
+++ b/msm8909/loc_api/libloc_api_50001/Android.mk
@@ -16,7 +16,8 @@
     libdl \
     liblog \
     libloc_core \
-    libgps.utils
+    libgps.utils \
+    libprocessgroup
 
 LOCAL_SRC_FILES += \
     loc_eng.cpp \
@@ -75,7 +76,8 @@
     libloc_eng \
     libloc_core \
     libgps.utils \
-    libdl
+    libdl \
+    libprocessgroup
 
 ifneq ($(filter $(TARGET_DEVICE), apq8084 msm8960), false)
 endif
diff --git a/msm8909/utils/Android.mk b/msm8909/utils/Android.mk
index 289926c..b7e30fb 100644
--- a/msm8909/utils/Android.mk
+++ b/msm8909/utils/Android.mk
@@ -10,7 +10,8 @@
 LOCAL_SHARED_LIBRARIES := \
     libutils \
     libcutils \
-    liblog
+    liblog \
+    libprocessgroup
 
 LOCAL_SRC_FILES += \
     loc_log.cpp \
diff --git a/msm8960/core/Android.mk b/msm8960/core/Android.mk
index 3144313..dc2b31a 100644
--- a/msm8960/core/Android.mk
+++ b/msm8960/core/Android.mk
@@ -12,7 +12,8 @@
     liblog \
     libcutils \
     libgps.utils \
-    libdl
+    libdl \
+    libprocessgroup
 
 LOCAL_SRC_FILES += \
     MsgTask.cpp \
diff --git a/msm8960/loc_api/libloc_api_50001/Android.mk b/msm8960/loc_api/libloc_api_50001/Android.mk
index b9a63b0..9f60c5d 100644
--- a/msm8960/loc_api/libloc_api_50001/Android.mk
+++ b/msm8960/loc_api/libloc_api_50001/Android.mk
@@ -16,7 +16,8 @@
     libdl \
     liblog \
     libloc_core \
-    libgps.utils
+    libgps.utils \
+    libprocessgroup
 
 LOCAL_SRC_FILES += \
     loc_eng.cpp \
@@ -74,7 +75,8 @@
     libloc_eng \
     libloc_core \
     libgps.utils \
-    libdl
+    libdl \
+    libprocessgroup
 
 LOCAL_SRC_FILES += \
     loc.cpp \
diff --git a/msm8994/core/Android.mk b/msm8994/core/Android.mk
index 46d5343..a8b8995 100644
--- a/msm8994/core/Android.mk
+++ b/msm8994/core/Android.mk
@@ -21,7 +21,8 @@
     liblog \
     libcutils \
     libgps.utils \
-    libdl
+    libdl \
+    libprocessgroup
 
 LOCAL_SRC_FILES += \
     MsgTask.cpp \
diff --git a/msm8994/loc_api/libloc_api_50001/Android.mk b/msm8994/loc_api/libloc_api_50001/Android.mk
index 74d5423..4992540 100644
--- a/msm8994/loc_api/libloc_api_50001/Android.mk
+++ b/msm8994/loc_api/libloc_api_50001/Android.mk
@@ -16,7 +16,8 @@
     libdl \
     liblog \
     libloc_core \
-    libgps.utils
+    libgps.utils \
+    libprocessgroup
 
 LOCAL_SRC_FILES += \
     loc_eng.cpp \
@@ -74,7 +75,8 @@
     libloc_eng \
     libloc_core \
     libgps.utils \
-    libdl
+    libdl \
+    libprocessgroup
 
 ifneq ($(filter $(TARGET_DEVICE), apq8084 msm8960), false)
 endif
diff --git a/msm8996/loc_api/libloc_api_50001/Android.mk b/msm8996/loc_api/libloc_api_50001/Android.mk
index 5182318..c517a23 100644
--- a/msm8996/loc_api/libloc_api_50001/Android.mk
+++ b/msm8996/loc_api/libloc_api_50001/Android.mk
@@ -17,7 +17,8 @@
     libdl \
     liblog \
     libloc_core \
-    libgps.utils
+    libgps.utils \
+    libprocessgroup
 
 LOCAL_SRC_FILES += \
     loc_eng.cpp \
@@ -74,7 +75,8 @@
     libloc_eng \
     libloc_core \
     libgps.utils \
-    libdl
+    libdl \
+    libprocessgroup
 
 ifneq ($(filter $(TARGET_DEVICE), apq8084 msm8960), false)
 endif
diff --git a/msm8996/utils/Android.mk b/msm8996/utils/Android.mk
index a322d0f..f347d47 100644
--- a/msm8996/utils/Android.mk
+++ b/msm8996/utils/Android.mk
@@ -10,7 +10,8 @@
 LOCAL_SHARED_LIBRARIES := \
     libutils \
     libcutils \
-    liblog
+    liblog \
+    libprocessgroup
 
 LOCAL_SRC_FILES += \
     loc_log.cpp \
diff --git a/msm8998/android/Android.mk b/msm8998/android/Android.mk
index f649447..c72cb19 100644
--- a/msm8998/android/Android.mk
+++ b/msm8998/android/Android.mk
@@ -33,8 +33,6 @@
 LOCAL_SHARED_LIBRARIES := \
     liblog \
     libhidlbase \
-    libhidltransport \
-    libhwbinder \
     libutils \
     android.hardware.gnss@1.0 \
 
@@ -72,9 +70,7 @@
     libutils \
 
 LOCAL_SHARED_LIBRARIES += \
-    libhwbinder \
     libhidlbase \
-    libhidltransport \
     android.hardware.gnss@1.0 \
 
 include $(BUILD_EXECUTABLE)
diff --git a/msm8998/utils/Android.mk b/msm8998/utils/Android.mk
index ff18f2f..b97dad3 100644
--- a/msm8998/utils/Android.mk
+++ b/msm8998/utils/Android.mk
@@ -12,7 +12,8 @@
     libutils \
     libcutils \
     liblog \
-    libloc_pla
+    libloc_pla \
+    libprocessgroup
 
 LOCAL_SRC_FILES += \
     loc_log.cpp \
diff --git a/msm8998/utils/platform_lib_abstractions/loc_pla/src/Android.mk b/msm8998/utils/platform_lib_abstractions/loc_pla/src/Android.mk
index 0d2afe7..c029bc7 100644
--- a/msm8998/utils/platform_lib_abstractions/loc_pla/src/Android.mk
+++ b/msm8998/utils/platform_lib_abstractions/loc_pla/src/Android.mk
@@ -11,7 +11,8 @@
     libutils \
     libcutils \
     liblog \
-    libloc_stub
+    libloc_stub \
+    libprocessgroup
 
 LOCAL_SRC_FILES += \
         platform_lib_gettid.cpp \
diff --git a/sdm845/android/Android.mk b/sdm845/android/Android.mk
index 4f1cdf2..e517359 100644
--- a/sdm845/android/Android.mk
+++ b/sdm845/android/Android.mk
@@ -33,8 +33,6 @@
 LOCAL_SHARED_LIBRARIES := \
     liblog \
     libhidlbase \
-    libhidltransport \
-    libhwbinder \
     libcutils \
     libutils \
     android.hardware.gnss@1.0 \
@@ -47,6 +45,7 @@
     liblocation_api \
 
 LOCAL_CFLAGS += $(GNSS_CFLAGS)
+LOCAL_CFLAGS += -Wno-error
 include $(BUILD_SHARED_LIBRARY)
 
 BUILD_GNSS_HIDL_SERVICE := true
@@ -82,9 +81,7 @@
     libutils \
 
 LOCAL_SHARED_LIBRARIES += \
-    libhwbinder \
     libhidlbase \
-    libhidltransport \
     android.hardware.gnss@1.0 \
     android.hardware.gnss@1.1 \
 
diff --git a/sdm845/android/Gnss.cpp b/sdm845/android/Gnss.cpp
index 374ab52..025d1e0 100644
--- a/sdm845/android/Gnss.cpp
+++ b/sdm845/android/Gnss.cpp
@@ -289,7 +289,7 @@
 
 Return<bool> Gnss::injectTime(int64_t timeMs, int64_t timeReferenceMs,
                               int32_t uncertaintyMs) {
-        return true;
+    return true;
 }
 
 Return<void> Gnss::deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags)  {
diff --git a/sdm845/android/location_api/GnssAPIClient.cpp b/sdm845/android/location_api/GnssAPIClient.cpp
index 61b8b38..b799981 100644
--- a/sdm845/android/location_api/GnssAPIClient.cpp
+++ b/sdm845/android/location_api/GnssAPIClient.cpp
@@ -57,7 +57,8 @@
     mGnssNiCbIface(nullptr),
     mControlClient(new LocationAPIControlClient()),
     mLocationCapabilitiesMask(0),
-    mLocationCapabilitiesCached(false)
+    mLocationCapabilitiesCached(false),
+    mTracking(false)
 {
     LOC_LOGD("%s]: (%p %p)", __FUNCTION__, &gpsCb, &niCb);
 
@@ -141,6 +142,11 @@
 bool GnssAPIClient::gnssStart()
 {
     LOC_LOGD("%s]: ()", __FUNCTION__);
+
+    mMutex.lock();
+    mTracking = true;
+    mMutex.unlock();
+
     bool retVal = true;
     locAPIStartTracking(mTrackingOptions);
     return retVal;
@@ -149,6 +155,11 @@
 bool GnssAPIClient::gnssStop()
 {
     LOC_LOGD("%s]: ()", __FUNCTION__);
+
+    mMutex.lock();
+    mTracking = false;
+    mMutex.unlock();
+
     bool retVal = true;
     locAPIStopTracking();
     return retVal;
@@ -349,11 +360,17 @@
 
 void GnssAPIClient::onTrackingCb(Location location)
 {
-    LOC_LOGD("%s]: (flags: %02x)", __FUNCTION__, location.flags);
     mMutex.lock();
     auto gnssCbIface(mGnssCbIface);
+    bool isTracking = mTracking;
     mMutex.unlock();
 
+    LOC_LOGD("%s]: (flags: %02x isTracking: %d)", __FUNCTION__, location.flags, isTracking);
+
+    if (!isTracking) {
+        return;
+    }
+
     if (gnssCbIface != nullptr) {
         GnssLocation gnssLocation;
         convertGnssLocation(location, gnssLocation);
diff --git a/sdm845/android/location_api/GnssAPIClient.h b/sdm845/android/location_api/GnssAPIClient.h
index 82f8fbf..39e919e 100644
--- a/sdm845/android/location_api/GnssAPIClient.h
+++ b/sdm845/android/location_api/GnssAPIClient.h
@@ -98,6 +98,7 @@
     LocationAPIControlClient* mControlClient;
     LocationCapabilitiesMask mLocationCapabilitiesMask;
     bool mLocationCapabilitiesCached;
+    bool mTracking;
     TrackingOptions mTrackingOptions;
 };
 
diff --git a/sdm845/core/Android.mk b/sdm845/core/Android.mk
index 1a4f51a..46f5fab 100644
--- a/sdm845/core/Android.mk
+++ b/sdm845/core/Android.mk
@@ -35,7 +35,8 @@
 
 LOCAL_CFLAGS += \
      -fno-short-enums \
-     -D_ANDROID_
+     -D_ANDROID_ \
+     -Wno-error
 
 LOCAL_C_INCLUDES:= \
     $(LOCAL_PATH)/data-items \
diff --git a/sdm845/core/LocApiBase.cpp b/sdm845/core/LocApiBase.cpp
index d06fddf..a0bf9c4 100644
--- a/sdm845/core/LocApiBase.cpp
+++ b/sdm845/core/LocApiBase.cpp
@@ -31,6 +31,7 @@
 
 #include <dlfcn.h>
 #include <inttypes.h>
+#include <gps_extended_c.h>
 #include <LocApiBase.h>
 #include <LocAdapterBase.h>
 #include <log_util.h>
@@ -95,7 +96,10 @@
     }
     inline virtual void proc() const {
         mLocApi->close();
-        mLocApi->open(mLocApi->getEvtMask());
+        if (LOC_API_ADAPTER_ERR_SUCCESS == mLocApi->open(mLocApi->getEvtMask())) {
+            // Notify adapters that engine up after SSR
+            mLocApi->handleEngineUpEvent();
+        }
     }
     inline void locallog() const {
         LOC_LOGV("LocSsrMsg");
@@ -107,13 +111,17 @@
 
 struct LocOpenMsg : public LocMsg {
     LocApiBase* mLocApi;
-    inline LocOpenMsg(LocApiBase* locApi) :
-            LocMsg(), mLocApi(locApi)
+    LocAdapterBase* mAdapter;
+    inline LocOpenMsg(LocApiBase* locApi, LocAdapterBase* adapter = nullptr) :
+            LocMsg(), mLocApi(locApi), mAdapter(adapter)
     {
         locallog();
     }
     inline virtual void proc() const {
-        mLocApi->open(mLocApi->getEvtMask());
+        if (LOC_API_ADAPTER_ERR_SUCCESS == mLocApi->open(mLocApi->getEvtMask()) &&
+            nullptr != mAdapter) {
+            mLocApi->handleEngineUpEvent();
+        }
     }
     inline void locallog() const {
         LOC_LOGv("LocOpen Mask: %" PRIx64 "\n", mLocApi->getEvtMask());
@@ -201,7 +209,7 @@
     for (int i = 0; i < MAX_ADAPTERS && mLocAdapters[i] != adapter; i++) {
         if (mLocAdapters[i] == NULL) {
             mLocAdapters[i] = adapter;
-            mMsgTask->sendMsg(new LocOpenMsg(this));
+            mMsgTask->sendMsg(new LocOpenMsg(this, adapter));
             break;
         }
     }
@@ -250,17 +258,15 @@
 
 void LocApiBase::handleEngineUpEvent()
 {
-    // This will take care of renegotiating the loc handle
-    mMsgTask->sendMsg(new LocSsrMsg(this));
-
-    LocDualContext::injectFeatureConfig(mContext);
-
     // loop through adapters, and deliver to all adapters.
     TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineUpEvent());
 }
 
 void LocApiBase::handleEngineDownEvent()
 {
+    // This will take care of renegotiating the loc handle
+    mMsgTask->sendMsg(new LocSsrMsg(this));
+
     // loop through adapters, and deliver to all adapters.
     TO_ALL_LOCADAPTERS(mLocAdapters[i]->handleEngineDownEvent());
 }
diff --git a/sdm845/core/LocApiBase.h b/sdm845/core/LocApiBase.h
index aec1846..b93b227 100644
--- a/sdm845/core/LocApiBase.h
+++ b/sdm845/core/LocApiBase.h
@@ -80,12 +80,12 @@
     friend struct LocOpenMsg;
     friend class ContextBase;
     const MsgTask* mMsgTask;
-    ContextBase *mContext;
     LocAdapterBase* mLocAdapters[MAX_ADAPTERS];
     uint64_t mSupportedMsg;
     uint8_t mFeaturesSupported[MAX_FEATURE_LENGTH];
 
 protected:
+    ContextBase *mContext;
     virtual enum loc_api_adapter_err
         open(LOC_API_ADAPTER_EVENT_MASK_T mask);
     virtual enum loc_api_adapter_err
diff --git a/sdm845/core/LocDualContext.cpp b/sdm845/core/LocDualContext.cpp
index 180d9dc..9851d61 100644
--- a/sdm845/core/LocDualContext.cpp
+++ b/sdm845/core/LocDualContext.cpp
@@ -55,7 +55,6 @@
 const MsgTask* LocDualContext::mMsgTask = NULL;
 ContextBase* LocDualContext::mFgContext = NULL;
 ContextBase* LocDualContext::mBgContext = NULL;
-ContextBase* LocDualContext::mInjectContext = NULL;
 // the name must be shorter than 15 chars
 const char* LocDualContext::mLocationHalName = "Loc_hal_worker";
 #ifndef USE_GLIB
@@ -91,11 +90,6 @@
         mFgContext = new LocDualContext(msgTask,
                                         mFgExclMask);
     }
-    if(NULL == mInjectContext) {
-        LOC_LOGD("%s:%d]: mInjectContext is FgContext", __func__, __LINE__);
-        mInjectContext = mFgContext;
-        injectFeatureConfig(mInjectContext);
-    }
     pthread_mutex_unlock(&LocDualContext::mGetLocContextMutex);
 
     if (firstMsg) {
@@ -116,11 +110,6 @@
         mBgContext = new LocDualContext(msgTask,
                                         mBgExclMask);
     }
-    if(NULL == mInjectContext) {
-        LOC_LOGD("%s:%d]: mInjectContext is BgContext", __func__, __LINE__);
-        mInjectContext = mBgContext;
-        injectFeatureConfig(mInjectContext);
-    }
     pthread_mutex_unlock(&LocDualContext::mGetLocContextMutex);
 
     if (firstMsg) {
@@ -132,13 +121,9 @@
 
 void LocDualContext :: injectFeatureConfig(ContextBase *curContext)
 {
-    LOC_LOGD("%s:%d]: Enter", __func__, __LINE__);
-    if(curContext == mInjectContext) {
-        LOC_LOGD("%s:%d]: Calling LBSProxy (%p) to inject feature config",
-                 __func__, __LINE__, ((LocDualContext *)mInjectContext)->mLBSProxy);
-        ((LocDualContext *)mInjectContext)->mLBSProxy->injectFeatureConfig(curContext);
-    }
-    LOC_LOGD("%s:%d]: Exit", __func__, __LINE__);
+    LOC_LOGD("%s:%d]: Calling LBSProxy (%p) to inject feature config",
+             __func__, __LINE__, ((LocDualContext *)curContext)->mLBSProxy);
+    ((LocDualContext *)curContext)->mLBSProxy->injectFeatureConfig(curContext);
 }
 
 LocDualContext::LocDualContext(const MsgTask* msgTask,
diff --git a/sdm845/core/LocDualContext.h b/sdm845/core/LocDualContext.h
index 3b3ce2c..edfbfb7 100644
--- a/sdm845/core/LocDualContext.h
+++ b/sdm845/core/LocDualContext.h
@@ -40,7 +40,6 @@
     static const MsgTask* mMsgTask;
     static ContextBase* mFgContext;
     static ContextBase* mBgContext;
-    static ContextBase* mInjectContext;
     static const MsgTask* getMsgTask(LocThread::tCreate tCreator,
                                      const char* name, bool joinable = true);
     static const MsgTask* getMsgTask(const char* name, bool joinable = true);
diff --git a/sdm845/etc/Android.mk b/sdm845/etc/Android.mk
deleted file mode 100644
index d9eb0e1..0000000
--- a/sdm845/etc/Android.mk
+++ /dev/null
@@ -1,12 +0,0 @@
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := gps.conf
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_CLASS := ETC
-LOCAL_MODULE_PATH  := $(TARGET_OUT_VENDOR)/etc/
-LOCAL_SRC_FILES := gps.conf
-
-include $(BUILD_PREBUILT)
-
diff --git a/sdm845/etc/gps.conf b/sdm845/etc/gps.conf
deleted file mode 100644
index 6cd410a..0000000
--- a/sdm845/etc/gps.conf
+++ /dev/null
@@ -1,221 +0,0 @@
-#Uncommenting these urls would only enable
-#the power up auto injection and force injection(test case).
-#XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra2.bin
-#XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra2.bin
-#XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra2.bin
-
-#Version check for XTRA
-#DISABLE = 0
-#AUTO    = 1
-#XTRA2   = 2
-#XTRA3   = 3
-XTRA_VERSION_CHECK=0
-
-# Error Estimate
-# _SET = 1
-# _CLEAR = 0
-ERR_ESTIMATE=0
-
-#NTP server
-NTP_SERVER=time.izatcloud.net
-
-#XTRA CA path
-XTRA_CA_PATH=/system/etc/security/cacerts
-
-# DEBUG LEVELS: 0 - none, 1 - Error, 2 - Warning, 3 - Info
-#               4 - Debug, 5 - Verbose
-# If DEBUG_LEVEL is commented, Android's logging levels will be used
-DEBUG_LEVEL = 3
-
-# Intermediate position report, 1=enable, 0=disable
-INTERMEDIATE_POS=0
-
-# Below bit mask configures how GPS functionalities
-# should be locked when user turns off GPS on Settings
-# Set bit 0x1 if MO GPS functionalities are to be locked
-# Set bit 0x2 if NI GPS functionalities are to be locked
-# default – both MO and NI locked for maximal privacy
-#GPS_LOCK = 3
-
-# supl version 1.0
-SUPL_VER=0x10000
-
-# Emergency SUPL, 1=enable, 0=disable
-#SUPL_ES=0
-
-#Choose PDN for Emergency SUPL
-#1 - Use emergency PDN
-#0 - Use regular SUPL PDN for Emergency SUPL
-#USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL=0
-
-#SUPL_MODE is a bit mask set in config.xml per carrier by default.
-#If it is uncommented here, this value will overwrite the value from
-#config.xml.
-#MSA=0X2
-#MSB=0X1
-#SUPL_MODE=
-
-# GPS Capabilities bit mask
-# SCHEDULING = 0x01
-# MSB = 0x02
-# MSA = 0x04
-# ON_DEMAND_TIME = 0x10
-# GEOFENCE = 0x20
-# default = ON_DEMAND_TIME | MSA | MSB | SCHEDULING | GEOFENCE
-CAPABILITIES=0x37
-
-# Accuracy threshold for intermediate positions
-# less accurate positions are ignored, 0 for passing all positions
-# ACCURACY_THRES=5000
-
-################################
-##### AGPS server settings #####
-################################
-
-# FOR SUPL SUPPORT, set the following
-# SUPL_HOST=supl.host.com or IP
-# SUPL_PORT=1234
-
-# FOR C2K PDE SUPPORT, set the following
-# C2K_HOST=c2k.pde.com or IP
-# C2K_PORT=1234
-
-# Bitmask of slots that are available
-# for write/install to, where 1s indicate writable,
-# and the default value is 0 where no slots
-# are writable. For example, AGPS_CERT_WRITABLE_MASK
-# of b1000001010 makes 3 slots available
-# and the remaining 7 slots unwritable.
-#AGPS_CERT_WRITABLE_MASK=0
-
-####################################
-#  LTE Positioning Profile Settings
-####################################
-# 0: Enable RRLP on LTE(Default)
-# 1: Enable LPP_User_Plane on LTE
-# 2: Enable LPP_Control_Plane
-# 3: Enable both LPP_User_Plane and LPP_Control_Plane
-LPP_PROFILE = 2
-
-################################
-# EXTRA SETTINGS
-################################
-# NMEA provider (1=Modem Processor, 0=Application Processor)
-NMEA_PROVIDER=0
-# Mark if it is a SGLTE target (1=SGLTE, 0=nonSGLTE)
-SGLTE_TARGET=0
-
-##################################################
-# Select Positioning Protocol on A-GLONASS system
-##################################################
-# 0x1: RRC CPlane
-# 0x2: RRLP UPlane
-# 0x4: LLP Uplane
-A_GLONASS_POS_PROTOCOL_SELECT = 0
-
-##################################################
-# Select technology for LPPe Control Plane
-##################################################
-# 0x1: DBH for LPPe CP
-# 0x2: WLAN AP Measurements for LPPe CP
-# 0x4: SRN AP measurement for CP
-# 0x8: Sensor Barometer Measurement LPPe CP
-LPPE_CP_TECHNOLOGY = 0
-
-##################################################
-# Select technology for LPPe User Plane
-##################################################
-# 0x1: DBH for LPPe UP
-# 0x2: WLAN AP Measurements for LPPe UP
-# 0x4: SRN AP measurement for UP
-# 0x8: Sensor Barometer Measurement LPPe UP
-LPPE_UP_TECHNOLOGY = 0
-
-##################################################
-# AGPS_CONFIG_INJECT
-##################################################
-# enable/disable injection of AGPS configurations:
-#     SUPL_VER
-#     SUPL_HOST
-#     SUPL_PORT
-#     C2K_HOST
-#     C2K_PORT
-#     LPP_PROFILE
-#     A_GLONASS_POS_PROTOCOL_SELECT
-# 0: disable
-# 1: enable
-AGPS_CONFIG_INJECT = 1
-
-##################################################
-# GNSS settings for automotive use cases
-# Configurations in following section are
-# specific to automotive use cases, others
-# please do not change, keep the default values
-##################################################
-
-# AP Coarse Timestamp Uncertainty
-##################################################
-# default : 10
-# AP time stamp uncertainty, until GNSS receiver
-# is able to acquire better timing information
-AP_TIMESTAMP_UNCERTAINTY = 10
-
-##################################################
-# QDR engine availability status
-##################################################
-# 0 : NO QDR (default)
-# 1 : QDR enabled
-# This settings enables QDR Configuration for
-# automotive use case, if enabled then
-# DR_AP_Service needs to be enabled in izat.conf
-#EXTERNAL_DR_ENABLED = 0
-
-#####################################
-# DR_SYNC Pulse Availability
-#####################################
-# 0 : DR_SYNC pulse not available (default)
-# 1 : DR_SYNC pulse available
-# This configuration enables the driver to make use
-# of PPS events generated by DR_SYNC pulse
-# Standard Linux PPS driver needs to be enabled
-DR_SYNC_ENABLED = 0
-
-#####################################
-# PPS Device name
-#####################################
-PPS_DEVICENAME = /dev/pps0
-
-#####################################
-# AP Clock Accuracy
-#####################################
-# Quality of APPS processor clock (in PPM).
-# Value specified is used for calculation of
-# APPS time stamp uncertainty
-AP_CLOCK_PPM = 100
-
-#####################################
-# MAX ms difference to detect missing pulse
-#####################################
-# Specifies time threshold in ms to validate any missing PPS pulses
-MISSING_PULSE_TIME_DELTA = 900
-
-#####################################
-# Propagation time uncertainty
-#####################################
-# This settings enables time uncertainty propagation
-# logic incase of missing PPS pulse
-PROPAGATION_TIME_UNCERTAINTY = 1
-
-#######################################
-#  APN / IP Type Configuration
-#  APN and IP Type to use for setting
-#  up WWAN call.
-#  Use below values for IP Type:
-#  v4 = 4
-#  v6 = 6
-#  v4v6 = 10
-#######################################
-# INTERNET_APN = abc.xyz
-# INTERNET_IP_TYPE = 4
-# SUPL_APN = abc.xyz
-# SUPL_IP_TYPE = 4
diff --git a/sdm845/gnss/GnssAdapter.cpp b/sdm845/gnss/GnssAdapter.cpp
index d7c9da4..7a0a520 100644
--- a/sdm845/gnss/GnssAdapter.cpp
+++ b/sdm845/gnss/GnssAdapter.cpp
@@ -655,14 +655,14 @@
         int32_t length = -1;
         const char noHost[] = "NONE";
 
-        locErr = LOCATION_ERROR_INVALID_PARAMETER;
-
         if ((NULL == server) || (server[0] == 0) ||
                 (strncasecmp(noHost, server, sizeof(noHost)) == 0)) {
             serverUrl[0] = '\0';
             length = 0;
         } else if (port > 0) {
             length = snprintf(serverUrl, sizeof(serverUrl), "%s:%u", server, port);
+        } else {
+            locErr = LOCATION_ERROR_INVALID_PARAMETER;
         }
 
         if (length >= 0 && strncasecmp(getServerUrl().c_str(),
@@ -694,17 +694,20 @@
         inline virtual void proc() const {
             if (ContextBase::mGps_conf.AGPS_CONFIG_INJECT) {
                 mApi.setSUPLVersion(mAdapter.convertSuplVersion(ContextBase::mGps_conf.SUPL_VER));
-                mApi.setLPPConfig(mAdapter.convertLppProfile(ContextBase::mGps_conf.LPP_PROFILE));
+                // mApi.setLPPConfig(mAdapter.convertLppProfile(ContextBase::mGps_conf.LPP_PROFILE));
                 mApi.setAGLONASSProtocol(ContextBase::mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT);
             }
             mAdapter.setSuplHostServer(ContextBase::mGps_conf.SUPL_HOST,
                                        ContextBase::mGps_conf.SUPL_PORT);
             mApi.setSensorControlConfig(ContextBase::mSap_conf.SENSOR_USAGE,
                                         ContextBase::mSap_conf.SENSOR_PROVIDER);
+
+            /* Mark these LPPe functions, they are MBN configured.
             mApi.setLPPeProtocolCp(
-                mAdapter.convertLppeCp(ContextBase::mGps_conf.LPPE_CP_TECHNOLOGY));
+                    mAdapter.convertLppeCp(ContextBase::mGps_conf.LPPE_CP_TECHNOLOGY));
             mApi.setLPPeProtocolUp(
-                mAdapter.convertLppeUp(ContextBase::mGps_conf.LPPE_UP_TECHNOLOGY));
+                    mAdapter.convertLppeUp(ContextBase::mGps_conf.LPPE_UP_TECHNOLOGY));
+            */
 
             // set nmea mask type
             uint32_t mask = 0;
@@ -872,6 +875,8 @@
                     errs[index++] = err;
                 }
             }
+
+            /* Comment out LPP injection as it's configured by MBN.
             if (mConfig.flags & GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) {
                 uint32_t newLppProfile = mAdapter.convertLppProfile(mConfig.lppProfile);
                 if (newLppProfile != ContextBase::mGps_conf.LPP_PROFILE &&
@@ -885,6 +890,8 @@
                     errs[index++] = err;
                 }
             }
+            */
+
             if (mConfig.flags & GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) {
                 uint32_t newLppeControlPlaneMask =
                     mAdapter.convertLppeCp(mConfig.lppeControlPlaneMask);
@@ -1367,8 +1374,8 @@
 GnssAdapter::gnssSvTypeConfigUpdate()
 {
     LocationError err = LOCATION_ERROR_GENERAL_FAILURE;
-    LOC_LOGd("constellations blacklisted 0x%" PRIx64 ", enabled 0x%" PRIx64,
-             mGnssSvTypeConfig.blacklistedSvTypesMask, mGnssSvTypeConfig.enabledSvTypesMask);
+    LOC_LOGd("size %zu constellations blacklisted 0x%" PRIx64 ", enabled 0x%" PRIx64,
+             mGnssSvTypeConfig.size, mGnssSvTypeConfig.blacklistedSvTypesMask, mGnssSvTypeConfig.enabledSvTypesMask);
 
     if (mGnssSvTypeConfig.size == sizeof(mGnssSvTypeConfig)) {
         GnssSvIdConfig blacklistConfig = {};
@@ -1405,7 +1412,6 @@
             }
         }
     } else {
-        LOC_LOGE("Invalid GnssSvTypeConfig size");
         err = LOCATION_ERROR_SUCCESS;
     }
 
diff --git a/sdm845/gnss/location_gnss.cpp b/sdm845/gnss/location_gnss.cpp
index 105145a..a8b9ac2 100644
--- a/sdm845/gnss/location_gnss.cpp
+++ b/sdm845/gnss/location_gnss.cpp
@@ -109,6 +109,7 @@
 const GnssInterface* getGnssInterface()
 #endif // DEBUG_X86
 {
+   gGnssInterface.initialize();
    return &gGnssInterface;
 }
 
diff --git a/sdm845/location/Android.mk b/sdm845/location/Android.mk
index bbd6fbd..38dea0a 100644
--- a/sdm845/location/Android.mk
+++ b/sdm845/location/Android.mk
@@ -30,6 +30,7 @@
 LOCAL_PRELINK_MODULE := false
 
 LOCAL_CFLAGS += $(GNSS_CFLAGS)
+LOCAL_CFLAGS += -Wno-error
 include $(BUILD_SHARED_LIBRARY)
 
 include $(CLEAR_VARS)
diff --git a/sdm845/utils/Android.mk b/sdm845/utils/Android.mk
index 699be66..40c3bbb 100644
--- a/sdm845/utils/Android.mk
+++ b/sdm845/utils/Android.mk
@@ -12,7 +12,8 @@
     libdl \
     libutils \
     libcutils \
-    liblog
+    liblog \
+    libprocessgroup
 
 ifeq ($(filter P% p%,$(TARGET_PLATFORM_VERSION)),)
 LOCAL_SHARED_LIBRARIES += libprocessgroup
@@ -35,7 +36,8 @@
 # Flag -std=c++11 is not accepted by compiler when LOCAL_CLANG is set to true
 LOCAL_CFLAGS += \
      -fno-short-enums \
-     -D_ANDROID_
+     -D_ANDROID_ \
+     -Wno-error
 
 ifeq ($(TARGET_BUILD_VARIANT),user)
    LOCAL_CFLAGS += -DTARGET_BUILD_VARIANT_USER
diff --git a/sdm845/utils/LocTimer.cpp b/sdm845/utils/LocTimer.cpp
index 93775d0..44d6cd5 100644
--- a/sdm845/utils/LocTimer.cpp
+++ b/sdm845/utils/LocTimer.cpp
@@ -398,8 +398,8 @@
 
 inline
 LocTimerPollTask::LocTimerPollTask()
-    : mFd(epoll_create(2)), mThread(new LocThread()) {
-    // before a next call returens, a thread will be created. The run() method
+    : mFd(epoll_create1(EPOLL_CLOEXEC)), mThread(new LocThread()) {
+    // before a next call returns, a thread will be created. The run() method
     // could already be running in parallel. Also, since each of the objs
     // creates a thread, the container will make sure that there will be only
     // one of such obj for our timer implementation.
diff --git a/sdm845/utils/MsgTask.cpp b/sdm845/utils/MsgTask.cpp
index eaead5c..5f73f00 100644
--- a/sdm845/utils/MsgTask.cpp
+++ b/sdm845/utils/MsgTask.cpp
@@ -35,6 +35,7 @@
 #include <log_util.h>
 #include <loc_log.h>
 #include <loc_pla.h>
+#include <processgroup/sched_policy.h>
 
 static void LocMsgDestroy(void* msg) {
     delete (LocMsg*)msg;
diff --git a/sdm845/utils/loc_nmea.cpp b/sdm845/utils/loc_nmea.cpp
index 558dc65..bf87599 100644
--- a/sdm845/utils/loc_nmea.cpp
+++ b/sdm845/utils/loc_nmea.cpp
@@ -507,9 +507,9 @@
         sv_cache_info.gal_used_mask =
                 (uint32_t)locationExtended.gnss_sv_used_ids.gal_sv_used_ids_mask;
         sv_cache_info.qzss_used_mask =
-                (uint32_t)locationExtended.gnss_sv_used_ids.bds_sv_used_ids_mask;
-        sv_cache_info.bds_used_mask =
                 (uint32_t)locationExtended.gnss_sv_used_ids.qzss_sv_used_ids_mask;
+        sv_cache_info.bds_used_mask =
+                (uint32_t)locationExtended.gnss_sv_used_ids.bds_sv_used_ids_mask;
     }
     if (generate_nmea) {
         char talker[3] = {'G', 'P', '\0'};
diff --git a/utils/Android.mk b/utils/Android.mk
index cf9e02c..f224b18 100644
--- a/utils/Android.mk
+++ b/utils/Android.mk
@@ -28,7 +28,8 @@
 
 LOCAL_CFLAGS += \
      -fno-short-enums \
-     -D_ANDROID_
+     -D_ANDROID_ \
+     -Wno-error
 
 ifeq ($(TARGET_BUILD_VARIANT),user)
    LOCAL_CFLAGS += -DTARGET_BUILD_VARIANT_USER