use of org.thoughtcrime.securesms.mms.PartUriParser in project Signal-Android by WhisperSystems.
the class PartProvider method openFile.
@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.");
}
Aggregations