blob: 68d38635de27d54dd3a822c564a6303ad7ce161e [file] [log] [blame]
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001/*
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_RIL_INTERNAL_H
18#define ANDROID_RIL_INTERNAL_H
19
20#include <binder/Parcel.h>
21
22namespace android {
23
24#define SOCKET_NAME_RIL "rild"
25#define SOCKET2_NAME_RIL "rild2"
26#define SOCKET3_NAME_RIL "rild3"
27#define SOCKET4_NAME_RIL "rild4"
28
Amit Mahajan439da362017-02-13 17:43:04 -080029#define OEM_HOOK_SERVICE_NAME "oemhook"
30#define OEM_HOOK2_SERVICE_NAME "oemhook2"
31#define OEM_HOOK3_SERVICE_NAME "oemhook3"
32#define OEM_HOOK4_SERVICE_NAME "oemhook4"
33
Amit Mahajancd77a5b2016-08-25 11:19:21 -070034/* Constants for response types */
35#define RESPONSE_SOLICITED 0
36#define RESPONSE_UNSOLICITED 1
37#define RESPONSE_SOLICITED_ACK 2
38#define RESPONSE_SOLICITED_ACK_EXP 3
39#define RESPONSE_UNSOLICITED_ACK_EXP 4
40
Amit Mahajan5829a472016-12-28 17:28:07 -080041// Enable verbose logging
42#define VDBG 0
43
44#define MIN(a,b) ((a)<(b) ? (a) : (b))
45
46// Enable RILC log
47#define RILC_LOG 0
48
49#if RILC_LOG
50 #define startRequest sprintf(printBuf, "(")
51 #define closeRequest sprintf(printBuf, "%s)", printBuf)
52 #define printRequest(token, req) \
53 RLOGD("[%04d]> %s %s", token, requestToString(req), printBuf)
54
55 #define startResponse sprintf(printBuf, "%s {", printBuf)
56 #define closeResponse sprintf(printBuf, "%s}", printBuf)
57 #define printResponse RLOGD("%s", printBuf)
58
59 #define clearPrintBuf printBuf[0] = 0
60 #define removeLastChar printBuf[strlen(printBuf)-1] = 0
61 #define appendPrintBuf(x...) snprintf(printBuf, PRINTBUF_SIZE, x)
62#else
63 #define startRequest
64 #define closeRequest
65 #define printRequest(token, req)
66 #define startResponse
67 #define closeResponse
68 #define printResponse
69 #define clearPrintBuf
70 #define removeLastChar
71 #define appendPrintBuf(x...)
72#endif
73
Amit Mahajancd77a5b2016-08-25 11:19:21 -070074typedef struct CommandInfo CommandInfo;
75
76extern "C" const char * requestToString(int request);
77
78typedef struct RequestInfo {
79 int32_t token; //this is not RIL_Token
80 CommandInfo *pCI;
81 struct RequestInfo *p_next;
82 char cancelled;
83 char local; // responses to local commands do not go back to command process
84 RIL_SOCKET_ID socket_id;
85 int wasAckSent; // Indicates whether an ack was sent earlier
86} RequestInfo;
87
88typedef struct CommandInfo {
89 int requestNumber;
Amit Mahajan759786a2017-03-03 17:35:47 -080090 int(*responseFunction) (int slotId, int responseType, int token,
Amit Mahajancd77a5b2016-08-25 11:19:21 -070091 RIL_Errno e, void *response, size_t responselen);
92} CommandInfo;
93
Sanket Padawef220dc52017-01-02 23:46:00 -080094RequestInfo * addRequestToList(int serial, int slotId, int request);
Amit Mahajancd77a5b2016-08-25 11:19:21 -070095
96char * RIL_getRilSocketName();
97
Sanket Padawef220dc52017-01-02 23:46:00 -080098void releaseWakeLock();
Amit Mahajanc7ad6262017-03-14 16:39:27 -070099
100void onNewCommandConnect(RIL_SOCKET_ID socket_id);
101
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700102} // namespace android
103
104#endif //ANDROID_RIL_INTERNAL_H