Search in sources :

Example 6 with QualifiedNetworks

use of com.android.internal.telephony.dataconnection.AccessNetworksManager.QualifiedNetworks in project android_frameworks_opt_telephony by LineageOS.

the class TransportManagerTest method testBackToBackHandoverNeeded.

@Test
@SmallTest
public void testBackToBackHandoverNeeded() throws Exception {
    mTransportManager.registerForHandoverNeededEvent(mTestHandler, EVENT_HANDOVER_NEEDED);
    // Initial qualified networks
    List<QualifiedNetworks> networkList = new ArrayList<>(Arrays.asList(new QualifiedNetworks(ApnSetting.TYPE_IMS, new int[] { AccessNetworkType.EUTRAN, AccessNetworkType.UTRAN, AccessNetworkType.IWLAN })));
    mTransportManager.obtainMessage(1, /* EVENT_QUALIFIED_NETWORKS_CHANGED */
    new AsyncResult(null, networkList, null)).sendToTarget();
    processAllMessages();
    // Verify handover needed event was not sent
    verify(mTestHandler, never()).sendMessageAtTime(any(Message.class), anyLong());
    assertEquals(AccessNetworkConstants.TRANSPORT_TYPE_WWAN, mTransportManager.getCurrentTransport(ApnSetting.TYPE_IMS));
    // Now change the order of qualified networks by putting IWLAN first
    networkList = new ArrayList<>(Arrays.asList(new QualifiedNetworks(ApnSetting.TYPE_IMS, new int[] { AccessNetworkType.IWLAN, AccessNetworkType.UTRAN, AccessNetworkType.EUTRAN })));
    mTransportManager.obtainMessage(1, /* EVENT_QUALIFIED_NETWORKS_CHANGED */
    new AsyncResult(null, networkList, null)).sendToTarget();
    processAllMessages();
    ArgumentCaptor<Message> messageArgumentCaptor = ArgumentCaptor.forClass(Message.class);
    // Verify handover needed event was sent and the the target transport is WLAN.
    verify(mTestHandler, times(1)).sendMessageAtTime(messageArgumentCaptor.capture(), anyLong());
    Message message = messageArgumentCaptor.getValue();
    assertEquals(EVENT_HANDOVER_NEEDED, message.what);
    AsyncResult ar = (AsyncResult) message.obj;
    HandoverParams params = (HandoverParams) ar.result;
    assertEquals(ApnSetting.TYPE_IMS, params.apnType);
    assertEquals(AccessNetworkConstants.TRANSPORT_TYPE_WLAN, params.targetTransport);
    // Before handover is completed, update the available networks again.
    // This time change the order of qualified networks by putting EUTRAN first
    networkList = new ArrayList<>(Arrays.asList(new QualifiedNetworks(ApnSetting.TYPE_IMS, new int[] { AccessNetworkType.EUTRAN, AccessNetworkType.UTRAN, AccessNetworkType.IWLAN })));
    mTransportManager.obtainMessage(1, /* EVENT_QUALIFIED_NETWORKS_CHANGED */
    new AsyncResult(null, networkList, null)).sendToTarget();
    processAllMessages();
    // Verify handover needed event was sent only once (for the previous change)
    verify(mTestHandler, times(1)).sendMessageAtTime(messageArgumentCaptor.capture(), anyLong());
    LinkedList<List<QualifiedNetworks>> listQueue = getAvailableNetworksList();
    // Verify the list has been queued.
    assertEquals(1, listQueue.size());
    // Notify handover succeeded.
    params.callback.onCompleted(true, false);
    assertEquals(AccessNetworkConstants.TRANSPORT_TYPE_WLAN, mTransportManager.getCurrentTransport(ApnSetting.TYPE_IMS));
    processAllMessages();
    listQueue = getAvailableNetworksList();
    // Verify the queue is empty.
    assertEquals(0, listQueue.size());
    // Verify handover 2nd needed event was sent
    verify(mTestHandler, times(2)).sendMessageAtTime(messageArgumentCaptor.capture(), anyLong());
}
Also used : Message(android.os.Message) ArrayList(java.util.ArrayList) HandoverParams(com.android.internal.telephony.dataconnection.TransportManager.HandoverParams) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) QualifiedNetworks(com.android.internal.telephony.dataconnection.AccessNetworksManager.QualifiedNetworks) AsyncResult(android.os.AsyncResult) SmallTest(android.test.suitebuilder.annotation.SmallTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

QualifiedNetworks (com.android.internal.telephony.dataconnection.AccessNetworksManager.QualifiedNetworks)6 AsyncResult (android.os.AsyncResult)5 Message (android.os.Message)4 LinkedList (java.util.LinkedList)4 SmallTest (android.test.suitebuilder.annotation.SmallTest)3 TelephonyTest (com.android.internal.telephony.TelephonyTest)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Test (org.junit.Test)3 RegistrantList (android.os.RegistrantList)2 HandoverParams (com.android.internal.telephony.dataconnection.TransportManager.HandoverParams)2 NonNull (android.annotation.NonNull)1 Nullable (android.annotation.Nullable)1 StringDef (android.annotation.StringDef)1 Handler (android.os.Handler)1 SystemProperties (android.os.SystemProperties)1 AccessNetworkConstants (android.telephony.AccessNetworkConstants)1 AccessNetworkType (android.telephony.AccessNetworkConstants.AccessNetworkType)1 ApnType (android.telephony.Annotation.ApnType)1 CarrierConfigManager (android.telephony.CarrierConfigManager)1