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

Commit 538c3fa3 authored by Steve Howard's avatar Steve Howard Committed by Android Git Automerger
Browse files

am cdcc0a65: Merge "Have download manager give more details when downloads are...

am cdcc0a65: Merge "Have download manager give more details when downloads are paused" into gingerbread

Merge commit 'cdcc0a65' into gingerbread-plus-aosp

* commit 'cdcc0a65':
  Have download manager give more details when downloads are paused
parents 6bbc2f15 cdcc0a65
Loading
Loading
Loading
Loading
+77 −33
Original line number Original line Diff line number Diff line
@@ -24617,55 +24617,55 @@
 visibility="public"
 visibility="public"
>
>
</field>
</field>
<field name="COLUMN_ERROR_CODE"
<field name="COLUMN_ID"
 type="java.lang.String"
 type="java.lang.String"
 transient="false"
 transient="false"
 volatile="false"
 volatile="false"
 value="&quot;error_code&quot;"
 value="&quot;_id&quot;"
 static="true"
 static="true"
 final="true"
 final="true"
 deprecated="not deprecated"
 deprecated="not deprecated"
 visibility="public"
 visibility="public"
>
>
</field>
</field>
<field name="COLUMN_ID"
<field name="COLUMN_LAST_MODIFIED_TIMESTAMP"
 type="java.lang.String"
 type="java.lang.String"
 transient="false"
 transient="false"
 volatile="false"
 volatile="false"
 value="&quot;_id&quot;"
 value="&quot;last_modified_timestamp&quot;"
 static="true"
 static="true"
 final="true"
 final="true"
 deprecated="not deprecated"
 deprecated="not deprecated"
 visibility="public"
 visibility="public"
>
>
</field>
</field>
<field name="COLUMN_LAST_MODIFIED_TIMESTAMP"
<field name="COLUMN_LOCAL_URI"
 type="java.lang.String"
 type="java.lang.String"
 transient="false"
 transient="false"
 volatile="false"
 volatile="false"
 value="&quot;last_modified_timestamp&quot;"
 value="&quot;local_uri&quot;"
 static="true"
 static="true"
 final="true"
 final="true"
 deprecated="not deprecated"
 deprecated="not deprecated"
 visibility="public"
 visibility="public"
>
>
</field>
</field>
<field name="COLUMN_LOCAL_URI"
<field name="COLUMN_MEDIA_TYPE"
 type="java.lang.String"
 type="java.lang.String"
 transient="false"
 transient="false"
 volatile="false"
 volatile="false"
 value="&quot;local_uri&quot;"
 value="&quot;media_type&quot;"
 static="true"
 static="true"
 final="true"
 final="true"
 deprecated="not deprecated"
 deprecated="not deprecated"
 visibility="public"
 visibility="public"
>
>
</field>
</field>
<field name="COLUMN_MEDIA_TYPE"
<field name="COLUMN_REASON"
 type="java.lang.String"
 type="java.lang.String"
 transient="false"
 transient="false"
 volatile="false"
 volatile="false"
 value="&quot;media_type&quot;"
 value="&quot;reason&quot;"
 static="true"
 static="true"
 final="true"
 final="true"
 deprecated="not deprecated"
 deprecated="not deprecated"
@@ -24826,6 +24826,50 @@
 visibility="public"
 visibility="public"
>
>
</field>
</field>
<field name="PAUSED_QUEUED_FOR_WIFI"
 type="int"
 transient="false"
 volatile="false"
 value="3"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="PAUSED_UNKNOWN"
 type="int"
 transient="false"
 volatile="false"
 value="4"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="PAUSED_WAITING_FOR_NETWORK"
 type="int"
 transient="false"
 volatile="false"
 value="2"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="PAUSED_WAITING_TO_RETRY"
 type="int"
 transient="false"
 volatile="false"
 value="1"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="STATUS_FAILED"
<field name="STATUS_FAILED"
 type="int"
 type="int"
 transient="false"
 transient="false"
@@ -268848,9 +268892,9 @@
 deprecated="not deprecated"
 deprecated="not deprecated"
 visibility="protected"
 visibility="protected"
