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