Search in sources :

Example 71 with AsyncResult

use of android.os.AsyncResult in project android_frameworks_opt_telephony by LineageOS.

the class GsmCdmaPhoneTest method testEcmCancelledPreservedThroughSrvcc.

@Test
@SmallTest
public void testEcmCancelledPreservedThroughSrvcc() throws Exception {
    replaceInstance(Phone.class, "mImsPhone", mPhoneUT, mImsPhone);
    assertFalse(mPhoneUT.isEcmCanceledForEmergency());
    // Set ECM cancelled state on ImsPhone to be transferred via migrateFrom
    doReturn(true).when(mImsPhone).isEcmCanceledForEmergency();
    verify(mSimulatedCommandsVerifier).registerForSrvccStateChanged(any(), eq(EVENT_SRVCC_STATE_CHANGED), any());
    // Start SRVCC
    Message msg = Message.obtain();
    msg.what = EVENT_SRVCC_STATE_CHANGED;
    msg.obj = new AsyncResult(null, new int[] { TelephonyManager.SRVCC_STATE_HANDOVER_STARTED }, null);
    mPhoneUT.sendMessage(msg);
    processAllMessages();
    // verify ECM cancelled is transferred correctly.
    assertTrue(mPhoneUT.isEcmCanceledForEmergency());
}
Also used : Message(android.os.Message) AsyncResult(android.os.AsyncResult) FlakyTest(androidx.test.filters.FlakyTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 72 with AsyncResult

use of android.os.AsyncResult in project android_frameworks_opt_telephony by LineageOS.

the class GsmCdmaPhoneTest method testGetEmptyIccCard.

@Test
@SmallTest
public void testGetEmptyIccCard() {
    doReturn(null).when(mUiccController).getUiccProfileForPhone(anyInt());
    IccCard iccCard = mPhoneUT.getIccCard();
    // The iccCard should be a dummy object, not null.
    assertTrue(!(iccCard instanceof UiccProfile));
    assertTrue(iccCard != null);
    assertEquals(IccCardConstants.State.UNKNOWN, iccCard.getState());
    assertEquals(null, iccCard.getIccRecords());
    assertEquals(false, iccCard.getIccLockEnabled());
    assertEquals(false, iccCard.getIccFdnEnabled());
    assertEquals(false, iccCard.isApplicationOnIcc(IccCardApplicationStatus.AppType.APPTYPE_SIM));
    assertEquals(false, iccCard.hasIccCard());
    assertEquals(false, iccCard.getIccPin2Blocked());
    assertEquals(false, iccCard.getIccPuk2Blocked());
    Message onComplete = mTestHandler.obtainMessage(EVENT_SET_ICC_LOCK_ENABLED);
    iccCard.setIccLockEnabled(true, "password", onComplete);
    processAllMessages();
    ArgumentCaptor<Message> messageArgumentCaptor = ArgumentCaptor.forClass(Message.class);
    // Verify that message is sent back with exception.
    verify(mTestHandler, times(1)).sendMessageAtTime(messageArgumentCaptor.capture(), anyLong());
    Message message = messageArgumentCaptor.getAllValues().get(0);
    AsyncResult ret = (AsyncResult) message.obj;
    assertEquals(EVENT_SET_ICC_LOCK_ENABLED, message.what);
    assertTrue(ret.exception != null);
}
Also used : UiccProfile(com.android.internal.telephony.uicc.UiccProfile) Message(android.os.Message) AsyncResult(android.os.AsyncResult) FlakyTest(androidx.test.filters.FlakyTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 73 with AsyncResult

use of android.os.AsyncResult 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 74 with AsyncResult

use of android.os.AsyncResult 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 75 with AsyncResult

use of android.os.AsyncResult in project android_frameworks_opt_telephony by LineageOS.

the class GsmInboundSmsHandlerTest method sendNewSms.

private void sendNewSms() {
    mGsmInboundSmsHandler.sendMessage(InboundSmsHandler.EVENT_NEW_SMS, new AsyncResult(null, mSmsMessage, null));
    // handle EVENT_NEW_SMS, EVENT_BROADCAST_SMS
    processAllMessages();
}
Also used : AsyncResult(android.os.AsyncResult)

Aggregations

AsyncResult (android.os.AsyncResult)267 Test (org.junit.Test)60 Message (android.os.Message)57 TelephonyTest (com.android.internal.telephony.TelephonyTest)45 SmallTest (android.test.suitebuilder.annotation.SmallTest)26 ArrayList (java.util.ArrayList)21 Registrant (android.os.Registrant)19 FlakyTest (androidx.test.filters.FlakyTest)17 Intent (android.content.Intent)13 CellInfo (android.telephony.CellInfo)12 MediumTest (android.test.suitebuilder.annotation.MediumTest)12 SmallTest (androidx.test.filters.SmallTest)11 NetworkRegistrationInfo (android.telephony.NetworkRegistrationInfo)9 List (java.util.List)7 Mockito.anyString (org.mockito.Mockito.anyString)6 InvocationOnMock (org.mockito.invocation.InvocationOnMock)6 FlakyTest (android.support.test.filters.FlakyTest)5 MediumTest (android.support.test.filters.MediumTest)5 LteVopsSupportInfo (android.telephony.LteVopsSupportInfo)5 SmsMessage (android.telephony.SmsMessage)5