>
>
<parameter name="url1" type="java.net.URL">
<parameter name="a" type="java.net.URL">
</parameter>
</parameter>
<parameter name="url2" type="java.net.URL">
<parameter name="b" type="java.net.URL">
</parameter>
</parameter>
</method>
</method>
<method name="openConnection"
<method name="openConnection"
@@ -291603,7 +291647,7 @@
>
>
<parameter name="parameterName" type="java.lang.String">
<parameter name="parameterName" type="java.lang.String">
</parameter>
</parameter>
<parameter name="x" type="java.sql.Blob">
<parameter name="blob" type="java.sql.Blob">
</parameter>
</parameter>
<exception name="SQLException" type="java.sql.SQLException">
<exception name="SQLException" type="java.sql.SQLException">
</exception>
</exception>
@@ -291762,7 +291806,7 @@
>
>
<parameter name="parameterName" type="java.lang.String">
<parameter name="parameterName" type="java.lang.String">
</parameter>
</parameter>
<parameter name="x" type="java.sql.Clob">
<parameter name="clob" type="java.sql.Clob">
</parameter>
</parameter>
<exception name="SQLException" type="java.sql.SQLException">
<exception name="SQLException" type="java.sql.SQLException">
</exception>
</exception>
@@ -291900,7 +291944,7 @@
>
>
<parameter name="parameterName" type="java.lang.String">
<parameter name="parameterName" type="java.lang.String">
</parameter>
</parameter>
<parameter name="value" type="java.io.Reader">
<parameter name="reader" type="java.io.Reader">
</parameter>
</parameter>
<parameter name="length" type="long">
<parameter name="length" type="long">
</parameter>
</parameter>
@@ -291936,7 +291980,7 @@
>
>
<parameter name="parameterName" type="java.lang.String">
<parameter name="parameterName" type="java.lang.String">
</parameter>
</parameter>
<parameter name="value" type="java.sql.NClob">
<parameter name="nclob" type="java.sql.NClob">
</parameter>
</parameter>
<exception name="SQLException" type="java.sql.SQLException">
<exception name="SQLException" type="java.sql.SQLException">
</exception>
</exception>
@@ -291989,7 +292033,7 @@
>
>
<parameter name="parameterName" type="java.lang.String">
<parameter name="parameterName" type="java.lang.String">
</parameter>
</parameter>
<parameter name="value" type="java.lang.String">
<parameter name="string" type="java.lang.String">
</parameter>
</parameter>
<exception name="SQLException" type="java.sql.SQLException">
<exception name="SQLException" type="java.sql.SQLException">
</exception>
</exception>
@@ -292099,7 +292143,7 @@
>
>
<parameter name="parameterName" type="java.lang.String">
<parameter name="parameterName" type="java.lang.String">
</parameter>
</parameter>
<parameter name="x" type="java.sql.RowId">
<parameter name="rowId" type="java.sql.RowId">
</parameter>
</parameter>
<exception name="SQLException" type="java.sql.SQLException">
<exception name="SQLException" type="java.sql.SQLException">
</exception>
</exception>
@@ -292116,7 +292160,7 @@
>
>
<parameter name="parameterName" type="java.lang.String">
<parameter name="parameterName" type="java.lang.String">
</parameter>
</parameter>
<parameter name="xmlObject" type="java.sql.SQLXML">
<parameter name="sqlXml" type="java.sql.SQLXML">
</parameter>
</parameter>
<exception name="SQLException" type="java.sql.SQLException">
<exception name="SQLException" type="java.sql.SQLException">
</exception>
</exception>
@@ -297252,7 +297296,7 @@
>
>
<parameter name="parameterIndex" type="int">
<parameter name="parameterIndex" type="int">
</parameter>
</parameter>
<parameter name="x" type="java.io.InputStream">
<parameter name="inputStream" type="java.io.InputStream">
</parameter>
</parameter>
<parameter name="length" type="long">
<parameter name="length" type="long">
</parameter>
</parameter>
@@ -297271,7 +297315,7 @@
>
>
<parameter name="parameterIndex" type="int">
<parameter name="parameterIndex" type="int">
</parameter>
</parameter>
<parameter name="x" type="java.io.InputStream">
<parameter name="inputStream" type="java.io.InputStream">
</parameter>
</parameter>
<exception name="SQLException" type="java.sql.SQLException">
<exception name="SQLException" type="java.sql.SQLException">
</exception>
</exception>
@@ -297324,7 +297368,7 @@
>
>
<parameter name="parameterIndex" type="int">
<parameter name="parameterIndex" type="int">
</parameter>
</parameter>
<parameter name="x" type="java.io.InputStream">
<parameter name="inputStream" type="java.io.InputStream">
</parameter>
</parameter>
<parameter name="length" type="long">
<parameter name="length" type="long">
</parameter>
</parameter>
@@ -297343,7 +297387,7 @@
>
>
<parameter name="parameterIndex" type="int">
<parameter name="parameterIndex" type="int">
</parameter>
</parameter>
<parameter name="x" type="java.io.InputStream">
<parameter name="inputStream" type="java.io.InputStream">
</parameter>
</parameter>
<exception name="SQLException" type="java.sql.SQLException">
<exception name="SQLException" type="java.sql.SQLException">
</exception>
</exception>
@@ -297676,7 +297720,7 @@
>
>
<parameter name="parameterIndex" type="int">
<parameter name="parameterIndex" type="int">
</parameter>
</parameter>
<parameter name="value" type="java.io.Reader">
<parameter name="reader" type="java.io.Reader">
</parameter>
</parameter>
<parameter name="length" type="long">
<parameter name="length" type="long">
</parameter>
</parameter>
@@ -297695,7 +297739,7 @@
>
>
<parameter name="parameterIndex" type="int">
<parameter name="parameterIndex" type="int">
</parameter>
</parameter>
<parameter name="value" type="java.io.Reader">
<parameter name="reader" type="java.io.Reader">
</parameter>
</parameter>
<exception name="SQLException" type="java.sql.SQLException">
<exception name="SQLException" type="java.sql.SQLException">
</exception>
</exception>
@@ -297765,7 +297809,7 @@
>
>
<parameter name="parameterIndex" type="int">
<parameter name="parameterIndex" type="int">
</parameter>
</parameter>
<parameter name="value" type="java.lang.String">
<parameter name="theString" type="java.lang.String">
</parameter>
</parameter>
<exception name="SQLException" type="java.sql.SQLException">
<exception name="SQLException" type="java.sql.SQLException">
</exception>
</exception>
@@ -297892,7 +297936,7 @@
>
>
<parameter name="parameterIndex" type="int">
<parameter name="parameterIndex" type="int">
</parameter>
</parameter>
<parameter name="x" type="java.sql.RowId">
<parameter name="theRowId" type="java.sql.RowId">
</parameter>
</parameter>
<exception name="SQLException" type="java.sql.SQLException">
<exception name="SQLException" type="java.sql.SQLException">
</exception>
</exception>
@@ -300886,7 +300930,7 @@
>
>
<parameter name="columnIndex" type="int">
<parameter name="columnIndex" type="int">
</parameter>
</parameter>
<parameter name="x" type="java.sql.RowId">
<parameter name="value" type="java.sql.RowId">
</parameter>
</parameter>
<exception name="SQLException" type="java.sql.SQLException">
<exception name="SQLException" type="java.sql.SQLException">
</exception>
</exception>
@@ -300903,7 +300947,7 @@
>
>
<parameter name="columnLabel" type="java.lang.String">
<parameter name="columnLabel" type="java.lang.String">
</parameter>
</parameter>
<parameter name="x" type="java.sql.RowId">
<parameter name="value" type="java.sql.RowId">
</parameter>
</parameter>
<exception name="SQLException" type="java.sql.SQLException">
<exception name="SQLException" type="java.sql.SQLException">
</exception>
</exception>
@@ -303235,7 +303279,7 @@
 deprecated="not deprecated"
 deprecated="not deprecated"
 visibility="public"
 visibility="public"
