Search in sources :

Example 1 with LocalLog

use of android.util.LocalLog in project android_frameworks_opt_telephony by LineageOS.

the class DcTrackerTest method testDDSResetAutoAttach.

// Test the default data switch scenario.
@Test
@MediumTest
public void testDDSResetAutoAttach() throws Exception {
    mDct.setDataEnabled(true);
    mContextFixture.putBooleanResource(com.android.internal.R.bool.config_auto_attach_data_on_creation, true);
    mSimulatedCommands.setDataCallResponse(true, createDataCallResponse());
    DataConnectionReasons dataConnectionReasons = new DataConnectionReasons();
    boolean allowed = isDataAllowed(dataConnectionReasons);
    assertFalse(dataConnectionReasons.toString(), allowed);
    ArgumentCaptor<Integer> intArgumentCaptor = ArgumentCaptor.forClass(Integer.class);
    verify(mUiccController, times(1)).registerForIccChanged(eq(mDct), intArgumentCaptor.capture(), eq(null));
    // Ideally this should send EVENT_ICC_CHANGED.
    mDct.sendMessage(mDct.obtainMessage(intArgumentCaptor.getValue(), null));
    waitForMs(100);
    verify(mSimRecords, times(1)).registerForRecordsLoaded(eq(mDct), intArgumentCaptor.capture(), eq(null));
    // Ideally this should send EVENT_RECORDS_LOADED.
    mDct.sendMessage(mDct.obtainMessage(intArgumentCaptor.getValue(), null));
    waitForMs(100);
    verify(mSST, times(1)).registerForDataConnectionAttached(eq(mDct), intArgumentCaptor.capture(), eq(null));
    // Ideally this should send EVENT_DATA_CONNECTION_ATTACHED");
    mDct.sendMessage(mDct.obtainMessage(intArgumentCaptor.getValue(), null));
    waitForMs(200);
    NetworkRequest nr = new NetworkRequest.Builder().addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET).build();
    LocalLog l = new LocalLog(100);
    mDct.requestNetwork(nr, l);
    waitForMs(200);
    verifyDataConnected(FAKE_APN1);
    assertTrue(mDct.getAutoAttachOnCreation());
    mDct.update();
    // The auto attach flag should be reset after update
    assertFalse(mDct.getAutoAttachOnCreation());
    verify(mSST, times(1)).registerForDataConnectionDetached(eq(mDct), intArgumentCaptor.capture(), eq(null));
    // Ideally this should send EVENT_DATA_CONNECTION_DETACHED
    mDct.sendMessage(mDct.obtainMessage(intArgumentCaptor.getValue(), null));
    waitForMs(200);
    // Data should not be allowed since auto attach flag has been reset.
    dataConnectionReasons = new DataConnectionReasons();
    allowed = isDataAllowed(dataConnectionReasons);
    assertFalse(dataConnectionReasons.toString(), allowed);
}
Also used : NetworkRequest(android.net.NetworkRequest) LocalLog(android.util.LocalLog) TelephonyTest(com.android.internal.telephony.TelephonyTest) MediumTest(android.test.suitebuilder.annotation.MediumTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) FlakyTest(android.support.test.filters.FlakyTest) Test(org.junit.Test) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 2 with LocalLog

use of android.util.LocalLog in project android_frameworks_opt_telephony by LineageOS.

the class ApnContextTest method testNetworkRequest.

@Test
@SmallTest
public void testNetworkRequest() throws Exception {
    LocalLog log = new LocalLog(3);
    NetworkRequest nr = new NetworkRequest.Builder().build();
    mApnContext.requestNetwork(nr, log);
    verify(mDcTracker, times(1)).setEnabled(eq(DctConstants.APN_DEFAULT_ID), eq(true));
    mApnContext.requestNetwork(nr, log);
    verify(mDcTracker, times(1)).setEnabled(eq(DctConstants.APN_DEFAULT_ID), eq(true));
    mApnContext.releaseNetwork(nr, log);
    verify(mDcTracker, times(1)).setEnabled(eq(DctConstants.APN_DEFAULT_ID), eq(false));
    mApnContext.releaseNetwork(nr, log);
    verify(mDcTracker, times(1)).setEnabled(eq(DctConstants.APN_DEFAULT_ID), eq(false));
}
Also used : NetworkRequest(android.net.NetworkRequest) LocalLog(android.util.LocalLog) SmallTest(android.test.suitebuilder.annotation.SmallTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 3 with LocalLog

use of android.util.LocalLog in project android_frameworks_opt_telephony by LineageOS.

the class TelephonyNetworkFactory method applyRequests.

private void applyRequests(HashMap<NetworkRequest, LocalLog> requestMap, boolean action, String logStr) {
    for (NetworkRequest networkRequest : requestMap.keySet()) {
        LocalLog localLog = requestMap.get(networkRequest);
        localLog.log(logStr);
        if (action == REQUEST) {
            mDcTracker.requestNetwork(networkRequest, localLog);
        } else {
            mDcTracker.releaseNetwork(networkRequest, localLog);
        }
    }
}
Also used : NetworkRequest(android.net.NetworkRequest) LocalLog(android.util.LocalLog)

Aggregations

NetworkRequest (android.net.NetworkRequest)3 LocalLog (android.util.LocalLog)3 SmallTest (android.test.suitebuilder.annotation.SmallTest)2 TelephonyTest (com.android.internal.telephony.TelephonyTest)2 Test (org.junit.Test)2 FlakyTest (android.support.test.filters.FlakyTest)1 MediumTest (android.test.suitebuilder.annotation.MediumTest)1