Search in sources :

Example 1 with HandoverCallback

use of com.android.internal.telephony.dataconnection.TransportManager.HandoverParams.HandoverCallback in project android_frameworks_opt_telephony by LineageOS.

the class TelephonyNetworkFactoryTest method testHandoverNoLiveData.

/**
 * Test handover when there is no live data connection
 */
@Test
@SmallTest
public void testHandoverNoLiveData() throws Exception {
    createMockedTelephonyComponents();
    doReturn(0).when(mSubscriptionController).getSubIdUsingPhoneId(0);
    mTelephonyNetworkFactoryUT.mInternalHandler.sendEmptyMessage(TelephonyNetworkFactory.EVENT_SUBSCRIPTION_CHANGED);
    activatePhoneInPhoneSwitcher(0, true);
    makeDefaultInternetRequest();
    makeSubSpecificMmsRequest(0);
    processAllMessages();
    Field f = TelephonyNetworkFactory.class.getDeclaredField("mInternalHandler");
    f.setAccessible(true);
    Handler h = (Handler) f.get(mTelephonyNetworkFactoryUT);
    HandoverCallback handoverCallback = mock(HandoverCallback.class);
    HandoverParams hp = new HandoverParams(ApnSetting.TYPE_MMS, AccessNetworkConstants.TRANSPORT_TYPE_WLAN, handoverCallback);
    AsyncResult ar = new AsyncResult(null, hp, null);
    h.sendMessage(h.obtainMessage(5, ar));
    processAllMessages();
    doReturn(AccessNetworkConstants.TRANSPORT_TYPE_WLAN).when(mTransportManager).getCurrentTransport(anyInt());
    hp = new HandoverParams(ApnSetting.TYPE_MMS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN, handoverCallback);
    ar = new AsyncResult(null, hp, null);
    h.sendMessage(h.obtainMessage(5, ar));
    processAllMessages();
}
Also used : Field(java.lang.reflect.Field) HandoverCallback(com.android.internal.telephony.dataconnection.TransportManager.HandoverParams.HandoverCallback) HandoverParams(com.android.internal.telephony.dataconnection.TransportManager.HandoverParams) Handler(android.os.Handler) AsyncResult(android.os.AsyncResult) FlakyTest(androidx.test.filters.FlakyTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 2 with HandoverCallback

use of com.android.internal.telephony.dataconnection.TransportManager.HandoverParams.HandoverCallback in project android_frameworks_opt_telephony by LineageOS.

the class TelephonyNetworkFactoryTest method testHandoverActivatingData.

/**
 * Test handover when the data connection is being connected.
 */
@Test
@SmallTest
public void testHandoverActivatingData() throws Exception {
    createMockedTelephonyComponents();
    doReturn(0).when(mSubscriptionController).getSubIdUsingPhoneId(0);
    mTelephonyNetworkFactoryUT.mInternalHandler.sendEmptyMessage(TelephonyNetworkFactory.EVENT_SUBSCRIPTION_CHANGED);
    activatePhoneInPhoneSwitcher(0, true);
    makeDefaultInternetRequest();
    makeSubSpecificMmsRequest(0);
    processAllMessages();
    Field f = TelephonyNetworkFactory.class.getDeclaredField("mInternalHandler");
    f.setAccessible(true);
    Handler h = (Handler) f.get(mTelephonyNetworkFactoryUT);
    HandoverCallback handoverCallback = mock(HandoverCallback.class);
    Mockito.reset(mDcTracker);
    doReturn(mDataConnection).when(mDcTracker).getDataConnectionByApnType(anyString());
    doReturn(false).when(mDataConnection).isActive();
    HandoverParams hp = new HandoverParams(ApnSetting.TYPE_MMS, AccessNetworkConstants.TRANSPORT_TYPE_WLAN, handoverCallback);
    AsyncResult ar = new AsyncResult(null, hp, null);
    h.sendMessage(h.obtainMessage(5, ar));
    processAllMessages();
    verify(mDcTracker, times(1)).releaseNetwork(any(), eq(1));
    verify(mDcTracker, times(1)).requestNetwork(any(), eq(1), any());
}
Also used : Field(java.lang.reflect.Field) HandoverCallback(com.android.internal.telephony.dataconnection.TransportManager.HandoverParams.HandoverCallback) HandoverParams(com.android.internal.telephony.dataconnection.TransportManager.HandoverParams) Handler(android.os.Handler) AsyncResult(android.os.AsyncResult) FlakyTest(androidx.test.filters.FlakyTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

AsyncResult (android.os.AsyncResult)2 Handler (android.os.Handler)2 SmallTest (android.test.suitebuilder.annotation.SmallTest)2 FlakyTest (androidx.test.filters.FlakyTest)2 TelephonyTest (com.android.internal.telephony.TelephonyTest)2 HandoverParams (com.android.internal.telephony.dataconnection.TransportManager.HandoverParams)2 HandoverCallback (com.android.internal.telephony.dataconnection.TransportManager.HandoverParams.HandoverCallback)2 Field (java.lang.reflect.Field)2 Test (org.junit.Test)2