1ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
2ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *
3ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * Redistribution and use in source and binary forms, with or without
4ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * modification, are permitted provided that the following conditions are
5ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * met:
6ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *     * Redistributions of source code must retain the above copyright
7ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *       notice, this list of conditions and the following disclaimer.
8ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *     * Redistributions in binary form must reproduce the above
9ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *       copyright notice, this list of conditions and the following
10ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *       disclaimer in the documentation and/or other materials provided
11ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *       with the distribution.
12ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *     * Neither the name of The Linux Foundation, nor the names of its
13ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *       contributors may be used to endorse or promote products derived
14ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *       from this software without specific prior written permission.
15ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *
16ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo *
28ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo */
29ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOG_NDDEBUG 0
30ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOG_TAG "LocSvc_LocAdapterBase"
31ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
32ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#include <dlfcn.h>
33ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#include <LocAdapterBase.h>
34ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#include <loc_target.h>
35ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#include <log_util.h>
36ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
37ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russonamespace loc_core {
38ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
39ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russostruct LocOpenMsg : public LocMsg {
40ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LocAdapterBase* mLocAdapter;
41ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    LocApiBase* mLocApi;
42ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    inline LocOpenMsg(LocAdapterBase* locAdapter,
43ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo                      LocApiBase* locApi) :
44ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo        LocMsg(), mLocAdapter(locAdapter), mLocApi(locApi)
45ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    {
46ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo        locallog();
47ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    }
48ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    inline virtual void proc() const {
49ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo        mLocApi->addAdapter(mLocAdapter);
50ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    }
51ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    inline void locallog() {
52ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo        LOC_LOGV("LocOpen");
53ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    }
54ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    inline virtual void log() {
55ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo        locallog();
56ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    }
57ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo};
58ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
59ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo// This is the top level class, so the constructor will
60ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo// always gets called. Here we prepare for the default.
61ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo// But if getLocApi(targetEnumType target) is overriden,
62ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo// the right locApi should get created.
63ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoLocAdapterBase::LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
64ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo                               ContextBase* context) :
65ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    mEvtMask(mask), mContext(context),
66ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    mLocApi(context->getLocApi()), mMsgTask(context->getMsgTask())
67ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo{
68ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    sendMsg(new LocOpenMsg(this, mLocApi));
69ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo}
70ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
71ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russovoid LocAdapterBase::
72ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    handleEngineDownEvent()
73ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoDEFAULT_IMPL()
74ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
75ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russovoid LocAdapterBase::
76ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    reportPosition(UlpLocation &location,
77ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo                   GpsLocationExtended &locationExtended,
78ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo                   void* locationExt,
79ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo                   enum loc_sess_status status,
80ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo                   LocPosTechMask loc_technology_mask)
81ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoDEFAULT_IMPL()
82ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
83ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russovoid LocAdapterBase::
84ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    reportSv(GpsSvStatus &svStatus,
85ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo             GpsLocationExtended &locationExtended,
86ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo             void* svExt)
87ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoDEFAULT_IMPL()
88ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
89ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
90ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russovoid LocAdapterBase::
91ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    reportStatus(GpsStatusValue status)
92ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoDEFAULT_IMPL()
93ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
94ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
95ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russovoid LocAdapterBase::
96ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    reportNmea(const char* nmea, int length)
97ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoDEFAULT_IMPL()
98ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
99ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russobool LocAdapterBase::
100ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    reportXtraServer(const char* url1, const char* url2,
101ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo                     const char* url3, const int maxlength)
102ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoDEFAULT_IMPL(false)
103ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
104ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russobool LocAdapterBase::
105ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    requestXtraData()
106ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoDEFAULT_IMPL(false)
107ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
108ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russobool LocAdapterBase::
109ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    requestTime()
110ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoDEFAULT_IMPL(false)
111ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
112ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russobool LocAdapterBase::
113ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    requestLocation()
114ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoDEFAULT_IMPL(false)
115ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
116ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russobool LocAdapterBase::
117ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    requestATL(int connHandle, AGpsType agps_type)
118ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoDEFAULT_IMPL(false)
119ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
120ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russobool LocAdapterBase::
121ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    releaseATL(int connHandle)
122ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoDEFAULT_IMPL(false)
123ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
124ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russobool LocAdapterBase::
125ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    requestSuplES(int connHandle)
126ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoDEFAULT_IMPL(false)
127ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
128ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russobool LocAdapterBase::
129ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    reportDataCallOpened()
130ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoDEFAULT_IMPL(false)
131ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
132ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russobool LocAdapterBase::
133ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    reportDataCallClosed()
134ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoDEFAULT_IMPL(false)
135ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo
136ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russobool LocAdapterBase::
137ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo    requestNiNotify(GpsNiNotification &notify, const void* data)
138ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoDEFAULT_IMPL(false)
139ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo} // namespace loc_core
140