diff options
author | Jeff Sharkey <jsharkey@android.com> | 2016-04-20 23:23:09 -0600 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2016-04-25 12:59:46 -0600 |
commit | 3a5f5eafb34eaa4963c801882148e8f61514a61b (patch) | |
tree | c38ae2f58cb39e4e17be37e8eec2fe040b4b6436 /tests/src/com/android/providers/downloads/DownloadProviderFunctionalTest.java | |
parent | dbcd4cfe7f0fed77a77afb1c1d242a508fc5462a (diff) | |
download | android_packages_providers_DownloadProvider-3a5f5eafb34eaa4963c801882148e8f61514a61b.tar.gz android_packages_providers_DownloadProvider-3a5f5eafb34eaa4963c801882148e8f61514a61b.tar.bz2 android_packages_providers_DownloadProvider-3a5f5eafb34eaa4963c801882148e8f61514a61b.zip |
Move DownloadManager to use JobScheduler.
JobScheduler is in a much better position to coordinate tasks across
the platform to optimize battery and RAM usage. This change removes
a bunch of manual scheduling logic by representing each download as
a separate job with relevant scheduling constraints. Requested
network types, retry backoff timing, and newly added charging and
idle constraints are plumbed through as job parameters.
When a job times out, we halt the download and schedule it to resume
later. The majority of downloads should have ETag values to enable
resuming like this.
Remove local wakelocks, since the platform now acquires and blames
our jobs on the requesting app.
When an active download is pushing updates to the database, check for
both paused and cancelled state to quickly halt an ongoing download.
Shift DownloadNotifier to update directly based on a Cursor, since we
no longer have the overhead of fully-parsed DownloadInfo objects.
Unify a handful of worker threads into a single shared thread.
Remove legacy "large download" activity that was thrown in the face
of the user; the UX best-practice is to go through notification, and
update that dialog to let the user override and continue if under
the hard limit.
Bug: 28098882, 26571724
Change-Id: I33ebe59b3c2ea9c89ec526f70b1950c734abc4a7
Diffstat (limited to 'tests/src/com/android/providers/downloads/DownloadProviderFunctionalTest.java')
-rw-r--r-- | tests/src/com/android/providers/downloads/DownloadProviderFunctionalTest.java | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/tests/src/com/android/providers/downloads/DownloadProviderFunctionalTest.java b/tests/src/com/android/providers/downloads/DownloadProviderFunctionalTest.java index 3b651048..9a4e6444 100644 --- a/tests/src/com/android/providers/downloads/DownloadProviderFunctionalTest.java +++ b/tests/src/com/android/providers/downloads/DownloadProviderFunctionalTest.java @@ -17,8 +17,10 @@ package com.android.providers.downloads; import static android.text.format.DateUtils.SECOND_IN_MILLIS; + import static java.net.HttpURLConnection.HTTP_OK; +import android.content.ContentUris; import android.content.ContentValues; import android.database.Cursor; import android.net.ConnectivityManager; @@ -56,7 +58,6 @@ public class DownloadProviderFunctionalTest extends AbstractDownloadProviderFunc String path = "/download_manager_test_path"; Uri downloadUri = requestDownload(path); assertEquals(Downloads.Impl.STATUS_PENDING, getDownloadStatus(downloadUri)); - assertTrue(mTestContext.mHasServiceBeenStarted); runUntilStatus(downloadUri, Downloads.Impl.STATUS_SUCCESS); RecordedRequest request = takeRequest(); @@ -108,13 +109,11 @@ public class DownloadProviderFunctionalTest extends AbstractDownloadProviderFunc // Assert that HTTP request succeeds when cleartext traffic is permitted mSystemFacade.mCleartextTrafficPermitted = true; Uri downloadUri = requestDownload("/path"); - assertEquals("http", downloadUri.getScheme()); runUntilStatus(downloadUri, Downloads.Impl.STATUS_SUCCESS); // Assert that HTTP request fails when cleartext traffic is not permitted mSystemFacade.mCleartextTrafficPermitted = false; downloadUri = requestDownload("/path"); - assertEquals("http", downloadUri.getScheme()); runUntilStatus(downloadUri, Downloads.Impl.STATUS_BAD_REQUEST); } @@ -131,8 +130,8 @@ public class DownloadProviderFunctionalTest extends AbstractDownloadProviderFunc } private void runUntilStatus(Uri downloadUri, int expected) throws Exception { - startService(null); - + startDownload(ContentUris.parseId(downloadUri)); + int actual = -1; final long timeout = SystemClock.elapsedRealtime() + (15 * SECOND_IN_MILLIS); |