Amit Mahajan | cd77a5b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 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_RIL_INTERNAL_H |
| 18 | #define ANDROID_RIL_INTERNAL_H |
| 19 | |
Amit Mahajan | cd77a5b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 20 | namespace android { |
| 21 | |
Amit Mahajan | 35e9310 | 2017-03-28 11:17:55 -0700 | [diff] [blame] | 22 | #define RIL_SERVICE_NAME_BASE "slot" |
| 23 | #define RIL1_SERVICE_NAME "slot1" |
| 24 | #define RIL2_SERVICE_NAME "slot2" |
| 25 | #define RIL3_SERVICE_NAME "slot3" |
| 26 | #define RIL4_SERVICE_NAME "slot4" |
Amit Mahajan | 439da36 | 2017-02-13 17:43:04 -0800 | [diff] [blame] | 27 | |
Amit Mahajan | cd77a5b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 28 | /* Constants for response types */ |
| 29 | #define RESPONSE_SOLICITED 0 |
| 30 | #define RESPONSE_UNSOLICITED 1 |
| 31 | #define RESPONSE_SOLICITED_ACK 2 |
| 32 | #define RESPONSE_SOLICITED_ACK_EXP 3 |
| 33 | #define RESPONSE_UNSOLICITED_ACK_EXP 4 |
| 34 | |
Amit Mahajan | 5829a47 | 2016-12-28 17:28:07 -0800 | [diff] [blame] | 35 | // Enable verbose logging |
| 36 | #define VDBG 0 |
| 37 | |
| 38 | #define MIN(a,b) ((a)<(b) ? (a) : (b)) |
| 39 | |
| 40 | // Enable RILC log |
| 41 | #define RILC_LOG 0 |
| 42 | |
| 43 | #if RILC_LOG |
| 44 | #define startRequest sprintf(printBuf, "(") |
| 45 | #define closeRequest sprintf(printBuf, "%s)", printBuf) |
| 46 | #define printRequest(token, req) \ |
| 47 | RLOGD("[%04d]> %s %s", token, requestToString(req), printBuf) |
| 48 | |
| 49 | #define startResponse sprintf(printBuf, "%s {", printBuf) |
| 50 | #define closeResponse sprintf(printBuf, "%s}", printBuf) |
| 51 | #define printResponse RLOGD("%s", printBuf) |
| 52 | |
| 53 | #define clearPrintBuf printBuf[0] = 0 |
| 54 | #define removeLastChar printBuf[strlen(printBuf)-1] = 0 |
| 55 | #define appendPrintBuf(x...) snprintf(printBuf, PRINTBUF_SIZE, x) |
| 56 | #else |
| 57 | #define startRequest |
| 58 | #define closeRequest |
| 59 | #define printRequest(token, req) |
| 60 | #define startResponse |
| 61 | #define closeResponse |
| 62 | #define printResponse |
| 63 | #define clearPrintBuf |
| 64 | #define removeLastChar |
| 65 | #define appendPrintBuf(x...) |
| 66 | #endif |
| 67 | |
Amit Mahajan | cd77a5b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 68 | typedef struct CommandInfo CommandInfo; |
| 69 | |
| 70 | extern "C" const char * requestToString(int request); |
| 71 | |
| 72 | typedef struct RequestInfo { |
| 73 | int32_t token; //this is not RIL_Token |
| 74 | CommandInfo *pCI; |
| 75 | struct RequestInfo *p_next; |
| 76 | char cancelled; |
| 77 | char local; // responses to local commands do not go back to command process |
| 78 | RIL_SOCKET_ID socket_id; |
| 79 | int wasAckSent; // Indicates whether an ack was sent earlier |
| 80 | } RequestInfo; |
| 81 | |
| 82 | typedef struct CommandInfo { |
| 83 | int requestNumber; |
Amit Mahajan | 759786a | 2017-03-03 17:35:47 -0800 | [diff] [blame] | 84 | int(*responseFunction) (int slotId, int responseType, int token, |
Amit Mahajan | cd77a5b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 85 | RIL_Errno e, void *response, size_t responselen); |
| 86 | } CommandInfo; |
| 87 | |
Sanket Padawe | f220dc5 | 2017-01-02 23:46:00 -0800 | [diff] [blame] | 88 | RequestInfo * addRequestToList(int serial, int slotId, int request); |
Amit Mahajan | cd77a5b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 89 | |
Amit Mahajan | 35e9310 | 2017-03-28 11:17:55 -0700 | [diff] [blame] | 90 | char * RIL_getServiceName(); |
Amit Mahajan | cd77a5b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 91 | |
Sanket Padawe | f220dc5 | 2017-01-02 23:46:00 -0800 | [diff] [blame] | 92 | void releaseWakeLock(); |
Amit Mahajan | c7ad626 | 2017-03-14 16:39:27 -0700 | [diff] [blame] | 93 | |
| 94 | void onNewCommandConnect(RIL_SOCKET_ID socket_id); |
| 95 | |
Amit Mahajan | cd77a5b | 2016-08-25 11:19:21 -0700 | [diff] [blame] | 96 | } // namespace android |
| 97 | |
| 98 | #endif //ANDROID_RIL_INTERNAL_H |