public void removeSource(PhoneAccountHandle phoneAccount) { VoicemailContract.Status.setStatus( mContext, phoneAccount, VoicemailContract.Status.CONFIGURATION_STATE_NOT_CONFIGURED, VoicemailContract.Status.DATA_CHANNEL_STATE_NO_CONNECTION, VoicemailContract.Status.NOTIFICATION_CHANNEL_STATE_NO_CONNECTION); removePhoneStateListener(phoneAccount); mActiveVvmSources.remove(phoneAccount); OmtpVvmSyncService.cancelAllRetries(mContext, phoneAccount); }
/** * When a voicemail source is removed, we don't always know which one was removed. Check the list * of registered phone accounts against the active subscriptions list and remove the inactive * sources. */ public void removeInactiveSources() { for (PhoneAccountHandle phoneAccount : mActiveVvmSources) { if (!PhoneUtils.isPhoneAccountActive(mSubscriptionManager, phoneAccount)) { removeSource(phoneAccount); } } // Remove any orphaned phone state listeners as well. for (PhoneAccountHandle phoneAccount : mPhoneStateListenerMap.keySet()) { if (!PhoneUtils.isPhoneAccountActive(mSubscriptionManager, phoneAccount)) { removePhoneStateListener(phoneAccount); } } }