diff options
-rw-r--r-- | include/telephony/ril.h | 312 | ||||
-rw-r--r-- | libril/Android.mk | 23 | ||||
-rw-r--r-- | libril/RilSapSocket.cpp | 4 | ||||
-rw-r--r-- | libril/ril.cpp | 14 | ||||
-rw-r--r-- | libril/ril_service.cpp | 85 | ||||
-rw-r--r-- | reference-ril/atchannel.c | 27 | ||||
-rw-r--r-- | reference-ril/misc.c | 11 | ||||
-rw-r--r-- | reference-ril/misc.h | 3 | ||||
-rw-r--r-- | reference-ril/reference-ril.c | 188 | ||||
-rw-r--r-- | rild/Android.mk | 11 | ||||
-rw-r--r-- | rild/rild.c | 52 | ||||
-rw-r--r-- | rild/rild.rc | 3 |
12 files changed, 531 insertions, 202 deletions
diff --git a/include/telephony/ril.h b/include/telephony/ril.h index 4f0dee0..12258bf 100644 --- a/include/telephony/ril.h +++ b/include/telephony/ril.h @@ -31,7 +31,7 @@ extern "C" { #endif - +#ifndef SIM_COUNT #if defined(ANDROID_SIM_COUNT_2) #define SIM_COUNT 2 #elif defined(ANDROID_SIM_COUNT_3) @@ -45,6 +45,7 @@ extern "C" { #ifndef ANDROID_MULTI_SIM #define SIM_COUNT 1 #endif +#endif /* * RIL version. @@ -357,7 +358,17 @@ typedef enum { PREF_NET_TYPE_LTE_GSM_WCDMA = 9, /* LTE, GSM/WCDMA */ PREF_NET_TYPE_LTE_CMDA_EVDO_GSM_WCDMA = 10, /* LTE, CDMA, EvDo, GSM/WCDMA */ PREF_NET_TYPE_LTE_ONLY = 11, /* LTE only */ - PREF_NET_TYPE_LTE_WCDMA = 12 /* LTE/WCDMA */ + PREF_NET_TYPE_LTE_WCDMA = 12, /* LTE/WCDMA */ + PREF_NET_TYPE_TD_SCDMA_ONLY = 13, /* TD-SCDMA only */ + PREF_NET_TYPE_TD_SCDMA_WCDMA = 14, /* TD-SCDMA and WCDMA */ + PREF_NET_TYPE_TD_SCDMA_LTE = 15, /* TD-SCDMA and LTE */ + PREF_NET_TYPE_TD_SCDMA_GSM = 16, /* TD-SCDMA and GSM */ + PREF_NET_TYPE_TD_SCDMA_GSM_LTE = 17, /* TD-SCDMA,GSM and LTE */ + PREF_NET_TYPE_TD_SCDMA_GSM_WCDMA = 18, /* TD-SCDMA, GSM/WCDMA */ + PREF_NET_TYPE_TD_SCDMA_WCDMA_LTE = 19, /* TD-SCDMA, WCDMA and LTE */ + PREF_NET_TYPE_TD_SCDMA_GSM_WCDMA_LTE = 20, /* TD-SCDMA, GSM/WCDMA and LTE */ + PREF_NET_TYPE_TD_SCDMA_GSM_WCDMA_CDMA_EVDO_AUTO = 21, /* TD-SCDMA, GSM/WCDMA, CDMA and EvDo */ + PREF_NET_TYPE_TD_SCDMA_LTE_CDMA_EVDO_GSM_WCDMA = 22 /* TD-SCDMA, LTE, CDMA, EvDo GSM/WCDMA */ } RIL_PreferredNetworkType; /* Source for cdma subscription */ @@ -1988,11 +1999,11 @@ typedef enum { typedef enum { RIL_DST_POWER_SAVE_MODE, // Device power save mode (provided by PowerManager) - // Non-zero value indicates the device is in power save mode. + // True indicates the device is in power save mode. RIL_DST_CHARGING_STATE, // Device charging state (provided by BatteryManager) - // Non-zero value indicates the device is charging. - RIL_DST_LOW_DATA_EXPECTED // Low data expected mode. Non-zero value indicates low data - // traffic is expected, for example, when the device is idle + // True indicates the device is charging. + RIL_DST_LOW_DATA_EXPECTED // Low data expected mode. True indicates low data traffic + // is expected, for example, when the device is idle // (e.g. not doing tethering in the background). Note // this doesn't mean no data is expected. } RIL_DeviceStateType; @@ -2632,6 +2643,12 @@ typedef struct { * Valid errors: * SUCCESS * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * MODEM_ERR + * NOT_PROVISIONED + * REQUEST_NOT_SUPPORTED */ #define RIL_REQUEST_SIGNAL_STRENGTH 19 @@ -2660,6 +2677,12 @@ typedef struct { * Valid errors: * SUCCESS * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * MODEM_ERR + * NOT_PROVISIONED + * REQUEST_NOT_SUPPORTED */ #define RIL_REQUEST_DATA_REGISTRATION_STATE 21 @@ -2681,6 +2704,10 @@ typedef struct { * Valid errors: * SUCCESS * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * REQUEST_NOT_SUPPORTED */ #define RIL_REQUEST_OPERATOR 22 @@ -2706,6 +2733,16 @@ typedef struct { * SUCCESS * RADIO_NOT_AVAILABLE * OPERATION_NOT_ALLOWED + * INVALID_STATE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * DEVICE_IN_USE + * OPERATION_NOT_ALLOWED + * INVALID_MODEM_STATE + * REQUEST_NOT_SUPPORTED */ #define RIL_REQUEST_RADIO_POWER 23 @@ -2890,7 +2927,8 @@ typedef struct { * * Other errors could include: * RADIO_NOT_AVAILABLE, OP_NOT_ALLOWED_BEFORE_REG_TO_NW, - * OP_NOT_ALLOWED_DURING_VOICE_CALL and REQUEST_NOT_SUPPORTED. + * OP_NOT_ALLOWED_DURING_VOICE_CALL and REQUEST_NOT_SUPPORTED, + * INVALID_ARGUMENTS * * See also: RIL_REQUEST_DEACTIVATE_DATA_CALL */ @@ -3185,6 +3223,12 @@ typedef struct { * Valid errors: * SUCCESS * RADIO_NOT_AVAILABLE (radio resetting) + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * MODEM_ERR + * NOT_PROVISIONED + * REQUEST_NOT_SUPPORTED */ #define RIL_REQUEST_GET_IMEI 38 @@ -3203,6 +3247,12 @@ typedef struct { * Valid errors: * SUCCESS * RADIO_NOT_AVAILABLE (radio resetting) + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * MODEM_ERR + * NOT_PROVISIONED + * REQUEST_NOT_SUPPORTED */ #define RIL_REQUEST_GET_IMEISV 39 @@ -3255,6 +3305,10 @@ typedef struct { * Valid errors: * SUCCESS * RADIO_NOT_AVAILABLE + * INVALID_CALL_ID + * INVALID_STATE + * INVALID_ARGUMENTS + * REQUEST_NOT_SUPPORTED * * See also: RIL_REQUEST_SETUP_DATA_CALL */ @@ -3379,6 +3433,12 @@ typedef struct { * Valid errors: * SUCCESS * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED * */ #define RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE 45 @@ -3399,6 +3459,12 @@ typedef struct { * RADIO_NOT_AVAILABLE * ILLEGAL_SIM_OR_ME * OPERATION_NOT_ALLOWED + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED * * Note: Returns ILLEGAL_SIM_OR_ME when the failure is permanent and * no retries needed, such as illegal SIM or ME. @@ -3422,6 +3488,13 @@ typedef struct { * RADIO_NOT_AVAILABLE * ILLEGAL_SIM_OR_ME * OPERATION_NOT_ALLOWED + * INVALID_STATE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED * * Note: Returns ILLEGAL_SIM_OR_ME when the failure is permanent and * no retries needed, such as illegal SIM or ME. @@ -3457,6 +3530,9 @@ typedef struct { * INTERNAL_ERR * NO_MEMORY * MODEM_ERR + * REQUEST_NOT_SUPPORTED + * CANCELLED + * OPERATION_NOT_ALLOWED * */ #define RIL_REQUEST_QUERY_AVAILABLE_NETWORKS 48 @@ -3526,6 +3602,12 @@ typedef struct { * SUCCESS * RADIO_NOT_AVAILABLE * EMPTY_RECORD + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * MODEM_ERR + * NOT_PROVISIONED + * REQUEST_NOT_SUPPORTED * */ #define RIL_REQUEST_BASEBAND_VERSION 51 @@ -3780,6 +3862,11 @@ typedef struct { * * Valid errors: * SUCCESS + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * REQUEST_NOT_SUPPORTED */ #define RIL_REQUEST_SCREEN_STATE 61 @@ -3876,6 +3963,12 @@ typedef struct { * SUCCESS * RADIO_NOT_AVAILABLE * OPERATION_NOT_ALLOWED + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED * * See also: RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE */ @@ -3895,6 +3988,11 @@ typedef struct { * Valid errors: * SUCCESS * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * MODEM_ERR + * REQUEST_NOT_SUPPORTED * * See also: RIL_REQUEST_SET_BAND_MODE */ @@ -4034,6 +4132,12 @@ typedef struct { * RADIO_NOT_AVAILABLE (radio resetting) * OPERATION_NOT_ALLOWED * MODE_NOT_SUPPORTED + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED */ #define RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE 73 @@ -4051,6 +4155,12 @@ typedef struct { * Valid errors: * SUCCESS * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED * * See also: RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE */ @@ -4067,6 +4177,12 @@ typedef struct { * Valid errors: * SUCCESS * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * MODEM_ERR + * NO_NETWORK_FOUND + * REQUEST_NOT_SUPPORTED */ #define RIL_REQUEST_GET_NEIGHBORING_CELL_IDS 75 @@ -4089,6 +4205,12 @@ typedef struct { * Valid errors: * SUCCESS * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED * * See also: RIL_REQUEST_SCREEN_STATE, RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED */ @@ -4130,6 +4252,13 @@ typedef struct { * Valid errors: * SUCCESS * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED + * OPERATION_NOT_ALLOWED */ #define RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE 78 @@ -4150,6 +4279,12 @@ typedef struct { * Valid errors: * SUCCESS * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED */ #define RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE 79 @@ -4322,6 +4457,12 @@ typedef struct { * Valid errors: * SUCCESS * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED * */ #define RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY 86 @@ -4559,6 +4700,14 @@ typedef struct { * Valid errors: * SUCCESS * RIL_E_SUBSCRIPTION_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * NOT_PROVISIONED + * REQUEST_NOT_SUPPORTED + * */ #define RIL_REQUEST_CDMA_SUBSCRIPTION 95 @@ -4638,6 +4787,14 @@ typedef struct { * Valid errors: * SUCCESS * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * NOT_PROVISIONED + * REQUEST_NOT_SUPPORTED + * */ #define RIL_REQUEST_DEVICE_IDENTITY 98 @@ -4656,6 +4813,12 @@ typedef struct { * SUCCESS * RADIO_NOT_AVAILABLE * OPERATION_NOT_ALLOWED + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED * */ #define RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE 99 @@ -4833,7 +4996,7 @@ typedef struct { * RIL_REQUEST_VOICE_RADIO_TECH * * Query the radio technology type (3GPP/3GPP2) used for voice. Query is valid only - * when radio state is RADIO_STATE_ON + * when radio state is not RADIO_STATE_UNAVAILABLE * * "data" is NULL * "response" is int * @@ -4856,6 +5019,17 @@ typedef struct { * "data" is NULL * * "response" is an array of RIL_CellInfo_v12. + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * MODEM_ERR + * NO_NETWORK_FOUND + * REQUEST_NOT_SUPPORTED + * */ #define RIL_REQUEST_GET_CELL_INFO_LIST 109 @@ -4875,6 +5049,11 @@ typedef struct { * Valid errors: * SUCCESS * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * REQUEST_NOT_SUPPORTED */ #define RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE 110 @@ -4902,6 +5081,14 @@ typedef struct { * SUCCESS * RADIO_NOT_AVAILABLE (radio resetting) * SUBSCRIPTION_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * NOT_PROVISIONED + * REQUEST_NOT_SUPPORTED + * */ #define RIL_REQUEST_SET_INITIAL_ATTACH_APN 111 @@ -5121,6 +5308,12 @@ typedef struct { * SUCCESS * RADIO_NOT_AVAILABLE (radio resetting) * SUBSCRIPTION_NOT_SUPPORTED + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED * */ #define RIL_REQUEST_SET_UICC_SUBSCRIPTION 122 @@ -5141,6 +5334,14 @@ typedef struct { * * SUCCESS * RADIO_NOT_AVAILABLE (radio resetting) + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * MODEM_ERR + * INVALID_ARGUMENTS + * DEVICE_IN_USE + * INVALID_MODEM_STATE + * REQUEST_NOT_SUPPORTED * */ #define RIL_REQUEST_ALLOW_DATA 123 @@ -5191,6 +5392,7 @@ typedef struct { * Valid errors: * SUCCESS * RADIO_NOT_AVAILABLE + * REQUEST_NOT_SUPPORTED * * See also: RIL_UNSOL_DC_RT_INFO_CHANGED */ @@ -5243,6 +5445,10 @@ typedef struct { * SUCCESS * RADIO_NOT_AVAILABLE * OPERATION_NOT_ALLOWED + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * REQUEST_NOT_SUPPORTED */ #define RIL_REQUEST_SHUTDOWN 129 @@ -5257,6 +5463,8 @@ typedef struct { * SUCCESS * RADIO_NOT_AVAILABLE * OPERATION_NOT_ALLOWED + * INVALID_STATE + * REQUEST_NOT_SUPPORTED */ #define RIL_REQUEST_GET_RADIO_CAPABILITY 130 @@ -5276,6 +5484,13 @@ typedef struct { * SUCCESS means a RIL_UNSOL_RADIO_CAPABILITY will be sent within 30 seconds. * RADIO_NOT_AVAILABLE * OPERATION_NOT_ALLOWED + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * INVALID_STATE + * REQUEST_NOT_SUPPORTED */ #define RIL_REQUEST_SET_RADIO_CAPABILITY 131 @@ -5294,6 +5509,8 @@ typedef struct { * SUCCESS * RADIO_NOT_AVAILABLE * LCE_NOT_SUPPORTED + * INTERNAL_ERR + * REQUEST_NOT_SUPPORTED */ #define RIL_REQUEST_START_LCE 132 @@ -5342,6 +5559,12 @@ typedef struct { * * SUCCESS * RADIO_NOT_AVAILABLE (radio resetting) + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * MODEM_ERR + * NOT_PROVISIONED + * REQUEST_NOT_SUPPORTED */ #define RIL_REQUEST_GET_ACTIVITY_INFO 135 @@ -5412,6 +5635,11 @@ typedef struct { * Valid errors: * SUCCESS * RADIO_NOT_AVAILABLE (radio resetting) + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * REQUEST_NOT_SUPPORTED */ #define RIL_REQUEST_SEND_DEVICE_STATE 138 @@ -5433,6 +5661,10 @@ typedef struct { * SUCCESS * INVALID_ARGUMENTS (e.g. the requested filter doesn't exist) * RADIO_NOT_AVAILABLE (radio resetting) + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * REQUEST_NOT_SUPPORTED */ #define RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER 139 @@ -6146,40 +6378,40 @@ typedef struct { */ #define RIL_UNSOL_LCEDATA_RECV 1045 -/** - * RIL_UNSOL_PCO_DATA - * - * Called when there is new Carrier PCO data received for a data call. Ideally - * only new data will be forwarded, though this is not required. Multiple - * boxes of carrier PCO data for a given call should result in a series of - * RIL_UNSOL_PCO_DATA calls. - * - * "data" is the RIL_PCO_Data structure. - * - */ + /** + * RIL_UNSOL_PCO_DATA + * + * Called when there is new Carrier PCO data received for a data call. Ideally + * only new data will be forwarded, though this is not required. Multiple + * boxes of carrier PCO data for a given call should result in a series of + * RIL_UNSOL_PCO_DATA calls. + * + * "data" is the RIL_PCO_Data structure. + * + */ #define RIL_UNSOL_PCO_DATA 1046 -/** - * RIL_UNSOL_MODEM_RESTART - * - * Called when there is a modem reset. - * - * "reason" is "const char *" containing the reason for the reset. It - * could be a crash signature if the restart was due to a crash or some - * string such as "user-initiated restart" or "AT command initiated - * restart" that explains the cause of the modem restart. - * - * When modem restarts, one of the following radio state transitions will happen - * 1) RADIO_STATE_ON->RADIO_STATE_UNAVAILABLE->RADIO_STATE_ON or - * 2) RADIO_STATE_OFF->RADIO_STATE_UNAVAILABLE->RADIO_STATE_OFF - * This message can be sent either just before the RADIO_STATE changes to RADIO_STATE_UNAVAILABLE - * or just after but should never be sent after the RADIO_STATE changes from UNAVAILABLE to - * AVAILABLE(RADIO_STATE_ON/RADIO_STATE_OFF) again. - * - * It should NOT be sent after the RADIO_STATE changes to AVAILABLE after the - * modem restart as that could be interpreted as a second modem reset by the - * framework. - */ + /** + * RIL_UNSOL_MODEM_RESTART + * + * Called when there is a modem reset. + * + * "reason" is "const char *" containing the reason for the reset. It + * could be a crash signature if the restart was due to a crash or some + * string such as "user-initiated restart" or "AT command initiated + * restart" that explains the cause of the modem restart. + * + * When modem restarts, one of the following radio state transitions will happen + * 1) RADIO_STATE_ON->RADIO_STATE_UNAVAILABLE->RADIO_STATE_ON or + * 2) RADIO_STATE_OFF->RADIO_STATE_UNAVAILABLE->RADIO_STATE_OFF + * This message can be sent either just before the RADIO_STATE changes to RADIO_STATE_UNAVAILABLE + * or just after but should never be sent after the RADIO_STATE changes from UNAVAILABLE to + * AVAILABLE(RADIO_STATE_ON/RADIO_STATE_OFF) again. + * + * It should NOT be sent after the RADIO_STATE changes to AVAILABLE after the + * modem restart as that could be interpreted as a second modem reset by the + * framework. + */ #define RIL_UNSOL_MODEM_RESTART 1047 /** diff --git a/libril/Android.mk b/libril/Android.mk index 27083ef..0016839 100644 --- a/libril/Android.mk +++ b/libril/Android.mk @@ -28,10 +28,10 @@ LOCAL_SHARED_LIBRARIES := \ LOCAL_STATIC_LIBRARIES := \ libprotobuf-c-nano-enable_malloc \ -#LOCAL_CFLAGS := -DANDROID_MULTI_SIM -DDSDA_RILD1 LOCAL_CFLAGS += -Wno-unused-parameter ifeq ($(SIM_COUNT), 2) + LOCAL_CFLAGS += -DANDROID_MULTI_SIM -DDSDA_RILD1 LOCAL_CFLAGS += -DANDROID_SIM_COUNT_2 endif @@ -45,24 +45,3 @@ LOCAL_SANITIZE := integer include $(BUILD_SHARED_LIBRARY) - -# For RdoServD which needs a static library -# ========================================= -ifneq ($(ANDROID_BIONIC_TRANSITION),) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES:= \ - ril.cpp - -LOCAL_STATIC_LIBRARIES := \ - libutils_static \ - libcutils \ - librilutils_static \ - libprotobuf-c-nano-enable_malloc - -LOCAL_CFLAGS += -Wno-unused-parameter - -LOCAL_MODULE:= libril_static - -include $(BUILD_STATIC_LIBRARY) -endif # ANDROID_BIONIC_TRANSITION diff --git a/libril/RilSapSocket.cpp b/libril/RilSapSocket.cpp index 02db4ad..cf99773 100644 --- a/libril/RilSapSocket.cpp +++ b/libril/RilSapSocket.cpp @@ -78,7 +78,9 @@ void RilSapSocket::sOnUnsolicitedResponse(int unsolResponse, const void *data, size_t datalen) { RilSapSocket *sap_socket = getSocketById(RIL_SOCKET_1); - sap_socket->onUnsolicitedResponse(unsolResponse, (void *)data, datalen); + if(sap_socket){ + sap_socket->onUnsolicitedResponse(unsolResponse, (void *)data, datalen); + } } #endif diff --git a/libril/ril.cpp b/libril/ril.cpp index ea9ca86..f07bd5a 100644 --- a/libril/ril.cpp +++ b/libril/ril.cpp @@ -192,12 +192,8 @@ extern "C" void RIL_onUnsolicitedResponse(int unsolResponse, const void *data, #if defined(ANDROID_MULTI_SIM) #define RIL_UNSOL_RESPONSE(a, b, c, d) RIL_onUnsolicitedResponse((a), (b), (c), (d)) -#define CALL_ONREQUEST(a, b, c, d, e) s_callbacks.onRequest((a), (b), (c), (d), (e)) -#define CALL_ONSTATEREQUEST(a) s_callbacks.onStateRequest(a) #else #define RIL_UNSOL_RESPONSE(a, b, c, d) RIL_onUnsolicitedResponse((a), (b), (c)) -#define CALL_ONREQUEST(a, b, c, d, e) s_callbacks.onRequest((a), (b), (c), (d)) -#define CALL_ONSTATEREQUEST(a) s_callbacks.onStateRequest() #endif static UserCallbackInfo * internalRequestTimedCallback @@ -959,7 +955,7 @@ failCauseToString(RIL_Errno e) { 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: return "E_EMPTY_RECORD"; + 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"; @@ -1219,13 +1215,13 @@ requestToString(int request) { case RIL_UNSOL_HARDWARE_CONFIG_CHANGED: return "UNSOL_HARDWARE_CONFIG_CHANGED"; case RIL_UNSOL_DC_RT_INFO_CHANGED: return "UNSOL_DC_RT_INFO_CHANGED"; case RIL_UNSOL_RADIO_CAPABILITY: return "UNSOL_RADIO_CAPABILITY"; + case RIL_UNSOL_MODEM_RESTART: return "UNSOL_MODEM_RESTART"; + case RIL_UNSOL_CARRIER_INFO_IMSI_ENCRYPTION: return "UNSOL_CARRIER_INFO_IMSI_ENCRYPTION"; case RIL_UNSOL_ON_SS: return "UNSOL_ON_SS"; case RIL_UNSOL_STK_CC_ALPHA_NOTIFY: return "UNSOL_STK_CC_ALPHA_NOTIFY"; case RIL_UNSOL_LCEDATA_RECV: return "UNSOL_LCEDATA_RECV"; case RIL_UNSOL_PCO_DATA: return "UNSOL_PCO_DATA"; - case RIL_UNSOL_MODEM_RESTART: return "UNSOL_MODEM_RESTART"; - case RIL_UNSOL_CARRIER_INFO_IMSI_ENCRYPTION: return "UNSOL_CARRIER_INFO_IMSI_ENCRYPTION"; - default: return "<unknown request>"; + default: return "<unknown request>"; } } @@ -1252,4 +1248,4 @@ rilSocketIdToString(RIL_SOCKET_ID socket_id) } } -} /* namespace android */
\ No newline at end of file +} /* namespace android */ diff --git a/libril/ril_service.cpp b/libril/ril_service.cpp index ea85054..6dd7878 100644 --- a/libril/ril_service.cpp +++ b/libril/ril_service.cpp @@ -51,6 +51,15 @@ using android::sp; #define ATOI_NULL_HANDLED(x) (x ? atoi(x) : -1) #define ATOI_NULL_HANDLED_DEF(x, defaultVal) (x ? atoi(x) : defaultVal) +#if defined(ANDROID_MULTI_SIM) +#define CALL_ONREQUEST(a, b, c, d, e) \ + s_vendorFunctions->onRequest((a), (b), (c), (d), ((RIL_SOCKET_ID)(e))) +#define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest((RIL_SOCKET_ID)(a)) +#else +#define CALL_ONREQUEST(a, b, c, d, e) s_vendorFunctions->onRequest((a), (b), (c), (d)) +#define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest() +#endif + RIL_RadioFunctions *s_vendorFunctions = NULL; static CommandInfo *s_commands; @@ -512,7 +521,7 @@ bool dispatchVoid(int serial, int slotId, int request) { if (pRI == NULL) { return false; } - s_vendorFunctions->onRequest(request, NULL, 0, pRI); + CALL_ONREQUEST(request, NULL, 0, pRI, slotId); return true; } @@ -527,7 +536,7 @@ bool dispatchString(int serial, int slotId, int request, const char * str) { return false; } - s_vendorFunctions->onRequest(request, pString, sizeof(char *), pRI); + CALL_ONREQUEST(request, pString, sizeof(char *), pRI, slotId); memsetAndFreeStrings(1, pString); return true; @@ -561,7 +570,7 @@ bool dispatchStrings(int serial, int slotId, int request, int countStrings, ...) } va_end(ap); - s_vendorFunctions->onRequest(request, pStrings, countStrings * sizeof(char *), pRI); + CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId); if (pStrings != NULL) { for (int i = 0 ; i < countStrings ; i++) { @@ -601,7 +610,7 @@ bool dispatchStrings(int serial, int slotId, int request, const hidl_vec<hidl_st } } - s_vendorFunctions->onRequest(request, pStrings, countStrings * sizeof(char *), pRI); + CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId); if (pStrings != NULL) { for (int i = 0 ; i < countStrings ; i++) { @@ -636,7 +645,7 @@ bool dispatchInts(int serial, int slotId, int request, int countInts, ...) { } va_end(ap); - s_vendorFunctions->onRequest(request, pInts, countInts * sizeof(int), pRI); + CALL_ONREQUEST(request, pInts, countInts * sizeof(int), pRI, slotId); if (pInts != NULL) { #ifdef MEMSET_FREED @@ -665,7 +674,7 @@ bool dispatchCallForwardStatus(int serial, int slotId, int request, return false; } - s_vendorFunctions->onRequest(request, &cf, sizeof(cf), pRI); + CALL_ONREQUEST(request, &cf, sizeof(cf), pRI, slotId); memsetAndFreeStrings(1, cf.number); @@ -680,7 +689,7 @@ bool dispatchRaw(int serial, int slotId, int request, const hidl_vec<uint8_t>& r const uint8_t *uData = rawBytes.data(); - s_vendorFunctions->onRequest(request, (void *) uData, rawBytes.size(), pRI); + CALL_ONREQUEST(request, (void *) uData, rawBytes.size(), pRI, slotId); return true; } @@ -704,7 +713,7 @@ bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message return false; } - s_vendorFunctions->onRequest(request, &apdu, sizeof(apdu), pRI); + CALL_ONREQUEST(request, &apdu, sizeof(apdu), pRI, slotId); memsetAndFreeStrings(1, apdu.data); @@ -902,7 +911,7 @@ Return<void> RadioImpl::dial(int32_t serial, const Dial& dialInfo) { dial.uusInfo = &uusInfo; } - s_vendorFunctions->onRequest(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI); + CALL_ONREQUEST(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI, mSlotId); memsetAndFreeStrings(2, dial.address, uusInfo.uusData); @@ -1147,7 +1156,7 @@ Return<void> RadioImpl::iccIOForApp(int32_t serial, const IccIo& iccIo) { return Void(); } - s_vendorFunctions->onRequest(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI); + CALL_ONREQUEST(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI, mSlotId); memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr); @@ -1280,7 +1289,7 @@ Return<void> RadioImpl::setBarringPassword(int32_t serial, const hidl_string& fa RLOGD("setBarringPassword: serial %d", serial); #endif dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD, - 2, oldPassword.c_str(), newPassword.c_str()); + 3, facility.c_str(), oldPassword.c_str(), newPassword.c_str()); return Void(); } @@ -1432,7 +1441,7 @@ Return<void> RadioImpl::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWri return Void(); } - s_vendorFunctions->onRequest(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI); + CALL_ONREQUEST(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI, mSlotId); memsetAndFreeStrings(2, args.smsc, args.pdu); @@ -1651,7 +1660,7 @@ Return<void> RadioImpl::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) { RIL_CDMA_SMS_Message rcsm = {}; constructCdmaSms(rcsm, sms); - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId); return Void(); } @@ -1669,7 +1678,7 @@ Return<void> RadioImpl::acknowledgeLastIncomingCdmaSms(int32_t serial, const Cdm rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass; rcsa.uSMSCauseCode = smsAck.smsCauseCode; - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI, mSlotId); return Void(); } @@ -1706,8 +1715,8 @@ Return<void> RadioImpl::setGsmBroadcastConfig(int32_t serial, gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected); } - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, gsmBciPtrs, - num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, gsmBciPtrs, + num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI, mSlotId); return Void(); } @@ -1751,8 +1760,8 @@ Return<void> RadioImpl::setCdmaBroadcastConfig(int32_t serial, cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected); } - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, cdmaBciPtrs, - num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, cdmaBciPtrs, + num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI, mSlotId); return Void(); } @@ -1787,7 +1796,7 @@ Return<void> RadioImpl::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& c rcsw.status = (int) cdmaSms.status; constructCdmaSms(rcsw.message, cdmaSms.message); - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI, mSlotId); return Void(); } @@ -1944,7 +1953,7 @@ Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInf return Void(); } - s_vendorFunctions->onRequest(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI); + CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId); memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.username, iaa.password); } else { @@ -1988,7 +1997,7 @@ Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInf return Void(); } - s_vendorFunctions->onRequest(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI); + CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId); memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username, iaa.password, iaa.mvnoMatchData); @@ -2047,8 +2056,8 @@ bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) { } rism.message.gsmMessage = pStrings; - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) + - sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) + + sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI, pRI->socket_id); for (int i = 0 ; i < countStrings ; i++) { memsetAndFreeStrings(1, pStrings[i]); @@ -2079,8 +2088,8 @@ bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) { constructCdmaSms(rcsm, message.cdmaMessage[0]); - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) + - sizeof(uint8_t) + sizeof(int32_t) + sizeof(rcsm), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) + + sizeof(uint8_t) + sizeof(int32_t) + sizeof(rcsm), pRI, pRI->socket_id); return true; } @@ -2136,7 +2145,7 @@ Return<void> RadioImpl::iccOpenLogicalChannel(int32_t serial, const hidl_string& return Void(); } - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, ¶ms, sizeof(params), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, ¶ms, sizeof(params), pRI, mSlotId); memsetAndFreeStrings(1, params.aidPtr); } @@ -2171,7 +2180,7 @@ Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) { RIL_NV_ReadItem nvri = {}; nvri.itemID = (RIL_NV_Item) itemId; - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI, mSlotId); return Void(); } @@ -2192,7 +2201,7 @@ Return<void> RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) { return Void(); } - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI, mSlotId); memsetAndFreeStrings(1, nvwi.value); return Void(); @@ -2249,7 +2258,7 @@ Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType; rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus; - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI, mSlotId); return Void(); } @@ -2293,7 +2302,7 @@ Return<void> RadioImpl::requestIccSimAuthentication(int32_t serial, int32_t auth return Void(); } - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI, mSlotId); memsetAndFreeStrings(2, pf.authData, pf.aid); return Void(); @@ -2404,8 +2413,8 @@ Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfil dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled); } - s_vendorFunctions->onRequest(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs, - num * sizeof(RIL_DataProfileInfo *), pRI); + CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs, + num * sizeof(RIL_DataProfileInfo *), pRI, mSlotId); freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4, &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol, @@ -2482,8 +2491,8 @@ Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfil dataProfiles[i].mtu = profiles[i].mtu; } - s_vendorFunctions->onRequest(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs, - num * sizeof(RIL_DataProfileInfo_v15 *), pRI); + CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs, + num * sizeof(RIL_DataProfileInfo_v15 *), pRI, mSlotId); freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6, &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol, @@ -2528,7 +2537,7 @@ Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability rilRc.status = (int) rc.status; strncpy(rilRc.logicalModemUuid, rc.logicalModemUuid.c_str(), MAX_UUID_LENGTH); - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI, mSlotId); return Void(); } @@ -2620,7 +2629,7 @@ Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed, excludedCarriers[i].match_data = carriers.excludedCarriers[i].matchData.c_str(); } - s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI); + CALL_ONREQUEST(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI, mSlotId); #ifdef MEMSET_FREED memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier)); @@ -2864,6 +2873,7 @@ int radio::supplyIccPinForAppResponse(int slotId, int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen); Return<void> retStatus = radioService[slotId]->mRadioResponse-> supplyIccPinForAppResponse(responseInfo, ret); + RLOGE("supplyIccPinForAppResponse: amit ret %d", ret); radioService[slotId]->checkReturnStatus(retStatus); } else { RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL", @@ -6476,7 +6486,8 @@ int radio::radioStateChangedInd(int slotId, int indicationType, int token, RIL_Errno e, void *response, size_t responseLen) { if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { - RadioState radioState = (RadioState) s_vendorFunctions->onStateRequest(); + RadioState radioState = + (RadioState) CALL_ONSTATEREQUEST(slotId); RLOGD("radioStateChangedInd: radioState %d", radioState); Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged( convertIntToRadioIndicationType(indicationType), radioState); diff --git a/reference-ril/atchannel.c b/reference-ril/atchannel.c index 5dc3e3c..0041836 100644 --- a/reference-ril/atchannel.c +++ b/reference-ril/atchannel.c @@ -61,12 +61,17 @@ void AT_DUMP(const char* prefix, const char* buff, int len) #endif /* - * for current pending command - * these are protected by s_commandmutex + * There is one reader thread |s_tid_reader| and potentially multiple writer + * threads. |s_commandmutex| and |s_commandcond| are used to maintain the + * condition that the writer thread will not read from |sp_response| until the + * reader thread has signaled itself is finished, etc. |s_writeMutex| is used to + * prevent multiple writer threads from calling at_send_command_full_nolock + * function at the same time. */ static pthread_mutex_t s_commandmutex = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t s_commandcond = PTHREAD_COND_INITIALIZER; +static pthread_mutex_t s_writeMutex = PTHREAD_MUTEX_INITIALIZER; static ATCommandType s_type; static const char *s_responsePrefix = NULL; @@ -736,12 +741,16 @@ static int at_send_command_full (const char *command, ATCommandType type, long long timeoutMsec, ATResponse **pp_outResponse) { int err; + bool inEmulator; if (0 != pthread_equal(s_tid_reader, pthread_self())) { /* cannot be called from reader thread */ return AT_ERROR_INVALID_THREAD; } - + inEmulator = isInEmulator(); + if (inEmulator) { + pthread_mutex_lock(&s_writeMutex); + } pthread_mutex_lock(&s_commandmutex); err = at_send_command_full_nolock(command, type, @@ -749,6 +758,9 @@ static int at_send_command_full (const char *command, ATCommandType type, timeoutMsec, pp_outResponse); pthread_mutex_unlock(&s_commandmutex); + if (inEmulator) { + pthread_mutex_unlock(&s_writeMutex); + } if (err == AT_ERROR_TIMEOUT && s_onTimeout != NULL) { s_onTimeout(); @@ -888,12 +900,16 @@ int at_handshake() { int i; int err = 0; + bool inEmulator; if (0 != pthread_equal(s_tid_reader, pthread_self())) { /* cannot be called from reader thread */ return AT_ERROR_INVALID_THREAD; } - + inEmulator = isInEmulator(); + if (inEmulator) { + pthread_mutex_lock(&s_writeMutex); + } pthread_mutex_lock(&s_commandmutex); for (i = 0 ; i < HANDSHAKE_RETRY_COUNT ; i++) { @@ -914,6 +930,9 @@ int at_handshake() } pthread_mutex_unlock(&s_commandmutex); + if (inEmulator) { + pthread_mutex_unlock(&s_writeMutex); + } return err; } diff --git a/reference-ril/misc.c b/reference-ril/misc.c index e4b8d72..c0e9b6e 100644 --- a/reference-ril/misc.c +++ b/reference-ril/misc.c @@ -14,7 +14,9 @@ ** See the License for the specific language governing permissions and ** limitations under the License. */ +#include <sys/system_properties.h> +#include "misc.h" /** returns 1 if line starts with prefix, 0 if it does not */ int strStartsWith(const char *line, const char *prefix) { @@ -27,3 +29,12 @@ int strStartsWith(const char *line, const char *prefix) return *prefix == '\0'; } +// Returns true iff running this process in an emulator VM +bool isInEmulator(void) { + static int inQemu = -1; + if (inQemu < 0) { + char propValue[PROP_VALUE_MAX]; + inQemu = (__system_property_get("ro.kernel.qemu", propValue) != 0); + } + return inQemu == 1; +} diff --git a/reference-ril/misc.h b/reference-ril/misc.h index 7044a07..9e65ab3 100644 --- a/reference-ril/misc.h +++ b/reference-ril/misc.h @@ -14,6 +14,9 @@ ** See the License for the specific language governing permissions and ** limitations under the License. */ +#include <stdbool.h> /** returns 1 if line starts with prefix, 0 if it does not */ int strStartsWith(const char *line, const char *prefix); +/** Returns true iff running this process in an emulator VM */ +bool isInEmulator(void);
\ No newline at end of file diff --git a/reference-ril/reference-ril.c b/reference-ril/reference-ril.c index 59bb372..22f93c5 100644 --- a/reference-ril/reference-ril.c +++ b/reference-ril/reference-ril.c @@ -17,7 +17,6 @@ #include <telephony/ril_cdma_sms.h> #include <telephony/librilutils.h> -#include <stdbool.h> #include <stdio.h> #include <assert.h> #include <string.h> @@ -26,6 +25,7 @@ #include <sys/cdefs.h> #include <sys/types.h> #include <sys/stat.h> +#include <inttypes.h> #include <fcntl.h> #include <pthread.h> #include <alloca.h> @@ -35,8 +35,8 @@ #include <getopt.h> #include <sys/socket.h> #include <cutils/sockets.h> -#include <termios.h> #include <sys/system_properties.h> +#include <termios.h> #include <system/qemu_pipe.h> #include "ril.h" @@ -240,15 +240,6 @@ static int s_repollCallsCount = 0; static int s_expectAnswer = 0; #endif /* WORKAROUND_ERRONEOUS_ANSWER */ -// Returns true iff running this process in an emulator VM -static bool isInEmulator(void) { - static int inQemu = -1; - if (inQemu < 0) { - char propValue[PROP_VALUE_MAX]; - inQemu = (__system_property_get("ro.kernel.qemu", propValue) != 0); - } - return inQemu == 1; -} static int s_cell_info_rate_ms = INT_MAX; static int s_mcc = 0; @@ -340,6 +331,22 @@ error: return -1; } +static int parseSimResponseLine(char* line, RIL_SIM_IO_Response* response) { + int err; + + err = at_tok_start(&line); + if (err < 0) return err; + err = at_tok_nextint(&line, &response->sw1); + if (err < 0) return err; + err = at_tok_nextint(&line, &response->sw2); + if (err < 0) return err; + + if (at_tok_hasmore(&line)) { + err = at_tok_nextstr(&line, &response->simResponse); + if (err < 0) return err; + } + return 0; +} /** do post-AT+CFUN=1 initialization */ static void onRadioPowerOn() @@ -543,23 +550,27 @@ static void requestOrSendDataCallList(RIL_Token *t) err = at_tok_nextstr(&line, &out); if (err < 0) goto error; - responses[i].type = alloca(strlen(out) + 1); - strcpy(responses[i].type, out); + + int type_size = strlen(out) + 1; + responses[i].type = alloca(type_size); + strlcpy(responses[i].type, out, type_size); // APN ignored for v5 err = at_tok_nextstr(&line, &out); if (err < 0) goto error; - responses[i].ifname = alloca(strlen(PPP_TTY_PATH) + 1); - strcpy(responses[i].ifname, PPP_TTY_PATH); + int ifname_size = strlen(PPP_TTY_PATH) + 1; + responses[i].ifname = alloca(ifname_size); + strlcpy(responses[i].ifname, PPP_TTY_PATH, ifname_size); err = at_tok_nextstr(&line, &out); if (err < 0) goto error; - responses[i].addresses = alloca(strlen(out) + 1); - strcpy(responses[i].addresses, out); + int addresses_size = strlen(out) + 1; + responses[i].addresses = alloca(addresses_size); + strlcpy(responses[i].addresses, out, addresses_size); if (isInEmulator()) { /* We are in the emulator - the dns servers are listed @@ -1652,6 +1663,119 @@ error2: RIL_onRequestComplete(t, RIL_E_SMS_SEND_FAIL_RETRY, &response, sizeof(response)); } +static void requestSimOpenChannel(void *data, size_t datalen, RIL_Token t) +{ + ATResponse *p_response = NULL; + int32_t session_id; + int err; + char cmd[32]; + char dummy; + char *line; + + // Max length is 16 bytes according to 3GPP spec 27.007 section 8.45 + if (data == NULL || datalen == 0 || datalen > 16) { + ALOGE("Invalid data passed to requestSimOpenChannel"); + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + return; + } + + snprintf(cmd, sizeof(cmd), "AT+CCHO=%s", data); + + err = at_send_command_numeric(cmd, &p_response); + if (err < 0 || p_response == NULL || p_response->success == 0) { + ALOGE("Error %d opening logical channel: %d", + err, p_response ? p_response->success : 0); + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + at_response_free(p_response); + return; + } + + // Ensure integer only by scanning for an extra char but expect one result + line = p_response->p_intermediates->line; + if (sscanf(line, "%" SCNd32 "%c", &session_id, &dummy) != 1) { + ALOGE("Invalid AT response, expected integer, was '%s'", line); + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + return; + } + + RIL_onRequestComplete(t, RIL_E_SUCCESS, &session_id, sizeof(&session_id)); + at_response_free(p_response); +} + +static void requestSimCloseChannel(void *data, size_t datalen, RIL_Token t) +{ + ATResponse *p_response = NULL; + int32_t session_id; + int err; + char cmd[32]; + + if (data == NULL || datalen != sizeof(session_id)) { + ALOGE("Invalid data passed to requestSimCloseChannel"); + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + return; + } + session_id = ((int32_t *)data)[0]; + snprintf(cmd, sizeof(cmd), "AT+CCHC=%" PRId32, session_id); + err = at_send_command_singleline(cmd, "+CCHC", &p_response); + + if (err < 0 || p_response == NULL || p_response->success == 0) { + ALOGE("Error %d closing logical channel %d: %d", + err, session_id, p_response ? p_response->success : 0); + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + at_response_free(p_response); + return; + } + + RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + + at_response_free(p_response); +} + +static void requestSimTransmitApduChannel(void *data, + size_t datalen, + RIL_Token t) +{ + ATResponse *p_response = NULL; + int err; + char *cmd; + char *line; + size_t cmd_size; + RIL_SIM_IO_Response sim_response; + RIL_SIM_APDU *apdu = (RIL_SIM_APDU *)data; + + if (apdu == NULL || datalen != sizeof(RIL_SIM_APDU)) { + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + return; + } + + cmd_size = 10 + (apdu->data ? strlen(apdu->data) : 0); + asprintf(&cmd, "AT+CGLA=%d,%zu,%02x%02x%02x%02x%02x%s", + apdu->sessionid, cmd_size, apdu->cla, apdu->instruction, + apdu->p1, apdu->p2, apdu->p3, apdu->data ? apdu->data : ""); + + err = at_send_command_singleline(cmd, "+CGLA", &p_response); + free(cmd); + if (err < 0 || p_response == NULL || p_response->success == 0) { + ALOGE("Error %d transmitting APDU: %d", + err, p_response ? p_response->success : 0); + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + at_response_free(p_response); + return; + } + + line = p_response->p_intermediates->line; + err = parseSimResponseLine(line, &sim_response); + + if (err == 0) { + RIL_onRequestComplete(t, RIL_E_SUCCESS, + &sim_response, sizeof(sim_response)); + } else { + ALOGE("Error %d parsing SIM response line: %s", err, line); + RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); + } + at_response_free(p_response); +} + static void requestSetupDataCall(void *data, size_t datalen, RIL_Token t) { const char *apn; @@ -1830,18 +1954,9 @@ static void requestSIM_IO(void *data, size_t datalen __unused, RIL_Token t) line = p_response->p_intermediates->line; - err = at_tok_start(&line); - if (err < 0) goto error; - - err = at_tok_nextint(&line, &(sr.sw1)); - if (err < 0) goto error; - - err = at_tok_nextint(&line, &(sr.sw2)); - if (err < 0) goto error; - - if (at_tok_hasmore(&line)) { - err = at_tok_nextstr(&line, &(sr.simResponse)); - if (err < 0) goto error; + err = parseSimResponseLine(line, &sr); + if (err < 0) { + goto error; } RIL_onRequestComplete(t, RIL_E_SUCCESS, &sr, sizeof(sr)); @@ -2001,9 +2116,9 @@ static void requestGetHardwareConfig(void *data, size_t datalen, RIL_Token t) * RIL_onRequestComplete() may be called from any thread, before or after * this function returns. * - * Will always be called from the same thread, so returning here implies - * that the radio is ready to process another command (whether or not - * the previous command has completed). + * Because onRequest function could be called from multiple different thread, + * we must ensure that the underlying at_send_command_* function + * is atomic. */ static void onRequest (int request, void *data, size_t datalen, RIL_Token t) @@ -2175,6 +2290,15 @@ onRequest (int request, void *data, size_t datalen, RIL_Token t) case RIL_REQUEST_IMS_SEND_SMS: requestImsSendSMS(data, datalen, t); break; + case RIL_REQUEST_SIM_OPEN_CHANNEL: + requestSimOpenChannel(data, datalen, t); + break; + case RIL_REQUEST_SIM_CLOSE_CHANNEL: + requestSimCloseChannel(data, datalen, t); + break; + case RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL: + requestSimTransmitApduChannel(data, datalen, t); + break; case RIL_REQUEST_SETUP_DATA_CALL: requestSetupDataCall(data, datalen, t); break; diff --git a/rild/Android.mk b/rild/Android.mk index fe81d22..4f5802b 100644 --- a/rild/Android.mk +++ b/rild/Android.mk @@ -6,21 +6,20 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ rild.c - LOCAL_SHARED_LIBRARIES := \ - liblog \ libcutils \ - libril \ - libdl + libdl \ + liblog \ + libril -# temporary hack for broken vendor rils +# Temporary hack for broken vendor RILs. LOCAL_WHOLE_STATIC_LIBRARIES := \ librilutils_static LOCAL_CFLAGS := -DRIL_SHLIB -#LOCAL_CFLAGS += -DANDROID_MULTI_SIM ifeq ($(SIM_COUNT), 2) + LOCAL_CFLAGS += -DANDROID_MULTI_SIM LOCAL_CFLAGS += -DANDROID_SIM_COUNT_2 endif diff --git a/rild/rild.c b/rild/rild.c index ce04040..fb4955a 100644 --- a/rild/rild.c +++ b/rild/rild.c @@ -40,7 +40,6 @@ #define LIB_PATH_PROPERTY "rild.libpath" #define LIB_ARGS_PROPERTY "rild.libargs" #define MAX_LIB_ARGS 16 -#define MAX_CAP_NUM (CAP_TO_INDEX(CAP_LAST_CAP) + 1) static void usage(const char *argv0) { fprintf(stderr, "Usage: %s -l <ril impl library> [-- <args for impl library>]\n", argv0); @@ -98,54 +97,9 @@ static int make_argv(char * args, char ** argv) { return count; } -/* - * switchUser - Switches UID to radio, preserving CAP_NET_ADMIN capabilities. - * Our group, cache, was set by init. - */ -void switchUser() { - char debuggable[PROP_VALUE_MAX]; - - prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0); - if (setresuid(AID_RADIO, AID_RADIO, AID_RADIO) == -1) { - RLOGE("setresuid failed: %s", strerror(errno)); - exit(EXIT_FAILURE); - } - - struct __user_cap_header_struct header; - memset(&header, 0, sizeof(header)); - header.version = _LINUX_CAPABILITY_VERSION_3; - header.pid = 0; - - struct __user_cap_data_struct data[MAX_CAP_NUM]; - memset(&data, 0, sizeof(data)); - - data[CAP_TO_INDEX(CAP_NET_ADMIN)].effective |= CAP_TO_MASK(CAP_NET_ADMIN); - data[CAP_TO_INDEX(CAP_NET_ADMIN)].permitted |= CAP_TO_MASK(CAP_NET_ADMIN); - - data[CAP_TO_INDEX(CAP_NET_RAW)].effective |= CAP_TO_MASK(CAP_NET_RAW); - data[CAP_TO_INDEX(CAP_NET_RAW)].permitted |= CAP_TO_MASK(CAP_NET_RAW); - - data[CAP_TO_INDEX(CAP_BLOCK_SUSPEND)].effective |= CAP_TO_MASK(CAP_BLOCK_SUSPEND); - data[CAP_TO_INDEX(CAP_BLOCK_SUSPEND)].permitted |= CAP_TO_MASK(CAP_BLOCK_SUSPEND); - - if (capset(&header, &data[0]) == -1) { - RLOGE("capset failed: %s", strerror(errno)); - exit(EXIT_FAILURE); - } - - /* - * Debuggable build only: - * Set DUMPABLE that was cleared by setuid() to have tombstone on RIL crash - */ - property_get("ro.debuggable", debuggable, "0"); - if (strcmp(debuggable, "1") == 0) { - prctl(PR_SET_DUMPABLE, 1, 0, 0, 0); - } -} - int main(int argc, char **argv) { // vendor ril lib path either passed in as -l parameter, or read from rild.libpath property - const char * rilLibPath = NULL; + const char *rilLibPath = NULL; // ril arguments either passed in as -- parameter, or read from rild.libargs property char **rilArgv; // handle for vendor ril lib @@ -209,8 +163,6 @@ int main(int argc, char **argv) { } } - switchUser(); - dlHandle = dlopen(rilLibPath, RTLD_NOW); if (dlHandle == NULL) { @@ -252,7 +204,7 @@ int main(int argc, char **argv) { } rilArgv[argc++] = "-c"; - rilArgv[argc++] = clientId; + rilArgv[argc++] = (char*)clientId; RLOGD("RIL_Init argc = %d clientId = %s", argc, rilArgv[argc-1]); // Make sure there's a reasonable argv[0] diff --git a/rild/rild.rc b/rild/rild.rc index 2aa8c63..b27e1da 100644 --- a/rild/rild.rc +++ b/rild/rild.rc @@ -1,4 +1,5 @@ service ril-daemon /vendor/bin/hw/rild class main - user root + user radio group radio cache inet misc audio log readproc wakelock + capabilities BLOCK_SUSPEND NET_ADMIN NET_RAW |