/**
 * RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING
 *
 * Turn on STK unsol commands.
 */
void requestStkIsRunning(void *data, size_t datalen, RIL_Token t)
{
    char *cmd;
    int err;
    ATResponse *atresponse = NULL;

    asprintf(&cmd, "AT*STKC=1,\"000000000000000000\"");
    err = at_send_command(cmd, &atresponse);
    free(cmd);

    if (err < 0 || atresponse->success == 0)
        goto error;

    /* Android 2.1 does not handle the response to this RIL command
       This is seen as an error message in the radio log:
       "[0001]< RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING exception, possible 
       invalid RIL response" */
    RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);

  finally:
    at_response_free(atresponse);

    return;

  error:
    RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
    goto finally;
}
Beispiel #2
0
void requestExplicitCallTransfer(void *data, size_t datalen, RIL_Token t)
{
	/* MTK proprietary start */
	int ret;
	ATResponse *p_response = NULL;

        //BEGIN mtk03923 [20120210][ALPS00114093]
        if (inDTMF) {
	    RIL_onRequestComplete(t, RIL_E_CANCELLED, NULL, 0);     // RIL_E_GENERIC_FAILURE
            return;
        }
        //END   mtk03923 [20120210][ALPS00114093]


	ret = at_send_command("AT+CHLD=4", &p_response, CC_CHANNEL_CTX);

	if (ret < 0 || p_response->success == 0)
		goto error;

	RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
	at_response_free(p_response);
	return;

error:
	RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
	at_response_free(p_response);
	/* MTK proprietary end */
}
Beispiel #3
0
void  requestSendUSSD(void *data, size_t datalen, RIL_Token t)
{
	ATResponse *p_response = NULL;
	int err = 0;
	char* ussdRequest;
	char* cmd;

	at_send_command("AT+CSCS=\"GSM\"", NULL);
	ussdStatus = 1;

	ussdRequest = (char*)(data);
	asprintf(&cmd, "AT+CUSD=1,%s,15", ussdRequest);
	err = at_send_command(cmd, &p_response);
	free(cmd);


	if (err < 0 || p_response->success == 0) {
		goto error;
	}
	
    RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
    at_response_free(p_response);
    return;
	
error:
    at_response_free(p_response);
	RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);

}
Beispiel #4
0
void requestGSMSetBroadcastSMSConfig(void *data, size_t datalen, RIL_Token t)
{
	ATResponse *atresponse = NULL;
	int err;
	char *cmd;
	RIL_GSM_BroadcastSmsConfigInfo* configInfo = (RIL_GSM_BroadcastSmsConfigInfo*)data;

	if (!configInfo->selected)
		goto error;

	/* TODO Should this test be done or shall we just let the modem return error. */       
	if ((configInfo->toServiceId - configInfo->fromServiceId) > 10)
		goto error;

	asprintf(&cmd, "AT+CSCB=0,\"%d-%d\",\"%d-%d\"", configInfo->fromServiceId, configInfo->toServiceId, configInfo->fromCodeScheme, configInfo->toCodeScheme);

	err = at_send_command(cmd, &atresponse);

	if (err < 0 || atresponse->success == 0)
		goto error;

	RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);

finally:
	at_response_free(atresponse);
	return;

error:
	RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
	goto finally;
}
/**
 * RIL_REQUEST_STK_SET_PROFILE
 *
 * Download the STK terminal profile as part of SIM initialization
 * procedure.
 */
void requestStkSetProfile(void *data, size_t datalen, RIL_Token t)
{
#ifdef USE_U8500_RIL
    /* Currently this request is not supported. */
    RIL_onRequestComplete(t, RIL_E_REQUEST_NOT_SUPPORTED, NULL, 0);

    return;
#else
    char *cmd;
    int err;
    ATResponse *atresponse = NULL;
    const char *profile = (const char *) data;

    asprintf(&cmd, "AT*STKC=0,\"%s\"", profile);
    err = at_send_command(cmd, &atresponse);
    free(cmd);

    if (err < 0 || atresponse->success == 0)
    goto error;

    RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);

  finally:
    at_response_free(atresponse);

    return;

  error:
    RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
  goto finally;
#endif
}
Beispiel #6
0
static void requestSMSAcknowledge(void *data, size_t datalen, RIL_Token t)
{
    int ackSuccess = ((int *)data)[0];
    LOGV("requestSMSAcknowledge()");

    if (ackSuccess == 1)
    {
        if(ipcFixSMS() != 0)
        {
            LOGE("requestSMSAcknowledge() ipcFixSMS() failed");
            goto error;
        }
        LOGD("requestSMSAcknowledge() sending SMS_ACKNOWLEDGE\n");
    }
    else if (ackSuccess == 0) {
        LOGD("requestSMSAcknowledge() not sending SMS_ACKNOWLEDGE\n");
    }
    else {
        LOGE("unsupported arg to RIL_REQUEST_SMS_ACKNOWLEDGE\n");
        goto error;
    }

    LOGV("requestSMSAcknowledge() sucsessfull");
    RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
    return;
error:
    RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
}
Beispiel #7
0
void requestWriteSmsToSim(void *data, size_t datalen, RIL_Token t)
{
	RIL_SMS_WriteArgs *p_args;
	char *cmd;
	int length;
	int err;
	ATResponse *p_response = NULL;

	p_args = (RIL_SMS_WriteArgs *)data;

	length = strlen(p_args->pdu)/2;
	asprintf(&cmd, "AT+CMGW=%d,%d", length, p_args->status);

	err = at_send_command_sms(cmd, p_args->pdu, "+CMGW:", &p_response);

	if (err != 0 || p_response->success == 0) goto error;

	RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
	at_response_free(p_response);

	return;
error:
	RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
	at_response_free(p_response);
}
/**
 * RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL
 *
 * Manually select a specified network.
 *
 * The radio baseband/RIL implementation is expected to fall back to
 * automatic selection mode if the manually selected network should go
 * out of range in the future.
 */
void requestSetNetworkSelectionManual(void *data, size_t datalen,
                                      RIL_Token t)
{
    /*
     * AT+COPS=[<mode>[,<format>[,<oper>[,<AcT>]]]]
     *    <mode>   = 4 = Manual (<oper> field shall be present and AcT optionally) with fallback to automatic if manual fails.
     *    <format> = 2 = Numeric <oper>, the number has structure:
     *                   (country code digit 3)(country code digit 2)(country code digit 1)
     *                   (network code digit 2)(network code digit 1)
     */

    (void) datalen;
    int err = 0;
    const char *mccMnc = (const char *) data;

    /* Check inparameter. */
    if (mccMnc == NULL)
        goto error;

    /* Build and send command. */
    err = at_send_command("AT+COPS=1,2,\"%s\"", mccMnc);
    if (err != AT_NOERROR)
        goto error;

    RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
    return;

error:
    RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
}
/**
 * RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE
 *
 * Requests to send a terminal response to SIM for a received
 * proactive command.
 */
void requestStkSendTerminalResponse(void *data, size_t datalen,
                                    RIL_Token t)
{
    char *cmd;
    int err;
    ATResponse *atresponse = NULL;
    const char *stkResponse = (const char *) data;

    asprintf(&cmd, "AT*STKR=\"%s\"", stkResponse);
    err = at_send_command(cmd, &atresponse);
    free(cmd);

    if (err < 0 || atresponse->success == 0)
        goto error;

    RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);

  finally:
    at_response_free(atresponse);

    return;

  error:
    RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
    goto finally;
}
void ipc_gprs_pdp_context_enable_complete(struct ipc_message_info *info)
{
	struct ipc_gen_phone_res *phone_res = (struct ipc_gen_phone_res *) info->data;
	struct ril_gprs_connection *gprs_connection;
	int rc;

	gprs_connection = ril_gprs_connection_get_token(reqGetToken(info->aseq));

	if(!gprs_connection) {
		LOGE("Unable to find GPRS connection, aborting");

		RIL_onRequestComplete(reqGetToken(info->aseq),
			RIL_E_GENERIC_FAILURE, NULL, 0);
		return;
	}

	rc = ipc_gen_phone_res_check(phone_res);
	if(rc < 0) {
		LOGE("There was an error, aborting PDP context complete");

		gprs_connection->fail_cause = PDP_FAIL_ERROR_UNSPECIFIED;
		gprs_connection->token = (RIL_Token) 0x00;
		ril_state.gprs_last_failed_cid = gprs_connection->cid;

		RIL_onRequestComplete(reqGetToken(info->aseq),
			RIL_E_GENERIC_FAILURE, NULL, 0);
		return;
	}

	LOGD("Waiting for IP configuration!");
}
/**
 * Poll +COPS? and return a success, or if the loop counter reaches
 * REPOLL_OPERATOR_SELECTED, return generic failure.
 */
