summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers/downloads/DownloadThread.java
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2016-04-28 15:33:38 -0600
committerJeff Sharkey <jsharkey@android.com>2016-04-29 12:30:02 -0600
commitb3597b9d2fdde31bb0a8af821e3da3ca786e277b (patch)
tree375cd055478b96d305856e72b222e795decc1309 /src/com/android/providers/downloads/DownloadThread.java
parent67db99b0fc55846a4fa6d4a134a0533426428e7f (diff)
downloadandroid_packages_providers_DownloadProvider-b3597b9d2fdde31bb0a8af821e3da3ca786e277b.tar.gz
android_packages_providers_DownloadProvider-b3597b9d2fdde31bb0a8af821e3da3ca786e277b.tar.bz2
android_packages_providers_DownloadProvider-b3597b9d2fdde31bb0a8af821e3da3ca786e277b.zip
Visible downloads should run while blocked/dozing.
Downloads with visible notifications should behave as if the requesting app was running a foreground service. The easiest way to implement this for now is to ignore any BLOCKED network status and use the new setWillBeForeground() API so job scheduling ignores any active blocked/dozing status. Bug: 26571724 Change-Id: I8ea2b2a7cdb5f469adc11b4d897ff55bd8a9db9a
Diffstat (limited to 'src/com/android/providers/downloads/DownloadThread.java')
-rw-r--r--src/com/android/providers/downloads/DownloadThread.java23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/com/android/providers/downloads/DownloadThread.java b/src/com/android/providers/downloads/DownloadThread.java
index c559367f..3bcde17e 100644
--- a/src/com/android/providers/downloads/DownloadThread.java
+++ b/src/com/android/providers/downloads/DownloadThread.java
@@ -221,6 +221,7 @@ public class DownloadThread extends Thread {
private long mLastUpdateBytes = 0;
private long mLastUpdateTime = 0;
+ private boolean mIgnoreBlocked;
private Network mNetwork;
private int mNetworkType = ConnectivityManager.TYPE_NONE;
@@ -269,10 +270,15 @@ public class DownloadThread extends Thread {
mInfoDelta.mStatus = STATUS_RUNNING;
mInfoDelta.writeToDatabase();
+ // If we're showing a foreground notification for the requesting
+ // app, the download isn't affected by the blocked status of the
+ // requesting app
+ mIgnoreBlocked = mInfo.isVisible();
+
// Use the caller's default network to make this connection, since
// they might be subject to restrictions that we shouldn't let them
- // circumvent.
- mNetwork = mSystemFacade.getActiveNetwork(mInfo.mUid);
+ // circumvent
+ mNetwork = mSystemFacade.getActiveNetwork(mInfo.mUid, mIgnoreBlocked);
if (mNetwork == null) {
throw new StopRequestException(STATUS_WAITING_FOR_NETWORK,
"No network associated with requesting UID");
@@ -280,7 +286,8 @@ public class DownloadThread extends Thread {
// Remember which network this download started on; used to
// determine if errors were due to network changes.
- final NetworkInfo info = mSystemFacade.getNetworkInfo(mNetwork);
+ final NetworkInfo info = mSystemFacade.getNetworkInfo(mNetwork, mInfo.mUid,
+ mIgnoreBlocked);
if (info != null) {
mNetworkType = info.getType();
}
@@ -323,7 +330,8 @@ public class DownloadThread extends Thread {
}
if (mInfoDelta.mNumFailed < Constants.MAX_RETRIES) {
- final NetworkInfo info = mSystemFacade.getNetworkInfo(mNetwork);
+ final NetworkInfo info = mSystemFacade.getNetworkInfo(mNetwork, mInfo.mUid,
+ mIgnoreBlocked);
if (info != null && info.getType() == mNetworkType && info.isConnected()) {
// Underlying network is still intact, use normal backoff
mInfoDelta.mStatus = STATUS_WAITING_TO_RETRY;
@@ -707,7 +715,8 @@ public class DownloadThread extends Thread {
.getRequiredNetworkType(mInfoDelta.mTotalBytes) != JobInfo.NETWORK_TYPE_UNMETERED;
final boolean allowRoaming = mInfo.isRoamingAllowed();
- final NetworkInfo info = mSystemFacade.getNetworkInfo(mNetwork);
+ final NetworkInfo info = mSystemFacade.getNetworkInfo(mNetwork, mInfo.mUid,
+ mIgnoreBlocked);
if (info == null || !info.isConnected()) {
throw new StopRequestException(STATUS_WAITING_FOR_NETWORK, "Network is disconnected");
}
@@ -870,7 +879,9 @@ public class DownloadThread extends Thread {
@Override
public void onRestrictBackgroundWhitelistChanged(int uid, boolean whitelisted) {
// caller is NPMS, since we only register with them
- mPolicyDirty = true;
+ if (uid == mInfo.mUid) {
+ mPolicyDirty = true;
+ }
}
};