當前位置: 首頁>>代碼示例>>Java>>正文


Java SecurityEvent類代碼示例

本文整理匯總了Java中org.thoughtcrime.securesms.crypto.SecurityEvent的典型用法代碼示例。如果您正苦於以下問題:Java SecurityEvent類的具體用法?Java SecurityEvent怎麽用?Java SecurityEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SecurityEvent類屬於org.thoughtcrime.securesms.crypto包,在下文中一共展示了SecurityEvent類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onRun

import org.thoughtcrime.securesms.crypto.SecurityEvent; //導入依賴的package包/類
@Override
public void onRun() throws IOException {
  Log.w("DirectoryRefreshJob", "DirectoryRefreshJob.onRun()");
  PowerManager          powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
  PowerManager.WakeLock wakeLock     = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Directory Refresh");

  try {
    wakeLock.acquire();
    if (recipients == null) {
      DirectoryHelper.refreshDirectory(context, KeyCachingService.getMasterSecret(context));
    } else {
      DirectoryHelper.refreshDirectoryFor(context, masterSecret, recipients, TextSecurePreferences.getLocalNumber(context));
    }
    SecurityEvent.broadcastSecurityUpdateEvent(context);
  } finally {
    if (wakeLock.isHeld()) wakeLock.release();
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:19,代碼來源:DirectoryRefreshJob.java

示例2: handleEndSessionMessage

import org.thoughtcrime.securesms.crypto.SecurityEvent; //導入依賴的package包/類
private void handleEndSessionMessage(MasterSecret masterSecret, long recipientId,
                                     TextSecureEnvelope envelope, TextSecureMessage message)
{
  IncomingTextMessage incomingTextMessage = new IncomingTextMessage(envelope.getSource(),
                                                                    envelope.getSourceDevice(),
                                                                    message.getTimestamp(),
                                                                    "", Optional.<TextSecureGroup>absent());

  IncomingEndSessionMessage incomingEndSessionMessage = new IncomingEndSessionMessage(incomingTextMessage);
  EncryptingSmsDatabase     database                  = DatabaseFactory.getEncryptingSmsDatabase(context);
  Pair<Long, Long>          messageAndThreadId        = database.insertMessageInbox(masterSecret, incomingEndSessionMessage);

  SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
  sessionStore.deleteAllSessions(recipientId);

  SecurityEvent.broadcastSecurityUpdateEvent(context, messageAndThreadId.second);
  MessageNotifier.updateNotification(context, masterSecret, messageAndThreadId.second);
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:19,代碼來源:PushDecryptJob.java

示例3: handleEndSessionMessage

import org.thoughtcrime.securesms.crypto.SecurityEvent; //導入依賴的package包/類
private void handleEndSessionMessage(@NonNull MasterSecretUnion        masterSecret,
                                     @NonNull SignalServiceEnvelope    envelope,
                                     @NonNull SignalServiceDataMessage message,
                                     @NonNull Optional<Long>           smsMessageId)
{
  EncryptingSmsDatabase smsDatabase         = DatabaseFactory.getEncryptingSmsDatabase(context);
  IncomingTextMessage   incomingTextMessage = new IncomingTextMessage(envelope.getSource(),
                                                                      envelope.getSourceDevice(),
                                                                      message.getTimestamp(),
                                                                      "", Optional.<SignalServiceGroup>absent(), 0);

  Long threadId;

  if (!smsMessageId.isPresent()) {
    IncomingEndSessionMessage incomingEndSessionMessage = new IncomingEndSessionMessage(incomingTextMessage);
    Optional<InsertResult>    insertResult              = smsDatabase.insertMessageInbox(masterSecret, incomingEndSessionMessage);

    if (insertResult.isPresent()) threadId = insertResult.get().getThreadId();
    else                          threadId = null;
  } else {
    smsDatabase.markAsEndSession(smsMessageId.get());
    threadId = smsDatabase.getThreadIdForMessage(smsMessageId.get());
  }

  if (threadId != null) {
    SessionStore sessionStore = new TextSecureSessionStore(context);
    sessionStore.deleteAllSessions(envelope.getSource());

    SecurityEvent.broadcastSecurityUpdateEvent(context);
    MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), threadId);
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:33,代碼來源:PushDecryptJob.java

示例4: handleSynchronizeSentEndSessionMessage

import org.thoughtcrime.securesms.crypto.SecurityEvent; //導入依賴的package包/類
private long handleSynchronizeSentEndSessionMessage(@NonNull MasterSecretUnion     masterSecret,
                                                    @NonNull SentTranscriptMessage message,
                                                    @NonNull Optional<Long>        smsMessageId)
{
  EncryptingSmsDatabase     database                  = DatabaseFactory.getEncryptingSmsDatabase(context);
  Recipients                recipients                = getSyncMessageDestination(message);
  OutgoingTextMessage       outgoingTextMessage       = new OutgoingTextMessage(recipients, "", -1);
  OutgoingEndSessionMessage outgoingEndSessionMessage = new OutgoingEndSessionMessage(outgoingTextMessage);

  long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipients);

  if (recipients.isSingleRecipient() && !recipients.isGroupRecipient()) {
    SessionStore sessionStore = new TextSecureSessionStore(context);
    sessionStore.deleteAllSessions(recipients.getPrimaryRecipient().getNumber());

    SecurityEvent.broadcastSecurityUpdateEvent(context);

    long messageId = database.insertMessageOutbox(masterSecret, threadId, outgoingEndSessionMessage,
                                                  false, message.getTimestamp(), null);
    database.markAsSent(messageId, true);
  }

  if (smsMessageId.isPresent()) {
    database.deleteMessage(smsMessageId.get());
  }

  return threadId;
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:29,代碼來源:PushDecryptJob.java

示例5: onSecurityEvent

import org.thoughtcrime.securesms.crypto.SecurityEvent; //導入依賴的package包/類
@Override
public void onSecurityEvent(long recipientId) {
  Recipients recipients = RecipientFactory.getRecipientsForIds(context, String.valueOf(recipientId), false);
  long       threadId   = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipients);

  SecurityEvent.broadcastSecurityUpdateEvent(context, threadId);
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:8,代碼來源:SecurityEventListener.java

示例6: initializeReceivers

import org.thoughtcrime.securesms.crypto.SecurityEvent; //導入依賴的package包/類
private void initializeReceivers() {
  securityUpdateReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
      if (intent.getLongExtra("thread_id", -1) == -1)
        return;

      if (intent.getLongExtra("thread_id", -1) == threadId) {
        initializeSecurity();
        initializeTitleBar();
        calculateCharactersRemaining();
      }
    }
  };

  groupUpdateReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
      Log.w("ConversationActivity", "Group update received...");
      if (recipients != null) {
        String ids = recipients.toIdString();
        Log.w("ConversationActivity", "Looking up new recipients...");
        recipients = RecipientFactory.getRecipientsForIds(context, ids, false);
        initializeTitleBar();
      }
    }
  };

  registerReceiver(securityUpdateReceiver,
                   new IntentFilter(SecurityEvent.SECURITY_UPDATE_EVENT),
                   KeyCachingService.KEY_PERMISSION, null);

  registerReceiver(groupUpdateReceiver,
                   new IntentFilter(GroupDatabase.DATABASE_UPDATE_ACTION));
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:36,代碼來源:ConversationActivity.java

示例7: handleSentResult

import org.thoughtcrime.securesms.crypto.SecurityEvent; //導入依賴的package包/類
private void handleSentResult(MasterSecret masterSecret, long messageId, int result) {
  try {
    EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
    SmsMessageRecord      record   = database.getMessage(masterSecret, messageId);

    switch (result) {
      case Activity.RESULT_OK:
        database.markAsSent(messageId);

        if (record != null && record.isEndSession()) {
          Log.w(TAG, "Ending session...");
          SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
          sessionStore.deleteAllSessions(record.getIndividualRecipient().getRecipientId());
          SecurityEvent.broadcastSecurityUpdateEvent(context, record.getThreadId());
        }

        break;
      case SmsManager.RESULT_ERROR_NO_SERVICE:
      case SmsManager.RESULT_ERROR_RADIO_OFF:
        Log.w(TAG, "Service connectivity problem, requeuing...");
        ApplicationContext.getInstance(context)
            .getJobManager()
            .add(new SmsSendJob(context, messageId, record.getIndividualRecipient().getNumber()));

        break;
      default:
        database.markAsSentFailed(messageId);
        MessageNotifier.notifyMessageDeliveryFailed(context, record.getRecipients(), record.getThreadId());
    }
  } catch (NoSuchMessageException e) {
    Log.w(TAG, e);
  }
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:34,代碼來源:SmsSentJob.java

示例8: onSecurityEvent

import org.thoughtcrime.securesms.crypto.SecurityEvent; //導入依賴的package包/類
@Override
public void onSecurityEvent(SignalServiceAddress textSecureAddress) {
  SecurityEvent.broadcastSecurityUpdateEvent(context);
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:5,代碼來源:SecurityEventListener.java


注:本文中的org.thoughtcrime.securesms.crypto.SecurityEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。