Home | History | Annotate | Download | only in core
      1 /* Copyright (c) 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 #ifndef GPS_EXTENDED_H
     30 #define GPS_EXTENDED_H
     31 
     32 #ifdef __cplusplus
     33 extern "C" {
     34 #endif /* __cplusplus */
     35 
     36 #include <gps_extended_c.h>
     37 
     38 struct LocPosMode
     39 {
     40     LocPositionMode mode;
     41     GpsPositionRecurrence recurrence;
     42     uint32_t min_interval;
     43     uint32_t preferred_accuracy;
     44     uint32_t preferred_time;
     45     char credentials[14];
     46     char provider[8];
     47     LocPosMode(LocPositionMode m, GpsPositionRecurrence recr,
     48                uint32_t gap, uint32_t accu, uint32_t time,
     49                const char* cred, const char* prov) :
     50         mode(m), recurrence(recr),
     51         min_interval(gap < MIN_POSSIBLE_FIX_INTERVAL ? MIN_POSSIBLE_FIX_INTERVAL : gap),
     52         preferred_accuracy(accu), preferred_time(time) {
     53         memset(credentials, 0, sizeof(credentials));
     54         memset(provider, 0, sizeof(provider));
     55         if (NULL != cred) {
     56             memcpy(credentials, cred, sizeof(credentials)-1);
     57         }
     58         if (NULL != prov) {
     59             memcpy(provider, prov, sizeof(provider)-1);
     60         }
     61     }
     62 
     63     inline LocPosMode() :
     64         mode(LOC_POSITION_MODE_MS_BASED),
     65         recurrence(GPS_POSITION_RECURRENCE_PERIODIC),
     66         min_interval(MIN_POSSIBLE_FIX_INTERVAL),
     67         preferred_accuracy(50), preferred_time(120000) {
     68         memset(credentials, 0, sizeof(credentials));
     69         memset(provider, 0, sizeof(provider));
     70     }
     71 
     72     inline bool equals(const LocPosMode &anotherMode) const
     73     {
     74         return anotherMode.mode == mode &&
     75             anotherMode.recurrence == recurrence &&
     76             anotherMode.min_interval == min_interval &&
     77             anotherMode.preferred_accuracy == preferred_accuracy &&
     78             anotherMode.preferred_time == preferred_time &&
     79             !strncmp(anotherMode.credentials, credentials, sizeof(credentials)-1) &&
     80             !strncmp(anotherMode.provider, provider, sizeof(provider)-1);
     81     }
     82 
     83     void logv() const;
     84 };
     85 
     86 
     87 #ifdef __cplusplus
     88 }
     89 #endif /* __cplusplus */
     90 
     91 #endif /* GPS_EXTENDED_H */
     92 
     93