X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=libril%2Fril.cpp;h=08035636187b87553eede3eda6faad7b5be9fdb8;hb=ab379831bc;hp=750358ba5bd16aec095f3a073d156853e4dac8e2;hpb=f1190e330665ca1572287e9325fdb7040c8ee03a;p=android-x86%2Fhardware-ril.git diff --git a/libril/ril.cpp b/libril/ril.cpp old mode 100755 new mode 100644 index 750358b..0803563 --- a/libril/ril.cpp +++ b/libril/ril.cpp @@ -282,6 +282,7 @@ static void dispatchUiccSubscripton(Parcel &p, RequestInfo *pRI); static void dispatchSimAuthentication(Parcel &p, RequestInfo *pRI); static void dispatchDataProfile(Parcel &p, RequestInfo *pRI); static void dispatchRadioCapability(Parcel &p, RequestInfo *pRI); +static void dispatchCarrierRestrictions(Parcel &p, RequestInfo *pRI); static int responseInts(Parcel &p, void *response, size_t responselen); static int responseFailCause(Parcel &p, void *response, size_t responselen); static int responseStrings(Parcel &p, void *response, size_t responselen); @@ -314,6 +315,8 @@ static int responseSSData(Parcel &p, void *response, size_t responselen); static int responseLceStatus(Parcel &p, void *response, size_t responselen); static int responseLceData(Parcel &p, void *response, size_t responselen); static int responseActivityData(Parcel &p, void *response, size_t responselen); +static int responseCarrierRestrictions(Parcel &p, void *response, size_t responselen); +static int responsePcoData(Parcel &p, void *response, size_t responselen); static int decodeVoiceRadioTechnology (RIL_RadioState radioState); static int decodeCdmaSubscriptionSource (RIL_RadioState radioState); @@ -533,6 +536,13 @@ processCommandBuffer(void *buffer, size_t buflen, RIL_SOCKET_ID socket_id) { return 0; } + // Received an Ack for the previous result sent to RIL.java, + // so release wakelock and exit + if (request == RIL_RESPONSE_ACKNOWLEDGEMENT) { + releaseWakeLock(); + return 0; + } + if (request < 1 || request >= (int32_t)NUM_ELEMS(s_commands)) { Parcel pErr; RLOGE("unsupported request code %d token %d", request, token); @@ -545,14 +555,6 @@ processCommandBuffer(void *buffer, size_t buflen, RIL_SOCKET_ID socket_id) { return 0; } - // Received an Ack for the previous result sent to RIL.java, - // so release wakelock and exit - if (request == RIL_RESPONSE_ACKNOWLEDGEMENT) { - releaseWakeLock(); - return 0; - } - - pRI = (RequestInfo *)calloc(1, sizeof(RequestInfo)); if (pRI == NULL) { RLOGE("Memory allocation failed for request %s", requestToString(request)); @@ -1330,7 +1332,7 @@ dispatchImsGsmSms(Parcel &p, RequestInfo *pRI, uint8_t retry, int32_t messageRef pStrings = NULL; datalen = 0; } else { - if (countStrings > (INT_MAX/sizeof(char *))) { + if ((size_t)countStrings > (INT_MAX/sizeof(char *))) { RLOGE("Invalid value of countStrings: \n"); closeRequest; return; @@ -2136,6 +2138,105 @@ invalid: return; } +/** + * Callee expects const RIL_CarrierRestrictions * + */ +static void dispatchCarrierRestrictions(Parcel &p, RequestInfo *pRI) { + RIL_CarrierRestrictions cr; + RIL_Carrier * allowed_carriers = NULL; + RIL_Carrier * excluded_carriers = NULL; + int32_t t; + status_t status; + + memset(&cr, 0, sizeof(RIL_CarrierRestrictions)); + + if (s_callbacks.version < 14) { + RLOGE("Unsuppoted RIL version %d, min version expected %d", + s_callbacks.version, 14); + RIL_onRequestComplete(pRI, RIL_E_REQUEST_NOT_SUPPORTED, NULL, 0); + return; + } + + status = p.readInt32(&t); + if (status != NO_ERROR) { + goto invalid; + } + allowed_carriers = (RIL_Carrier *)calloc(t, sizeof(RIL_Carrier)); + if (allowed_carriers == NULL) { + RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber)); + goto exit; + } + cr.len_allowed_carriers = t; + cr.allowed_carriers = allowed_carriers; + + status = p.readInt32(&t); + if (status != NO_ERROR) { + goto invalid; + } + excluded_carriers = (RIL_Carrier *)calloc(t, sizeof(RIL_Carrier)); + if (excluded_carriers == NULL) { + RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber)); + goto exit; + } + cr.len_excluded_carriers = t; + cr.excluded_carriers = excluded_carriers; + + startRequest; + appendPrintBuf("%s len_allowed_carriers:%d, len_excluded_carriers:%d,", + printBuf, cr.len_allowed_carriers, cr.len_excluded_carriers); + + appendPrintBuf("%s allowed_carriers:", printBuf); + for (int32_t i = 0; i < cr.len_allowed_carriers; i++) { + RIL_Carrier *p_cr = allowed_carriers + i; + p_cr->mcc = strdupReadString(p); + p_cr->mnc = strdupReadString(p); + status = p.readInt32(&t); + p_cr->match_type = static_cast(t); + if (status != NO_ERROR) { + goto invalid; + } + p_cr->match_data = strdupReadString(p); + appendPrintBuf("%s [%d mcc:%s, mnc:%s, match_type:%d, match_data:%s],", + printBuf, i, p_cr->mcc, p_cr->mnc, p_cr->match_type, p_cr->match_data); + } + + for (int32_t i = 0; i < cr.len_excluded_carriers; i++) { + RIL_Carrier *p_cr = excluded_carriers + i; + p_cr->mcc = strdupReadString(p); + p_cr->mnc = strdupReadString(p); + status = p.readInt32(&t); + p_cr->match_type = static_cast(t); + if (status != NO_ERROR) { + goto invalid; + } + p_cr->match_data = strdupReadString(p); + appendPrintBuf("%s [%d mcc:%s, mnc:%s, match_type:%d, match_data:%s],", + printBuf, i, p_cr->mcc, p_cr->mnc, p_cr->match_type, p_cr->match_data); + } + + closeRequest; + printRequest(pRI->token, pRI->pCI->requestNumber); + + CALL_ONREQUEST(pRI->pCI->requestNumber, + &cr, + sizeof(RIL_CarrierRestrictions), + pRI, pRI->socket_id); + + goto exit; + +invalid: + invalidCommandBlock(pRI); + RIL_onRequestComplete(pRI, RIL_E_INVALID_ARGUMENTS, NULL, 0); +exit: + if (allowed_carriers != NULL) { + free(allowed_carriers); + } + if (excluded_carriers != NULL) { + free(excluded_carriers); + } + return; +} + static int blockingWrite(int fd, const void *buffer, size_t len) { size_t writeOffset = 0; @@ -3070,9 +3171,10 @@ static int responseRilSignalStrength(Parcel &p, return RIL_ERRNO_INVALID_RESPONSE; } + RIL_SignalStrength_v10 *p_cur; if (s_callbacks.version <= LAST_IMPRECISE_RIL_VERSION) { if (responselen >= sizeof (RIL_SignalStrength_v5)) { - RIL_SignalStrength_v10 *p_cur = ((RIL_SignalStrength_v10 *) response); + p_cur = ((RIL_SignalStrength_v10 *) response); responseRilSignalStrengthV5(p, p_cur); @@ -3104,7 +3206,7 @@ static int responseRilSignalStrength(Parcel &p, assert(0); } } - RIL_SignalStrength_v10 *p_cur = ((RIL_SignalStrength_v10 *) response); + p_cur = ((RIL_SignalStrength_v10 *) response); responseRilSignalStrengthV10(p, p_cur); } startResponse; @@ -3883,8 +3985,8 @@ static int responseLceStatus(Parcel &p, void *response, size_t responselen) { RLOGE("invalid response: NULL"); } else { - RLOGE("responseLceStatus: invalid response length %d expecting len: d%", - sizeof(RIL_LceStatusInfo), responselen); + RLOGE("responseLceStatus: invalid response length %u expecting len: %u", + (unsigned)sizeof(RIL_LceStatusInfo), (unsigned)responselen); } return RIL_ERRNO_INVALID_RESPONSE; } @@ -3907,8 +4009,8 @@ static int responseLceData(Parcel &p, void *response, size_t responselen) { RLOGE("invalid response: NULL"); } else { - RLOGE("responseLceData: invalid response length %d expecting len: d%", - sizeof(RIL_LceDataInfo), responselen); + RLOGE("responseLceData: invalid response length %u expecting len: %u", + (unsigned)sizeof(RIL_LceDataInfo), (unsigned)responselen); } return RIL_ERRNO_INVALID_RESPONSE; } @@ -3936,8 +4038,8 @@ static int responseActivityData(Parcel &p, void *response, size_t responselen) { RLOGE("invalid response: NULL"); } else { - RLOGE("responseActivityData: invalid response length %d expecting len: d%", - sizeof(RIL_ActivityStatsInfo), responselen); + RLOGE("responseActivityData: invalid response length %u expecting len: %u", + (unsigned)sizeof(RIL_ActivityStatsInfo), (unsigned)responselen); } return RIL_ERRNO_INVALID_RESPONSE; } @@ -3961,6 +4063,78 @@ static int responseActivityData(Parcel &p, void *response, size_t responselen) { return 0; } +static int responseCarrierRestrictions(Parcel &p, void *response, size_t responselen) { + if (response == NULL) { + RLOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + if (responselen != sizeof(RIL_CarrierRestrictions)) { + RLOGE("responseCarrierRestrictions: invalid response length %u expecting len: %u", + (unsigned)responselen, (unsigned)sizeof(RIL_CarrierRestrictions)); + return RIL_ERRNO_INVALID_RESPONSE; + } + + RIL_CarrierRestrictions *p_cr = (RIL_CarrierRestrictions *)response; + startResponse; + + p.writeInt32(p_cr->len_allowed_carriers); + p.writeInt32(p_cr->len_excluded_carriers); + appendPrintBuf(" %s len_allowed_carriers: %d, len_excluded_carriers: %d,", printBuf, + p_cr->len_allowed_carriers,p_cr->len_excluded_carriers); + + appendPrintBuf(" %s allowed_carriers:", printBuf); + for(int32_t i = 0; i < p_cr->len_allowed_carriers; i++) { + RIL_Carrier *carrier = p_cr->allowed_carriers + i; + writeStringToParcel(p, carrier->mcc); + writeStringToParcel(p, carrier->mnc); + p.writeInt32(carrier->match_type); + writeStringToParcel(p, carrier->match_data); + appendPrintBuf(" %s [%d mcc: %s, mnc: %s, match_type: %d, match_data: %s],", printBuf, + i, carrier->mcc, carrier->mnc, carrier->match_type, carrier->match_data); + } + + appendPrintBuf(" %s excluded_carriers:", printBuf); + for(int32_t i = 0; i < p_cr->len_excluded_carriers; i++) { + RIL_Carrier *carrier = p_cr->excluded_carriers + i; + writeStringToParcel(p, carrier->mcc); + writeStringToParcel(p, carrier->mnc); + p.writeInt32(carrier->match_type); + writeStringToParcel(p, carrier->match_data); + appendPrintBuf(" %s [%d mcc: %s, mnc: %s, match_type: %d, match_data: %s],", printBuf, + i, carrier->mcc, carrier->mnc, carrier->match_type, carrier->match_data); + } + + closeResponse; + + return 0; +} + +static int responsePcoData(Parcel &p, void *response, size_t responselen) { + if (response == NULL) { + RLOGE("responsePcoData: invalid NULL response"); + return RIL_ERRNO_INVALID_RESPONSE; + } + if (responselen != sizeof(RIL_PCO_Data)) { + RLOGE("responsePcoData: invalid response length %u, expecting %u", + (unsigned)responselen, (unsigned)sizeof(RIL_PCO_Data)); + return RIL_ERRNO_INVALID_RESPONSE; + } + + RIL_PCO_Data *p_cur = (RIL_PCO_Data *)response; + p.writeInt32(p_cur->cid); + writeStringToParcel(p, p_cur->bearer_proto); + p.writeInt32(p_cur->pco_id); + p.writeInt32(p_cur->contents_length); + p.write(p_cur->contents, p_cur->contents_length); + + startResponse; + appendPrintBuf("PCO data received: cid %d, id %d, length %d", + p_cur->cid, p_cur->pco_id, p_cur->contents_length); + closeResponse; + + return 0; +} + /** * A write on the wakeup fd is done just to pop us out of select() * We empty the buffer here and then ril_event will reset the timers on the @@ -4107,7 +4281,7 @@ static void listenCallback (int fd, short flags, void *param) { int err; int is_phone_socket; int fdCommand = -1; - char* processName; + const char* processName; RecordStream *p_rs; MySocketListenParam* listenParam; RilSocket *sapSocket = NULL; @@ -4245,12 +4419,12 @@ static void debugCallback (int fd, short flags, void *param) { int data; unsigned int qxdm_data[6]; const char *deactData[1] = {"1"}; - char *actData[1]; RIL_Dial dialData; int hangupData[1] = {1}; int number; char **args; RIL_SOCKET_ID socket_id = RIL_SOCKET_1; + int MAX_DIAL_ADDRESS = 128; int sim_id = 0; RLOGI("debugCallback for socket %s", rilSocketIdToString(socket_id)); @@ -4397,12 +4571,6 @@ static void debugCallback (int fd, short flags, void *param) { // Set network selection automatic. issueLocalRequest(RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, NULL, 0, socket_id); break; - case 6: - RLOGI("Debug port: Setup Data Call, Apn :%s\n", args[1]); - actData[0] = args[1]; - issueLocalRequest(RIL_REQUEST_SETUP_DATA_CALL, &actData, - sizeof(actData), socket_id); - break; case 7: RLOGI("Debug port: Deactivate Data Call"); issueLocalRequest(RIL_REQUEST_DEACTIVATE_DATA_CALL, &deactData, @@ -4411,6 +4579,12 @@ static void debugCallback (int fd, short flags, void *param) { case 8: RLOGI("Debug port: Dial Call"); dialData.clir = 0; + if (strlen(args[1]) > MAX_DIAL_ADDRESS) { + RLOGE("Debug port: Error calling Dial"); + freeDebugCallbackArgs(number, args); + close(acceptFD); + return; + } dialData.address = args[1]; issueLocalRequest(RIL_REQUEST_DIAL, &dialData, sizeof(dialData), socket_id); break; @@ -4609,7 +4783,8 @@ RIL_register (const RIL_RadioFunctions *callbacks) { &s_commands_event, /* commands_event */ &s_listen_event, /* listen_event */ processCommandsCallback, /* processCommandsCallback */ - NULL /* p_rs */ + NULL, /* p_rs */ + RIL_TELEPHONY_SOCKET /* type */ }; #if (SIM_COUNT >= 2) @@ -4621,7 +4796,8 @@ RIL_register (const RIL_RadioFunctions *callbacks) { &s_commands_event_socket2, /* commands_event */ &s_listen_event_socket2, /* listen_event */ processCommandsCallback, /* processCommandsCallback */ - NULL /* p_rs */ + NULL, /* p_rs */ + RIL_TELEPHONY_SOCKET /* type */ }; #endif @@ -4634,7 +4810,8 @@ RIL_register (const RIL_RadioFunctions *callbacks) { &s_commands_event_socket3, /* commands_event */ &s_listen_event_socket3, /* listen_event */ processCommandsCallback, /* processCommandsCallback */ - NULL /* p_rs */ + NULL, /* p_rs */ + RIL_TELEPHONY_SOCKET /* type */ }; #endif @@ -4647,7 +4824,8 @@ RIL_register (const RIL_RadioFunctions *callbacks) { &s_commands_event_socket4, /* commands_event */ &s_listen_event_socket4, /* listen_event */ processCommandsCallback, /* processCommandsCallback */ - NULL /* p_rs */ + NULL, /* p_rs */ + RIL_TELEPHONY_SOCKET /* type */ }; #endif @@ -4750,6 +4928,8 @@ RIL_register_socket (RIL_RadioFunctions *(*Init)(const struct RIL_Env *, int, ch #if (SIM_COUNT >= 4) RilSapSocket::initSapSocket("sap_uim_socket4", UimFuncs); #endif + break; + default:; } } } @@ -5376,6 +5556,21 @@ failCauseToString(RIL_Errno e) { case RIL_E_NO_SMS_TO_ACK: return "E_NO_SMS_TO_ACK"; case RIL_E_NETWORK_ERR: return "E_NETWORK_ERR"; case RIL_E_REQUEST_RATE_LIMITED: return "E_REQUEST_RATE_LIMITED"; + case RIL_E_SIM_BUSY: return "E_SIM_BUSY"; + case RIL_E_SIM_FULL: return "E_SIM_FULL"; + case RIL_E_NETWORK_REJECT: return "E_NETWORK_REJECT"; + case RIL_E_OPERATION_NOT_ALLOWED: return "E_OPERATION_NOT_ALLOWED"; + case RIL_E_EMPTY_RECORD: "E_EMPTY_RECORD"; + case RIL_E_INVALID_SMS_FORMAT: return "E_INVALID_SMS_FORMAT"; + case RIL_E_ENCODING_ERR: return "E_ENCODING_ERR"; + case RIL_E_INVALID_SMSC_ADDRESS: return "E_INVALID_SMSC_ADDRESS"; + case RIL_E_NO_SUCH_ENTRY: return "E_NO_SUCH_ENTRY"; + case RIL_E_NETWORK_NOT_READY: return "E_NETWORK_NOT_READY"; + case RIL_E_NOT_PROVISIONED: return "E_NOT_PROVISIONED"; + case RIL_E_NO_SUBSCRIPTION: return "E_NO_SUBSCRIPTION"; + case RIL_E_NO_NETWORK_FOUND: return "E_NO_NETWORK_FOUND"; + case RIL_E_DEVICE_IN_USE: return "E_DEVICE_IN_USE"; + case RIL_E_ABORTED: return "E_ABORTED"; case RIL_E_OEM_ERROR_1: return "E_OEM_ERROR_1"; case RIL_E_OEM_ERROR_2: return "E_OEM_ERROR_2"; case RIL_E_OEM_ERROR_3: return "E_OEM_ERROR_3"; @@ -5510,6 +5705,7 @@ requestToString(int request) { case RIL_REQUEST_QUERY_CLIP: return "QUERY_CLIP"; case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE"; case RIL_REQUEST_DATA_CALL_LIST: return "DATA_CALL_LIST"; + case RIL_REQUEST_NV_RESET_CONFIG: return "NV_RESET_CONFIG"; case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO"; case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW"; case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS"; @@ -5573,6 +5769,8 @@ requestToString(int request) { case RIL_REQUEST_GET_DC_RT_INFO: return "GET_DC_RT_INFO"; case RIL_REQUEST_SET_DC_RT_INFO_RATE: return "SET_DC_RT_INFO_RATE"; case RIL_REQUEST_SET_DATA_PROFILE: return "SET_DATA_PROFILE"; + case RIL_REQUEST_SET_CARRIER_RESTRICTIONS: return "SET_CARRIER_RESTRICTIONS"; + case RIL_REQUEST_GET_CARRIER_RESTRICTIONS: return "GET_CARRIER_RESTRICTIONS"; case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED"; case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED"; case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED"; @@ -5618,6 +5816,7 @@ requestToString(int request) { case RIL_REQUEST_SHUTDOWN: return "SHUTDOWN"; case RIL_UNSOL_RADIO_CAPABILITY: return "RIL_UNSOL_RADIO_CAPABILITY"; case RIL_RESPONSE_ACKNOWLEDGEMENT: return "RIL_RESPONSE_ACKNOWLEDGEMENT"; + case RIL_UNSOL_PCO_DATA: return "RIL_UNSOL_PCO_DATA"; default: return ""; } }