diff options
author | Nilesh Gharde <ngharde@codeaurora.org> | 2020-12-31 10:11:03 +0530 |
---|---|---|
committer | Nilesh Gharde <ngharde@codeaurora.org> | 2021-01-06 01:37:17 +0530 |
commit | 1d288a41da8a2febcb7e75e51caae38fcb9fe9d2 (patch) | |
tree | 7652b3f34feca276b21f8d1b29ded51594bad72c | |
parent | 555935f14fe316db3cdbda4c0ba953a539cfad78 (diff) |
default internet ATL handler implementation
default internet ATL handler, to handle ATL request for
AGPS_ATL_TYPE_WWAN. This implemntaion will be
common for Android based platform(LA/Kaios)
Change-Id: I5b93ee14706b90450a7200567ea6f0009b54e825
CRs-fixed: 2813900
-rw-r--r-- | android/1.0/AGnssRil.cpp | 3 | ||||
-rw-r--r-- | android/1.1/AGnssRil.cpp | 3 | ||||
-rw-r--r-- | android/2.0/AGnssRil.cpp | 8 | ||||
-rw-r--r-- | android/2.1/AGnssRil.cpp | 8 | ||||
-rw-r--r-- | core/SystemStatus.cpp | 7 | ||||
-rw-r--r-- | core/SystemStatus.h | 28 | ||||
-rw-r--r-- | core/data-items/DataItemConcreteTypesBase.h | 7 | ||||
-rw-r--r-- | gnss/Android.bp | 1 | ||||
-rw-r--r-- | gnss/GnssAdapter.cpp | 26 | ||||
-rw-r--r-- | gnss/GnssAdapter.h | 4 | ||||
-rw-r--r-- | gnss/Makefile.am | 3 | ||||
-rw-r--r-- | gnss/NativeAgpsHandler.cpp | 127 | ||||
-rw-r--r-- | gnss/NativeAgpsHandler.h | 64 | ||||
-rw-r--r-- | gnss/location_gnss.cpp | 9 | ||||
-rw-r--r-- | location/location_interface.h | 2 |
15 files changed, 255 insertions, 45 deletions
diff --git a/android/1.0/AGnssRil.cpp b/android/1.0/AGnssRil.cpp index 0437cf1..d7f30eb 100644 --- a/android/1.0/AGnssRil.cpp +++ b/android/1.0/AGnssRil.cpp @@ -54,6 +54,7 @@ Return<bool> AGnssRil::updateNetworkState(bool connected, NetworkType type, bool const int NetworkType_BLUETOOTH = 7; const int NetworkType_ETHERNET = 9; const int NetworkType_PROXY = 16; + std::string apn(""); // for XTRA if (nullptr != mGnss && ( nullptr != mGnss->getGnssInterface() )) { @@ -102,7 +103,7 @@ Return<bool> AGnssRil::updateNetworkState(bool connected, NetworkType type, bool } break; } - mGnss->getGnssInterface()->updateConnectionStatus(connected, false, typeout, 0); + mGnss->getGnssInterface()->updateConnectionStatus(connected, typeout, false, 0, apn); } return true; } diff --git a/android/1.1/AGnssRil.cpp b/android/1.1/AGnssRil.cpp index 1e774f1..95c8d63 100644 --- a/android/1.1/AGnssRil.cpp +++ b/android/1.1/AGnssRil.cpp @@ -54,6 +54,7 @@ Return<bool> AGnssRil::updateNetworkState(bool connected, NetworkType type, bool const int NetworkType_BLUETOOTH = 7; const int NetworkType_ETHERNET = 9; const int NetworkType_PROXY = 16; + std::string apn(""); // for XTRA if (nullptr != mGnss && ( nullptr != mGnss->getGnssInterface() )) { @@ -102,7 +103,7 @@ Return<bool> AGnssRil::updateNetworkState(bool connected, NetworkType type, bool } break; } - mGnss->getGnssInterface()->updateConnectionStatus(connected, false, typeout, 0); + mGnss->getGnssInterface()->updateConnectionStatus(connected, typeout, false, 0, apn); } return true; } diff --git a/android/2.0/AGnssRil.cpp b/android/2.0/AGnssRil.cpp index a477fc2..d8005e4 100644 --- a/android/2.0/AGnssRil.cpp +++ b/android/2.0/AGnssRil.cpp @@ -54,6 +54,7 @@ Return<bool> AGnssRil::updateNetworkState(bool connected, NetworkType type, bool const int NetworkType_BLUETOOTH = 7; const int NetworkType_ETHERNET = 9; const int NetworkType_PROXY = 16; + std::string apn(""); // for XTRA if (nullptr != mGnss && ( nullptr != mGnss->getGnssInterface() )) { @@ -102,13 +103,13 @@ Return<bool> AGnssRil::updateNetworkState(bool connected, NetworkType type, bool } break; } - mGnss->getGnssInterface()->updateConnectionStatus(connected, false, typeout, 0); + mGnss->getGnssInterface()->updateConnectionStatus(connected, typeout, false, 0, apn); } return true; } Return<bool> AGnssRil::updateNetworkState_2_0(const V2_0::IAGnssRil::NetworkAttributes& attributes) { ENTRY_LOG_CALLFLOW(); - + std::string apn = attributes.apn; if (nullptr != mGnss && (nullptr != mGnss->getGnssInterface())) { int8_t typeout = loc_core::TYPE_UNKNOWN; bool roaming = false; @@ -120,8 +121,9 @@ Return<bool> AGnssRil::updateNetworkState_2_0(const V2_0::IAGnssRil::NetworkAttr if (attributes.capabilities & IAGnssRil::NetworkCapability::NOT_ROAMING) { roaming = false; } + LOC_LOGd("apn string received is: %s", apn.c_str()); mGnss->getGnssInterface()->updateConnectionStatus(attributes.isConnected, - typeout, roaming, (NetworkHandle) attributes.networkHandle); + typeout, roaming, (NetworkHandle) attributes.networkHandle, apn); } return true; } diff --git a/android/2.1/AGnssRil.cpp b/android/2.1/AGnssRil.cpp index 65fb300..f413e93 100644 --- a/android/2.1/AGnssRil.cpp +++ b/android/2.1/AGnssRil.cpp @@ -54,6 +54,7 @@ Return<bool> AGnssRil::updateNetworkState(bool connected, NetworkType type, bool const int NetworkType_BLUETOOTH = 7; const int NetworkType_ETHERNET = 9; const int NetworkType_PROXY = 16; + std::string apn(""); // for XTRA if (nullptr != mGnss && ( nullptr != mGnss->getGnssInterface() )) { @@ -102,13 +103,13 @@ Return<bool> AGnssRil::updateNetworkState(bool connected, NetworkType type, bool } break; } - mGnss->getGnssInterface()->updateConnectionStatus(connected, false, typeout, 0); + mGnss->getGnssInterface()->updateConnectionStatus(connected, typeout, false, 0, apn); } return true; } Return<bool> AGnssRil::updateNetworkState_2_0(const V2_0::IAGnssRil::NetworkAttributes& attributes) { ENTRY_LOG_CALLFLOW(); - + std::string apn = attributes.apn; if (nullptr != mGnss && (nullptr != mGnss->getGnssInterface())) { int8_t typeout = loc_core::TYPE_UNKNOWN; bool roaming = false; @@ -120,8 +121,9 @@ Return<bool> AGnssRil::updateNetworkState_2_0(const V2_0::IAGnssRil::NetworkAttr if (attributes.capabilities & IAGnssRil::NetworkCapability::NOT_ROAMING) { roaming = false; } + LOC_LOGd("apn string received is: %s", apn.c_str()); mGnss->getGnssInterface()->updateConnectionStatus(attributes.isConnected, - typeout, roaming, (NetworkHandle) attributes.networkHandle); + typeout, roaming, (NetworkHandle) attributes.networkHandle, apn); } return true; } diff --git a/core/SystemStatus.cpp b/core/SystemStatus.cpp index 891a8e6..d792577 100644 --- a/core/SystemStatus.cpp +++ b/core/SystemStatus.cpp @@ -1291,7 +1291,7 @@ void SystemStatus::resetNetworkInfo() { for (int i=0; i<mCache.mNetworkInfo.size(); ++i) { // Reset all the cached NetworkInfo Items as disconnected eventConnectionStatus(false, mCache.mNetworkInfo[i].mType, mCache.mNetworkInfo[i].mRoaming, - mCache.mNetworkInfo[i].mNetworkHandle); + mCache.mNetworkInfo[i].mNetworkHandle, mCache.mNetworkInfo[i].mApn); } } @@ -1732,11 +1732,12 @@ bool SystemStatus::setDefaultGnssEngineStates(void) @return true when successfully done ******************************************************************************/ bool SystemStatus::eventConnectionStatus(bool connected, int8_t type, - bool roaming, NetworkHandle networkHandle) + bool roaming, NetworkHandle networkHandle, + string& apn) { // send networkinof dataitem to systemstatus observer clients SystemStatusNetworkInfo s(type, "", "", connected, roaming, - (uint64_t) networkHandle); + (uint64_t) networkHandle, apn); mSysStatusObsvr.notify({&s}); return true; diff --git a/core/SystemStatus.h b/core/SystemStatus.h index d7e60dd..097e7cc 100644 --- a/core/SystemStatus.h +++ b/core/SystemStatus.h @@ -482,12 +482,13 @@ class SystemStatusNetworkInfo : public SystemStatusItemBase, NetworkInfoDataItemBase* mSrcObjPtr; public: inline SystemStatusNetworkInfo( - int32_t type=0, - std::string typeName="", - string subTypeName="", - bool connected=false, - bool roaming=false, - uint64_t networkHandle=NETWORK_HANDLE_UNKNOWN) : + int32_t type = 0, + std::string typeName = "", + string subTypeName = "", + bool connected = false, + bool roaming = false, + uint64_t networkHandle = NETWORK_HANDLE_UNKNOWN, + string apn = "") : NetworkInfoDataItemBase( (NetworkType)type, type, @@ -496,7 +497,7 @@ public: connected && (!roaming), connected, roaming, - networkHandle), + networkHandle, apn), mSrcObjPtr(nullptr) {} inline SystemStatusNetworkInfo(const NetworkInfoDataItemBase& itemBase) : NetworkInfoDataItemBase(itemBase), @@ -508,14 +509,19 @@ public: for (uint8_t i = 0; rtv && i < MAX_NETWORK_HANDLES; ++i) { rtv &= (mAllNetworkHandles[i] == peer.mAllNetworkHandles[i]); } - return rtv; + return peer.mApn.compare(mApn); } inline virtual SystemStatusItemBase& collate(SystemStatusItemBase& curInfo) { 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 memcpy(mAllNetworkHandles, (static_cast<SystemStatusNetworkInfo&>(curInfo)).getNetworkHandle(), sizeof(mAllNetworkHandles)); + // Update the apn for non-mobile type connections. + if (TYPE_MOBILE != mType && apn.compare("") != 0) { + mApn = apn; + } if (mConnected) { mAllTypes |= allTypes; for (uint8_t i = 0; i < MAX_NETWORK_HANDLES; ++i) { @@ -577,8 +583,8 @@ public: return *this; } inline void dump(void) override { - LOC_LOGD("NetworkInfo: mAllTypes=%" PRIx64 " connected=%u mType=%x", - mAllTypes, mConnected, mType); + LOC_LOGD("NetworkInfo: mAllTypes=%" PRIx64 " connected=%u mType=%x mApn=%s", + mAllTypes, mConnected, mType, mApn.c_str()); } }; @@ -907,7 +913,7 @@ public: bool getReport(SystemStatusReports& reports, bool isLatestonly = false) const; bool setDefaultGnssEngineStates(void); bool eventConnectionStatus(bool connected, int8_t type, - bool roaming, NetworkHandle networkHandle); + bool roaming, NetworkHandle networkHandle, string& apn); bool updatePowerConnectState(bool charging); void resetNetworkInfo(); }; diff --git a/core/data-items/DataItemConcreteTypesBase.h b/core/data-items/DataItemConcreteTypesBase.h index c32d65d..11a3cce 100644 --- a/core/data-items/DataItemConcreteTypesBase.h +++ b/core/data-items/DataItemConcreteTypesBase.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2015-2017, 2019, The Linux Foundation. All rights reserved. +/* Copyright (c) 2015-2017, 2020, 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 @@ -284,7 +284,7 @@ class NetworkInfoDataItemBase : public IDataItemCore { public: NetworkInfoDataItemBase( NetworkType initialType, int32_t type, string typeName, string subTypeName, - bool available, bool connected, bool roaming, uint64_t networkHandle ): + bool available, bool connected, bool roaming, uint64_t networkHandle, string apn): mAllTypes(typeToAllTypes(initialType)), mType(type), mTypeName(typeName), @@ -293,7 +293,7 @@ public: mConnected(connected), mRoaming(roaming), mNetworkHandle(networkHandle), - mId(NETWORKINFO_DATA_ITEM_ID) { + mId(NETWORKINFO_DATA_ITEM_ID), mApn(apn) { mAllNetworkHandles[0].networkHandle = networkHandle; mAllNetworkHandles[0].networkType = initialType; } @@ -318,6 +318,7 @@ public: bool mRoaming; NetworkInfoType mAllNetworkHandles[MAX_NETWORK_HANDLES]; uint64_t mNetworkHandle; + string mApn; protected: DataItemId mId; inline uint64_t typeToAllTypes(NetworkType type) { diff --git a/gnss/Android.bp b/gnss/Android.bp index af0a208..a3e8de9 100644 --- a/gnss/Android.bp +++ b/gnss/Android.bp @@ -21,6 +21,7 @@ cc_library_shared { "GnssAdapter.cpp", "Agps.cpp", "XtraSystemStatusObserver.cpp", + "NativeAgpsHandler.cpp", ], cflags: ["-fno-short-enums"] + GNSS_CFLAGS, diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index d3792b9..759b42d 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -137,7 +137,8 @@ GnssAdapter::GnssAdapter() : mLastDeleteAidingDataTime(0), mDgnssState(0), mSendNmeaConsent(false), - mDgnssLastNmeaBootTimeMilli(0) + mDgnssLastNmeaBootTimeMilli(0), + mNativeAgpsHandler(mSystemStatus->getOsObserver(), *this) { LOC_LOGD("%s]: Constructor %p", __func__, this); mLocPositionMode.mode = LOC_POSITION_MODE_INVALID; @@ -5027,23 +5028,20 @@ GnssAdapter::reportGnssEngEnergyConsumedEvent(uint64_t energyConsumedSinceFirstB void GnssAdapter::initDefaultAgps() { LOC_LOGD("%s]: ", __func__); - void *handle = nullptr; - if ((handle = dlopen("libloc_net_iface.so", RTLD_NOW)) == nullptr) { - LOC_LOGD("%s]: libloc_net_iface.so not found !", __func__); - return; - } - LocAgpsGetAgpsCbInfo getAgpsCbInfo = (LocAgpsGetAgpsCbInfo) - dlsym(handle, "LocNetIfaceAgps_getAgpsCbInfo"); - if (getAgpsCbInfo == nullptr) { - LOC_LOGE("%s]: Failed to get method LocNetIfaceAgps_getStatusCb", __func__); - dlclose(handle); - return; + LocAgpsGetAgpsCbInfo getAgpsCbInfo = + (LocAgpsGetAgpsCbInfo)dlGetSymFromLib(handle, "libloc_net_iface.so", + "LocNetIfaceAgps_getAgpsCbInfo"); + // Below step is to make sure we init nativeAgpsHandler + // for Android platforms only + AgpsCbInfo cbInfo = {}; + if (nullptr != getAgpsCbInfo) { + cbInfo = getAgpsCbInfo(agpsOpenResultCb, agpsCloseResultCb, this); + } else { + cbInfo = mNativeAgpsHandler.getAgpsCbInfo(); } - AgpsCbInfo& cbInfo = getAgpsCbInfo(agpsOpenResultCb, agpsCloseResultCb, this); - if (cbInfo.statusV4Cb == nullptr) { LOC_LOGE("%s]: statusV4Cb is nullptr!", __func__); dlclose(handle); diff --git a/gnss/GnssAdapter.h b/gnss/GnssAdapter.h index 5e617f7..3622c88 100644 --- a/gnss/GnssAdapter.h +++ b/gnss/GnssAdapter.h @@ -41,6 +41,7 @@ #include <functional> #include <loc_misc_utils.h> #include <queue> +#include <NativeAgpsHandler.h> #define MAX_URL_LEN 256 #define NMEA_SENTENCE_MAX_LENGTH 200 @@ -281,6 +282,9 @@ class GnssAdapter : public LocAdapterBase { GnssReportLoggerUtil mLogger; bool mDreIntEnabled; + /* === NativeAgpsHandler ======================================================== */ + NativeAgpsHandler mNativeAgpsHandler; + /* === Misc callback from QMI LOC API ============================================== */ GnssEnergyConsumedCallback mGnssEnergyConsumedCb; std::function<void(bool)> mPowerStateCb; diff --git a/gnss/Makefile.am b/gnss/Makefile.am index db20c15..dd313a1 100644 --- a/gnss/Makefile.am +++ b/gnss/Makefile.am @@ -13,7 +13,8 @@ libgnss_la_SOURCES = \ location_gnss.cpp \ GnssAdapter.cpp \ XtraSystemStatusObserver.cpp \ - Agps.cpp + Agps.cpp \ + NativeAgpsHandler.cpp if USE_GLIB libgnss_la_CFLAGS = -DUSE_GLIB $(AM_CFLAGS) @GLIB_CFLAGS@ diff --git a/gnss/NativeAgpsHandler.cpp b/gnss/NativeAgpsHandler.cpp new file mode 100644 index 0000000..ce4c03a --- /dev/null +++ b/gnss/NativeAgpsHandler.cpp @@ -0,0 +1,127 @@ +/* Copyright (c) 2020, 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 + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#define LOG_TAG "LocSvc_NativeAgpsHandler" + +#include <LocAdapterBase.h> +#include <SystemStatus.h> +#include <DataItemId.h> +#include <DataItemsFactoryProxy.h> +#include <DataItemConcreteTypesBase.h> +#include <loc_log.h> +#include <NativeAgpsHandler.h> +#include <GnssAdapter.h> + +using namespace loc_core; + +// IDataItemObserver overrides +void NativeAgpsHandler::getName(string& name) { + name = "NativeAgpsHandler"; +} + +void NativeAgpsHandler::notify(const list<IDataItemCore*>& dlist) { + for (auto each : dlist) { + switch (each->getId()) { + case NETWORKINFO_DATA_ITEM_ID: { + NetworkInfoDataItemBase* networkInfo = + static_cast<NetworkInfoDataItemBase*>(each); + uint64_t mobileBit = (uint64_t )1 << loc_core::TYPE_MOBILE; + uint64_t allTypes = networkInfo->mAllTypes; + mConnected = ((networkInfo->mAllTypes & mobileBit) == mobileBit); + /** + * mApn Telephony preferred Access Point Name to use for + * carrier data connection when connected to a cellular network. + * Empty string, otherwise. + */ + mApn = networkInfo->mApn; + LOC_LOGd("updated mConnected:%d, mApn: %s", mConnected, mApn.c_str()); + break; + } + default: + break; + } + } +} + +NativeAgpsHandler* NativeAgpsHandler::sLocalHandle = nullptr; +NativeAgpsHandler::NativeAgpsHandler(IOsObserver* sysStatObs, GnssAdapter& adapter) : + mSystemStatusObsrvr(sysStatObs), mConnected(false), mAdapter(adapter) { + sLocalHandle = this; + list<DataItemId> subItemIdList = {NETWORKINFO_DATA_ITEM_ID}; + mSystemStatusObsrvr->subscribe(subItemIdList, this); +} + +NativeAgpsHandler::~NativeAgpsHandler() { + if (nullptr != mSystemStatusObsrvr) { + LOC_LOGd("Unsubscribe for network info."); + list<DataItemId> subItemIdList = {NETWORKINFO_DATA_ITEM_ID}; + mSystemStatusObsrvr->unsubscribe(subItemIdList, this); + } + sLocalHandle = nullptr; + mSystemStatusObsrvr = nullptr; +} + + +AgpsCbInfo NativeAgpsHandler::getAgpsCbInfo() { + AgpsCbInfo nativeCbInfo = {}; + nativeCbInfo.statusV4Cb = (void*)agnssStatusIpV4Cb; + nativeCbInfo.atlType = AGPS_ATL_TYPE_WWAN; + return nativeCbInfo; +} + +void NativeAgpsHandler::agnssStatusIpV4Cb(AGnssExtStatusIpV4 statusInfo) { + if (nullptr != sLocalHandle) { + sLocalHandle->processATLRequestRelease(statusInfo); + } else { + LOC_LOGe("sLocalHandle is null"); + } +} + +void NativeAgpsHandler::processATLRequestRelease(AGnssExtStatusIpV4 statusInfo) { + if (LOC_AGPS_TYPE_WWAN_ANY == statusInfo.type) { + LOC_LOGd("status.type = %d status.apnTypeMask = 0x%X", statusInfo.type, + statusInfo.apnTypeMask); + switch (statusInfo.status) { + case LOC_GPS_REQUEST_AGPS_DATA_CONN: + if (mConnected) { + mAdapter.dataConnOpenCommand(LOC_AGPS_TYPE_WWAN_ANY, mApn.c_str(), mApn.size(), + AGPS_APN_BEARER_IPV4); + } else { + mAdapter.dataConnFailedCommand(LOC_AGPS_TYPE_WWAN_ANY); + } + break; + case LOC_GPS_RELEASE_AGPS_DATA_CONN: + mAdapter.dataConnClosedCommand(LOC_AGPS_TYPE_WWAN_ANY); + break; + default: + LOC_LOGe("Invalid Request: %d", statusInfo.status); + } + } else { + LOC_LOGe("mAgpsManger is null or invalid request type!"); + } +} diff --git a/gnss/NativeAgpsHandler.h b/gnss/NativeAgpsHandler.h new file mode 100644 index 0000000..fb0b46c --- /dev/null +++ b/gnss/NativeAgpsHandler.h @@ -0,0 +1,64 @@ +/* Copyright (c) 2020, 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 + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef NATIVEAGPSHANDLER_H +#define NATIVEAGPSHANDLER_H + +#include <cinttypes> +#include <string.h> +#include <gps_extended_c.h> +#include <IDataItemObserver.h> +#include <IDataItemCore.h> +#include <IOsObserver.h> + +using namespace std; +using loc_core::IOsObserver; +using loc_core::IDataItemObserver; +using loc_core::IDataItemCore; + +class GnssAdapter; + +class NativeAgpsHandler : public IDataItemObserver { +public: + NativeAgpsHandler(IOsObserver* sysStatObs, GnssAdapter& adapter); + ~NativeAgpsHandler(); + AgpsCbInfo getAgpsCbInfo(); + // IDataItemObserver overrides + virtual void notify(const list<IDataItemCore*>& dlist); + inline virtual void getName(string& name); +private: + static NativeAgpsHandler* sLocalHandle; + static void agnssStatusIpV4Cb(AGnssExtStatusIpV4 statusInfo); + void processATLRequestRelease(AGnssExtStatusIpV4 statusInfo); + IOsObserver* mSystemStatusObsrvr; + bool mConnected; + string mApn; + GnssAdapter& mAdapter; +}; + +#endif // NATIVEAGPSHANDLER_H diff --git a/gnss/location_gnss.cpp b/gnss/location_gnss.cpp index 04a461a..0454a13 100644 --- a/gnss/location_gnss.cpp +++ b/gnss/location_gnss.cpp @@ -66,8 +66,8 @@ static void agpsDataConnOpen(AGpsExtType agpsType, const char* apnName, int apnL static void agpsDataConnClosed(AGpsExtType agpsType); static void agpsDataConnFailed(AGpsExtType agpsType); static void getDebugReport(GnssDebugReport& report); -static void updateConnectionStatus(bool connected, int8_t type, bool roaming = false, - NetworkHandle networkHandle = NETWORK_HANDLE_UNKNOWN); +static void updateConnectionStatus(bool connected, int8_t type, bool roaming, + NetworkHandle networkHandle, string& apn); static void getGnssEnergyConsumed(GnssEnergyConsumedCallback energyConsumedCb); static void enableNfwLocationAccess(bool enable); static void nfwInit(const NfwCbInfo& cbInfo); @@ -371,10 +371,11 @@ static void getDebugReport(GnssDebugReport& report) { } static void updateConnectionStatus(bool connected, int8_t type, - bool roaming, NetworkHandle networkHandle) { + bool roaming, NetworkHandle networkHandle, + string& apn) { if (NULL != gGnssAdapter) { gGnssAdapter->getSystemStatus()->eventConnectionStatus( - connected, type, roaming, networkHandle); + connected, type, roaming, networkHandle, apn); } } diff --git a/location/location_interface.h b/location/location_interface.h index 01bbe45..69d4f0c 100644 --- a/location/location_interface.h +++ b/location/location_interface.h @@ -78,7 +78,7 @@ struct GnssInterface { void (*agpsDataConnFailed)(AGpsExtType agpsType); void (*getDebugReport)(GnssDebugReport& report); void (*updateConnectionStatus)(bool connected, int8_t type, bool roaming, - NetworkHandle networkHandle); + NetworkHandle networkHandle, std::string& apn); void (*odcpiInit)(const OdcpiRequestCallback& callback, OdcpiPrioritytype priority); void (*odcpiInject)(const Location& location); void (*blockCPI)(double latitude, double longitude, float accuracy, |