static void pollOperatorSelected(void *params)
{
    int err = 0;
    int response = 0;
    char *line = NULL;
    ATResponse *atresponse = NULL;
    struct operatorPollParams *poll_params;
    RIL_Token t;

    assert(params != NULL);

    poll_params = (struct operatorPollParams *) params;
    t = poll_params->t;

    if (poll_params->loopcount >= REPOLL_OPERATOR_SELECTED)
        goto error;

    err = at_send_command_singleline("AT+COPS?", "+COPS:", &atresponse);
    if (err != AT_NOERROR)
        goto error;

    line = atresponse->p_intermediates->line;

    err = at_tok_start(&line);
    if (err < 0)
        goto error;

    err = at_tok_nextint(&line, &response);
    if (err < 0)
        goto error;

    /* If we don't get more than the COPS: {0-4} we are not registered.
       Loop and try again. */
    if (!at_tok_hasmore(&line)) {
        switch (s_registrationDeniedReason) {
        case IMSI_UNKNOWN_IN_HLR: /* fall through */
        case ILLEGAL_ME:
            RIL_onRequestComplete(t, RIL_E_ILLEGAL_SIM_OR_ME, NULL, 0);
            free(poll_params);
            break;
        default:
            poll_params->loopcount++;
            enqueueRILEvent(RIL_EVENT_QUEUE_PRIO, pollOperatorSelected,
                            poll_params, &TIMEVAL_OPERATOR_SELECT_POLL);
        }
    } else {
        /* We got operator, throw a success! */
        RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
        free(poll_params);
    }

    at_response_free(atresponse);
    return;

error:
    RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
    free(poll_params);
    at_response_free(atresponse);
    return;
}
void ipc_gprs_pdp_context_disable_complete(struct ipc_message_info *info)
{
	struct ipc_gen_phone_res *phone_res = (struct ipc_gen_phone_res *) info->data;
	struct ril_gprs_connection *gprs_connection;
	int rc;

	gprs_connection = ril_gprs_connection_get_token(reqGetToken(info->aseq));

	if(!gprs_connection) {
		LOGE("Unable to find GPRS connection, aborting");

		RIL_onRequestComplete(reqGetToken(info->aseq),
			RIL_E_GENERIC_FAILURE, NULL, 0);
		return;
	}

	rc = ipc_gen_phone_res_check(phone_res);
	if(rc < 0) {
		LOGE("There was an error, aborting PDP context complete");

		// RILJ is not going to ask for fail reason
		ril_gprs_connection_del(gprs_connection);

		RIL_onRequestComplete(reqGetToken(info->aseq),
			RIL_E_GENERIC_FAILURE, NULL, 0);
		return;
	}

	LOGD("Waiting for GPRS call status");
}
/**
 * RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM
 *
 * When STK application gets RIL_UNSOL_STK_CALL_SETUP, the call actually has
 * been initialized by ME already. (We could see the call has been in the 'call
 * list') So, STK application needs to accept/reject the call according as user
 * operations.
 */
