Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 376fedf6 authored by Vasu Nori's avatar Vasu Nori Committed by Android (Google) Code Review
Browse files

Merge "bug:3362635 add new public API to downloadmanager to get mxbytesovermobile" into honeycomb

parents 168a0e90 0abbf809
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -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"
+36 −0
Original line number Diff line number Diff line
@@ -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.
     */