rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | #include <vendor-ril/telephony/ril.h> |
| 2 | #include <log/log.h> |
| 3 | |
| 4 | #include "atci_at_util.h" |
| 5 | #include "atci_util.h" |
| 6 | |
| 7 | #undef LOG_TAG |
| 8 | #define LOG_TAG "DEMO_ATCI_UTIL" |
| 9 | |
| 10 | static atci_cmd_type_t *atci_cmd_table[MAX_CMD_HANDLER_MODULE_NUM]; |
| 11 | int atci_cmd_register(atci_cmd_type_t *ptr) { |
| 12 | int i = 0; |
| 13 | for (i = 0; i < MAX_CMD_HANDLER_MODULE_NUM; i++) { |
| 14 | if (NULL == atci_cmd_table[i]) { |
| 15 | atci_cmd_table[i] = ptr; |
| 16 | return SYS_SUCC; |
| 17 | } |
| 18 | } |
| 19 | RLOGE("atci_cmd_table,is full,cmd_register fail!!!"); |
| 20 | return SYS_FAIL; |
| 21 | } |
| 22 | |
| 23 | atci_cmd_type_t* atci_find_cmd_handler(char *prefix) { |
| 24 | |
| 25 | atci_cmd_type_t *reasult = NULL; |
| 26 | atci_cmd_type_t **reasult_ptr; |
| 27 | |
| 28 | reasult_ptr = atci_cmd_table; |
| 29 | int i, j; |
| 30 | for (i = 0; i < MAX_CMD_HANDLER_MODULE_NUM; i++) { |
| 31 | atci_cmd_type_t *tmp_ptr; |
| 32 | if (NULL == reasult_ptr[i]) { |
| 33 | continue; |
| 34 | } |
| 35 | tmp_ptr = reasult_ptr[i]; |
| 36 | for (j = 0;; j++) { |
| 37 | if (NULL == tmp_ptr[j].cmd_prefix) { |
| 38 | break; |
| 39 | } |
| 40 | //RLOGD("scan [%s]",tmp_ptr[j].cmd_prefix); |
| 41 | if (0 == strcasecmp(prefix, tmp_ptr[j].cmd_prefix)) { |
| 42 | RLOGD("find cmd[%s] handle", prefix); |
| 43 | reasult = &tmp_ptr[j]; |
| 44 | return reasult; |
| 45 | } |
| 46 | } |
| 47 | if (NULL != reasult) { |
| 48 | break; |
| 49 | } |
| 50 | } |
| 51 | RLOGD("can't find cmd[%s],need handle by default", prefix); |
| 52 | return reasult; |
| 53 | } |
| 54 | |
| 55 | char* request2RILStr(int request) { |
| 56 | switch (request) { |
| 57 | case RIL_REQUEST_SET_CALL_FORWARD: |
| 58 | return "RIL_REQUEST_SET_CALL_FORWARD"; |
| 59 | case RIL_REQUEST_SET_CALL_WAITING: |
| 60 | return "RIL_REQUEST_SET_CALL_WAITING"; |
| 61 | case RIL_REQUEST_SET_FACILITY_LOCK: |
| 62 | return "RIL_REQUEST_SET_FACILITY_LOCK"; |
| 63 | case RIL_REQUEST_DIAL: |
| 64 | return "RIL_REQUEST_DIAL"; |
| 65 | case RIL_REQUEST_REMOVE_IMS_CONFERENCE_CALL_MEMBER: |
| 66 | return "RIL_REQUEST_REMOVE_IMS_CONFERENCE_CALL_MEMBER"; |
| 67 | case RIL_REQUEST_RADIO_POWER: |
| 68 | return "RIL_REQUEST_RADIO_POWER"; |
| 69 | case RIL_REQUEST_SET_MUTE: |
| 70 | return "RIL_REQUEST_SET_MUTE"; |
| 71 | case RIL_REQUEST_CONFERENCE: |
| 72 | return "RIL_REQUEST_CONFERENCE"; |
| 73 | case RIL_REQUEST_CONFERENCE_DIAL: |
| 74 | return "RIL_REQUEST_CONFERENCE_DIAL"; |
| 75 | case RIL_REQUEST_DIAL_WITH_SIP_URI: |
| 76 | return "RIL_REQUEST_DIAL_WITH_SIP_URI"; |
| 77 | case RIL_REQUEST_SET_IMS_ENABLE: |
| 78 | return "RIL_REQUEST_SET_IMS_ENABLE"; |
| 79 | default: |
| 80 | return "unknown define"; |
| 81 | } |
| 82 | } |