1d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd/*
2d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Copyright (C) 2008 The Android Open Source Project
3d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd *
4d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Licensed under the Apache License, Version 2.0 (the "License");
5d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * you may not use this file except in compliance with the License.
6d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * You may obtain a copy of the License at
7d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd *
8d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd *      http://www.apache.org/licenses/LICENSE-2.0
9d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd *
10d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Unless required by applicable law or agreed to in writing, software
11d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * distributed under the License is distributed on an "AS IS" BASIS,
12d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * See the License for the specific language governing permissions and
14d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * limitations under the License.
15d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd */
16d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
17d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddpackage com.android.messaging.mmslib;
18d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
19d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport android.app.DownloadManager;
20d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport android.content.Context;
21d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport android.net.Uri;
22d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport android.provider.BaseColumns;
23d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
24d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd/**
25d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * The Download Manager
26d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd *
27d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * @pending
28d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd */
29d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddpublic final class Downloads {
30d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd    private Downloads() {}
31d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
32d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd    /**
33d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd     * Implementation details
34d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd     *
35d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd     * Exposes constants used to interact with the download manager's
36d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd     * content provider.
37d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd     * The constants URI ... STATUS are the names of columns in the downloads table.
38d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd     *
39d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd     * @hide
40d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd     */
41d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd    public static final class Impl implements BaseColumns {
42d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        private Impl() {}
43d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
44d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
45d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The permission to access the download manager
46d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
47d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String PERMISSION_ACCESS = "android.permission.ACCESS_DOWNLOAD_MANAGER";
48d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
49d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
50d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The permission to access the download manager's advanced functions
51d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
52d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String PERMISSION_ACCESS_ADVANCED =
53d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                "android.permission.ACCESS_DOWNLOAD_MANAGER_ADVANCED";
54d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
55d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
56d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The permission to access the all the downloads in the manager.
57d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
58d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String PERMISSION_ACCESS_ALL =
59d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                "android.permission.ACCESS_ALL_DOWNLOADS";
60d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
61d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
62d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The permission to directly access the download manager's cache
63d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * directory
64d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
65d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String PERMISSION_CACHE = "android.permission.ACCESS_CACHE_FILESYSTEM";
66d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
67d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
68d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The permission to send broadcasts on download completion
69d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
70d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String PERMISSION_SEND_INTENTS =
71d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                "android.permission.SEND_DOWNLOAD_COMPLETED_INTENTS";
72d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
73d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
74d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The permission to download files to the cache partition that won't be automatically
75d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * purged when space is needed.
76d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
77d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String PERMISSION_CACHE_NON_PURGEABLE =
78d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                "android.permission.DOWNLOAD_CACHE_NON_PURGEABLE";
79d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
80d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
81d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The permission to download files without any system notification being shown.
82d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
83d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String PERMISSION_NO_NOTIFICATION =
84d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                "android.permission.DOWNLOAD_WITHOUT_NOTIFICATION";
85d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
86d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
87d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The content:// URI to access downloads owned by the caller's UID.
88d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
89d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final Uri CONTENT_URI =
90d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                Uri.parse("content://downloads/my_downloads");
91d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
92d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
93d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The content URI for accessing all downloads across all UIDs (requires the
94d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * ACCESS_ALL_DOWNLOADS permission).
95d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
96d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final Uri ALL_DOWNLOADS_CONTENT_URI =
97d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                Uri.parse("content://downloads/all_downloads");
98d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
99d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /** URI segment to access a publicly accessible downloaded file */
100d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String PUBLICLY_ACCESSIBLE_DOWNLOADS_URI_SEGMENT = "public_downloads";
101d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
102d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
103d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The content URI for accessing publicly accessible downloads (i.e., it requires no
104d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * permissions to access this downloaded file)
105d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
106d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final Uri PUBLICLY_ACCESSIBLE_DOWNLOADS_URI =
107d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                Uri.parse("content://downloads/" + PUBLICLY_ACCESSIBLE_DOWNLOADS_URI_SEGMENT);
108d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
109d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
110d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Broadcast Action: this is sent by the download manager to the app
111d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * that had initiated a download when that download completes. The
112d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * download's content: uri is specified in the intent's data.
113d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
114d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String ACTION_DOWNLOAD_COMPLETED =
115d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                "android.intent.action.DOWNLOAD_COMPLETED";
116d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
117d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
118d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Broadcast Action: this is sent by the download manager to the app
119d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * that had initiated a download when the user selects the notification
120d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * associated with that download. The download's content: uri is specified
121d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * in the intent's data if the click is associated with a single download,
122d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * or Downloads.CONTENT_URI if the notification is associated with
123d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * multiple downloads.
124d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Note: this is not currently sent for downloads that have completed
125d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * successfully.
126d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
127d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String ACTION_NOTIFICATION_CLICKED =
128d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                "android.intent.action.DOWNLOAD_NOTIFICATION_CLICKED";
129d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
130d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
131d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column containing the URI of the data being downloaded.
132d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: TEXT</P>
133d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Init/Read</P>
134d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
135d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_URI = "uri";
136d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
137d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
138d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column containing application-specific data.
139d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: TEXT</P>
140d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Init/Read/Write</P>
141d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
142d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_APP_DATA = "entity";
143d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
144d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
145d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column containing the flags that indicates whether
146d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * the initiating application is capable of verifying the integrity of
147d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * the downloaded file. When this flag is set, the download manager
148d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * performs downloads and reports success even in some situations where
149d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * it can't guarantee that the download has completed (e.g. when doing
150d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * a byte-range request without an ETag, or when it can't determine
151d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * whether a download fully completed).
152d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: BOOLEAN</P>
153d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Init</P>
154d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
155d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_NO_INTEGRITY = "no_integrity";
156d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
157d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
158d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column containing the filename that the initiating
159d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * application recommends. When possible, the download manager will attempt
160d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * to use this filename, or a variation, as the actual name for the file.
161d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: TEXT</P>
162d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Init</P>
163d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
164d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_FILE_NAME_HINT = "hint";
165d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
166d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
167d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column containing the filename where the downloaded data
168d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * was actually stored.
169d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: TEXT</P>
170d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Read</P>
171d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
172d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String _DATA = "_data";
173d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
174d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
175d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column containing the MIME type of the downloaded data.
176d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: TEXT</P>
177d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Init/Read</P>
178d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
179d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_MIME_TYPE = "mimetype";
180d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
181d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
182d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column containing the flag that controls the destination
183d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * of the download. See the DESTINATION_* constants for a list of legal values.
184d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: INTEGER</P>
185d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Init</P>
186d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
187d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_DESTINATION = "destination";
188d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
189d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
190d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column containing the flags that controls whether the
191d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * download is displayed by the UI. See the VISIBILITY_* constants for
192d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * a list of legal values.
193d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: INTEGER</P>
194d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Init/Read/Write</P>
195d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
196d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_VISIBILITY = "visibility";
197d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
198d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
199d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column containing the current control state  of the download.
200d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Applications can write to this to control (pause/resume) the download.
201d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * the CONTROL_* constants for a list of legal values.
202d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: INTEGER</P>
203d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Read</P>
204d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
205d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_CONTROL = "control";
206d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
207d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
208d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column containing the current status of the download.
209d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Applications can read this to follow the progress of each download. See
210d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * the STATUS_* constants for a list of legal values.
211d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: INTEGER</P>
212d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Read</P>
213d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
214d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_STATUS = "status";
215d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
216d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
217d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column containing the date at which some interesting
218d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * status changed in the download. Stored as a System.currentTimeMillis()
219d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * value.
220d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: BIGINT</P>
221d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Read</P>
222d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
223d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_LAST_MODIFICATION = "lastmod";
224d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
225d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
226d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column containing the package name of the application
227d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * that initiating the download. The download manager will send
228d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * notifications to a component in this package when the download completes.
229d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: TEXT</P>
230d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Init/Read</P>
231d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
232d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_NOTIFICATION_PACKAGE = "notificationpackage";
233d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
234d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
235d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column containing the component name of the class that
236d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * will receive notifications associated with the download. The
237d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * package/class combination is passed to
238d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Intent.setClassName(String,String).
239d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: TEXT</P>
240d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Init/Read</P>
241d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
242d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_NOTIFICATION_CLASS = "notificationclass";
243d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
244d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
245d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * If extras are specified when requesting a download they will be provided in the intent
246d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * that is sent to the specified class and package when a download has finished.
247d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: TEXT</P>
248d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Init</P>
249d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
250d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_NOTIFICATION_EXTRAS = "notificationextras";
251d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
252d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
253d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column contain the values of the cookie to be used for
254d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * the download. This is used directly as the value for the Cookie: HTTP
255d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * header that gets sent with the request.
256d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: TEXT</P>
257d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Init</P>
258d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
259d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_COOKIE_DATA = "cookiedata";
260d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
261d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
262d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column containing the user agent that the initiating
263d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * application wants the download manager to use for this download.
264d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: TEXT</P>
265d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Init</P>
266d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
267d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_USER_AGENT = "useragent";
268d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
269d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
270d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column containing the referer (sic) that the initiating
271d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * application wants the download manager to use for this download.
272d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: TEXT</P>
273d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Init</P>
274d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
275d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_REFERER = "referer";
276d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
277d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
278d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column containing the total size of the file being
279d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * downloaded.
280d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: INTEGER</P>
281d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Read</P>
282d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
283d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_TOTAL_BYTES = "total_bytes";
284d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
285d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
286d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column containing the size of the part of the file that
287d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * has been downloaded so far.
288d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: INTEGER</P>
289d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Read</P>
290d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
291d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_CURRENT_BYTES = "current_bytes";
292d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
293d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
294d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column where the initiating application can provide the
295d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * UID of another application that is allowed to access this download. If
296d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * multiple applications share the same UID, all those applications will be
297d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * allowed to access this download. This column can be updated after the
298d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * download is initiated. This requires the permission
299d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * android.permission.ACCESS_DOWNLOAD_MANAGER_ADVANCED.
300d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: INTEGER</P>
301d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Init</P>
302d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
303d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_OTHER_UID = "otheruid";
304d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
305d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
306d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column where the initiating application can provided the
307d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * title of this download. The title will be displayed ito the user in the
308d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * list of downloads.
309d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: TEXT</P>
310d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Init/Read/Write</P>
311d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
312d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_TITLE = "title";
313d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
314d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
315d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column where the initiating application can provide the
316d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * description of this download. The description will be displayed to the
317d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * user in the list of downloads.
318d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: TEXT</P>
319d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Init/Read/Write</P>
320d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
321d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_DESCRIPTION = "description";
322d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
323d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
324d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column indicating whether the download was requesting through the public
325d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * API.  This controls some differences in behavior.
326d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: BOOLEAN</P>
327d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Init/Read</P>
328d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
329d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_IS_PUBLIC_API = "is_public_api";
330d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
331d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
332d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column holding a bitmask of allowed network types.  This is only used for
333d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * public API downloads.
334d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: INTEGER</P>
335d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Init/Read</P>
336d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
337d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_ALLOWED_NETWORK_TYPES = "allowed_network_types";
338d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
339d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
340d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column indicating whether roaming connections can be used.  This is only
341d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * used for public API downloads.
342d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: BOOLEAN</P>
343d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Init/Read</P>
344d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
345d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_ALLOW_ROAMING = "allow_roaming";
346d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
347d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
348d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The name of the column indicating whether metered connections can be used.  This is only
349d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * used for public API downloads.
350d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: BOOLEAN</P>
351d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Init/Read</P>
352d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
353d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_ALLOW_METERED = "allow_metered";
354d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
355d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
356d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Whether or not this download should be displayed in the system's Downloads UI.  Defaults
357d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * to true.
358d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: INTEGER</P>
359d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Init/Read</P>
360d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
361d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_IS_VISIBLE_IN_DOWNLOADS_UI = "is_visible_in_downloads_ui";
362d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
363d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
364d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * If true, the user has confirmed that this download can proceed over the mobile network
365d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * even though it exceeds the recommended maximum size.
366d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: BOOLEAN</P>
367d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
368d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_BYPASS_RECOMMENDED_SIZE_LIMIT =
369d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd            "bypass_recommended_size_limit";
370d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
371d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
372d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Set to true if this download is deleted. It is completely removed from the database
373d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * when MediaProvider database also deletes the metadata asociated with this downloaded
374d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * file.
375d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: BOOLEAN</P>
376d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Read</P>
377d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
378d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_DELETED = "deleted";
379d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
380d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
381d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The URI to the corresponding entry in MediaProvider for this downloaded entry. It is
382d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * used to delete the entries from MediaProvider database when it is deleted from the
383d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * downloaded list.
384d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: TEXT</P>
385d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Owner can Read</P>
386d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
387d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_MEDIAPROVIDER_URI = "mediaprovider_uri";
388d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
389d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
390d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The column that is used to remember whether the media scanner was invoked.
391d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * It can take the values: null or 0(not scanned), 1(scanned), 2 (not scannable).
392d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: TEXT</P>
393d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
394d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_MEDIA_SCANNED = "scanned";
395d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
396d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
397d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The column with errorMsg for a failed downloaded.
398d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Used only for debugging purposes.
399d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: TEXT</P>
400d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
401d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_ERROR_MSG = "errorMsg";
402d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
403d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
404d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         *  This column stores the source of the last update to this row.
405d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         *  This column is only for internal use.
406d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         *  Valid values are indicated by LAST_UPDATESRC_* constants.
407d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * <P>Type: INT</P>
408d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
409d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_LAST_UPDATESRC = "lastUpdateSrc";
410d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
411d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /** The column that is used to count retries */
412d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final String COLUMN_FAILED_CONNECTIONS = "numfailed";
413d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
414d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
415d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * default value for {@link #COLUMN_LAST_UPDATESRC}.
416d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This value is used when this column's value is not relevant.
417d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
418d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int LAST_UPDATESRC_NOT_RELEVANT = 0;
419d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
420d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
421d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * One of the values taken by {@link #COLUMN_LAST_UPDATESRC}.
422d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This value is used when the update is NOT to be relayed to the DownloadService
423d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * (and thus spare DownloadService from scanning the database when this change occurs)
424d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
425d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int LAST_UPDATESRC_DONT_NOTIFY_DOWNLOADSVC = 1;
426d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
427d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /*
428d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Lists the destinations that an application can specify for a download.
429d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
430d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
431d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
432d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download will be saved to the external storage. This is the
433d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * default behavior, and should be used for any file that the user
434d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * can freely access, copy, delete. Even with that destination,
435d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * unencrypted DRM files are saved in secure internal storage.
436d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Downloads to the external destination only write files for which
437d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * there is a registered handler. The resulting files are accessible
438d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * by filename to all applications.
439d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
440d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int DESTINATION_EXTERNAL = 0;
441d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
442d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
443d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download will be saved to the download manager's private
444d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * partition. This is the behavior used by applications that want to
445d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * download private files that are used and deleted soon after they
446d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * get downloaded. All file types are allowed, and only the initiating
447d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * application can access the file (indirectly through a content
448d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * provider). This requires the
449d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * android.permission.ACCESS_DOWNLOAD_MANAGER_ADVANCED permission.
450d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
451d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int DESTINATION_CACHE_PARTITION = 1;
452d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
453d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
454d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download will be saved to the download manager's private
455d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * partition and will be purged as necessary to make space. This is
456d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * for private files (similar to CACHE_PARTITION) that aren't deleted
457d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * immediately after they are used, and are kept around by the download
458d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * manager as long as space is available.
459d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
460d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int DESTINATION_CACHE_PARTITION_PURGEABLE = 2;
461d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
462d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
463d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download will be saved to the download manager's private
464d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * partition, as with DESTINATION_CACHE_PARTITION, but the download
465d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * will not proceed if the user is on a roaming data connection.
466d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
467d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int DESTINATION_CACHE_PARTITION_NOROAMING = 3;
468d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
469d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
470d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download will be saved to the location given by the file URI in
471d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * {@link #COLUMN_FILE_NAME_HINT}.
472d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
473d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int DESTINATION_FILE_URI = 4;
474d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
475d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
476d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download will be saved to the system cache ("/cache")
477d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * partition. This option is only used by system apps and so it requires
478d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * android.permission.ACCESS_CACHE_FILESYSTEM permission.
479d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
480d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int DESTINATION_SYSTEMCACHE_PARTITION = 5;
481d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
482d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
483d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download was completed by the caller (i.e., NOT downloadmanager)
484d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * and caller wants to have this download displayed in Downloads App.
485d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
486d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int DESTINATION_NON_DOWNLOADMANAGER_DOWNLOAD = 6;
487d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
488d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
489d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download is allowed to run.
490d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
491d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int CONTROL_RUN = 0;
492d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
493d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
494d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download must pause at the first opportunity.
495d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
496d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int CONTROL_PAUSED = 1;
497d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
498d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /*
499d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Lists the states that the download manager can set on a download
500d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * to notify applications of the download progress.
501d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The codes follow the HTTP families:<br>
502d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * 1xx: informational<br>
503d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * 2xx: success<br>
504d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * 3xx: redirects (not used by the download manager)<br>
505d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * 4xx: client errors<br>
506d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * 5xx: server errors
507d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
508d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
509d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
510d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Returns whether the status is informational (i.e. 1xx).
511d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
512d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static boolean isStatusInformational(int status) {
513d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd            return (status >= 100 && status < 200);
514d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        }
515d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
516d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
517d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Returns whether the status is a success (i.e. 2xx).
518d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
519d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static boolean isStatusSuccess(int status) {
520d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd            return (status >= 200 && status < 300);
521d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        }
522d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
523d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
524d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Returns whether the status is an error (i.e. 4xx or 5xx).
525d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
526d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static boolean isStatusError(int status) {
527d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd            return (status >= 400 && status < 600);
528d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        }
529d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
530d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
531d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Returns whether the status is a client error (i.e. 4xx).
532d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
533d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static boolean isStatusClientError(int status) {
534d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd            return (status >= 400 && status < 500);
535d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        }
536d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
537d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
538d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Returns whether the status is a server error (i.e. 5xx).
539d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
540d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static boolean isStatusServerError(int status) {
541d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd            return (status >= 500 && status < 600);
542d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        }
543d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
544d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
545d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * this method determines if a notification should be displayed for a
546d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * given {@link #COLUMN_VISIBILITY} value
547d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * @param visibility the value of {@link #COLUMN_VISIBILITY}.
548d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * @return true if the notification should be displayed. false otherwise.
549d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
550d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static boolean isNotificationToBeDisplayed(int visibility) {
551d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd            return visibility == DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED ||
552d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                    visibility == DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION;
553d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        }
554d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
555d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
556d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Returns whether the download has completed (either with success or
557d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * error).
558d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
559d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static boolean isStatusCompleted(int status) {
560d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd            return (status >= 200 && status < 300) || (status >= 400 && status < 600);
561d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        }
562d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
563d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
564d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download hasn't stated yet
565d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
566d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_PENDING = 190;
567d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
568d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
569d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download has started
570d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
571d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_RUNNING = 192;
572d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
573d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
574d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download has been paused by the owning app.
575d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
576d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_PAUSED_BY_APP = 193;
577d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
578d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
579d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download encountered some network error and is waiting before retrying the request.
580d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
581d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_WAITING_TO_RETRY = 194;
582d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
583d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
584d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download is waiting for network connectivity to proceed.
585d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
586d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_WAITING_FOR_NETWORK = 195;
587d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
588d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
589d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download exceeded a size limit for mobile networks and is waiting for a Wi-Fi
590d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * connection to proceed.
591d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
592d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_QUEUED_FOR_WIFI = 196;
593d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
594d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
595d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download couldn't be completed due to insufficient storage
596d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * space.  Typically, this is because the SD card is full.
597d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
598d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_INSUFFICIENT_SPACE_ERROR = 198;
599d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
600d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
601d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download couldn't be completed because no external storage
602d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * device was found.  Typically, this is because the SD card is not
603d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * mounted.
604d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
605d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_DEVICE_NOT_FOUND_ERROR = 199;
606d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
607d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
608d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download has successfully completed.
609d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Warning: there might be other status values that indicate success
610d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * in the future.
611d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Use isSucccess() to capture the entire category.
612d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
613d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_SUCCESS = 200;
614d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
615d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
616d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This request couldn't be parsed. This is also used when processing
617d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * requests with unknown/unsupported URI schemes.
618d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
619d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_BAD_REQUEST = 400;
620d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
621d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
622d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download can't be performed because the content type cannot be
623d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * handled.
624d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
625d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_NOT_ACCEPTABLE = 406;
626d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
627d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
628d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download cannot be performed because the length cannot be
629d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * determined accurately. This is the code for the HTTP error "Length
630d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Required", which is typically used when making requests that require
631d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * a content length but don't have one, and it is also used in the
632d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * client when a response is received whose length cannot be determined
633d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * accurately (therefore making it impossible to know when a download
634d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * completes).
635d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
636d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_LENGTH_REQUIRED = 411;
637d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
638d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
639d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download was interrupted and cannot be resumed.
640d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This is the code for the HTTP error "Precondition Failed", and it is
641d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * also used in situations where the client doesn't have an ETag at all.
642d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
643d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_PRECONDITION_FAILED = 412;
644d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
645d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
646d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The lowest-valued error status that is not an actual HTTP status code.
647d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
648d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int MIN_ARTIFICIAL_ERROR_STATUS = 488;
649d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
650d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
651d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * The requested destination file already exists.
652d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
653d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_FILE_ALREADY_EXISTS_ERROR = 488;
654d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
655d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
656d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Some possibly transient error occurred, but we can't resume the download.
657d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
658d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_CANNOT_RESUME = 489;
659d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
660d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
661d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download was canceled
662d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
663d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_CANCELED = 490;
664d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
665d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
666d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download has completed with an error.
667d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Warning: there will be other status values that indicate errors in
668d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * the future. Use isStatusError() to capture the entire category.
669d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
670d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_UNKNOWN_ERROR = 491;
671d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
672d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
673d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download couldn't be completed because of a storage issue.
674d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Typically, that's because the filesystem is missing or full.
675d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Use the more specific {@link #STATUS_INSUFFICIENT_SPACE_ERROR}
676d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * and {@link #STATUS_DEVICE_NOT_FOUND_ERROR} when appropriate.
677d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
678d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_FILE_ERROR = 492;
679d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
680d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
681d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download couldn't be completed because of an HTTP
682d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * redirect response that the download manager couldn't
683d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * handle.
684d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
685d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_UNHANDLED_REDIRECT = 493;
686d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
687d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
688d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download couldn't be completed because of an
689d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * unspecified unhandled HTTP code.
690d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
691d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_UNHANDLED_HTTP_CODE = 494;
692d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
693d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
694d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download couldn't be completed because of an
695d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * error receiving or processing data at the HTTP level.
696d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
697d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_HTTP_DATA_ERROR = 495;
698d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
699d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
700d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download couldn't be completed because of an
701d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * HttpException while setting up the request.
702d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
703d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_HTTP_EXCEPTION = 496;
704d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
705d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
706d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download couldn't be completed because there were
707d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * too many redirects.
708d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
709d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_TOO_MANY_REDIRECTS = 497;
710d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
711d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
712d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download has failed because requesting application has been
713d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * blocked by {@link NetworkPolicyManager}.
714d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         *
715d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * @hide
716d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * @deprecated since behavior now uses
717d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         *             {@link #STATUS_WAITING_FOR_NETWORK}
718d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
719d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        @Deprecated
720d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int STATUS_BLOCKED = 498;
721d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
722d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /** {@hide} */
723d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static String statusToString(int status) {
724d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd            switch (status) {
725d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_PENDING: return "PENDING";
726d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_RUNNING: return "RUNNING";
727d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_PAUSED_BY_APP: return "PAUSED_BY_APP";
728d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_WAITING_TO_RETRY: return "WAITING_TO_RETRY";
729d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_WAITING_FOR_NETWORK: return "WAITING_FOR_NETWORK";
730d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_QUEUED_FOR_WIFI: return "QUEUED_FOR_WIFI";
731d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_INSUFFICIENT_SPACE_ERROR: return "INSUFFICIENT_SPACE_ERROR";
732d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_DEVICE_NOT_FOUND_ERROR: return "DEVICE_NOT_FOUND_ERROR";
733d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_SUCCESS: return "SUCCESS";
734d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_BAD_REQUEST: return "BAD_REQUEST";
735d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_NOT_ACCEPTABLE: return "NOT_ACCEPTABLE";
736d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_LENGTH_REQUIRED: return "LENGTH_REQUIRED";
737d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_PRECONDITION_FAILED: return "PRECONDITION_FAILED";
738d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_FILE_ALREADY_EXISTS_ERROR: return "FILE_ALREADY_EXISTS_ERROR";
739d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_CANNOT_RESUME: return "CANNOT_RESUME";
740d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_CANCELED: return "CANCELED";
741d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_UNKNOWN_ERROR: return "UNKNOWN_ERROR";
742d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_FILE_ERROR: return "FILE_ERROR";
743d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_UNHANDLED_REDIRECT: return "UNHANDLED_REDIRECT";
744d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_UNHANDLED_HTTP_CODE: return "UNHANDLED_HTTP_CODE";
745d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_HTTP_DATA_ERROR: return "HTTP_DATA_ERROR";
746d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_HTTP_EXCEPTION: return "HTTP_EXCEPTION";
747d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_TOO_MANY_REDIRECTS: return "TOO_MANY_REDIRECTS";
748d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                case STATUS_BLOCKED: return "BLOCKED";
749d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                default: return Integer.toString(status);
750d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd            }
751d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        }
752d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
753d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
754d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download is visible but only shows in the notifications
755d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * while it's in progress.
756d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
757d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int VISIBILITY_VISIBLE = DownloadManager.Request.VISIBILITY_VISIBLE;
758d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
759d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
760d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download is visible and shows in the notifications while
761d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * in progress and after completion.
762d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
763d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int VISIBILITY_VISIBLE_NOTIFY_COMPLETED =
764d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED;
765d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
766d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
767d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * This download doesn't show in the UI or in the notifications.
768d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
769d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static final int VISIBILITY_HIDDEN = DownloadManager.Request.VISIBILITY_HIDDEN;
770d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
771d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        /**
772d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         * Constants related to HTTP request headers associated with each download.
773d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd         */
774d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        public static class RequestHeaders {
775d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd            public static final String HEADERS_DB_TABLE = "request_headers";
776d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd            public static final String COLUMN_DOWNLOAD_ID = "download_id";
777d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd            public static final String COLUMN_HEADER = "header";
778d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd            public static final String COLUMN_VALUE = "value";
779d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
780d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd            /**
781d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd             * Path segment to add to a download URI to retrieve request headers
782d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd             */
783d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd            public static final String URI_SEGMENT = "headers";
784d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
785d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd            /**
786d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd             * Prefix for ContentValues keys that contain HTTP header lines, to be passed to
787d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd             * DownloadProvider.insert().
788d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd             */
789d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd            public static final String INSERT_KEY_PREFIX = "http_header_";
790d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        }
791d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd    }
792d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
793d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd    /**
794d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd     * Query where clause for general querying.
795d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd     */
796d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd    private static final String QUERY_WHERE_CLAUSE = Impl.COLUMN_NOTIFICATION_PACKAGE + "=? AND "
797d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd            + Impl.COLUMN_NOTIFICATION_CLASS + "=?";
798d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
799d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd    /**
800d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd     * Delete all the downloads for a package/class pair.
801d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd     */
802d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd    public static final void removeAllDownloadsByPackage(
803d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd            Context context, String notificationPackage, String notificationClass) {
804d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        context.getContentResolver().delete(Impl.CONTENT_URI, QUERY_WHERE_CLAUSE,
805d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                new String[] { notificationPackage, notificationClass });
806d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd    }
807d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd}
808