当前位置: 首页>>代码示例>>Java>>正文


Java UndeliverableMessageException类代码示例

本文整理汇总了Java中org.thoughtcrime.securesms.transport.UndeliverableMessageException的典型用法代码示例。如果您正苦于以下问题:Java UndeliverableMessageException类的具体用法?Java UndeliverableMessageException怎么用?Java UndeliverableMessageException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UndeliverableMessageException类属于org.thoughtcrime.securesms.transport包,在下文中一共展示了UndeliverableMessageException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: send

import org.thoughtcrime.securesms.transport.UndeliverableMessageException; //导入依赖的package包/类
@Nullable
@Override
public SendConf send(@NonNull byte[] pduBytes, int subscriptionId)
    throws UndeliverableMessageException
{
  if (subscriptionId == -1 || VERSION.SDK_INT < 22) {
    Log.w(TAG, "Sending via legacy connection");
    try {
      SendConf result = new OutgoingLegacyMmsConnection(context).send(pduBytes, subscriptionId);

      if (result != null && result.getResponseStatus() == PduHeaders.RESPONSE_STATUS_OK) {
        return result;
      } else {
        Log.w(TAG, "Got bad legacy response: " + (result != null ? result.getResponseStatus() : null));
      }
    } catch (UndeliverableMessageException | ApnUnavailableException e) {
      Log.w(TAG, e);
    }
  }

  if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
    return new OutgoingLollipopMmsConnection(context).send(pduBytes, subscriptionId);
  } else {
    throw new UndeliverableMessageException("Lollipop API not available to try...");
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:27,代码来源:CompatMmsConnection.java

示例2: send

import org.thoughtcrime.securesms.transport.UndeliverableMessageException; //导入依赖的package包/类
@Override
@TargetApi(VERSION_CODES.LOLLIPOP)
public @Nullable synchronized SendConf send(@NonNull byte[] pduBytes, int subscriptionId)
    throws UndeliverableMessageException
{
  beginTransaction();
  try {
    MmsBodyProvider.Pointer pointer = MmsBodyProvider.makeTemporaryPointer(getContext());
    Util.copy(new ByteArrayInputStream(pduBytes), pointer.getOutputStream());

    SmsManager smsManager;

    if (VERSION.SDK_INT >= 22 && subscriptionId != -1) {
      smsManager = SmsManager.getSmsManagerForSubscriptionId(subscriptionId);
    } else {
      smsManager = SmsManager.getDefault();
    }

    smsManager.sendMultimediaMessage(getContext(),
                                     pointer.getUri(),
                                     null,
                                     null,
                                     getPendingIntent());

    waitForResult();

    Log.w(TAG, "MMS broadcast received and processed.");
    pointer.close();

    if (response == null) {
      throw new UndeliverableMessageException("Null response.");
    }

    return (SendConf) new PduParser(response).parse();
  } catch (IOException | TimeoutException e) {
    throw new UndeliverableMessageException(e);
  } finally {
    endTransaction();
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:41,代码来源:OutgoingLollipopMmsConnection.java

示例3: getPduBytes

import org.thoughtcrime.securesms.transport.UndeliverableMessageException; //导入依赖的package包/类
private byte[] getPduBytes(SendReq message)
    throws IOException, UndeliverableMessageException, InsecureFallbackApprovalException
{
  String number = TelephonyUtil.getManager(context).getLine1Number();

  message.setBody(SmilUtil.getSmilBody(message.getBody()));

  if (!TextUtils.isEmpty(number)) {
    message.setFrom(new EncodedStringValue(number));
  }

  byte[] pduBytes = new PduComposer(context, message).make();

  if (pduBytes == null) {
    throw new UndeliverableMessageException("PDU composition failed, null payload");
  }

  return pduBytes;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:20,代码来源:MmsSendJob.java

示例4: scaleAttachments

import org.thoughtcrime.securesms.transport.UndeliverableMessageException; //导入依赖的package包/类
protected List<Attachment> scaleAttachments(@NonNull MasterSecret masterSecret,
                                            @NonNull MediaConstraints constraints,
                                            @NonNull List<Attachment> attachments)
    throws UndeliverableMessageException
{
  AttachmentDatabase attachmentDatabase = DatabaseFactory.getAttachmentDatabase(context);
  List<Attachment>   results            = new LinkedList<>();

  for (Attachment attachment : attachments) {
    try {
      if (constraints.isSatisfied(context, masterSecret, attachment)) {
        results.add(attachment);
      } else if (constraints.canResize(attachment)) {
        MediaStream resized = constraints.getResizedMedia(context, masterSecret, attachment);
        results.add(attachmentDatabase.updateAttachmentData(masterSecret, attachment, resized));
      } else {
        throw new UndeliverableMessageException("Size constraints could not be met!");
      }
    } catch (IOException | MmsException e) {
      throw new UndeliverableMessageException(e);
    }
  }

  return results;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:26,代码来源:SendJob.java

示例5: onRun

import org.thoughtcrime.securesms.transport.UndeliverableMessageException; //导入依赖的package包/类
@Override
public void onRun(MasterSecret masterSecret) throws NoSuchMessageException {
  EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
  SmsMessageRecord      record   = database.getMessage(masterSecret, messageId);

  try {
    Log.w(TAG, "Sending message: " + messageId);

    deliver(masterSecret, record);
  } catch (UndeliverableMessageException ude) {
    Log.w(TAG, ude);
    DatabaseFactory.getSmsDatabase(context).markAsSentFailed(record.getId());
    MessageNotifier.notifyMessageDeliveryFailed(context, record.getRecipients(), record.getThreadId());
  } catch (InsecureFallbackApprovalException ifae) {
    Log.w(TAG, ifae);
    DatabaseFactory.getSmsDatabase(context).markAsPendingInsecureSmsFallback(record.getId());
    MessageNotifier.notifyMessageDeliveryFailed(context, record.getRecipients(), record.getThreadId());
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:20,代码来源:SmsSendJob.java

示例6: validateDestinations

import org.thoughtcrime.securesms.transport.UndeliverableMessageException; //导入依赖的package包/类
private void validateDestinations(SendReq message) throws UndeliverableMessageException {
  if (message.getTo() != null) {
    for (EncodedStringValue to : message.getTo()) {
      validateDestination(to);
    }
  }

  if (message.getCc() != null) {
    for (EncodedStringValue cc : message.getCc()) {
      validateDestination(cc);
    }
  }

  if (message.getBcc() != null) {
    for (EncodedStringValue bcc : message.getBcc()) {
      validateDestination(bcc);
    }
  }

  if (message.getTo() == null && message.getCc() == null && message.getBcc() == null) {
    throw new UndeliverableMessageException("No to, cc, or bcc specified!");
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:24,代码来源:MmsSendJob.java

示例7: onPushSend

import org.thoughtcrime.securesms.transport.UndeliverableMessageException; //导入依赖的package包/类
@Override
public void onPushSend(MasterSecret masterSecret)
    throws RetryLaterException, MmsException, NoSuchMessageException,
           UndeliverableMessageException
{
  ExpiringMessageManager expirationManager = ApplicationContext.getInstance(context).getExpiringMessageManager();
  MmsDatabase            database          = DatabaseFactory.getMmsDatabase(context);
  OutgoingMediaMessage   message           = database.getOutgoingMessage(masterSecret, messageId);

  try {
    deliver(masterSecret, message);
    database.markAsSent(messageId, true);
    markAttachmentsUploaded(messageId, message.getAttachments());

    if (message.getExpiresIn() > 0 && !message.isExpirationUpdate()) {
      database.markExpireStarted(messageId);
      expirationManager.scheduleDeletion(messageId, true, message.getExpiresIn());
    }

  } catch (InsecureFallbackApprovalException ifae) {
    Log.w(TAG, ifae);
    database.markAsPendingInsecureSmsFallback(messageId);
    notifyMediaMessageDeliveryFailed(context, messageId);
    ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context));
  } catch (UntrustedIdentityException uie) {
    Log.w(TAG, uie);
    Recipients recipients  = RecipientFactory.getRecipientsFromString(context, uie.getE164Number(), false);
    long       recipientId = recipients.getPrimaryRecipient().getRecipientId();

    database.addMismatchedIdentity(messageId, recipientId, uie.getIdentityKey());
    database.markAsSentFailed(messageId);
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:34,代码来源:PushMediaSendJob.java

示例8: onSend

import org.thoughtcrime.securesms.transport.UndeliverableMessageException; //导入依赖的package包/类
@Override
public void onSend(MasterSecret masterSecret) throws NoSuchMessageException {
  EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
  SmsMessageRecord      record   = database.getMessage(masterSecret, messageId);

  try {
    Log.w(TAG, "Sending message: " + messageId);

    deliver(record);
  } catch (UndeliverableMessageException ude) {
    Log.w(TAG, ude);
    DatabaseFactory.getSmsDatabase(context).markAsSentFailed(record.getId());
    MessageNotifier.notifyMessageDeliveryFailed(context, record.getRecipients(), record.getThreadId());
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:16,代码来源:SmsSendJob.java

示例9: getSendResult

import org.thoughtcrime.securesms.transport.UndeliverableMessageException; //导入依赖的package包/类
private MmsSendResult getSendResult(SendConf conf, SendReq message)
    throws UndeliverableMessageException
{
  if (conf == null) {
    throw new UndeliverableMessageException("No M-Send.conf received in response to send.");
  } else if (conf.getResponseStatus() != PduHeaders.RESPONSE_STATUS_OK) {
    throw new UndeliverableMessageException("Got bad response: " + conf.getResponseStatus());
  } else if (isInconsistentResponse(message, conf)) {
    throw new UndeliverableMessageException("Mismatched response!");
  } else {
    return new MmsSendResult(conf.getMessageId(), conf.getResponseStatus());
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:14,代码来源:MmsSendJob.java

示例10: validateDestinations

import org.thoughtcrime.securesms.transport.UndeliverableMessageException; //导入依赖的package包/类
private void validateDestinations(EncodedStringValue[] destinations) throws UndeliverableMessageException {
  if (destinations == null) return;

  for (EncodedStringValue destination : destinations) {
    if (destination == null || !NumberUtil.isValidSmsOrEmail(destination.getString())) {
      throw new UndeliverableMessageException("Invalid destination: " +
                                              (destination == null ? null : destination.getString()));
    }
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:11,代码来源:MmsSendJob.java

示例11: getPduBytes

import org.thoughtcrime.securesms.transport.UndeliverableMessageException; //导入依赖的package包/类
private byte[] getPduBytes(SendReq message)
    throws IOException, UndeliverableMessageException, InsecureFallbackApprovalException
{
  byte[] pduBytes = new PduComposer(context, message).make();

  if (pduBytes == null) {
    throw new UndeliverableMessageException("PDU composition failed, null payload");
  }

  return pduBytes;
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:12,代码来源:MmsSendJob.java

示例12: deliver

import org.thoughtcrime.securesms.transport.UndeliverableMessageException; //导入依赖的package包/类
private void deliver(MasterSecret masterSecret, SmsMessageRecord record)
    throws UndeliverableMessageException, InsecureFallbackApprovalException
{
  if (!NumberUtil.isValidSmsOrEmail(record.getIndividualRecipient().getNumber())) {
    throw new UndeliverableMessageException("Not a valid SMS destination! " + record.getIndividualRecipient().getNumber());
  }

  if (record.isSecure() || record.isKeyExchange() || record.isEndSession()) {
    deliverSecureMessage(masterSecret, record);
  } else {
    deliverPlaintextMessage(record);
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:14,代码来源:SmsSendJob.java

示例13: deliverSecureMessage

import org.thoughtcrime.securesms.transport.UndeliverableMessageException; //导入依赖的package包/类
private void deliverSecureMessage(MasterSecret masterSecret, SmsMessageRecord message)
    throws UndeliverableMessageException, InsecureFallbackApprovalException
{
  MultipartSmsMessageHandler multipartMessageHandler = new MultipartSmsMessageHandler();
  OutgoingTextMessage transportMessage               = OutgoingTextMessage.from(message);

  if (message.isSecure() || message.isEndSession()) {
    transportMessage = getAsymmetricEncrypt(masterSecret, transportMessage);
  }

  ArrayList<String> messages                = multipartMessageHandler.divideMessage(transportMessage);
  ArrayList<PendingIntent> sentIntents      = constructSentIntents(message.getId(), message.getType(), messages, message.isSecure());
  ArrayList<PendingIntent> deliveredIntents = constructDeliveredIntents(message.getId(), message.getType(), messages);

  Log.w("SmsTransport", "Secure divide into message parts: " + messages.size());

  for (int i=0;i<messages.size();i++) {
    // NOTE 11/04/14 -- There's apparently a bug where for some unknown recipients
    // and messages, this will throw an NPE.  We have no idea why, so we're just
    // catching it and marking the message as a failure.  That way at least it
    // doesn't repeatedly crash every time you start the app.
    try {
      SmsManager.getDefault().sendTextMessage(message.getIndividualRecipient().getNumber(), null, messages.get(i),
                                              sentIntents.get(i),
                                              deliveredIntents == null ? null : deliveredIntents.get(i));
    } catch (NullPointerException npe) {
      Log.w(TAG, npe);
      Log.w(TAG, "Recipient: " + message.getIndividualRecipient().getNumber());
      Log.w(TAG, "Message Total Parts/Current: " + messages.size() + "/" + i);
      Log.w(TAG, "Message Part Length: " + messages.get(i).getBytes().length);
      throw new UndeliverableMessageException(npe);
    } catch (IllegalArgumentException iae) {
      Log.w(TAG, iae);
      throw new UndeliverableMessageException(iae);
    }
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:38,代码来源:SmsSendJob.java

示例14: deliverPlaintextMessage

import org.thoughtcrime.securesms.transport.UndeliverableMessageException; //导入依赖的package包/类
private void deliverPlaintextMessage(SmsMessageRecord message)
    throws UndeliverableMessageException
{
  ArrayList<String> messages                = SmsManager.getDefault().divideMessage(message.getBody().getBody());
  ArrayList<PendingIntent> sentIntents      = constructSentIntents(message.getId(), message.getType(), messages, false);
  ArrayList<PendingIntent> deliveredIntents = constructDeliveredIntents(message.getId(), message.getType(), messages);
  String recipient                          = message.getIndividualRecipient().getNumber();

  // NOTE 11/04/14 -- There's apparently a bug where for some unknown recipients
  // and messages, this will throw an NPE.  We have no idea why, so we're just
  // catching it and marking the message as a failure.  That way at least it doesn't
  // repeatedly crash every time you start the app.
  try {
    SmsManager.getDefault().sendMultipartTextMessage(recipient, null, messages, sentIntents, deliveredIntents);
  } catch (NullPointerException npe) {
    Log.w(TAG, npe);
    Log.w(TAG, "Recipient: " + recipient);
    Log.w(TAG, "Message Parts: " + messages.size());

    try {
      for (int i=0;i<messages.size();i++) {
        SmsManager.getDefault().sendTextMessage(recipient, null, messages.get(i),
                                                sentIntents.get(i),
                                                deliveredIntents == null ? null : deliveredIntents.get(i));
      }
    } catch (NullPointerException npe2) {
      Log.w(TAG, npe);
      throw new UndeliverableMessageException(npe2);
    }
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:32,代码来源:SmsSendJob.java

示例15: sendMms

import org.thoughtcrime.securesms.transport.UndeliverableMessageException; //导入依赖的package包/类
private MmsSendResult sendMms(MasterSecret masterSecret, MmsRadio radio, SendReq message,
                              boolean usingMmsRadio, boolean useProxy)
    throws IOException, UndeliverableMessageException, InsecureFallbackApprovalException
{
  String  number         = ((TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE)).getLine1Number();
  boolean upgradedSecure = false;

  if (MmsDatabase.Types.isSecureType(message.getDatabaseMessageBox())) {
    message        = getEncryptedMessage(masterSecret, message);
    upgradedSecure = true;
  }

  if (number != null && number.trim().length() != 0) {
    message.setFrom(new EncodedStringValue(number));
  }

  try {
    OutgoingMmsConnection connection = new OutgoingMmsConnection(context, radio.getApnInformation(), new PduComposer(context, message).make());
    SendConf conf = connection.send(usingMmsRadio, useProxy);

    for (int i=0;i<message.getBody().getPartsNum();i++) {
      Log.w(TAG, "Sent MMS part of content-type: " + new String(message.getBody().getPart(i).getContentType()));
    }

    if (conf == null) {
      throw new UndeliverableMessageException("No M-Send.conf received in response to send.");
    } else if (conf.getResponseStatus() != PduHeaders.RESPONSE_STATUS_OK) {
      throw new UndeliverableMessageException("Got bad response: " + conf.getResponseStatus());
    } else if (isInconsistentResponse(message, conf)) {
      throw new UndeliverableMessageException("Mismatched response!");
    } else {
      return new MmsSendResult(conf.getMessageId(), conf.getResponseStatus(), upgradedSecure, false);
    }
  } catch (ApnUnavailableException aue) {
    throw new IOException("no APN was retrievable");
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:38,代码来源:MmsSendJob.java


注:本文中的org.thoughtcrime.securesms.transport.UndeliverableMessageException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。