use of android.app.DownloadManager in project AndroidChromium by JackyAndroid.
the class DownloadManagerService method getLaunchIntentFromDownloadId.
/**
* Return the intent to launch for a given download item.
*
* @param context Context of the app.
* @param filePath Path to the file.
* @param downloadId ID of the download item in DownloadManager.
* @param isSupportedMimeType Whether the MIME type is supported by browser.
* @return the intent to launch for the given download item.
*/
static Intent getLaunchIntentFromDownloadId(Context context, @Nullable String filePath, long downloadId, boolean isSupportedMimeType) {
assert !ThreadUtils.runningOnUiThread();
DownloadManager manager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
Uri contentUri = manager.getUriForDownloadedFile(downloadId);
if (contentUri == null)
return null;
String mimeType = manager.getMimeTypeForDownloadedFile(downloadId);
if (isSupportedMimeType) {
// Redirect the user to an internal media viewer. The file path is necessary to show
// the real file path to the user instead of a content:// download ID.
Uri fileUri = contentUri;
if (filePath != null)
fileUri = Uri.fromFile(new File(filePath));
return DownloadUtils.getMediaViewerIntentForDownloadItem(fileUri, contentUri, mimeType);
}
return DownloadUtils.createViewIntentForDownloadItem(contentUri, mimeType);
}
use of android.app.DownloadManager in project platform_frameworks_base by android.
the class FilesActivityUiTest method testDownload_Queued.
// We don't really need to test the entirety of download support
// since downloads is (almost) just another provider.
@Suppress
public void testDownload_Queued() throws Exception {
DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
// This downloads ends up being queued (because DNS can't be resolved).
// We'll still see an entry in the downloads UI with a "Queued" label.
dm.enqueue(new Request(Uri.parse("http://hammychamp.toodles")));
bots.roots.openRoot("Downloads");
bots.directory.assertDocumentsPresent("Queued");
}
use of android.app.DownloadManager in project platform_frameworks_base by android.
the class FilesActivityUiTest method testDownload_RetryUnsuccessful.
@Suppress
public void testDownload_RetryUnsuccessful() throws Exception {
DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
// This downloads fails! But it'll still show up.
dm.enqueue(new Request(Uri.parse("http://www.google.com/hamfancy")));
bots.roots.openRoot("Downloads");
UiObject doc = bots.directory.findDocument("Unsuccessful");
doc.waitForExists(TIMEOUT);
int toolType = Configurator.getInstance().getToolType();
Configurator.getInstance().setToolType(MotionEvent.TOOL_TYPE_FINGER);
doc.click();
Configurator.getInstance().setToolType(toolType);
assertTrue(bots.main.findDownloadRetryDialog().exists());
// to clear the dialog.
device.pressBack();
}
use of android.app.DownloadManager in project android_frameworks_base by DirtyUnicorns.
the class FilesActivityUiTest method testDownload_Queued.
// We don't really need to test the entirety of download support
// since downloads is (almost) just another provider.
@Suppress
public void testDownload_Queued() throws Exception {
DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
// This downloads ends up being queued (because DNS can't be resolved).
// We'll still see an entry in the downloads UI with a "Queued" label.
dm.enqueue(new Request(Uri.parse("http://hammychamp.toodles")));
bots.roots.openRoot("Downloads");
bots.directory.assertDocumentsPresent("Queued");
}
use of android.app.DownloadManager in project android_frameworks_base by DirtyUnicorns.
the class FilesActivityUiTest method testDownload_RetryUnsuccessful.
@Suppress
public void testDownload_RetryUnsuccessful() throws Exception {
DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
// This downloads fails! But it'll still show up.
dm.enqueue(new Request(Uri.parse("http://www.google.com/hamfancy")));
bots.roots.openRoot("Downloads");
UiObject doc = bots.directory.findDocument("Unsuccessful");
doc.waitForExists(TIMEOUT);
int toolType = Configurator.getInstance().getToolType();
Configurator.getInstance().setToolType(MotionEvent.TOOL_TYPE_FINGER);
doc.click();
Configurator.getInstance().setToolType(toolType);
assertTrue(bots.main.findDownloadRetryDialog().exists());
// to clear the dialog.
device.pressBack();
}
Aggregations