>
>
<parameter name="x" type="java.sql.NClob">
<parameter name="theNClob" type="java.sql.NClob">
</parameter>
</parameter>
<exception name="SQLException" type="java.sql.SQLException">
<exception name="SQLException" type="java.sql.SQLException">
</exception>
</exception>
@@ -303250,7 +303294,7 @@
 deprecated="not deprecated"
 deprecated="not deprecated"
 visibility="public"
 visibility="public"
>
>
<parameter name="x" type="java.lang.String">
<parameter name="theString" type="java.lang.String">
</parameter>
</parameter>
<exception name="SQLException" type="java.sql.SQLException">
<exception name="SQLException" type="java.sql.SQLException">
</exception>
</exception>
@@ -303295,7 +303339,7 @@
 deprecated="not deprecated"
 deprecated="not deprecated"
 visibility="public"
 visibility="public"
>
>
<parameter name="x" type="java.sql.RowId">
<parameter name="theRowId" type="java.sql.RowId">
</parameter>
</parameter>
<exception name="SQLException" type="java.sql.SQLException">
<exception name="SQLException" type="java.sql.SQLException">
</exception>
</exception>
@@ -303310,7 +303354,7 @@
 deprecated="not deprecated"
 deprecated="not deprecated"
 visibility="public"
 visibility="public"
