summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers/downloads/DownloadInfo.java
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2011-06-15 11:18:46 -0700
committerJeff Sharkey <jsharkey@android.com>2011-06-17 16:34:50 -0700
commit961024389b3782936a40a7d090d670290bb66c3c (patch)
tree7188814c93d784118a5efea428eb203418f88575 /src/com/android/providers/downloads/DownloadInfo.java
parent1fec3e68161dce11cc6995c8c3de50d6ca37f2e7 (diff)
downloadandroid_packages_providers_DownloadProvider-961024389b3782936a40a7d090d670290bb66c3c.tar.gz
android_packages_providers_DownloadProvider-961024389b3782936a40a7d090d670290bb66c3c.tar.bz2
android_packages_providers_DownloadProvider-961024389b3782936a40a7d090d670290bb66c3c.zip
Teach DownloadManager about network policy.
Now network access is determined by using getActiveNetworkInfoForUid() which uses BLOCKED to indicate that network should be rejected for the requesting UID. While download in progress, watch for any policy changes that should trigger pause. Also check NetworkInfo.isConnected() for correctness. Change-Id: I1efa79823f15ecc3fa088a6719da1b770c64b255
Diffstat (limited to 'src/com/android/providers/downloads/DownloadInfo.java')
-rw-r--r--src/com/android/providers/downloads/DownloadInfo.java19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/com/android/providers/downloads/DownloadInfo.java b/src/com/android/providers/downloads/DownloadInfo.java
index 313386fe..00b10452 100644
--- a/src/com/android/providers/downloads/DownloadInfo.java
+++ b/src/com/android/providers/downloads/DownloadInfo.java
@@ -24,6 +24,8 @@ import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.net.NetworkInfo.DetailedState;
import android.net.Uri;
import android.os.Environment;
import android.provider.Downloads;
@@ -177,6 +179,11 @@ public class DownloadInfo {
public static final int NETWORK_TYPE_DISALLOWED_BY_REQUESTOR = 6;
/**
+ * Current network is blocked for requesting application.
+ */
+ public static final int NETWORK_BLOCKED = 7;
+
+ /**
* For intents used to notify the user that a download exceeds a size threshold, if this extra
* is true, WiFi is required for this download size; otherwise, it is only recommended.
*/
@@ -333,14 +340,17 @@ public class DownloadInfo {
* @return one of the NETWORK_* constants
*/
public int checkCanUseNetwork() {
- Integer networkType = mSystemFacade.getActiveNetworkType();
- if (networkType == null) {
+ final NetworkInfo info = mSystemFacade.getActiveNetworkInfo(mUid);
+ if (info == null) {
return NETWORK_NO_CONNECTION;
}
+ if (DetailedState.BLOCKED.equals(info.getDetailedState())) {
+ return NETWORK_BLOCKED;
+ }
if (!isRoamingAllowed() && mSystemFacade.isNetworkRoaming()) {
return NETWORK_CANNOT_USE_ROAMING;
}
- return checkIsNetworkTypeAllowed(networkType);
+ return checkIsNetworkTypeAllowed(info.getType());
}
private boolean isRoamingAllowed() {
@@ -372,6 +382,9 @@ public class DownloadInfo {
case NETWORK_TYPE_DISALLOWED_BY_REQUESTOR:
return "download was requested to not use the current network type";
+ case NETWORK_BLOCKED:
+ return "network is blocked for requesting application";
+
default:
return "unknown error with network connectivity";
}