multiple XTRA downloaders could be triggered on boot up

Disable loc xtra apis to allow only one XTRA downloader
when other XTRA downloader is enabled.

Change-Id: I0183608f801cdc6a7d7db730d5d633e556c95386
CRs-fixed: 1022064
diff --git a/msm8909/core/ContextBase.h b/msm8909/core/ContextBase.h
index 45f441a..7ad7c8a 100644
--- a/msm8909/core/ContextBase.h
+++ b/msm8909/core/ContextBase.h
@@ -58,6 +58,7 @@
     inline LocApiProxyBase* getLocApiProxy() { return mLocApiProxy; }
     inline bool hasAgpsExtendedCapabilities() { return mLBSProxy->hasAgpsExtendedCapabilities(); }
     inline bool hasCPIExtendedCapabilities() { return mLBSProxy->hasCPIExtendedCapabilities(); }
+    inline bool hasNativeXtraClient() { return mLBSProxy->hasNativeXtraClient(); }
     inline void modemPowerVote(bool power) const { return mLBSProxy->modemPowerVote(power); }
     inline void requestUlp(LocAdapterBase* adapter,
                            unsigned long capabilities) {
diff --git a/msm8909/core/LBSProxyBase.h b/msm8909/core/LBSProxyBase.h
index 09d96aa..fa4e707 100644
--- a/msm8909/core/LBSProxyBase.h
+++ b/msm8909/core/LBSProxyBase.h
@@ -55,6 +55,7 @@
     inline virtual bool hasCPIExtendedCapabilities() const { return false; }
     inline virtual void modemPowerVote(bool power) const {}
     virtual void injectFeatureConfig(ContextBase* /* context */) const {}
+    inline virtual bool hasNativeXtraClient() const { return false; }
 };
 
 typedef LBSProxyBase* (getLBSProxy_t)();
diff --git a/msm8909/loc_api/libloc_api_50001/Android.mk b/msm8909/loc_api/libloc_api_50001/Android.mk
index 8f7fca8..17f80db 100644
--- a/msm8909/loc_api/libloc_api_50001/Android.mk
+++ b/msm8909/loc_api/libloc_api_50001/Android.mk
@@ -89,6 +89,10 @@
     -fno-short-enums \
     -D_ANDROID_ \
 
+ifeq ($(TARGET_BUILD_VARIANT),user)
+   LOCAL_CFLAGS += -DTARGET_BUILD_VARIANT_USER
+endif
+
 ifeq ($(TARGET_USES_QCOM_BSP), true)
 LOCAL_CFLAGS += -DTARGET_USES_QCOM_BSP
 endif
diff --git a/msm8909/loc_api/libloc_api_50001/LocEngAdapter.h b/msm8909/loc_api/libloc_api_50001/LocEngAdapter.h
index 0e0fdbe..6666860 100644
--- a/msm8909/loc_api/libloc_api_50001/LocEngAdapter.h
+++ b/msm8909/loc_api/libloc_api_50001/LocEngAdapter.h
@@ -106,6 +106,9 @@
     inline bool hasCPIExtendedCapabilities() {
         return mContext->hasCPIExtendedCapabilities();
     }
+    inline bool hasNativeXtraClient() {
+        return mContext->hasNativeXtraClient();
+    }
     inline const MsgTask* getMsgTask() { return mMsgTask; }
 
     inline enum loc_api_adapter_err
diff --git a/msm8909/loc_api/libloc_api_50001/loc_eng_xtra.cpp b/msm8909/loc_api/libloc_api_50001/loc_eng_xtra.cpp
index 7bb8083..b2f0e9b 100644
--- a/msm8909/loc_api/libloc_api_50001/loc_eng_xtra.cpp
+++ b/msm8909/loc_api/libloc_api_50001/loc_eng_xtra.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2009-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
@@ -124,6 +124,13 @@
     loc_eng_xtra_data_s_type *xtra_module_data_ptr;
     ENTRY_LOG();
 
+    if(!loc_eng_data.adapter->mSupportsTimeInjection
+       || loc_eng_data.adapter->hasNativeXtraClient()) {
+        LOC_LOGD("XTRA is already supported. disable it here.\n");
+        EXIT_LOG(%d, 1); // return 1 denote failure
+        return 1;
+    }
+
     if(callbacks == NULL) {
         LOC_LOGE("loc_eng_xtra_init: failed, cb is NULL");
     } else {