** limitations under the License.
*/
-#include <telephony/ril.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <sys/socket.h>
#include <cutils/sockets.h>
#include <termios.h>
+#include <sys/system_properties.h>
+
+#include "ril.h"
+#include "hardware/qemu_pipe.h"
#define LOG_TAG "RIL"
#include <utils/Log.h>
SIM_PIN = 3,
SIM_PUK = 4,
SIM_NETWORK_PERSONALIZATION = 5
-} SIM_Status;
+} SIM_Status;
static void onRequest (int request, void *data, size_t datalen, RIL_Token t);
static RIL_RadioState currentState();
static const char *getVersion();
static int isRadioOn();
static SIM_Status getSIMStatus();
-static int getCardStatus(RIL_CardStatus **pp_card_status);
-static void freeCardStatus(RIL_CardStatus *p_card_status);
+static int getCardStatus(RIL_CardStatus_v6 **pp_card_status);
+static void freeCardStatus(RIL_CardStatus_v6 *p_card_status);
static void onDataCallListChanged(void *param);
extern const char * requestToString(int request);
return 0;
error:
- LOGE("invalid CLCC line\n");
+ ALOGE("invalid CLCC line\n");
return -1;
}
p_cur = p_cur->p_next)
n++;
- RIL_Data_Call_Response *responses =
- alloca(n * sizeof(RIL_Data_Call_Response));
+ RIL_Data_Call_Response_v6 *responses =
+ alloca(n * sizeof(RIL_Data_Call_Response_v6));
int i;
for (i = 0; i < n; i++) {
+ responses[i].status = -1;
+ responses[i].suggestedRetryTime = -1;
responses[i].cid = -1;
responses[i].active = -1;
responses[i].type = "";
- responses[i].apn = "";
- responses[i].address = "";
+ responses[i].ifname = "";
+ responses[i].addresses = "";
+ responses[i].dnses = "";
+ responses[i].gateways = "";
}
- RIL_Data_Call_Response *response = responses;
+ RIL_Data_Call_Response_v6 *response = responses;
for (p_cur = p_response->p_intermediates; p_cur != NULL;
p_cur = p_cur->p_next) {
char *line = p_cur->line;
p_cur = p_cur->p_next) {
char *line = p_cur->line;
int cid;
- char *type;
- char *apn;
- char *address;
-
err = at_tok_start(&line);
if (err < 0)
continue;
}
+ // Assume no error
+ responses[i].status = 0;
+
+ // type
err = at_tok_nextstr(&line, &out);
if (err < 0)
goto error;
-
responses[i].type = alloca(strlen(out) + 1);
strcpy(responses[i].type, out);
+ // APN ignored for v5
err = at_tok_nextstr(&line, &out);
if (err < 0)
goto error;
- responses[i].apn = alloca(strlen(out) + 1);
- strcpy(responses[i].apn, out);
+ responses[i].ifname = alloca(strlen(PPP_TTY_PATH) + 1);
+ strcpy(responses[i].ifname, PPP_TTY_PATH);
err = at_tok_nextstr(&line, &out);
if (err < 0)
goto error;
- responses[i].address = alloca(strlen(out) + 1);
- strcpy(responses[i].address, out);
+ responses[i].addresses = alloca(strlen(out) + 1);
+ strcpy(responses[i].addresses, out);
+
+ {
+ char propValue[PROP_VALUE_MAX];
+
+ if (__system_property_get("ro.kernel.qemu", propValue) != 0) {
+ /* We are in the emulator - the dns servers are listed
+ * by the following system properties, setup in
+ * /system/etc/init.goldfish.sh:
+ * - net.eth0.dns1
+ * - net.eth0.dns2
+ * - net.eth0.dns3
+ * - net.eth0.dns4
+ */
+ const int dnslist_sz = 128;
+ char* dnslist = alloca(dnslist_sz);
+ const char* separator = "";
+ int nn;
+
+ dnslist[0] = 0;
+ for (nn = 1; nn <= 4; nn++) {
+ /* Probe net.eth0.dns<n> */
+ char propName[PROP_NAME_MAX];
+ snprintf(propName, sizeof propName, "net.eth0.dns%d", nn);
+
+ /* Ignore if undefined */
+ if (__system_property_get(propName, propValue) == 0) {
+ continue;
+ }
+
+ /* Append the DNS IP address */
+ strlcat(dnslist, separator, dnslist_sz);
+ strlcat(dnslist, propValue, dnslist_sz);
+ separator = " ";
+ }
+ responses[i].dnses = dnslist;
+
+ /* There is only on gateway in the emulator */
+ responses[i].gateways = "10.0.2.2";
+ }
+ else {
+ /* I don't know where we are, so use the public Google DNS
+ * servers by default and no gateway.
+ */
+ responses[i].dnses = "8.8.8.8 8.8.4.4";
+ responses[i].gateways = "";
+ }
+ }
}
at_response_free(p_response);
if (t != NULL)
RIL_onRequestComplete(*t, RIL_E_SUCCESS, responses,
- n * sizeof(RIL_Data_Call_Response));
+ n * sizeof(RIL_Data_Call_Response_v6));
else
RIL_onUnsolicitedResponse(RIL_UNSOL_DATA_CALL_LIST_CHANGED,
responses,
- n * sizeof(RIL_Data_Call_Response));
+ n * sizeof(RIL_Data_Call_Response_v6));
return;
return;
error:
at_response_free(p_response);
- LOGE("requestQueryNetworkSelectionMode must never return error when radio is on");
+ ALOGE("requestQueryNetworkSelectionMode must never return error when radio is on");
RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
}
&& p_calls[i].state == RIL_CALL_ACTIVE
&& s_repollCallsCount < REPOLL_CALLS_COUNT_MAX
) {
- LOGI(
+ ALOGI(
"Hit WORKAROUND_ERRONOUS_ANSWER case."
" Repoll count: %d\n", s_repollCallsCount);
s_repollCallsCount++;
{
ATResponse *p_response = NULL;
int err;
- int response[2];
char *line;
+ int count =0;
+ int numofElements=sizeof(RIL_SignalStrength_v6)/sizeof(int);
+ int response[numofElements];
err = at_send_command_singleline("AT+CSQ", "+CSQ:", &p_response);
err = at_tok_start(&line);
if (err < 0) goto error;
- err = at_tok_nextint(&line, &(response[0]));
- if (err < 0) goto error;
-
- err = at_tok_nextint(&line, &(response[1]));
- if (err < 0) goto error;
+ for (count =0; count < numofElements; count ++) {
+ err = at_tok_nextint(&line, &(response[count]));
+ if (err < 0) goto error;
+ }
RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response));
return;
error:
- LOGE("requestSignalStrength must never return an error when radio is on");
+ ALOGE("requestSignalStrength must never return an error when radio is on");
RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
at_response_free(p_response);
}
int count = 3;
- if (request == RIL_REQUEST_REGISTRATION_STATE) {
+ if (request == RIL_REQUEST_VOICE_REGISTRATION_STATE) {
cmd = "AT+CREG?";
prefix = "+CREG:";
- } else if (request == RIL_REQUEST_GPRS_REGISTRATION_STATE) {
+ } else if (request == RIL_REQUEST_DATA_REGISTRATION_STATE) {
cmd = "AT+CGREG?";
prefix = "+CGREG:";
} else {
return;
error:
- LOGE("requestRegistrationState must never return an error when radio is on");
+ ALOGE("requestRegistrationState must never return an error when radio is on");
RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
at_response_free(p_response);
}
return;
error:
- LOGE("requestOperator must not return error when radio is on");
+ ALOGE("requestOperator must not return error when radio is on");
RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
at_response_free(p_response);
}
char *cmd;
int err;
ATResponse *p_response = NULL;
- char *response[2] = { "1", PPP_TTY_PATH };
apn = ((const char **)data)[2];
int retry = 10;
const char *pdp_type;
- LOGD("requesting data connection to APN '%s'", apn);
+ ALOGD("requesting data connection to APN '%s'", apn);
fd = open ("/dev/qmi", O_RDWR);
if (fd >= 0) { /* the device doesn't exist on the emulator */
- LOGD("opened the qmi device\n");
+ ALOGD("opened the qmi device\n");
asprintf(&cmd, "up:%s", apn);
len = strlen(cmd);
} while (written < 0 && errno == EINTR);
if (written < 0) {
- LOGE("### ERROR writing to /dev/qmi");
+ ALOGE("### ERROR writing to /dev/qmi");
close(fd);
goto error;
}
} while (rlen < 0 && errno == EINTR);
if (rlen < 0) {
- LOGE("### ERROR reading from /dev/qmi");
+ ALOGE("### ERROR reading from /dev/qmi");
close(fd);
goto error;
} else {
status[rlen] = '\0';
- LOGD("### status: %s", status);
+ ALOGD("### status: %s", status);
}
} while (strncmp(status, "STATE=up", 8) && strcmp(status, "online") && --retry);
close(fd);
if (retry == 0) {
- LOGE("### Failed to get data connection up\n");
+ ALOGE("### Failed to get data connection up\n");
goto error;
}
qmistatus = system("netcfg rmnet0 dhcp");
- LOGD("netcfg rmnet0 dhcp: status %d\n", qmistatus);
+ ALOGD("netcfg rmnet0 dhcp: status %d\n", qmistatus);
if (qmistatus < 0) goto error;
pdp_type = "IP";
}
- asprintf(&cmd, "AT+CGDCONT=1,\"%s\",\"%s\",,0,0", apn, pdp_type);
+ asprintf(&cmd, "AT+CGDCONT=1,\"%s\",\"%s\",,0,0", pdp_type, apn);
//FIXME check for error here
err = at_send_command(cmd, NULL);
free(cmd);
}
}
- RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response));
+ requestOrSendDataCallList(&t);
+
at_response_free(p_response);
return;
} else if (ackSuccess == 0) {
err = at_send_command("AT+CNMA=2", NULL);
} else {
- LOGE("unsupported arg to RIL_REQUEST_SMS_ACKNOWLEDGE\n");
+ ALOGE("unsupported arg to RIL_REQUEST_SMS_ACKNOWLEDGE\n");
goto error;
}
RIL_SIM_IO_Response sr;
int err;
char *cmd = NULL;
- RIL_SIM_IO *p_args;
+ RIL_SIM_IO_v6 *p_args;
char *line;
memset(&sr, 0, sizeof(sr));
- p_args = (RIL_SIM_IO *)data;
+ p_args = (RIL_SIM_IO_v6 *)data;
/* FIXME handle pin2 */
ATResponse *p_response;
int err;
- LOGD("onRequest: %s", requestToString(request));
+ ALOGD("onRequest: %s", requestToString(request));
/* Ignore all requests except RIL_REQUEST_GET_SIM_STATUS
* when RADIO_STATE_UNAVAILABLE.
switch (request) {
case RIL_REQUEST_GET_SIM_STATUS: {
- RIL_CardStatus *p_card_status;
+ RIL_CardStatus_v6 *p_card_status;
char *p_buffer;
int buffer_size;
case RIL_REQUEST_SIGNAL_STRENGTH:
requestSignalStrength(data, datalen, t);
break;
- case RIL_REQUEST_REGISTRATION_STATE:
- case RIL_REQUEST_GPRS_REGISTRATION_STATE:
+ case RIL_REQUEST_VOICE_REGISTRATION_STATE:
+ case RIL_REQUEST_DATA_REGISTRATION_STATE:
requestRegistrationState(request, data, datalen, t);
break;
case RIL_REQUEST_OPERATOR:
int i;
const char ** cur;
- LOGD("got OEM_HOOK_STRINGS: 0x%8p %lu", data, (long)datalen);
+ ALOGD("got OEM_HOOK_STRINGS: 0x%8p %lu", data, (long)datalen);
for (i = (datalen / sizeof (char *)), cur = (const char **)data ;
i > 0 ; cur++, i --) {
- LOGD("> '%s'", *cur);
+ ALOGD("> '%s'", *cur);
}
// echo back strings
}
/** Returns SIM_NOT_READY on error */
-static SIM_Status
+static SIM_Status
getSIMStatus()
{
ATResponse *p_response = NULL;
* This must be freed using freeCardStatus.
* @return: On success returns RIL_E_SUCCESS
*/
-static int getCardStatus(RIL_CardStatus **pp_card_status) {
+static int getCardStatus(RIL_CardStatus_v6 **pp_card_status) {
static RIL_AppStatus app_status_array[] = {
// SIM_ABSENT = 0
{ RIL_APPTYPE_UNKNOWN, RIL_APPSTATE_UNKNOWN, RIL_PERSOSUBSTATE_UNKNOWN,
}
// Allocate and initialize base card status.
- RIL_CardStatus *p_card_status = malloc(sizeof(RIL_CardStatus));
+ RIL_CardStatus_v6 *p_card_status = malloc(sizeof(RIL_CardStatus_v6));
p_card_status->card_state = card_state;
p_card_status->universal_pin_state = RIL_PINSTATE_UNKNOWN;
p_card_status->gsm_umts_subscription_app_index = RIL_CARD_MAX_APPS;
p_card_status->cdma_subscription_app_index = RIL_CARD_MAX_APPS;
+ p_card_status->ims_subscription_app_index = RIL_CARD_MAX_APPS;
p_card_status->num_applications = num_apps;
// Initialize application status
/**
* Free the card status returned by getCardStatus
*/
-static void freeCardStatus(RIL_CardStatus *p_card_status) {
+static void freeCardStatus(RIL_CardStatus_v6 *p_card_status) {
free(p_card_status);
}
err = at_tok_nextstr(&line, &response);
if (err != 0) {
- LOGE("invalid NITZ line %s\n", s);
+ ALOGE("invalid NITZ line %s\n", s);
} else {
RIL_onUnsolicitedResponse (
RIL_UNSOL_NITZ_TIME_RECEIVED,
|| strStartsWith(s,"+CGREG:")
) {
RIL_onUnsolicitedResponse (
- RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED,
+ RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED,
NULL, 0);
#ifdef WORKAROUND_FAKE_CGEV
RIL_requestTimedCallback (onDataCallListChanged, NULL, NULL);
/* Called on command or reader thread */
static void onATReaderClosed()
{
- LOGI("AT channel closed\n");
+ ALOGI("AT channel closed\n");
at_close();
s_closed = 1;
/* Called on command thread */
static void onATTimeout()
{
- LOGI("AT channel timeout; closing\n");
+ ALOGI("AT channel timeout; closing\n");
at_close();
s_closed = 1;
fd = socket_loopback_client(s_port, SOCK_STREAM);
} else if (s_device_socket) {
if (!strcmp(s_device_path, "/dev/socket/qemud")) {
- /* Qemu-specific control socket */
- fd = socket_local_client( "qemud",
- ANDROID_SOCKET_NAMESPACE_RESERVED,
- SOCK_STREAM );
- if (fd >= 0 ) {
- char answer[2];
-
- if ( write(fd, "gsm", 3) != 3 ||
- read(fd, answer, 2) != 2 ||
- memcmp(answer, "OK", 2) != 0)
- {
- close(fd);
- fd = -1;
- }
- }
+ /* Before trying to connect to /dev/socket/qemud (which is
+ * now another "legacy" way of communicating with the
+ * emulator), we will try to connecto to gsm service via
+ * qemu pipe. */
+ fd = qemu_pipe_open("qemud:gsm");
+ if (fd < 0) {
+ /* Qemu-specific control socket */
+ fd = socket_local_client( "qemud",
+ ANDROID_SOCKET_NAMESPACE_RESERVED,
+ SOCK_STREAM );
+ if (fd >= 0 ) {
+ char answer[2];
+
+ if ( write(fd, "gsm", 3) != 3 ||
+ read(fd, answer, 2) != 2 ||
+ memcmp(answer, "OK", 2) != 0)
+ {
+ close(fd);
+ fd = -1;
+ }
+ }
+ }
}
else
fd = socket_local_client( s_device_path,
ret = at_open(fd, onUnsolicited);
if (ret < 0) {
- LOGE ("AT error %d on at_open\n", ret);
+ ALOGE ("AT error %d on at_open\n", ret);
return 0;
}
sleep(1);
waitForClose();
- LOGI("Re-opening after close");
+ ALOGI("Re-opening after close");
}
}
usage(argv[0]);
return NULL;
}
- LOGI("Opening loopback port %d\n", s_port);
+ ALOGI("Opening loopback port %d\n", s_port);
break;
case 'd':
s_device_path = optarg;
- LOGI("Opening tty device %s\n", s_device_path);
+ ALOGI("Opening tty device %s\n", s_device_path);
break;
case 's':
s_device_path = optarg;
s_device_socket = 1;
- LOGI("Opening socket %s\n", s_device_path);
+ ALOGI("Opening socket %s\n", s_device_path);
break;
default:
if (s_port == 0) {
usage(argv[0]);
}
- LOGI("Opening loopback port %d\n", s_port);
+ ALOGI("Opening loopback port %d\n", s_port);
break;
case 'd':
s_device_path = optarg;
- LOGI("Opening tty device %s\n", s_device_path);
+ ALOGI("Opening tty device %s\n", s_device_path);
break;
case 's':
s_device_path = optarg;
s_device_socket = 1;
- LOGI("Opening socket %s\n", s_device_path);
+ ALOGI("Opening socket %s\n", s_device_path);
break;
default: