/**
   * Displays a class-zero message immediately in a pop-up window with the number from where it
   * received the Notification with the body of the message
   */
  private void displayClassZeroMessage(Context context, SmsMessage sms, String format) {
    // Using NEW_TASK here is necessary because we're calling
    // startActivity from outside an activity.
    Intent smsDialogIntent =
        new Intent(context, ClassZeroActivity.class)
            .putExtra("pdu", sms.getPdu())
            .putExtra("format", format)
            .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);

    context.startActivity(smsDialogIntent);
  }
  /** {@inheritDoc} */
  protected int dispatchMessage(SmsMessageBase smsb) {

    // If sms is null, means there was a parsing error.
    if (smsb == null) {
      return Intents.RESULT_SMS_GENERIC_ERROR;
    }
    SmsMessage sms = (SmsMessage) smsb;
    boolean handled = false;

    if (sms.isTypeZero()) {
      // As per 3GPP TS 23.040 9.2.3.9, Type Zero messages should not be
      // Displayed/Stored/Notified. They should only be acknowledged.
      Log.d(TAG, "Received short message type 0, Don't display or store it. Send Ack");
      return Intents.RESULT_SMS_HANDLED;
    }

    // Special case the message waiting indicator messages
    if (sms.isMWISetMessage()) {
      mGsmPhone.updateMessageWaitingIndicator(true);
      handled = sms.isMwiDontStore();
      if (Config.LOGD) {
        Log.d(TAG, "Received voice mail indicator set SMS shouldStore=" + !handled);
      }
    } else if (sms.isMWIClearMessage()) {
      mGsmPhone.updateMessageWaitingIndicator(false);
      handled = sms.isMwiDontStore();
      if (Config.LOGD) {
        Log.d(TAG, "Received voice mail indicator clear SMS shouldStore=" + !handled);
      }
    }

    if (handled) {
      return Intents.RESULT_SMS_HANDLED;
    }

    if (!mStorageAvailable && (sms.getMessageClass() != MessageClass.CLASS_0)) {
      // It's a storable message and there's no storage available.  Bail.
      // (See TS 23.038 for a description of class 0 messages.)
      return Intents.RESULT_SMS_OUT_OF_MEMORY;
    }

    SmsHeader smsHeader = sms.getUserDataHeader();
    // See if message is partial or port addressed.
    if ((smsHeader == null) || (smsHeader.concatRef == null)) {
      // Message is not partial (not part of concatenated sequence).
      byte[][] pdus = new byte[1][];
      pdus[0] = sms.getPdu();

      if (smsHeader != null && smsHeader.portAddrs != null) {
        if (smsHeader.portAddrs.destPort == SmsHeader.PORT_WAP_PUSH) {
          return mWapPush.dispatchWapPdu(sms.getUserData());
        } else {
          // The message was sent to a port, so concoct a URI for it.
          dispatchPortAddressedPdus(pdus, smsHeader.portAddrs.destPort);
        }
      } else {
        // Normal short and non-port-addressed message, dispatch it.
        dispatchPdus(pdus);
      }
      return Activity.RESULT_OK;
    } else {
      // Process the message part.
      return processMessagePart(sms, smsHeader.concatRef, smsHeader.portAddrs);
    }
  }