147ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. 234ee09551764b045fdc02df754157473125edf60Kevin Tang * 334ee09551764b045fdc02df754157473125edf60Kevin Tang * Redistribution and use in source and binary forms, with or without 434ee09551764b045fdc02df754157473125edf60Kevin Tang * modification, are permitted provided that the following conditions are 534ee09551764b045fdc02df754157473125edf60Kevin Tang * met: 634ee09551764b045fdc02df754157473125edf60Kevin Tang * * Redistributions of source code must retain the above copyright 734ee09551764b045fdc02df754157473125edf60Kevin Tang * notice, this list of conditions and the following disclaimer. 834ee09551764b045fdc02df754157473125edf60Kevin Tang * * Redistributions in binary form must reproduce the above 934ee09551764b045fdc02df754157473125edf60Kevin Tang * copyright notice, this list of conditions and the following 1034ee09551764b045fdc02df754157473125edf60Kevin Tang * disclaimer in the documentation and/or other materials provided 1134ee09551764b045fdc02df754157473125edf60Kevin Tang * with the distribution. 12e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo * * Neither the name of The Linux Foundation, nor the names of its 1334ee09551764b045fdc02df754157473125edf60Kevin Tang * contributors may be used to endorse or promote products derived 1434ee09551764b045fdc02df754157473125edf60Kevin Tang * from this software without specific prior written permission. 1534ee09551764b045fdc02df754157473125edf60Kevin Tang * 1634ee09551764b045fdc02df754157473125edf60Kevin Tang * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 1734ee09551764b045fdc02df754157473125edf60Kevin Tang * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 1834ee09551764b045fdc02df754157473125edf60Kevin Tang * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 1934ee09551764b045fdc02df754157473125edf60Kevin Tang * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 2034ee09551764b045fdc02df754157473125edf60Kevin Tang * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2134ee09551764b045fdc02df754157473125edf60Kevin Tang * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2234ee09551764b045fdc02df754157473125edf60Kevin Tang * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 2334ee09551764b045fdc02df754157473125edf60Kevin Tang * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 2434ee09551764b045fdc02df754157473125edf60Kevin Tang * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 2534ee09551764b045fdc02df754157473125edf60Kevin Tang * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 2634ee09551764b045fdc02df754157473125edf60Kevin Tang * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2734ee09551764b045fdc02df754157473125edf60Kevin Tang * 2834ee09551764b045fdc02df754157473125edf60Kevin Tang */ 29e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo#ifndef __LOC_CONTEXT_BASE__ 30e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo#define __LOC_CONTEXT_BASE__ 3134ee09551764b045fdc02df754157473125edf60Kevin Tang 32e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo#include <stdbool.h> 33e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo#include <ctype.h> 34e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo#include <MsgTask.h> 35e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo#include <LocApiBase.h> 3647ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo#include <LBSProxyBase.h> 3734ee09551764b045fdc02df754157473125edf60Kevin Tang 38e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russonamespace loc_core { 3934ee09551764b045fdc02df754157473125edf60Kevin Tang 40e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russoclass LocAdapterBase; 4134ee09551764b045fdc02df754157473125edf60Kevin Tang 42e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russoclass ContextBase { 4347ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo static LBSProxyBase* getLBSProxy(const char* libName); 44e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo LocApiBase* createLocApi(LOC_API_ADAPTER_EVENT_MASK_T excludedMask); 45e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russoprotected: 4647ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo const LBSProxyBase* mLBSProxy; 47e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo const MsgTask* mMsgTask; 48e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo LocApiBase* mLocApi; 4947ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo LocApiProxyBase *mLocApiProxy; 50e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russopublic: 51e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo ContextBase(const MsgTask* msgTask, 52e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo LOC_API_ADAPTER_EVENT_MASK_T exMask, 53e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo const char* libName); 5447ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo inline virtual ~ContextBase() { delete mLocApi; delete mLBSProxy; } 5534ee09551764b045fdc02df754157473125edf60Kevin Tang 56e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo inline const MsgTask* getMsgTask() { return mMsgTask; } 57e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo inline LocApiBase* getLocApi() { return mLocApi; } 5847ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo inline LocApiProxyBase* getLocApiProxy() { return mLocApiProxy; } 5947ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo inline bool hasAgpsExtendedCapabilities() { return mLBSProxy->hasAgpsExtendedCapabilities(); } 6047ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo inline bool hasCPIExtendedCapabilities() { return mLBSProxy->hasCPIExtendedCapabilities(); } 610c7fdf015bfdb33b14a990b280c38386cb8e1f9cVineeta Srivastava inline void modemPowerVote(bool power) const { return mLBSProxy->modemPowerVote(power); } 62e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo inline void requestUlp(LocAdapterBase* adapter, 63e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo unsigned long capabilities) { 6447ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo mLBSProxy->requestUlp(adapter, capabilities); 65e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo } 6647ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo inline void sendMsg(const LocMsg *msg) { getMsgTask()->sendMsg(msg); } 67e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo}; 6834ee09551764b045fdc02df754157473125edf60Kevin Tang 69e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo} // namespace loc_core 7034ee09551764b045fdc02df754157473125edf60Kevin Tang 71e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo#endif //__LOC_CONTEXT_BASE__ 72