summaryrefslogtreecommitdiffstats
path: root/tests
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 /tests
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 'tests')
-rw-r--r--tests/src/com/android/providers/downloads/FakeSystemFacade.java9
-rw-r--r--tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java5
2 files changed, 10 insertions, 4 deletions
diff --git a/tests/src/com/android/providers/downloads/FakeSystemFacade.java b/tests/src/com/android/providers/downloads/FakeSystemFacade.java
index 9620ffc3..fbaf6366 100644
--- a/tests/src/com/android/providers/downloads/FakeSystemFacade.java
+++ b/tests/src/com/android/providers/downloads/FakeSystemFacade.java
@@ -4,6 +4,7 @@ import android.app.Notification;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
import android.test.AssertionFailedError;
import java.util.ArrayList;
@@ -36,8 +37,12 @@ public class FakeSystemFacade implements SystemFacade {
return mTimeMillis;
}
- public Integer getActiveNetworkType() {
- return mActiveNetworkType;
+ public NetworkInfo getActiveNetworkInfo(int uid) {
+ if (mActiveNetworkType == null) {
+ return null;
+ } else {
+ return new NetworkInfo(mActiveNetworkType, 0, null, null);
+ }
}
public boolean isNetworkRoaming() {
diff --git a/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java b/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
index 64c19530..f2a26f12 100644
--- a/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
+++ b/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
@@ -441,11 +441,12 @@ public class PublicApiFunctionalTest extends AbstractPublicApiTest {
}
public void testBasicConnectivityChanges() throws Exception {
+ // without connectivity, download immediately pauses
+ mSystemFacade.mActiveNetworkType = null;
+
enqueueResponse(HTTP_OK, FILE_CONTENT);
Download download = enqueueRequest(getRequest());
- // without connectivity, download immediately pauses
- mSystemFacade.mActiveNetworkType = null;
download.runUntilStatus(DownloadManager.STATUS_PAUSED);
// connecting should start the download