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


Java KeyCachingService.getMasterSecret方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: openFile

import org.thoughtcrime.securesms.service.KeyCachingService; //导入方法依赖的package包/类
@Override
public ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode) throws FileNotFoundException {
  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 {
      PartUriParser        partUri = new PartUriParser(uri);
      File                 tmpFile = copyPartToTemporaryFile(masterSecret, partUri.getPartId());
      ParcelFileDescriptor pdf     = ParcelFileDescriptor.open(tmpFile, ParcelFileDescriptor.MODE_READ_ONLY);

      if (!tmpFile.delete()) {
        Log.w(TAG, "Failed to delete temp file.");
      }

      return pdf;
    } catch (IOException ioe) {
      Log.w(TAG, ioe);
      throw new FileNotFoundException("Error opening file");
    }
  }

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

示例8: onRun

import org.thoughtcrime.securesms.service.KeyCachingService; //导入方法依赖的package包/类
@Override
public void onRun() {
  Log.w(TAG, "onRun()");
  
  Optional<IncomingTextMessage> message      = assembleMessageFragments(pdus, subscriptionId);
  MasterSecret                  masterSecret = KeyCachingService.getMasterSecret(context);

  MasterSecretUnion masterSecretUnion;

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

  if (message.isPresent() && !isBlocked(message.get())) {
    Optional<InsertResult> insertResult = storeMessage(masterSecretUnion, message.get());

    if (insertResult.isPresent()) {
      MessageNotifier.updateNotification(context, masterSecret, insertResult.get().getThreadId());
    }
  } else if (message.isPresent()) {
    Log.w(TAG, "*** Received blocked SMS, ignoring...");
  } else {
    Log.w(TAG, "*** Failed to assemble message fragments!");
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:28,代码来源:SmsReceiveJob.java

示例9: onAdded

import org.thoughtcrime.securesms.service.KeyCachingService; //导入方法依赖的package包/类
@Override
public void onAdded() {
  if (automatic && KeyCachingService.getMasterSecret(context) == null) {
    DatabaseFactory.getMmsDatabase(context).markIncomingNotificationReceived(threadId);
    MessageNotifier.updateNotification(context, null);
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:8,代码来源:MmsDownloadJob.java

示例10: decode

import org.thoughtcrime.securesms.service.KeyCachingService; //导入方法依赖的package包/类
@Override
public Bitmap decode(Context context, Uri uri) throws Exception {
  if (!PartAuthority.isLocalUri(uri)) {
    return new SkiaImageDecoder().decode(context, uri);
  }

  MasterSecret masterSecret = KeyCachingService.getMasterSecret(context);

  if (masterSecret == null) {
    throw new IllegalStateException("Can't decode without secret");
  }

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

  try {
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inPreferredConfig = Bitmap.Config.ARGB_8888;

    Bitmap bitmap = BitmapFactory.decodeStream(inputStream, null, options);

    if (bitmap == null) {
      throw new RuntimeException("Skia image region decoder returned null bitmap - image format may not be supported");
    }

    return bitmap;
  } finally {
    if (inputStream != null) inputStream.close();
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:30,代码来源:AttachmentBitmapDecoder.java

示例11: query

import org.thoughtcrime.securesms.service.KeyCachingService; //导入方法依赖的package包/类
@Override
public Cursor query(@NonNull Uri url, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
  Log.w(TAG, "query() called: " + url);
  MasterSecret masterSecret = KeyCachingService.getMasterSecret(getContext());

  if (projection == null || projection.length <= 0) return null;

  switch (uriMatcher.match(url)) {
    case SINGLE_ROW:
      PartUriParser      partUri      = new PartUriParser(url);
      DatabaseAttachment attachment   = DatabaseFactory.getAttachmentDatabase(getContext()).getAttachment(masterSecret, partUri.getPartId());

      if (attachment == null) return null;

      MatrixCursor       matrixCursor = new MatrixCursor(projection, 1);
      Object[]           resultRow    = new Object[projection.length];

      for (int i=0;i<projection.length;i++) {
        if (OpenableColumns.DISPLAY_NAME.equals(projection[i])) {
          resultRow[i] = attachment.getFileName();
        }
      }

      matrixCursor.addRow(resultRow);
      return matrixCursor;
  }

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

示例12: initializeFromMasterSecret

import org.thoughtcrime.securesms.service.KeyCachingService; //导入方法依赖的package包/类
private <T extends Activity & PassphraseRequiredActivity> void initializeFromMasterSecret(T activity) {
  MasterSecret masterSecret = KeyCachingService.getMasterSecret(activity);

  if (masterSecret == null) {
    activity.onMasterSecretCleared();
  } else {
    activity.onNewMasterSecret(masterSecret);
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:10,代码来源:PassphraseRequiredMixin.java

示例13: isPresent

import org.thoughtcrime.securesms.service.KeyCachingService; //导入方法依赖的package包/类
@Override
public boolean isPresent() {
  return KeyCachingService.getMasterSecret(context) != null;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:5,代码来源:MasterSecretRequirement.java

示例14: getMasterSecret

import org.thoughtcrime.securesms.service.KeyCachingService; //导入方法依赖的package包/类
private MasterSecret getMasterSecret() throws RequirementNotMetException {
  MasterSecret masterSecret = KeyCachingService.getMasterSecret(context);

  if (masterSecret == null) throw new RequirementNotMetException();
  else                      return masterSecret;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:7,代码来源:MasterSecretJob.java

示例15: onReceive

import org.thoughtcrime.securesms.service.KeyCachingService; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
  MasterSecret masterSecret  = KeyCachingService.getMasterSecret(context);
  int          reminderCount = intent.getIntExtra("reminder_count", 0);
  MessageNotifier.updateNotification(context, masterSecret, true, reminderCount + 1);
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:7,代码来源:MessageNotifier.java


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