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


Java KeyCachingService类代码示例

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


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

示例1: onServiceConnected

import org.thoughtcrime.securesms.service.KeyCachingService; //导入依赖的package包/类
@Override
public void onServiceConnected(ComponentName className, IBinder service) {
  keyCachingService = ((KeyCachingService.KeySetBinder)service).getService();
  keyCachingService.setMasterSecret(masterSecret);

  PassphraseActivity.this.unbindService(PassphraseActivity.this.serviceConnection);

  masterSecret = null;
  cleanup();

  Intent nextIntent = getIntent().getParcelableExtra("next_intent");
  if (nextIntent != null) {
      try {
          startActivity(nextIntent);
      } catch (java.lang.SecurityException e) {
          Log.w("PassphraseActivity",
                  "Access permission not passed from PassphraseActivity, retry sharing.");
      }
  }
  finish();
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:22,代码来源:PassphraseActivity.java

示例2: onRun

import org.thoughtcrime.securesms.service.KeyCachingService; //导入依赖的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

示例3: onRun

import org.thoughtcrime.securesms.service.KeyCachingService; //导入依赖的package包/类
@Override
public void onRun() throws NoSuchMessageException {

  if (!IdentityKeyUtil.hasIdentityKey(context)) {
    Log.w(TAG, "Skipping job, waiting for migration...");
    MessageNotifier.updateNotification(context, null, true, -2);
    return;
  }

  MasterSecret          masterSecret         = KeyCachingService.getMasterSecret(context);
  PushDatabase          database             = DatabaseFactory.getPushDatabase(context);
  SignalServiceEnvelope envelope             = database.get(messageId);
  Optional<Long>        optionalSmsMessageId = smsMessageId > 0 ? Optional.of(smsMessageId) :
                                                               Optional.<Long>absent();

  MasterSecretUnion masterSecretUnion;

  if (masterSecret == null) masterSecretUnion = new MasterSecretUnion(MasterSecretUtil.getAsymmetricMasterSecret(context, null));
  else                      masterSecretUnion = new MasterSecretUnion(masterSecret);

  handleMessage(masterSecretUnion, envelope, optionalSmsMessageId);
  database.delete(messageId);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:24,代码来源:PushDecryptJob.java

示例4: handle

import org.thoughtcrime.securesms.service.KeyCachingService; //导入依赖的package包/类
public void handle(SignalServiceEnvelope envelope, boolean sendExplicitReceipt) {
  if (!isActiveNumber(context, envelope.getSource())) {
    TextSecureDirectory directory           = TextSecureDirectory.getInstance(context);
    ContactTokenDetails contactTokenDetails = new ContactTokenDetails();
    contactTokenDetails.setNumber(envelope.getSource());

    directory.setNumber(contactTokenDetails, true);

    Recipients recipients = RecipientFactory.getRecipientsFromString(context, envelope.getSource(), false);
    ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context, KeyCachingService.getMasterSecret(context), recipients));
  }

  if (envelope.isReceipt()) {
    handleReceipt(envelope);
  } else if (envelope.isPreKeySignalMessage() || envelope.isSignalMessage()) {
    handleMessage(envelope, sendExplicitReceipt);
  } else {
    Log.w(TAG, "Received envelope of unknown type: " + envelope.getType());
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:21,代码来源:PushReceivedJob.java

示例5: init

import org.thoughtcrime.securesms.service.KeyCachingService; //导入依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.GINGERBREAD_MR1)
@Override
public Point init(Context context, Uri uri) throws Exception {
  Log.w(TAG, "Init!");
  if (!PartAuthority.isLocalUri(uri)) {
    passthrough = new SkiaImageRegionDecoder();
    return passthrough.init(context, uri);
  }

  MasterSecret masterSecret = KeyCachingService.getMasterSecret(context);

  if (masterSecret == null) {
    throw new IllegalStateException("No master secret available...");
  }

  InputStream inputStream = PartAuthority.getAttachmentStream(context, masterSecret, uri);

  this.bitmapRegionDecoder = BitmapRegionDecoder.newInstance(inputStream, false);
  inputStream.close();

  return new Point(bitmapRegionDecoder.getWidth(), bitmapRegionDecoder.getHeight());
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:23,代码来源:AttachmentRegionDecoder.java

示例6: openFile

import org.thoughtcrime.securesms.service.KeyCachingService; //导入依赖的package包/类
@Override
public ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode) throws FileNotFoundException {
  final MasterSecret masterSecret = KeyCachingService.getMasterSecret(getContext());
  Log.w(TAG, "openFile() called!");

  if (masterSecret == null) {
    Log.w(TAG, "masterSecret was null, abandoning.");
    return null;
  }

  switch (uriMatcher.match(uri)) {
  case SINGLE_ROW:
    Log.w(TAG, "Parting out a single row...");
    try {
      final PartUriParser partUri = new PartUriParser(uri);
      return getParcelStreamForAttachment(masterSecret, partUri.getPartId());
    } catch (IOException ioe) {
      Log.w(TAG, ioe);
      throw new FileNotFoundException("Error opening file");
    }
  }

  throw new FileNotFoundException("Request for bad part.");
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:25,代码来源:PartProvider.java

示例7: onRun

import org.thoughtcrime.securesms.service.KeyCachingService; //导入依赖的package包/类
@Override
public void onRun() throws NoSuchMessageException {

  if (!IdentityKeyUtil.hasIdentityKey(context)) {
    Log.w(TAG, "Skipping job, waiting for migration...");
    return;
  }

  MasterSecret          masterSecret         = KeyCachingService.getMasterSecret(context);
  PushDatabase          database             = DatabaseFactory.getPushDatabase(context);
  SignalServiceEnvelope envelope             = database.get(messageId);
  Optional<Long>        optionalSmsMessageId = smsMessageId > 0 ? Optional.of(smsMessageId) :
                                                               Optional.<Long>absent();

  MasterSecretUnion masterSecretUnion;

  if (masterSecret == null) masterSecretUnion = new MasterSecretUnion(MasterSecretUtil.getAsymmetricMasterSecret(context, null));
  else                      masterSecretUnion = new MasterSecretUnion(masterSecret);

  handleMessage(masterSecretUnion, envelope, optionalSmsMessageId);
  database.delete(messageId);
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:23,代码来源:PushDecryptJob.java

示例8: storeMessage

import org.thoughtcrime.securesms.service.KeyCachingService; //导入依赖的package包/类
private Pair<Long, Long> storeMessage(IncomingTextMessage message) {
  EncryptingSmsDatabase database     = DatabaseFactory.getEncryptingSmsDatabase(context);
  MasterSecret          masterSecret = KeyCachingService.getMasterSecret(context);

  Pair<Long, Long> messageAndThreadId;

  if (message.isSecureMessage()) {
    messageAndThreadId = database.insertMessageInbox((MasterSecret)null, message);
  } else if (masterSecret == null) {
    messageAndThreadId = database.insertMessageInbox(MasterSecretUtil.getAsymmetricMasterSecret(context, null), message);
  } else {
    messageAndThreadId = database.insertMessageInbox(masterSecret, message);
  }

  if (masterSecret == null || message.isSecureMessage() || message.isKeyExchange()) {
    ApplicationContext.getInstance(context)
                      .getJobManager()
                      .add(new SmsDecryptJob(context, messageAndThreadId.first));
  } else {
    MessageNotifier.updateNotification(context, masterSecret, messageAndThreadId.second);
  }

  return messageAndThreadId;
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:25,代码来源:SmsReceiveJob.java

示例9: cancelOrphanedNotifications

import org.thoughtcrime.securesms.service.KeyCachingService; //导入依赖的package包/类
private static void cancelOrphanedNotifications(@NonNull Context context, NotificationState notificationState) {
  if (Build.VERSION.SDK_INT >= 23) {
    try {
      NotificationManager     notifications       = ServiceUtil.getNotificationManager(context);
      StatusBarNotification[] activeNotifications = notifications.getActiveNotifications();

      for (StatusBarNotification notification : activeNotifications) {
        boolean validNotification = false;

        if (notification.getId() != SUMMARY_NOTIFICATION_ID &&
                notification.getId() != CallNotificationBuilder.WEBRTC_NOTIFICATION   &&
                notification.getId() != KeyCachingService.SERVICE_RUNNING_ID          &&
                notification.getId() != MessageRetrievalService.FOREGROUND_ID)
        {
          for (NotificationItem item : notificationState.getNotifications()) {
            if (notification.getId() == (SUMMARY_NOTIFICATION_ID + item.getThreadId())) {
              validNotification = true;
              break;
            }
          }

          if (!validNotification) {
            notifications.cancel(notification.getId());
          }
        }
      }
    } catch (Throwable e) {
      // XXX Android ROM Bug, see #6043
      Log.w(TAG, e);
    }
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:33,代码来源:MessageNotifier.java

示例10: onReceive

import org.thoughtcrime.securesms.service.KeyCachingService; //导入依赖的package包/类
@Override
public void onReceive(final Context context, final Intent intent) {
  new AsyncTask<Void, Void, Void>() {
    @Override
    protected Void doInBackground(Void... params) {
      MasterSecret masterSecret  = KeyCachingService.getMasterSecret(context);
      int          reminderCount = intent.getIntExtra("reminder_count", 0);
      MessageNotifier.updateNotification(context, masterSecret, true, false, reminderCount + 1);

      return null;
    }
  }.execute();
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:14,代码来源:MessageNotifier.java

示例11: onPerformSync

import org.thoughtcrime.securesms.service.KeyCachingService; //导入依赖的package包/类
@Override
public void onPerformSync(Account account, Bundle extras, String authority,
                          ContentProviderClient provider, SyncResult syncResult)
{
  Log.w(TAG, "onPerformSync(" + authority +")");

  if (TextSecurePreferences.isPushRegistered(getContext())) {
    try {
      DirectoryHelper.refreshDirectory(getContext(), KeyCachingService.getMasterSecret(getContext()));
    } catch (IOException e) {
      Log.w(TAG, e);
    }
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:15,代码来源:ContactsSyncAdapter.java

示例12: onCreate

import org.thoughtcrime.securesms.service.KeyCachingService; //导入依赖的package包/类
@Override
protected final void onCreate(Bundle savedInstanceState) {
  Log.w(TAG, "onCreate(" + savedInstanceState + ")");
  this.networkAccess = new SignalServiceNetworkAccess(this);
  onPreCreate();
  final MasterSecret masterSecret = KeyCachingService.getMasterSecret(this);
  routeApplicationState(masterSecret);
  super.onCreate(savedInstanceState);
  if (!isFinishing()) {
    initializeClearKeyReceiver();
    onCreate(savedInstanceState, masterSecret);
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:14,代码来源:PassphraseRequiredActionBarActivity.java

示例13: onResume

import org.thoughtcrime.securesms.service.KeyCachingService; //导入依赖的package包/类
@Override
protected void onResume() {
  Log.w(TAG, "onResume()");
  super.onResume();
  KeyCachingService.registerPassphraseActivityStarted(this);

  if (!networkAccess.isCensored(this)) MessageRetrievalService.registerActivityStarted(this);
  else                                 ApplicationContext.getInstance(this).getJobManager().add(new PushNotificationReceiveJob(this));

  isVisible = true;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:12,代码来源:PassphraseRequiredActionBarActivity.java

示例14: onPause

import org.thoughtcrime.securesms.service.KeyCachingService; //导入依赖的package包/类
@Override
protected void onPause() {
  Log.w(TAG, "onPause()");
  super.onPause();
  KeyCachingService.registerPassphraseActivityStopped(this);

  if (!networkAccess.isCensored(this)) MessageRetrievalService.registerActivityStopped(this);

  isVisible = false;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:11,代码来源:PassphraseRequiredActionBarActivity.java

示例15: initializeClearKeyReceiver

import org.thoughtcrime.securesms.service.KeyCachingService; //导入依赖的package包/类
private void initializeClearKeyReceiver() {
  Log.w(TAG, "initializeClearKeyReceiver()");
  this.clearKeyReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
      Log.w(TAG, "onReceive() for clear key event");
      onMasterSecretCleared();
    }
  };

  IntentFilter filter = new IntentFilter(KeyCachingService.CLEAR_KEY_EVENT);
  registerReceiver(clearKeyReceiver, filter, KeyCachingService.KEY_PERMISSION, null);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:14,代码来源:PassphraseRequiredActionBarActivity.java


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