void requestStkHandleCallSetupRequestedFromSIM(void *data,
                                               size_t datalen, RIL_Token t)
{
    char *cmd;
    int err;
    int answer = 0;
    ATResponse *atresponse = NULL;

    if(((int *)data)[0] > 0 ){
        answer = 1;
    }
    asprintf(&cmd, "AT*ESHLVOCR=%d", answer);
    err = at_send_command(cmd, &atresponse);
    free(cmd);

    if (err < 0 || atresponse->success == 0)
        goto error;

    RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);

  finally:
    at_response_free(atresponse);

    return;

  error:
    RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
    goto finally;
}
void requestChangePassword(void *data, size_t datalen, RIL_Token t,
                           char *facility, int request)
{
    int err = 0;
    char *oldPassword = NULL;
    char *newPassword = NULL;
    int num_retries = -1;

    if (datalen != 3 * sizeof(char *) || strlen(facility) != 2)
        goto error;


    oldPassword = ((char **) data)[0];
    newPassword = ((char **) data)[1];

    err = at_send_command("AT+CPWD=\"%s\",\"%s\",\"%s\"", facility,
                oldPassword, newPassword);
    if (err != AT_NOERROR)
        goto error;

    num_retries = getNumRetries(request);
    RIL_onRequestComplete(t, RIL_E_SUCCESS, &num_retries, sizeof(int *));

    return;

error:
    if (at_get_cme_error(err) == CME_INCORRECT_PASSWORD) {
        num_retries = getNumRetries(request);
        RIL_onRequestComplete(t, RIL_E_PASSWORD_INCORRECT, &num_retries, sizeof(int *));
    } else
        RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
}
Beispiel #15
0
void requestSwitchWaitingOrHoldingAndActive(void *data, size_t datalen, RIL_Token t)
{
	int ret;
	ATResponse *p_response = NULL;

        //BEGIN mtk03923 [20120210][ALPS00114093]
        if (inDTMF) {
	    RIL_onRequestComplete(t, RIL_E_CANCELLED, NULL, 0);     // RIL_E_GENERIC_FAILURE
            return;
        }
        //END   mtk03923 [20120210][ALPS00114093]


	ret = at_send_command("AT+CHLD=2", &p_response, CC_CHANNEL_CTX);

	if (ret < 0 || p_response->success == 0)
		goto error;

#ifdef WORKAROUND_ERRONEOUS_ANSWER
	s_expectAnswer = 1;
#endif  /* WORKAROUND_ERRONEOUS_ANSWER */

	RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
	at_response_free(p_response);
	return;

error:
	RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
	at_response_free(p_response);
}
Beispiel #16
0
void requestGetSMSCAddress(void *data, size_t datalen, RIL_Token t)
{
	ATResponse *atresponse = NULL;
	int err;
	char *line;
	char *response;

	err = at_send_command_singleline("AT+CSCA?", "+CSCA:", &atresponse);

	if (err < 0 || atresponse->success == 0)
		goto error;

	line = atresponse->p_intermediates->line;

	err = at_tok_start(&line);
	if (err < 0)
		goto error;

	err = at_tok_nextstr(&line, &response);
	if (err < 0)
		goto error;

	RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(char *));

finally:
	at_response_free(atresponse);
	return;

error:
	RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
	goto finally;
}
Beispiel #17
0
/**
 * RIL_REQUEST_SET_TTY_MODE
 *
 * Ask the modem to set the TTY mode
 */
void requestSetTtyMode(void *data, size_t datalen, RIL_Token t)
{
    int err;
    ATResponse *atresponse = NULL;
    int mode = ((int *) data)[0];

    /*
     * The modem supports one TTY mode where voice and TTY tones are
     * automatically detected. FULL (1), HCO (2) and VCO (3) are therefore
     * automatically handled by the modem TTY enabled mode (1).
     */
    err = at_send_command(mode?"AT*ETTY=1":"AT*ETTY=0", &atresponse);

    if (err < 0 || atresponse->success == 0)
        goto error;

    s_ttyMode = mode;

    RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);

finally:
    at_response_free(atresponse);
    return;

error:
    RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
    goto finally;
}
Beispiel #18
0
void requestSeparateConnection(void *data, size_t datalen, RIL_Token t)
{
	char cmd[12];
	int party = ((int *)data)[0];
	int ret;
	ATResponse *p_response = NULL;

        //BEGIN mtk03923 [20120210][ALPS00114093]
        if (inDTMF) {
	    RIL_onRequestComplete(t, RIL_E_CANCELLED, NULL, 0);     // RIL_E_GENERIC_FAILURE
            return;
        }
        //END   mtk03923 [20120210][ALPS00114093]


	// Make sure that party is in a valid range.
	// (Note: The Telephony middle layer imposes a range of 1 to 7.
	// It's sufficient for us to just make sure it's single digit.)
	if (party > 0 && party < 10) {
		sprintf(cmd, "AT+CHLD=2%d", party);
		ret = at_send_command(cmd, &p_response, CC_CHANNEL_CTX);

		if (ret < 0 || p_response->success == 0) {
			at_response_free(p_response);
			goto error;
		}

		RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
		at_response_free(p_response);
		return;
	}

error:
	RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
}
Beispiel #19
0
	/**
	 * RIL_REQUEST_SET_LOCATION_UPDATES
	 *
	 * Enables/disables network state change notifications due to changes in
	 * LAC and/or CID (basically, +CREG=2 vs. +CREG=1).  
	 *
	 * Note:  The RIL implementation should default to "updates enabled"
	 * when the screen is on and "updates disabled" when the screen is off.
	 *
	 * See also: RIL_REQUEST_SCREEN_STATE, RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED.
	 */
void requestSetLocationUpdates(void *data, size_t datalen, RIL_Token t)
{
	int enable = 0;
	int err = 0;
	char *cmd;
	ATResponse *atresponse = NULL;

	enable = ((int *) data)[0];
	assert(enable == 0 || enable == 1);

	asprintf(&cmd, "AT+CREG=%d", (enable == 0 ? 1 : 2));
	err = at_send_command(cmd, &atresponse);
	free(cmd);

	if (err < 0 || atresponse->success == 0)
		goto error;

	RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);

finally:
	at_response_free(atresponse);
	return;

error:
	RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
	goto finally;
}
Beispiel #20
0
void StkSendRequestComplete(int err, ATResponse *p_response, RIL_Token t)
{
    if (err < 0 || p_response->success == 0) {
        RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
    } else {
        RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
    }
}
/**
 * RIL_REQUEST_SIGNAL_STRENGTH
 *
 * Requests current signal strength and bit error rate.
 *
 * Must succeed if radio is on.
 */
void requestSignalStrength(void *data, size_t datalen, RIL_Token t)
{
    (void) data; (void) datalen;
    RIL_SignalStrength_v6 signalStrength;

    if (getSignalStrength(&signalStrength) < 0) {
        LOGE("%s() Must never return an error when radio is on", __func__);
        RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
    } else
        RIL_onRequestComplete(t, RIL_E_SUCCESS, &signalStrength,
                              sizeof(RIL_SignalStrength_v6));
}
/**
 * RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE
 *
 * Query the preferred network type (CS/PS domain, RAT, and operation mode)
 * for searching and registering.
 */
void requestGetPreferredNetworkType(void *data, size_t datalen,
                                    RIL_Token t)
{
    (void) data; (void) datalen;
    int err = 0;
    int response = 0;
    int cfun;
    char *line;
    ATResponse *atresponse;

    err = at_send_command_singleline("AT+CFUN?", "+CFUN:", &atresponse);
    if (err != AT_NOERROR)
        goto error;

    line = atresponse->p_intermediates->line;

    err = at_tok_start(&line);
    if (err < 0)
        goto error;

    err = at_tok_nextint(&line, &cfun);
    if (err < 0)
        goto error;

    if (cfun < 0 || cfun >= 7)
        goto error;

    switch (cfun) {
    case PREF_NET_TYPE_2G_ONLY:
        response = PREF_NET_TYPE_GSM_ONLY;
        break;
    case PREF_NET_TYPE_3G_ONLY:
        response = PREF_NET_TYPE_WCDMA;
        break;
    case PREF_NET_TYPE_3G:
        response = PREF_NET_TYPE_GSM_WCDMA_AUTO;
        break;
    default:
        response = PREF_NET_TYPE_GSM_WCDMA_AUTO;
        break;
    }

    RIL_onRequestComplete(t, RIL_E_SUCCESS, &response, sizeof(int));

finally:
    at_response_free(atresponse);
    return;

error:
    RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
    goto finally;
}
Beispiel #23
0
	/**
	 * RIL_REQUEST_QUERY_FACILITY_LOCK
	 *
	 * Query the status of a facility lock state.
	 */
