From 0abbf809bf46eea21f64fb62c55852783269aca2 Mon Sep 17 00:00:00 2001 From: Vasu Nori Date: Mon, 17 Jan 2011 15:08:14 -0800 Subject: bug:3362635 add new public API to downloadmanager to get mxbytesovermobile bug:3362635 Change-Id: I7380964c6098d5ca6396b17980f78457c23d1a87 --- core/java/android/app/DownloadManager.java | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'core/java/android/app/DownloadManager.java') 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; @@ -1034,6 +1036,40 @@ public class DownloadManager { mResolver.update(mBaseUri, values, getWhereClauseForIds(ids), getWhereArgsForIds(ids)); } + /** + * 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. */ -- cgit v1.2.3