summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers/downloads/DownloadInfo.java
diff options
context:
space:
mode:
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";
}