1 /* Copyright (c) 2011-2014,2016 The 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 #ifndef LOC_API_ADAPTER_BASE_H 30 #define LOC_API_ADAPTER_BASE_H 31 32 #include <gps_extended.h> 33 #include <UlpProxyBase.h> 34 #include <ContextBase.h> 35 36 namespace loc_core { 37 38 class LocAdapterProxyBase; 39 40 class LocAdapterBase { 41 protected: 42 LOC_API_ADAPTER_EVENT_MASK_T mEvtMask; 43 ContextBase* mContext; 44 LocApiBase* mLocApi; 45 LocAdapterProxyBase* mLocAdapterProxyBase; 46 const MsgTask* mMsgTask; 47 LocAdapterBase(const MsgTask * msgTask)48 inline LocAdapterBase(const MsgTask* msgTask) : 49 mEvtMask(0), mContext(NULL), mLocApi(NULL), 50 mLocAdapterProxyBase(NULL), mMsgTask(msgTask) {} 51 public: ~LocAdapterBase()52 inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); } 53 LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask, 54 ContextBase* context, LocAdapterProxyBase *adapterProxyBase = NULL); 55 inline LOC_API_ADAPTER_EVENT_MASK_T checkMask(LOC_API_ADAPTER_EVENT_MASK_T mask)56 checkMask(LOC_API_ADAPTER_EVENT_MASK_T mask) const { 57 return mEvtMask & mask; 58 } 59 getEvtMask()60 inline LOC_API_ADAPTER_EVENT_MASK_T getEvtMask() const { 61 return mEvtMask; 62 } 63 sendMsg(const LocMsg * msg)64 inline void sendMsg(const LocMsg* msg) const { 65 mMsgTask->sendMsg(msg); 66 } 67 sendMsg(const LocMsg * msg)68 inline void sendMsg(const LocMsg* msg) { 69 mMsgTask->sendMsg(msg); 70 } 71 updateEvtMask(LOC_API_ADAPTER_EVENT_MASK_T event,loc_registration_mask_status isEnabled)72 inline void updateEvtMask(LOC_API_ADAPTER_EVENT_MASK_T event, 73 loc_registration_mask_status isEnabled) 74 { 75 mEvtMask = 76 isEnabled == LOC_REGISTRATION_MASK_ENABLED ? (mEvtMask|event):(mEvtMask&~event); 77 78 mLocApi->updateEvtMask(); 79 } 80 isFeatureSupported(uint8_t featureVal)81 inline bool isFeatureSupported(uint8_t featureVal) { 82 return mLocApi->isFeatureSupported(featureVal); 83 } 84 85 // This will be overridden by the individual adapters 86 // if necessary. setUlpProxy(UlpProxyBase * ulp)87 inline virtual void setUlpProxy(UlpProxyBase* ulp) { 88 89 (void)ulp; 90 } 91 virtual void handleEngineUpEvent(); 92 virtual void handleEngineDownEvent(); setPositionModeInt(LocPosMode & posMode)93 inline virtual void setPositionModeInt(LocPosMode& posMode) { 94 95 (void)posMode; 96 } startFixInt()97 virtual void startFixInt() {} stopFixInt()98 virtual void stopFixInt() {} getZppInt()99 virtual void getZppInt() {} 100 virtual void reportPosition(UlpLocation &location, 101 GpsLocationExtended &locationExtended, 102 void* locationExt, 103 enum loc_sess_status status, 104 LocPosTechMask loc_technology_mask); 105 virtual void reportSv(GnssSvStatus &svStatus, 106 GpsLocationExtended &locationExtended, 107 void* svExt); 108 virtual void reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet); 109 virtual void reportSvPolynomial(GnssSvPolynomial &svPolynomial); 110 virtual void reportStatus(GpsStatusValue status); 111 virtual void reportNmea(const char* nmea, int length); 112 virtual bool reportXtraServer(const char* url1, const char* url2, 113 const char* url3, const int maxlength); 114 virtual bool requestXtraData(); 115 virtual bool requestTime(); 116 virtual bool requestLocation(); 117 virtual bool requestATL(int connHandle, AGpsType agps_type); 118 virtual bool releaseATL(int connHandle); 119 virtual bool requestSuplES(int connHandle); 120 virtual bool reportDataCallOpened(); 121 virtual bool reportDataCallClosed(); 122 virtual bool requestNiNotify(GpsNiNotification ¬ify, 123 const void* data); isInSession()124 inline virtual bool isInSession() { return false; } getContext()125 ContextBase* getContext() const { return mContext; } 126 virtual void reportGnssMeasurementData(GnssData &gnssMeasurementData); 127 virtual bool reportWwanZppFix(GpsLocation &zppLoc); 128 }; 129 130 } // namespace loc_core 131 132 #endif //LOC_API_ADAPTER_BASE_H 133