use of android.support.annotation.NonNull in project Signal-Android by WhisperSystems.
the class IdentityKeyUtil method getIdentityKeyPair.
@NonNull
public static IdentityKeyPair getIdentityKeyPair(@NonNull Context context) {
if (!hasIdentityKey(context))
throw new AssertionError("There isn't one!");
try {
IdentityKey publicKey = getIdentityKey(context);
ECPrivateKey privateKey = Curve.decodePrivatePoint(Base64.decode(retrieve(context, IDENTITY_PRIVATE_KEY_PREF)));
return new IdentityKeyPair(publicKey, privateKey);
} catch (IOException e) {
throw new AssertionError(e);
}
}
use of android.support.annotation.NonNull in project Signal-Android by WhisperSystems.
the class AttachmentDatabase method getPendingAttachments.
@NonNull
public List<DatabaseAttachment> getPendingAttachments() {
final SQLiteDatabase database = databaseHelper.getReadableDatabase();
final List<DatabaseAttachment> attachments = new LinkedList<>();
Cursor cursor = null;
try {
cursor = database.query(TABLE_NAME, PROJECTION, TRANSFER_STATE + " = ?", new String[] { String.valueOf(TRANSFER_PROGRESS_STARTED) }, null, null, null);
while (cursor != null && cursor.moveToNext()) {
attachments.add(getAttachment(cursor));
}
} finally {
if (cursor != null)
cursor.close();
}
return attachments;
}
use of android.support.annotation.NonNull in project Signal-Android by WhisperSystems.
the class AttachmentDatabase method getAttachmentsForMessage.
@NonNull
public List<DatabaseAttachment> getAttachmentsForMessage(long mmsId) {
SQLiteDatabase database = databaseHelper.getReadableDatabase();
List<DatabaseAttachment> results = new LinkedList<>();
Cursor cursor = null;
try {
cursor = database.query(TABLE_NAME, PROJECTION, MMS_ID + " = ?", new String[] { mmsId + "" }, null, null, null);
while (cursor != null && cursor.moveToNext()) {
results.add(getAttachment(cursor));
}
return results;
} finally {
if (cursor != null)
cursor.close();
}
}
use of android.support.annotation.NonNull in project Signal-Android by WhisperSystems.
the class AttachmentDatabase method setAttachmentData.
@NonNull
private Pair<File, Long> setAttachmentData(@NonNull MasterSecret masterSecret, @NonNull InputStream in) throws MmsException {
try {
File partsDirectory = context.getDir("parts", Context.MODE_PRIVATE);
File dataFile = File.createTempFile("part", ".mms", partsDirectory);
return new Pair<>(dataFile, setAttachmentData(masterSecret, dataFile, in));
} catch (IOException e) {
throw new MmsException(e);
}
}
use of android.support.annotation.NonNull in project Signal-Android by WhisperSystems.
the class SmsDatabase method insertCallLog.
@NonNull
private Pair<Long, Long> insertCallLog(@NonNull String number, long type, boolean unread) {
Recipients recipients = RecipientFactory.getRecipientsFromString(context, number, true);
long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipients);
ContentValues values = new ContentValues(6);
values.put(ADDRESS, number);
values.put(ADDRESS_DEVICE_ID, 1);
values.put(DATE_RECEIVED, System.currentTimeMillis());
values.put(DATE_SENT, System.currentTimeMillis());
values.put(READ, unread ? 0 : 1);
values.put(TYPE, type);
values.put(THREAD_ID, threadId);
SQLiteDatabase db = databaseHelper.getWritableDatabase();
long messageId = db.insert(TABLE_NAME, null, values);
DatabaseFactory.getThreadDatabase(context).update(threadId, true);
notifyConversationListeners(threadId);
jobManager.add(new TrimThreadJob(context, threadId));
if (unread) {
DatabaseFactory.getThreadDatabase(context).setUnread(threadId);
}
return new Pair<>(messageId, threadId);
}
Aggregations