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 --- src/com/android/providers/downloads/RealSystemFacade.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/com/android/providers/downloads/RealSystemFacade.java') diff --git a/src/com/android/providers/downloads/RealSystemFacade.java b/src/com/android/providers/downloads/RealSystemFacade.java index 71dac5fe..f2423d47 100644 --- a/src/com/android/providers/downloads/RealSystemFacade.java +++ b/src/com/android/providers/downloads/RealSystemFacade.java @@ -27,7 +27,7 @@ class RealSystemFacade implements SystemFacade { return System.currentTimeMillis(); } - public Integer getActiveNetworkType() { + public NetworkInfo getActiveNetworkInfo(int uid) { ConnectivityManager connectivity = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivity == null) { @@ -35,14 +35,11 @@ class RealSystemFacade implements SystemFacade { return null; } - NetworkInfo activeInfo = connectivity.getActiveNetworkInfo(); - if (activeInfo == null) { - if (Constants.LOGVV) { - Log.v(Constants.TAG, "network is not available"); - } - return null; + final NetworkInfo activeInfo = connectivity.getActiveNetworkInfoForUid(uid); + if (activeInfo == null && Constants.LOGVV) { + Log.v(Constants.TAG, "network is not available"); } - return activeInfo.getType(); + return activeInfo; } public boolean isNetworkRoaming() { -- cgit v1.2.3