>
>
<parameter name="x" type="java.sql.SQLXML">
<parameter name="theXml" type="java.sql.SQLXML">
</parameter>
</parameter>
<exception name="SQLException" type="java.sql.SQLException">
<exception name="SQLException" type="java.sql.SQLException">
</exception>
</exception>
+85 −25
Original line number Original line Diff line number Diff line
@@ -100,16 +100,23 @@ public class DownloadManager {
    public final static String COLUMN_STATUS = "status";
    public final static String COLUMN_STATUS = "status";


    /**
    /**
     * Indicates the type of error that occurred, when {@link #COLUMN_STATUS} is
     * Provides more detail on the status of the download.  Its meaning depends on the value of
     * {@link #STATUS_FAILED}.  If an HTTP error occurred, this will hold the HTTP status code as
     * {@link #COLUMN_STATUS}.
     * defined in RFC 2616.  Otherwise, it will hold one of the ERROR_* constants.
     *
     *
     * If {@link #COLUMN_STATUS} is not {@link #STATUS_FAILED}, this column's value is undefined.
     * When {@link #COLUMN_STATUS} is {@link #STATUS_FAILED}, this indicates the type of error that
     * occurred.  If an HTTP error occurred, this will hold the HTTP status code as defined in RFC
     * 2616.  Otherwise, it will hold one of the ERROR_* constants.
     *
     * When {@link #COLUMN_STATUS} is {@link #STATUS_PAUSED}, this indicates why the download is
     * paused.  It will hold one of the PAUSED_* constants.
     *
     * If {@link #COLUMN_STATUS} is neither {@link #STATUS_FAILED} nor {@link #STATUS_PAUSED}, this
     * column's value is undefined.
     *
     *
     * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1.1">RFC 2616
     * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1.1">RFC 2616
     * status codes</a>
     * status codes</a>
     */
     */
    public final static String COLUMN_ERROR_CODE = "error_code";
    public final static String COLUMN_REASON = "reason";


    /**
    /**
     * Number of bytes download so far.
     * Number of bytes download so far.
@@ -156,53 +163,76 @@ public class DownloadManager {
    public final static int ERROR_UNKNOWN = 1000;
    public final static int ERROR_UNKNOWN = 1000;


    /**
    /**
     * Value of {@link #COLUMN_ERROR_CODE} when a storage issue arises which doesn't fit under any
     * Value of {@link #COLUMN_REASON} when a storage issue arises which doesn't fit under any
     * other error code. Use the more specific {@link #ERROR_INSUFFICIENT_SPACE} and
     * other error code. Use the more specific {@link #ERROR_INSUFFICIENT_SPACE} and
     * {@link #ERROR_DEVICE_NOT_FOUND} when appropriate.
     * {@link #ERROR_DEVICE_NOT_FOUND} when appropriate.
     */
     */
    public final static int ERROR_FILE_ERROR = 1001;
    public final static int ERROR_FILE_ERROR = 1001;


    /**
    /**
     * Value of {@link #COLUMN_ERROR_CODE} when an HTTP code was received that download manager
     * Value of {@link #COLUMN_REASON} when an HTTP code was received that download manager
     * can't handle.
     * can't handle.
     */
     */
    public final static int ERROR_UNHANDLED_HTTP_CODE = 1002;
    public final static int ERROR_UNHANDLED_HTTP_CODE = 1002;


    /**
    /**
     * Value of {@link #COLUMN_ERROR_CODE} when an error receiving or processing data occurred at
     * Value of {@link #COLUMN_REASON} when an error receiving or processing data occurred at
     * the HTTP level.
     * the HTTP level.
     */
     */
    public final static int ERROR_HTTP_DATA_ERROR = 1004;
    public final static int ERROR_HTTP_DATA_ERROR = 1004;


    /**
    /**
     * Value of {@link #COLUMN_ERROR_CODE} when there were too many redirects.
     * Value of {@link #COLUMN_REASON} when there were too many redirects.
     */
     */
    public final static int ERROR_TOO_MANY_REDIRECTS = 1005;
    public final static int ERROR_TOO_MANY_REDIRECTS = 1005;


    /**
    /**
     * Value of {@link #COLUMN_ERROR_CODE} when there was insufficient storage space. Typically,
     * Value of {@link #COLUMN_REASON} when there was insufficient storage space. Typically,
     * this is because the SD card is full.
     * this is because the SD card is full.
     */
     */
    public final static int ERROR_INSUFFICIENT_SPACE = 1006;
    public final static int ERROR_INSUFFICIENT_SPACE = 1006;


    /**
    /**
     * Value of {@link #COLUMN_ERROR_CODE} when no external storage device was found. Typically,
     * Value of {@link #COLUMN_REASON} when no external storage device was found. Typically,
     * this is because the SD card is not mounted.
     * this is because the SD card is not mounted.
     */
     */
    public final static int ERROR_DEVICE_NOT_FOUND = 1007;
    public final static int ERROR_DEVICE_NOT_FOUND = 1007;


    /**
    /**
     * Value of {@link #COLUMN_ERROR_CODE} when some possibly transient error occurred but we can't
     * Value of {@link #COLUMN_REASON} when some possibly transient error occurred but we can't
     * resume the download.
     * resume the download.
     */
     */
    public final static int ERROR_CANNOT_RESUME = 1008;
    public final static int ERROR_CANNOT_RESUME = 1008;


    /**
    /**
     * Value of {@link #COLUMN_ERROR_CODE} when the requested destination file already exists (the
     * Value of {@link #COLUMN_REASON} when the requested destination file already exists (the
     * download manager will not overwrite an existing file).
     * download manager will not overwrite an existing file).
     */
     */
    public final static int ERROR_FILE_ALREADY_EXISTS = 1009;
    public final static int ERROR_FILE_ALREADY_EXISTS = 1009;


    /**
     * Value of {@link #COLUMN_REASON} when the download is paused because some network error
     * occurred and the download manager is waiting before retrying the request.
     */
    public final static int PAUSED_WAITING_TO_RETRY = 1;

    /**
     * Value of {@link #COLUMN_REASON} when the download is waiting for network connectivity to
     * proceed.
     */
    public final static int PAUSED_WAITING_FOR_NETWORK = 2;

    /**
     * Value of {@link #COLUMN_REASON} when the download exceeds a size limit for downloads over
     * the mobile network and the download manager is waiting for a Wi-Fi connection to proceed.
     */
    public final static int PAUSED_QUEUED_FOR_WIFI = 3;

    /**
     * Value of {@link #COLUMN_REASON} when the download is paused for some other reason.
     */
    public final static int PAUSED_UNKNOWN = 4;

    /**
    /**
     * Broadcast intent action sent by the download manager when a download completes.
     * Broadcast intent action sent by the download manager when a download completes.
     */
     */
@@ -236,7 +266,7 @@ public class DownloadManager {
        COLUMN_TOTAL_SIZE_BYTES,
        COLUMN_TOTAL_SIZE_BYTES,
        COLUMN_LOCAL_URI,
        COLUMN_LOCAL_URI,
        COLUMN_STATUS,
        COLUMN_STATUS,
        COLUMN_ERROR_CODE,
        COLUMN_REASON,
        COLUMN_BYTES_DOWNLOADED_SO_FAR,
        COLUMN_BYTES_DOWNLOADED_SO_FAR,
        COLUMN_LAST_MODIFIED_TIMESTAMP
        COLUMN_LAST_MODIFIED_TIMESTAMP
    };
    };
