1 /* 2 * Copyright (C) 2009 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 _HARDWARE_GPS_NI_H 18 #define _HARDWARE_GPS_NI_H 19 20 #include <stdint.h> 21 22 #if __cplusplus 23 extern "C" { 24 #endif 25 26 /** 27 * Name for NI interface 28 */ 29 #define GPS_NI_INTERFACE "gps-ni" 30 31 /** 32 * String length constants 33 */ 34 #define GPS_NI_SHORT_STRING_MAXLEN 256 35 #define GPS_NI_LONG_STRING_MAXLEN 2048 36 37 /** 38 * GpsNiType constants 39 */ 40 typedef uint32_t GpsNiType; 41 #define GPS_NI_TYPE_VOICE 1 42 #define GPS_NI_TYPE_UMTS_SUPL 2 43 #define GPS_NI_TYPE_UMTS_CTRL_PLANE 3 44 45 /** 46 * GpsNiNotifyFlags constants 47 */ 48 typedef uint32_t GpsNiNotifyFlags; 49 /** NI requires notification */ 50 #define GPS_NI_NEED_NOTIFY 0x0001 51 /** NI requires verification */ 52 #define GPS_NI_NEED_VERIFY 0x0002 53 /** NI requires privacy override, no notification/minimal trace */ 54 #define GPS_NI_PRIVACY_OVERRIDE 0x0004 55 56 /** 57 * GPS NI responses, used to define the response in 58 * NI structures 59 */ 60 typedef int GpsUserResponseType; 61 #define GPS_NI_RESPONSE_ACCEPT 1 62 #define GPS_NI_RESPONSE_DENY 2 63 #define GPS_NI_RESPONSE_NORESP 3 64 65 /** 66 * NI data encoding scheme 67 */ 68 typedef int GpsNiEncodingType; 69 #define GPS_ENC_NONE 0 70 #define GPS_ENC_SUPL_GSM_DEFAULT 1 71 #define GPS_ENC_SUPL_UTF8 2 72 #define GPS_ENC_SUPL_UCS2 3 73 #define GPS_ENC_UNKNOWN -1 74 75 /** Represents an NI request */ 76 typedef struct { 77 /** 78 * An ID generated by HAL to associate NI notifications and UI 79 * responses 80 */ 81 int notification_id; 82 83 /** 84 * An NI type used to distinguish different categories of NI 85 * events, such as GPS_NI_TYPE_VOICE, GPS_NI_TYPE_UMTS_SUPL, ... 86 */ 87 GpsNiType ni_type; 88 89 /** 90 * Notification/verification options, combinations of GpsNiNotifyFlags constants 91 */ 92 GpsNiNotifyFlags notify_flags; 93 94 /** 95 * Timeout period to wait for user response. 96 * Set to 0 for no time out limit. 97 */ 98 int timeout; 99 100 /** 101 * Default response when time out. 102 */ 103 GpsUserResponseType default_response; 104 105 /** 106 * Requestor ID 107 */ 108 char requestor_id[GPS_NI_SHORT_STRING_MAXLEN]; 109 110 /** 111 * Notification message. It can also be used to store client_id in some cases 112 */ 113 char text[GPS_NI_LONG_STRING_MAXLEN]; 114 115 /** 116 * Client name decoding scheme 117 */ 118 GpsNiEncodingType requestor_id_encoding; 119 120 /** 121 * Client name decoding scheme 122 */ 123 GpsNiEncodingType text_encoding; 124 125 /** 126 * A pointer to extra data. Format: 127 * key_1 = value_1 128 * key_2 = value_2 129 */ 130 char extras[GPS_NI_LONG_STRING_MAXLEN]; 131 132 } GpsNiNotification; 133 134 /** Callback with NI notification. */ 135 typedef void (*gps_ni_notify_callback)(GpsNiNotification *notification); 136 137 /** GPS NI callback structure. */ 138 typedef struct 139 { 140 /** 141 * Sends the notification request from HAL to GPSLocationProvider. 142 */ 143 gps_ni_notify_callback notify_cb; 144 } GpsNiCallbacks; 145 146 /** 147 * Extended interface for Network-initiated (NI) support. 148 */ 149 typedef struct 150 { 151 /** Registers the callbacks for HAL to use. */ 152 void (*init) (GpsNiCallbacks *callbacks); 153 154 /** Sends a response to HAL. */ 155 void (*respond) (int notif_id, GpsUserResponseType user_response); 156 } GpsNiInterface; 157 158 #if __cplusplus 159 } // extern "C" 160 #endif 161 162 #endif // _HARDWARE_GPS_NI_H 163