void requestQueryFacilityLock(void *data, size_t datalen, RIL_Token t)
{
	int err, rat, response;
	ATResponse *atresponse = NULL;
	char *cmd = NULL;
	char *line = NULL;
	char *facility_string = NULL;
	char *facility_password = NULL;
	char *facility_class = NULL;

	assert(datalen >= (3 * sizeof(char **)));

	facility_string = ((char **) data)[0];
	facility_password = ((char **) data)[1];
	facility_class = ((char **) data)[2];

	/* do not support FD string, force copy string SC */
	if(strcmp(facility_string, "FD") == 0){
		strcpy(facility_string, "SC");
	}

	asprintf(&cmd, "AT+CLCK=\"%s\",2,\"%s\",%s", facility_string,
			facility_password, facility_class);

	err = at_send_command_singleline(cmd, "+CLCK:", &atresponse);
	free(cmd);
	if (err < 0 || atresponse->success == 0) {
		goto error;
	}

	line = atresponse->p_intermediates->line;

	err = at_tok_start(&line);
	if (err < 0)
		goto error;

	err = at_tok_nextint(&line, &response);
	if (err < 0)
		goto error;

	RIL_onRequestComplete(t, RIL_E_SUCCESS, &response, sizeof(int));

finally:
	at_response_free(atresponse);
	return;

error:
	RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
	goto finally;
}
void hackDeactivateData(void *data, size_t datalen, RIL_Token t)
{
	int err;
	char * cmd;
	char * cid;
	int fd,i,fd2;
	ATResponse *p_response = NULL;

	ALOGW("DeactivateData");

	cid = ((char **)data)[0];
	asprintf(&cmd, "AT+CGACT=0,%s", cid);
    send_modem(cmd);
    free(cmd);

    // kill monitor process
    ALOGD("Deactdata:killing monitor");
    kill(monitor_pid, SIGTERM);
    waitpid(monitor_pid, NULL, 0);
    monitor_pid = 0;

    // kill remaining pppd
    ALOGD("Deactdata:killing pppd");
	system("killall pppd");
	sleep(1);

	i=0;
	while((fd = open("/etc/ppp/ppp0.pid",O_RDONLY)) > 0) {
		if(i%5 == 0) {
			system("killall pppd");
		}
		close(fd);
		if(i>25)
			goto error;
		i++;
		sleep(1);
	}

	ALOGD("Deactdata done, waiting 10 sec to let pppd die");
    is_data_active = 0;

    sleep(10);

	RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
	return;

	error:
		RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
}
Beispiel #25
0
void requestDeleteSmsOnSim(void *data, size_t datalen, RIL_Token t)
{
	char * cmd;
	int err;
	ATResponse * p_response = NULL;
	asprintf(&cmd, "AT+CMGD=%d", ((int *)data)[0]);
	err = at_send_command(cmd, &p_response);
	free(cmd);
	if (err < 0 || p_response->success == 0) {
		RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
	} else {
		RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
	}
	at_response_free(p_response);
}
/**
 * Enter SIM PIN, might be PIN, PIN2, PUK, PUK2, etc.
 *
 * Data can hold pointers to one or two strings, depending on what we
 * want to enter. (PUK requires new PIN, etc.).
 *
 * FIXME: Do we need to return remaining tries left on error as well?
 *        Also applies to the rest of the requests that got the retries
 *        in later commits to ril.h.
 */
