Commit d4c5c517 authored by Min Qin's avatar Min Qin Committed by Commit Bot

Work around an issue that Content uri from DownloadManager is not working for other apps

On certain android versions, content URI from the DownloadManager can not be read by other apps
This CL works around the problem by using the file uri.

BUG=722383

Change-Id: I30ee7ab0ad16f9e13a5d43a1b1f50fe7425078ad
Reviewed-on: https://chromium-review.googlesource.com/530047
Commit-Queue: Min Qin <qinmin@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Cr-Commit-Position: refs/heads/master@{#478694}
parent ea3b6c19
...@@ -18,6 +18,7 @@ import android.support.annotation.Nullable; ...@@ -18,6 +18,7 @@ import android.support.annotation.Nullable;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Pair; import android.util.Pair;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.base.ObserverList; import org.chromium.base.ObserverList;
...@@ -737,8 +738,9 @@ public class DownloadManagerService ...@@ -737,8 +738,9 @@ public class DownloadManagerService
Context context, @Nullable String filePath, long downloadId, Context context, @Nullable String filePath, long downloadId,
boolean isSupportedMimeType) { boolean isSupportedMimeType) {
assert !ThreadUtils.runningOnUiThread(); assert !ThreadUtils.runningOnUiThread();
Uri contentUri = DownloadManagerDelegate.getContentUriFromDownloadManager( Uri contentUri = filePath == null
context, downloadId); ? DownloadManagerDelegate.getContentUriFromDownloadManager(context, downloadId)
: ApiCompatibilityUtils.getUriForDownloadedFile(new File(filePath));
if (contentUri == null) return null; if (contentUri == null) return null;
DownloadManager manager = DownloadManager manager =
......
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