diff options
author | Joakim Roubert <joakim.roubert@stericsson.com> | 2010-09-29 12:47:36 +0200 |
---|---|---|
committer | Sverre Vegge <sverre.vegge@stericsson.com> | 2010-11-26 12:44:29 +0100 |
commit | aed3ffa8e4712fb4639b2949138c05cc07a91d36 (patch) | |
tree | 994e95387cac2c886195764efdc9d751c98eff9f | |
parent | 3d05aca55cdbc5c5cb12c6abbe4d3b966fb27d76 (diff) | |
download | u300-aed3ffa8e4712fb4639b2949138c05cc07a91d36.tar.gz |
Code cleanup performed in order to make code more consistent and readable.
Change-Id: I01bda5c3e966194945400f04e677d53617e22f23
Signed-off-by: Sverre Vegge <sverre.vegge@stericsson.com>
-rw-r--r-- | README | 6 | ||||
-rw-r--r-- | RELEASE_NOTES | 8 | ||||
-rw-r--r-- | atchannel.c | 58 | ||||
-rw-r--r-- | atchannel.h | 100 | ||||
-rw-r--r-- | u300-ril-callhandling.c | 80 | ||||
-rw-r--r-- | u300-ril-messaging.c | 35 | ||||
-rw-r--r-- | u300-ril-network.c | 88 | ||||
-rw-r--r-- | u300-ril-oem-parser.cpp | 11 | ||||
-rw-r--r-- | u300-ril-oem-parser.h | 35 | ||||
-rw-r--r-- | u300-ril-pdp.c | 26 | ||||
-rw-r--r-- | u300-ril-pdp.h | 2 | ||||
-rw-r--r-- | u300-ril-services.c | 44 | ||||
-rw-r--r-- | u300-ril-sim.c | 109 | ||||
-rw-r--r-- | u300-ril-stk.c | 24 | ||||
-rw-r--r-- | u300-ril.c | 72 |
15 files changed, 361 insertions, 337 deletions
@@ -13,12 +13,12 @@ BUILDING mydroid/hardware/ste/u300-ril$ cd hardware/ste/u300-ril/ mydroid/hardware/ste/u300-ril$ mm - This will produce the libu300-ril.so in the + This will produce the libu300-ril.so in the mydroid/out/product/..../system/lib/ directory. INSTALLATION Copy the libu300-ril.so file to the /system/lib/ directory on target and - modify the ril-daemon service in android's init.rc to use it. A sample + modify the ril-daemon service in android's init.rc to use it. A sample follows: service ril-daemon /system/bin/rild -l /system/lib/libu300-ril.so -- -c CAIF -i gprs0 @@ -49,7 +49,7 @@ INSTALLATION Make sure that the RIL has access to the AT channel or change it if needed. For example to change permission rights to /dev/chnlat* in init.rc, please add: - + device /dev/chnlat* 0660 radio radio to init.rc above the service definitions. This is important, since the RIL diff --git a/RELEASE_NOTES b/RELEASE_NOTES deleted file mode 100644 index ae8c268..0000000 --- a/RELEASE_NOTES +++ /dev/null @@ -1,8 +0,0 @@ -Release notes for ST-Ericsson U300 RIL R2B - -MAJOR CHANGES - - Initial contribution - -Fixed IR:s - - None - diff --git a/atchannel.c b/atchannel.c index b58b085..c44af23 100644 --- a/atchannel.c +++ b/atchannel.c @@ -89,8 +89,8 @@ struct atcontext { const char *smsPDU; ATResponse *response; - void (*onTimeout) (void); - void (*onReaderClosed) (void); + void (*onTimeout)(void); + void (*onReaderClosed)(void); int readerClosed; int timeoutMsec; @@ -376,8 +376,8 @@ static void processLine(const char *line) break; case SINGLELINE: if (ac->response->p_intermediates == NULL - && strStartsWith(line, ac->responsePrefix) - ) + && strStartsWith(line, ac->responsePrefix) + ) addIntermediate(line); else /* We already have an intermediate response. */ @@ -783,7 +783,7 @@ static ATResponse *at_response_new() return (ATResponse *) calloc(1, sizeof(ATResponse)); } -void at_response_free(ATResponse * p_response) +void at_response_free(ATResponse *p_response) { ATLine *p_line; @@ -810,7 +810,7 @@ void at_response_free(ATResponse * p_response) * The line reader places the intermediate responses in reverse order, * here we flip them back. */ -static void reverseIntermediates(ATResponse * p_response) +static void reverseIntermediates(ATResponse *p_response) { ATLine *pcur, *pnext; @@ -837,7 +837,7 @@ static int at_send_command_full_nolock(const char *command, const char *responsePrefix, const char *smspdu, long long timeoutMsec, - ATResponse ** pp_outResponse) + ATResponse **pp_outResponse) { int err = 0; @@ -908,7 +908,7 @@ static int at_send_command_full_nolock(const char *command, } err = 0; - error: +error: clearPendingCommand(); pthread_cond_broadcast(&ac->requestcond); @@ -925,7 +925,7 @@ static int at_send_command_full_nolock(const char *command, static int at_send_command_full(const char *command, ATCommandType type, const char *responsePrefix, const char *smspdu, long long timeoutMsec, - ATResponse ** pp_outResponse) + ATResponse **pp_outResponse) { int err; @@ -971,7 +971,7 @@ void at_send_escape(void) * if non-NULL, the resulting ATResponse * must be eventually freed with * at_response_free. */ -int at_send_command(const char *command, ATResponse ** pp_outResponse) +int at_send_command(const char *command, ATResponse **pp_outResponse) { int err; @@ -986,7 +986,7 @@ int at_send_command(const char *command, ATResponse ** pp_outResponse) int at_send_command_singleline(const char *command, const char *responsePrefix, - ATResponse ** pp_outResponse) + ATResponse **pp_outResponse) { int err; @@ -996,8 +996,8 @@ int at_send_command_singleline(const char *command, NULL, ac->timeoutMsec, pp_outResponse); if (err == 0 && pp_outResponse != NULL - && (*pp_outResponse)->success > 0 - && (*pp_outResponse)->p_intermediates == NULL) { + && (*pp_outResponse)->success > 0 + && (*pp_outResponse)->p_intermediates == NULL) { /* Successful command must have an intermediate response. */ at_response_free(*pp_outResponse); *pp_outResponse = NULL; @@ -1009,7 +1009,7 @@ int at_send_command_singleline(const char *command, int at_send_command_numeric(const char *command, - ATResponse ** pp_outResponse) + ATResponse **pp_outResponse) { int err; @@ -1019,8 +1019,8 @@ int at_send_command_numeric(const char *command, NULL, ac->timeoutMsec, pp_outResponse); if (err == 0 && pp_outResponse != NULL - && (*pp_outResponse)->success > 0 - && (*pp_outResponse)->p_intermediates == NULL) { + && (*pp_outResponse)->success > 0 + && (*pp_outResponse)->p_intermediates == NULL) { /* Successful command must have an intermediate response. */ at_response_free(*pp_outResponse); *pp_outResponse = NULL; @@ -1034,7 +1034,7 @@ int at_send_command_numeric(const char *command, int at_send_command_sms(const char *command, const char *pdu, const char *responsePrefix, - ATResponse ** pp_outResponse) + ATResponse **pp_outResponse) { int err; @@ -1044,8 +1044,8 @@ int at_send_command_sms(const char *command, pdu, ac->timeoutMsec, pp_outResponse); if (err == 0 && pp_outResponse != NULL - && (*pp_outResponse)->success > 0 - && (*pp_outResponse)->p_intermediates == NULL) { + && (*pp_outResponse)->success > 0 + && (*pp_outResponse)->p_intermediates == NULL) { /* Successful command must have an intermediate response. */ at_response_free(*pp_outResponse); *pp_outResponse = NULL; @@ -1058,7 +1058,7 @@ int at_send_command_sms(const char *command, int at_send_command_multiline(const char *command, const char *responsePrefix, - ATResponse ** pp_outResponse) + ATResponse **pp_outResponse) { int err; @@ -1082,7 +1082,7 @@ void at_set_timeout_msec(int timeout) } /** This callback is invoked on the command thread. */ -void at_set_on_timeout(void (*onTimeout) (void)) +void at_set_on_timeout(void (*onTimeout)(void)) { struct atcontext *ac = getAtContext(); @@ -1096,7 +1096,7 @@ void at_set_on_timeout(void (*onTimeout) (void)) * You should still call at_close(). It may also be invoked immediately from the * current thread if the read channel is already closed. */ -void at_set_on_reader_closed(void (*onClose) (void)) +void at_set_on_reader_closed(void (*onClose)(void)) { struct atcontext *ac = getAtContext(); @@ -1147,7 +1147,7 @@ int at_handshake() * Returns error code from response. * Assumes AT+CMEE=1 (numeric) mode. */ -AT_CME_Error at_get_cme_error(const ATResponse * p_response) +AT_CME_Error at_get_cme_error(const ATResponse *p_response) { int ret; int err; @@ -1157,8 +1157,8 @@ AT_CME_Error at_get_cme_error(const ATResponse * p_response) return CME_SUCCESS; if (p_response->finalResponse == NULL - || !strStartsWith(p_response->finalResponse, "+CME ERROR:") - ) + || !strStartsWith(p_response->finalResponse, "+CME ERROR:") + ) return CME_ERROR_NON_CME; p_cur = p_response->finalResponse; @@ -1178,7 +1178,7 @@ AT_CME_Error at_get_cme_error(const ATResponse * p_response) /** * Returns SM cause code from response to AT+CEER command. */ -AT_SM_Cause at_get_sm_cause(const ATResponse * p_response) +AT_SM_Cause at_get_sm_cause(const ATResponse *p_response) { int ret; int err; @@ -1188,20 +1188,26 @@ AT_SM_Cause at_get_sm_cause(const ATResponse * p_response) /* Check every line of the response for the expected output. */ p = p_response->p_intermediates; + while (p != NULL) { line = p->line; + if (strstr(line, "+CEER: Deactivate Cause: SM") != NULL) break; if (p->p_next == NULL) return SM_CAUSE_NON_SM; p = p->p_next; } + if (p == NULL) return SM_CAUSE_NON_SM; + p_cur = strchr(line, 'M'); + if (p_cur == NULL) { return SM_CAUSE_NON_SM; } + p_cur++; ret = strtol(p_cur, NULL, 10); diff --git a/atchannel.h b/atchannel.h index e15bf21..6393919 100644 --- a/atchannel.h +++ b/atchannel.h @@ -49,27 +49,27 @@ extern "C" { response */ - typedef enum { - NO_RESULT, /* No intermediate response expected. */ - NUMERIC, /* A single intermediate response starting with a 0-9. */ - SINGLELINE, /* A single intermediate response starting with a prefix. */ - MULTILINE /* Multiple line intermediate response - starting with a prefix. */ - } ATCommandType; +typedef enum { + NO_RESULT, /* No intermediate response expected. */ + NUMERIC, /* A single intermediate response starting with a 0-9. */ + SINGLELINE, /* A single intermediate response starting with a prefix. */ + MULTILINE /* Multiple line intermediate response + starting with a prefix. */ +} ATCommandType; /** A singly-linked list of intermediate responses. */ - typedef struct ATLine { - struct ATLine *p_next; - char *line; - } ATLine; +typedef struct ATLine { + struct ATLine *p_next; + char *line; +} ATLine; /** Free this with at_response_free(). */ - typedef struct { - int success; /* True if final response indicates - success (eg "OK"). */ - char *finalResponse; /* Eg OK, ERROR */ - ATLine *p_intermediates; /* Any intermediate responses. */ - } ATResponse; +typedef struct { + int success; /* True if final response indicates + success (eg "OK"). */ + char *finalResponse; /* Eg OK, ERROR */ + ATLine *p_intermediates; /* Any intermediate responses. */ +} ATResponse; /** * A user-provided unsolicited response handler function. @@ -77,22 +77,22 @@ extern "C" { * "s" is the line, and "sms_pdu" is either NULL or the PDU response * for multi-line TS 27.005 SMS PDU responses (eg +CMT:). */ - typedef void (*ATUnsolHandler) (const char *s, const char *sms_pdu); +typedef void (*ATUnsolHandler)(const char *s, const char *sms_pdu); - int at_open(int fd, ATUnsolHandler h); - void at_close(); +int at_open(int fd, ATUnsolHandler h); +void at_close(); /* * Set default timeout for at commands. Let it be reasonable high * since some commands take their time. Default is 10 minutes. */ - void at_set_timeout_msec(int timeout); +void at_set_timeout_msec(int timeout); /* * This callback is invoked on the command thread. * You should reset or handshake here to avoid getting out of sync. */ - void at_set_on_timeout(void (*onTimeout) (void)); +void at_set_on_timeout(void (*onTimeout)(void)); /* * This callback is invoked on the reader thread (like ATUnsolHandler), when the @@ -100,48 +100,48 @@ extern "C" { * You should still call at_close(). It may also be invoked immediately from the * current thread if the read channel is already closed. */ - void at_set_on_reader_closed(void (*onClose) (void)); +void at_set_on_reader_closed(void (*onClose)(void)); - void at_send_escape(void); +void at_send_escape(void); - int at_send_command_singleline(const char *command, - const char *responsePrefix, - ATResponse ** pp_outResponse); +int at_send_command_singleline(const char *command, + const char *responsePrefix, + ATResponse **pp_outResponse); - int at_send_command_numeric(const char *command, - ATResponse ** pp_outResponse); +int at_send_command_numeric(const char *command, + ATResponse **pp_outResponse); - int at_send_command_multiline(const char *command, - const char *responsePrefix, - ATResponse ** pp_outResponse); +int at_send_command_multiline(const char *command, + const char *responsePrefix, + ATResponse **pp_outResponse); - int at_handshake(); +int at_handshake(); - int at_send_command(const char *command, ATResponse ** pp_outResponse); +int at_send_command(const char *command, ATResponse **pp_outResponse); - int at_send_command_sms(const char *command, const char *pdu, - const char *responsePrefix, - ATResponse ** pp_outResponse); +int at_send_command_sms(const char *command, const char *pdu, + const char *responsePrefix, + ATResponse **pp_outResponse); - void at_response_free(ATResponse * p_response); +void at_response_free(ATResponse *p_response); - void at_make_default_channel(void); +void at_make_default_channel(void); - typedef enum { - CME_ERROR_NON_CME = -1, - CME_SUCCESS = 0, - CME_SIM_NOT_INSERTED = 10 - } AT_CME_Error; +typedef enum { + CME_ERROR_NON_CME = -1, + CME_SUCCESS = 0, + CME_SIM_NOT_INSERTED = 10 +} AT_CME_Error; - AT_CME_Error at_get_cme_error(const ATResponse * p_response); +AT_CME_Error at_get_cme_error(const ATResponse *p_response); - typedef enum { - SM_CAUSE_NON_SM = -1, - SM_SUCCESS = 0 - } AT_SM_Cause; +typedef enum { + SM_CAUSE_NON_SM = -1, + SM_SUCCESS = 0 +} AT_SM_Cause; - AT_SM_Cause at_get_sm_cause(const ATResponse * p_response); +AT_SM_Cause at_get_sm_cause(const ATResponse *p_response); #ifdef __cplusplus } diff --git a/u300-ril-callhandling.c b/u300-ril-callhandling.c index 105bdba..8f28e35 100644 --- a/u300-ril-callhandling.c +++ b/u300-ril-callhandling.c @@ -35,6 +35,10 @@ #include <utils/Log.h> enum cli_validity { + /* Maps to numberPresentation and namePresentation in structure RIL_Call + * in file ril.h. + * 0=Allowed, 1=Restricted, 2=Not Specified/Unknown 3=Payphone + */ CLI_VALID = 0, CLI_WITHELD = 1, CLI_UNAVAILABLE = 2 @@ -65,7 +69,7 @@ static struct cli_info cli_info; /* Last call fail cause, obtained by *ECAV. */ static int s_lastCallFailCause = CALL_FAIL_ERROR_UNSPECIFIED; -static int clccStateToRILState(int state, RIL_CallState * p_state) +static int clccStateToRILState(int state, RIL_CallState *p_state) { switch (state) { case 0: @@ -95,7 +99,7 @@ static int clccStateToRILState(int state, RIL_CallState * p_state) * Note: Directly modified line and has *p_call point directly into * modified line. */ -static int callFromCLCCLine(char *line, RIL_Call * p_call) +static int callFromCLCCLine(char *line, RIL_Call *p_call) { /* +CLCC: 1,0,2,0,0,\"+18005551212\",145 index,isMT,state,mode,isMpty(,number,TOA)? */ @@ -128,7 +132,7 @@ static int callFromCLCCLine(char *line, RIL_Call * p_call) /* We're only providing real CLI validity on incoming calls */ if (cli_info.valid && (p_call->state == RIL_CALL_INCOMING || - p_call->state == RIL_CALL_WAITING)) { + p_call->state == RIL_CALL_WAITING)) { p_call->numberPresentation = cli_info.cli_validity; p_call->namePresentation = cli_info.cli_validity; } @@ -169,7 +173,7 @@ static int callFromCLCCLine(char *line, RIL_Call * p_call) return 0; - error: +error: LOGE("invalid CLCC line\n"); return -1; } @@ -263,7 +267,7 @@ void onECAVReceived(const char *s) enqueueRILEvent(RIL_EVENT_QUEUE_PRIO, hangupBusyCall, NULL, NULL); } - finally: +finally: free(line); /* Send the response even if we failed.. */ @@ -271,7 +275,7 @@ void onECAVReceived(const char *s) return; - error: +error: LOGE("ECAV: Failed to parse %s.", s); /* Reset lastCallFailCause */ s_lastCallFailCause = CALL_FAIL_ERROR_UNSPECIFIED; @@ -298,14 +302,14 @@ void onAudioCallEventNotify(const char *s) if (err < 0) goto error; - finally: +finally: free(line); /* Send the response even if we failed.. */ RIL_onUnsolicitedResponse(RIL_UNSOL_RINGBACK_TONE, &res, sizeof(int *)); return; - error: +error: LOGE("EACE: Failed to parse %s.", s); goto finally; } @@ -410,11 +414,11 @@ void requestHangupWaitingOrBackground(void *data, size_t datalen, RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -452,10 +456,10 @@ void requestHangupForegroundResumeBackground(void *data, size_t datalen, RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -480,11 +484,11 @@ void requestSwitchWaitingOrHoldingAndActive(void *data, size_t datalen, RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -507,11 +511,11 @@ void requestConference(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -547,11 +551,11 @@ void requestSeparateConnection(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -573,11 +577,11 @@ void requestExplicitCallTransfer(void *data, size_t datalen, RIL_Token t) goto error; RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -599,11 +603,11 @@ void requestUDUB(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -633,11 +637,11 @@ void requestSetMute(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -670,11 +674,11 @@ void requestGetMute(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, &response, sizeof(int)); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -791,11 +795,11 @@ void requestDial(void *data, size_t datalen, RIL_Token t) it will call GET_CURRENT_CALLS and determine success that way. */ RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -823,11 +827,11 @@ void requestAnswer(void *data, size_t datalen, RIL_Token t) it will call GET_CURRENT_CALLS and determine success that way. */ RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -908,13 +912,13 @@ void requestHangup(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: if (cmd) free(cmd); at_response_free(atresponse); return; - error: +error: /* Success or failure is ignored by the upper layer here, it will call GET_CURRENT_CALLS and determine success that way. */ RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); @@ -952,14 +956,14 @@ void requestDTMF(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: if (cmd != NULL) free(cmd); at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -998,14 +1002,14 @@ void requestDTMFStart(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: if (cmd != NULL) free(cmd); at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -1028,11 +1032,11 @@ void requestDTMFStop(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } diff --git a/u300-ril-messaging.c b/u300-ril-messaging.c index db86b8a..633b213 100644 --- a/u300-ril-messaging.c +++ b/u300-ril-messaging.c @@ -48,8 +48,7 @@ struct held_pdu { static pthread_mutex_t s_held_pdus_mutex = PTHREAD_MUTEX_INITIALIZER; static struct held_pdu *s_held_pdus = NULL; -static struct held_pdu *dequeue_held_pdu() -{ +static struct held_pdu *dequeue_held_pdu() { struct held_pdu *hpdu = NULL; if (s_held_pdus != NULL) { @@ -138,7 +137,7 @@ void onNewBroadcastSms(const char *pdu) RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS, message, sizeof(char *)); - error: +error: return; } @@ -170,11 +169,11 @@ void onNewSmsOnSIM(const char *s) RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM, &index, sizeof(int *)); - finally: +finally: free(line); return; - error: +error: LOGE("Failed to parse +CMTI."); goto finally; } @@ -260,13 +259,14 @@ void requestGSMGetBroadcastSMSConfig(void *data, size_t datalen, RIL_onRequestComplete(t, RIL_E_SUCCESS, configInfo, sizeof(RIL_GSM_BroadcastSmsConfigInfo *)); - finally: +finally: + if (configInfo != NULL) free(configInfo); at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -368,11 +368,11 @@ void requestGSMSMSBroadcastActivation(void *data, size_t datalen, RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -428,11 +428,12 @@ void requestSendSMS(void *data, size_t datalen, RIL_Token t) /* No support for ackPDU. Do we need it? */ RIL_onRequestComplete(t, RIL_E_SUCCESS, &response, sizeof(response)); - finally: +finally: at_response_free(atresponse); return; - error: +error: + switch (at_get_cme_error(atresponse)) { case 332: case 331: @@ -544,11 +545,11 @@ void requestWriteSmsToSim(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, &index, sizeof(int *)); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -602,11 +603,11 @@ void requestGetSMSCAddress(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(char *)); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -629,11 +630,11 @@ void requestSetSMSCAddress(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } diff --git a/u300-ril-network.c b/u300-ril-network.c index e5cc39b..4ddf847 100644 --- a/u300-ril-network.c +++ b/u300-ril-network.c @@ -93,15 +93,15 @@ static void pollOperatorSelected(void *params) goto finished; } - finally: +finally: at_response_free(atresponse); return; - finished: +finished: free(poll_params); goto finally; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finished; } @@ -186,13 +186,13 @@ static void GSMNeighbouringCellIDs(void *data, size_t datalen, RIL_Token t) } RIL_onRequestComplete(t, RIL_E_SUCCESS, ptr_cells, - n*sizeof(RIL_NeighboringCell*)); + n * sizeof(RIL_NeighboringCell *)); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -268,13 +268,13 @@ static void WCDMANeighbouringCellIDs(void *data, size_t datalen, } RIL_onRequestComplete(t, RIL_E_SUCCESS, ptr_cells, - n*sizeof(RIL_NeighboringCell*)); + n * sizeof(RIL_NeighboringCell *)); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -287,7 +287,7 @@ static void WCDMANeighbouringCellIDs(void *data, size_t datalen, */ void onNetworkTimeReceived(const char *s) { - char *line, *tok, *response, *tz, *nitz, *timestamp, *dst; + char *line, *tok, *response, *tz, *nitz, *timestamp, *dst; tok = line = strdup(s); at_tok_start(&tok); @@ -371,7 +371,7 @@ void unsolSignalStrength(const char *s) free(line); return; - error: +error: free(line); } @@ -417,7 +417,7 @@ void unsolSimSmsFull(const char *s) free(line); return; - error: +error: free(line); } @@ -479,7 +479,7 @@ void requestSetNetworkSelectionAutomatic(void *data, size_t datalen, return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); return; } @@ -519,7 +519,7 @@ void requestSetNetworkSelectionManual(void *data, size_t datalen, goto error; RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: at_response_free(atresponse); @@ -528,7 +528,7 @@ void requestSetNetworkSelectionManual(void *data, size_t datalen, return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -556,7 +556,7 @@ void requestQueryAvailableNetworks(void *data, size_t datalen, RIL_Token t) int err = 0; ATResponse *atresponse = NULL; const char *statusTable[] = - { "unknown", "available", "current", "forbidden" }; + { "unknown", "available", "current", "forbidden" }; char **responseArray = NULL; char *p; int n = 0; @@ -654,11 +654,11 @@ void requestQueryAvailableNetworks(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, responseArray, i * 4 * sizeof(char *)); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -705,11 +705,11 @@ void requestSetPreferredNetworkType(void *data, size_t datalen, RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, errno, NULL, 0); goto finally; } @@ -759,11 +759,11 @@ void requestGetPreferredNetworkType(void *data, size_t datalen, RIL_onRequestComplete(t, RIL_E_SUCCESS, &response, sizeof(int)); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -805,11 +805,12 @@ void requestEnterNetworkDepersonalization(void *data, size_t datalen, /* TODO: Return number of retries left. */ RIL_onRequestComplete(t, RIL_E_SUCCESS, &num_retries, sizeof(int *)); - finally: +finally: at_response_free(atresponse); return; - error: +error: + if (atresponse && at_get_cme_error(atresponse) == 16) rilerr = RIL_E_PASSWORD_INCORRECT; @@ -849,11 +850,11 @@ void requestQueryNetworkSelectionMode(void *data, size_t datalen, RIL_onRequestComplete(t, RIL_E_SUCCESS, &response, sizeof(int)); - finally: +finally: at_response_free(atresponse); return; - error: +error: LOGE("requestQueryNetworkSelectionMode must never return error when radio is on"); RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; @@ -963,11 +964,11 @@ void requestSignalStrength(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, &signalStrength, sizeof(RIL_SignalStrength)); - finally: +finally: at_response_free(atresponse); return; - error: +error: LOGE("requestSignalStrength must never return an error when radio is on"); RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; @@ -1114,8 +1115,7 @@ void requestRegistrationState(void *data, size_t datalen, RIL_Token t) else responseStr[2] = NULL; - if (count > 3) - { + if (count > 3) { /* * Android expects this for response[3]: * @@ -1193,7 +1193,7 @@ void requestRegistrationState(void *data, size_t datalen, RIL_Token t) actSet = 1; } - wa_final: +wa_final: if (actSet) { LOGI("AcT switched from %d to %d", response[3], cgregAcT); response[3] = cgregAcT; @@ -1228,7 +1228,7 @@ void requestRegistrationState(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, responseStr, count * sizeof(char *)); - finally: +finally: if (!getScreenState()) at_send_command("AT+CGREG=0;*EREG=0", NULL); releaseScreenStateLock(); /* Important! */ @@ -1245,7 +1245,7 @@ void requestRegistrationState(void *data, size_t datalen, RIL_Token t) at_response_free(atresponse); return; - error: +error: LOGE("requestRegistrationState must never return an error when radio is on."); RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; @@ -1382,7 +1382,7 @@ void requestGprsRegistrationState(void *data, size_t datalen, RIL_Token t) asprintf(&responseStr[0], "%d", response[0]); /* state */ if (response[1] >= 0) - asprintf(&responseStr[1], "%04x", response[1]); /* LAC */ + asprintf(&responseStr[1], "%04x", response[1]); /* LAC */ else responseStr[1] = NULL; @@ -1441,7 +1441,7 @@ void requestGprsRegistrationState(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, responseStr, count * sizeof(char *)); - finally: +finally: if (!getScreenState()) at_send_command("AT+CGREG=0", NULL); releaseScreenStateLock(); /* Important! */ @@ -1458,7 +1458,7 @@ void requestGprsRegistrationState(void *data, size_t datalen, RIL_Token t) at_response_free(atresponse); return; - error: +error: LOGE("requestRegistrationState must never return an error when radio is on."); RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; @@ -1550,11 +1550,11 @@ void requestOperator(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response)); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -1589,11 +1589,11 @@ void requestSetLocationUpdates(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -1637,18 +1637,18 @@ void requestNeighbouringCellIDs(void *data, size_t datalen, RIL_Token t) if (err < 0) goto error; - if ( /* GSM */ network == 0) + if (/* GSM */ network == 0) GSMNeighbouringCellIDs(data, datalen, t); - else if ( /* WCDMA */ network == 2) + else if (/* WCDMA */ network == 2) WCDMANeighbouringCellIDs(data, datalen, t); else goto error; - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } diff --git a/u300-ril-oem-parser.cpp b/u300-ril-oem-parser.cpp index f1fda13..603bd12 100644 --- a/u300-ril-oem-parser.cpp +++ b/u300-ril-oem-parser.cpp @@ -28,7 +28,8 @@ #include "u300-ril-oem-parser.h" -namespace u300_ril { +namespace u300_ril +{ using android::NO_ERROR; using android::NO_MEMORY; @@ -38,14 +39,14 @@ using android::NOT_ENOUGH_DATA; using android::NAME_NOT_FOUND; OemRilParser::OemRilParser() - : mParcel() + : mParcel() {} OemRilParser::~OemRilParser() {} android::status_t -OemRilParser::parseHeader(uint32_t* msg_id) +OemRilParser::parseHeader(uint32_t *msg_id) { status_t status; struct u300_ril_oem_hdr hdr; @@ -75,7 +76,7 @@ OemRilParser::parseHeader(uint32_t* msg_id) #ifdef U300_RIL_OEM_MSG_SELFTEST android::status_t -OemRilParser::parsePing(struct u300_ril_oem_ping_request* request) +OemRilParser::parsePing(struct u300_ril_oem_ping_request *request) { status_t status; if (!request) @@ -105,7 +106,7 @@ OemRilParser::parsePing(struct u300_ril_oem_ping_request* request) #ifdef U300_RIL_OEM_MSG_SELFTEST android::status_t -OemRilParser::writePingResponse(const struct u300_ril_oem_ping_response* response) +OemRilParser::writePingResponse(const struct u300_ril_oem_ping_response *response) { status_t status; diff --git a/u300-ril-oem-parser.h b/u300-ril-oem-parser.h index cfab2e8..893a1b1 100644 --- a/u300-ril-oem-parser.h +++ b/u300-ril-oem-parser.h @@ -30,7 +30,8 @@ #include "u300-ril-oem-msg.h" /* private */ -namespace u300_ril { +namespace u300_ril +{ /** U300 OEM RIL serializer/deserializer */ class OemRilParser @@ -38,8 +39,8 @@ class OemRilParser typedef android::status_t status_t; public: - OemRilParser(); - ~OemRilParser(); + OemRilParser(); + ~OemRilParser(); /** Set data buffer * @@ -53,7 +54,7 @@ public: * \retval BAD_VALUE indicates invalid argument. * \retval NO_MEMORY indicates memory allocation error. */ - inline status_t setData(uint8_t* buffer, size_t len); + inline status_t setData(uint8_t *buffer, size_t len); /** Get data buffer * @@ -61,7 +62,7 @@ public: * * \retval Pointer to the internal data buffer. */ - inline const uint8_t* data() const; + inline const uint8_t *data() const; /** Get data buffer size * @@ -83,7 +84,7 @@ public: * \retval NOT_ENOUGH_DATA indicates buffer underrun. * \retval NAME_NOT_FOUND indicates invalid message id. */ - status_t parseHeader(/*out*/ uint32_t* msg_id); + status_t parseHeader(/*out*/ uint32_t *msg_id); #ifdef U300_RIL_OEM_MSG_SELFTEST /** Parse OEM PING request. @@ -97,28 +98,28 @@ public: * \retval NOT_ENOUGH_DATA indicates buffer underrun. * \retval NO_MEMORY indicates memory allocation error. */ - status_t parsePing(/*out*/ struct u300_ril_oem_ping_request* request); + status_t parsePing(/*out*/ struct u300_ril_oem_ping_request *request); #endif /* U300_RIL_OEM_MSG_SELFTEST */ /* TODO: Define new parseXXX methods here */ - /** Explicitly reset the parser. + /** Explicitly reset the parser. * * \retval NO_ERROR indicates success. */ inline status_t reset(); #ifdef U300_RIL_OEM_MSG_SELFTEST - /** Build OEM PING response. + /** Build OEM PING response. * * \param response: [in] structure to be serialized. * \retval NO_ERROR indicates success. * \retval BAD_VALUE indicates invalid argument. * \retval NO_MEMORY indicates memory allocation error. */ - status_t writePingResponse(/*in*/ const struct u300_ril_oem_ping_response* response); + status_t writePingResponse(/*in*/ const struct u300_ril_oem_ping_response *response); #endif /* U300_RIL_OEM_MSG_SELFTEST */ /** Build OEM NETWORK_SEARCH_AND_SET response. @@ -133,9 +134,9 @@ public: private: /** No copy semantic*/ - OemRilParser(const OemRilParser& o); + OemRilParser(const OemRilParser &o); /** No copy semantic*/ - OemRilParser& operator=(const OemRilParser& o); + OemRilParser &operator=(const OemRilParser &o); private: /** Write an OEM RIL header to the stream. @@ -154,7 +155,7 @@ private: * \retval BAD_VALUE indicates invalid argument. * \retval NOT_ENOUGH_DATA indicates buffer underrun. */ - status_t readInt32(/*out*/ uint32_t* val); + status_t readInt32(/*out*/ uint32_t *val); /** Write an integer to the stream. * @@ -187,12 +188,12 @@ private: /* Implementation: inline delegates */ -inline android::status_t OemRilParser::setData(uint8_t* buffer, size_t len) +inline android::status_t OemRilParser::setData(uint8_t *buffer, size_t len) { return mParcel.setData(buffer, len); } -inline const uint8_t* OemRilParser::data() const +inline const uint8_t *OemRilParser::data() const { return mParcel.data(); } @@ -207,9 +208,9 @@ inline android::status_t OemRilParser::reset() return mParcel.setDataSize(0); } -inline android::status_t OemRilParser::readInt32(/*out*/ uint32_t* val) +inline android::status_t OemRilParser::readInt32(/*out*/ uint32_t *val) { - return mParcel.readInt32((int32_t*)val); + return mParcel.readInt32((int32_t *)val); } inline android::status_t OemRilParser::writeInt32(/*in*/ uint32_t val) diff --git a/u300-ril-pdp.c b/u300-ril-pdp.c index 2155506..edd0e88 100644 --- a/u300-ril-pdp.c +++ b/u300-ril-pdp.c @@ -62,7 +62,7 @@ static int convertAuthenticationMethod(const char *authentication) auth = strtol(authentication, &end, 10); - switch(auth) { + switch (auth) { case 0: /*PAP and CHAP is never performed.*/ return RIL_PDP_AUTH_NONE; /*00001*/ case 1: /*PAP may be performed; CHAP is never performed.*/ @@ -74,12 +74,13 @@ static int convertAuthenticationMethod(const char *authentication) default: break; } + return -1; } /* requestOrSendPDPContextList */ -static void requestOrSendPDPContextList(RIL_Token * token) +static void requestOrSendPDPContextList(RIL_Token *token) { ATResponse *atresponse = NULL; RIL_Data_Call_Response *responses = NULL; @@ -105,14 +106,16 @@ static void requestOrSendPDPContextList(RIL_Token * token) goto send_and_return; responses = alloca(number_of_contexts * sizeof(RIL_Data_Call_Response)); - memset (responses, 0, sizeof(responses)); + memset(responses, 0, sizeof(responses)); + for (i = 0; i < number_of_contexts; i++) { responses[i].cid = -1; responses[i].active = -1; } /*parse the result*/ - i=0; + i = 0; + for (cursor = atresponse->p_intermediates; cursor != NULL; cursor = cursor->p_next) { char *line = cursor->line; @@ -141,7 +144,8 @@ static void requestOrSendPDPContextList(RIL_Token * token) /* Read the currend pdp settings */ - err = at_send_command_multiline("AT+CGDCONT?", "+CGDCONT:",&atresponse); + err = at_send_command_multiline("AT+CGDCONT?", "+CGDCONT:", &atresponse); + if (err != 0 || atresponse->success == 0) goto error; @@ -219,7 +223,8 @@ error: if (responses[i].type != NULL) free(responses[i].type); } - free (responses); + + free(responses); } } @@ -302,7 +307,7 @@ void requestSetupDataCall(void *data, size_t datalen, RIL_Token t) * AT*EIAAUW=<cid>,<bearer_id>,<userid>,<password>,<auth_prot>,<ask4pwd> */ asprintf(&cmd, "AT*EIAAUW=1,1,\"%s\",\"%s\",%d,0", - (username ? username : ""),(password ? password : ""),auth); + (username ? username : ""), (password ? password : ""), auth); err = at_send_command(cmd, NULL); free(cmd); if (err < 0) @@ -337,7 +342,8 @@ void requestSetupDataCall(void *data, size_t datalen, RIL_Token t) */ s_lastDataCallFailCause = at_get_sm_cause(atresponse); LOGE("PDP Context Activate failed with SM Cause Code %i", - s_lastDataCallFailCause); + s_lastDataCallFailCause); + if (s_lastDataCallFailCause == SM_CAUSE_NON_SM) s_lastDataCallFailCause = PDP_FAIL_ERROR_UNSPECIFIED; @@ -632,7 +638,3 @@ void requestLastPDPFailCause(void *data, size_t datalen, RIL_Token t) s_lastDataCallFailCause = PDP_FAIL_ERROR_UNSPECIFIED; } - - - - diff --git a/u300-ril-pdp.h b/u300-ril-pdp.h index 25819fe..87a4ba2 100644 --- a/u300-ril-pdp.h +++ b/u300-ril-pdp.h @@ -24,7 +24,7 @@ #ifndef U300_RIL_PDP_H #define U300_RIL_PDP_H 1 -void requestOrSendPDPContextList(RIL_Token * t); +void requestOrSendPDPContextList(RIL_Token *t); void onPDPContextListChanged(void *param); void requestPDPContextList(void *data, size_t datalen, RIL_Token t); void requestSetupDataCall(void *data, size_t datalen, RIL_Token t); diff --git a/u300-ril-services.c b/u300-ril-services.c index 06a4665..7b67096 100644 --- a/u300-ril-services.c +++ b/u300-ril-services.c @@ -66,12 +66,12 @@ void requestQueryClip(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, &response, sizeof(int)); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -125,13 +125,14 @@ void requestSendUSSD(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: + if (response != NULL) at_response_free(response); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -175,7 +176,7 @@ void onSuppServiceNotification(const char *s, int type) RIL_onUnsolicitedResponse(RIL_UNSOL_SUPP_SVC_NOTIFICATION, &ssnResponse, sizeof(ssnResponse)); - error: +error: free(line); } @@ -228,7 +229,7 @@ void onUSSDReceived(const char *s) RIL_onUnsolicitedResponse(RIL_UNSOL_ON_USSD, response, n * sizeof(char *)); - error: +error: return; } @@ -267,11 +268,11 @@ void requestGetCLIR(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response)); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -294,12 +295,12 @@ void requestSetCLIR(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: free(cmd); at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -379,14 +380,14 @@ void requestQueryCallForwardStatus(void *data, size_t datalen, RIL_Token t) } RIL_onRequestComplete(t, RIL_E_SUCCESS, rilResponseArray, n * sizeof(RIL_CallForwardInfo *)); - finally: +finally: if (cmd != NULL) free(cmd); if (atresponse != NULL) at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -445,8 +446,7 @@ void requestSetCallForward(void *data, size_t datalen, RIL_Token t) serviceClass); } else if ((callForwardInfo->status == 0) || (callForwardInfo->status == 1) || - (callForwardInfo->status == 4)) - { + (callForwardInfo->status == 4)) { asprintf(&cmd, "AT+CCFC=%d,%d", callForwardInfo->reason, callForwardInfo->status); } else { @@ -460,12 +460,12 @@ void requestSetCallForward(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: free(cmd); at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -523,12 +523,12 @@ void requestQueryCallWaiting(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(int) * 2); - finally: +finally: free(cmd); at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -554,11 +554,11 @@ void requestSetCallWaiting(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: free(pCmd); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -590,10 +590,10 @@ void requestSetSuppSvcNotification(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } diff --git a/u300-ril-sim.c b/u300-ril-sim.c index 80d3ba5..76a7d34 100644 --- a/u300-ril-sim.c +++ b/u300-ril-sim.c @@ -89,11 +89,11 @@ static void resetSim(void *param) pollSIMState(NULL); } - finally: +finally: at_response_free(atresponse); return; - error: +error: goto finally; } @@ -124,11 +124,11 @@ void onSimStateChanged(const char *s) if (state == 7) enqueueRILEvent(RIL_EVENT_QUEUE_PRIO, resetSim, NULL, NULL); - finally: +finally: free(tok); return; - error: +error: LOGE("ERROR in onSimStateChanged!"); goto finally; } @@ -207,7 +207,7 @@ static SIM_Status getSIMStatus() ret = SIM_READY; - done: +done: at_response_free(atresponse); return ret; } @@ -218,40 +218,56 @@ static SIM_Status getSIMStatus() * This must be freed using freeCardStatus. * @return: On success returns RIL_E_SUCCESS. */ -static int getCardStatus(RIL_CardStatus ** pp_card_status) +static int getCardStatus(RIL_CardStatus **pp_card_status) { static RIL_AppStatus app_status_array[] = { /* SIM_ABSENT = 0 */ - {RIL_APPTYPE_UNKNOWN, RIL_APPSTATE_UNKNOWN, - RIL_PERSOSUBSTATE_UNKNOWN, - NULL, NULL, 0, RIL_PINSTATE_UNKNOWN, RIL_PINSTATE_UNKNOWN}, + { + RIL_APPTYPE_UNKNOWN, RIL_APPSTATE_UNKNOWN, + RIL_PERSOSUBSTATE_UNKNOWN, + NULL, NULL, 0, RIL_PINSTATE_UNKNOWN, RIL_PINSTATE_UNKNOWN + }, /* SIM_NOT_READY = 1 */ - {RIL_APPTYPE_SIM, RIL_APPSTATE_DETECTED, RIL_PERSOSUBSTATE_UNKNOWN, - NULL, NULL, 0, RIL_PINSTATE_UNKNOWN, RIL_PINSTATE_UNKNOWN}, + { + RIL_APPTYPE_SIM, RIL_APPSTATE_DETECTED, RIL_PERSOSUBSTATE_UNKNOWN, + NULL, NULL, 0, RIL_PINSTATE_UNKNOWN, RIL_PINSTATE_UNKNOWN + }, /* SIM_READY = 2 */ - {RIL_APPTYPE_SIM, RIL_APPSTATE_READY, RIL_PERSOSUBSTATE_READY, - NULL, NULL, 0, RIL_PINSTATE_UNKNOWN, RIL_PINSTATE_UNKNOWN}, + { + RIL_APPTYPE_SIM, RIL_APPSTATE_READY, RIL_PERSOSUBSTATE_READY, + NULL, NULL, 0, RIL_PINSTATE_UNKNOWN, RIL_PINSTATE_UNKNOWN + }, /* SIM_PIN = 3 */ - {RIL_APPTYPE_SIM, RIL_APPSTATE_PIN, RIL_PERSOSUBSTATE_UNKNOWN, - NULL, NULL, 0, RIL_PINSTATE_ENABLED_NOT_VERIFIED, - RIL_PINSTATE_UNKNOWN}, + { + RIL_APPTYPE_SIM, RIL_APPSTATE_PIN, RIL_PERSOSUBSTATE_UNKNOWN, + NULL, NULL, 0, RIL_PINSTATE_ENABLED_NOT_VERIFIED, + RIL_PINSTATE_UNKNOWN + }, /* SIM_PUK = 4 */ - {RIL_APPTYPE_SIM, RIL_APPSTATE_PUK, RIL_PERSOSUBSTATE_UNKNOWN, - NULL, NULL, 0, RIL_PINSTATE_ENABLED_BLOCKED, - RIL_PINSTATE_UNKNOWN}, + { + RIL_APPTYPE_SIM, RIL_APPSTATE_PUK, RIL_PERSOSUBSTATE_UNKNOWN, + NULL, NULL, 0, RIL_PINSTATE_ENABLED_BLOCKED, + RIL_PINSTATE_UNKNOWN + }, /* SIM_NETWORK_PERSONALIZATION = 5 */ - {RIL_APPTYPE_SIM, RIL_APPSTATE_SUBSCRIPTION_PERSO, - RIL_PERSOSUBSTATE_SIM_NETWORK, - NULL, NULL, 0, RIL_PINSTATE_ENABLED_NOT_VERIFIED, - RIL_PINSTATE_UNKNOWN}, + { + RIL_APPTYPE_SIM, RIL_APPSTATE_SUBSCRIPTION_PERSO, + RIL_PERSOSUBSTATE_SIM_NETWORK, + NULL, NULL, 0, RIL_PINSTATE_ENABLED_NOT_VERIFIED, + RIL_PINSTATE_UNKNOWN + }, /* SIM_PIN2 = 6 */ - {RIL_APPTYPE_SIM, RIL_APPSTATE_READY, RIL_PERSOSUBSTATE_UNKNOWN, - NULL, NULL, 0, RIL_PINSTATE_UNKNOWN, - RIL_PINSTATE_ENABLED_NOT_VERIFIED}, + { + RIL_APPTYPE_SIM, RIL_APPSTATE_READY, RIL_PERSOSUBSTATE_UNKNOWN, + NULL, NULL, 0, RIL_PINSTATE_UNKNOWN, + RIL_PINSTATE_ENABLED_NOT_VERIFIED + }, /* SIM_PUK2 = 7 */ - {RIL_APPTYPE_SIM, RIL_APPSTATE_READY, RIL_PERSOSUBSTATE_UNKNOWN, - NULL, NULL, 0, RIL_PINSTATE_UNKNOWN, - RIL_PINSTATE_ENABLED_BLOCKED} + { + RIL_APPTYPE_SIM, RIL_APPSTATE_READY, RIL_PERSOSUBSTATE_UNKNOWN, + NULL, NULL, 0, RIL_PINSTATE_UNKNOWN, + RIL_PINSTATE_ENABLED_BLOCKED + } }; RIL_CardState card_state; int num_apps; @@ -310,8 +326,8 @@ static void freeCardStatus(RIL_CardStatus * p_card_status) void pollSIMState(void *param) { if (((int) param) != 1 && - currentState() != RADIO_STATE_SIM_NOT_READY && - currentState() != RADIO_STATE_SIM_LOCKED_OR_ABSENT) + currentState() != RADIO_STATE_SIM_NOT_READY && + currentState() != RADIO_STATE_SIM_LOCKED_OR_ABSENT) /* No longer valid to poll. */ return; @@ -340,7 +356,8 @@ void pollSIMState(void *param) /** * Get the number of retries left for pin functions */ -static int getNumRetries (int request) { +static int getNumRetries(int request) +{ ATResponse *atresponse = NULL; int err = 0; char *cmd = NULL; @@ -377,11 +394,11 @@ static int getNumRetries (int request) { line = atresponse->p_intermediates->line; sscanf(line, "*EPINR: %d", &num_retries); - finally: +finally: at_response_free(atresponse); return num_retries; - error: +error: LOGE("ERROR in getNumRetries()"); goto finally; } @@ -404,12 +421,12 @@ void requestGetSimStatus(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, (char *) p_card_status, sizeof(*p_card_status)); - finally: +finally: if (p_card_status != NULL) freeCardStatus(p_card_status); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -474,12 +491,12 @@ void requestSIM_IO(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, &sr, sizeof(sr)); - finally: +finally: at_response_free(atresponse); free(cmd); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -527,10 +544,10 @@ void requestEnterSimPin(void *data, size_t datalen, RIL_Token t, int request) RIL_onRequestComplete(t, RIL_E_SUCCESS, &num_retries, sizeof(int *)); } - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -570,11 +587,11 @@ void requestChangePassword(char *facility, void *data, size_t datalen, RIL_onRequestComplete(t, RIL_E_SUCCESS, &num_retries, sizeof(int *)); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -637,7 +654,7 @@ void requestSetFacilityLock(void *data, size_t datalen, RIL_Token t) if (err < 0){ goto error; } - if (atresponse->success == 0){ + if (atresponse->success == 0) { switch (at_get_cme_error(atresponse)) { case 11: /* CME ERROR 11: "SIM PIN required" happens when PIN is wrong */ @@ -676,7 +693,7 @@ void requestSetFacilityLock(void *data, size_t datalen, RIL_Token t) at_response_free(atresponse); return; - error: +error: at_response_free(atresponse); RIL_onRequestComplete(t, errorril, &num_retries, sizeof(int *)); } @@ -724,11 +741,11 @@ void requestQueryFacilityLock(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, &response, sizeof(int)); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } diff --git a/u300-ril-stk.c b/u300-ril-stk.c index 066d5e7..6ab391e 100644 --- a/u300-ril-stk.c +++ b/u300-ril-stk.c @@ -51,12 +51,12 @@ void requestStkSendTerminalResponse(void *data, size_t datalen, RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -99,12 +99,12 @@ void requestStkSendEnvelopeCommand(void *data, size_t datalen, RIL_Token t) } else RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -144,12 +144,12 @@ void requestStkGetProfile(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(char *)); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -178,12 +178,12 @@ void requestStkIsRunning(void *data, size_t datalen, RIL_Token t) invalid RIL response" */ RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -210,12 +210,12 @@ void requestStkSetProfile(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -262,7 +262,7 @@ void onStkProactiveCommand(const char *s) RIL_onUnsolicitedResponse(RIL_UNSOL_STK_PROACTIVE_COMMAND, str, sizeof(char *)); - error: +error: free(line); } @@ -286,6 +286,6 @@ void onStkEventNotify(const char *s) RIL_onUnsolicitedResponse(RIL_UNSOL_STK_EVENT_NOTIFY, str, sizeof(char *)); - error: +error: free(line); } @@ -68,10 +68,10 @@ #define EMERGENCY_LIST "ro.ril.ecclist" -#define timespec_cmp(a, b, op) \ - ((a).tv_sec == (b).tv_sec \ - ? (a).tv_nsec op(b).tv_nsec \ - : (a).tv_sec op(b).tv_sec) +#define timespec_cmp(a, b, op) \ + ((a).tv_sec == (b).tv_sec \ + ? (a).tv_nsec op(b).tv_nsec \ + : (a).tv_sec op(b).tv_sec) /*** Declarations ***/ static void onRequest(int request, void *data, size_t datalen, @@ -111,7 +111,7 @@ typedef struct RILRequest { } RILRequest; typedef struct RILEvent { - void (*eventCallback) (void *param); + void (*eventCallback)(void *param); void *param; struct timespec abstime; struct RILEvent *next; @@ -162,7 +162,7 @@ int restrictedState = RIL_RESTRICTED_STATE_NONE; * 0 = the "normal" queue, 1 = prio queue and 2 = both. If only one queue * is present, then the event will be inserted into that queue. */ -void enqueueRILEvent(int isPrio, void (*callback) (void *param), +void enqueueRILEvent(int isPrio, void (*callback)(void *param), void *param, const struct timeval *relativeTime) { struct timeval tv; @@ -192,13 +192,13 @@ void enqueueRILEvent(int isPrio, void (*callback) (void *param), } if (!s_requestQueuePrio.enabled || - (isPrio == RIL_EVENT_QUEUE_NORMAL - || isPrio == RIL_EVENT_QUEUE_ALL)) + (isPrio == RIL_EVENT_QUEUE_NORMAL + || isPrio == RIL_EVENT_QUEUE_ALL)) q = &s_requestQueue; else if (isPrio == RIL_EVENT_QUEUE_PRIO) q = &s_requestQueuePrio; - again: +again: pthread_mutex_lock(&q->queueMutex); if (q->eventList == NULL) q->eventList = e; @@ -230,7 +230,7 @@ void enqueueRILEvent(int isPrio, void (*callback) (void *param), pthread_mutex_unlock(&q->queueMutex); if (s_requestQueuePrio.enabled && isPrio == RIL_EVENT_QUEUE_ALL - && !done) { + && !done) { RILEvent *e2 = malloc(sizeof(RILEvent)); memcpy(e2, e, sizeof(RILEvent)); e = e2; @@ -403,11 +403,11 @@ static void requestDeviceIdentity(void *data, size_t datalen, RIL_Token t) free(response[1]); /* Do not free empty strings */ - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -484,10 +484,10 @@ static void requestRadioPower(void *data, size_t datalen, RIL_Token t) } RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -562,11 +562,11 @@ static void requestScreenState(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: pthread_mutex_unlock(&s_screen_state_mutex); return; - error: +error: LOGE("ERROR: requestScreenState failed"); if (t != (RIL_Token) 0) RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); @@ -589,7 +589,7 @@ static void requestBasebandVersion(void *data, size_t datalen, RIL_Token t) err = at_send_command_singleline("AT+CGMR", "\0", &atresponse); if (err < 0 || - atresponse->success == 0 || atresponse->p_intermediates == NULL) + atresponse->success == 0 || atresponse->p_intermediates == NULL) goto error; line = atresponse->p_intermediates->line; @@ -600,16 +600,16 @@ static void requestBasebandVersion(void *data, size_t datalen, RIL_Token t) /* be checked here. */ /* Todo: Until Android implements limit handling on the string we need */ /* to have a workaround in the RIL to chop the string. */ - if (strlen(line)>90) - *(line+90) = '\0'; + if (strlen(line) > 90) + *(line + 90) = '\0'; RIL_onRequestComplete(t, RIL_E_SUCCESS, line, sizeof(char *)); - finally: +finally: at_response_free(atresponse); return; - error: +error: LOGE("Error in requestBasebandVersion()"); RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; @@ -637,11 +637,11 @@ static void requestSetTtyMode(void *data, size_t datalen, RIL_Token t) RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); - finally: +finally: at_response_free(atresponse); return; - error: +error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); goto finally; } @@ -698,7 +698,7 @@ static void processRequest(int request, void *data, size_t datalen, * This is according to reference RIL implementation. * Note that returning RIL_E_RADIO_NOT_AVAILABLE for all ignored requests * causes Android Telephony to enter state RADIO_NOT_AVAILABLE and block - * all communication with the RIL. + * all communication with the RIL. */ if (sState == RADIO_STATE_OFF && !(request == RIL_REQUEST_RADIO_POWER || @@ -1120,12 +1120,11 @@ static const char *getVersion(void) return RIL_VERSION_STRING; } -const char * radioStateToString(RIL_RadioState radioState) +const char *radioStateToString(RIL_RadioState radioState) { const char *state; - switch (radioState) - { + switch (radioState) { case RADIO_STATE_OFF: state = "RADIO_STATE_OFF"; break; @@ -1157,6 +1156,7 @@ const char * radioStateToString(RIL_RadioState radioState) state = "RADIO_STATE_<> Unknown!"; break; } + return state; } @@ -1226,7 +1226,7 @@ static int isRadioOn() return ret; - error: +error: at_response_free(atresponse); return -1; } @@ -1325,7 +1325,7 @@ static char initializeCommon(void) goto error; return 0; - error: +error: return 1; } @@ -1399,15 +1399,16 @@ static char initializeChannel() * absent, these numbers also has to be added: 000, 08, 110, 999, 118 * and 119. */ - err = property_set(EMERGENCY_LIST,"911,112,000,08,110,999,118,119"); - if(err < 0) + err = property_set(EMERGENCY_LIST, "911,112,000,08,110,999,118,119"); + + if (err < 0) LOGE("Creating emergency list ro.ril.ecclist in system properties failed!"); else LOGE("Adding 911, 112, 000, 08, 110, 999, 118 and 119 to system property ro.ril.ecclist"); return 0; - error: +error: return 1; } @@ -1443,13 +1444,12 @@ static void onUnsolicited(const char *s, const char *sms_pdu) RIL_onUnsolicitedResponse(RIL_UNSOL_CALL_RING, NULL, 0); else if (strStartsWith(s, "NO CARRIER") || strStartsWith(s, "+CCWA") - || strStartsWith(s, "BUSY")){ - if(strStartsWith(s, "+CCWA")) + || strStartsWith(s, "BUSY")) { + if (strStartsWith(s, "+CCWA")) onCCWAReceived(s); RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, NULL, 0); - } - else if (strStartsWith(s, "*EREG:") + } else if (strStartsWith(s, "*EREG:") || strStartsWith(s, "+CGREG:") || strStartsWith(s, "*EPSB:")) RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED, |