@@ -349,6 +349,7 @@ public static class Request {
349349 private String mMimeType ;
350350 private boolean mRoamingAllowed = true ;
351351 private int mAllowedNetworkTypes = ~0 ; // default to all network types allowed
352+ private boolean mAllowedOverMetered = true ;
352353 private boolean mIsVisibleInDownloadsUi = true ;
353354 private boolean mScannable = false ;
354355 private boolean mUseSystemCache = false ;
@@ -609,8 +610,11 @@ public Request setNotificationVisibility(int visibility) {
609610 }
610611
611612 /**
612- * Restrict the types of networks over which this download may proceed. By default, all
613- * network types are allowed.
613+ * Restrict the types of networks over which this download may proceed.
614+ * By default, all network types are allowed. Consider using
615+ * {@link #setAllowedOverMetered(boolean)} instead, since it's more
616+ * flexible.
617+ *
614618 * @param flags any combination of the NETWORK_* bit flags.
615619 * @return this object
616620 */
@@ -619,6 +623,17 @@ public Request setAllowedNetworkTypes(int flags) {
619623 return this ;
620624 }
621625
626+ /**
627+ * Set whether this download may proceed over a metered network
628+ * connection. By default, metered networks are allowed.
629+ *
630+ * @see ConnectivityManager#isActiveNetworkMetered()
631+ */
632+ public Request setAllowedOverMetered (boolean allow ) {
633+ mAllowedOverMetered = allow ;
634+ return this ;
635+ }
636+
622637 /**
623638 * Set whether this download may proceed over a roaming connection. By default, roaming is
624639 * allowed.
@@ -672,6 +687,7 @@ ContentValues toContentValues(String packageName) {
672687 putIfNonNull (values , Downloads .Impl .COLUMN_DESCRIPTION , mDescription );
673688 putIfNonNull (values , Downloads .Impl .COLUMN_MIME_TYPE , mMimeType );
674689
690+ // TODO: add COLUMN_ALLOW_METERED and persist
675691 values .put (Downloads .Impl .COLUMN_VISIBILITY , mNotificationVisibility );
676692 values .put (Downloads .Impl .COLUMN_ALLOWED_NETWORK_TYPES , mAllowedNetworkTypes );
677693 values .put (Downloads .Impl .COLUMN_ALLOW_ROAMING , mRoamingAllowed );
0 commit comments