Commit 69c4d120 authored by Moxie Marlinspike's avatar Moxie Marlinspike Committed by Bastien Le Querrec
parent 1192ff74
......@@ -409,6 +409,15 @@
</intent-filter>
</receiver>
<provider android:name="android.support.v4.content.FileProvider"
android:authorities="org.smssecure.smssecure.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_provider_paths" />
</provider>
<receiver android:enabled="true"
android:name=".service.BootReceiver">
<intent-filter>
......
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-cache-path name="external_cache" path="." />
<external-files-path name="external_files" path="." />
</paths>
\ No newline at end of file
......@@ -5,14 +5,17 @@ import android.content.ContentUris;
import android.content.Context;
import android.content.UriMatcher;
import android.net.Uri;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.FileProvider;
import android.util.Log;
import android.webkit.MimeTypeMap;
import org.smssecure.smssecure.crypto.DecryptingPartInputStream;
import org.smssecure.smssecure.crypto.EncryptingPartOutputStream;
import org.smssecure.smssecure.crypto.MasterSecret;
import org.smssecure.smssecure.util.FileProviderUtil;
import org.smssecure.smssecure.util.Util;
import java.io.ByteArrayInputStream;
......@@ -107,8 +110,8 @@ public class PersistentBlobProvider {
}
public Uri createForExternal(@NonNull String mimeType) throws IOException {
return Uri.fromFile(new File(getExternalDir(context),
String.valueOf(System.currentTimeMillis()) + "." + getExtensionFromMimeType(mimeType)));
File target = new File(getExternalDir(context), String.valueOf(System.currentTimeMillis()) + "." + getExtensionFromMimeType(mimeType));
return FileProviderUtil.getUriFor(context, target);
}
public boolean delete(@NonNull Uri uri) {
......
package org.smssecure.smssecure.util;
import android.content.Context;
import android.net.Uri;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v4.content.FileProvider;
import java.io.File;
public class FileProviderUtil {
private static final String AUTHORITY = "org.smssecure.smssecure.fileprovider";
public static Uri getUriFor(@NonNull Context context, @NonNull File file) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) return FileProvider.getUriForFile(context, AUTHORITY, file);
else return Uri.fromFile(file);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment