Search in sources :

Example 1 with DataProfile

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

the class DcTrackerTest method testDataRetry.

// Test the scenario where the first data call setup is failed, and then retry the setup later.
@Test
@MediumTest
public void testDataRetry() throws Exception {
    AsyncResult ar = new AsyncResult(null, new Pair<>(true, DataEnabledSettings.REASON_USER_DATA_ENABLED), null);
    mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_DATA_ENABLED_CHANGED, ar));
    waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
    // LOST_CONNECTION(0x10004) is a non-permanent failure, so we'll retry data setup later.
    SetupDataCallResult result = createSetupDataCallResult();
    result.status = 0x10004;
    // Simulate RIL fails the data call setup
    mSimulatedCommands.setDataCallResult(true, result);
    DataConnectionReasons dataConnectionReasons = new DataConnectionReasons();
    boolean allowed = isDataAllowed(dataConnectionReasons);
    assertFalse(dataConnectionReasons.toString(), allowed);
    logd("Sending EVENT_ENABLE_APN");
    // APN id 0 is APN_TYPE_DEFAULT
    mDct.enableApn(ApnSetting.TYPE_DEFAULT, DcTracker.REQUEST_TYPE_NORMAL, null);
    waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
    sendInitializationEvents();
    dataConnectionReasons = new DataConnectionReasons();
    allowed = isDataAllowed(dataConnectionReasons);
    assertTrue(dataConnectionReasons.toString(), allowed);
    ArgumentCaptor<DataProfile> dpCaptor = ArgumentCaptor.forClass(DataProfile.class);
    // Verify if RIL command was sent properly.
    verify(mSimulatedCommandsVerifier, times(1)).setupDataCall(eq(AccessNetworkType.EUTRAN), dpCaptor.capture(), eq(false), eq(false), eq(DataService.REQUEST_REASON_NORMAL), any(), any(Message.class));
    verifyDataProfile(dpCaptor.getValue(), FAKE_APN1, 0, 21, 1, NETWORK_TYPE_LTE_BITMASK);
    // This time we'll let RIL command succeed.
    mSimulatedCommands.setDataCallResult(true, createSetupDataCallResult());
    // Send event for reconnecting data
    initApns(PhoneConstants.APN_TYPE_DEFAULT, new String[] { PhoneConstants.APN_TYPE_ALL });
    mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_DATA_RECONNECT, mPhone.getPhoneId(), AccessNetworkConstants.TRANSPORT_TYPE_WWAN, mApnContext));
    waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
    // Data connection is running on a different thread. Have to wait.
    waitForMs(200);
    dpCaptor = ArgumentCaptor.forClass(DataProfile.class);
    // Verify if RIL command was sent properly.
    verify(mSimulatedCommandsVerifier, times(2)).setupDataCall(eq(AccessNetworkType.EUTRAN), dpCaptor.capture(), eq(false), eq(false), eq(DataService.REQUEST_REASON_NORMAL), any(), any(Message.class));
    verifyDataProfile(dpCaptor.getValue(), FAKE_APN2, 0, 21, 1, NETWORK_TYPE_LTE_BITMASK);
    // Verify connected with APN2 setting.
    verifyDataConnected(FAKE_APN2);
}
Also used : DataProfile(android.telephony.data.DataProfile) Message(android.os.Message) AsyncResult(android.os.AsyncResult) SetupDataCallResult(android.hardware.radio.V1_0.SetupDataCallResult) FlakyTest(androidx.test.filters.FlakyTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) MediumTest(android.test.suitebuilder.annotation.MediumTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 2 with DataProfile

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

the class DcTrackerTest method testRecoveryStepReRegister.

@Test
@SmallTest
public void testRecoveryStepReRegister() throws Exception {
    ContentResolver resolver = mContext.getContentResolver();
    Settings.Global.putInt(resolver, Settings.Global.DATA_STALL_RECOVERY_ON_BAD_NETWORK, 1);
    Settings.Global.putLong(resolver, Settings.Global.MIN_DURATION_BETWEEN_RECOVERY_STEPS_IN_MS, 100);
    Settings.System.putInt(resolver, "radio.data.stall.recovery.action", 2);
    doReturn(new SignalStrength()).when(mPhone).getSignalStrength();
    doReturn(PhoneConstants.State.IDLE).when(mPhone).getState();
    mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS, new String[] { PhoneConstants.APN_TYPE_DEFAULT, PhoneConstants.APN_TYPE_MMS });
    mDct.enableApn(ApnSetting.TYPE_DEFAULT, DcTracker.REQUEST_TYPE_NORMAL, null);
    sendInitializationEvents();
    ArgumentCaptor<DataProfile> dpCaptor = ArgumentCaptor.forClass(DataProfile.class);
    verify(mSimulatedCommandsVerifier, times(1)).setupDataCall(eq(AccessNetworkType.EUTRAN), dpCaptor.capture(), eq(false), eq(false), eq(DataService.REQUEST_REASON_NORMAL), any(), any(Message.class));
    verifyDataProfile(dpCaptor.getValue(), FAKE_APN1, 0, 21, 1, NETWORK_TYPE_LTE_BITMASK);
    logd("Sending EVENT_NETWORK_STATUS_CHANGED false");
    mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_NETWORK_STATUS_CHANGED, NetworkAgent.INVALID_NETWORK, 1, null));
    waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
    // expected to get preferred network type
    verify(mSST, times(1)).reRegisterNetwork(eq(null));
}
Also used : DataProfile(android.telephony.data.DataProfile) Message(android.os.Message) ContentResolver(android.content.ContentResolver) MockContentResolver(android.test.mock.MockContentResolver) SignalStrength(android.telephony.SignalStrength) FlakyTest(androidx.test.filters.FlakyTest) 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 3 with DataProfile

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

the class DataProfileTest method testEquals.

@SmallTest
public void testEquals() throws Exception {
    DataProfile dp1 = DcTracker.createDataProfile(mApn1, mApn1.getProfileId(), false);
    DataProfile dp2 = DcTracker.createDataProfile(mApn1, mApn1.getProfileId(), false);
    assertEquals(dp1, dp2);
    dp2 = DcTracker.createDataProfile(mApn2, mApn2.getProfileId(), false);
    assertFalse(dp1.equals(dp2));
}
Also used : DataProfile(android.telephony.data.DataProfile) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 4 with DataProfile

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

the class DataProfileTest method testCreateFromApnSetting.

@SmallTest
public void testCreateFromApnSetting() throws Exception {
    DataProfile dp = DcTracker.createDataProfile(mApn1, mApn1.getProfileId(), false);
    assertEquals(mApn1.getProfileId(), dp.getProfileId());
    assertEquals(mApn1.getApnName(), dp.getApn());
    assertEquals(mApn1.getProtocol(), dp.getProtocolType());
    assertEquals(RILConstants.SETUP_DATA_AUTH_PAP_CHAP, dp.getAuthType());
    assertEquals(mApn1.getUser(), dp.getUserName());
    assertEquals(mApn1.getPassword(), dp.getPassword());
    // TYPE_COMMON
    assertEquals(0, dp.getType());
    assertEquals(mApn1.getWaitTime(), dp.getWaitTime());
    assertEquals(mApn1.isEnabled(), dp.isEnabled());
    assertFalse(dp.isPersistent());
    assertFalse(dp.isPreferred());
}
Also used : DataProfile(android.telephony.data.DataProfile) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 5 with DataProfile

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

the class RILTest method testSetupDataCall.

@Test
public void testSetupDataCall() throws Exception {
    DataProfile dp = new DataProfile.Builder().setProfileId(PROFILE_ID).setApn(APN).setProtocolType(PROTOCOL).setAuthType(AUTH_TYPE).setUserName(USER_NAME).setPassword(PASSWORD).setType(TYPE).setMaxConnectionsTime(MAX_CONNS_TIME).setMaxConnections(MAX_CONNS).setWaitTime(WAIT_TIME).enable(APN_ENABLED).setSupportedApnTypesBitmask(SUPPORTED_APNT_YPES_BITMAK).setRoamingProtocolType(ROAMING_PROTOCOL).setBearerBitmask(BEARER_BITMASK).setMtu(MTU).setPersistent(PERSISTENT).setPreferred(false).build();
    mRILUnderTest.setupDataCall(AccessNetworkConstants.AccessNetworkType.EUTRAN, dp, false, false, 0, null, obtainMessage());
    ArgumentCaptor<DataProfileInfo> dpiCaptor = ArgumentCaptor.forClass(DataProfileInfo.class);
    verify(mRadioProxy).setupDataCall(mSerialNumberCaptor.capture(), eq(AccessNetworkConstants.AccessNetworkType.EUTRAN), dpiCaptor.capture(), eq(true), eq(false), eq(false));
    verifyRILResponse(mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_SETUP_DATA_CALL);
    DataProfileInfo dpi = dpiCaptor.getValue();
    assertEquals(PROFILE_ID, dpi.profileId);
    assertEquals(APN, dpi.apn);
    assertEquals(PROTOCOL, ApnSetting.getProtocolIntFromString(dpi.protocol));
    assertEquals(AUTH_TYPE, dpi.authType);
    assertEquals(USER_NAME, dpi.user);
    assertEquals(PASSWORD, dpi.password);
    assertEquals(TYPE, dpi.type);
    assertEquals(MAX_CONNS_TIME, dpi.maxConnsTime);
    assertEquals(MAX_CONNS, dpi.maxConns);
    assertEquals(WAIT_TIME, dpi.waitTime);
    assertEquals(APN_ENABLED, dpi.enabled);
    assertEquals(SUPPORTED_APNT_YPES_BITMAK, dpi.supportedApnTypesBitmap);
    assertEquals(ROAMING_PROTOCOL, ApnSetting.getProtocolIntFromString(dpi.protocol));
    assertEquals(BEARER_BITMASK, ServiceState.convertBearerBitmaskToNetworkTypeBitmask(dpi.bearerBitmap >> 1));
    assertEquals(MTU, dpi.mtu);
}
Also used : DataProfile(android.telephony.data.DataProfile) DataProfileInfo(android.hardware.radio.V1_0.DataProfileInfo) FlakyTest(androidx.test.filters.FlakyTest) Test(org.junit.Test)

Aggregations

DataProfile (android.telephony.data.DataProfile)15 SmallTest (android.test.suitebuilder.annotation.SmallTest)10 FlakyTest (androidx.test.filters.FlakyTest)9 Test (org.junit.Test)9 Message (android.os.Message)8 MediumTest (android.test.suitebuilder.annotation.MediumTest)7 TelephonyTest (com.android.internal.telephony.TelephonyTest)7 ContentResolver (android.content.ContentResolver)4 SignalStrength (android.telephony.SignalStrength)4 MockContentResolver (android.test.mock.MockContentResolver)4 AsyncResult (android.os.AsyncResult)3 DataProfileInfo (android.hardware.radio.V1_0.DataProfileInfo)2 ApnSetting (android.telephony.data.ApnSetting)2 ArrayList (java.util.ArrayList)2 Ignore (org.junit.Ignore)2 IRadio (android.hardware.radio.V1_0.IRadio)1 SetupDataCallResult (android.hardware.radio.V1_0.SetupDataCallResult)1 LinkProperties (android.net.LinkProperties)1 RemoteException (android.os.RemoteException)1 DataFailureCause (android.telephony.Annotation.DataFailureCause)1