diff options
author | Jeff Sharkey <jsharkey@android.com> | 2016-06-22 14:19:22 -0600 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2016-06-22 15:42:47 -0600 |
commit | b5ca499c7417fc5954b6914d6d52e6e2c02ce7d8 (patch) | |
tree | a4d34b5bd595edc068d1f75fe7905607349aa828 /src/com/android/providers/downloads/DownloadThread.java | |
parent | 07c50f1e60407083113bacf7c39b8bda67523b2b (diff) | |
download | android_packages_providers_DownloadProvider-b5ca499c7417fc5954b6914d6d52e6e2c02ce7d8.tar.gz android_packages_providers_DownloadProvider-b5ca499c7417fc5954b6914d6d52e6e2c02ce7d8.tar.bz2 android_packages_providers_DownloadProvider-b5ca499c7417fc5954b6914d6d52e6e2c02ce7d8.zip |
Re-schedule downloads queued for unmetered.
When a download is stopped due to a metered network, we should
reschedule the job just like any other network failure. If a
download requires an unmetered network, treat WAITING_FOR_NETWORK as
QUEUED_FOR_WIFI so we show a meaningful notification.
Bug: 29440531
Change-Id: I31e6535c575fd32e2982ef840ae501acf1db3927
Diffstat (limited to 'src/com/android/providers/downloads/DownloadThread.java')
-rw-r--r-- | src/com/android/providers/downloads/DownloadThread.java | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/com/android/providers/downloads/DownloadThread.java b/src/com/android/providers/downloads/DownloadThread.java index 34d6ad1a..60a04ff1 100644 --- a/src/com/android/providers/downloads/DownloadThread.java +++ b/src/com/android/providers/downloads/DownloadThread.java @@ -353,6 +353,13 @@ public class DownloadThread extends Thread { } } + // If we're waiting for a network that must be unmetered, our status + // is actually queued so we show relevant notifications + if (mInfoDelta.mStatus == STATUS_WAITING_FOR_NETWORK + && !mInfo.isMeteredAllowed(mInfoDelta.mTotalBytes)) { + mInfoDelta.mStatus = STATUS_QUEUED_FOR_WIFI; + } + } catch (Throwable t) { mInfoDelta.mStatus = STATUS_UNKNOWN_ERROR; mInfoDelta.mErrorMsg = t.toString(); @@ -380,7 +387,8 @@ public class DownloadThread extends Thread { DownloadScanner.requestScanBlocking(mContext, mInfo); } } else if (mInfoDelta.mStatus == STATUS_WAITING_TO_RETRY - || mInfoDelta.mStatus == STATUS_WAITING_FOR_NETWORK) { + || mInfoDelta.mStatus == STATUS_WAITING_FOR_NETWORK + || mInfoDelta.mStatus == STATUS_QUEUED_FOR_WIFI) { Helpers.scheduleJob(mContext, DownloadInfo.queryDownloadInfo(mContext, mId)); } @@ -727,20 +735,16 @@ public class DownloadThread extends Thread { // checking connectivity will apply current policy mPolicyDirty = false; - final boolean allowMetered = mInfo - .getRequiredNetworkType(mInfoDelta.mTotalBytes) != JobInfo.NETWORK_TYPE_UNMETERED; - final boolean allowRoaming = mInfo.isRoamingAllowed(); - final NetworkInfo info = mSystemFacade.getNetworkInfo(mNetwork, mInfo.mUid, mIgnoreBlocked); if (info == null || !info.isConnected()) { throw new StopRequestException(STATUS_WAITING_FOR_NETWORK, "Network is disconnected"); } - if (info.isRoaming() && !allowRoaming) { + if (info.isRoaming() && !mInfo.isRoamingAllowed()) { throw new StopRequestException(STATUS_WAITING_FOR_NETWORK, "Network is roaming"); } - if (info.isMetered() && !allowMetered) { - throw new StopRequestException(STATUS_QUEUED_FOR_WIFI, "Network is metered"); + if (info.isMetered() && !mInfo.isMeteredAllowed(mInfoDelta.mTotalBytes)) { + throw new StopRequestException(STATUS_WAITING_FOR_NETWORK, "Network is metered"); } } |