From 961024389b3782936a40a7d090d670290bb66c3c Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Wed, 15 Jun 2011 11:18:46 -0700 Subject: 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 --- tests/src/com/android/providers/downloads/FakeSystemFacade.java | 9 +++++++-- .../com/android/providers/downloads/PublicApiFunctionalTest.java | 5 +++-- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'tests/src/com/android') 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 -- cgit v1.2.3