diff options
author | Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> | 2017-06-03 23:06:56 +0200 |
---|---|---|
committer | Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> | 2017-06-03 23:06:56 +0200 |
commit | b495720c202fe7667831c5d30e007f8a2ab47b1f (patch) | |
tree | 90d4e36948106b11e3bf4aa08d76a03af639bee1 | |
parent | 559ecf8fd701d969d5e0131c0e60fbbd6b42452a (diff) | |
download | hardware_ril_samsung-ril-b495720c202fe7667831c5d30e007f8a2ab47b1f.zip hardware_ril_samsung-ril-b495720c202fe7667831c5d30e007f8a2ab47b1f.tar.gz hardware_ril_samsung-ril-b495720c202fe7667831c5d30e007f8a2ab47b1f.tar.bz2 |
move encoding check to ss.c
Signed-off-by: Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de>
-rw-r--r-- | samsung-ril.h | 6 | ||||
-rw-r--r-- | ss.c | 43 | ||||
-rw-r--r-- | utils.c | 32 | ||||
-rw-r--r-- | utils.h | 8 |
4 files changed, 44 insertions, 45 deletions
diff --git a/samsung-ril.h b/samsung-ril.h index 28a731f..cf6dc15 100644 --- a/samsung-ril.h +++ b/samsung-ril.h @@ -369,6 +369,12 @@ int ril_request_screen_state(void *data, size_t size, RIL_Token token); * SS */ +enum { + USSD_ENCODING_UNKNOWN, + USSD_ENCODING_GSM7, + USSD_ENCODING_UCS2 +}; + int ipc_ss_ussd(struct ipc_message *message); int ril_request_send_ussd(void *data, size_t size, RIL_Token token); int ril_request_cancel_ussd(void *data, size_t size, RIL_Token token); @@ -230,12 +230,45 @@ int ipc2ril_ussd_state(struct ipc_ss_ussd_header *ussd, char *message[2]) return 0; } +int ipc2ril_ussd_encoding(int data_encoding) +{ + switch (data_encoding >> 4) { + case 0x00: + case 0x02: + case 0x03: + return USSD_ENCODING_GSM7; + case 0x01: + if (data_encoding == 0x10) + return USSD_ENCODING_GSM7; + if (data_encoding == 0x11) + return USSD_ENCODING_UCS2; + break; + case 0x04: + case 0x05: + case 0x06: + case 0x07: + if (data_encoding & 0x20) + return USSD_ENCODING_UNKNOWN; + if (((data_encoding >> 2) & 3) == 0) + return USSD_ENCODING_GSM7; + if (((data_encoding >> 2) & 3) == 2) + return USSD_ENCODING_UCS2; + break; + case 0xF: + if (!(data_encoding & 4)) + return USSD_ENCODING_GSM7; + break; + } + + return USSD_ENCODING_UNKNOWN; +} + int ipc_ss_ussd(struct ipc_message *message) { char *data_dec = NULL; int data_dec_len = 0; - sms_coding_scheme coding_scheme; char *ussd_message[2]; + int ussd_encoding; struct ipc_ss_ussd_header *ussd = NULL; unsigned char state; int rc; @@ -254,9 +287,9 @@ int ipc_ss_ussd(struct ipc_message *message) ril_request_data_set_uniq(RIL_REQUEST_SEND_USSD, (void *) &ussd->state, sizeof(unsigned char)); if (ussd->length > 0 && message->size > 0 && message->data != NULL) { - coding_scheme = sms_get_coding_scheme(ussd->dcs); - switch (coding_scheme) { - case SMS_CODING_SCHEME_GSM7: + ussd_encoding = ipc2ril_ussd_encoding(ussd->dcs); + switch (ussd_encoding) { + case USSD_ENCODING_GSM7: RIL_LOGD("USSD Rx encoding is GSM7"); data_dec_len = gsm72ascii((unsigned char *) message->data @@ -265,7 +298,7 @@ int ipc_ss_ussd(struct ipc_message *message) ussd_message[1][data_dec_len] = '\0'; break; - case SMS_CODING_SCHEME_UCS2: + case USSD_ENCODING_UCS2: RIL_LOGD("USSD Rx encoding %x is UCS2", ussd->dcs); data_dec_len = message->size - sizeof(struct ipc_ss_ussd_header); @@ -184,38 +184,6 @@ int utf8_write(char *utf8, int offset, int v) return result; } -sms_coding_scheme sms_get_coding_scheme(int data_encoding) -{ - switch (data_encoding >> 4) { - case 0x00: - case 0x02: - case 0x03: - return SMS_CODING_SCHEME_GSM7; - case 0x01: - if (data_encoding == 0x10) - return SMS_CODING_SCHEME_GSM7; - if (data_encoding == 0x11) - return SMS_CODING_SCHEME_UCS2; - break; - case 0x04: - case 0x05: - case 0x06: - case 0x07: - if (data_encoding & 0x20) - return SMS_CODING_SCHEME_UNKNOWN; - if (((data_encoding >> 2) & 3) == 0) - return SMS_CODING_SCHEME_GSM7; - if (((data_encoding >> 2) & 3) == 2) - return SMS_CODING_SCHEME_UCS2; - break; - case 0xF: - if (!(data_encoding & 4)) - return SMS_CODING_SCHEME_GSM7; - break; - } - return SMS_CODING_SCHEME_UNKNOWN; -} - int data_dump(const void *data, size_t size) { unsigned int cols = 8; @@ -42,12 +42,4 @@ int eventfd_flush(int fd); int eventfd_recv(int fd, eventfd_t *event); int eventfd_send(int fd, eventfd_t event); -typedef enum { - SMS_CODING_SCHEME_UNKNOWN = 0, - SMS_CODING_SCHEME_GSM7, - SMS_CODING_SCHEME_UCS2 -} sms_coding_scheme; - -sms_coding_scheme sms_get_coding_scheme(int data_encoding); - #endif |