Merge "DownloadManager and metered networks."

This commit is contained in:
Jeff Sharkey
2012-04-16 12:03:43 -07:00
committed by Android (Google) Code Review
2 changed files with 19 additions and 2 deletions

View File

@@ -3265,6 +3265,7 @@ package android.app {
method public android.app.DownloadManager.Request addRequestHeader(java.lang.String, java.lang.String);
method public void allowScanningByMediaScanner();
method public android.app.DownloadManager.Request setAllowedNetworkTypes(int);
method public android.app.DownloadManager.Request setAllowedOverMetered(boolean);
method public android.app.DownloadManager.Request setAllowedOverRoaming(boolean);
method public android.app.DownloadManager.Request setDescription(java.lang.CharSequence);
method public android.app.DownloadManager.Request setDestinationInExternalFilesDir(android.content.Context, java.lang.String, java.lang.String);

View File

@@ -349,6 +349,7 @@ public class DownloadManager {
private String mMimeType;
private boolean mRoamingAllowed = true;
private int mAllowedNetworkTypes = ~0; // default to all network types allowed
private boolean mAllowedOverMetered = true;
private boolean mIsVisibleInDownloadsUi = true;
private boolean mScannable = false;
private boolean mUseSystemCache = false;
@@ -609,8 +610,11 @@ public class DownloadManager {
}
/**
* Restrict the types of networks over which this download may proceed. By default, all
* network types are allowed.
* Restrict the types of networks over which this download may proceed.
* By default, all network types are allowed. Consider using
* {@link #setAllowedOverMetered(boolean)} instead, since it's more
* flexible.
*
* @param flags any combination of the NETWORK_* bit flags.
* @return this object
*/
@@ -619,6 +623,17 @@ public class DownloadManager {
return this;
}
/**
* Set whether this download may proceed over a metered network
* connection. By default, metered networks are allowed.
*
* @see ConnectivityManager#isActiveNetworkMetered()
*/
public Request setAllowedOverMetered(boolean allow) {
mAllowedOverMetered = allow;
return this;
}
/**
* Set whether this download may proceed over a roaming connection. By default, roaming is
* allowed.
@@ -672,6 +687,7 @@ public class DownloadManager {
putIfNonNull(values, Downloads.Impl.COLUMN_DESCRIPTION, mDescription);
putIfNonNull(values, Downloads.Impl.COLUMN_MIME_TYPE, mMimeType);
// TODO: add COLUMN_ALLOW_METERED and persist
values.put(Downloads.Impl.COLUMN_VISIBILITY, mNotificationVisibility);
values.put(Downloads.Impl.COLUMN_ALLOWED_NETWORK_TYPES, mAllowedNetworkTypes);
values.put(Downloads.Impl.COLUMN_ALLOW_ROAMING, mRoamingAllowed);