diff options
author | Jeff Sharkey <jsharkey@android.com> | 2011-06-16 13:39:02 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-06-16 13:39:02 -0700 |
commit | ad4c9ed7de1c3c3b7781db9c46503263c5bf8464 (patch) | |
tree | 1bf7a169ad31b1b9135fb64420a18978d4811f7b /core/java | |
parent | 179cfcf65499e0da07d44b38cbb657a4ca898e63 (diff) | |
parent | 1a303953589fdddf21d88b8fa660136f5b060d0d (diff) | |
download | frameworks_base-ad4c9ed7de1c3c3b7781db9c46503263c5bf8464.zip frameworks_base-ad4c9ed7de1c3c3b7781db9c46503263c5bf8464.tar.gz frameworks_base-ad4c9ed7de1c3c3b7781db9c46503263c5bf8464.tar.bz2 |
Merge "DownloadManager flags for network policy."
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/app/ContextImpl.java | 10 | ||||
-rw-r--r-- | core/java/android/app/DownloadManager.java | 15 | ||||
-rw-r--r-- | core/java/android/net/NetworkPolicyManager.java | 14 | ||||
-rw-r--r-- | core/java/android/provider/Downloads.java | 9 |
4 files changed, 47 insertions, 1 deletions
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index 20dc792..94a4afa 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -52,6 +52,8 @@ import android.location.LocationManager; import android.media.AudioManager; import android.net.ConnectivityManager; import android.net.IConnectivityManager; +import android.net.INetworkPolicyManager; +import android.net.NetworkPolicyManager; import android.net.ThrottleManager; import android.net.IThrottleManager; import android.net.Uri; @@ -339,6 +341,14 @@ class ContextImpl extends Context { return new LocationManager(ILocationManager.Stub.asInterface(b)); }}); + registerService(NETWORK_POLICY_SERVICE, new ServiceFetcher() { + @Override + public Object createService(ContextImpl ctx) { + return new NetworkPolicyManager(INetworkPolicyManager.Stub.asInterface( + ServiceManager.getService(NETWORK_POLICY_SERVICE))); + } + }); + registerService(NOTIFICATION_SERVICE, new ServiceFetcher() { public Object createService(ContextImpl ctx) { final Context outerContext = ctx.getOuterContext(); diff --git a/core/java/android/app/DownloadManager.java b/core/java/android/app/DownloadManager.java index b88e5cf..28559cc 100644 --- a/core/java/android/app/DownloadManager.java +++ b/core/java/android/app/DownloadManager.java @@ -23,6 +23,7 @@ import android.content.Context; import android.database.Cursor; import android.database.CursorWrapper; import android.net.ConnectivityManager; +import android.net.NetworkPolicyManager; import android.net.Uri; import android.os.Environment; import android.os.ParcelFileDescriptor; @@ -170,7 +171,6 @@ public class DownloadManager { */ public final static int STATUS_FAILED = 1 << 4; - /** * Value of COLUMN_ERROR_CODE when the download has completed with an error that doesn't fit * under any other error code. @@ -249,6 +249,14 @@ public class DownloadManager { public final static int PAUSED_UNKNOWN = 4; /** + * Value of {@link #COLUMN_REASON} when the download has been paused because + * of {@link NetworkPolicyManager} controls on the requesting application. + * + * @hide + */ + public final static int PAUSED_BY_POLICY = 5; + + /** * Broadcast intent action sent by the download manager when a download completes. */ public final static String ACTION_DOWNLOAD_COMPLETE = "android.intent.action.DOWNLOAD_COMPLETE"; @@ -796,6 +804,7 @@ public class DownloadManager { parts.add(statusClause("=", Downloads.Impl.STATUS_WAITING_TO_RETRY)); parts.add(statusClause("=", Downloads.Impl.STATUS_WAITING_FOR_NETWORK)); parts.add(statusClause("=", Downloads.Impl.STATUS_QUEUED_FOR_WIFI)); + parts.add(statusClause("=", Downloads.Impl.STATUS_PAUSED_BY_POLICY)); } if ((mStatusFlags & STATUS_SUCCESSFUL) != 0) { parts.add(statusClause("=", Downloads.Impl.STATUS_SUCCESS)); @@ -1266,6 +1275,9 @@ public class DownloadManager { case Downloads.Impl.STATUS_QUEUED_FOR_WIFI: return PAUSED_QUEUED_FOR_WIFI; + case Downloads.Impl.STATUS_PAUSED_BY_POLICY: + return PAUSED_BY_POLICY; + default: return PAUSED_UNKNOWN; } @@ -1321,6 +1333,7 @@ public class DownloadManager { case Downloads.Impl.STATUS_WAITING_TO_RETRY: case Downloads.Impl.STATUS_WAITING_FOR_NETWORK: case Downloads.Impl.STATUS_QUEUED_FOR_WIFI: + case Downloads.Impl.STATUS_PAUSED_BY_POLICY: return STATUS_PAUSED; case Downloads.Impl.STATUS_SUCCESS: diff --git a/core/java/android/net/NetworkPolicyManager.java b/core/java/android/net/NetworkPolicyManager.java index 538a06e..0d4d9a9 100644 --- a/core/java/android/net/NetworkPolicyManager.java +++ b/core/java/android/net/NetworkPolicyManager.java @@ -115,6 +115,20 @@ public class NetworkPolicyManager { } } + public void registerListener(INetworkPolicyListener listener) { + try { + mService.registerListener(listener); + } catch (RemoteException e) { + } + } + + public void unregisterListener(INetworkPolicyListener listener) { + try { + mService.unregisterListener(listener); + } catch (RemoteException e) { + } + } + /** * Compute the last cycle boundary for the given {@link NetworkPolicy}. For * example, if cycle day is 20th, and today is June 15th, it will return May diff --git a/core/java/android/provider/Downloads.java b/core/java/android/provider/Downloads.java index 3c4bb79..0a8c3ca 100644 --- a/core/java/android/provider/Downloads.java +++ b/core/java/android/provider/Downloads.java @@ -17,6 +17,7 @@ package android.provider; import android.app.DownloadManager; +import android.net.NetworkPolicyManager; import android.net.Uri; /** @@ -547,6 +548,14 @@ public final class Downloads { } /** + * This download has been paused because requesting application has been + * blocked by {@link NetworkPolicyManager}. + * + * @hide + */ + public static final int STATUS_PAUSED_BY_POLICY = 189; + + /** * This download hasn't stated yet */ public static final int STATUS_PENDING = 190; |