#define startRequest sprintf(printBuf, "(")
#define closeRequest sprintf(printBuf, "%s)", printBuf)
#define printRequest(token, req) \
- LOGD("[%04d]> %s %s", token, requestToString(req), printBuf)
+ ALOGD("[%04d]> %s %s", token, requestToString(req), printBuf)
#define startResponse sprintf(printBuf, "%s {", printBuf)
#define closeResponse sprintf(printBuf, "%s}", printBuf)
- #define printResponse LOGD("%s", printBuf)
+ #define printResponse ALOGD("%s", printBuf)
#define clearPrintBuf printBuf[0] = 0
#define removeLastChar printBuf[strlen(printBuf)-1] = 0
static void dispatchRaw(Parcel& p, RequestInfo *pRI);
static void dispatchSmsWrite (Parcel &p, RequestInfo *pRI);
static void dispatchDataCall (Parcel& p, RequestInfo *pRI);
+static void dispatchVoiceRadioTech (Parcel& p, RequestInfo *pRI);
+static void dispatchCdmaSubscriptionSource (Parcel& p, RequestInfo *pRI);
static void dispatchCdmaSms(Parcel &p, RequestInfo *pRI);
static void dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI);
static int responseCdmaSignalInfoRecord(Parcel &p,void *response, size_t responselen);
static int responseCdmaCallWaiting(Parcel &p,void *response, size_t responselen);
+static int decodeVoiceRadioTechnology (RIL_RadioState radioState);
+static int decodeCdmaSubscriptionSource (RIL_RadioState radioState);
+static RIL_RadioState processRadioState(RIL_RadioState newRadioState);
+
extern "C" const char * requestToString(int request);
extern "C" const char * failCauseToString(RIL_Errno);
extern "C" const char * callStateToString(RIL_CallState);
#include "ril_unsol_commands.h"
};
+/* For older RILs that do not support new commands RIL_REQUEST_VOICE_RADIO_TECH and
+ RIL_UNSOL_VOICE_RADIO_TECH_CHANGED messages, decode the voice radio tech from
+ radio state message and store it. Every time there is a change in Radio State
+ check to see if voice radio tech changes and notify telephony
+ */
+int voiceRadioTech = -1;
+
+/* For older RILs that do not support new commands RIL_REQUEST_GET_CDMA_SUBSCRIPTION_SOURCE
+ and RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED messages, decode the subscription
+ source from radio state and store it. Every time there is a change in Radio State
+ check to see if subscription source changed and notify telephony
+ */
+int cdmaSubscriptionSource = -1;
+
+/* For older RILs that do not send RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, decode the
+ SIM/RUIM state from radio state and store it. Every time there is a change in Radio State,
+ check to see if SIM/RUIM status changed and notify telephony
+ */
+int simRuimStatus = -1;
static char *
strdupReadString(Parcel &p) {
ret = pthread_mutex_unlock(&s_pendingRequestsMutex);
assert (ret == 0);
- LOGD("C[locl]> %s", requestToString(request));
+ ALOGD("C[locl]> %s", requestToString(request));
s_callbacks.onRequest(request, data, len, pRI);
}
}
}
+// For backwards compatibility with RILs that dont support RIL_REQUEST_VOICE_RADIO_TECH.
+// When all RILs handle this request, this function can be removed and
+// the request can be sent directly to the RIL using dispatchVoid.
+static void dispatchVoiceRadioTech(Parcel& p, RequestInfo *pRI) {
+ RIL_RadioState state = s_callbacks.onStateRequest();
+
+ if ((RADIO_STATE_UNAVAILABLE == state) || (RADIO_STATE_OFF == state)) {
+ RIL_onRequestComplete(pRI, RIL_E_RADIO_NOT_AVAILABLE, NULL, 0);
+ }
+
+ // RILs that support RADIO_STATE_ON should support this request.
+ if (RADIO_STATE_ON == state) {
+ dispatchVoid(p, pRI);
+ return;
+ }
+
+ // For Older RILs, that do not support RADIO_STATE_ON, assume that they
+ // will not support this new request either and decode Voice Radio Technology
+ // from Radio State
+ voiceRadioTech = decodeVoiceRadioTechnology(state);
+
+ if (voiceRadioTech < 0)
+ RIL_onRequestComplete(pRI, RIL_E_GENERIC_FAILURE, NULL, 0);
+ else
+ RIL_onRequestComplete(pRI, RIL_E_SUCCESS, &voiceRadioTech, sizeof(int));
+}
+
+// For backwards compatibility in RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE:.
+// When all RILs handle this request, this function can be removed and
+// the request can be sent directly to the RIL using dispatchVoid.
+static void dispatchCdmaSubscriptionSource(Parcel& p, RequestInfo *pRI) {
+ RIL_RadioState state = s_callbacks.onStateRequest();
+
+ if ((RADIO_STATE_UNAVAILABLE == state) || (RADIO_STATE_OFF == state)) {
+ RIL_onRequestComplete(pRI, RIL_E_RADIO_NOT_AVAILABLE, NULL, 0);
+ }
+
+ // RILs that support RADIO_STATE_ON should support this request.
+ if (RADIO_STATE_ON == state) {
+ dispatchVoid(p, pRI);
+ return;
+ }
+
+ // For Older RILs, that do not support RADIO_STATE_ON, assume that they
+ // will not support this new request either and decode CDMA Subscription Source
+ // from Radio State
+ cdmaSubscriptionSource = decodeCdmaSubscriptionSource(state);
+
+ if (cdmaSubscriptionSource < 0)
+ RIL_onRequestComplete(pRI, RIL_E_GENERIC_FAILURE, NULL, 0);
+ else
+ RIL_onRequestComplete(pRI, RIL_E_SUCCESS, &cdmaSubscriptionSource, sizeof(int));
+}
+
static int
blockingWrite(int fd, const void *buffer, size_t len) {
size_t writeOffset = 0;
int i;
for (i = 0; i < num; i++) {
p.writeInt32((int)p_cur[i].status);
+ p.writeInt32(p_cur[i].suggestedRetryTime);
p.writeInt32(p_cur[i].cid);
p.writeInt32(p_cur[i].active);
writeStringToParcel(p, p_cur[i].type);
writeStringToParcel(p, p_cur[i].addresses);
writeStringToParcel(p, p_cur[i].dnses);
writeStringToParcel(p, p_cur[i].gateways);
- appendPrintBuf("%s[status=%d,cid=%d,%s,%d,%s,%s,%s],", printBuf,
+ appendPrintBuf("%s[status=%d,retry=%d,cid=%d,%s,%d,%s,%s,%s],", printBuf,
p_cur[i].status,
+ p_cur[i].suggestedRetryTime,
p_cur[i].cid,
(p_cur[i].active==0)?"down":"up",
(char*)p_cur[i].ifname,
}
if (responselen < sizeof(RIL_CDMA_CallWaiting_v6)) {
- LOGW("Upgrade to ril version %d\n", RIL_VERSION);
+ ALOGW("Upgrade to ril version %d\n", RIL_VERSION);
}
RIL_CDMA_CallWaiting_v6 *p_cur = ((RIL_CDMA_CallWaiting_v6 *) response);
uint8_t uct;
void* dest;
- LOGD("Inside responseCdmaSms");
+ ALOGD("Inside responseCdmaSms");
if (response == NULL && responselen != 0) {
LOGE("invalid response: NULL");
char buff[16];
int ret;
- LOGV("processWakeupCallback");
+ ALOGV("processWakeupCallback");
/* empty our wakeup socket out */
do {
if (ret != 0) {
LOGE("error on reading command socket errno:%d\n", errno);
} else {
- LOGW("EOS. Closing command socket.");
+ ALOGW("EOS. Closing command socket.");
}
close(s_fdCommand);
static void onNewCommandConnect() {
+ // Inform we are connected and the ril version
+ int rilVer = s_callbacks.version;
+ RIL_onUnsolicitedResponse(RIL_UNSOL_RIL_CONNECTED,
+ &rilVer, sizeof(rilVer));
+
// implicit radio state changed
RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED,
NULL, 0);
if (s_callbacks.getVersion != NULL) {
const char *version;
version = s_callbacks.getVersion();
- LOGI("RIL Daemon version: %s\n", version);
+ ALOGI("RIL Daemon version: %s\n", version);
property_set(PROPERTY_RIL_IMPL, version);
} else {
- LOGI("RIL Daemon version: unavailable\n");
+ ALOGI("RIL Daemon version: unavailable\n");
property_set(PROPERTY_RIL_IMPL, "unavailable");
}
LOGE("Error on getpwuid() errno: %d", errno);
}
} else {
- LOGD("Error on getsockopt() errno: %d", errno);
+ ALOGD("Error on getsockopt() errno: %d", errno);
}
if ( !is_phone_socket ) {
LOGE ("Error setting O_NONBLOCK errno:%d", errno);
}
- LOGI("libril: new connection");
+ ALOGI("libril: new connection");
p_rs = record_stream_new(s_fdCommand, MAX_COMMAND_BYTES);
switch (atoi(args[0])) {
case 0:
- LOGI ("Connection on debug port: issuing reset.");
+ ALOGI ("Connection on debug port: issuing reset.");
issueLocalRequest(RIL_REQUEST_RESET_RADIO, NULL, 0);
break;
case 1:
- LOGI ("Connection on debug port: issuing radio power off.");
+ ALOGI ("Connection on debug port: issuing radio power off.");
data = 0;
issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int));
// Close the socket
s_fdCommand = -1;
break;
case 2:
- LOGI ("Debug port: issuing unsolicited voice network change.");
+ ALOGI ("Debug port: issuing unsolicited voice network change.");
RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED,
NULL, 0);
break;
case 3:
- LOGI ("Debug port: QXDM log enable.");
+ ALOGI ("Debug port: QXDM log enable.");
qxdm_data[0] = 65536; // head.func_tag
qxdm_data[1] = 16; // head.len
qxdm_data[2] = 1; // mode: 1 for 'start logging'
6 * sizeof(int));
break;
case 4:
- LOGI ("Debug port: QXDM log disable.");
+ ALOGI ("Debug port: QXDM log disable.");
qxdm_data[0] = 65536;
qxdm_data[1] = 16;
qxdm_data[2] = 0; // mode: 0 for 'stop logging'
6 * sizeof(int));
break;
case 5:
- LOGI("Debug port: Radio On");
+ ALOGI("Debug port: Radio On");
data = 1;
issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int));
sleep(2);
issueLocalRequest(RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, NULL, 0);
break;
case 6:
- LOGI("Debug port: Setup Data Call, Apn :%s\n", args[1]);
+ ALOGI("Debug port: Setup Data Call, Apn :%s\n", args[1]);
actData[0] = args[1];
issueLocalRequest(RIL_REQUEST_SETUP_DATA_CALL, &actData,
sizeof(actData));
break;
case 7:
- LOGI("Debug port: Deactivate Data Call");
+ ALOGI("Debug port: Deactivate Data Call");
issueLocalRequest(RIL_REQUEST_DEACTIVATE_DATA_CALL, &deactData,
sizeof(deactData));
break;
case 8:
- LOGI("Debug port: Dial Call");
+ ALOGI("Debug port: Dial Call");
dialData.clir = 0;
dialData.address = args[1];
issueLocalRequest(RIL_REQUEST_DIAL, &dialData, sizeof(dialData));
break;
case 9:
- LOGI("Debug port: Answer Call");
+ ALOGI("Debug port: Answer Call");
issueLocalRequest(RIL_REQUEST_ANSWER, NULL, 0);
break;
case 10:
- LOGI("Debug port: End Call");
+ ALOGI("Debug port: End Call");
issueLocalRequest(RIL_REQUEST_HANGUP, &hangupData,
sizeof(hangupData));
break;
// Only returns on error
ril_event_loop();
LOGE ("error in event_loop_base errno:%d", errno);
+ // kill self to restart on error
+ kill(0, SIGKILL);
return NULL;
}
if (pRI->local > 0) {
// Locally issued command...void only!
// response does not go back up the command socket
- LOGD("C[locl]< %s", requestToString(pRI->pCI->requestNumber));
+ ALOGD("C[locl]< %s", requestToString(pRI->pCI->requestNumber));
goto done;
}
}
if (s_fdCommand < 0) {
- LOGD ("RIL onRequestComplete: Command channel closed");
+ ALOGD ("RIL onRequestComplete: Command channel closed");
}
sendResponse(p);
}
wakeTimeoutCallback (void *param) {
// We're using "param != NULL" as a cancellation mechanism
if (param == NULL) {
- //LOGD("wakeTimeout: releasing wake lock");
+ //ALOGD("wakeTimeout: releasing wake lock");
releaseWakeLock();
} else {
- //LOGD("wakeTimeout: releasing wake lock CANCELLED");
+ //ALOGD("wakeTimeout: releasing wake lock CANCELLED");
}
}
+static int
+decodeVoiceRadioTechnology (RIL_RadioState radioState) {
+ switch (radioState) {
+ case RADIO_STATE_SIM_NOT_READY:
+ case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
+ case RADIO_STATE_SIM_READY:
+ return RADIO_TECH_UMTS;
+
+ case RADIO_STATE_RUIM_NOT_READY:
+ case RADIO_STATE_RUIM_READY:
+ case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:
+ case RADIO_STATE_NV_NOT_READY:
+ case RADIO_STATE_NV_READY:
+ return RADIO_TECH_1xRTT;
+
+ default:
+ ALOGD("decodeVoiceRadioTechnology: Invoked with incorrect RadioState");
+ return -1;
+ }
+}
+
+static int
+decodeCdmaSubscriptionSource (RIL_RadioState radioState) {
+ switch (radioState) {
+ case RADIO_STATE_SIM_NOT_READY:
+ case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
+ case RADIO_STATE_SIM_READY:
+ case RADIO_STATE_RUIM_NOT_READY:
+ case RADIO_STATE_RUIM_READY:
+ case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:
+ return CDMA_SUBSCRIPTION_SOURCE_RUIM_SIM;
+
+ case RADIO_STATE_NV_NOT_READY:
+ case RADIO_STATE_NV_READY:
+ return CDMA_SUBSCRIPTION_SOURCE_NV;
+
+ default:
+ ALOGD("decodeCdmaSubscriptionSource: Invoked with incorrect RadioState");
+ return -1;
+ }
+}
+
+static int
+decodeSimStatus (RIL_RadioState radioState) {
+ switch (radioState) {
+ case RADIO_STATE_SIM_NOT_READY:
+ case RADIO_STATE_RUIM_NOT_READY:
+ case RADIO_STATE_NV_NOT_READY:
+ case RADIO_STATE_NV_READY:
+ return -1;
+ case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
+ case RADIO_STATE_SIM_READY:
+ case RADIO_STATE_RUIM_READY:
+ case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:
+ return radioState;
+ default:
+ ALOGD("decodeSimStatus: Invoked with incorrect RadioState");
+ return -1;
+ }
+}
+
+static bool is3gpp2(int radioTech) {
+ switch (radioTech) {
+ case RADIO_TECH_IS95A:
+ case RADIO_TECH_IS95B:
+ case RADIO_TECH_1xRTT:
+ case RADIO_TECH_EVDO_0:
+ case RADIO_TECH_EVDO_A:
+ case RADIO_TECH_EVDO_B:
+ case RADIO_TECH_EHRPD:
+ return true;
+ default:
+ return false;
+ }
+}
+
+/* If RIL sends SIM states or RUIM states, store the voice radio
+ * technology and subscription source information so that they can be
+ * returned when telephony framework requests them
+ */
+static RIL_RadioState
+processRadioState(RIL_RadioState newRadioState) {
+
+ if((newRadioState > RADIO_STATE_UNAVAILABLE) && (newRadioState < RADIO_STATE_ON)) {
+ int newVoiceRadioTech;
+ int newCdmaSubscriptionSource;
+ int newSimStatus;
+
+ /* This is old RIL. Decode Subscription source and Voice Radio Technology
+ from Radio State and send change notifications if there has been a change */
+ newVoiceRadioTech = decodeVoiceRadioTechnology(newRadioState);
+ if(newVoiceRadioTech != voiceRadioTech) {
+ voiceRadioTech = newVoiceRadioTech;
+ RIL_onUnsolicitedResponse (RIL_UNSOL_VOICE_RADIO_TECH_CHANGED,
+ &voiceRadioTech, sizeof(voiceRadioTech));
+ }
+ if(is3gpp2(newVoiceRadioTech)) {
+ newCdmaSubscriptionSource = decodeCdmaSubscriptionSource(newRadioState);
+ if(newCdmaSubscriptionSource != cdmaSubscriptionSource) {
+ cdmaSubscriptionSource = newCdmaSubscriptionSource;
+ RIL_onUnsolicitedResponse (RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED,
+ &cdmaSubscriptionSource, sizeof(cdmaSubscriptionSource));
+ }
+ }
+ newSimStatus = decodeSimStatus(newRadioState);
+ if(newSimStatus != simRuimStatus) {
+ simRuimStatus = newSimStatus;
+ RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, NULL, 0);
+ }
+
+ /* Send RADIO_ON to telephony */
+ newRadioState = RADIO_STATE_ON;
+ }
+
+ return newRadioState;
+}
+
extern "C"
void RIL_onUnsolicitedResponse(int unsolResponse, void *data,
size_t datalen)
int ret;
int64_t timeReceived = 0;
bool shouldScheduleTimeout = false;
+ RIL_RadioState newState;
if (s_registerCalled == 0) {
// Ignore RIL_onUnsolicitedResponse before RIL_register
- LOGW("RIL_onUnsolicitedResponse called before RIL_register");
+ ALOGW("RIL_onUnsolicitedResponse called before RIL_register");
return;
}
// some things get more payload
switch(unsolResponse) {
case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED:
- p.writeInt32(s_callbacks.onStateRequest());
+ newState = processRadioState(s_callbacks.onStateRequest());
+ p.writeInt32(newState);
appendPrintBuf("%s {%s}", printBuf,
radioStateToString(s_callbacks.onStateRequest()));
break;
case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:return"RADIO_RUIM_LOCKED_OR_ABSENT";
case RADIO_STATE_NV_NOT_READY:return"RADIO_NV_NOT_READY";
case RADIO_STATE_NV_READY:return"RADIO_NV_READY";
+ case RADIO_STATE_ON:return"RADIO_ON";
default: return "<unknown state>";
}
}
case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "REPORT_SMS_MEMORY_STATUS";
case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: return "REPORT_STK_SERVICE_IS_RUNNING";
case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: return "CDMA_GET_SUBSCRIPTION_SOURCE";
+ case RIL_REQUEST_ISIM_AUTHENTICATION: return "ISIM_AUTHENTICATION";
+ case RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU: return "RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU";
+ case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS: return "RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS";
+ case RIL_REQUEST_VOICE_RADIO_TECH: return "VOICE_RADIO_TECH";
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";
case RIL_UNSOL_OEM_HOOK_RAW: return "UNSOL_OEM_HOOK_RAW";
case RIL_UNSOL_RINGBACK_TONE: return "UNSOL_RINGBACK_TONE";
case RIL_UNSOL_RESEND_INCALL_MUTE: return "UNSOL_RESEND_INCALL_MUTE";
- case RIL_UNSOL_CDMA_SUBSCRIPTION_CHANGED: return "UNSOL_CDMA_SUBSCRIPTION_CHANGED";
+ case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return "UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED";
case RIL_UNSOL_CDMA_PRL_CHANGED: return "UNSOL_CDMA_PRL_CHANGED";
case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: return "UNSOL_EXIT_EMERGENCY_CALLBACK_MODE";
+ case RIL_UNSOL_RIL_CONNECTED: return "UNSOL_RIL_CONNECTED";
+ case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: return "UNSOL_VOICE_RADIO_TECH_CHANGED";
default: return "<unknown request>";
}
}