• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2011-2015, 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 #ifndef __LOC_CONTEXT_BASE__
30 #define __LOC_CONTEXT_BASE__
31 
32 #include <stdbool.h>
33 #include <ctype.h>
34 #include <MsgTask.h>
35 #include <LocApiBase.h>
36 #include <LBSProxyBase.h>
37 
38 #define MAX_XTRA_SERVER_URL_LENGTH 256
39 
40 /* GPS.conf support */
41 /* NOTE: the implementaiton of the parser casts number
42    fields to 32 bit. To ensure all 'n' fields working,
43    they must all be 32 bit fields. */
44 typedef struct loc_gps_cfg_s
45 {
46     uint32_t       INTERMEDIATE_POS;
47     uint32_t       ACCURACY_THRES;
48     uint32_t       SUPL_VER;
49     uint32_t       SUPL_MODE;
50     uint32_t       SUPL_ES;
51     uint32_t       CAPABILITIES;
52     uint32_t       LPP_PROFILE;
53     uint32_t       XTRA_VERSION_CHECK;
54     char           XTRA_SERVER_1[MAX_XTRA_SERVER_URL_LENGTH];
55     char           XTRA_SERVER_2[MAX_XTRA_SERVER_URL_LENGTH];
56     char           XTRA_SERVER_3[MAX_XTRA_SERVER_URL_LENGTH];
57     uint32_t       USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL;
58     uint32_t       NMEA_PROVIDER;
59     uint32_t       GPS_LOCK;
60     uint32_t       A_GLONASS_POS_PROTOCOL_SELECT;
61     uint32_t       AGPS_CERT_WRITABLE_MASK;
62     uint32_t       AGPS_CONFIG_INJECT;
63     uint32_t       LPPE_CP_TECHNOLOGY;
64     uint32_t       LPPE_UP_TECHNOLOGY;
65     uint32_t       EXTERNAL_DR_ENABLED;
66 } loc_gps_cfg_s_type;
67 
68 /* NOTE: the implementaiton of the parser casts number
69    fields to 32 bit. To ensure all 'n' fields working,
70    they must all be 32 bit fields. */
71 /* Meanwhile, *_valid fields are 8 bit fields, and 'f'
72    fields are double. Rigid as they are, it is the
73    the status quo, until the parsing mechanism is
74    change, that is. */
75 typedef struct
76 {
77     uint8_t        GYRO_BIAS_RANDOM_WALK_VALID;
78     double         GYRO_BIAS_RANDOM_WALK;
79     uint32_t       SENSOR_ACCEL_BATCHES_PER_SEC;
80     uint32_t       SENSOR_ACCEL_SAMPLES_PER_BATCH;
81     uint32_t       SENSOR_GYRO_BATCHES_PER_SEC;
82     uint32_t       SENSOR_GYRO_SAMPLES_PER_BATCH;
83     uint32_t       SENSOR_ACCEL_BATCHES_PER_SEC_HIGH;
84     uint32_t       SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH;
85     uint32_t       SENSOR_GYRO_BATCHES_PER_SEC_HIGH;
86     uint32_t       SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH;
87     uint32_t       SENSOR_CONTROL_MODE;
88     uint32_t       SENSOR_USAGE;
89     uint32_t       SENSOR_ALGORITHM_CONFIG_MASK;
90     uint8_t        ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
91     double         ACCEL_RANDOM_WALK_SPECTRAL_DENSITY;
92     uint8_t        ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
93     double         ANGLE_RANDOM_WALK_SPECTRAL_DENSITY;
94     uint8_t        RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
95     double         RATE_RANDOM_WALK_SPECTRAL_DENSITY;
96     uint8_t        VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID;
97     double         VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY;
98     uint32_t       SENSOR_PROVIDER;
99 } loc_sap_cfg_s_type;
100 
101 namespace loc_core {
102 
103 class LocAdapterBase;
104 
105 class ContextBase {
106     static LBSProxyBase* getLBSProxy(const char* libName);
107     LocApiBase* createLocApi(LOC_API_ADAPTER_EVENT_MASK_T excludedMask);
108 protected:
109     const LBSProxyBase* mLBSProxy;
110     const MsgTask* mMsgTask;
111     LocApiBase* mLocApi;
112     LocApiProxyBase *mLocApiProxy;
113 public:
114     ContextBase(const MsgTask* msgTask,
115                 LOC_API_ADAPTER_EVENT_MASK_T exMask,
116                 const char* libName);
~ContextBase()117     inline virtual ~ContextBase() { delete mLocApi; delete mLBSProxy; }
118 
getMsgTask()119     inline const MsgTask* getMsgTask() { return mMsgTask; }
getLocApi()120     inline LocApiBase* getLocApi() { return mLocApi; }
getLocApiProxy()121     inline LocApiProxyBase* getLocApiProxy() { return mLocApiProxy; }
hasAgpsExtendedCapabilities()122     inline bool hasAgpsExtendedCapabilities() { return mLBSProxy->hasAgpsExtendedCapabilities(); }
hasCPIExtendedCapabilities()123     inline bool hasCPIExtendedCapabilities() { return mLBSProxy->hasCPIExtendedCapabilities(); }
hasNativeXtraClient()124     inline bool hasNativeXtraClient() { return mLBSProxy->hasNativeXtraClient(); }
modemPowerVote(bool power)125     inline void modemPowerVote(bool power) const { return mLBSProxy->modemPowerVote(power); }
requestUlp(LocAdapterBase * adapter,unsigned long capabilities)126     inline void requestUlp(LocAdapterBase* adapter,
127                            unsigned long capabilities) {
128         mLBSProxy->requestUlp(adapter, capabilities);
129     }
getIzatDevId()130     inline IzatDevId_t getIzatDevId() const {
131         return mLBSProxy->getIzatDevId();
132     }
sendMsg(const LocMsg * msg)133     inline void sendMsg(const LocMsg *msg) { getMsgTask()->sendMsg(msg); }
134 
135     static loc_gps_cfg_s_type mGps_conf;
136     static loc_sap_cfg_s_type mSap_conf;
137 
138     static uint32_t getCarrierCapabilities();
139 
140 };
141 
142 } // namespace loc_core
143 
144 #endif //__LOC_CONTEXT_BASE__
145