本文整理汇总了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);
}
示例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());
}
示例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.");
}
示例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);
}
示例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;
}
示例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);
}
}
示例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.");
}
示例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!");
}
}
示例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);
}
}
示例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();
}
}
示例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;
}
示例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);
}
}
示例13: isPresent
import org.thoughtcrime.securesms.service.KeyCachingService; //导入方法依赖的package包/类
@Override
public boolean isPresent() {
return KeyCachingService.getMasterSecret(context) != null;
}
示例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;
}
示例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);
}