@@ -258,7 +288,7 @@ public class DownloadManager {
    };
    };


    private static final Set<String> LONG_COLUMNS = new HashSet<String>(
    private static final Set<String> LONG_COLUMNS = new HashSet<String>(
            Arrays.asList(COLUMN_ID, COLUMN_TOTAL_SIZE_BYTES, COLUMN_STATUS, COLUMN_ERROR_CODE,
            Arrays.asList(COLUMN_ID, COLUMN_TOTAL_SIZE_BYTES, COLUMN_STATUS, COLUMN_REASON,
                          COLUMN_BYTES_DOWNLOADED_SO_FAR, COLUMN_LAST_MODIFIED_TIMESTAMP));
                          COLUMN_BYTES_DOWNLOADED_SO_FAR, COLUMN_LAST_MODIFIED_TIMESTAMP));


    /**
    /**
@@ -617,8 +647,10 @@ public class DownloadManager {
                    parts.add(statusClause("=", Downloads.STATUS_RUNNING));
                    parts.add(statusClause("=", Downloads.STATUS_RUNNING));
                }
                }
                if ((mStatusFlags & STATUS_PAUSED) != 0) {
                if ((mStatusFlags & STATUS_PAUSED) != 0) {
                    parts.add(statusClause("=", Downloads.STATUS_PENDING_PAUSED));
                    parts.add(statusClause("=", Downloads.Impl.STATUS_PAUSED_BY_APP));
                    parts.add(statusClause("=", Downloads.STATUS_RUNNING_PAUSED));
                    parts.add(statusClause("=", Downloads.Impl.STATUS_WAITING_TO_RETRY));
                    parts.add(statusClause("=", Downloads.Impl.STATUS_WAITING_FOR_NETWORK));
                    parts.add(statusClause("=", Downloads.Impl.STATUS_QUEUED_FOR_WIFI));
                }
                }
                if ((mStatusFlags & STATUS_SUCCESSFUL) != 0) {
                if ((mStatusFlags & STATUS_SUCCESSFUL) != 0) {
                    parts.add(statusClause("=", Downloads.STATUS_SUCCESS));
                    parts.add(statusClause("=", Downloads.STATUS_SUCCESS));
@@ -914,8 +946,8 @@ public class DownloadManager {
            if (column.equals(COLUMN_STATUS)) {
            if (column.equals(COLUMN_STATUS)) {
                return translateStatus((int) getUnderlyingLong(Downloads.COLUMN_STATUS));
                return translateStatus((int) getUnderlyingLong(Downloads.COLUMN_STATUS));
            }
            }
            if (column.equals(COLUMN_ERROR_CODE)) {
            if (column.equals(COLUMN_REASON)) {
                return translateErrorCode((int) getUnderlyingLong(Downloads.COLUMN_STATUS));
                return getReason((int) getUnderlyingLong(Downloads.COLUMN_STATUS));
            }
            }
            if (column.equals(COLUMN_BYTES_DOWNLOADED_SO_FAR)) {
            if (column.equals(COLUMN_BYTES_DOWNLOADED_SO_FAR)) {
                return getUnderlyingLong(Downloads.COLUMN_CURRENT_BYTES);
                return getUnderlyingLong(Downloads.COLUMN_CURRENT_BYTES);
@@ -924,10 +956,36 @@ public class DownloadManager {
            return getUnderlyingLong(Downloads.COLUMN_LAST_MODIFICATION);
            return getUnderlyingLong(Downloads.COLUMN_LAST_MODIFICATION);
        }
        }


        private long translateErrorCode(int status) {
        private long getReason(int status) {
            if (translateStatus(status) != STATUS_FAILED) {
            switch (translateStatus(status)) {
                case STATUS_FAILED:
                    return getErrorCode(status);

                case STATUS_PAUSED:
                    return getPausedReason(status);

                default:
                    return 0; // arbitrary value when status is not an error
                    return 0; // arbitrary value when status is not an error
            }
            }
        }

        private long getPausedReason(int status) {
            switch (status) {
                case Downloads.Impl.STATUS_WAITING_TO_RETRY:
                    return PAUSED_WAITING_TO_RETRY;

                case Downloads.Impl.STATUS_WAITING_FOR_NETWORK:
                    return PAUSED_WAITING_FOR_NETWORK;

                case Downloads.Impl.STATUS_QUEUED_FOR_WIFI:
                    return PAUSED_QUEUED_FOR_WIFI;

                default:
                    return PAUSED_UNKNOWN;
            }
        }

        private long getErrorCode(int status) {
            if ((400 <= status && status < Downloads.Impl.MIN_ARTIFICIAL_ERROR_STATUS)
            if ((400 <= status && status < Downloads.Impl.MIN_ARTIFICIAL_ERROR_STATUS)
                    || (500 <= status && status < 600)) {
                    || (500 <= status && status < 600)) {
                // HTTP status code
                // HTTP status code
@@ -973,7 +1031,7 @@ public class DownloadManager {
            return super.getString(super.getColumnIndex(column));
            return super.getString(super.getColumnIndex(column));
        }
        }


        private long translateStatus(int status) {
        private int translateStatus(int status) {
            switch (status) {
            switch (status) {
                case Downloads.STATUS_PENDING:
                case Downloads.STATUS_PENDING:
                    return STATUS_PENDING;
                    return STATUS_PENDING;
@@ -981,8 +1039,10 @@ public class DownloadManager {
                case Downloads.STATUS_RUNNING:
                case Downloads.STATUS_RUNNING:
                    return STATUS_RUNNING;
                    return STATUS_RUNNING;


                case Downloads.STATUS_PENDING_PAUSED:
                case Downloads.Impl.STATUS_PAUSED_BY_APP:
                case Downloads.STATUS_RUNNING_PAUSED:
                case Downloads.Impl.STATUS_WAITING_TO_RETRY:
                case Downloads.Impl.STATUS_WAITING_FOR_NETWORK:
                case Downloads.Impl.STATUS_QUEUED_FOR_WIFI:
                    return STATUS_PAUSED;
                    return STATUS_PAUSED;


                case Downloads.STATUS_SUCCESS:
                case Downloads.STATUS_SUCCESS:
+17 −37
Original line number Original line Diff line number Diff line
@@ -377,16 +377,6 @@ public final class Downloads {
        return (status >= 100 && status < 200);
        return (status >= 100 && status < 200);
    }
    }


    /**
     * Returns whether the download is suspended. (i.e. whether the download
     * won't complete without some action from outside the download
     * manager).
     * @hide
     */
    public static boolean isStatusSuspended(int status) {
        return (status == STATUS_PENDING_PAUSED || status == STATUS_RUNNING_PAUSED);
    }

    /**
    /**
     * Returns whether the status is a success (i.e. 2xx).
     * Returns whether the status is a success (i.e. 2xx).
     * @hide
     * @hide
@@ -434,24 +424,12 @@ public final class Downloads {
     */
     */
    public static final int STATUS_PENDING = 190;
    public static final int STATUS_PENDING = 190;


    /**
     * This download hasn't stated yet and is paused
     * @hide
     */
    public static final int STATUS_PENDING_PAUSED = 191;

    /**
    /**
     * This download has started
     * This download has started
     * @hide
     * @hide
     */
     */
    public static final int STATUS_RUNNING = 192;
    public static final int STATUS_RUNNING = 192;


    /**
     * This download has started and is paused
     * @hide
     */
    public static final int STATUS_RUNNING_PAUSED = 193;

    /**
    /**
     * This download has successfully completed.
     * This download has successfully completed.
     * Warning: there might be other status values that indicate success
     * Warning: there might be other status values that indicate success
@@ -979,15 +957,6 @@ public final class Downloads {
            return (status >= 100 && status < 200);
            return (status >= 100 && status < 200);
        }
        }


        /**
         * Returns whether the download is suspended. (i.e. whether the download
         * won't complete without some action from outside the download
         * manager).
         */
        public static boolean isStatusSuspended(int status) {
            return (status == STATUS_PENDING_PAUSED || status == STATUS_RUNNING_PAUSED);
        }

        /**
        /**
         * Returns whether the status is a success (i.e. 2xx).
         * Returns whether the status is a success (i.e. 2xx).
         */
         */
