diff options
| author | 2011-01-17 15:08:14 -0800 | |
|---|---|---|
| committer | 2011-01-17 15:14:53 -0800 | |
| commit | 0abbf809bf46eea21f64fb62c55852783269aca2 (patch) | |
| tree | 1be486d5ddacb2439d4ff8557a28809eb7ebe07a | |
| parent | 5401c5a25687a6e6e97f59fee76aa0ae1feac807 (diff) | |
bug:3362635 add new public API to downloadmanager to get mxbytesovermobile
bug:3362635
Change-Id: I7380964c6098d5ca6396b17980f78457c23d1a87
| -rw-r--r-- | api/current.xml | 26 | ||||
| -rw-r--r-- | core/java/android/app/DownloadManager.java | 36 |
2 files changed, 62 insertions, 0 deletions
diff --git a/api/current.xml b/api/current.xml index 6d12990facd7..1309201ebd62 100644 --- a/api/current.xml +++ b/api/current.xml @@ -28822,6 +28822,19 @@ <parameter name="request" type="android.app.DownloadManager.Request"> </parameter> </method> +<method name="getMaxBytesOverMobile" + return="java.lang.Long" + abstract="false" + native="false" + synchronized="false" + static="true" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="context" type="android.content.Context"> +</parameter> +</method> <method name="getMimeTypeForDownloadedFile" return="java.lang.String" abstract="false" @@ -28835,6 +28848,19 @@ <parameter name="id" type="long"> </parameter> </method> +<method name="getRecommendedMaxBytesOverMobile" + return="java.lang.Long" + abstract="false" + native="false" + synchronized="false" + static="true" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="context" type="android.content.Context"> +</parameter> +</method> <method name="getUriForDownloadedFile" return="android.net.Uri" abstract="false" 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) { |