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());
}
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);
}
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);
}
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();
}
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();
}
Aggregations