コード例 #1
0
 @Override
 protected void onPostExecute(Pair<Long, Recipients> groupInfo) {
   final long threadId = groupInfo.first;
   final Recipients recipients = groupInfo.second;
   if (threadId > -1) {
     Intent intent = getIntent();
     intent.putExtra(GROUP_THREAD_EXTRA, threadId);
     intent.putExtra(GROUP_RECIPIENT_EXTRA, recipients.getIds());
     setResult(RESULT_OK, intent);
     finish();
   } else if (threadId == RES_BAD_NUMBER) {
     Toast.makeText(
             getApplicationContext(),
             R.string.GroupCreateActivity_contacts_invalid_number,
             Toast.LENGTH_LONG)
         .show();
     disableWhisperGroupProgressUi();
   } else if (threadId == RES_MMS_EXCEPTION) {
     Toast.makeText(
             getApplicationContext(),
             R.string.GroupCreateActivity_contacts_mms_exception,
             Toast.LENGTH_LONG)
         .show();
     setResult(RESULT_CANCELED);
     finish();
   }
 }
コード例 #2
0
 @Override
 protected void onPostExecute(Pair<Long, Recipients> groupInfo) {
   super.onPostExecute(groupInfo);
   final long threadId = groupInfo.first;
   final Recipients recipients = groupInfo.second;
   if (threadId > -1) {
     Intent intent = new Intent(GroupCreateActivity.this, ConversationActivity.class);
     intent.putExtra(ConversationActivity.THREAD_ID_EXTRA, threadId);
     intent.putExtra(
         ConversationActivity.DISTRIBUTION_TYPE_EXTRA, ThreadDatabase.DistributionTypes.DEFAULT);
     intent.putExtra(ConversationActivity.RECIPIENTS_EXTRA, recipients.getIds());
     startActivity(intent);
     finish();
   } else if (threadId == RES_BAD_NUMBER) {
     Toast.makeText(
             getApplicationContext(),
             R.string.GroupCreateActivity_contacts_invalid_number,
             Toast.LENGTH_LONG)
         .show();
     disableWhisperGroupProgressUi();
   } else if (threadId == RES_MMS_EXCEPTION) {
     Toast.makeText(
             getApplicationContext(),
             R.string.GroupCreateActivity_contacts_mms_exception,
             Toast.LENGTH_LONG)
         .show();
     finish();
   }
 }
コード例 #3
0
  private void handleUntrustedIdentityMessage(
      MasterSecret masterSecret, TextSecureEnvelope envelope, Optional<Long> smsMessageId) {
    try {
      EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
      Recipients recipients =
          RecipientFactory.getRecipientsFromString(context, envelope.getSource(), false);
      long recipientId = recipients.getPrimaryRecipient().getRecipientId();
      PreKeyWhisperMessage whisperMessage = new PreKeyWhisperMessage(envelope.getMessage());
      IdentityKey identityKey = whisperMessage.getIdentityKey();
      String encoded = Base64.encodeBytes(envelope.getMessage());
      IncomingTextMessage textMessage =
          new IncomingTextMessage(
              envelope.getSource(),
              envelope.getSourceDevice(),
              envelope.getTimestamp(),
              encoded,
              Optional.<TextSecureGroup>absent());

      if (!smsMessageId.isPresent()) {
        IncomingPreKeyBundleMessage bundleMessage =
            new IncomingPreKeyBundleMessage(textMessage, encoded);
        Pair<Long, Long> messageAndThreadId =
            database.insertMessageInbox(masterSecret, bundleMessage);

        database.setMismatchedIdentity(messageAndThreadId.first, recipientId, identityKey);
        MessageNotifier.updateNotification(context, masterSecret, messageAndThreadId.second);
      } else {
        database.updateMessageBody(masterSecret, smsMessageId.get(), encoded);
        database.markAsPreKeyBundle(smsMessageId.get());
        database.setMismatchedIdentity(smsMessageId.get(), recipientId, identityKey);
      }
    } catch (InvalidMessageException | InvalidVersionException e) {
      throw new AssertionError(e);
    }
  }
コード例 #4
0
 @Override
 protected Void doInBackground(Void... voids) {
   final GroupDatabase db = DatabaseFactory.getGroupDatabase(GroupCreateActivity.this);
   final Recipients recipients = db.getGroupMembers(groupId, false);
   if (recipients != null) {
     final List<Recipient> recipientList = recipients.getRecipientsList();
     if (recipientList != null) {
       if (existingContacts == null) existingContacts = new HashSet<>(recipientList.size());
       existingContacts.addAll(recipientList);
     }
   }
   GroupDatabase.GroupRecord group = db.getGroup(groupId);
   if (group != null) {
     existingTitle = group.getTitle();
     final byte[] existingAvatar = group.getAvatar();
     if (existingAvatar != null) {
       existingAvatarBmp =
           BitmapFactory.decodeByteArray(existingAvatar, 0, existingAvatar.length);
     }
   }
   return null;
 }