Use FileProvider for update file handling

Fixes #7654
Closes #7658
This commit is contained in:
Henning Dodenhof 2018-04-06 19:35:11 +02:00 committed by Moxie Marlinspike
parent 2a1ce859c4
commit e0603abdd3
2 changed files with 4 additions and 2 deletions

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<paths> <paths>
<external-cache-path name="external_cache" path="." /> <external-cache-path name="external_cache" path="." />
<external-files-path name="external_files" path="." />
<external-path name="external_pictures" path="Pictures"/> <external-path name="external_pictures" path="Pictures"/>
<external-path name="external_video" path="Movies"/> <external-path name="external_video" path="Movies"/>

View File

@ -14,6 +14,7 @@ import android.support.v4.app.NotificationCompat;
import android.util.Log; import android.util.Log;
import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.util.FileProviderUtil;
import org.thoughtcrime.securesms.util.FileUtils; import org.thoughtcrime.securesms.util.FileUtils;
import org.thoughtcrime.securesms.util.Hex; import org.thoughtcrime.securesms.util.Hex;
import org.thoughtcrime.securesms.util.ServiceUtil; import org.thoughtcrime.securesms.util.ServiceUtil;
@ -55,7 +56,7 @@ public class UpdateApkReadyListener extends BroadcastReceiver {
private void displayInstallNotification(Context context, Uri uri) { private void displayInstallNotification(Context context, Uri uri) {
Intent intent = new Intent(Intent.ACTION_VIEW); Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setDataAndType(uri, "application/vnd.android.package-archive"); intent.setDataAndType(uri, "application/vnd.android.package-archive");
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
@ -87,7 +88,7 @@ public class UpdateApkReadyListener extends BroadcastReceiver {
if (localUri != null) { if (localUri != null) {
File localFile = new File(Uri.parse(localUri).getPath()); File localFile = new File(Uri.parse(localUri).getPath());
return Uri.fromFile(localFile); return FileProviderUtil.getUriFor(context, localFile);
} }
} }
} finally { } finally {