Search in sources :

Example 11 with DataProfile

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

the class DcTrackerTest method testNetworkStatusChangedRecoveryON.

@FlakyTest
@Test
@SmallTest
public void testNetworkStatusChangedRecoveryON() throws Exception {
    ContentResolver resolver = mContext.getContentResolver();
    Settings.Global.putInt(resolver, Settings.Global.DATA_STALL_RECOVERY_ON_BAD_NETWORK, 1);
    Settings.System.putInt(resolver, "radio.data.stall.recovery.action", 0);
    doReturn(new SignalStrength()).when(mPhone).getSignalStrength();
    mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS, new String[] { PhoneConstants.APN_TYPE_DEFAULT, PhoneConstants.APN_TYPE_MMS });
    mDct.enableApn(ApnSetting.TYPE_IMS, DcTracker.REQUEST_TYPE_NORMAL, null);
    mDct.enableApn(ApnSetting.TYPE_DEFAULT, DcTracker.REQUEST_TYPE_NORMAL, null);
    sendInitializationEvents();
    ArgumentCaptor<DataProfile> dpCaptor = ArgumentCaptor.forClass(DataProfile.class);
    verify(mSimulatedCommandsVerifier, timeout(TEST_TIMEOUT).times(2)).setupDataCall(eq(AccessNetworkType.EUTRAN), dpCaptor.capture(), eq(false), eq(false), eq(DataService.REQUEST_REASON_NORMAL), any(), any(Message.class));
    waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
    verifyDataProfile(dpCaptor.getValue(), FAKE_APN1, 0, 21, 1, NETWORK_TYPE_LTE_BITMASK);
    logd("Sending EVENT_NETWORK_STATUS_CHANGED");
    mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_NETWORK_STATUS_CHANGED, NetworkAgent.VALID_NETWORK, 1, null));
    waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
    logd("Sending EVENT_NETWORK_STATUS_CHANGED");
    mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_NETWORK_STATUS_CHANGED, NetworkAgent.INVALID_NETWORK, 1, null));
    waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
    // Data connection is running on a different thread. Have to wait.
    waitForMs(200);
    verify(mSimulatedCommandsVerifier, times(1)).getDataCallList(any(Message.class));
}
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) 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 12 with DataProfile

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

the class DcTrackerTest method testRecoveryStepPDPReset.

@FlakyTest
@Test
@SmallTest
public void testRecoveryStepPDPReset() 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", 1);
    doReturn(new SignalStrength()).when(mPhone).getSignalStrength();
    mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS, new String[] { PhoneConstants.APN_TYPE_DEFAULT, PhoneConstants.APN_TYPE_MMS });
    mDct.enableApn(ApnSetting.TYPE_IMS, DcTracker.REQUEST_TYPE_NORMAL, null);
    mDct.enableApn(ApnSetting.TYPE_DEFAULT, DcTracker.REQUEST_TYPE_NORMAL, null);
    sendInitializationEvents();
    ArgumentCaptor<DataProfile> dpCaptor = ArgumentCaptor.forClass(DataProfile.class);
    verify(mSimulatedCommandsVerifier, timeout(TEST_TIMEOUT).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_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());
    waitForMs(200);
    // expected tear down all DataConnections
    verify(mSimulatedCommandsVerifier, times(1)).deactivateDataCall(eq(DataService.REQUEST_REASON_NORMAL), anyInt(), any(Message.class));
}
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) 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 13 with DataProfile

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

the class DcTrackerTest method testRecoveryStepRestartRadio.

@Test
@SmallTest
public void testRecoveryStepRestartRadio() 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", 3);
    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)).powerOffRadioSafely();
}
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 14 with DataProfile

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

the class DcTrackerTest method testCarrierActionSetMeteredApnsEnabled.

// Test for API carrierActionSetMeteredApnsEnabled.
@FlakyTest
@Ignore
@Test
@MediumTest
public void testCarrierActionSetMeteredApnsEnabled() throws Exception {
    // step 1: setup two DataCalls one for Internet and IMS
    // step 2: set data is enabled
    // step 3: cold sim is detected
    // step 4: all data connection is torn down
    mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS, new String[] { PhoneConstants.APN_TYPE_DEFAULT, PhoneConstants.APN_TYPE_MMS });
    mDct.enableApn(ApnSetting.TYPE_IMS, DcTracker.REQUEST_TYPE_NORMAL, null);
    mDct.enableApn(ApnSetting.TYPE_DEFAULT, DcTracker.REQUEST_TYPE_NORMAL, null);
    sendInitializationEvents();
    ArgumentCaptor<DataProfile> dpCaptor = ArgumentCaptor.forClass(DataProfile.class);
    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_APN1, 0, 5, 1, NETWORK_TYPE_LTE_BITMASK);
    assertTrue(mDct.isAnyDataConnected());
    AsyncResult ar = new AsyncResult(null, new Pair<>(false, DataEnabledSettings.REASON_DATA_ENABLED_BY_CARRIER), null);
    mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_DATA_ENABLED_CHANGED, ar));
    waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
    // Data connection is running on a different thread. Have to wait.
    waitForMs(200);
    // Validate all metered data connections have been torn down
    verify(mSimulatedCommandsVerifier, times(1)).deactivateDataCall(eq(DataService.REQUEST_REASON_NORMAL), anyInt(), any(Message.class));
    assertTrue(mDct.isAnyDataConnected());
    assertEquals(DctConstants.State.IDLE, mDct.getState(PhoneConstants.APN_TYPE_DEFAULT));
}
Also used : DataProfile(android.telephony.data.DataProfile) Message(android.os.Message) AsyncResult(android.os.AsyncResult) FlakyTest(androidx.test.filters.FlakyTest) Ignore(org.junit.Ignore) 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 15 with DataProfile

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

the class DataProfileTest method testCreateFromApnSettingWithNetworkTypeBitmask.

@SmallTest
public void testCreateFromApnSettingWithNetworkTypeBitmask() throws Exception {
    DataProfile dp = DcTracker.createDataProfile(mApn3, mApn3.getProfileId(), false);
    assertEquals(mApn3.getProfileId(), dp.getProfileId());
    assertEquals(mApn3.getApnName(), dp.getApn());
    assertEquals(mApn3.getProtocol(), dp.getProtocolType());
    assertEquals(RILConstants.SETUP_DATA_AUTH_PAP_CHAP, dp.getAuthType());
    assertEquals(mApn3.getUser(), dp.getUserName());
    assertEquals(mApn3.getPassword(), dp.getPassword());
    // TYPE_3GPP2
    assertEquals(2, dp.getType());
    assertEquals(mApn3.getWaitTime(), dp.getWaitTime());
    assertEquals(mApn3.isEnabled(), dp.isEnabled());
    int expectedBearerBitmap = mApn3.getNetworkTypeBitmask();
    assertEquals(expectedBearerBitmap, dp.getBearerBitmask());
}
Also used : DataProfile(android.telephony.data.DataProfile) SmallTest(android.test.suitebuilder.annotation.SmallTest)

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