Search in sources :

Example 1 with DataCallResponse

use of android.telephony.data.DataCallResponse in project android_frameworks_opt_telephony by LineageOS.

the class DataConnectionTest method testModemSuggestRetry.

@Test
@SmallTest
public void testModemSuggestRetry() throws Exception {
    DataCallResponse response = new DataCallResponse.Builder().setCause(0).setSuggestedRetryTime(0).setId(1).setLinkStatus(2).setProtocolType(ApnSetting.PROTOCOL_IP).setInterfaceName(FAKE_IFNAME).setAddresses(Arrays.asList(new LinkAddress(InetAddresses.parseNumericAddress(FAKE_ADDRESS), 0))).setDnsAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_DNS))).setGatewayAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_GATEWAY))).setPcscfAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_PCSCF_ADDRESS))).setMtuV4(1440).setMtuV6(1440).build();
    assertEquals(response.getSuggestedRetryTime(), getSuggestedRetryDelay(response));
    response = new DataCallResponse.Builder().setCause(0).setSuggestedRetryTime(1000).setId(1).setLinkStatus(2).setProtocolType(ApnSetting.PROTOCOL_IP).setInterfaceName(FAKE_IFNAME).setAddresses(Arrays.asList(new LinkAddress(InetAddresses.parseNumericAddress(FAKE_ADDRESS), 0))).setDnsAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_DNS))).setGatewayAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_GATEWAY))).setPcscfAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_PCSCF_ADDRESS))).setMtuV4(1440).setMtuV6(1440).build();
    assertEquals(response.getSuggestedRetryTime(), getSuggestedRetryDelay(response));
    response = new DataCallResponse.Builder().setCause(0).setSuggestedRetryTime(9999).setId(1).setLinkStatus(2).setProtocolType(ApnSetting.PROTOCOL_IP).setInterfaceName(FAKE_IFNAME).setAddresses(Arrays.asList(new LinkAddress(InetAddresses.parseNumericAddress(FAKE_ADDRESS), 0))).setDnsAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_DNS))).setGatewayAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_GATEWAY))).setPcscfAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_PCSCF_ADDRESS))).setMtuV4(1440).setMtuV6(1440).build();
    assertEquals(response.getSuggestedRetryTime(), getSuggestedRetryDelay(response));
}
Also used : DataCallResponse(android.telephony.data.DataCallResponse) LinkAddress(android.net.LinkAddress) TelephonyTest(com.android.internal.telephony.TelephonyTest) MediumTest(android.test.suitebuilder.annotation.MediumTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 2 with DataCallResponse

use of android.telephony.data.DataCallResponse in project android_frameworks_opt_telephony by LineageOS.

the class RadioIndication method responseDataCallListChanged.

private void responseDataCallListChanged(int indicationType, List<?> dcList) {
    mRil.processIndication(indicationType);
    if (RIL.RILJ_LOGD)
        mRil.unsljLogRet(RIL_UNSOL_DATA_CALL_LIST_CHANGED, dcList);
    ArrayList<DataCallResponse> response = RIL.convertDataCallResultList(dcList);
    mRil.mDataCallListChangedRegistrants.notifyRegistrants(new AsyncResult(null, response, null));
}
Also used : DataCallResponse(android.telephony.data.DataCallResponse) AsyncResult(android.os.AsyncResult)

Example 3 with DataCallResponse

use of android.telephony.data.DataCallResponse in project android_frameworks_opt_telephony by LineageOS.

the class DataConnection method connect.

/**
 * Begin setting up a data connection, calls setupDataCall
 * and the ConnectionParams will be returned with the
 * EVENT_SETUP_DATA_CONNECTION_DONE
 *
 * @param cp is the connection parameters
 *
 * @return Fail cause if failed to setup data connection. {@link DataFailCause#NONE} if success.
 */
@DataFailureCause
private int connect(ConnectionParams cp) {
    log("connect: carrier='" + mApnSetting.getEntryName() + "' APN='" + mApnSetting.getApnName() + "' proxy='" + mApnSetting.getProxyAddressAsString() + "' port='" + mApnSetting.getProxyPort() + "'");
    if (cp.mApnContext != null)
        cp.mApnContext.requestLog("DataConnection.connect");
    // Check if we should fake an error.
    if (mDcTesterFailBringUpAll.getDcFailBringUp().mCounter > 0) {
        DataCallResponse response = new DataCallResponse.Builder().setCause(mDcTesterFailBringUpAll.getDcFailBringUp().mFailCause).setSuggestedRetryTime(mDcTesterFailBringUpAll.getDcFailBringUp().mSuggestedRetryTime).setMtuV4(PhoneConstants.UNSET_MTU).setMtuV6(PhoneConstants.UNSET_MTU).build();
        Message msg = obtainMessage(EVENT_SETUP_DATA_CONNECTION_DONE, cp);
        AsyncResult.forMessage(msg, response, null);
        sendMessage(msg);
        if (DBG) {
            log("connect: FailBringUpAll=" + mDcTesterFailBringUpAll.getDcFailBringUp() + " send error response=" + response);
        }
        mDcTesterFailBringUpAll.getDcFailBringUp().mCounter -= 1;
        return DataFailCause.NONE;
    }
    mCreateTime = -1;
    mLastFailTime = -1;
    mLastFailCause = DataFailCause.NONE;
    Message msg = obtainMessage(EVENT_SETUP_DATA_CONNECTION_DONE, cp);
    msg.obj = cp;
    DataProfile dp = DcTracker.createDataProfile(mApnSetting, cp.mProfileId, cp.mIsPreferredApn);
    // We need to use the actual modem roaming state instead of the framework roaming state
    // here. This flag is only passed down to ril_service for picking the correct protocol (for
    // old modem backward compatibility).
    boolean isModemRoaming = mPhone.getServiceState().getDataRoamingFromRegistration();
    // If the apn is NOT metered, we will allow data roaming regardless of the setting.
    boolean isUnmeteredApnType = !ApnSettingUtils.isMeteredApnType(cp.mApnContext.getApnTypeBitmask(), mPhone);
    // Set this flag to true if the user turns on data roaming. Or if we override the roaming
    // state in framework, we should set this flag to true as well so the modem will not reject
    // the data call setup (because the modem actually thinks the device is roaming).
    boolean allowRoaming = mPhone.getDataRoamingEnabled() || (isModemRoaming && (!mPhone.getServiceState().getDataRoaming() || isUnmeteredApnType));
    if (DBG) {
        log("allowRoaming=" + allowRoaming + ", mPhone.getDataRoamingEnabled()=" + mPhone.getDataRoamingEnabled() + ", isModemRoaming=" + isModemRoaming + ", mPhone.getServiceState().getDataRoaming()=" + mPhone.getServiceState().getDataRoaming() + ", isUnmeteredApnType=" + isUnmeteredApnType);
    }
    // Check if this data setup is a handover.
    LinkProperties linkProperties = null;
    int reason = DataService.REQUEST_REASON_NORMAL;
    if (cp.mRequestType == DcTracker.REQUEST_TYPE_HANDOVER) {
        // If this is a data setup for handover, we need to pass the link properties
        // of the existing data connection to the modem.
        DcTracker dcTracker = mPhone.getDcTracker(getHandoverSourceTransport());
        if (dcTracker == null || cp.mApnContext == null) {
            loge("connect: Handover failed. dcTracker=" + dcTracker + ", apnContext=" + cp.mApnContext);
            return DataFailCause.HANDOVER_FAILED;
        }
        DataConnection dc = dcTracker.getDataConnectionByApnType(cp.mApnContext.getApnType());
        if (dc == null) {
            loge("connect: Can't find data connection for handover.");
            return DataFailCause.HANDOVER_FAILED;
        }
        // Preserve the potential network agent from the source data connection. The ownership
        // is not transferred at this moment.
        mHandoverSourceNetworkAgent = dc.getNetworkAgent();
        if (mHandoverSourceNetworkAgent == null) {
            loge("Cannot get network agent from the source dc " + dc.getName());
            return DataFailCause.HANDOVER_FAILED;
        }
        linkProperties = dc.getLinkProperties();
        if (linkProperties == null || linkProperties.getLinkAddresses().isEmpty()) {
            loge("connect: Can't find link properties of handover data connection. dc=" + dc);
            return DataFailCause.HANDOVER_FAILED;
        }
        mHandoverLocalLog.log("Handover started. Preserved the agent.");
        log("Get the handover source network agent: " + mHandoverSourceNetworkAgent);
        dc.setHandoverState(HANDOVER_STATE_BEING_TRANSFERRED);
        reason = DataService.REQUEST_REASON_HANDOVER;
    }
    mDataServiceManager.setupDataCall(ServiceState.rilRadioTechnologyToAccessNetworkType(cp.mRilRat), dp, isModemRoaming, allowRoaming, reason, linkProperties, msg);
    TelephonyMetrics.getInstance().writeSetupDataCall(mPhone.getPhoneId(), cp.mRilRat, dp.getProfileId(), dp.getApn(), dp.getProtocolType());
    return DataFailCause.NONE;
}
Also used : DataCallResponse(android.telephony.data.DataCallResponse) DataProfile(android.telephony.data.DataProfile) Message(android.os.Message) LinkProperties(android.net.LinkProperties) DataFailureCause(android.telephony.Annotation.DataFailureCause)

Example 4 with DataCallResponse

use of android.telephony.data.DataCallResponse in project android_frameworks_opt_telephony by LineageOS.

the class SimulatedCommands method setupDataCall.

@Override
public void setupDataCall(int accessNetworkType, DataProfile dataProfile, boolean isRoaming, boolean allowRoaming, int reason, LinkProperties linkProperties, Message result) {
    SimulatedCommandsVerifier.getInstance().setupDataCall(accessNetworkType, dataProfile, isRoaming, allowRoaming, reason, linkProperties, result);
    if (mSetupDataCallResult == null) {
        try {
            mSetupDataCallResult = new SetupDataCallResult();
            mSetupDataCallResult.status = 0;
            mSetupDataCallResult.suggestedRetryTime = -1;
            mSetupDataCallResult.cid = 1;
            mSetupDataCallResult.active = 2;
            mSetupDataCallResult.type = "IP";
            mSetupDataCallResult.ifname = "rmnet_data7";
            mSetupDataCallResult.addresses = "12.34.56.78";
            mSetupDataCallResult.dnses = "98.76.54.32";
            mSetupDataCallResult.gateways = "11.22.33.44";
            mSetupDataCallResult.pcscf = "fd00:976a:c305:1d::8 fd00:976a:c202:1d::7 fd00:976a:c305:1d::5";
            mSetupDataCallResult.mtu = 1440;
        } catch (Exception e) {
        }
    }
    // Store different cids to simulate concurrent IMS and default data calls
    if ((dataProfile.getSupportedApnTypesBitmask() & ApnSetting.TYPE_IMS) == ApnSetting.TYPE_IMS) {
        mSetupDataCallResult.cid = 0;
    } else {
        mSetupDataCallResult.cid = 1;
    }
    DataCallResponse response = RIL.convertDataCallResult(mSetupDataCallResult);
    if (mDcSuccess) {
        resultSuccess(result, response);
    } else {
        resultFail(result, response, new RuntimeException("Setup data call failed!"));
    }
}
Also used : DataCallResponse(android.telephony.data.DataCallResponse) SetupDataCallResult(android.hardware.radio.V1_0.SetupDataCallResult) CommandException(com.android.internal.telephony.CommandException)

Example 5 with DataCallResponse

use of android.telephony.data.DataCallResponse in project android_frameworks_opt_telephony by LineageOS.

the class TelephonyMetricsTest method testWriteOnSetupDataCallResponse.

// Test write on setup data call response
@Test
@SmallTest
public void testWriteOnSetupDataCallResponse() throws Exception {
    DataCallResponse response = new DataCallResponse.Builder().setCause(5).setSuggestedRetryTime(6).setId(7).setLinkStatus(8).setProtocolType(ApnSetting.PROTOCOL_IPV4V6).setInterfaceName(FAKE_IFNAME).setAddresses(Arrays.asList(new LinkAddress(InetAddresses.parseNumericAddress(FAKE_ADDRESS), 0))).setDnsAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_DNS))).setGatewayAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_GATEWAY))).setPcscfAddresses(Arrays.asList(InetAddresses.parseNumericAddress(FAKE_PCSCF_ADDRESS))).setMtuV4(1440).setMtuV6(1440).build();
    mMetrics.writeOnRilSolicitedResponse(mPhone.getPhoneId(), 1, 2, RIL_REQUEST_SETUP_DATA_CALL, response);
    TelephonyLog log = buildProto();
    assertEquals(1, log.events.length);
    assertEquals(0, log.callSessions.length);
    assertEquals(0, log.smsSessions.length);
    assertFalse(log.eventsDropped);
    TelephonyEvent.RilSetupDataCallResponse respProto = log.events[0].setupDataCallResponse;
    assertEquals(5, respProto.status);
    assertEquals(6, respProto.suggestedRetryTimeMillis);
    assertEquals(7, respProto.call.cid);
    assertEquals(PDP_TYPE_IPV4V6, respProto.call.type);
    assertEquals(FAKE_IFNAME, respProto.call.iframe);
}
Also used : DataCallResponse(android.telephony.data.DataCallResponse) LinkAddress(android.net.LinkAddress) TelephonyLog(com.android.internal.telephony.nano.TelephonyProto.TelephonyLog) TelephonyEvent(com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent) TelephonyTest(com.android.internal.telephony.TelephonyTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

DataCallResponse (android.telephony.data.DataCallResponse)16 LinkAddress (android.net.LinkAddress)10 SmallTest (android.test.suitebuilder.annotation.SmallTest)10 Test (org.junit.Test)9 TelephonyTest (com.android.internal.telephony.TelephonyTest)8 MediumTest (android.test.suitebuilder.annotation.MediumTest)6 LinkProperties (android.net.LinkProperties)4 AsyncResult (android.os.AsyncResult)2 SetupDataCallResult (android.hardware.radio.V1_0.SetupDataCallResult)1 Message (android.os.Message)1 Parcel (android.os.Parcel)1 DataFailureCause (android.telephony.Annotation.DataFailureCause)1 DataProfile (android.telephony.data.DataProfile)1 FlakyTest (androidx.test.filters.FlakyTest)1 CommandException (com.android.internal.telephony.CommandException)1 SmsResponse (com.android.internal.telephony.SmsResponse)1 TelephonyEvent (com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent)1 RilSetupDataCallResponse (com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent.RilSetupDataCallResponse)1 TelephonyLog (com.android.internal.telephony.nano.TelephonyProto.TelephonyLog)1 ArrayList (java.util.ArrayList)1