Пример #1
0
 private SmsManager getSmsManagerFor(int subscriptionId) {
   if (Build.VERSION.SDK_INT >= 22 && subscriptionId != -1) {
     return SmsManager.getSmsManagerForSubscriptionId(subscriptionId);
   } else {
     return SmsManager.getDefault();
   }
 }
  private OmtpMessageSender getMessageSender() {
    if (mCarrierConfig == null) {
      Log.w(TAG, "Empty carrier config.");
      return null;
    }

    int applicationPort = mCarrierConfig.getInt(CarrierConfigManager.KEY_VVM_PORT_NUMBER_INT, 0);
    String destinationNumber =
        mCarrierConfig.getString(CarrierConfigManager.KEY_VVM_DESTINATION_NUMBER_STRING);
    if (TextUtils.isEmpty(destinationNumber)) {
      Log.w(TAG, "No destination number for this carrier.");
      return null;
    }

    OmtpMessageSender messageSender = null;
    SmsManager smsManager = SmsManager.getSmsManagerForSubscriptionId(mSubId);
    switch (mVvmType) {
      case TelephonyManager.VVM_TYPE_OMTP:
        messageSender =
            new OmtpStandardMessageSender(
                smsManager,
                (short) applicationPort,
                destinationNumber,
                null,
                OmtpConstants.PROTOCOL_VERSION1_1,
                null);
        break;
      case TelephonyManager.VVM_TYPE_CVVM:
        messageSender =
            new OmtpCvvmMessageSender(smsManager, (short) applicationPort, destinationNumber);
        break;
      default:
        Log.w(TAG, "Unexpected visual voicemail type: " + mVvmType);
    }

    return messageSender;
  }