@ -30,6 +30,7 @@
# include <cutils/jstring.h>
# include <sys/types.h>
# include <sys/limits.h>
# include <sys/system_properties.h>
# include <pwd.h>
# include <stdio.h>
# include <stdlib.h>
@ -313,6 +314,8 @@ static RIL_RadioState processRadioState(RIL_RadioState newRadioState);
static bool isServiceTypeCfQuery ( RIL_SsServiceType serType , RIL_SsRequestType reqType ) ;
static bool isDebuggable ( ) ;
# ifdef RIL_SHLIB
# if defined(ANDROID_MULTI_SIM)
extern " C " void RIL_onUnsolicitedResponse ( int unsolResponse , const void * data ,
@ -2584,17 +2587,7 @@ static int responseDataCallListV9(Parcel &p, void *response, size_t responselen)
return 0 ;
}
static int responseDataCallList ( Parcel & p , void * response , size_t responselen )
{
if ( s_callbacks . version < 5 ) {
RLOGD ( " responseDataCallList: v4 " ) ;
return responseDataCallListV4 ( p , response , responselen ) ;
} else if ( responselen % sizeof ( RIL_Data_Call_Response_v6 ) = = 0 ) {
return responseDataCallListV6 ( p , response , responselen ) ;
} else if ( responselen % sizeof ( RIL_Data_Call_Response_v9 ) = = 0 ) {
return responseDataCallListV9 ( p , response , responselen ) ;
} else {
static int responseDataCallListV11 ( Parcel & p , void * response , size_t responselen ) {
if ( response = = NULL & & responselen ! = 0 ) {
RLOGE ( " invalid response: NULL " ) ;
return RIL_ERRNO_INVALID_RESPONSE ;
@ -2642,11 +2635,36 @@ static int responseDataCallList(Parcel &p, void *response, size_t responselen)
}
removeLastChar ;
closeResponse ;
}
return 0 ;
}
static int responseDataCallList ( Parcel & p , void * response , size_t responselen )
{
if ( s_callbacks . version < = LAST_IMPRECISE_RIL_VERSION ) {
if ( s_callbacks . version < 5 ) {
RLOGD ( " responseDataCallList: v4 " ) ;
return responseDataCallListV4 ( p , response , responselen ) ;
} else if ( responselen % sizeof ( RIL_Data_Call_Response_v6 ) = = 0 ) {
return responseDataCallListV6 ( p , response , responselen ) ;
} else if ( responselen % sizeof ( RIL_Data_Call_Response_v9 ) = = 0 ) {
return responseDataCallListV9 ( p , response , responselen ) ;
} else {
return responseDataCallListV11 ( p , response , responselen ) ;
}
} else { // RIL version >= 12
if ( responselen % sizeof ( RIL_Data_Call_Response_v11 ) ! = 0 ) {
RLOGE ( " Data structure expected is RIL_Data_Call_Response_v11 " ) ;
if ( ! isDebuggable ( ) ) {
return RIL_ERRNO_INVALID_RESPONSE ;
} else {
assert ( 0 ) ;
}
}
return responseDataCallListV11 ( p , response , responselen ) ;
}
}
static int responseSetupDataCall ( Parcel & p , void * response , size_t responselen )
{
if ( s_callbacks . version < 5 ) {
@ -2971,20 +2989,11 @@ static int responseCdmaInformationRecords(Parcel &p,
return 0 ;
}
static int responseRilSignalStrength ( Parcel & p ,
void * response , size_t responselen ) {
static void responseRilSignalStrengthV5 ( Parcel & p , RIL_SignalStrength_v10 * p_cur ) {
int gsmSignalStrength ;
int cdmaDbm ;
int evdoDbm ;
if ( response = = NULL & & responselen ! = 0 ) {
RLOGE ( " invalid response: NULL " ) ;
return RIL_ERRNO_INVALID_RESPONSE ;
}
if ( responselen > = sizeof ( RIL_SignalStrength_v5 ) ) {
RIL_SignalStrength_v10 * p_cur = ( ( RIL_SignalStrength_v10 * ) response ) ;
gsmSignalStrength = p_cur - > GW_SignalStrength . signalStrength & 0xFF ;
# ifdef MODEM_TYPE_XMM6260
@ -3029,11 +3038,12 @@ static int responseRilSignalStrength(Parcel &p,
p . writeInt32 ( evdoDbm ) ;
p . writeInt32 ( p_cur - > EVDO_SignalStrength . ecio ) ;
p . writeInt32 ( p_cur - > EVDO_SignalStrength . signalNoiseRatio ) ;
if ( responselen > = sizeof ( RIL_SignalStrength_v6 ) ) {
}
static void responseRilSignalStrengthV6Extra ( Parcel & p , RIL_SignalStrength_v10 * p_cur ) {
/*
* Fixup LTE for backwards compatibility
*/
if ( s_callbacks . version < = 6 ) {
// signalStrength: -1 -> 99
if ( p_cur - > LTE_SignalStrength . signalStrength = = - 1 ) {
p_cur - > LTE_SignalStrength . signalStrength = 99 ;
@ -3055,12 +3065,36 @@ static int responseRilSignalStrength(Parcel &p,
if ( p_cur - > LTE_SignalStrength . cqi = = - 1 ) {
p_cur - > LTE_SignalStrength . cqi = INT_MAX ;
}
}
p . writeInt32 ( p_cur - > LTE_SignalStrength . signalStrength ) ;
p . writeInt32 ( p_cur - > LTE_SignalStrength . rsrp ) ;
p . writeInt32 ( p_cur - > LTE_SignalStrength . rsrq ) ;
p . writeInt32 ( p_cur - > LTE_SignalStrength . rssnr ) ;
p . writeInt32 ( p_cur - > LTE_SignalStrength . cqi ) ;
}
static void responseRilSignalStrengthV10 ( Parcel & p , RIL_SignalStrength_v10 * p_cur ) {
responseRilSignalStrengthV5 ( p , p_cur ) ;
responseRilSignalStrengthV6Extra ( p , p_cur ) ;
p . writeInt32 ( p_cur - > TD_SCDMA_SignalStrength . rscp ) ;
}
static int responseRilSignalStrength ( Parcel & p ,
void * response , size_t responselen ) {
if ( response = = NULL & & responselen ! = 0 ) {
RLOGE ( " invalid response: NULL " ) ;
return RIL_ERRNO_INVALID_RESPONSE ;
}
if ( s_callbacks . version < = LAST_IMPRECISE_RIL_VERSION ) {
if ( responselen > = sizeof ( RIL_SignalStrength_v5 ) ) {
RIL_SignalStrength_v10 * p_cur = ( ( RIL_SignalStrength_v10 * ) response ) ;
responseRilSignalStrengthV5 ( p , p_cur ) ;
if ( responselen > = sizeof ( RIL_SignalStrength_v6 ) ) {
responseRilSignalStrengthV6Extra ( p , p_cur ) ;
if ( responselen > = sizeof ( RIL_SignalStrength_v10 ) ) {
p . writeInt32 ( p_cur - > TD_SCDMA_SignalStrength . rscp ) ;
} else {
@ -3074,6 +3108,22 @@ static int responseRilSignalStrength(Parcel &p,
p . writeInt32 ( INT_MAX ) ;
p . writeInt32 ( INT_MAX ) ;
}
} else {
RLOGE ( " invalid response length " ) ;
return RIL_ERRNO_INVALID_RESPONSE ;
}
} else { // RIL version >= 12
if ( responselen % sizeof ( RIL_SignalStrength_v10 ) ! = 0 ) {
RLOGE ( " Data structure expected is RIL_SignalStrength_v10 " ) ;
if ( ! isDebuggable ( ) ) {
return RIL_ERRNO_INVALID_RESPONSE ;
} else {
assert ( 0 ) ;
}
}
RIL_SignalStrength_v10 * p_cur = ( ( RIL_SignalStrength_v10 * ) response ) ;
responseRilSignalStrengthV10 ( p , p_cur ) ;
}
startResponse ;
appendPrintBuf ( " %s[signalStrength=%d,bitErrorRate=%d, \
@ -3097,12 +3147,6 @@ static int responseRilSignalStrength(Parcel &p,
p_cur - > LTE_SignalStrength . cqi ,
p_cur - > TD_SCDMA_SignalStrength . rscp ) ;
closeResponse ;
} else {
RLOGE ( " invalid response length " ) ;
return RIL_ERRNO_INVALID_RESPONSE ;
}
return 0 ;
}
@ -3161,6 +3205,7 @@ static int responseCdmaCallWaiting(Parcel &p, void *response,
writeStringToParcel ( p , p_cur - > name ) ;
marshallSignalInfoRecord ( p , p_cur - > signalInfoRecord ) ;
if ( s_callbacks . version < = LAST_IMPRECISE_RIL_VERSION ) {
if ( responselen > = sizeof ( RIL_CDMA_CallWaiting_v6 ) ) {
p . writeInt32 ( p_cur - > number_type ) ;
p . writeInt32 ( p_cur - > number_plan ) ;
@ -3168,6 +3213,18 @@ static int responseCdmaCallWaiting(Parcel &p, void *response,
p . writeInt32 ( 0 ) ;
p . writeInt32 ( 0 ) ;
}
} else { // RIL version >= 12
if ( responselen % sizeof ( RIL_CDMA_CallWaiting_v6 ) ! = 0 ) {
RLOGE ( " Data structure expected is RIL_CDMA_CallWaiting_v6 " ) ;
if ( ! isDebuggable ( ) ) {
return RIL_ERRNO_INVALID_RESPONSE ;
} else {
assert ( 0 ) ;
}
}
p . writeInt32 ( p_cur - > number_type ) ;
p . writeInt32 ( p_cur - > number_plan ) ;
}
startResponse ;
appendPrintBuf ( " %snumber=%s,numberPresentation=%d, name=%s, \
@ -3188,14 +3245,7 @@ static int responseCdmaCallWaiting(Parcel &p, void *response,
return 0 ;
}
static int responseSimRefresh ( Parcel & p , void * response , size_t responselen ) {
if ( response = = NULL & & responselen ! = 0 ) {
RLOGE ( " responseSimRefresh: invalid response: NULL " ) ;
return RIL_ERRNO_INVALID_RESPONSE ;
}
startResponse ;
if ( s_callbacks . version = = 7 ) {
static void responseSimRefreshV7 ( Parcel & p , void * response ) {
RIL_SimRefreshResponse_v7 * p_cur = ( ( RIL_SimRefreshResponse_v7 * ) response ) ;
p . writeInt32 ( p_cur - > result ) ;
p . writeInt32 ( p_cur - > ef_id ) ;
@ -3206,6 +3256,19 @@ static int responseSimRefresh(Parcel &p, void *response, size_t responselen) {
p_cur - > result ,
p_cur - > ef_id ,
p_cur - > aid ) ;
}
static int responseSimRefresh ( Parcel & p , void * response , size_t responselen ) {
if ( response = = NULL & & responselen ! = 0 ) {
RLOGE ( " responseSimRefresh: invalid response: NULL " ) ;
return RIL_ERRNO_INVALID_RESPONSE ;
}
startResponse ;
if ( s_callbacks . version < = LAST_IMPRECISE_RIL_VERSION ) {
if ( s_callbacks . version = = 7 ) {
responseSimRefreshV7 ( p , response ) ;
} else {
int * p_cur = ( ( int * ) response ) ;
p . writeInt32 ( p_cur [ 0 ] ) ;
@ -3217,6 +3280,18 @@ static int responseSimRefresh(Parcel &p, void *response, size_t responselen) {
p_cur [ 0 ] ,
p_cur [ 1 ] ) ;
}
} else { // RIL version >= 12
if ( responselen % sizeof ( RIL_SimRefreshResponse_v7 ) ! = 0 ) {
RLOGE ( " Data structure expected is RIL_SimRefreshResponse_v7 " ) ;
if ( ! isDebuggable ( ) ) {
return RIL_ERRNO_INVALID_RESPONSE ;
} else {
assert ( 0 ) ;
}
}
responseSimRefreshV7 ( p , response ) ;
}
closeResponse ;
return 0 ;
@ -3578,38 +3653,57 @@ static void sendSimStatusAppInfo(Parcel &p, int num_apps, RIL_AppStatus appStatu
closeResponse ;
}
static int responseSimStatus ( Parcel & p , void * response , size_t responselen ) {
int i ;
if ( response = = NULL & & responselen ! = 0 ) {
RLOGE ( " invalid response: NULL " ) ;
return RIL_ERRNO_INVALID_RESPONSE ;
}
if ( responselen = = sizeof ( RIL_CardStatus_v6 ) ) {
RIL_CardStatus_v6 * p_cur = ( ( RIL_CardStatus_v6 * ) response ) ;
static void responseSimStatusV5 ( Parcel & p , void * response ) {
RIL_CardStatus_v5 * p_cur = ( ( RIL_CardStatus_v5 * ) response ) ;
p . writeInt32 ( p_cur - > card_state ) ;
p . writeInt32 ( p_cur - > universal_pin_state ) ;
p . writeInt32 ( p_cur - > gsm_umts_subscription_app_index ) ;
p . writeInt32 ( p_cur - > cdma_subscription_app_index ) ;
p . writeInt32 ( p_cur - > ims_subscription_app_index ) ;
sendSimStatusAppInfo ( p , p_cur - > num_applications , p_cur - > applications ) ;
} else if ( responselen = = sizeof ( RIL_CardStatus_v5 ) ) {
RIL_CardStatus_v5 * p_cur = ( ( RIL_CardStatus_v5 * ) response ) ;
}
static void responseSimStatusV6 ( Parcel & p , void * response ) {
RIL_CardStatus_v6 * p_cur = ( ( RIL_CardStatus_v6 * ) response ) ;
p . writeInt32 ( p_cur - > card_state ) ;
p . writeInt32 ( p_cur - > universal_pin_state ) ;
p . writeInt32 ( p_cur - > gsm_umts_subscription_app_index ) ;
p . writeInt32 ( p_cur - > cdma_subscription_app_index ) ;
p . writeInt32 ( - 1 ) ;
p . writeInt32 ( p_cur - > ims_subscription_app_index ) ;
sendSimStatusAppInfo ( p , p_cur - > num_applications , p_cur - > applications ) ;
}
static int responseSimStatus ( Parcel & p , void * response , size_t responselen ) {
int i ;
if ( response = = NULL & & responselen ! = 0 ) {
RLOGE ( " invalid response: NULL " ) ;
return RIL_ERRNO_INVALID_RESPONSE ;
}
if ( s_callbacks . version < = LAST_IMPRECISE_RIL_VERSION ) {
if ( responselen = = sizeof ( RIL_CardStatus_v6 ) ) {
responseSimStatusV6 ( p , response ) ;
} else if ( responselen = = sizeof ( RIL_CardStatus_v5 ) ) {
responseSimStatusV5 ( p , response ) ;
} else {
RLOGE ( " responseSimStatus: A RilCardStatus_v6 or _v5 expected \n " ) ;
return RIL_ERRNO_INVALID_RESPONSE ;
}
} else { // RIL version >= 12
if ( responselen % sizeof ( RIL_CardStatus_v6 ) ! = 0 ) {
RLOGE ( " Data structure expected is RIL_CardStatus_v6 " ) ;
if ( ! isDebuggable ( ) ) {
return RIL_ERRNO_INVALID_RESPONSE ;
} else {
assert ( 0 ) ;
}
}
responseSimStatusV6 ( p , response ) ;
}
return 0 ;
}
@ -4425,11 +4519,7 @@ RIL_register (const RIL_RadioFunctions *callbacks) {
callbacks - > version , RIL_VERSION_MIN ) ;
return ;
}
if ( callbacks - > version > RIL_VERSION ) {
RLOGE ( " RIL_register: version %d is too new, max version is %d " ,
callbacks - > version , RIL_VERSION ) ;
return ;
}
RLOGE ( " RIL_register: RIL version %d " , callbacks - > version ) ;
if ( s_registerCalled > 0 ) {
@ -5326,6 +5416,18 @@ rilSocketIdToString(RIL_SOCKET_ID socket_id)
}
}
/*
* Returns true for a debuggable build .
*/
static bool isDebuggable ( ) {
char debuggable [ PROP_VALUE_MAX ] ;
property_get ( " ro.debuggable " , debuggable , " 0 " ) ;
if ( strcmp ( debuggable , " 1 " ) = = 0 ) {
return true ;
}
return false ;
}
} /* namespace android */
void rilEventAddWakeup_helper ( struct ril_event * ev ) {