summaryrefslogtreecommitdiff
path: root/core/java/android/app/DownloadManager.java
diff options
context:
space:
mode:
authorVasu Nori <vnori@google.com>2011-01-17 15:08:14 -0800
committerVasu Nori <vnori@google.com>2011-01-17 15:14:53 -0800
commit0abbf809bf46eea21f64fb62c55852783269aca2 (patch)
tree1be486d5ddacb2439d4ff8557a28809eb7ebe07a /core/java/android/app/DownloadManager.java
parent5401c5a25687a6e6e97f59fee76aa0ae1feac807 (diff)
bug:3362635 add new public API to downloadmanager to get mxbytesovermobile
bug:3362635 Change-Id: I7380964c6098d5ca6396b17980f78457c23d1a87
Diffstat (limited to 'core/java/android/app/DownloadManager.java')
-rw-r--r--core/java/android/app/DownloadManager.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/core/java/android/app/DownloadManager.java b/core/java/android/app/DownloadManager.java
index 12f4a1868f6a..297d24604d00 100644
--- a/core/java/android/app/DownloadManager.java
+++ b/core/java/android/app/DownloadManager.java
@@ -28,6 +28,8 @@ import android.os.Binder;
import android.os.Environment;
import android.os.ParcelFileDescriptor;
import android.provider.Downloads;
+import android.provider.Settings;
+import android.provider.Settings.SettingNotFoundException;
import android.util.Log;
import android.util.Pair;
@@ -1035,6 +1037,40 @@ public class DownloadManager {
}
/**
+ * Returns maximum size, in bytes, of downloads that may go over a mobile connection; or null if
+ * there's no limit
+ *
+ * @param context the {@link Context} to use for accessing the {@link ContentResolver}
+ * @return maximum size, in bytes, of downloads that may go over a mobile connection; or null if
+ * there's no limit
+ */
+ public static Long getMaxBytesOverMobile(Context context) {
+ try {
+ return Settings.Secure.getLong(context.getContentResolver(),
+ Settings.Secure.DOWNLOAD_MAX_BYTES_OVER_MOBILE);
+ } catch (SettingNotFoundException exc) {
+ return null;
+ }
+ }
+
+ /**
+ * Returns recommended maximum size, in bytes, of downloads that may go over a mobile
+ * connection; or null if there's no recommended limit. The user will have the option to bypass
+ * this limit.
+ *
+ * @param context the {@link Context} to use for accessing the {@link ContentResolver}
+ * @return recommended maximum size, in bytes, of downloads that may go over a mobile
+ * connection; or null if there's no recommended limit.
+ */
+ public static Long getRecommendedMaxBytesOverMobile(Context context) {
+ try {
+ return Settings.Secure.getLong(context.getContentResolver(),
+ Settings.Secure.DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE);
+ } catch (SettingNotFoundException exc) {
+ return null;
+ }
+ }
+ /**
* Get the DownloadProvider URI for the download with the given ID.
*/
Uri getDownloadUri(long id) {