@@ -1030,19 +999,30 @@ public final class Downloads {
        public static final int STATUS_PENDING = 190;
        public static final int STATUS_PENDING = 190;


        /**
        /**
         * This download hasn't stated yet and is paused
         * This download has started
         */
         */
        public static final int STATUS_PENDING_PAUSED = 191;
        public static final int STATUS_RUNNING = 192;


        /**
        /**
         * This download has started
         * This download has been paused by the owning app.
         */
         */
        public static final int STATUS_RUNNING = 192;
        public static final int STATUS_PAUSED_BY_APP = 193;

        /**
         * This download encountered some network error and is waiting before retrying the request.
         */
        public static final int STATUS_WAITING_TO_RETRY = 194;

        /**
         * This download is waiting for network connectivity to proceed.
         */
        public static final int STATUS_WAITING_FOR_NETWORK = 195;


        /**
        /**
         * This download has started and is paused
         * This download exceeded a size limit for mobile networks and is waiting for a Wi-Fi
         * connection to proceed.
         */
         */
        public static final int STATUS_RUNNING_PAUSED = 193;
        public static final int STATUS_QUEUED_FOR_WIFI = 196;


        /**
        /**
         * This download has successfully completed.
         * This download has successfully completed.
+4 −4
Original line number Original line Diff line number Diff line
@@ -120,7 +120,7 @@ public class DownloadManagerIntegrationTest extends DownloadManagerBaseTest {


        Cursor cursor = getCursor(dlRequest);
        Cursor cursor = getCursor(dlRequest);
        try {
        try {
            verifyInt(cursor, DownloadManager.COLUMN_ERROR_CODE, error);
            verifyInt(cursor, DownloadManager.COLUMN_REASON, error);
        } finally {
        } finally {
            cursor.close();
            cursor.close();
        }
        }
@@ -183,7 +183,7 @@ public class DownloadManagerIntegrationTest extends DownloadManagerBaseTest {
        Cursor cursor = getCursor(dlRequest);
        Cursor cursor = getCursor(dlRequest);
        try {
        try {
            verifyInt(cursor, DownloadManager.COLUMN_STATUS, DownloadManager.STATUS_FAILED);
            verifyInt(cursor, DownloadManager.COLUMN_STATUS, DownloadManager.STATUS_FAILED);
            verifyInt(cursor, DownloadManager.COLUMN_ERROR_CODE,
            verifyInt(cursor, DownloadManager.COLUMN_REASON,
                    DownloadManager.ERROR_CANNOT_RESUME);
                    DownloadManager.ERROR_CANNOT_RESUME);
        } finally {
        } finally {
            cursor.close();
            cursor.close();
@@ -269,7 +269,7 @@ public class DownloadManagerIntegrationTest extends DownloadManagerBaseTest {


            try {
            try {
                verifyInt(cursor, DownloadManager.COLUMN_STATUS, DownloadManager.STATUS_FAILED);
                verifyInt(cursor, DownloadManager.COLUMN_STATUS, DownloadManager.STATUS_FAILED);
                verifyInt(cursor, DownloadManager.COLUMN_ERROR_CODE,
                verifyInt(cursor, DownloadManager.COLUMN_REASON,
                        DownloadManager.ERROR_FILE_ERROR);
                        DownloadManager.ERROR_FILE_ERROR);
            } finally {
            } finally {
                cursor.close();
                cursor.close();
@@ -476,7 +476,7 @@ public class DownloadManagerIntegrationTest extends DownloadManagerBaseTest {
        // For the last download we should have failed b/c there is not enough space left in cache
        // For the last download we should have failed b/c there is not enough space left in cache
        Cursor cursor = getCursor(dlRequest);
        Cursor cursor = getCursor(dlRequest);
        try {
        try {
            verifyInt(cursor, DownloadManager.COLUMN_ERROR_CODE,
            verifyInt(cursor, DownloadManager.COLUMN_REASON,
                    DownloadManager.ERROR_INSUFFICIENT_SPACE);
                    DownloadManager.ERROR_INSUFFICIENT_SPACE);
        } finally {
        } finally {
            cursor.close();
            cursor.close();
+1 −1
Original line number Original line Diff line number Diff line
@@ -145,7 +145,7 @@ public class DownloadManagerStressTest extends DownloadManagerBaseTest {


            cursor = getCursor(dlRequest);
            cursor = getCursor(dlRequest);
            verifyInt(cursor, DownloadManager.COLUMN_STATUS, DownloadManager.STATUS_FAILED);
            verifyInt(cursor, DownloadManager.COLUMN_STATUS, DownloadManager.STATUS_FAILED);
            verifyInt(cursor, DownloadManager.COLUMN_ERROR_CODE,
            verifyInt(cursor, DownloadManager.COLUMN_REASON,
                    DownloadManager.ERROR_INSUFFICIENT_SPACE);
                    DownloadManager.ERROR_INSUFFICIENT_SPACE);
        } finally {
        } finally {
            if (cursor != null) {
            if (cursor != null) {