void requestEnterSimPin(void *data, size_t datalen, RIL_Token t, int request)
{
    int err = 0;
    int cme_err;
    const char **strings = (const char **) data;
    int num_retries = -1;

    if (datalen == sizeof(char *)) {
        err = at_send_command("AT+CPIN=\"%s\"", strings[0]);
    } else if (datalen == 2 * sizeof(char *)) {
        if(!strings[1]){
            err = at_send_command("AT+CPIN=\"%s\"", strings[0]);
        } else {
            err = at_send_command("AT+CPIN=\"%s\",\"%s\"", strings[0], strings[1]);
        }
    } else if (datalen == 3 * sizeof(char *)) {
            err = at_send_command("AT+CPIN=\"%s\",\"%s\"", strings[0], strings[1]);
    } else
        goto error;

    cme_err = at_get_cme_error(err);

    if (cme_err != CME_ERROR_NON_CME && err != AT_NOERROR) {
        switch (cme_err) {
        case CME_SIM_PIN_REQUIRED:
        case CME_SIM_PUK_REQUIRED:
        case CME_INCORRECT_PASSWORD:
        case CME_SIM_PIN2_REQUIRED:
        case CME_SIM_PUK2_REQUIRED:
            num_retries = getNumRetries (request);
            RIL_onRequestComplete(t, RIL_E_PASSWORD_INCORRECT, &num_retries, sizeof(int *));
            break;
        default:
            goto error;
        }
    } else {
        /*
         * Got OK, return success and wait for *EPEV to trigger poll
         * of SIM state.
         */

        num_retries = getNumRetries (request);
        RIL_onRequestComplete(t, RIL_E_SUCCESS, &num_retries, sizeof(int *));
    }
    return;
error:
    RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
}
void onRequest(int request, void *data, size_t datalen, RIL_Token t) {
    if(!rmnet_mode){
        if(request==RIL_REQUEST_SETUP_DATA_CALL){ // Let's have fun !
            hackSetupData(data, datalen, t);
            return;
        } else if(request==RIL_REQUEST_DEACTIVATE_DATA_CALL) {
            hackDeactivateData(data, datalen, t);
            return;
        } else if(request == RIL_REQUEST_REGISTRATION_STATE) {
            hackOnRequestRegistrationState(data, datalen, t);
            htc_onRequest(request, data, datalen, t);
            return;
        } else if(request == RIL_REQUEST_DATA_CALL_LIST) {
            // cheat here
            ALOGW("*** Request call list, fake reply ***");
            RIL_Data_Call_Response data_call;
            data_call.cid = 1;
            data_call.active = 1;
            data_call.type = "IP";
            data_call.apn = current_apn;
            data_call.address = "";
            RIL_onRequestComplete(t, RIL_E_SUCCESS, &data_call, sizeof(data_call));
            return;
        }
    }
	return htc_onRequest(request, data, datalen, t);
}
void ril_request_deactivate_data_call(RIL_Token t, void *data, int length)
{
	struct ril_gprs_connection *gprs_connection;
	struct ipc_gprs_pdp_context_set context;

	char *cid = ((char **) data)[0];
	int rc;

	gprs_connection = ril_gprs_connection_get_cid(atoi(cid));

	if(!gprs_connection) {
		LOGE("Unable to find GPRS connection, aborting");

		RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
		return;
	}

	gprs_connection->token = t;

	ipc_gprs_pdp_context_setup(&context, gprs_connection->cid, 0, NULL, NULL);

	ipc_gen_phone_res_expect_to_func(reqGetId(t), IPC_GPRS_PDP_CONTEXT,
		ipc_gprs_pdp_context_disable_complete);

	ipc_fmt_send(IPC_GPRS_PDP_CONTEXT, IPC_TYPE_SET,
		(void *) &context, sizeof(struct ipc_gprs_pdp_context_set), reqGetId(t));
}
Beispiel #29
0
void requestSetAudioPath(int *data, size_t datalen, RIL_Token t)
{
	ATResponse *p_response = NULL;
	int err;	
	char *cmd;

	int path = data[0];
	int channel = 1;

	switch(path){
		case SOUND_AUDIO_PATH_HANDSET:
			channel = 0;
			break;
		case SOUND_AUDIO_PATH_SPEAKER:
		case SOUND_AUDIO_PATH_HEADSET:
			channel = 1;
			break;
		case SOUND_AUDIO_PATH_BLUETOOTH:
		case SOUND_AUDIO_PATH_BLUETOOTH_NO_NR:
			channel = 2;
			break;
	}
	switchToChannel(channel,-1);
	RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
}
/**
 * RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE
 *
 * Requests to set the preferred network type for searching and registering
 * (CS/PS domain, RAT, and operation mode).
 */
void requestSetPreferredNetworkType(void *data, size_t datalen,
                                    RIL_Token t)
{
    (void) datalen;
    int arg = 0;
    int err = 0;
    int rat;

    rat = ((int *) data)[0];

    switch (rat) {
    case PREF_NET_TYPE_GSM_WCDMA_AUTO:
    case PREF_NET_TYPE_GSM_WCDMA:
        arg = PREF_NET_TYPE_3G;
        LOGD("[%s] network type = auto", __FUNCTION__);
        break;
    case PREF_NET_TYPE_GSM_ONLY:
        arg = PREF_NET_TYPE_2G_ONLY;
        LOGD("[%s] network type = 2g only", __FUNCTION__);
        break;
    case PREF_NET_TYPE_WCDMA:
        arg = PREF_NET_TYPE_3G_ONLY;
        LOGD("[%s] network type = 3g only", __FUNCTION__);
        break;
    default:
        LOGW("[%s] unknown network type: (%d)", __FUNCTION__, rat);
    }
    pref_net_type = arg;
    err = at_send_command("AT+CFUN=%d", arg);
    RIL_onRequestComplete(t, (err == AT_NOERROR)? RIL_E_SUCCESS : RIL_E_GENERIC_FAILURE, NULL, 0);
    return;
}