147ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. 2e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * 3e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * Redistribution and use in source and binary forms, with or without 4e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * modification, are permitted provided that the following conditions are 5e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * met: 6e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * * Redistributions of source code must retain the above copyright 7e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * notice, this list of conditions and the following disclaimer. 8e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * * Redistributions in binary form must reproduce the above 9e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * copyright notice, this list of conditions and the following 10e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * disclaimer in the documentation and/or other materials provided 11e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * with the distribution. 12e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * * Neither the name of The Linux Foundation, nor the names of its 13e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * contributors may be used to endorse or promote products derived 14e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * from this software without specific prior written permission. 15e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * 16e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * 28e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo */ 29e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo#ifndef LOC_API_ADAPTER_BASE_H 30e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo#define LOC_API_ADAPTER_BASE_H 31e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo 32e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo#include <gps_extended.h> 33e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo#include <UlpProxyBase.h> 34e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo#include <ContextBase.h> 35e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo 36e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russonamespace loc_core { 37e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo 3847ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russoclass LocAdapterProxyBase; 3947ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo 40e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russoclass LocAdapterBase { 41e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russoprotected: 42bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo LOC_API_ADAPTER_EVENT_MASK_T mEvtMask; 43e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo ContextBase* mContext; 44e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo LocApiBase* mLocApi; 4547ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo LocAdapterProxyBase* mLocAdapterProxyBase; 46e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo const MsgTask* mMsgTask; 47e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo 48e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo inline LocAdapterBase(const MsgTask* msgTask) : 49bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo mEvtMask(0), mContext(NULL), mLocApi(NULL), 50bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo mLocAdapterProxyBase(NULL), mMsgTask(msgTask) {} 510ed9ab19618e840907e343877bf91bd30aba8be9Vineeta Srivastavapublic: 5247ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); } 5347ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask, 5447ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo ContextBase* context, LocAdapterProxyBase *adapterProxyBase = NULL); 55e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo inline LOC_API_ADAPTER_EVENT_MASK_T 56e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo checkMask(LOC_API_ADAPTER_EVENT_MASK_T mask) const { 57e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo return mEvtMask & mask; 58e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo } 59e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo 60e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo inline LOC_API_ADAPTER_EVENT_MASK_T getEvtMask() const { 61e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo return mEvtMask; 62e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo } 63e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo 64e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo inline void sendMsg(const LocMsg* msg) const { 65e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo mMsgTask->sendMsg(msg); 66e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo } 67e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo 68e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo inline void sendMsg(const LocMsg* msg) { 69e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo mMsgTask->sendMsg(msg); 70e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo } 71e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo 72bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo inline void updateEvtMask(LOC_API_ADAPTER_EVENT_MASK_T event, 73bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo loc_registration_mask_status isEnabled) 74bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo { 75bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo mEvtMask = 76bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo isEnabled == LOC_REGISTRATION_MASK_ENABLED ? (mEvtMask|event):(mEvtMask&~event); 77bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo 78bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo mLocApi->updateEvtMask(); 79bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo } 80bfff6343845ad9ff062c5fd97bb3b9be1053340eDante Russo 81e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo // This will be overridden by the individual adapters 82e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo // if necessary. 83e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo inline virtual void setUlpProxy(UlpProxyBase* ulp) {} 8447ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo virtual void handleEngineUpEvent(); 85e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo virtual void handleEngineDownEvent(); 86e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo inline virtual void setPositionModeInt(LocPosMode& posMode) {} 87e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo virtual void startFixInt() {} 88e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo virtual void stopFixInt() {} 8947ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo virtual void getZppInt() {} 90e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo virtual void reportPosition(UlpLocation &location, 91e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo GpsLocationExtended &locationExtended, 92e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo void* locationExt, 93e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo enum loc_sess_status status, 94e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo LocPosTechMask loc_technology_mask); 95e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo virtual void reportSv(GpsSvStatus &svStatus, 96e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo GpsLocationExtended &locationExtended, 97e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo void* svExt); 98e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo virtual void reportStatus(GpsStatusValue status); 99e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo virtual void reportNmea(const char* nmea, int length); 100e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo virtual bool reportXtraServer(const char* url1, const char* url2, 101e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo const char* url3, const int maxlength); 102e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo virtual bool requestXtraData(); 103e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo virtual bool requestTime(); 104e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo virtual bool requestLocation(); 105e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo virtual bool requestATL(int connHandle, AGpsType agps_type); 106e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo virtual bool releaseATL(int connHandle); 107e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo virtual bool requestSuplES(int connHandle); 108e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo virtual bool reportDataCallOpened(); 109e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo virtual bool reportDataCallClosed(); 110e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo virtual bool requestNiNotify(GpsNiNotification ¬ify, 111e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo const void* data); 112e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo inline virtual bool isInSession() { return false; } 11347ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo ContextBase* getContext() const { return mContext; } 1148aac9d301fc5aa83071492803f4335b73f2604e3Vineeta Srivastava virtual void reportGpsMeasurementData(GpsData &gpsMeasurementData); 115e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo}; 116e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo 117e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo} // namespace loc_core 118e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo 119e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo#endif //LOC_API_ADAPTER_BASE_H 120