1 /* Copyright (c) 2011-2013, 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 #define LOG_NDDEBUG 0
30 #define LOG_TAG "LocSvc_LocAdapterBase"
31 
32 #include <dlfcn.h>
33 #include <LocAdapterBase.h>
34 #include <loc_target.h>
35 #include <log_util.h>
36 
37 namespace loc_core {
38 
39 struct LocOpenMsg : public LocMsg {
40     LocAdapterBase* mLocAdapter;
41     LocApiBase* mLocApi;
LocOpenMsgloc_core::LocOpenMsg42     inline LocOpenMsg(LocAdapterBase* locAdapter,
43                       LocApiBase* locApi) :
44         LocMsg(), mLocAdapter(locAdapter), mLocApi(locApi)
45     {
46         locallog();
47     }
procloc_core::LocOpenMsg48     inline virtual void proc() const {
49         mLocApi->addAdapter(mLocAdapter);
50     }
locallogloc_core::LocOpenMsg51     inline void locallog() {
52         LOC_LOGV("LocOpen");
53     }
logloc_core::LocOpenMsg54     inline virtual void log() {
55         locallog();
56     }
57 };
58 
59 // This is the top level class, so the constructor will
60 // always gets called. Here we prepare for the default.
61 // But if getLocApi(targetEnumType target) is overriden,
62 // the right locApi should get created.
LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,ContextBase * context)63 LocAdapterBase::LocAdapterBase(const LOC_API_ADAPTER_EVENT_MASK_T mask,
64                                ContextBase* context) :
65     mEvtMask(mask), mContext(context),
66     mLocApi(context->getLocApi()), mMsgTask(context->getMsgTask())
67 {
68     sendMsg(new LocOpenMsg(this, mLocApi));
69 }
70 
71 void LocAdapterBase::
72     handleEngineDownEvent()
73 DEFAULT_IMPL()
74 
75 void LocAdapterBase::
76     reportPosition(UlpLocation &location,
77                    GpsLocationExtended &locationExtended,
78                    void* locationExt,
79                    enum loc_sess_status status,
80                    LocPosTechMask loc_technology_mask)
81 DEFAULT_IMPL()
82 
83 void LocAdapterBase::
84     reportSv(GpsSvStatus &svStatus,
85              GpsLocationExtended &locationExtended,
86              void* svExt)
87 DEFAULT_IMPL()
88 
89 
90 void LocAdapterBase::
91     reportStatus(GpsStatusValue status)
92 DEFAULT_IMPL()
93 
94 
95 void LocAdapterBase::
96     reportNmea(const char* nmea, int length)
97 DEFAULT_IMPL()
98 
99 bool LocAdapterBase::
100     reportXtraServer(const char* url1, const char* url2,
101                      const char* url3, const int maxlength)
102 DEFAULT_IMPL(false)
103 
104 bool LocAdapterBase::
105     requestXtraData()
106 DEFAULT_IMPL(false)
107 
108 bool LocAdapterBase::
109     requestTime()
110 DEFAULT_IMPL(false)
111 
112 bool LocAdapterBase::
113     requestLocation()
114 DEFAULT_IMPL(false)
115 
116 bool LocAdapterBase::
117     requestATL(int connHandle, AGpsType agps_type)
118 DEFAULT_IMPL(false)
119 
120 bool LocAdapterBase::
121     releaseATL(int connHandle)
122 DEFAULT_IMPL(false)
123 
124 bool LocAdapterBase::
125     requestSuplES(int connHandle)
126 DEFAULT_IMPL(false)
127 
128 bool LocAdapterBase::
129     reportDataCallOpened()
130 DEFAULT_IMPL(false)
131 
132 bool LocAdapterBase::
133     reportDataCallClosed()
134 DEFAULT_IMPL(false)
135 
136 bool LocAdapterBase::
137     requestNiNotify(GpsNiNotification &notify, const void* data)
138 DEFAULT_IMPL(false)
139 } // namespace loc_core
140