LocAdapterBase.h revision 8aac9d301fc5aa83071492803f4335b73f2604e3
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:
42e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    const 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) :
4947ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo        mEvtMask(0), mContext(NULL), mLocApi(NULL), mLocAdapterProxyBase(NULL), mMsgTask(msgTask) {}
500ed9ab19618e840907e343877bf91bd30aba8be9Vineeta Srivastavapublic:
5147ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo    inline virtual ~LocAdapterBase() { mLocApi->removeAdapter(this); }
5247ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo    LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
5347ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo                   ContextBase* context, LocAdapterProxyBase *adapterProxyBase = NULL);
54e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    inline LOC_API_ADAPTER_EVENT_MASK_T
55e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo        checkMask(LOC_API_ADAPTER_EVENT_MASK_T mask) const {
56e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo        return mEvtMask & mask;
57e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    }
58e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo
59e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    inline LOC_API_ADAPTER_EVENT_MASK_T getEvtMask() const {
60e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo        return mEvtMask;
61e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    }
62e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo
63e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    inline void sendMsg(const LocMsg* msg) const {
64e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo        mMsgTask->sendMsg(msg);
65e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    }
66e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo
67e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    inline void sendMsg(const LocMsg* msg) {
68e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo        mMsgTask->sendMsg(msg);
69e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    }
70e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo
71e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    // This will be overridden by the individual adapters
72e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    // if necessary.
73e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    inline virtual void setUlpProxy(UlpProxyBase* ulp) {}
7447ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo    virtual void handleEngineUpEvent();
75e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    virtual void handleEngineDownEvent();
76e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    inline virtual void setPositionModeInt(LocPosMode& posMode) {}
77e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    virtual void startFixInt() {}
78e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    virtual void stopFixInt() {}
7947ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo    virtual void getZppInt() {}
80e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    virtual void reportPosition(UlpLocation &location,
81e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo                                GpsLocationExtended &locationExtended,
82e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo                                void* locationExt,
83e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo                                enum loc_sess_status status,
84e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo                                LocPosTechMask loc_technology_mask);
85e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    virtual void reportSv(GpsSvStatus &svStatus,
86e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo                          GpsLocationExtended &locationExtended,
87e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo                          void* svExt);
88e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    virtual void reportStatus(GpsStatusValue status);
89e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    virtual void reportNmea(const char* nmea, int length);
90e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    virtual bool reportXtraServer(const char* url1, const char* url2,
91e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo                                  const char* url3, const int maxlength);
92e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    virtual bool requestXtraData();
93e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    virtual bool requestTime();
94e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    virtual bool requestLocation();
95e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    virtual bool requestATL(int connHandle, AGpsType agps_type);
96e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    virtual bool releaseATL(int connHandle);
97e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    virtual bool requestSuplES(int connHandle);
98e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    virtual bool reportDataCallOpened();
99e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    virtual bool reportDataCallClosed();
100e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    virtual bool requestNiNotify(GpsNiNotification &notify,
101e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo                                 const void* data);
102e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo    inline virtual bool isInSession() { return false; }
10347ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo    virtual void shutdown();
10447ad5e4cf2f6810db3c0e7ec79696496a94b6f0dDante Russo    ContextBase* getContext() const { return mContext; }
1058aac9d301fc5aa83071492803f4335b73f2604e3Vineeta Srivastava    virtual void reportGpsMeasurementData(GpsData &gpsMeasurementData);
106e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo};
107e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo
108e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo} // namespace loc_core
109e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo
110e14a6c846df2ce4bb1847e4250991f7c52fd793dDante Russo#endif //LOC_API_ADAPTER_BASE_H
111