1 /* Copyright (c) 2011-2014, 2016-2017The Linux Foundation. All rights reserved. 2 * 3 * Redistribution and use in source and binary forms, with or without 4 * modification, are permitted provided that the following conditions are 5 * met: 6 * * Redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer. 8 * * Redistributions in binary form must reproduce the above 9 * copyright notice, this list of conditions and the following 10 * disclaimer in the documentation and/or other materials provided 11 * with the distribution. 12 * * Neither the name of The Linux Foundation, nor the names of its 13 * contributors may be used to endorse or promote products derived 14 * from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 */ 29 #define LOG_NDEBUG 0 30 #define LOG_TAG "LocSvc_LocAdapterBase" 31 32 #include <dlfcn.h> 33 #include <LocAdapterBase.h> 34 #include <loc_target.h> 35 #include <platform_lib_log_util.h> 36 #include <LocAdapterProxyBase.h> 37 38 namespace loc_core { 39 40 // This is the top level class, so the constructor will 41 // always gets called. Here we prepare for the default. 42 // But if getLocApi(targetEnumType target) is overriden, 43 // the right locApi should get created. 44 LocAdapterBase::LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask, 45 ContextBase* context, LocAdapterProxyBase *adapterProxyBase) : 46 mEvtMask(mask), mContext(context), 47 mLocApi(context->getLocApi()), mLocAdapterProxyBase(adapterProxyBase), 48 mMsgTask(context->getMsgTask()) 49 { 50 mLocApi->addAdapter(this); 51 } 52 53 uint32_t LocAdapterBase::mSessionIdCounter(1); 54 55 uint32_t LocAdapterBase::generateSessionId() 56 { 57 if (++mSessionIdCounter == 0xFFFFFFFF) 58 mSessionIdCounter = 1; 59 60 return mSessionIdCounter; 61 } 62 63 void LocAdapterBase::handleEngineUpEvent() 64 { 65 if (mLocAdapterProxyBase) { 66 mLocAdapterProxyBase->handleEngineUpEvent(); 67 } 68 } 69 70 void LocAdapterBase::handleEngineDownEvent() 71 { 72 if (mLocAdapterProxyBase) { 73 mLocAdapterProxyBase->handleEngineDownEvent(); 74 } 75 } 76 77 void LocAdapterBase:: 78 reportPositionEvent(const UlpLocation& location, 79 const GpsLocationExtended& locationExtended, 80 enum loc_sess_status status, 81 LocPosTechMask loc_technology_mask, 82 bool fromUlp) { 83 if (mLocAdapterProxyBase != NULL) { 84 mLocAdapterProxyBase->reportPositionEvent((UlpLocation&)location, 85 (GpsLocationExtended&)locationExtended, 86 status, 87 loc_technology_mask); 88 } else { 89 DEFAULT_IMPL() 90 } 91 } 92 93 void LocAdapterBase:: 94 reportSvEvent(const GnssSvNotification& svNotify, bool fromUlp) 95 DEFAULT_IMPL() 96 97 void LocAdapterBase:: 98 reportSvMeasurementEvent(GnssSvMeasurementSet &svMeasurementSet) 99 DEFAULT_IMPL() 100 101 void LocAdapterBase:: 102 reportSvPolynomialEvent(GnssSvPolynomial &svPolynomial) 103 DEFAULT_IMPL() 104 105 void LocAdapterBase:: 106 reportStatus(LocGpsStatusValue status) 107 DEFAULT_IMPL() 108 109 110 void LocAdapterBase:: 111 reportNmeaEvent(const char* nmea, size_t length, bool fromUlp) 112 DEFAULT_IMPL() 113 114 bool LocAdapterBase:: 115 reportXtraServer(const char* url1, const char* url2, 116 const char* url3, const int maxlength) 117 DEFAULT_IMPL(false) 118 119 bool LocAdapterBase:: 120 requestXtraData() 121 DEFAULT_IMPL(false) 122 123 bool LocAdapterBase:: 124 requestTime() 125 DEFAULT_IMPL(false) 126 127 bool LocAdapterBase:: 128 requestLocation() 129 DEFAULT_IMPL(false) 130 131 bool LocAdapterBase:: 132 requestATL(int connHandle, LocAGpsType agps_type) 133 DEFAULT_IMPL(false) 134 135 bool LocAdapterBase:: 136 releaseATL(int connHandle) 137 DEFAULT_IMPL(false) 138 139 bool LocAdapterBase:: 140 requestSuplES(int connHandle) 141 DEFAULT_IMPL(false) 142 143 bool LocAdapterBase:: 144 reportDataCallOpened() 145 DEFAULT_IMPL(false) 146 147 bool LocAdapterBase:: 148 reportDataCallClosed() 149 DEFAULT_IMPL(false) 150 151 bool LocAdapterBase:: 152 requestNiNotifyEvent(const GnssNiNotification ¬ify, const void* data) 153 DEFAULT_IMPL(false) 154 155 void LocAdapterBase:: 156 reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& measurementsNotify) 157 DEFAULT_IMPL() 158 159 bool LocAdapterBase:: 160 reportWwanZppFix(LocGpsLocation &zppLoc) 161 DEFAULT_IMPL(false) 162 163 } // namespace loc_core 164