1/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_INCLUDE_HARDWARE_GPS_INTERNAL_H
18#define ANDROID_INCLUDE_HARDWARE_GPS_INTERNAL_H
19
20#include "hardware/gps.h"
21
22/****************************************************************************
23 * This file contains legacy structs that are deprecated/retired from gps.h *
24 ****************************************************************************/
25
26__BEGIN_DECLS
27
28/**
29 * Legacy GPS callback structure.
30 * Deprecated, to be removed in the next Android release.
31 * Use GpsCallbacks instead.
32 */
33typedef struct {
34    /** set to sizeof(GpsCallbacks_v1) */
35    size_t      size;
36    gps_location_callback location_cb;
37    gps_status_callback status_cb;
38    gps_sv_status_callback sv_status_cb;
39    gps_nmea_callback nmea_cb;
40    gps_set_capabilities set_capabilities_cb;
41    gps_acquire_wakelock acquire_wakelock_cb;
42    gps_release_wakelock release_wakelock_cb;
43    gps_create_thread create_thread_cb;
44    gps_request_utc_time request_utc_time_cb;
45} GpsCallbacks_v1;
46
47#pragma pack(push,4)
48// We need to keep the alignment of this data structure to 4-bytes, to ensure that in 64-bit
49// environments the size of this legacy definition does not collide with _v2. Implementations should
50// be using _v2 and _v3, so it's OK to pay the 'unaligned' penalty in 64-bit if an old
51// implementation is still in use.
52
53/**
54 * Legacy struct to represent the status of AGPS.
55 */
56typedef struct {
57    /** set to sizeof(AGpsStatus_v1) */
58    size_t          size;
59    AGpsType        type;
60    AGpsStatusValue status;
61} AGpsStatus_v1;
62
63#pragma pack(pop)
64
65/**
66 * Legacy struct to represent the status of AGPS augmented with a IPv4 address
67 * field.
68 */
69typedef struct {
70    /** set to sizeof(AGpsStatus_v2) */
71    size_t          size;
72    AGpsType        type;
73    AGpsStatusValue status;
74
75    /*-------------------- New fields in _v2 --------------------*/
76
77    uint32_t        ipaddr;
78} AGpsStatus_v2;
79
80/**
81 * Legacy extended interface for AGPS support.
82 * See AGpsInterface_v2 for more information.
83 */
84typedef struct {
85    /** set to sizeof(AGpsInterface_v1) */
86    size_t          size;
87    void  (*init)( AGpsCallbacks* callbacks );
88    int  (*data_conn_open)( const char* apn );
89    int  (*data_conn_closed)();
90    int  (*data_conn_failed)();
91    int  (*set_server)( AGpsType type, const char* hostname, int port );
92} AGpsInterface_v1;
93
94__END_DECLS
95
96#endif /* ANDROID_INCLUDE_HARDWARE_GPS_INTERNAL_H */
97