1syntax = "proto2"; 2 3option java_package = "org.android.btsap"; 4option java_outer_classname = "SapApi"; 5 6// 7// SAP Interface to RIL 8// 9// The protocol for the binary wire format to RIL shall consist of 10// the serialized format of MsgHeader. 11// MsgHeader payload field will contain the serialized format of 12// the actual message being sent, as described by the type and id 13// fields. 14// e.g. If type = REQUEST and id == RIL_SIM_SAP_CONNECT, payload 15// will contain the serialized wire format of a 16// RIL_SIM_SAP_CONNECT_REQ message. 17// 18 19// Message Header 20// Each SAP message stream will always be prepended with a MsgHeader 21message MsgHeader { 22 required fixed32 token = 1; // generated dynamically 23 required MsgType type = 2; 24 required MsgId id = 3; 25 required Error error = 4; 26 required bytes payload = 5; 27} 28 29enum MsgType { 30 UNKNOWN = 0; 31 REQUEST = 1; 32 RESPONSE = 2; 33 UNSOL_RESPONSE = 3; 34 } 35 36enum MsgId { 37 UNKNOWN_REQ = 0; 38 39 // 40 // For MsgType: REQUEST ,MsgId: RIL_SIM_SAP_CONNECT, Error: RIL_E_UNUSED, 41 // Message: message RIL_SIM_SAP_CONNECT_REQ 42 // For MsgType: RESPONSE, MsgId: RIL_SIM_SAP_CONNECT, Error:Valid errors, 43 // Message: message RIL_SIM_SAP_CONNECT_RSP 44 // 45 RIL_SIM_SAP_CONNECT = 1; 46 47 // 48 // For MsgType: REQUEST ,MsgId: RIL_SIM_SAP_DISCONNECT, Error: RIL_E_UNUSED, 49 // Message: message RIL_SIM_SAP_DISCONNECT_REQ 50 // For MsgType: RESPONSE, MsgId: RIL_SIM_SAP_DISCONNECT, Error:Valid errors, 51 // Message: message RIL_SIM_SAP_DISCONNECT_RSP 52 // For MsgType: UNSOL_RESPONSE, MsgId: RIL_SIM_SAP_DISCONNECT, Error: RIL_E_UNUSED, 53 // Message: message RIL_SIM_SAP_DISCONNECT_IND 54 // 55 RIL_SIM_SAP_DISCONNECT = 2; 56 57 // 58 // For MsgType: REQUEST ,MsgId: RIL_SIM_SAP_APDU, Error: RIL_E_UNUSED, 59 // Message: message RIL_SIM_SAP_APDU_REQ 60 // For MsgType: RESPONSE, MsgId: RIL_SIM_SAP_APDU, Error:Valid errors, 61 // Message: message RIL_SIM_SAP_APDU_RSP 62 // 63 RIL_SIM_SAP_APDU = 3; 64 65 // 66 // For MsgType: REQUEST ,MsgId: RIL_SIM_SAP_TRANSFER_ATR, Error: RIL_E_UNUSED, 67 // Message: message RIL_SIM_SAP_TRANSFER_ATR_REQ 68 // For MsgType: RESPONSE, MsgId: RIL_SIM_SAP_TRANSFER_ATR, Error:Valid errors, 69 // Message: message RIL_SIM_SAP_TRANSFER_ATR_RSP 70 // 71 RIL_SIM_SAP_TRANSFER_ATR = 4; 72 73 // 74 // For MsgType: REQUEST ,MsgId: RIL_SIM_SAP_POWER, Error: RIL_E_UNUSED, 75 // Message: message RIL_SIM_SAP_POWER_REQ 76 // For MsgType: RESPONSE, MsgId: RIL_SIM_SAP_POWER, Error:Valid errors, 77 // Message: message RIL_SIM_SAP_POWER_RSP 78 // 79 RIL_SIM_SAP_POWER = 5; 80 81 // 82 // For MsgType: REQUEST ,MsgId: RIL_SIM_SAP_RESET_SIM, Error: RIL_E_UNUSED, 83 // Message: message RIL_SIM_SAP_RESET_SIM_REQ 84 // For MsgType: RESPONSE, MsgId: RIL_SIM_SAP_RESET_SIM, Error:Valid errors, 85 // Message: message RIL_SIM_SAP_RESET_SIM_RSP 86 // 87 RIL_SIM_SAP_RESET_SIM = 6; 88 89 // 90 // For MsgType: UNSOL_RESPONSE, MsgId: RIL_SIM_SAP_STATUS, Error: RIL_E_UNUSED, 91 // Message: message RIL_SIM_SAP_STATUS_IND 92 // 93 RIL_SIM_SAP_STATUS = 7; 94 95 // 96 // For MsgType: REQUEST ,MsgId: RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS, Error: RIL_E_UNUSED, 97 // Message: message RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_REQ 98 // For MsgType: RESPONSE, MsgId: RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS, Error:Valid errors, 99 // Message: message RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_RSP 100 // 101 RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS = 8; 102 103 // 104 // For MsgType: UNSOL_RESPONSE, MsgId: RIL_SIM_SAP_ERROR_RESP, Error: RIL_E_UNUSED, 105 // Message: message RIL_SIM_SAP_ERROR_RSP 106 // 107 RIL_SIM_SAP_ERROR_RESP = 9; 108 109 // 110 // For MsgType: REQUEST ,MsgId: RIL_SIM_SAP_SET_TRANSFER_PROTOCOL, Error: RIL_E_UNUSED, 111 // Message: message RIL_SIM_SAP_SET_TRANSFER_PROTOCOL_REQ 112 // For MsgType: RESPONSE, MsgId: RIL_SIM_SAP_SET_TRANSFER_PROTOCOL, Error:Valid errors, 113 // Message: message RIL_SIM_SAP_SET_TRANSFER_PROTOCOL_RSP 114 // 115 RIL_SIM_SAP_SET_TRANSFER_PROTOCOL = 10; 116 } 117 118 enum Error { 119 RIL_E_SUCCESS = 0; 120 RIL_E_RADIO_NOT_AVAILABLE = 1; 121 RIL_E_GENERIC_FAILURE = 2; 122 RIL_E_REQUEST_NOT_SUPPORTED = 3; 123 RIL_E_CANCELLED = 4; 124 RIL_E_INVALID_PARAMETER = 5; 125 RIL_E_UNUSED = 6; 126 } 127 128// SAP 1.1 spec 5.1.1 129message RIL_SIM_SAP_CONNECT_REQ { 130 required int32 max_message_size = 1; 131} 132 133// SAP 1.1 spec 5.1.2 134message RIL_SIM_SAP_CONNECT_RSP { 135 enum Response { 136 RIL_E_SUCCESS = 0; 137 RIL_E_SAP_CONNECT_FAILURE = 1; 138 RIL_E_SAP_MSG_SIZE_TOO_LARGE = 2; 139 RIL_E_SAP_MSG_SIZE_TOO_SMALL = 3; 140 RIL_E_SAP_CONNECT_OK_CALL_ONGOING = 4; 141 } 142 required Response response = 1; 143// must be present for RIL_E_SAP_MSG_SIZE_TOO_LARGE and contain the 144// the suitable message size 145 optional int32 max_message_size = 2; 146} 147 148// SAP 1.1 spec 5.1.3 149message RIL_SIM_SAP_DISCONNECT_REQ { 150 //no params 151} 152 153 154// SAP 1.1 spec 5.1.4 155message RIL_SIM_SAP_DISCONNECT_RSP { 156 //no params 157} 158 159 160// SAP 1.1 spec 5.1.5 161message RIL_SIM_SAP_DISCONNECT_IND { 162 enum DisconnectType { 163 RIL_S_DISCONNECT_TYPE_GRACEFUL = 0; 164 RIL_S_DISCONNECT_TYPE_IMMEDIATE = 1; 165 } 166 required DisconnectType disconnectType = 1; 167} 168 169// SAP 1.1 spec 5.1.6 170message RIL_SIM_SAP_APDU_REQ { //handles both APDU and APDU7816 171 enum Type { 172 RIL_TYPE_APDU = 0; 173 RIL_TYPE_APDU7816 = 1; 174 } 175 required Type type = 1; 176 required bytes command = 2; 177} 178 179// SAP 1.1 spec 5.1.7 180message RIL_SIM_SAP_APDU_RSP { //handles both APDU and APDU7816 181 enum Type { 182 RIL_TYPE_APDU = 0; 183 RIL_TYPE_APDU7816 = 1; 184 } 185 required Type type = 1; 186 enum Response { 187 RIL_E_SUCCESS = 0; 188 RIL_E_GENERIC_FAILURE = 1; 189 RIL_E_SIM_NOT_READY = 2; 190 RIL_E_SIM_ALREADY_POWERED_OFF = 3; 191 RIL_E_SIM_ABSENT = 4; 192 } 193 required Response response = 2; 194 optional bytes apduResponse = 3; 195} 196 197// SAP 1.1 spec 5.1.8 198message RIL_SIM_SAP_TRANSFER_ATR_REQ { 199 // no params 200} 201 202// SAP 1.1 spec 5.1.9 203message RIL_SIM_SAP_TRANSFER_ATR_RSP { 204 enum Response { 205 RIL_E_SUCCESS = 0; 206 RIL_E_GENERIC_FAILURE = 1; 207 RIL_E_SIM_ALREADY_POWERED_OFF = 3; 208 RIL_E_SIM_ALREADY_POWERED_ON = 18; 209 RIL_E_SIM_ABSENT = 4; 210 RIL_E_SIM_DATA_NOT_AVAILABLE = 6; 211 } 212 required Response response = 1; 213 214 optional bytes atr = 2; //must be present on SUCCESS 215} 216 217 218// SAP 1.1 spec 5.1.10 +5.1.12 219message RIL_SIM_SAP_POWER_REQ { 220 required bool state = 1; //true = on, False = off 221} 222 223// SAP 1.1 spec 5.1.11 +5.1.13 224message RIL_SIM_SAP_POWER_RSP { 225 enum Response { 226 RIL_E_SUCCESS = 0; 227 RIL_E_GENERIC_FAILURE = 2; 228 RIL_E_SIM_ABSENT = 11; 229 RIL_E_SIM_ALREADY_POWERED_OFF = 17; 230 RIL_E_SIM_ALREADY_POWERED_ON = 18; 231 } 232 required Response response = 1; 233} 234 235// SAP 1.1 spec 5.1.14 236message RIL_SIM_SAP_RESET_SIM_REQ { 237 // no params 238} 239 240// SAP 1.1 spec 5.1.15 241message RIL_SIM_SAP_RESET_SIM_RSP { 242 enum Response { 243 RIL_E_SUCCESS = 0; 244 RIL_E_GENERIC_FAILURE = 2; 245 RIL_E_SIM_ABSENT = 11; 246 RIL_E_SIM_NOT_READY = 16; 247 RIL_E_SIM_ALREADY_POWERED_OFF = 17; 248 } 249 required Response response = 1; 250} 251 252// SAP 1.1 spec 5.1.16 253message RIL_SIM_SAP_STATUS_IND { 254 enum Status { 255 RIL_SIM_STATUS_UNKNOWN_ERROR = 0; 256 RIL_SIM_STATUS_CARD_RESET = 1; 257 RIL_SIM_STATUS_CARD_NOT_ACCESSIBLE = 2; 258 RIL_SIM_STATUS_CARD_REMOVED = 3; 259 RIL_SIM_STATUS_CARD_INSERTED = 4; 260 RIL_SIM_STATUS_RECOVERED = 5; 261 } 262 required Status statusChange = 1; 263} 264 265// SAP 1.1 spec 5.1.17 266message RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_REQ { 267 //no params 268 269} 270 271// SAP 1.1 spec 5.1.18 272message RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_RSP { 273 enum Response { 274 RIL_E_SUCCESS = 0; 275 RIL_E_GENERIC_FAILURE = 2; 276 RIL_E_SIM_DATA_NOT_AVAILABLE = 6; 277 } 278 required Response response = 1; 279 optional int32 CardReaderStatus = 2; 280} 281 282// SAP 1.1 spec 5.1.19 283message RIL_SIM_SAP_ERROR_RSP { 284 //no params 285} 286 287// SAP 1.1 spec 5.1.20 288message RIL_SIM_SAP_SET_TRANSFER_PROTOCOL_REQ { 289 enum Protocol { 290 t0 = 0; 291 t1 = 1; 292 } 293 required Protocol protocol = 1; 294} 295 296// SAP 1.1 spec 5.1.21 297message RIL_SIM_SAP_SET_TRANSFER_PROTOCOL_RSP { 298 enum Response { 299 RIL_E_SUCCESS = 0; 300 RIL_E_GENERIC_FAILURE = 2; 301 RIL_E_SIM_ABSENT = 11; 302 RIL_E_SIM_NOT_READY = 16; 303 RIL_E_SIM_ALREADY_POWERED_OFF = 17; 304 } 305 required Response response = 1; 306} 307