Search in sources :

Example 16 with MasterSecret

use of org.thoughtcrime.securesms.crypto.MasterSecret in project Signal-Android by WhisperSystems.

the class SaveAttachmentTask method doInBackground.

@Override
protected Integer doInBackground(SaveAttachmentTask.Attachment... attachments) {
    if (attachments == null || attachments.length == 0) {
        throw new AssertionError("must pass in at least one attachment");
    }
    try {
        Context context = contextReference.get();
        MasterSecret masterSecret = masterSecretReference.get();
        if (!Environment.getExternalStorageDirectory().canWrite()) {
            return WRITE_ACCESS_FAILURE;
        }
        if (context == null) {
            return FAILURE;
        }
        for (Attachment attachment : attachments) {
            if (attachment != null && !saveAttachment(context, masterSecret, attachment)) {
                return FAILURE;
            }
        }
        return SUCCESS;
    } catch (IOException ioe) {
        Log.w(TAG, ioe);
        return FAILURE;
    }
}
Also used : Context(android.content.Context) MasterSecret(org.thoughtcrime.securesms.crypto.MasterSecret) IOException(java.io.IOException)

Aggregations

MasterSecret (org.thoughtcrime.securesms.crypto.MasterSecret)16 MasterCipher (org.thoughtcrime.securesms.crypto.MasterCipher)4 IOException (java.io.IOException)3 InvalidPassphraseException (org.thoughtcrime.securesms.crypto.InvalidPassphraseException)3 PendingIntent (android.app.PendingIntent)2 Context (android.content.Context)2 Intent (android.content.Intent)2 Bitmap (android.graphics.Bitmap)2 InputStream (java.io.InputStream)2 MasterSecretUnion (org.thoughtcrime.securesms.crypto.MasterSecretUnion)2 ThreadDatabase (org.thoughtcrime.securesms.database.ThreadDatabase)2 ComponentName (android.content.ComponentName)1 Cursor (android.database.Cursor)1 BitmapFactory (android.graphics.BitmapFactory)1 Point (android.graphics.Point)1 Drawable (android.graphics.drawable.Drawable)1 Bundle (android.os.Bundle)1 ParcelFileDescriptor (android.os.ParcelFileDescriptor)1 ChooserTarget (android.service.chooser.ChooserTarget)1 Nullable (android.support.annotation.Nullable)1