use of com.android.internal.telephony.uicc.IccVmNotSupportedException in project android_frameworks_opt_telephony by LineageOS.
the class GsmCdmaPhoneTest method testVoiceMailNumberCdma.
@Test
@SmallTest
public void testVoiceMailNumberCdma() {
switchToCdma();
String voiceMailNumber = "1234567890";
// config_telephony_use_own_number_for_voicemail
mContextFixture.getCarrierConfigBundle().putBoolean(CarrierConfigManager.KEY_CONFIG_TELEPHONY_USE_OWN_NUMBER_FOR_VOICEMAIL_BOOL, true);
doReturn(voiceMailNumber).when(mSST).getMdnNumber();
assertEquals(voiceMailNumber, mPhoneUT.getVoiceMailNumber());
// voicemail number from config
voiceMailNumber = "1234567891";
mContextFixture.getCarrierConfigBundle().putString(CarrierConfigManager.KEY_DEFAULT_VM_NUMBER_STRING, voiceMailNumber);
assertEquals(voiceMailNumber, mPhoneUT.getVoiceMailNumber());
// voicemail number from config for roaming network
String voiceMailNumberForRoaming = "1234567892";
mContextFixture.getCarrierConfigBundle().putString(CarrierConfigManager.KEY_DEFAULT_VM_NUMBER_ROAMING_STRING, voiceMailNumberForRoaming);
// voicemail number from config for roaming network and ims unregistered
String voiceMailNumberForImsRoamingAndUnregistered = "1234567893";
mContextFixture.getCarrierConfigBundle().putString(CarrierConfigManager.KEY_DEFAULT_VM_NUMBER_ROAMING_AND_IMS_UNREGISTERED_STRING, voiceMailNumberForImsRoamingAndUnregistered);
// Verify voicemail number for home
doReturn(false).when(mSST.mSS).getRoaming();
doReturn(true).when(mSST).isImsRegistered();
assertEquals(voiceMailNumber, mPhoneUT.getVoiceMailNumber());
// Move to ims condition, verify voicemail number for ims unregistered
doReturn(false).when(mSST).isImsRegistered();
assertEquals(voiceMailNumber, mPhoneUT.getVoiceMailNumber());
// Move to roaming condition, verify voicemail number for roaming
doReturn(true).when(mSST.mSS).getRoaming();
assertEquals(voiceMailNumberForImsRoamingAndUnregistered, mPhoneUT.getVoiceMailNumber());
// Move to ims condition, verify voicemail number for roaming
doReturn(true).when(mSST).isImsRegistered();
assertEquals(voiceMailNumberForRoaming, mPhoneUT.getVoiceMailNumber());
// Move to home condition, verify voicemail number for home
doReturn(false).when(mSST.mSS).getRoaming();
assertEquals(voiceMailNumber, mPhoneUT.getVoiceMailNumber());
// voicemail number from sharedPreference
voiceMailNumber = "1234567893";
mPhoneUT.setVoiceMailNumber("alphaTag", voiceMailNumber, null);
ArgumentCaptor<Message> messageArgumentCaptor = ArgumentCaptor.forClass(Message.class);
InOrder inOrder = inOrder(mSimRecords);
inOrder.verify(mSimRecords).setVoiceMailNumber(eq("alphaTag"), eq(voiceMailNumber), messageArgumentCaptor.capture());
// SIM does not support voicemail number (IccVmNotSupportedException) so should be saved in
// shared pref
Message msg = messageArgumentCaptor.getValue();
AsyncResult.forMessage(msg).exception = new IccVmNotSupportedException("setVoiceMailNumber not implemented");
msg.sendToTarget();
processAllMessages();
assertEquals(voiceMailNumber, mPhoneUT.getVoiceMailNumber());
// voicemail number from SIM
voiceMailNumber = "1234567894";
mPhoneUT.setVoiceMailNumber("alphaTag", voiceMailNumber, null);
messageArgumentCaptor = ArgumentCaptor.forClass(Message.class);
inOrder.verify(mSimRecords).setVoiceMailNumber(eq("alphaTag"), eq(voiceMailNumber), messageArgumentCaptor.capture());
// successfully saved on SIM
msg = messageArgumentCaptor.getValue();
AsyncResult.forMessage(msg);
msg.sendToTarget();
processAllMessages();
doReturn(voiceMailNumber).when(mSimRecords).getVoiceMailNumber();
assertEquals(voiceMailNumber, mPhoneUT.getVoiceMailNumber());
}