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);
 }
  @Override
  public void onServiceStateChanged(ServiceState serviceState) {
    int state = serviceState.getState();
    if (state == mPreviousState
        || (state != ServiceState.STATE_IN_SERVICE
            && mPreviousState != ServiceState.STATE_IN_SERVICE)) {
      // Only interested in state changes or transitioning into or out of "in service".
      // Otherwise just quit.
      mPreviousState = state;
      return;
    }

    if (state == ServiceState.STATE_IN_SERVICE) {
      VoicemailStatusQueryHelper voicemailStatusQueryHelper =
          new VoicemailStatusQueryHelper(mContext);
      if (voicemailStatusQueryHelper.isVoicemailSourceConfigured(mPhoneAccount)) {
        if (!voicemailStatusQueryHelper.isNotificationsChannelActive(mPhoneAccount)) {
          Log.v(TAG, "Notifications channel is active for " + mPhoneAccount.getId());
          VoicemailContract.Status.setStatus(
              mContext,
              mPhoneAccount,
              VoicemailContract.Status.CONFIGURATION_STATE_OK,
              VoicemailContract.Status.DATA_CHANNEL_STATE_OK,
              VoicemailContract.Status.NOTIFICATION_CHANNEL_STATE_OK);
          PhoneGlobals.getInstance()
              .clearMwiIndicator(PhoneUtils.getSubIdForPhoneAccountHandle(mPhoneAccount));
        }
      }

      if (OmtpVvmSourceManager.getInstance(mContext).isVvmSourceRegistered(mPhoneAccount)) {
        Log.v(TAG, "Signal returned: requesting resync for " + mPhoneAccount.getId());
        LocalLogHelper.log(TAG, "Signal returned: requesting resync for " + mPhoneAccount.getId());
        // If the source is already registered, run a full sync in case something was missed
        // while signal was down.
        Intent serviceIntent =
            OmtpVvmSyncService.getSyncIntent(
                mContext,
                OmtpVvmSyncService.SYNC_FULL_SYNC,
                mPhoneAccount,
                true /* firstAttempt */);
        mContext.startService(serviceIntent);
      } else {
        Log.v(TAG, "Signal returned: reattempting activation for " + mPhoneAccount.getId());
        LocalLogHelper.log(
            TAG, "Signal returned: reattempting activation for " + mPhoneAccount.getId());
        // Otherwise initiate an activation because this means that an OMTP source was
        // recognized but either the activation text was not successfully sent or a response
        // was not received.
        OmtpVvmCarrierConfigHelper carrierConfigHelper =
            new OmtpVvmCarrierConfigHelper(
                mContext, PhoneUtils.getSubIdForPhoneAccountHandle(mPhoneAccount));
        carrierConfigHelper.startActivation();
      }
    } else {
      Log.v(TAG, "Notifications channel is inactive for " + mPhoneAccount.getId());
      mContext.stopService(
          OmtpVvmSyncService.getSyncIntent(
              mContext, OmtpVvmSyncService.SYNC_FULL_SYNC, mPhoneAccount, true /* firstAttempt */));

      if (!OmtpVvmSourceManager.getInstance(mContext).isVvmSourceRegistered(mPhoneAccount)) {
        return;
      }

      VoicemailContract.Status.setStatus(
          mContext,
          mPhoneAccount,
          VoicemailContract.Status.CONFIGURATION_STATE_OK,
          VoicemailContract.Status.DATA_CHANNEL_STATE_NO_CONNECTION,
          VoicemailContract.Status.NOTIFICATION_CHANNEL_STATE_NO_CONNECTION);
    }
    mPreviousState = state;
  }