/**
   * parse the input address to be a valid MMS address. - if the address is an email address, leave
   * it as is. - if the address can be parsed into a valid MMS phone number, return the parsed
   * number. - if the address is a compliant alias address, leave it as is.
   */
  public static String parseMmsAddress(String address) {
    // if it's a valid Email address, use that.
    if (Mms.isEmailAddress(address)) {
      return address;
    }

    // if we are able to parse the address to a MMS compliant phone number, take that.
    String retVal = parsePhoneNumberForMms(address);
    if (retVal != null) {
      return retVal;
    }

    // if it's an alias compliant address, use that.
    if (isAlias(address)) {
      return address;
    }

    // it's not a valid MMS address, return null
    return null;
  }
  public boolean sendMessage(long token) throws MmsException {
    if (LogTag.DEBUG_SEND) {
      Log.v(TAG, "sendMessage token: " + token);
    }
    if (mMessageText == null) {
      // Don't try to send an empty message, and destination should be just
      // one.
      throw new MmsException("Null message body or have multiple destinations.");
    }
    SmsManager smsManager = SmsManager.getDefault();
    ArrayList<String> messages = null;
    if ((MmsConfig.getEmailGateway() != null)
        && (Mms.isEmailAddress(mDest) || MessageUtils.isAlias(mDest))) {
      String msgText;
      msgText = mDest + " " + mMessageText;
      mDest = MmsConfig.getEmailGateway();
      messages = smsManager.divideMessage(msgText);
    } else {
      messages = smsManager.divideMessage(mMessageText);
      // remove spaces and dashes from destination number
      // (e.g. "801 555 1212" -> "8015551212")
      // (e.g. "+8211-123-4567" -> "+82111234567")
      mDest = PhoneNumberUtils.stripSeparators(mDest);
      mDest = Conversation.verifySingleRecipient(mContext, mThreadId, mDest);
    }
    int messageCount = messages.size();

    if (messageCount == 0) {
      // Don't try to send an empty message.
      throw new MmsException(
          "SmsMessageSender.sendMessage: divideMessage returned "
              + "empty messages. Original message is \""
              + mMessageText
              + "\"");
    }

    boolean moved = Sms.moveMessageToFolder(mContext, mUri, Sms.MESSAGE_TYPE_OUTBOX, 0);
    if (!moved) {
      throw new MmsException(
          "SmsMessageSender.sendMessage: couldn't move message " + "to outbox: " + mUri);
    }
    if (LogTag.DEBUG_SEND) {
      Log.v(
          TAG,
          "sendMessage mDest: " + mDest + " mRequestDeliveryReport: " + mRequestDeliveryReport);
    }

    ArrayList<PendingIntent> deliveryIntents = new ArrayList<PendingIntent>(messageCount);
    ArrayList<PendingIntent> sentIntents = new ArrayList<PendingIntent>(messageCount);
    for (int i = 0; i < messageCount; i++) {
      if (mRequestDeliveryReport && (i == (messageCount - 1))) {
        // TODO: Fix: It should not be necessary to
        // specify the class in this intent.  Doing that
        // unnecessarily limits customizability.
        deliveryIntents.add(
            PendingIntent.getBroadcast(
                mContext,
                0,
                new Intent(
                    MessageStatusReceiver.MESSAGE_STATUS_RECEIVED_ACTION,
                    mUri,
                    mContext,
                    MessageStatusReceiver.class),
                0));
      } else {
        deliveryIntents.add(null);
      }
      Intent intent =
          new Intent(SmsReceiverService.MESSAGE_SENT_ACTION, mUri, mContext, SmsReceiver.class);

      int requestCode = 0;
      if (i == messageCount - 1) {
        // Changing the requestCode so that a different pending intent
        // is created for the last fragment with
        // EXTRA_MESSAGE_SENT_SEND_NEXT set to true.
        requestCode = 1;
        intent.putExtra(SmsReceiverService.EXTRA_MESSAGE_SENT_SEND_NEXT, true);
      }
      if (LogTag.DEBUG_SEND) {
        Log.v(TAG, "sendMessage sendIntent: " + intent);
      }
      sentIntents.add(PendingIntent.getBroadcast(mContext, requestCode, intent, 0));
    }
    try {
      if (MultiSimConfig.isMultiSimEnabled()) {
        MSimSmsManager smsManagerMSim = MSimSmsManager.getDefault();
        smsManagerMSim.sendMultipartTextMessage(
            mDest,
            mServiceCenter,
            messages,
            sentIntents,
            deliveryIntents,
            ComposeMessageActivity.subSelected);
        Log.v(TAG, "뇰랙죄崗엥친駕가가가가!mSubscription: " + mSubscription);

      } else {
        smsManager.sendMultipartTextMessage(
            mDest, mServiceCenter, messages, sentIntents, deliveryIntents);
      }
    } catch (Exception ex) {
      Log.e(TAG, "SmsMessageSender.sendMessage: caught", ex);
      throw new MmsException(
          "SmsMessageSender.sendMessage: caught " + ex + " from MSimSmsManager.sendTextMessage()");
    }
    if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE) || LogTag.DEBUG_SEND) {
      log(
          "sendMessage: address="
              + mDest
              + ", threadId="
              + mThreadId
              + ", uri="
              + mUri
              + ", msgs.count="
              + messageCount);
    }
    return false;
  }