зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1476716
- Use DownloadManager.COLUMN_LOCAL_URI to query downloads; r=jchen
After API 24 DownloadManager.COLUMN_LOCAL_FILENAME got deprecated and querying for it would throw an error. To get around this DownloadManager.COLUMN_LOCAL_URI can be used but which adds the "file://" prefix. MozReview-Commit-ID: CvkoFyRCLo6 --HG-- extra : rebase_source : 66b0eeecf40b1b1b9fa51860f29032e02ebe507b
This commit is contained in:
Родитель
9febcf7435
Коммит
3141ebe19d
|
@ -33,6 +33,7 @@ import android.util.Log;
|
|||
public class DownloadsIntegration implements BundleEventListener
|
||||
{
|
||||
private static final String LOGTAG = "GeckoDownloadsIntegration";
|
||||
private static final String URI_FILE_PREFIX = "file://";
|
||||
|
||||
private static final List<String> UNKNOWN_MIME_TYPES;
|
||||
static {
|
||||
|
@ -72,7 +73,10 @@ public class DownloadsIntegration implements BundleEventListener
|
|||
}
|
||||
|
||||
public static Download fromCursor(final Cursor c) {
|
||||
final String path = c.getString(c.getColumnIndexOrThrow(DownloadManager.COLUMN_LOCAL_FILENAME));
|
||||
String path = c.getString(c.getColumnIndexOrThrow(DownloadManager.COLUMN_LOCAL_URI));
|
||||
if (path.contains(URI_FILE_PREFIX)) {
|
||||
path = path.replace(URI_FILE_PREFIX, "");
|
||||
}
|
||||
final long id = c.getLong(c.getColumnIndexOrThrow(DownloadManager.COLUMN_ID));
|
||||
return new Download(path, id);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче